|
|
@@ -20,6 +20,7 @@ import com.kxs.common.core.util.R;
|
|
|
import com.kxs.common.core.util.RetOps;
|
|
|
import com.kxs.common.core.util.SysUtils;
|
|
|
import com.kxs.common.security.util.SecurityUtils;
|
|
|
+import com.kxs.system.api.dto.kxsapp.camp.CampOpenNumStatDTO;
|
|
|
import com.kxs.system.api.dto.kxsapp.camp.PrizePoolDTO;
|
|
|
import com.kxs.system.api.feign.RemoteOldService;
|
|
|
import com.kxs.system.api.model.KxsCamp;
|
|
|
@@ -185,8 +186,6 @@ public class KxsCampServiceImpl extends ServiceImpl<KxsCampMapper, KxsCamp> impl
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void prizePoolIsRefreshed(PrizePoolDTO param) {
|
|
|
|
|
|
- //查询正在进行中的活动
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
//兑换券下单
|
|
|
if (param.getProductId() == 10 || param.getProductId() == 11) {
|
|
|
|
|
|
@@ -223,63 +222,94 @@ public class KxsCampServiceImpl extends ServiceImpl<KxsCampMapper, KxsCamp> impl
|
|
|
String[] pidPaths = user.getPidPath().split(StrPool.COMMA);
|
|
|
//翻转上级从最近的开始查询
|
|
|
Arrays.sort(pidPaths, Collections.reverseOrder());
|
|
|
- KxsCampUser campUser = baseMapper.selectUsersCamp(pidPaths, now);
|
|
|
- if (campUser != null) {
|
|
|
+ kxsCamp = baseMapper.selectUsersCamp(pidPaths);
|
|
|
+ if (kxsCamp != null) {
|
|
|
//给训练营加金额
|
|
|
- KxsCamp camp = baseMapper.selectById(campUser.getCampId());
|
|
|
- camp.setBonusPool(NumberUtil.add(camp.getBonusPool(), amount));
|
|
|
- camp.setOrderNum(camp.getOrderNum() + number.intValue());
|
|
|
- baseMapper.updateById(camp);
|
|
|
+ kxsCamp.setBonusPool(NumberUtil.add(kxsCamp.getBonusPool(), amount));
|
|
|
+ kxsCamp.setOrderNum(kxsCamp.getOrderNum() + number.intValue());
|
|
|
+ baseMapper.updateById(kxsCamp);
|
|
|
|
|
|
//给创客团队加金额
|
|
|
- campUser.setTeamOrderPool(NumberUtil.add(campUser.getTeamOrderPool(), amount));
|
|
|
- campUser.setTeamOrderNum(campUser.getTeamOrderNum() + number.intValue());
|
|
|
- kxsCampUserService.updateById(campUser);
|
|
|
- log.info("用户{}的上级{}参加训练营{},订单ID{},奖金池{},订单数{}", param.getUserId(), campUser.getUserId(), camp.getId(), param.getId(), camp.getBonusPool(), camp.getOrderNum());
|
|
|
+ KxsCampUser kxsCampUser = kxsCampUserService.getOne(Wrappers.<KxsCampUser>lambdaQuery()
|
|
|
+ .eq(KxsCampUser::getCampId, kxsCamp.getId())
|
|
|
+ .eq(KxsCampUser::getUserId, param.getUserId()));
|
|
|
+ //给创客团队加金额
|
|
|
+ kxsCampUser.setTeamOrderPool(NumberUtil.add(kxsCampUser.getTeamOrderPool(), amount));
|
|
|
+ kxsCampUser.setTeamOrderNum(kxsCampUser.getTeamOrderNum() + number.intValue());
|
|
|
+ kxsCampUserService.updateById(kxsCampUser);
|
|
|
+ log.info("用户{}的上级{}参加训练营{},订单ID{},奖金池{},订单数{}", param.getUserId(), kxsCampUser.getUserId(), kxsCamp.getId(), param.getId(), kxsCamp.getBonusPool(), kxsCamp.getOrderNum());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// if(param.getProductId() == 12 || param.getProductId() == 13){
|
|
|
-// log.info("开始处理大小盟主下单订单号:{}统计到训练营奖金池", param.getOrderNo());
|
|
|
-//
|
|
|
-// //查询此用户是否参加进行中的训练营
|
|
|
-// KxsCamp kxsCamp = baseMapper.selectUserCamp(param.getUserId(), now);
|
|
|
-// if (kxsCamp != null) {
|
|
|
-// //给训练营加下单数
|
|
|
-// kxsCamp.setOrderNum(kxsCamp.getOrderNum() + 1);
|
|
|
-// baseMapper.updateById(kxsCamp);
|
|
|
-//
|
|
|
-// //给创客团队加下单数
|
|
|
-// KxsCampUser kxsCampUser = kxsCampUserService.getOne(Wrappers.<KxsCampUser>lambdaQuery()
|
|
|
-// .eq(KxsCampUser::getCampId, kxsCamp.getId())
|
|
|
-// .eq(KxsCampUser::getUserId, param.getUserId()));
|
|
|
-// kxsCampUser.setTeamOrderNum(kxsCampUser.getTeamOrderNum() + 1);
|
|
|
-// kxsCampUserService.updateById(kxsCampUser);
|
|
|
-// log.info("用户{}参加训练营{},订单ID{}, 订单数{}", param.getUserId(), kxsCamp.getId(), param.getId(), kxsCamp.getOrderNum());
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// //查找此用户上级倒序后参加了训练营,把奖金加入到自己和训练营里
|
|
|
-// R<KxsUser> kxsUserR = remoteKxsUserService.loadUserById(param.getUserId(), SecurityConstants.FROM_IN);
|
|
|
-// KxsUser user = RetOps.of(kxsUserR)
|
|
|
-// .getData()
|
|
|
-// .orElseThrow(() -> new GlobalCustomerException(ErrorTypeEnum.USER_NOT_FOUND.getDescription()));
|
|
|
-// //下单用户的上级路径
|
|
|
-// String[] pidPaths = user.getPidPath().split(StrPool.COMMA);
|
|
|
-// //翻转上级从最近的开始查询
|
|
|
-// Arrays.sort(pidPaths, Collections.reverseOrder());
|
|
|
-// KxsCampUser campUser = baseMapper.selectUsersCamp(pidPaths, now);
|
|
|
-// if (campUser != null) {
|
|
|
-// //给训练营加下单数
|
|
|
-// KxsCamp camp = baseMapper.selectById(campUser.getCampId());
|
|
|
-// camp.setOrderNum(camp.getOrderNum() + 1);
|
|
|
-// baseMapper.updateById(camp);
|
|
|
-//
|
|
|
-// //给创客团队加下单数
|
|
|
-// campUser.setTeamOrderNum(campUser.getTeamOrderNum() + 1);
|
|
|
-// kxsCampUserService.updateById(campUser);
|
|
|
-// log.info("用户{}的上级{}参加训练营{},订单ID{}, 奖金池{},订单数{}", param.getUserId(), campUser.getUserId(), camp.getId(), param.getId(), camp.getBonusPool(), camp.getOrderNum());
|
|
|
-// }
|
|
|
-// }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Async
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void campOpenNumStat(CampOpenNumStatDTO param) {
|
|
|
+
|
|
|
+ //绑定时间
|
|
|
+ LocalDateTime bindTime = LocalDateTimeUtil.parse(param.getBindTime(), DatePattern.UTC_SIMPLE_PATTERN);
|
|
|
+ //查询当前用户参加的训练营
|
|
|
+ KxsCamp kxsCamp = baseMapper.selectUserCamp(param.getUserId().intValue());
|
|
|
+ if (kxsCamp != null) {
|
|
|
+ //判断绑定时间
|
|
|
+ if (!LocalDateTimeUtil.isIn(bindTime, kxsCamp.getStartTime(), kxsCamp.getEndTime(), false, false)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //给训练营加金额
|
|
|
+ kxsCamp.setOpenNum(kxsCamp.getOpenNum() + (param.getActType() == 4 ? 2 : 1));
|
|
|
+ baseMapper.updateById(kxsCamp);
|
|
|
+
|
|
|
+ //给创客团队加金额
|
|
|
+ KxsCampUser kxsCampUser = kxsCampUserService.getOne(Wrappers.<KxsCampUser>lambdaQuery()
|
|
|
+ .eq(KxsCampUser::getCampId, kxsCamp.getId())
|
|
|
+ .eq(KxsCampUser::getUserId, param.getUserId()));
|
|
|
+
|
|
|
+ switch (param.getActType()){
|
|
|
+ case 1 -> kxsCampUser.setTeamPosNum(kxsCampUser.getTeamPosNum() + 1);
|
|
|
+ case 2 -> kxsCampUser.setTeamGdNum(kxsCampUser.getTeamGdNum() + 1);
|
|
|
+ case 3 -> kxsCampUser.setTeamLkbNum(kxsCampUser.getTeamLkbNum() + 1);
|
|
|
+ case 4 -> kxsCampUser.setTeamLkbNum(kxsCampUser.getTeamLkbNum() + 2);
|
|
|
+ }
|
|
|
+ kxsCampUser.setTeamOpenNum(kxsCampUser.getTeamPosNum() + kxsCampUser.getTeamGdNum() + kxsCampUser.getTeamLkbNum());
|
|
|
+ kxsCampUserService.updateById(kxsCampUser);
|
|
|
+ log.info("用户{}参加训练营{},开机数+1", param.getUserId(), kxsCamp.getId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //查找此用户上级倒序后参加了训练营,把奖金加入到自己和训练营里
|
|
|
+ R<KxsUser> kxsUserR = remoteKxsUserService.loadUserById(param.getUserId(), SecurityConstants.FROM_IN);
|
|
|
+ KxsUser user = RetOps.of(kxsUserR)
|
|
|
+ .getData()
|
|
|
+ .orElseThrow(() -> new GlobalCustomerException(ErrorTypeEnum.USER_NOT_FOUND.getDescription()));
|
|
|
+ //下单用户的上级路径
|
|
|
+ String[] pidPaths = user.getPidPath().split(StrPool.COMMA);
|
|
|
+ //翻转上级从最近的开始查询
|
|
|
+ Arrays.sort(pidPaths, Collections.reverseOrder());
|
|
|
+ kxsCamp = baseMapper.selectUsersCamp(pidPaths);
|
|
|
+ if (kxsCamp != null) {
|
|
|
+ //判断绑定时间
|
|
|
+ if (!LocalDateTimeUtil.isIn(bindTime, kxsCamp.getStartTime(), kxsCamp.getEndTime(), false, false)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ kxsCamp.setOpenNum(kxsCamp.getOpenNum() + (param.getActType() == 4 ? 2 : 1));
|
|
|
+ baseMapper.updateById(kxsCamp);
|
|
|
+
|
|
|
+ //给创客团队加金额
|
|
|
+ KxsCampUser kxsCampUser = kxsCampUserService.getOne(Wrappers.<KxsCampUser>lambdaQuery()
|
|
|
+ .eq(KxsCampUser::getCampId, kxsCamp.getId())
|
|
|
+ .eq(KxsCampUser::getUserId, param.getUserId()));
|
|
|
+ //给创客团队加金额
|
|
|
+ switch (param.getActType()){
|
|
|
+ case 1 -> kxsCampUser.setTeamPosNum(kxsCampUser.getTeamPosNum() + 1);
|
|
|
+ case 2 -> kxsCampUser.setTeamGdNum(kxsCampUser.getTeamGdNum() + 1);
|
|
|
+ case 3 -> kxsCampUser.setTeamLkbNum(kxsCampUser.getTeamLkbNum() + 1);
|
|
|
+ case 4 -> kxsCampUser.setTeamLkbNum(kxsCampUser.getTeamLkbNum() + 2);
|
|
|
+ }
|
|
|
+ kxsCampUser.setTeamOpenNum(kxsCampUser.getTeamPosNum() + kxsCampUser.getTeamGdNum() + kxsCampUser.getTeamLkbNum());
|
|
|
+ kxsCampUserService.updateById(kxsCampUser);
|
|
|
+ log.info("用户{}的上级{}参加训练营{},开机数+1", param.getUserId(), kxsCampUser.getUserId(), kxsCamp.getId());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -297,7 +327,7 @@ public class KxsCampServiceImpl extends ServiceImpl<KxsCampMapper, KxsCamp> impl
|
|
|
//查询正在进行中的活动
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
//定时任务执行中时,查询当前正在进行的活动,由于定时任务执行时间偏差,当前时间减1一分钟判断
|
|
|
- List<KxsCamp> list = baseMapper.selectList(Wrappers.<KxsCamp>lambdaQuery().le(KxsCamp::getStartTime, now).ge(KxsCamp::getEndTime, now.minusMinutes(1)));
|
|
|
+ List<KxsCamp> list = baseMapper.selectList(Wrappers.<KxsCamp>lambdaQuery().eq(KxsCamp::getStatus, CampStatusEnum.STATUS_NORMAL.getType()));
|
|
|
//查询活动参与的创客
|
|
|
for (KxsCamp kxsCamp : list) {
|
|
|
|
|
|
@@ -330,7 +360,9 @@ public class KxsCampServiceImpl extends ServiceImpl<KxsCampMapper, KxsCamp> impl
|
|
|
//刷新参与创客的团队累计
|
|
|
KxsCampUser kxsCampUser = campUsersMap.get(leader.getUserId());
|
|
|
kxsCampUser.setTeamLeaderNum(kxsCampUser.getTeamLeaderNum() + 1);
|
|
|
- log.info("参与者{}自己下单盟主,进入到{}奖金池", leader.getUserId(), kxsCamp.getTitle());
|
|
|
+ kxsCampUserService.update(Wrappers.<KxsCampUser>lambdaUpdate().eq(KxsCampUser::getId, kxsCampUser.getId()).set(KxsCampUser::getTeamLeaderNum, kxsCampUser.getTeamLeaderNum()));
|
|
|
+ this.update(Wrappers.<KxsCamp>lambdaUpdate().eq(KxsCamp::getId, kxsCamp.getId()).set(KxsCamp::getOrderNum, kxsCamp.getOrderNum() + 1));
|
|
|
+ log.info("参与者{}自己下单盟主,进入到{}订单统计", leader.getUserId(), kxsCamp.getTitle());
|
|
|
continue;
|
|
|
}
|
|
|
//查询此盟主的上级
|
|
|
@@ -343,50 +375,15 @@ public class KxsCampServiceImpl extends ServiceImpl<KxsCampMapper, KxsCamp> impl
|
|
|
//通过用户的pidPath倒序查找最近所属的上级
|
|
|
Integer userId = SysUtils.checkUserIsChildren(pidPaths, userIds);
|
|
|
if (userId != null) {
|
|
|
-
|
|
|
//刷新参与创客的团队累计
|
|
|
KxsCampUser kxsCampUser = campUsersMap.get(userId);
|
|
|
kxsCampUser.setTeamLeaderNum(kxsCampUser.getTeamLeaderNum() + 1);
|
|
|
- log.info("创客:{}的团队购买盟主:{},进入到:{}奖金池", userId, leader.getUserId(), kxsCamp.getTitle());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /*
|
|
|
- * 查询活动区间开机数
|
|
|
- */
|
|
|
- for (Integer userId : campUsersMap.keySet()) {
|
|
|
- KxsCampUser kxsCampUser = campUsersMap.get(userId);
|
|
|
-
|
|
|
- HashMap<String, Object> data = new HashMap<>();
|
|
|
- data.put("UserId", userId);
|
|
|
- data.put("StartTime", LocalDateTimeUtil.format(kxsCamp.getStartTime(), DatePattern.PURE_DATE_PATTERN));
|
|
|
- data.put("EndTime", LocalDateTimeUtil.format(kxsCamp.getStartTime(), DatePattern.PURE_DATE_PATTERN));
|
|
|
- R resR = remoteOldService.teamOpenTotalData(JSON.toJSONString(data));
|
|
|
- if (resR.getStatus() == 1) {
|
|
|
- if (resR.getData() != null) {
|
|
|
- JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(resR.getData()));
|
|
|
- int total = jsonObject.getInteger("TeamPosMerchantCount")
|
|
|
- + jsonObject.getInteger("TeamSimMerchantCount")
|
|
|
- + jsonObject.getInteger("TeamMpMerchantCount");
|
|
|
- kxsCampUser.setTeamOpenNum(kxsCampUser.getTeamOpenNum() + total);
|
|
|
- }
|
|
|
+ kxsCampUserService.update(Wrappers.<KxsCampUser>lambdaUpdate().eq(KxsCampUser::getId, kxsCampUser.getId()).set(KxsCampUser::getTeamLeaderNum, kxsCampUser.getTeamLeaderNum()));
|
|
|
+ this.update(Wrappers.<KxsCamp>lambdaUpdate().eq(KxsCamp::getId, kxsCamp.getId()).set(KxsCamp::getOrderNum, kxsCamp.getOrderNum() + 1));
|
|
|
+ log.info("创客{}的上级{}参与训练营,进入到{}订单统计", leader.getUserId(), userId, kxsCamp.getTitle());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- //刷新参与创客的统计
|
|
|
- int openNum = 0;
|
|
|
- int orderNum = 0;
|
|
|
- for (KxsCampUser value : campUsersMap.values()) {
|
|
|
- openNum = openNum + value.getTeamOpenNum();
|
|
|
- orderNum = orderNum + value.getTeamOrderNum() + value.getTeamLeaderNum();
|
|
|
- kxsCampUserService.updateById(value);
|
|
|
- }
|
|
|
- kxsCamp.setOrderNum(orderNum);
|
|
|
- kxsCamp.setOpenNum(openNum);
|
|
|
- baseMapper.updateById(kxsCamp);
|
|
|
- log.info("训练营{}统计结束", kxsCamp.getCampNum());
|
|
|
-
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -403,7 +400,7 @@ public class KxsCampServiceImpl extends ServiceImpl<KxsCampMapper, KxsCamp> impl
|
|
|
if(Objects.equals(camp.getStatus(), CampStatusEnum.STATUS_END.getType())){
|
|
|
return R.failed("已结束的训练营无法再次开启");
|
|
|
}
|
|
|
- if(Objects.equals(camp.getStatus(), CampStatusEnum.STATUS_NORMAL.getType())){
|
|
|
+ if(Objects.equals(camp.getStatus(), param.getStatus())){
|
|
|
return R.failed("训练营已开启");
|
|
|
}
|
|
|
|
|
|
@@ -422,6 +419,8 @@ public class KxsCampServiceImpl extends ServiceImpl<KxsCampMapper, KxsCamp> impl
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
// private <T> void statusChange(T campT, LocalDateTime now) {
|
|
|
// if (campT instanceof KxsCamp camp) {
|
|
|
// if (camp.getEndTime().isBefore(now)) {
|