新增开奖定时任务 ,修改聚宝盆开奖规则

master
袁野 1 month ago
parent 4c393e1ac1
commit c60bec460f
  1. 43
      schedule/src/main/java/com/hfkj/schedule/LotterySchedule.java
  2. 2
      service/src/main/java/com/hfkj/entity/BsCornucopiaConfig.java
  3. 44
      service/src/main/java/com/hfkj/service/cornucopia/Impl/BsCornucopiaPoolServiceImpl.java
  4. 18
      service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.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("统计失败!!!");
}
}
}

@ -20,7 +20,7 @@ public class BsCornucopiaConfig implements Serializable {
private Long id;
/**
* 类型1:金聚宝盆增值回报 2玉聚宝盆增值回报
* 类型1:高值回报 2增值回报
*/
private Integer type;

@ -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<BsCornucopiaConfig> cornucopiaConfigList = cornucopiaConfigService.queryAllList(new HashMap<>());
List<BsCornucopiaConfig> 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<BsCornucopiaConfig> 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, "啊偶~没有配置参数!");
}

@ -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());

Loading…
Cancel
Save