主播薪资转代理日期,日限额限制

This commit is contained in:
2025-08-05 15:50:34 +08:00
parent c796d496d6
commit 8a4ba5f878
2 changed files with 39 additions and 46 deletions

View File

@@ -15,9 +15,9 @@ import com.accompany.core.service.SysConfService;
import com.accompany.core.util.I18NMessageSourceUtil; import com.accompany.core.util.I18NMessageSourceUtil;
import com.accompany.payment.service.RechargeUserService; import com.accompany.payment.service.RechargeUserService;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -69,38 +69,34 @@ public class GuildUsdToRechargeUserLimitService {
List<Integer> enableDayOfMonth = GuildConstant.RoleType.OWNER.equals(guildMember.getRoleType())? List<Integer> enableDayOfMonth = GuildConstant.RoleType.OWNER.equals(guildMember.getRoleType())?
configDto.getOwnerEnableDayOfMonth(): configDto.getOwnerEnableDayOfMonth():
configDto.getMemberEnableDayOfMonth(); configDto.getMemberEnableDayOfMonth();
if (CollectionUtils.isEmpty(enableDayOfMonth)){
return;
}
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(guildMember.getPartitionId()); PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(guildMember.getPartitionId());
ZonedDateTime zdt = DateTimeUtil.getDateTimeByZoneId(partitionEnum.getZoneId()); ZonedDateTime zdt = DateTimeUtil.getDateTimeByZoneId(partitionEnum.getZoneId());
if (!enableDayOfMonth.contains(zdt.getDayOfMonth())){
if (CollectionUtils.isNotEmpty(enableDayOfMonth) && !enableDayOfMonth.contains(zdt.getDayOfMonth())){
String enableDayOfMonthStr = enableDayOfMonth.stream().sorted().map(String::valueOf).collect(Collectors.joining(",")); String enableDayOfMonthStr = enableDayOfMonth.stream().sorted().map(String::valueOf).collect(Collectors.joining(","));
String errorMsg = I18NMessageSourceUtil.getMessage(I18nAlertEnum.GUILD_USD_TO_RECHARGE_USER_DAY_OF_MONTH_LIMIT, new Object[]{enableDayOfMonthStr}, guildMember.getPartitionId()); String errorMsg = I18NMessageSourceUtil.getMessage(I18nAlertEnum.GUILD_USD_TO_RECHARGE_USER_DAY_OF_MONTH_LIMIT, new Object[]{enableDayOfMonthStr}, guildMember.getPartitionId());
throw new ServiceException(errorMsg); throw new ServiceException(errorMsg);
} }
if (null == configDto.getDayNumLimit() || BigDecimal.ZERO.compareTo(configDto.getDayNumLimit()) <= 0){ if (null != configDto.getDayNumLimit() && BigDecimal.ZERO.compareTo(configDto.getDayNumLimit()) > 0){
return; ZonedDateTime todayStartTime = zdt.withHour(0).withMinute(0).withSecond(0).withNano(0);
Date systemStartTime = DateTimeUtil.converLocalDateTimeToDate(todayStartTime.withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime());
String systemStartTimeStr = DateTimeUtil.convertDateTime(systemStartTime);
ZonedDateTime todayEndTime = zdt.withHour(23).withMinute(59).withSecond(59).withNano(999999999);
Date systemEndTime = DateTimeUtil.converLocalDateTimeToDate(todayEndTime.withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime());
String systemEndTimeStr = DateTimeUtil.convertDateTime(systemEndTime);
Double todayNum = guildUsdBillRecordMapper.sum(guildMember.getPartitionId(), guildMember.getUid(), null,
systemStartTimeStr, systemEndTimeStr, GuildUsdOperateTypeEnum.USD_TO_RECHARGE_USER.getType());
BigDecimal todayNumB = null == todayNum? BigDecimal.ZERO: BigDecimal.valueOf(todayNum);
BigDecimal judgeNum = todayNumB.add(guildUsdNum);
if (judgeNum.compareTo(configDto.getDayNumLimit()) > 0){
String errorMsg = I18NMessageSourceUtil.getMessage(I18nAlertEnum.GUILD_USD_TO_RECHARGE_USER_DAY_NUM_LIMIT, null, guildMember.getPartitionId());
throw new ServiceException(errorMsg);
}
} }
ZonedDateTime todayStartTime = zdt.withHour(0).withMinute(0).withSecond(0).withNano(0);
Date systemStartTime = DateTimeUtil.converLocalDateTimeToDate(todayStartTime.withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime());
String systemStartTimeStr = DateTimeUtil.convertDateTime(systemStartTime);
ZonedDateTime todayEndTime = zdt.withHour(23).withMinute(59).withSecond(59).withNano(999999999);
Date systemEndTime = DateTimeUtil.converLocalDateTimeToDate(todayEndTime.withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime());
String systemEndTimeStr = DateTimeUtil.convertDateTime(systemEndTime);
Double todayNum = guildUsdBillRecordMapper.sum(guildMember.getPartitionId(), guildMember.getUid(), null,
systemStartTimeStr, systemEndTimeStr, GuildUsdOperateTypeEnum.USD_TO_RECHARGE_USER.getType());
BigDecimal todayNumB = null == todayNum? BigDecimal.ZERO: BigDecimal.valueOf(todayNum);
BigDecimal judgeNum = todayNumB.add(guildUsdNum);
if (judgeNum.compareTo(configDto.getDayNumLimit()) > 0){
String errorMsg = I18NMessageSourceUtil.getMessage(I18nAlertEnum.GUILD_USD_TO_RECHARGE_USER_DAY_NUM_LIMIT, null, guildMember.getPartitionId());
throw new ServiceException(errorMsg);
}
} }
public GuildUsdToRechargeUserLimitConfigDto getConfig(){ public GuildUsdToRechargeUserLimitConfigDto getConfig(){

View File

@@ -15,9 +15,9 @@ import com.accompany.core.service.SysConfService;
import com.accompany.core.util.I18NMessageSourceUtil; import com.accompany.core.util.I18NMessageSourceUtil;
import com.accompany.payment.service.RechargeUserService; import com.accompany.payment.service.RechargeUserService;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -69,36 +69,33 @@ public class GameUsdToRechargeUserLimitService {
List<Integer> enableDayOfMonth = GuildConstant.RoleType.OWNER.equals(guildMember.getRoleType())? List<Integer> enableDayOfMonth = GuildConstant.RoleType.OWNER.equals(guildMember.getRoleType())?
configDto.getOwnerEnableDayOfMonth(): configDto.getOwnerEnableDayOfMonth():
configDto.getMemberEnableDayOfMonth(); configDto.getMemberEnableDayOfMonth();
if (CollectionUtils.isEmpty(enableDayOfMonth)){
return;
}
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(guildMember.getPartitionId()); PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(guildMember.getPartitionId());
ZonedDateTime zdt = DateTimeUtil.getDateTimeByZoneId(partitionEnum.getZoneId()); ZonedDateTime zdt = DateTimeUtil.getDateTimeByZoneId(partitionEnum.getZoneId());
if (!enableDayOfMonth.contains(zdt.getDayOfMonth())){
if (CollectionUtils.isNotEmpty(enableDayOfMonth) && !enableDayOfMonth.contains(zdt.getDayOfMonth())){
String enableDayOfMonthStr = enableDayOfMonth.stream().sorted().map(String::valueOf).collect(Collectors.joining(",")); String enableDayOfMonthStr = enableDayOfMonth.stream().sorted().map(String::valueOf).collect(Collectors.joining(","));
String errorMsg = I18NMessageSourceUtil.getMessage(I18nAlertEnum.GUILD_USD_TO_RECHARGE_USER_DAY_OF_MONTH_LIMIT, new Object[]{enableDayOfMonthStr}, guildMember.getPartitionId()); String errorMsg = I18NMessageSourceUtil.getMessage(I18nAlertEnum.GUILD_USD_TO_RECHARGE_USER_DAY_OF_MONTH_LIMIT, new Object[]{enableDayOfMonthStr}, guildMember.getPartitionId());
throw new ServiceException(errorMsg); throw new ServiceException(errorMsg);
} }
if (null == configDto.getDayNumLimit() || BigDecimal.ZERO.compareTo(configDto.getDayNumLimit()) <= 0){ if (null != configDto.getDayNumLimit() && BigDecimal.ZERO.compareTo(configDto.getDayNumLimit()) > 0){
return; ZonedDateTime todayStartTime = zdt.withHour(0).withMinute(0).withSecond(0).withNano(0);
} Date systemStartTime = DateTimeUtil.converLocalDateTimeToDate(todayStartTime.withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime());
ZonedDateTime todayStartTime = zdt.withHour(0).withMinute(0).withSecond(0).withNano(0); String systemStartTimeStr = DateTimeUtil.convertDateTime(systemStartTime);
Date systemStartTime = DateTimeUtil.converLocalDateTimeToDate(todayStartTime.withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime());
String systemStartTimeStr = DateTimeUtil.convertDateTime(systemStartTime);
ZonedDateTime todayEndTime = zdt.withHour(23).withMinute(59).withSecond(59).withNano(999999999); ZonedDateTime todayEndTime = zdt.withHour(23).withMinute(59).withSecond(59).withNano(999999999);
Date systemEndTime = DateTimeUtil.converLocalDateTimeToDate(todayEndTime.withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime()); Date systemEndTime = DateTimeUtil.converLocalDateTimeToDate(todayEndTime.withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime());
String systemEndTimeStr = DateTimeUtil.convertDateTime(systemEndTime); String systemEndTimeStr = DateTimeUtil.convertDateTime(systemEndTime);
Double todayNum = guildUsdBillRecordMapper.sum(guildMember.getPartitionId(), guildMember.getUid(), null, Double todayNum = guildUsdBillRecordMapper.sum(guildMember.getPartitionId(), guildMember.getUid(), null,
systemStartTimeStr, systemEndTimeStr, GameUsdOperateTypeEnum.USD_TO_RECHARGE_USER.getType()); systemStartTimeStr, systemEndTimeStr, GameUsdOperateTypeEnum.USD_TO_RECHARGE_USER.getType());
BigDecimal todayNumB = null == todayNum? BigDecimal.ZERO: BigDecimal.valueOf(todayNum); BigDecimal todayNumB = null == todayNum? BigDecimal.ZERO: BigDecimal.valueOf(todayNum);
BigDecimal judgeNum = todayNumB.add(guildUsdNum); BigDecimal judgeNum = todayNumB.add(guildUsdNum);
if (judgeNum.compareTo(configDto.getDayNumLimit()) > 0){ if (judgeNum.compareTo(configDto.getDayNumLimit()) > 0){
String errorMsg = I18NMessageSourceUtil.getMessage(I18nAlertEnum.GUILD_USD_TO_RECHARGE_USER_DAY_NUM_LIMIT, null, guildMember.getPartitionId()); String errorMsg = I18NMessageSourceUtil.getMessage(I18nAlertEnum.GUILD_USD_TO_RECHARGE_USER_DAY_NUM_LIMIT, null, guildMember.getPartitionId());
throw new ServiceException(errorMsg); throw new ServiceException(errorMsg);
}
} }
} }