|
|
@@ -0,0 +1,107 @@
|
|
|
+package com.kxs.system.biz.task;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DatePattern;
|
|
|
+import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.kxs.common.core.constant.SecurityConstants;
|
|
|
+import com.kxs.common.core.constant.enums.ErrorTypeEnum;
|
|
|
+import com.kxs.common.core.exception.GlobalCustomerException;
|
|
|
+import com.kxs.common.core.util.R;
|
|
|
+import com.kxs.common.core.util.RetOps;
|
|
|
+import com.kxs.common.security.annotation.Inner;
|
|
|
+import com.kxs.product.api.feign.RemoteKxsProductService;
|
|
|
+import com.kxs.product.api.vo.kxsapp.shop.ShopOrderGoodsUserVO;
|
|
|
+import com.kxs.system.api.model.KxsCamp;
|
|
|
+import com.kxs.system.api.model.KxsCampUser;
|
|
|
+import com.kxs.system.biz.constant.enums.CampStatusEnum;
|
|
|
+import com.kxs.system.biz.service.KxsCampService;
|
|
|
+import com.kxs.system.biz.service.KxsCampUserService;
|
|
|
+import com.kxs.user.api.feign.RemoteKxsUserService;
|
|
|
+import com.kxs.user.api.model.KxsUser;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * KXS 系统模块异步任务
|
|
|
+ *
|
|
|
+ * @author 没秃顶的码农
|
|
|
+ * @date 2024-04-09
|
|
|
+ */
|
|
|
+@RequiredArgsConstructor
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("system-job")
|
|
|
+public class KxsSystemTask {
|
|
|
+
|
|
|
+ private final KxsCampService kxsCampService;
|
|
|
+
|
|
|
+ private final KxsCampUserService kxsCampUserService;
|
|
|
+
|
|
|
+ private final RemoteKxsProductService remoteKxsProductService;
|
|
|
+
|
|
|
+ private final RemoteKxsUserService remoteKxsUserService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ 奖金池计算方式
|
|
|
+ 1.个人及散下团队购买电签券/大POS券1组,1组计入60元,1组按实收金额5%计算;
|
|
|
+ 2.分期大盟主,按具体情况实收金额5%计入;
|
|
|
+ 团队开机统计方式
|
|
|
+ 1.统计方式:个人及散下团队开通广电卡、来客吧、pos商户
|
|
|
+ 2.广电卡统计:激活成功+1
|
|
|
+ 3.pos商户统计:激活成功+1
|
|
|
+ 4.来客吧商户统计: 商户任意通道待签约+1
|
|
|
+ 团队下单统计方式
|
|
|
+ 1.个人及散下团队购买电签券/大POS券计1组
|
|
|
+ * 一个小时执行一次
|
|
|
+ * 异步执行
|
|
|
+ */
|
|
|
+ @Inner
|
|
|
+ @GetMapping("/taskSubmitOrderAddCamp")
|
|
|
+ public void taskSubmitOrderAddCamp(@RequestParam("param") String para) {
|
|
|
+ //查询正在进行中的活动
|
|
|
+ List<KxsCamp> list = kxsCampService.list(Wrappers.<KxsCamp>lambdaQuery().eq(KxsCamp::getStatus, CampStatusEnum.STATUS_NORMAL.getType()));
|
|
|
+ //查询活动参与的创客
|
|
|
+ for (KxsCamp kxsCamp : list) {
|
|
|
+ //初始化奖金池
|
|
|
+ BigDecimal totalBonusPool = BigDecimal.ZERO;
|
|
|
+ int openNum;
|
|
|
+ int orderNum;
|
|
|
+ List<KxsCampUser> campUsers = kxsCampUserService.list(Wrappers.<KxsCampUser>lambdaQuery().eq(KxsCampUser::getCampId, kxsCamp.getId()));
|
|
|
+ //转换为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) {
|
|
|
+ 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 pidPath = user.getPidPath();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|