模板数据统计

模板活动数据

保存模板数据
This commit is contained in:
2025-06-30 19:01:47 +08:00
parent e5c66e89a1
commit 5d9f2bd398
18 changed files with 584 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
package com.accompany.payment.mapper;
import com.accompany.payment.model.ChannelStatistic;
import com.accompany.payment.model.ChargeRecord;
import com.accompany.payment.vo.ChargeRecordCountVo;
import com.accompany.payment.vo.ChargeRecordDetailVo;
import com.accompany.payment.vo.ChargeRecordStatisVo;
@@ -79,5 +80,6 @@ public interface ChargeRecordMapperMgr {
Long getRechargeMoneyByUidBetweenTime(@Param("uid") Long uid, @Param("device") String device, @Param("channel") String channel,
@Param("startTime") Date startTime, @Param("endTime") Date endTime);
List<ChargeRecord> getAllChargeUserAmount(@Param("list") List<Long> uids, @Param("startTime") Date startTime,
@Param("endTime") Date endTime);
}

View File

@@ -90,6 +90,11 @@ public class ChargeRecordService extends BaseService {
return chargeRecordMapperMgr.getChargeUserAmount(uid, startDate, endDate);
}
public List<ChargeRecord> getAllChargeUserAmount(List<Long> uids, Date startDate, Date endDate){
return chargeRecordMapperMgr.getAllChargeUserAmount(uids, startDate, endDate);
}
public boolean checkRepetitionOrder(String thirdOrderNo, String channel){
ChargeRecordExample example = new ChargeRecordExample();
example.createCriteria().andPingxxChargeIdEqualTo(thirdOrderNo)

View File

@@ -358,4 +358,23 @@
and uid = #{uid} and create_time &gt;= DATE_FORMAT(adddate(now(), -60), '%Y-%m-%d 00:00:00')
</select>
<select id="getAllChargeUserAmount" resultType="com.accompany.payment.model.ChargeRecord">
select uid,
sum(amount) amount,
sum(total_gold) totalGold
from charge_record
where charge_status in (2,6)
and uid in
<foreach collection="list" item="uid" open="(" separator="," close=")">
#{uid}
</foreach>
<if test="startTime != null">
and create_time &gt;= #{startTime}
</if>
<if test="endTime != null">
and create_time &lt; #{endTime}
</if>
group by uid
</select>
</mapper>

View File

@@ -0,0 +1,52 @@
package com.accompany.business.model.activity.stat;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* 活动日榜单统计实体类
*
* @author
* @since 2025-06-30
*/
@Data
public class ActivityDayData implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 模板活动key
*/
private String actKey;
/**
* 统计时间 yyyy-MM-dd
*/
private String statDate;
/**
* 活动类型对应ActivityType
*/
private Integer type;
/**
* 分区id
*/
private Integer partitionId;
/**
* 用户uid
*/
private Long uid;
/**
* 送礼次数
*/
private Integer actNum;
/**
* 活动参与值
*/
private BigDecimal actValue;
private Date createTime;
private Date updateTime;
}

View File

@@ -0,0 +1,71 @@
package com.accompany.business.model.activity.stat;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* 活动日数据统计实体类
*
* @author
* @since 2025-07-01
*/
@Data
public class ActivityDayTotal implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 模板活动key
*/
private String actKey;
/**
* 模板活动name
*/
private String actName;
/**
* 统计时间 yyyy-MM-dd
*/
private String statDate;
/**
* 活动类型对应ActivityType
*/
private Integer type;
/**
* 分区id
*/
private Integer partitionId;
/**
* 送礼总次数
*/
private Integer actNum;
/**
* 总参与人数
*/
private Integer totalUserNum;
/**
* 实际参与人数
*/
private Integer actUserNum;
/**
* 总参与人数在活动当天的新注册用户数量
*/
private Integer newUserNum;
/**
* 实际参与人数在活动当天的充值人数
*/
private Integer chargeUserNum;
/**
* 实际参与人数在活动当天的充值金币数
*/
private Long chargeGoldNum;
/**
* 活动参与值
*/
private BigDecimal actValue;
private Date createTime;
}

View File

@@ -2,11 +2,14 @@ package com.accompany.business.vo.activity.config;
import lombok.Data;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Date;
import java.util.List;
@Data
public class ActivityOfTemplateConfig {
private String actName;
private String actKey;
private List<Integer> partitionIds;
private Boolean actSwitch = false;
@@ -14,4 +17,25 @@ public class ActivityOfTemplateConfig {
private Date endTime;
private List<Integer> giftIds;
private Boolean rechargeLimit = false;
public static void main(String[] args) {
// 假设这是你的初始 ZonedDateTime不是东八区的
ZonedDateTime zoneBeginTime = ZonedDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0).withZoneSameInstant(ZoneId.of("Asia/Riyadh"));
ZonedDateTime zoneEndTime = ZonedDateTime.now().withHour(23).withMinute(59).withSecond(59).withNano(999_999_999).withZoneSameInstant(ZoneId.of("Asia/Riyadh"));
// 设置东八区时区
ZoneId chinaZone = ZoneId.of("Asia/Shanghai");
// 将时间转换到东八区
ZonedDateTime beginTimeInChina = zoneBeginTime.withZoneSameInstant(chinaZone);
ZonedDateTime endTimeInChina = zoneEndTime.withZoneSameInstant(chinaZone);
// 转换为 Date 对象
Date startDate = Date.from(beginTimeInChina.toInstant());
Date endDate = Date.from(endTimeInChina.toInstant());
// 输出结果以验证
System.out.println("Start Date in China: " + startDate);
System.out.println("End Date in China: " + endDate);
}
}

View File

@@ -16,7 +16,7 @@ import java.util.Date;
@Slf4j
@Component
public class SpecialGiftListener implements ApplicationListener<GiftMessageEvent> {
public class ActivityGiftListener implements ApplicationListener<GiftMessageEvent> {
@Autowired
private ActivityOfSpecialGiftService activityOfSpecialGiftService;
@@ -30,13 +30,15 @@ public class SpecialGiftListener implements ApplicationListener<GiftMessageEvent
try {
if (Constant.GiftType.CUSTOM_GIFT == giftMessage.getGiftType().byteValue()) {
log.info("SpecialGiftListener giftMessage = {}", JSONObject.toJSONString(giftMessage));
activityOfSpecialGiftService.addTotalNum(giftMessage.getSendUid(), giftMessage.getGiftId(), giftMessage.getGiftNum(), giftMessage.getGoldNum().doubleValue());
activityOfSpecialGiftService.addTotalNum(giftMessage.getSendUid(), giftMessage.getGiftId(),
giftMessage.getGiftNum(), giftMessage.getGoldNum().doubleValue());
}
} catch (Exception e) {
log.error("SpecialGiftListener:e.getMessage:{}", e.getMessage(), e);
}
//通用模板活动
activityOfTemplateService.andRankGoldNum(giftMessage.getSendUid(), giftMessage.getGiftId(), giftMessage.getGoldNum().doubleValue(), new Date(giftMessage.getMessTime()));
activityOfTemplateService.andRankGoldNum(giftMessage.getGiftNum(), giftMessage.getSendUid(),
giftMessage.getGiftId(), giftMessage.getGoldNum().doubleValue(), new Date(giftMessage.getMessTime()));
}
}

View File

@@ -0,0 +1,37 @@
package com.accompany.business.mybatismapper.activity.stat;
import com.accompany.business.model.activity.stat.ActivityDayData;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.houbb.heaven.annotation.reflect.Param;
import java.math.BigDecimal;
/**
* 活动日榜单统计 Mapper 接口
*
* @author
* @since 2025-06-30
*/
public interface ActivityDayDataMapper extends BaseMapper<ActivityDayData> {
/**
* 插入或更新活动日数据
* @param actKey 活动key
* @param statDate 统计日期
* @param type 活动类型
* @param partitionId 分区ID
* @param uid 用户ID
* @param actNum 送礼次数
* @param actValue 活动参与值
* @return 影响的行数
*/
int insertOrUpdateWithIncrement(
@Param("actKey") String actKey,
@Param("statDate") String statDate,
@Param("type") Integer type,
@Param("partitionId") Integer partitionId,
@Param("uid") Long uid,
@Param("actNum") Integer actNum,
@Param("actValue") BigDecimal actValue
);
}

View File

@@ -0,0 +1,14 @@
package com.accompany.business.mybatismapper.activity.stat;
import com.accompany.business.model.activity.stat.ActivityDayTotal;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 活动日数据统计 Mapper 接口
*
* @author
* @since 2025-07-01
*/
public interface ActivityDayTotalMapper extends BaseMapper<ActivityDayTotal> {
}

View File

@@ -1,6 +1,12 @@
package com.accompany.business.service.activity.h5;
import cn.hutool.core.date.DateUtil;
import com.accompany.business.constant.activity.ActivityType;
import com.accompany.business.model.activity.stat.ActivityDayData;
import com.accompany.business.model.activity.stat.ActivityDayTotal;
import com.accompany.business.service.activity.stat.ActivityDayDataService;
import com.accompany.business.service.activity.stat.ActivityDayTotalService;
import com.accompany.business.service.purse.DiamondGiveHistoryService;
import com.accompany.business.service.user.UsersService;
import com.accompany.business.vo.activity.config.ActivityOfTemplateConfig;
import com.accompany.business.vo.activity.h5.ActivityH5RankVo;
@@ -13,6 +19,8 @@ import com.accompany.core.enumeration.PartitionEnum;
import com.accompany.core.exception.ServiceException;
import com.accompany.core.model.Users;
import com.accompany.core.service.SysConfService;
import com.accompany.payment.model.ChargeRecord;
import com.accompany.payment.service.ChargeRecordService;
import com.accompany.payment.service.RechargeUserService;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
@@ -22,10 +30,15 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 通用模板活动
@@ -43,13 +56,21 @@ public class ActivityOfTemplateService {
private SysConfService sysConfService;
@Autowired
private UsersService usersService;
@Autowired
private ActivityDayDataService activityDayDataService;
@Autowired
private ActivityDayTotalService activityDayTotalService;
@Autowired
private ChargeRecordService chargeRecordService;
@Autowired
private DiamondGiveHistoryService diamondGiveHistoryService;
private ActivityType activityType() {
return ActivityType.COMMON_ACTIVITY;
}
public void andRankGoldNum(Long uid, Integer giftId, Double goldNum, Date date){
public void andRankGoldNum(Integer giftNum, Long uid, Integer giftId, Double goldNum, Date date){
try {
ActivitySwitchVo activitySwitchVo = activityRankRuleService.getActivitySwitchVo();
if (activitySwitchVo != null && ObjectUtils.equals(activitySwitchVo.getTemplateAct(), Boolean.FALSE)) {
@@ -71,6 +92,9 @@ public class ActivityOfTemplateService {
ZonedDateTime zoneStartTime = DateTimeUtil.convertWithZoneId(templateConfig.getStartTime(), partitionInfo.getZoneId());
String currentKeyDate = zoneStartTime.format(ActivityRankRuleService.dateFormatter_);
activityRankRuleService.addTotalNum(activityType(), uid, goldNum, templateConfig.getActKey(), currentKeyDate, partitionId.toString());
activityDayDataService.saveOrIncrement(templateConfig.getActKey(),
DateTimeUtil.convertWithZoneId(date, partitionInfo.getZoneId()).format(ActivityRankRuleService.dateFormatter), ActivityType.COMMON_ACTIVITY.getType(),
partitionId, uid, giftNum, BigDecimal.valueOf(goldNum));
}
} catch (Exception e) {
log.error("ActivityOfTemplateService.andRankGoldNum,uid:{},giftId:{},goldNum:{},date:{}", uid, giftId, goldNum, date);
@@ -102,6 +126,13 @@ public class ActivityOfTemplateService {
Double rankTotalNum = activityRankRuleService.getRankTotalNum(activityType(), rank.getMyRank().getUid(), customKey);
rank.getMyRank().setTotalGoldNum(rankTotalNum);
}
String format = zoneStartTime.format(ActivityRankRuleService.dateFormatter);
//记录参与,进页面算参与
if (!activityDayDataService.checkExist(actKey, format, activityType().getType(), partitionId, uid)) {
activityDayDataService.saveOrIncrement(templateConfig.getActKey(),
format, ActivityType.COMMON_ACTIVITY.getType(),
partitionId, uid, 0, BigDecimal.ZERO);
}
return rank;
}
@@ -155,4 +186,108 @@ public class ActivityOfTemplateService {
return null;
}
/**
* 不判断时间返回,活动结束后产品请求页面发奖励
* @param partitionId
* @return
*/
public List<ActivityOfTemplateConfig> getTemplateConfigList(Integer partitionId) {
String value = sysConfService.getSysConfValueById(Constant.SysConfId.ACTIVITY_TEMPLATE_CONFIG);
if (StringUtils.isBlank(value)) {
return null;
}
List<ActivityOfTemplateConfig> ofTemplateConfigs = JSONObject.parseArray(value, ActivityOfTemplateConfig.class);
return ofTemplateConfigs.stream()
.filter(x -> CollectionUtils.isNotEmpty(x.getPartitionIds()) && x.getPartitionIds().contains(partitionId))
.collect(Collectors.toList());
}
public void statData(Date now, PartitionEnum partitionEnum) {
try {
List<ActivityOfTemplateConfig> configList = getTemplateConfigList(partitionEnum.getId());
if (CollectionUtils.isEmpty(configList)) {
return;
}
Date offsetDay = DateUtil.offsetDay(now, -1);
ZonedDateTime zonedDateTime = DateTimeUtil.convertWithZoneId(offsetDay, partitionEnum.getZoneId());
String statDate = zonedDateTime.format(DateTimeUtil.dateFormatter);
ZonedDateTime zoneBeginTime = zonedDateTime.withHour(0).withMinute(0).withSecond(0).withNano(0);
ZonedDateTime zoneEndTime = zonedDateTime.withHour(23).withMinute(59).withSecond(59).withNano(999_999_999);
// 设置东八区时区
ZoneId chinaZone = ZoneId.of(PartitionEnum.CHINESE.getZoneId());
// 将时间转换到东八区
ZonedDateTime beginTimeInChina = zoneBeginTime.withZoneSameInstant(chinaZone);
ZonedDateTime endTimeInChina = zoneEndTime.withZoneSameInstant(chinaZone);
// 转换为 Date 对象
Date startDate = Date.from(beginTimeInChina.toInstant());
Date endDate = Date.from(endTimeInChina.toInstant());
List<ActivityDayTotal> totalList = new ArrayList<>();
for (ActivityOfTemplateConfig templateConfig : configList) {
// 1. 将zonedDateTime转换为Instant(UTC时间)
Instant targetInstant = zonedDateTime.toInstant();
Instant startInstant = templateConfig.getStartTime().toInstant();
Instant endInstant = templateConfig.getEndTime().toInstant();
if (targetInstant.isBefore(startInstant) || endInstant.isBefore(targetInstant)) {
continue;
}
ActivityDayTotal total = new ActivityDayTotal();
total.setActKey(templateConfig.getActKey());
total.setType(activityType().getType());
total.setPartitionId(partitionEnum.getId());
total.setStatDate(statDate);
total.setActName(templateConfig.getActName());
totalList.add(total);
List<ActivityDayData> activityDayData = activityDayDataService.dayList(templateConfig.getActKey(), statDate, activityType().getType(), partitionEnum.getId());
if (CollectionUtils.isEmpty(activityDayData)) {
continue;
}
total.setActNum(activityDayData.stream()
.mapToInt(ActivityDayData::getActNum)
.sum());
total.setActValue(activityDayData.stream()
.map(ActivityDayData::getActValue)
.reduce(BigDecimal.ZERO, BigDecimal::add));
total.setTotalUserNum(activityDayData.size());
total.setActUserNum((int)activityDayData.stream()
.filter(data -> data.getActValue().compareTo(BigDecimal.ZERO) != 0)
.count());
List<Long> uids = activityDayData.stream().map(ActivityDayData::getUid).collect(Collectors.toList());
List<Users> users = usersService.getUsersListByUids(uids);
Instant zoneBeginTimeInstant = zoneBeginTime.toInstant();
Instant zoneEndTimeInstant = zoneEndTime.toInstant();
long newUserCount = users.stream()
.filter(x -> zoneBeginTimeInstant.isBefore(x.getCreateTime().toInstant())
&& zoneEndTimeInstant.isAfter(x.getCreateTime().toInstant()))
.count();
total.setNewUserNum((int)newUserCount);
Map<Long, Long> uidGoldMap = diamondGiveHistoryService.userChargeMap(uids, startDate, endDate);
List<ChargeRecord> allChargeUserAmount = chargeRecordService.getAllChargeUserAmount(uids, startDate, endDate);
if (CollectionUtils.isNotEmpty(allChargeUserAmount)) {
allChargeUserAmount.forEach(chargeRecord -> {
uidGoldMap.merge(
chargeRecord.getUid(),
chargeRecord.getTotalGold(),
Long::sum // 存在则相加,不存在则新增
);
});
}
total.setChargeUserNum(uidGoldMap.size());
if (!uidGoldMap.isEmpty()) {
total.setChargeGoldNum(uidGoldMap.values().stream().reduce(0L, Long::sum));
}
}
if (CollectionUtils.isNotEmpty(totalList)) {
activityDayTotalService.saveBatch(totalList);
}
} catch (Exception e) {
log.error("ActivityOfTemplateTask.statEn,e:{}", e.getMessage(), e);
}
}
}

View File

@@ -0,0 +1,44 @@
package com.accompany.business.service.activity.stat;
import com.accompany.business.model.activity.stat.ActivityDayData;
import com.baomidou.mybatisplus.extension.service.IService;
import java.math.BigDecimal;
import java.util.List;
/**
* 活动日榜单统计 服务类
*
* @author
* @since 2025-06-30
*/
public interface ActivityDayDataService extends IService<ActivityDayData> {
/**
* 保存或叠加更新活动日数据
*
* @param actKey 活动key
* @param statDate 统计日期
* @param type 活动类型
* @param partitionId 分区ID
* @param uid 用户ID
* @param actNumIncrement 要增加的送礼次数
* @param actValueIncrement 要增加的活动参与值
* @return 操作是否成功
*/
boolean saveOrIncrement(String actKey, String statDate, Integer type,
Integer partitionId, Long uid, Integer actNumIncrement, BigDecimal actValueIncrement);
/**
* 校验是否重复存在
* @param actKey
* @param statDate
* @param type
* @param partitionId
* @param uid
* @return
*/
boolean checkExist(String actKey, String statDate, Integer type, Integer partitionId, Long uid);
List<ActivityDayData> dayList(String actKey, String statDate, Integer type, Integer partitionId);
}

View File

@@ -0,0 +1,55 @@
package com.accompany.business.service.activity.stat;
import com.accompany.business.model.activity.stat.ActivityDayData;
import com.accompany.business.mybatismapper.activity.stat.ActivityDayDataMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
/**
* 活动日榜单统计 服务实现类
*
* @author
* @since 2025-06-30
*/
@Service
public class ActivityDayDataServiceImpl extends ServiceImpl<ActivityDayDataMapper, ActivityDayData> implements ActivityDayDataService {
@Override
public boolean saveOrIncrement(String actKey, String statDate, Integer type,
Integer partitionId, Long uid, Integer actNumIncrement, BigDecimal actValueIncrement) {
Integer finalActNumIncrement = actNumIncrement != null ? actNumIncrement : 0;
int affectedRows = baseMapper.insertOrUpdateWithIncrement(actKey, statDate, type,
partitionId, uid, finalActNumIncrement, actValueIncrement
);
return affectedRows > 0;
}
@Override
public boolean checkExist(String actKey, String statDate, Integer type, Integer partitionId, Long uid) {
LambdaQueryWrapper<ActivityDayData> wrapper = Wrappers.lambdaQuery();
wrapper.eq(ActivityDayData::getActKey, actKey)
.eq(ActivityDayData::getStatDate, statDate)
.eq(ActivityDayData::getType, type)
.eq(ActivityDayData::getPartitionId, partitionId)
.eq(ActivityDayData::getUid, uid);
return baseMapper.selectCount(wrapper) > 0;
}
@Override
public List<ActivityDayData> dayList(String actKey, String statDate, Integer type, Integer partitionId) {
LambdaQueryWrapper<ActivityDayData> wrapper = Wrappers.lambdaQuery();
wrapper.select(ActivityDayData::getUid, ActivityDayData::getActNum, ActivityDayData::getActValue)
.eq(ActivityDayData::getActKey, actKey)
.eq(ActivityDayData::getStatDate, statDate)
.eq(ActivityDayData::getType, type)
.eq(ActivityDayData::getPartitionId, partitionId);
return baseMapper.selectList(wrapper);
}
}

View File

@@ -0,0 +1,15 @@
package com.accompany.business.service.activity.stat;
import com.accompany.business.model.activity.stat.ActivityDayTotal;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 活动日数据统计 服务类
*
* @author
* @since 2025-07-01
*/
public interface ActivityDayTotalService extends IService<ActivityDayTotal> {
}

View File

@@ -0,0 +1,18 @@
package com.accompany.business.service.activity.stat;
import com.accompany.business.model.activity.stat.ActivityDayTotal;
import com.accompany.business.mybatismapper.activity.stat.ActivityDayTotalMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* 活动日数据统计 服务实现类
*
* @author
* @since 2025-07-01
*/
@Service
public class ActivityDayTotalServiceImpl extends ServiceImpl<ActivityDayTotalMapper, ActivityDayTotal> implements ActivityDayTotalService {
}

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.accompany.business.mybatismapper.activity.stat.ActivityDayDataMapper">
<insert id="insertOrUpdateWithIncrement">
INSERT INTO activity_day_data (
act_key,
stat_date,
type,
partition_id,
uid,
act_num,
act_value,
create_time,
update_time
) VALUES (
#{actKey},
#{statDate},
#{type},
#{partitionId},
#{uid},
#{actNum},
#{actValue},
NOW(),
NOW()
)
ON DUPLICATE KEY UPDATE
act_num = act_num + VALUES(act_num),
act_value = act_value + VALUES(act_value),
update_time = NOW()
</insert>
</mapper>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.accompany.business.mybatismapper.activity.stat.ActivityDayTotalMapper">
</mapper>

View File

@@ -1,8 +1,10 @@
package com.accompany.business.controller.activity.h5;
import cn.hutool.core.date.DateUtil;
import com.accompany.business.service.activity.h5.ActivityOfTemplateService;
import com.accompany.business.vo.activity.h5.ActivityH5RankVo;
import com.accompany.common.annotation.Authorization;
import com.accompany.core.enumeration.PartitionEnum;
import com.accompany.core.vo.BaseResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -30,7 +32,14 @@ public class ActivityOfTemplateController {
@Authorization
@GetMapping(value = "/add")
public BaseResponseVO<Void> addTotalNum(Long sendUid, Integer giftId, Double totalNum) {
activityOfTemplateService.andRankGoldNum(sendUid, giftId, totalNum, new Date());
activityOfTemplateService.andRankGoldNum(1, sendUid, giftId, totalNum, new Date());
return BaseResponseVO.success();
}
@Authorization
@GetMapping(value = "/statData")
public BaseResponseVO<Void> statData(String date, Integer partitionId) {
activityOfTemplateService.statData(DateUtil.parseDateTime(date), PartitionEnum.getByPartitionId(partitionId));
return BaseResponseVO.success();
}
}

View File

@@ -0,0 +1,40 @@
package com.accompany.scheduler.task.activity;
import com.accompany.business.service.activity.h5.ActivityOfTemplateService;
import com.accompany.core.enumeration.PartitionEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
@Component
@Slf4j
public class ActivityOfTemplateTask {
@Autowired
private ActivityOfTemplateService activityOfTemplateService;
/**
* 每天1号凌晨0点10分执行
*/
@Scheduled(cron = "0 10 0 * * ?", zone = "Etc/GMT-3")
public void statAr() {
Date date = new Date();
List<PartitionEnum> partitionEnumList = List.of(PartitionEnum.ARAB, PartitionEnum.TURKEY);
for (PartitionEnum partitionEnum : partitionEnumList) {
activityOfTemplateService.statData(date, partitionEnum);
}
}
@Scheduled(cron = "0 10 0 * * ?")
public void statEn() {
Date date = new Date();
List<PartitionEnum> partitionEnumList = List.of(PartitionEnum.ENGLISH, PartitionEnum.ENGLISH2, PartitionEnum.CHINESE);
for (PartitionEnum partitionEnum : partitionEnumList) {
activityOfTemplateService.statData(date, partitionEnum);
}
}
}