公会-土耳其-结算钻石

This commit is contained in:
khalil
2024-11-14 12:03:59 +08:00
parent 82c094c28f
commit 8a67744b86
8 changed files with 84 additions and 105 deletions

View File

@@ -206,6 +206,8 @@ public enum BillObjTypeEnum {
ROOM_BACKGROUND_CUSTOM(139, "自定义房间背景", BillTypeEnum.OUT, CurrencyEnum.DIAMOND),
ROOM_BACKGROUND_CUSTOM_REJECT(140, "自定义房间背景驳回", BillTypeEnum.IN, CurrencyEnum.DIAMOND),
GUILD_SETTLEMENT_GOLD_IN( 141, "公会周期结算会长钻石收入", BillTypeEnum.IN, CurrencyEnum.GOLD),
;
BillObjTypeEnum(int value, String desc, BillTypeEnum type, CurrencyEnum currency) {

View File

@@ -10,7 +10,7 @@ public enum PartitionEnum {
ENGLISH(1, "Asia/Manila", "英语区"),
ARAB(2, "Asia/Riyadh", "阿语区"),
CHINESS(4, "Asia/Hong_Kong", "中文区"),
TURKEY(8, "Asia/Riyadh", "土耳其区"),
TURKEY(8, "Europe/Istanbul", "土耳其区"),
;
private final int id;

View File

@@ -40,6 +40,7 @@ public class AgencyMonthSettleDetail implements Serializable {
* 所属厅id
*/
private Integer guildId;
private Integer partitionId;
private String diamondLevel;
private Integer hallMemberCount;

View File

@@ -54,58 +54,47 @@ public class AgencyMonthSettleService {
@Autowired
private GuildMemberService guildMemberService;
public void monthRankTaskAll(Date beginDate, Date endDate) {
Integer partitionId = PartitionEnum.ARAB.getId();
try {
List<UserHallEnergyLevelDataVo> userHallEnergyLevelDataVos = guildMemberDiamondStatisticsService.agencySettle(partitionId, beginDate, null);
if (CollectionUtils.isEmpty(userHallEnergyLevelDataVos)) {
return;
public void monthRankTaskAll(Integer partitionId, Date beginDate, Date endDate) {
List<UserHallEnergyLevelDataVo> userHallEnergyLevelDataVos = guildMemberDiamondStatisticsService.agencySettle(partitionId, beginDate, null);
if (CollectionUtils.isEmpty(userHallEnergyLevelDataVos)) {
return;
}
List<AgencyMonthSettleDetail> agencyMonthSettleDetails = new ArrayList<>();
for (UserHallEnergyLevelDataVo dataVo : userHallEnergyLevelDataVos) {
AgencyMonthSettleDetail agencyMonthSettleDetail = AgencyMonthSettleDetail.builder().uid(dataVo.getUid()).guildId(dataVo.getHallId()).partitionId(partitionId)
.diamondLevel(dataVo.getEnergyLevel()).diamondNum(BigDecimal.valueOf(dataVo.getEnergyValue())).hallMemberCount(dataVo.getHallMemberCount())
.hallSalary(dataVo.getHallSalary()).salaryRate(dataVo.getSalaryRate()).createTime(new Date()).statDate(beginDate).endDate(endDate).build();
agencyMonthSettleDetails.add(agencyMonthSettleDetail);
}
agencyMonthSettleDetailService.saveBatch(agencyMonthSettleDetails);
for (UserHallEnergyLevelDataVo dataVo : userHallEnergyLevelDataVos) {
if (dataVo.getHallSalary().doubleValue() == 0) {
continue;
}
List<AgencyMonthSettleDetail> agencyMonthSettleDetails = new ArrayList<>();
for (UserHallEnergyLevelDataVo dataVo : userHallEnergyLevelDataVos) {
AgencyMonthSettleDetail agencyMonthSettleDetail = AgencyMonthSettleDetail.builder().uid(dataVo.getUid()).guildId(dataVo.getHallId())
.diamondLevel(dataVo.getEnergyLevel()).diamondNum(BigDecimal.valueOf(dataVo.getEnergyValue())).hallMemberCount(dataVo.getHallMemberCount())
.hallSalary(dataVo.getHallSalary()).salaryRate(dataVo.getSalaryRate()).createTime(new Date()).statDate(beginDate).endDate(endDate).build();
agencyMonthSettleDetails.add(agencyMonthSettleDetail);
}
agencyMonthSettleDetailService.saveBatch(agencyMonthSettleDetails);
for (UserHallEnergyLevelDataVo dataVo : userHallEnergyLevelDataVos) {
if (dataVo.getHallSalary().doubleValue() == 0) {
continue;
}
guildUsdOperateService.settlementUsd(dataVo.getHallId(), dataVo.getUid(), dataVo.getHallSalary());
}
} catch (Exception e) {
log.error("AgencyMonthSettleServiceImpl.monthRankTaskAll, region:{} e:{}", partitionId, e);
} finally {
guildUsdOperateService.settlementGold(dataVo.getHallId(), dataVo.getUid(), dataVo.getHallSalary());
}
}
public void monthRankTaskDetail(Date beginDate, Date endDate) {
Integer partitionId = PartitionEnum.ARAB.getId();
try {
List<UserHallEnergyLevelDataVo> userHallEnergyLevelDataVos = guildMemberDiamondStatisticsService.agencySettleDetail(partitionId, beginDate, null, null);
if (CollectionUtils.isEmpty(userHallEnergyLevelDataVos)) {
return;
}
List<AgencyUserMonthSettleDetail> agencyUserMonthSettleDetails = new ArrayList<>();
for (UserHallEnergyLevelDataVo dataVo : userHallEnergyLevelDataVos) {
AgencyUserMonthSettleDetail agencyMonthSettleDetail = AgencyUserMonthSettleDetail.builder().uid(dataVo.getUid()).guildId(dataVo.getHallId())
.diamondNum(BigDecimal.valueOf(dataVo.getEnergyValue())).createTime(new Date()).statDate(beginDate).endDate(endDate).build();
agencyUserMonthSettleDetails.add(agencyMonthSettleDetail);
}
if (CollectionUtils.isEmpty(agencyUserMonthSettleDetails)) {
log.info("empty agencyUserMonthSettleDetails");
return;
}
boolean saveBatch = agencyUserMonthSettleDetailService.saveBatch(agencyUserMonthSettleDetails);
if (!saveBatch) {
log.info("empty agencyUserMonthSettleDetails");
return;
}
} catch (Exception e) {
log.error("AgencyMonthSettleServiceImpl.monthRankTaskAll, region:{} e:{}", partitionId, e);
} finally {
public void monthRankTaskDetail(Integer partitionId, Date beginDate, Date endDate) {
List<UserHallEnergyLevelDataVo> userHallEnergyLevelDataVos = guildMemberDiamondStatisticsService.agencySettleDetail(partitionId, beginDate, null, null);
if (CollectionUtils.isEmpty(userHallEnergyLevelDataVos)) {
return;
}
List<AgencyUserMonthSettleDetail> agencyUserMonthSettleDetails = new ArrayList<>();
for (UserHallEnergyLevelDataVo dataVo : userHallEnergyLevelDataVos) {
AgencyUserMonthSettleDetail agencyMonthSettleDetail = AgencyUserMonthSettleDetail.builder().uid(dataVo.getUid()).guildId(dataVo.getHallId())
.diamondNum(BigDecimal.valueOf(dataVo.getEnergyValue())).createTime(new Date()).statDate(beginDate).endDate(endDate).build();
agencyUserMonthSettleDetails.add(agencyMonthSettleDetail);
}
if (CollectionUtils.isEmpty(agencyUserMonthSettleDetails)) {
log.info("empty agencyUserMonthSettleDetails");
return;
}
boolean saveBatch = agencyUserMonthSettleDetailService.saveBatch(agencyUserMonthSettleDetails);
if (!saveBatch) {
log.info("empty agencyUserMonthSettleDetails");
return;
}
}

View File

@@ -203,6 +203,20 @@ public class GuildUsdOperateService {
return vo;
}
public void settlementGold(Integer guildId, Long uid, BigDecimal goldNum) {
GuildMember guildMember = guildMemberService.getVaildGuildMemberByUid(uid);
if (null == guildMember || !GuildConstant.RoleType.OWNER.equals(guildMember.getRoleType())
|| !guildMember.getGuildId().equals(guildId)) {
throw new ServiceException(BusiStatus.FAMILY_PERMISSION_DENIED);
}
if (!userPurseService.addGold(uid, goldNum.doubleValue(), BillObjTypeEnum.GUILD_SETTLEMENT_GOLD_IN.getDesc())){
throw new ServiceException(BusiStatus.SERVERBUSY);
}
billRecordService.insertGeneralBillRecord(uid, uid, null, BillObjTypeEnum.GUILD_SETTLEMENT_GOLD_IN, goldNum.doubleValue());
}
public void settlementUsd(Integer guildId, Long uid, BigDecimal guildUsdNum) {
GuildMember guildMember = guildMemberService.getVaildGuildMemberByUid(uid);
if (null == guildMember || !GuildConstant.RoleType.OWNER.equals(guildMember.getRoleType())

View File

@@ -37,14 +37,11 @@
and hm.guild_id = ed.guild_id
and ed.cycle_date = #{cycleDate}
left join guild h on hm.guild_id = h.id
left join users u on hm.uid = u.uid
where hm.`enable` = 1
<if test="partitionId != null">
and u.partition_id = #{partitionId}
</if>
where hm.partition_id #{partitionId}
<if test="guildId != null">
and hm.guild_id = #{guildId}
</if>
and hm.`enable` = 1
group by hm.guild_id
</select>
@@ -59,16 +56,14 @@
and ed.cycle_date = #{cycleDate}
left join guild h on hm.guild_id = h.id
left join users u on hm.uid = u.uid
where hm.`enable` = 1
<if test="partitionId != null">
and u.partition_id = #{partitionId}
</if>
where hm.partition_id = #{partitionId}
<if test="guildId != null">
and hm.guild_id = #{guildId}
</if>
<if test="uid != null">
and hm.uid = #{uid}
</if>
and hm.`enable` = 1
group by hm.guild_id, hm.uid
</select>

View File

@@ -6,6 +6,7 @@ import com.accompany.business.service.guild.GuildMessageService;
import com.accompany.common.annotation.Authorization;
import com.accompany.common.result.BusiResult;
import com.accompany.core.base.UidContextHolder;
import com.accompany.core.enumeration.PartitionEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@@ -39,7 +40,7 @@ public class GuildTestController {
if (!"fdsfast43532453".equals(pwd)) {
return;
}
agencyMonthSettleService.monthRankTaskAll(DateUtil.parseDate(beginDate), DateUtil.parseDate(endDate));
agencyMonthSettleService.monthRankTaskAll(PartitionEnum.ARAB.getId(), DateUtil.parseDate(beginDate), DateUtil.parseDate(endDate));
}
@RequestMapping(value = "monthRankTaskDetailAll")
@@ -48,7 +49,7 @@ public class GuildTestController {
if (!"fdsfast43532453".equals(pwd)) {
return;
}
agencyMonthSettleService.monthRankTaskDetail(DateUtil.parseDate(beginDate), DateUtil.parseDate(endDate));
agencyMonthSettleService.monthRankTaskDetail(PartitionEnum.ARAB.getId(), DateUtil.parseDate(beginDate), DateUtil.parseDate(endDate));
}
}

View File

@@ -14,9 +14,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.stream.Collectors;
@Component
@Slf4j
@@ -27,7 +32,8 @@ public class GuildSettleTask {
private GuildSalaryBillDateCycleService guildSalaryBillDateCycleService ;
@Autowired
private PartitionInfoService partitionInfoService;
private static final DateTimeFormatter dateFormatters = DateTimeFormatter.ofPattern(DateTimeUtil.DEFAULT_DATETIME_PATTERN);
@Resource(name = "bizExecutor")
private ThreadPoolExecutor bizExecutor;
//zone = "Asia/Riyadh zone = "Etc/GMT-3" 两种方式都支持
@@ -35,41 +41,22 @@ public class GuildSettleTask {
* 公会月结算
* 每月16号凌晨0点10分执行
*/
@Scheduled(cron = "0 10 0 16 * ?", zone = "Etc/GMT-3")
public void monthRankTaskAll1() {
@Scheduled(cron = "0 10 0 1,16 * ?", zone = "Etc/GMT-3")
public void monthRankTask() {
Date date = new Date();
PartitionInfo byId = partitionInfoService.getById(PartitionEnum.ARAB.getId());
ZonedDateTime zonedDateTime = DateTimeUtil.convertWithZoneId(new Date(), byId.getZoneId());
log.info("=-=monthRankTaskAll=-=:东三区时间:{}", zonedDateTime.format(dateFormatters));
DateTime beginTime = DateUtil.beginOfMonth(date);
DateTime endTime = DateUtil.beginOfDay(date);
log.info("=-=monthRankTaskAll1=-=:beginTime:{},endTime:{}", DateUtil.formatDateTime(beginTime) , DateUtil.formatDateTime(endTime));
agencyMonthSettleService.monthRankTaskAll(beginTime, endTime);
log.info("=-=monthRankTaskAll1=-= end");
log.info("=-=monthRankTaskDetail1=-=:beginTime:{},endTime:{}", DateUtil.formatDateTime(beginTime) , DateUtil.formatDateTime(endTime));
agencyMonthSettleService.monthRankTaskDetail(beginTime, endTime);
log.info("=-=monthRankTaskDetail1=-= end");
}
/**
* 公户月结算,用户明细
* 每月1号凌晨0点10分执行
*/
@Scheduled(cron = "0 10 0 1 * ?", zone = "Etc/GMT-3")
public void monthRankTaskAll2() {
Date date = new Date();
PartitionInfo byId = partitionInfoService.getById(PartitionEnum.ARAB.getId());
ZonedDateTime zonedDateTime = DateTimeUtil.convertWithZoneId(new Date(), byId.getZoneId());
log.info("=-=monthRankTaskAll2=-=:东三区时间:{}", zonedDateTime.format(dateFormatters));
DateTime lastMonth = DateUtil.offsetMonth(date, -1);
DateTime beginTime = DateUtil.offsetDay(lastMonth, 15);
DateTime endTime = DateUtil.beginOfDay(date);
log.info("=-=monthRankTaskAll2=-=:beginTime:{},endTime:{}", DateUtil.formatDateTime(beginTime) , DateUtil.formatDateTime(endTime));
agencyMonthSettleService.monthRankTaskAll(beginTime, endTime);
log.info("=-=monthRankTaskAll2=-= end");
log.info("=-=monthRankTaskDetail2=-=:beginTime:{},endTime:{}", DateUtil.formatDateTime(beginTime) , DateUtil.formatDateTime(endTime));
agencyMonthSettleService.monthRankTaskDetail(beginTime, endTime);
log.info("=-=monthRankTaskDetail2=-= end");
List<PartitionEnum> partitionEnumList = List.of(PartitionEnum.ARAB, PartitionEnum.TURKEY);
for (PartitionEnum partitionEnum : partitionEnumList) {
bizExecutor.execute(()->{
DateTime beginTime = DateUtil.beginOfMonth(date);
DateTime endTime = DateUtil.beginOfDay(date);
log.info("=-=monthRankTaskAll1=-=:beginTime:{},endTime:{}", DateUtil.formatDateTime(beginTime) , DateUtil.formatDateTime(endTime));
agencyMonthSettleService.monthRankTaskAll(partitionEnum.getId(), beginTime, endTime);
log.info("=-=monthRankTaskAll1=-= end");
log.info("=-=monthRankTaskDetail1=-=:beginTime:{},endTime:{}", DateUtil.formatDateTime(beginTime) , DateUtil.formatDateTime(endTime));
agencyMonthSettleService.monthRankTaskDetail(partitionEnum.getId(), beginTime, endTime);
log.info("=-=monthRankTaskDetail1=-= end");
});
}
}
/**
@@ -87,14 +74,4 @@ public class GuildSettleTask {
}
}
//
//
// public static void main(String[] args) {
// String[] availableIDs = TimeZone.getAvailableIDs();
// for (String availableID : availableIDs) {
// System.out.println(availableID);
// }
// System.out.println(DateTimeUtil.getDateTimeByZoneId("Etc/GMT-3").format(dateFormatters));
// System.out.println(DateTimeUtil.getDateTimeByZoneId("Etc/GMT-8").format(dateFormatters));
// }
}