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

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.payment.service.RechargeUserService;
import com.alibaba.fastjson2.JSON;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
@@ -69,38 +69,34 @@ public class GuildUsdToRechargeUserLimitService {
List<Integer> enableDayOfMonth = GuildConstant.RoleType.OWNER.equals(guildMember.getRoleType())?
configDto.getOwnerEnableDayOfMonth():
configDto.getMemberEnableDayOfMonth();
if (CollectionUtils.isEmpty(enableDayOfMonth)){
return;
}
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(guildMember.getPartitionId());
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 errorMsg = I18NMessageSourceUtil.getMessage(I18nAlertEnum.GUILD_USD_TO_RECHARGE_USER_DAY_OF_MONTH_LIMIT, new Object[]{enableDayOfMonthStr}, guildMember.getPartitionId());
throw new ServiceException(errorMsg);
}
if (null == configDto.getDayNumLimit() || BigDecimal.ZERO.compareTo(configDto.getDayNumLimit()) <= 0){
return;
if (null != configDto.getDayNumLimit() && BigDecimal.ZERO.compareTo(configDto.getDayNumLimit()) > 0){
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(){

View File

@@ -15,9 +15,9 @@ import com.accompany.core.service.SysConfService;
import com.accompany.core.util.I18NMessageSourceUtil;
import com.accompany.payment.service.RechargeUserService;
import com.alibaba.fastjson2.JSON;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
@@ -69,36 +69,33 @@ public class GameUsdToRechargeUserLimitService {
List<Integer> enableDayOfMonth = GuildConstant.RoleType.OWNER.equals(guildMember.getRoleType())?
configDto.getOwnerEnableDayOfMonth():
configDto.getMemberEnableDayOfMonth();
if (CollectionUtils.isEmpty(enableDayOfMonth)){
return;
}
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(guildMember.getPartitionId());
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 errorMsg = I18NMessageSourceUtil.getMessage(I18nAlertEnum.GUILD_USD_TO_RECHARGE_USER_DAY_OF_MONTH_LIMIT, new Object[]{enableDayOfMonthStr}, guildMember.getPartitionId());
throw new ServiceException(errorMsg);
}
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);
if (null != configDto.getDayNumLimit() && BigDecimal.ZERO.compareTo(configDto.getDayNumLimit()) > 0){
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);
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, GameUsdOperateTypeEnum.USD_TO_RECHARGE_USER.getType());
BigDecimal todayNumB = null == todayNum? BigDecimal.ZERO: BigDecimal.valueOf(todayNum);
BigDecimal judgeNum = todayNumB.add(guildUsdNum);
Double todayNum = guildUsdBillRecordMapper.sum(guildMember.getPartitionId(), guildMember.getUid(), null,
systemStartTimeStr, systemEndTimeStr, GameUsdOperateTypeEnum.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);
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);
}
}
}