|
@@ -8,8 +8,6 @@ import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -23,19 +21,17 @@ import com.kxs.common.core.util.RetOps;
|
|
|
import com.kxs.common.core.util.SysUtils;
|
|
import com.kxs.common.core.util.SysUtils;
|
|
|
import com.kxs.common.security.util.SecurityUtils;
|
|
import com.kxs.common.security.util.SecurityUtils;
|
|
|
import com.kxs.product.api.feign.RemoteKxsProductService;
|
|
import com.kxs.product.api.feign.RemoteKxsProductService;
|
|
|
-import com.kxs.product.api.model.KxsMachine;
|
|
|
|
|
import com.kxs.product.api.vo.kxsapp.shop.ShopOrderGoodsUserVO;
|
|
import com.kxs.product.api.vo.kxsapp.shop.ShopOrderGoodsUserVO;
|
|
|
import com.kxs.system.api.feign.RemoteOldService;
|
|
import com.kxs.system.api.feign.RemoteOldService;
|
|
|
import com.kxs.system.api.model.KxsCampUser;
|
|
import com.kxs.system.api.model.KxsCampUser;
|
|
|
import com.kxs.system.api.vo.admin.CampUserExcelVO;
|
|
import com.kxs.system.api.vo.admin.CampUserExcelVO;
|
|
|
import com.kxs.system.api.vo.kxsapp.camp.CampGetByIdVO;
|
|
import com.kxs.system.api.vo.kxsapp.camp.CampGetByIdVO;
|
|
|
import com.kxs.system.api.vo.kxsapp.camp.CampPageVO;
|
|
import com.kxs.system.api.vo.kxsapp.camp.CampPageVO;
|
|
|
|
|
+import com.kxs.system.biz.amqp.rabbit.RabbitOrderQueueMQ;
|
|
|
import com.kxs.system.biz.constant.enums.CampStatusEnum;
|
|
import com.kxs.system.biz.constant.enums.CampStatusEnum;
|
|
|
import com.kxs.system.biz.constant.enums.SysErrorTypeEnum;
|
|
import com.kxs.system.biz.constant.enums.SysErrorTypeEnum;
|
|
|
import com.kxs.system.biz.mapper.KxsCampMapper;
|
|
import com.kxs.system.biz.mapper.KxsCampMapper;
|
|
|
import com.kxs.system.api.model.KxsCamp;
|
|
import com.kxs.system.api.model.KxsCamp;
|
|
|
-import com.kxs.system.biz.mapper.KxsCampUserMapper;
|
|
|
|
|
-import com.kxs.system.biz.service.KxsCampBonusLogService;
|
|
|
|
|
import com.kxs.system.biz.service.KxsCampService;
|
|
import com.kxs.system.biz.service.KxsCampService;
|
|
|
import com.kxs.system.biz.service.KxsCampUserService;
|
|
import com.kxs.system.biz.service.KxsCampUserService;
|
|
|
import com.kxs.user.api.feign.RemoteKxsUserService;
|
|
import com.kxs.user.api.feign.RemoteKxsUserService;
|
|
@@ -44,12 +40,10 @@ import com.kxs.user.api.model.KxsUser;
|
|
|
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
|
|
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
import org.springframework.scheduling.annotation.EnableAsync;
|
|
import org.springframework.scheduling.annotation.EnableAsync;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.BindingResult;
|
|
import org.springframework.validation.BindingResult;
|
|
|
|
|
|
|
|
-import javax.json.Json;
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -76,7 +70,6 @@ public class KxsCampServiceImpl extends ServiceImpl<KxsCampMapper, KxsCamp> impl
|
|
|
private final KxsCampUserService kxsCampUserService;
|
|
private final KxsCampUserService kxsCampUserService;
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public R addData(KxsCamp param) {
|
|
public R addData(KxsCamp param) {
|
|
|
|
|
|
|
@@ -94,11 +87,11 @@ public class KxsCampServiceImpl extends ServiceImpl<KxsCampMapper, KxsCamp> impl
|
|
|
@Override
|
|
@Override
|
|
|
public R updateData(KxsCamp param) {
|
|
public R updateData(KxsCamp param) {
|
|
|
|
|
|
|
|
- if(param.getId() == null){
|
|
|
|
|
|
|
+ if (param.getId() == null) {
|
|
|
return R.failed(SysErrorTypeEnum.PARAM_ERROR.getDescription());
|
|
return R.failed(SysErrorTypeEnum.PARAM_ERROR.getDescription());
|
|
|
}
|
|
}
|
|
|
KxsCamp kxsCamp = baseMapper.selectById(param.getId());
|
|
KxsCamp kxsCamp = baseMapper.selectById(param.getId());
|
|
|
- if(kxsCamp == null){
|
|
|
|
|
|
|
+ if (kxsCamp == null) {
|
|
|
return R.failed(SysErrorTypeEnum.NOT_DATA.getDescription());
|
|
return R.failed(SysErrorTypeEnum.NOT_DATA.getDescription());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -134,19 +127,19 @@ public class KxsCampServiceImpl extends ServiceImpl<KxsCampMapper, KxsCamp> impl
|
|
|
.getData()
|
|
.getData()
|
|
|
.orElse(null);
|
|
.orElse(null);
|
|
|
KxsCamp kxsCamp = baseMapper.selectById(excel.getCampId());
|
|
KxsCamp kxsCamp = baseMapper.selectById(excel.getCampId());
|
|
|
- if(kxsCamp == null){
|
|
|
|
|
|
|
+ if (kxsCamp == null) {
|
|
|
return R.failed(excel.getCampId() + "训练营编号不存在,请重新上传!");
|
|
return R.failed(excel.getCampId() + "训练营编号不存在,请重新上传!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (Objects.isNull(user)) {
|
|
if (Objects.isNull(user)) {
|
|
|
errorMsg.add(excel.getUserCode() + "创客未找到!");
|
|
errorMsg.add(excel.getUserCode() + "创客未找到!");
|
|
|
- }else{
|
|
|
|
|
- if(user.getRealStatus() != 1){
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (user.getRealStatus() != 1) {
|
|
|
errorMsg.add(excel.getUserCode() + "创客未实名!");
|
|
errorMsg.add(excel.getUserCode() + "创客未实名!");
|
|
|
}
|
|
}
|
|
|
//判断创客是否已在其他训练营
|
|
//判断创客是否已在其他训练营
|
|
|
KxsCampUser kxsCampUser = baseMapper.selectByUserId(user.getId(), now);
|
|
KxsCampUser kxsCampUser = baseMapper.selectByUserId(user.getId(), now);
|
|
|
- if(kxsCampUser != null){
|
|
|
|
|
|
|
+ if (kxsCampUser != null) {
|
|
|
errorMsg.add(excel.getUserCode() + "已在训练营!");
|
|
errorMsg.add(excel.getUserCode() + "已在训练营!");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -164,8 +157,7 @@ public class KxsCampServiceImpl extends ServiceImpl<KxsCampMapper, KxsCamp> impl
|
|
|
campUser.setUsername(user.getUsername());
|
|
campUser.setUsername(user.getUsername());
|
|
|
campUser.setUserCode(user.getUserCode());
|
|
campUser.setUserCode(user.getUserCode());
|
|
|
kxsCampUserService.save(campUser);
|
|
kxsCampUserService.save(campUser);
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
|
|
+ } else {
|
|
|
// 数据不合法
|
|
// 数据不合法
|
|
|
errorMessageList.add(new ErrorMessage(excel.getLineNum(), errorMsg));
|
|
errorMessageList.add(new ErrorMessage(excel.getLineNum(), errorMsg));
|
|
|
}
|
|
}
|
|
@@ -197,7 +189,7 @@ public class KxsCampServiceImpl extends ServiceImpl<KxsCampMapper, KxsCamp> impl
|
|
|
@Override
|
|
@Override
|
|
|
public R getByData(Integer id) {
|
|
public R getByData(Integer id) {
|
|
|
KxsCamp kxsCamp = baseMapper.selectById(id);
|
|
KxsCamp kxsCamp = baseMapper.selectById(id);
|
|
|
- if(kxsCamp == null){
|
|
|
|
|
|
|
+ if (kxsCamp == null) {
|
|
|
return R.failed(SysErrorTypeEnum.NOT_DATA.getDescription());
|
|
return R.failed(SysErrorTypeEnum.NOT_DATA.getDescription());
|
|
|
}
|
|
}
|
|
|
statusChange(kxsCamp, LocalDateTime.now());
|
|
statusChange(kxsCamp, LocalDateTime.now());
|
|
@@ -206,6 +198,60 @@ public class KxsCampServiceImpl extends ServiceImpl<KxsCampMapper, KxsCamp> impl
|
|
|
return R.ok(campGetByIdVO);
|
|
return R.ok(campGetByIdVO);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void prizePoolIsRefreshed(RabbitOrderQueueMQ.MsgEntity parse) {
|
|
|
|
|
+ //查询正在进行中的活动
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+ //兑换券下单
|
|
|
|
|
+ if(parse.getGoodsId() == 11 || parse.getGoodsId() == 12) {
|
|
|
|
|
+
|
|
|
|
|
+ //订单奖金
|
|
|
|
|
+ BigDecimal amount = NumberUtil.mul(NumberUtil.div(parse.getTotalPrice(), 600), 90);
|
|
|
|
|
+ //查询此用户是否参加进行中的训练营
|
|
|
|
|
+ KxsCamp kxsCamp = baseMapper.selectUserCamp(parse.getUserId(), now);
|
|
|
|
|
+ if (kxsCamp != null) {
|
|
|
|
|
+ //给训练营加金额
|
|
|
|
|
+ kxsCamp.setBonusPool(NumberUtil.add(kxsCamp.getBonusPool(), amount));
|
|
|
|
|
+ kxsCamp.setOrderNum(kxsCamp.getOrderNum() + 1);
|
|
|
|
|
+ baseMapper.updateById(kxsCamp);
|
|
|
|
|
+
|
|
|
|
|
+ //给创客团队加金额
|
|
|
|
|
+ KxsCampUser kxsCampUser = kxsCampUserService.getOne(Wrappers.<KxsCampUser>lambdaQuery()
|
|
|
|
|
+ .eq(KxsCampUser::getCampId, kxsCamp.getId())
|
|
|
|
|
+ .eq(KxsCampUser::getUserId, parse.getUserId()));
|
|
|
|
|
+ kxsCampUser.setTeamOrderPool(NumberUtil.add(kxsCampUser.getTeamOrderPool(), amount));
|
|
|
|
|
+ kxsCampUser.setTeamOrderNum(kxsCampUser.getTeamOrderNum() + 1);
|
|
|
|
|
+ kxsCampUserService.updateById(kxsCampUser);
|
|
|
|
|
+ log.info("用户{}参加训练营{},订单ID{}, 奖金池{},订单数{}", parse.getUserId(), kxsCamp.getId(), parse.getOrderId(), kxsCamp.getBonusPool(), kxsCamp.getOrderNum());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ //查找此用户上级倒序后参加了训练营,把奖金加入到自己和训练营里
|
|
|
|
|
+ R<KxsUser> kxsUserR = remoteKxsUserService.loadUserById(parse.getUserId(), SecurityConstants.FROM_IN);
|
|
|
|
|
+ KxsUser user = RetOps.of(kxsUserR)
|
|
|
|
|
+ .getData()
|
|
|
|
|
+ .orElseThrow(() -> new GlobalCustomerException(ErrorTypeEnum.USER_NOT_FOUND.getDescription()));
|
|
|
|
|
+ //下单用户的上级路径
|
|
|
|
|
+ String[] pidPaths = user.getPidPath().split(",");
|
|
|
|
|
+ //翻转上级从最近的开始查询
|
|
|
|
|
+ Arrays.sort(pidPaths, Collections.reverseOrder());
|
|
|
|
|
+ KxsCampUser campUser = baseMapper.selectUsersCamp(pidPaths, now);
|
|
|
|
|
+ if (campUser != null) {
|
|
|
|
|
+ //给训练营加金额
|
|
|
|
|
+ KxsCamp camp = baseMapper.selectById(campUser.getCampId());
|
|
|
|
|
+ camp.setBonusPool(NumberUtil.add(camp.getBonusPool(), amount));
|
|
|
|
|
+ camp.setOrderNum(camp.getOrderNum() + 1);
|
|
|
|
|
+ baseMapper.updateById(camp);
|
|
|
|
|
+
|
|
|
|
|
+ //给创客团队加金额
|
|
|
|
|
+ campUser.setTeamOrderPool(NumberUtil.add(campUser.getTeamOrderPool(), amount));
|
|
|
|
|
+ campUser.setTeamOrderNum(campUser.getTeamOrderNum() + 1);
|
|
|
|
|
+ kxsCampUserService.updateById(campUser);
|
|
|
|
|
+ log.info("用户{}的上级{}参加训练营{},订单ID{}, 奖金池{},订单数{}", parse.getUserId(), campUser.getUserId(), camp.getId(), parse.getOrderId(), camp.getBonusPool(), camp.getOrderNum());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public IPage<KxsCamp> getBySysPage(Page<KxsCamp> page, KxsCamp param) {
|
|
public IPage<KxsCamp> getBySysPage(Page<KxsCamp> page, KxsCamp param) {
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
@@ -217,208 +263,206 @@ public class KxsCampServiceImpl extends ServiceImpl<KxsCampMapper, KxsCamp> impl
|
|
|
return pageData;
|
|
return pageData;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- @Async("getAsyncExecutor")
|
|
|
|
|
- public void prizePoolIsRefreshed() {
|
|
|
|
|
- //查询正在进行中的活动
|
|
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
- //定时任务执行中时,查询当前正在进行的活动,由于定时任务执行时间偏差,当前时间减1一分钟判断
|
|
|
|
|
- List<KxsCamp> list = baseMapper.selectList(Wrappers.<KxsCamp>lambdaQuery().le(KxsCamp::getStartTime, now).ge(KxsCamp::getEndTime, now.minusMinutes(1)));
|
|
|
|
|
- //查询活动参与的创客
|
|
|
|
|
- for (KxsCamp kxsCamp : list) {
|
|
|
|
|
- //初始化奖金池
|
|
|
|
|
- BigDecimal totalBonusPool = BigDecimal.ZERO;
|
|
|
|
|
- //开机数
|
|
|
|
|
- int openNum = 0;
|
|
|
|
|
- //下单数
|
|
|
|
|
- int orderNum = 0;
|
|
|
|
|
-
|
|
|
|
|
- List<KxsCampUser> campUsers = kxsCampUserService.list(Wrappers.<KxsCampUser>lambdaQuery().eq(KxsCampUser::getCampId, kxsCamp.getId()));
|
|
|
|
|
- //清除参与创客的所有统计数据然后封装在map里方便统计
|
|
|
|
|
- Map<Integer, KxsCampUser> campUsersMap = new HashMap<>();
|
|
|
|
|
- for (KxsCampUser campUser : campUsers) {
|
|
|
|
|
- KxsCampUser kxsCampUser = new KxsCampUser();
|
|
|
|
|
- BeanUtil.copyProperties(campUser, kxsCampUser);
|
|
|
|
|
- kxsCampUser.setTeamOrderPool(BigDecimal.ZERO);
|
|
|
|
|
- kxsCampUser.setTeamLeaderPool(BigDecimal.ZERO);
|
|
|
|
|
- kxsCampUser.setTeamOrderNum(0);
|
|
|
|
|
- kxsCampUser.setTeamLeaderNum(0);
|
|
|
|
|
- kxsCampUser.setTeamOpenNum(0);
|
|
|
|
|
- campUsersMap.put(campUser.getUserId(), kxsCampUser);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //转换为userID集合
|
|
|
|
|
- List<Integer> userIds = campUsers.stream().map(KxsCampUser::getUserId).toList();
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- /*
|
|
|
|
|
- * 查询当前活动的时间区间所有电签大机的订单
|
|
|
|
|
- */
|
|
|
|
|
- R<List<ShopOrderGoodsUserVO>> ordersR = remoteKxsProductService.getDateBetweenOrders(LocalDateTimeUtil.format(kxsCamp.getStartTime(), DatePattern.NORM_DATETIME_PATTERN)
|
|
|
|
|
- , LocalDateTimeUtil.format(kxsCamp.getEndTime(), DatePattern.NORM_DATETIME_PATTERN), SecurityConstants.FROM_IN);
|
|
|
|
|
- List<ShopOrderGoodsUserVO> orders = RetOps.of(ordersR)
|
|
|
|
|
- .getData()
|
|
|
|
|
- .orElse(Collections.emptyList());
|
|
|
|
|
- //循环区间订单查询用户的上级是否包含参与创客的ID
|
|
|
|
|
- for (ShopOrderGoodsUserVO order : orders) {
|
|
|
|
|
- //如果是参与者自己下的单
|
|
|
|
|
- if (userIds.contains(order.getUserId())) {
|
|
|
|
|
- int currentNum = NumberUtil.div(order.getTotalPrice(), 600).intValue();
|
|
|
|
|
- //刷新参与创客的团队累计
|
|
|
|
|
- KxsCampUser kxsCampUser = campUsersMap.get(order.getUserId());
|
|
|
|
|
- BigDecimal amount = NumberUtil.mul(NumberUtil.div(order.getTotalPrice(), 600), 90);
|
|
|
|
|
- totalBonusPool = NumberUtil.add(totalBonusPool, amount);
|
|
|
|
|
- //兑换券下单
|
|
|
|
|
- kxsCampUser.setTeamOrderPool(NumberUtil.add(kxsCampUser.getTeamOrderPool(), amount));
|
|
|
|
|
- kxsCampUser.setTeamOrderNum(kxsCampUser.getTeamOrderNum() + currentNum);
|
|
|
|
|
-// if(order.getId() == 27 || order.getId() == 28){
|
|
|
|
|
-// //大小盟主下单, 奖金池+60,订单数+1
|
|
|
|
|
-// kxsCampUser.setTeamLeaderPool(NumberUtil.add(kxsCampUser.getTeamLeaderPool(), 60));
|
|
|
|
|
-// kxsCampUser.setTeamLeaderNum(kxsCampUser.getTeamLeaderNum() + 1);
|
|
|
|
|
-// currentNum = 1;
|
|
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public void prizePoolIsRefreshed(RabbitOrderQueueMQ.MsgEntity parse) {
|
|
|
|
|
+// //查询正在进行中的活动
|
|
|
|
|
+// LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+// //定时任务执行中时,查询当前正在进行的活动,由于定时任务执行时间偏差,当前时间减1一分钟判断
|
|
|
|
|
+// List<KxsCamp> list = baseMapper.selectList(Wrappers.<KxsCamp>lambdaQuery().le(KxsCamp::getStartTime, now).ge(KxsCamp::getEndTime, now.minusMinutes(1)));
|
|
|
|
|
+// //查询活动参与的创客
|
|
|
|
|
+// for (KxsCamp kxsCamp : list) {
|
|
|
|
|
+// //初始化奖金池
|
|
|
|
|
+// BigDecimal totalBonusPool = BigDecimal.ZERO;
|
|
|
|
|
+// //开机数
|
|
|
|
|
+// int openNum = 0;
|
|
|
|
|
+// //下单数
|
|
|
|
|
+// int orderNum = 0;
|
|
|
|
|
+//
|
|
|
|
|
+// List<KxsCampUser> campUsers = kxsCampUserService.list(Wrappers.<KxsCampUser>lambdaQuery().eq(KxsCampUser::getCampId, kxsCamp.getId()));
|
|
|
|
|
+// //清除参与创客的所有统计数据然后封装在map里方便统计
|
|
|
|
|
+// Map<Integer, KxsCampUser> campUsersMap = new HashMap<>();
|
|
|
|
|
+// for (KxsCampUser campUser : campUsers) {
|
|
|
|
|
+// KxsCampUser kxsCampUser = new KxsCampUser();
|
|
|
|
|
+// BeanUtil.copyProperties(campUser, kxsCampUser);
|
|
|
|
|
+// kxsCampUser.setTeamOrderPool(BigDecimal.ZERO);
|
|
|
|
|
+// kxsCampUser.setTeamLeaderPool(BigDecimal.ZERO);
|
|
|
|
|
+// kxsCampUser.setTeamOrderNum(0);
|
|
|
|
|
+// kxsCampUser.setTeamLeaderNum(0);
|
|
|
|
|
+// kxsCampUser.setTeamOpenNum(0);
|
|
|
|
|
+// campUsersMap.put(campUser.getUserId(), kxsCampUser);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// //转换为userID集合
|
|
|
|
|
+// List<Integer> userIds = campUsers.stream().map(KxsCampUser::getUserId).toList();
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// /*
|
|
|
|
|
+// * 查询当前活动的时间区间所有电签大机的订单
|
|
|
|
|
+// */
|
|
|
|
|
+// R<List<ShopOrderGoodsUserVO>> ordersR = remoteKxsProductService.getDateBetweenOrders(LocalDateTimeUtil.format(kxsCamp.getStartTime(), DatePattern.NORM_DATETIME_PATTERN)
|
|
|
|
|
+// , LocalDateTimeUtil.format(kxsCamp.getEndTime(), DatePattern.NORM_DATETIME_PATTERN), SecurityConstants.FROM_IN);
|
|
|
|
|
+// List<ShopOrderGoodsUserVO> orders = RetOps.of(ordersR)
|
|
|
|
|
+// .getData()
|
|
|
|
|
+// .orElse(Collections.emptyList());
|
|
|
|
|
+// //循环区间订单查询用户的上级是否包含参与创客的ID
|
|
|
|
|
+// for (ShopOrderGoodsUserVO order : orders) {
|
|
|
|
|
+// //如果是参与者自己下的单
|
|
|
|
|
+// if (userIds.contains(order.getUserId())) {
|
|
|
|
|
+// int currentNum = NumberUtil.div(order.getTotalPrice(), 600).intValue();
|
|
|
|
|
+// //刷新参与创客的团队累计
|
|
|
|
|
+// KxsCampUser kxsCampUser = campUsersMap.get(order.getUserId());
|
|
|
|
|
+// BigDecimal amount = NumberUtil.mul(NumberUtil.div(order.getTotalPrice(), 600), 90);
|
|
|
|
|
+// totalBonusPool = NumberUtil.add(totalBonusPool, amount);
|
|
|
|
|
+// //兑换券下单
|
|
|
|
|
+// kxsCampUser.setTeamOrderPool(NumberUtil.add(kxsCampUser.getTeamOrderPool(), amount));
|
|
|
|
|
+// kxsCampUser.setTeamOrderNum(kxsCampUser.getTeamOrderNum() + currentNum);
|
|
|
|
|
+//// if(order.getId() == 27 || order.getId() == 28){
|
|
|
|
|
+//// //大小盟主下单, 奖金池+60,订单数+1
|
|
|
|
|
+//// kxsCampUser.setTeamLeaderPool(NumberUtil.add(kxsCampUser.getTeamLeaderPool(), 60));
|
|
|
|
|
+//// kxsCampUser.setTeamLeaderNum(kxsCampUser.getTeamLeaderNum() + 1);
|
|
|
|
|
+//// currentNum = 1;
|
|
|
|
|
+//// }
|
|
|
|
|
+// orderNum += currentNum;
|
|
|
|
|
+// continue;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// R<KxsUser> kxsUserR = remoteKxsUserService.loadUserById(order.getUserId(), SecurityConstants.FROM_IN);
|
|
|
|
|
+// KxsUser user = RetOps.of(kxsUserR)
|
|
|
|
|
+// .getData()
|
|
|
|
|
+// .orElseThrow(() -> new GlobalCustomerException(ErrorTypeEnum.USER_NOT_FOUND.getDescription()));
|
|
|
|
|
+// //下单用户的上级路径
|
|
|
|
|
+// String[] pidPaths = user.getPidPath().split(",");
|
|
|
|
|
+// //通过用户的pidPath倒序查找最近所属的上级
|
|
|
|
|
+// Integer userId = SysUtils.checkUserIsChildren(pidPaths, userIds);
|
|
|
|
|
+// if(userId != null){
|
|
|
|
|
+// int currentNum = NumberUtil.div(order.getTotalPrice(), 600).intValue();
|
|
|
|
|
+// //刷新参与创客的团队累计
|
|
|
|
|
+// KxsCampUser kxsCampUser = campUsersMap.get(userId);
|
|
|
|
|
+// BigDecimal amount = NumberUtil.mul(NumberUtil.div(order.getTotalPrice(), 600), 90);
|
|
|
|
|
+// totalBonusPool = NumberUtil.add(totalBonusPool, amount);
|
|
|
|
|
+//
|
|
|
|
|
+// kxsCampUser.setTeamOrderPool(NumberUtil.add(kxsCampUser.getTeamOrderPool(), amount));
|
|
|
|
|
+// kxsCampUser.setTeamOrderNum(kxsCampUser.getTeamOrderNum() + currentNum);
|
|
|
|
|
+//// if(order.getId() == 27 || order.getId() == 28){
|
|
|
|
|
+//// //大小盟主下单, 奖金池+60,订单数+1
|
|
|
|
|
+//// kxsCampUser.setTeamLeaderPool(NumberUtil.add(kxsCampUser.getTeamLeaderPool(), 60));
|
|
|
|
|
+//// kxsCampUser.setTeamLeaderNum(kxsCampUser.getTeamLeaderNum() + 1);
|
|
|
|
|
+//// currentNum = 1;
|
|
|
|
|
+//// }
|
|
|
|
|
+// orderNum += currentNum;
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// /*
|
|
|
|
|
+// * 查询活动区间开通的大盟主添加到奖金池
|
|
|
|
|
+// */
|
|
|
|
|
+// R<List<KxsLeader>> leadersR = remoteKxsUserService.getDateBetweenLeaders(LocalDateTimeUtil.format(kxsCamp.getStartTime(), DatePattern.NORM_DATETIME_PATTERN)
|
|
|
|
|
+// , LocalDateTimeUtil.format(kxsCamp.getEndTime(), DatePattern.NORM_DATETIME_PATTERN), SecurityConstants.FROM_IN);
|
|
|
|
|
+// List<KxsLeader> leaders = RetOps.of(leadersR)
|
|
|
|
|
+// .getData()
|
|
|
|
|
+// .orElse(Collections.emptyList());
|
|
|
|
|
+// for (KxsLeader leader : leaders) {
|
|
|
|
|
+// //如果是参与者自己下的单
|
|
|
|
|
+// if (userIds.contains(leader.getUserId())) {
|
|
|
|
|
+// BigDecimal amount;
|
|
|
|
|
+// if(leader.getLeaderType().equals(LeaderTypeEnum.SMALL_LEADER.getType())){
|
|
|
|
|
+// amount = new BigDecimal("2000");
|
|
|
|
|
+// }else{
|
|
|
|
|
+// amount = new BigDecimal("8000");
|
|
|
// }
|
|
// }
|
|
|
- orderNum += currentNum;
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- R<KxsUser> kxsUserR = remoteKxsUserService.loadUserById(order.getUserId(), SecurityConstants.FROM_IN);
|
|
|
|
|
- KxsUser user = RetOps.of(kxsUserR)
|
|
|
|
|
- .getData()
|
|
|
|
|
- .orElseThrow(() -> new GlobalCustomerException(ErrorTypeEnum.USER_NOT_FOUND.getDescription()));
|
|
|
|
|
- //下单用户的上级路径
|
|
|
|
|
- String[] pidPaths = user.getPidPath().split(",");
|
|
|
|
|
- //通过用户的pidPath倒序查找最近所属的上级
|
|
|
|
|
- Integer userId = SysUtils.checkUserIsChildren(pidPaths, userIds);
|
|
|
|
|
- if(userId != null){
|
|
|
|
|
- int currentNum = NumberUtil.div(order.getTotalPrice(), 600).intValue();
|
|
|
|
|
- //刷新参与创客的团队累计
|
|
|
|
|
- KxsCampUser kxsCampUser = campUsersMap.get(userId);
|
|
|
|
|
- BigDecimal amount = NumberUtil.mul(NumberUtil.div(order.getTotalPrice(), 600), 90);
|
|
|
|
|
- totalBonusPool = NumberUtil.add(totalBonusPool, amount);
|
|
|
|
|
-
|
|
|
|
|
- kxsCampUser.setTeamOrderPool(NumberUtil.add(kxsCampUser.getTeamOrderPool(), amount));
|
|
|
|
|
- kxsCampUser.setTeamOrderNum(kxsCampUser.getTeamOrderNum() + currentNum);
|
|
|
|
|
-// if(order.getId() == 27 || order.getId() == 28){
|
|
|
|
|
-// //大小盟主下单, 奖金池+60,订单数+1
|
|
|
|
|
-// kxsCampUser.setTeamLeaderPool(NumberUtil.add(kxsCampUser.getTeamLeaderPool(), 60));
|
|
|
|
|
-// kxsCampUser.setTeamLeaderNum(kxsCampUser.getTeamLeaderNum() + 1);
|
|
|
|
|
-// currentNum = 1;
|
|
|
|
|
|
|
+// totalBonusPool = NumberUtil.add(totalBonusPool, amount);
|
|
|
|
|
+//
|
|
|
|
|
+// //刷新参与创客的团队累计
|
|
|
|
|
+// KxsCampUser kxsCampUser = campUsersMap.get(leader.getUserId());
|
|
|
|
|
+// kxsCampUser.setTeamLeaderPool(NumberUtil.add(kxsCampUser.getTeamLeaderPool(), amount));
|
|
|
|
|
+// kxsCampUser.setTeamLeaderNum(kxsCampUser.getTeamLeaderNum() + 1);
|
|
|
|
|
+// orderNum += 1;
|
|
|
|
|
+// log.info("参与者{}自己下单盟主,进入到{}奖金池", leader.getUserId(), kxsCamp.getTitle());
|
|
|
|
|
+// continue;
|
|
|
|
|
+// }
|
|
|
|
|
+// //查询此盟主的上级
|
|
|
|
|
+// R<KxsUser> kxsUserR = remoteKxsUserService.loadUserById(leader.getUserId(), SecurityConstants.FROM_IN);
|
|
|
|
|
+// KxsUser user = RetOps.of(kxsUserR)
|
|
|
|
|
+// .getData()
|
|
|
|
|
+// .orElseThrow(() -> new GlobalCustomerException(ErrorTypeEnum.USER_NOT_FOUND.getDescription()));
|
|
|
|
|
+// //下单用户的上级路径
|
|
|
|
|
+// String[] pidPaths = user.getPidPath().split(",");
|
|
|
|
|
+// //通过用户的pidPath倒序查找最近所属的上级
|
|
|
|
|
+// Integer userId = SysUtils.checkUserIsChildren(pidPaths, userIds);
|
|
|
|
|
+// if(userId != null){
|
|
|
|
|
+// BigDecimal amount;
|
|
|
|
|
+// if(leader.getLeaderType().equals(LeaderTypeEnum.SMALL_LEADER.getType())){
|
|
|
|
|
+// amount = new BigDecimal("2000");
|
|
|
|
|
+// }else{
|
|
|
|
|
+// amount = new BigDecimal("8000");
|
|
|
// }
|
|
// }
|
|
|
- orderNum += currentNum;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /*
|
|
|
|
|
- * 查询活动区间开通的大盟主添加到奖金池
|
|
|
|
|
- */
|
|
|
|
|
- R<List<KxsLeader>> leadersR = remoteKxsUserService.getDateBetweenLeaders(LocalDateTimeUtil.format(kxsCamp.getStartTime(), DatePattern.NORM_DATETIME_PATTERN)
|
|
|
|
|
- , LocalDateTimeUtil.format(kxsCamp.getEndTime(), DatePattern.NORM_DATETIME_PATTERN), SecurityConstants.FROM_IN);
|
|
|
|
|
- List<KxsLeader> leaders = RetOps.of(leadersR)
|
|
|
|
|
- .getData()
|
|
|
|
|
- .orElse(Collections.emptyList());
|
|
|
|
|
- for (KxsLeader leader : leaders) {
|
|
|
|
|
- //如果是参与者自己下的单
|
|
|
|
|
- if (userIds.contains(leader.getUserId())) {
|
|
|
|
|
- BigDecimal amount;
|
|
|
|
|
- if(leader.getLeaderType().equals(LeaderTypeEnum.SMALL_LEADER.getType())){
|
|
|
|
|
- amount = new BigDecimal("2000");
|
|
|
|
|
- }else{
|
|
|
|
|
- amount = new BigDecimal("8000");
|
|
|
|
|
- }
|
|
|
|
|
- totalBonusPool = NumberUtil.add(totalBonusPool, amount);
|
|
|
|
|
-
|
|
|
|
|
- //刷新参与创客的团队累计
|
|
|
|
|
- KxsCampUser kxsCampUser = campUsersMap.get(leader.getUserId());
|
|
|
|
|
- kxsCampUser.setTeamLeaderPool(NumberUtil.add(kxsCampUser.getTeamLeaderPool(), amount));
|
|
|
|
|
- kxsCampUser.setTeamLeaderNum(kxsCampUser.getTeamLeaderNum() + 1);
|
|
|
|
|
- orderNum += 1;
|
|
|
|
|
- log.info("参与者{}自己下单盟主,进入到{}奖金池", leader.getUserId(), kxsCamp.getTitle());
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- //查询此盟主的上级
|
|
|
|
|
- R<KxsUser> kxsUserR = remoteKxsUserService.loadUserById(leader.getUserId(), SecurityConstants.FROM_IN);
|
|
|
|
|
- KxsUser user = RetOps.of(kxsUserR)
|
|
|
|
|
- .getData()
|
|
|
|
|
- .orElseThrow(() -> new GlobalCustomerException(ErrorTypeEnum.USER_NOT_FOUND.getDescription()));
|
|
|
|
|
- //下单用户的上级路径
|
|
|
|
|
- String[] pidPaths = user.getPidPath().split(",");
|
|
|
|
|
- //通过用户的pidPath倒序查找最近所属的上级
|
|
|
|
|
- Integer userId = SysUtils.checkUserIsChildren(pidPaths, userIds);
|
|
|
|
|
- if(userId != null){
|
|
|
|
|
- BigDecimal amount;
|
|
|
|
|
- if(leader.getLeaderType().equals(LeaderTypeEnum.SMALL_LEADER.getType())){
|
|
|
|
|
- amount = new BigDecimal("2000");
|
|
|
|
|
- }else{
|
|
|
|
|
- amount = new BigDecimal("8000");
|
|
|
|
|
- }
|
|
|
|
|
- totalBonusPool = NumberUtil.add(totalBonusPool, amount);
|
|
|
|
|
-
|
|
|
|
|
- //刷新参与创客的团队累计
|
|
|
|
|
- KxsCampUser kxsCampUser = campUsersMap.get(userId);
|
|
|
|
|
- kxsCampUser.setTeamLeaderPool(NumberUtil.add(kxsCampUser.getTeamLeaderPool(), amount));
|
|
|
|
|
- kxsCampUser.setTeamLeaderNum(kxsCampUser.getTeamLeaderNum() + 1);
|
|
|
|
|
- orderNum += 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");
|
|
|
|
|
- openNum += total;
|
|
|
|
|
- kxsCampUser.setTeamOpenNum(kxsCampUser.getTeamOpenNum() + total);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- kxsCamp.setBonusPool(totalBonusPool);
|
|
|
|
|
- kxsCamp.setOrderNum(orderNum);
|
|
|
|
|
- kxsCamp.setOpenNum(openNum);
|
|
|
|
|
- baseMapper.updateById(kxsCamp);
|
|
|
|
|
- //刷新参与创客的统计
|
|
|
|
|
- kxsCampUserService.updateBatchById(new ArrayList<>(campUsersMap.values()));
|
|
|
|
|
- log.info("训练营{}统计结束", kxsCamp.getCampNum());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+// totalBonusPool = NumberUtil.add(totalBonusPool, amount);
|
|
|
|
|
+//
|
|
|
|
|
+// //刷新参与创客的团队累计
|
|
|
|
|
+// KxsCampUser kxsCampUser = campUsersMap.get(userId);
|
|
|
|
|
+// kxsCampUser.setTeamLeaderPool(NumberUtil.add(kxsCampUser.getTeamLeaderPool(), amount));
|
|
|
|
|
+// kxsCampUser.setTeamLeaderNum(kxsCampUser.getTeamLeaderNum() + 1);
|
|
|
|
|
+// orderNum += 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");
|
|
|
|
|
+// openNum += total;
|
|
|
|
|
+// kxsCampUser.setTeamOpenNum(kxsCampUser.getTeamOpenNum() + total);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// kxsCamp.setBonusPool(totalBonusPool);
|
|
|
|
|
+// kxsCamp.setOrderNum(orderNum);
|
|
|
|
|
+// kxsCamp.setOpenNum(openNum);
|
|
|
|
|
+// baseMapper.updateById(kxsCamp);
|
|
|
|
|
+// //刷新参与创客的统计
|
|
|
|
|
+// kxsCampUserService.updateBatchById(new ArrayList<>(campUsersMap.values()));
|
|
|
|
|
+// log.info("训练营{}统计结束", kxsCamp.getCampNum());
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 状态变更
|
|
* 状态变更
|
|
|
*
|
|
*
|
|
|
* @param campT 营地
|
|
* @param campT 营地
|
|
|
- * @param now 现在
|
|
|
|
|
|
|
+ * @param now 现在
|
|
|
*/
|
|
*/
|
|
|
- private <T> void statusChange(T campT, LocalDateTime now){
|
|
|
|
|
- if(campT instanceof KxsCamp camp){
|
|
|
|
|
- if(camp.getEndTime().isBefore(now)){
|
|
|
|
|
|
|
+ private <T> void statusChange(T campT, LocalDateTime now) {
|
|
|
|
|
+ if (campT instanceof KxsCamp camp) {
|
|
|
|
|
+ if (camp.getEndTime().isBefore(now)) {
|
|
|
camp.setStatus(CampStatusEnum.STATUS_END.getType());
|
|
camp.setStatus(CampStatusEnum.STATUS_END.getType());
|
|
|
} else if (LocalDateTimeUtil.isIn(now, camp.getStartTime(), camp.getEndTime(), false, false)) {
|
|
} else if (LocalDateTimeUtil.isIn(now, camp.getStartTime(), camp.getEndTime(), false, false)) {
|
|
|
camp.setStatus(CampStatusEnum.STATUS_NORMAL.getType());
|
|
camp.setStatus(CampStatusEnum.STATUS_NORMAL.getType());
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
camp.setStatus(CampStatusEnum.STATUS_CLOSE.getType());
|
|
camp.setStatus(CampStatusEnum.STATUS_CLOSE.getType());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if(campT instanceof CampPageVO camp){
|
|
|
|
|
- if(camp.getEndTime().isBefore(now)){
|
|
|
|
|
|
|
+ if (campT instanceof CampPageVO camp) {
|
|
|
|
|
+ if (camp.getEndTime().isBefore(now)) {
|
|
|
camp.setStatus(CampStatusEnum.STATUS_END.getType());
|
|
camp.setStatus(CampStatusEnum.STATUS_END.getType());
|
|
|
} else if (LocalDateTimeUtil.isIn(now, camp.getStartTime(), camp.getEndTime(), false, false)) {
|
|
} else if (LocalDateTimeUtil.isIn(now, camp.getStartTime(), camp.getEndTime(), false, false)) {
|
|
|
camp.setStatus(CampStatusEnum.STATUS_NORMAL.getType());
|
|
camp.setStatus(CampStatusEnum.STATUS_NORMAL.getType());
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
camp.setStatus(CampStatusEnum.STATUS_CLOSE.getType());
|
|
camp.setStatus(CampStatusEnum.STATUS_CLOSE.getType());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|