From c60bec460fb494f15c972fc73ba90be4915c8d3b Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Mon, 16 Dec 2024 15:16:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BC=80=E5=A5=96=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=20=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=81=9A=E5=AE=9D=E7=9B=86=E5=BC=80=E5=A5=96=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hfkj/schedule/LotterySchedule.java | 43 ++++++++++++++++++ .../com/hfkj/entity/BsCornucopiaConfig.java | 2 +- .../Impl/BsCornucopiaPoolServiceImpl.java | 44 ++++++++++++++++++- .../order/Impl/BsOrderServiceImpl.java | 18 ++++++++ 4 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 schedule/src/main/java/com/hfkj/schedule/LotterySchedule.java diff --git a/schedule/src/main/java/com/hfkj/schedule/LotterySchedule.java b/schedule/src/main/java/com/hfkj/schedule/LotterySchedule.java new file mode 100644 index 0000000..1b18e1e --- /dev/null +++ b/schedule/src/main/java/com/hfkj/schedule/LotterySchedule.java @@ -0,0 +1,43 @@ +package com.hfkj.schedule; + +import com.hfkj.service.cornucopia.BsCornucopiaPoolService; +import com.hfkj.service.partner.PartnerService; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * @ClassName LotterySchedule + * @Author Sum1Dream + * @Description 开奖定时任务 + * @Date 2024/11/4 下午2:48 + **/ +@Component +public class LotterySchedule { + @Resource + private PartnerService partnerService; + + @Resource + private BsCornucopiaPoolService cornucopiaPoolService; + + @Scheduled(cron = "0 30 23 * * ?") // 每日23:30:00 执行一次 + public void startCampaign() { + try { + partnerService.startCampaign(); + + } catch (Exception e) { + System.out.println("统计失败!!!"); + } + } + + @Scheduled(cron = "0 0 20 * * ?") // 每日20:00:00 执行一次 + public void cornucopiaLottery() { + try { + cornucopiaPoolService.cornucopiaLottery(); + + } catch (Exception e) { + System.out.println("统计失败!!!"); + } + } +} diff --git a/service/src/main/java/com/hfkj/entity/BsCornucopiaConfig.java b/service/src/main/java/com/hfkj/entity/BsCornucopiaConfig.java index 3c83eb9..991d7a3 100644 --- a/service/src/main/java/com/hfkj/entity/BsCornucopiaConfig.java +++ b/service/src/main/java/com/hfkj/entity/BsCornucopiaConfig.java @@ -20,7 +20,7 @@ public class BsCornucopiaConfig implements Serializable { private Long id; /** - * 类型:1:金聚宝盆增值回报 2:玉聚宝盆增值回报 + * 类型:1:高值回报 2:低增值回报 */ private Integer type; diff --git a/service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaPoolServiceImpl.java b/service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaPoolServiceImpl.java index 98cd08e..c05e92b 100644 --- a/service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaPoolServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaPoolServiceImpl.java @@ -18,6 +18,7 @@ import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum; import com.hfkj.sysenum.user.UserAccountRecordTypeEnum; import com.hfkj.sysenum.user.UserGradeEnum; import org.apache.commons.collections4.MapUtils; +import org.springframework.beans.BeanUtils; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; @@ -302,8 +303,49 @@ public class BsCornucopiaPoolServiceImpl implements BsCornucopiaPoolService { @Override public void cornucopiaLottery() throws Exception { + + // 创建Random对象 + Random random = new Random(); + + // 生成1或2之间的随机整数 + int randomNumber = random.nextInt(2) + 1; + // 查询聚宝盆配置参数 - List cornucopiaConfigList = cornucopiaConfigService.queryAllList(new HashMap<>()); + List cornucopiaConfigS = cornucopiaConfigService.queryAllList(new HashMap<>()); + // 高收益 + BsCornucopiaConfig configHigh = cornucopiaConfigS.stream().filter(s->s.getType().equals(1)).findFirst().orElse(null); + // 低收益 + BsCornucopiaConfig configLow = cornucopiaConfigS.stream().filter(s->s.getType().equals(2)).findFirst().orElse(null); + // 初始化金玉聚宝盆 + List cornucopiaConfigList = new ArrayList<>(); + // 1:金聚宝盆 2:玉聚宝盆 + for (BsCornucopiaConfig cornucopiaConfig : cornucopiaConfigS) { + BsCornucopiaConfig config = new BsCornucopiaConfig(); + BeanUtils.copyProperties(cornucopiaConfig , config); + cornucopiaConfigList.add(config); + } + + // 开出金 + if (randomNumber == 1) { + if (configHigh != null && configLow != null) { + cornucopiaConfigList.get(0).setProportion(configHigh.getProportion()); + cornucopiaConfigList.get(1).setProportion(configLow.getProportion()); + cornucopiaConfigList.get(0).setName("金聚宝盆"); + cornucopiaConfigList.get(1).setName("玉聚宝盆"); + + } + } + // 开出玉 + if (randomNumber == 2) { + if (configHigh != null && configLow != null) { + cornucopiaConfigList.get(1).setProportion(configHigh.getProportion()); + cornucopiaConfigList.get(0).setProportion(configLow.getProportion()); + cornucopiaConfigList.get(1).setName("玉聚宝盆"); + cornucopiaConfigList.get(0).setName("金聚宝盆"); + + } + } + if (cornucopiaConfigList.isEmpty()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "啊偶~没有配置参数!"); } diff --git a/service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java index 0875358..32f3ba3 100644 --- a/service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java @@ -18,6 +18,7 @@ import com.hfkj.model.BsOrderModel; import com.hfkj.model.UserTeamModel; import com.hfkj.service.elm.ElmService; import com.hfkj.service.meituan.MeiTuanService; +import com.hfkj.service.message.BsMessageService; import com.hfkj.service.order.BsOrderService; import com.hfkj.service.order.OrderBusinessService; import com.hfkj.service.pdd.PddService; @@ -27,6 +28,7 @@ import com.hfkj.service.taobao.TaoBaoService; import com.hfkj.service.user.BsUserContributeService; import com.hfkj.service.user.BsUserParentRelService; import com.hfkj.service.user.BsUserService; +import com.hfkj.sysenum.message.MessageTypeEnum; import com.hfkj.sysenum.partner.PartnerEnum; import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum; import com.pdd.pop.sdk.http.api.pop.response.PddDdkOrderListRangeGetResponse; @@ -71,14 +73,28 @@ public class BsOrderServiceImpl implements BsOrderService { @Resource private BsUserService userService; + @Resource + private BsMessageService bsMessageService; @Override public void create(BsOrder order) { + // 推送订单消息 + bsMessageService.createUserMsg(MessageTypeEnum.type2 ,order.getUserId() , "创建订单" , "创建订单" + order.getGoodsName() + "成功"); bsOrderMapper.insert(order); } @Override public BsOrder editData(BsOrder order) { + + if (order.getStatus() == 1) { + // 推送订单消息 + bsMessageService.createUserMsg(MessageTypeEnum.type2 ,order.getUserId() , "购买订单" , "下单" + order.getGoodsName() + "成功"); + } + if (order.getStatus() == 2) { + // 推送订单消息 + bsMessageService.createUserMsg(MessageTypeEnum.type2 ,order.getUserId() , "商品收货" , order.getGoodsName() + "收货成功"); + } + bsOrderMapper.updateByPrimaryKey(order); // 删除缓存 cacheDelete(order.getOrderNo()); @@ -266,6 +282,8 @@ public class BsOrderServiceImpl implements BsOrderService { otherParam.put("sourceId", bsOrder.getId()); otherParam.put("sourceOrderNo", bsOrder.getOrderNo()); userContributeService.purchase(bsOrder.getPromotionAmount(), bsOrder.getUserId(), otherParam); + // 推送订单消息 + bsMessageService.createUserMsg(MessageTypeEnum.type2 ,bsOrder.getUserId() , "订单返利" , "购买商品" + bsOrder.getGoodsName() + "返利成功"); bsOrder.setStatus(3); bsOrder.setUpdateTime(new Date()); bsOrder.setFinishTime(new Date());