diff --git a/bweb/src/main/java/com/hfkj/controller/SysSettingController.java b/bweb/src/main/java/com/hfkj/controller/SysSettingController.java index 3b12dd3..43dc623 100644 --- a/bweb/src/main/java/com/hfkj/controller/SysSettingController.java +++ b/bweb/src/main/java/com/hfkj/controller/SysSettingController.java @@ -67,4 +67,29 @@ public class SysSettingController { return ResponseMsgUtil.exception(e); } } + + @RequestMapping(value="/partnerDividendsRate",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "合伙人分红汇率") + public ResponseData partnerDividendsRate(@RequestBody JSONObject body) { + try { + if (body == null || body.getBigDecimal("exchangeRate") == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + SecDictionary where = new SecDictionary(); + where.setCodeType("PARTNER_DIVIDENDS_RATE"); + // 查询数据 + SecDictionary dictionary = secDictionaryService.getDictionary("PARTNER_DIVIDENDS_RATE").get(0); + dictionary.setCodeValue(body.getBigDecimal("exchangeRate").toString()); + secDictionaryService.update(where, dictionary); + + // 刷新缓存 + secDictionaryService.refreshCache(); + + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } } diff --git a/bweb/src/main/java/com/hfkj/controller/partner/PartnerController.java b/bweb/src/main/java/com/hfkj/controller/partner/PartnerController.java index 9dace49..b994691 100644 --- a/bweb/src/main/java/com/hfkj/controller/partner/PartnerController.java +++ b/bweb/src/main/java/com/hfkj/controller/partner/PartnerController.java @@ -114,4 +114,30 @@ public class PartnerController { } } + @RequestMapping(value="/getPartnerPool",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询合伙人等级奖池") + public ResponseData getPartnerPool(@RequestParam(value = "level" , required = false) Integer level) { + try { + + // 查询当期 + String lotteryNo = DateUtil.date2String(new Date() , DateUtil.YMD); + JSONObject obj = new JSONObject(); + // 查询当期用户内容 + Map map = new HashMap<>(); + map.put("status" , 1); + map.put("level" , level); + map.put("lotteryNo" , lotteryNo); + List list = bsPartnerPoolPreService.queryAllList(map); + BigDecimal toDayPartner = list.stream().map(BsPartnerPoolPre::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add); + obj.put("toDayPartner" , toDayPartner); + + return ResponseMsgUtil.success(obj); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/cweb/src/main/java/com/hfkj/controller/partner/PartnerController.java b/cweb/src/main/java/com/hfkj/controller/partner/PartnerController.java index 5b05c80..51fdbe9 100644 --- a/cweb/src/main/java/com/hfkj/controller/partner/PartnerController.java +++ b/cweb/src/main/java/com/hfkj/controller/partner/PartnerController.java @@ -112,7 +112,7 @@ public class PartnerController { throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, ""); } - // 查询上一期 + // 查询当期 String lotteryNo = DateUtil.date2String(new Date() , DateUtil.YMD); JSONObject obj = new JSONObject(); // 查询当期用户内容 diff --git a/schedule/src/main/java/com/hfkj/schedule/LotterySchedule.java b/schedule/src/main/java/com/hfkj/schedule/LotterySchedule.java index 1b18e1e..e32a933 100644 --- a/schedule/src/main/java/com/hfkj/schedule/LotterySchedule.java +++ b/schedule/src/main/java/com/hfkj/schedule/LotterySchedule.java @@ -27,7 +27,17 @@ public class LotterySchedule { partnerService.startCampaign(); } catch (Exception e) { - System.out.println("统计失败!!!"); + System.out.println("竞选失败!!!"); + } + } + + @Scheduled(cron = "0 40 23 * * ?") // 每日23:30:00 执行一次 + public void dividend() { + try { + partnerService.dividend(); + + } catch (Exception e) { + System.out.println("分红失败!!!"); } } diff --git a/service/src/main/java/com/hfkj/service/partner/BsPartnerUserRecordService.java b/service/src/main/java/com/hfkj/service/partner/BsPartnerUserRecordService.java index 330ffab..f117752 100644 --- a/service/src/main/java/com/hfkj/service/partner/BsPartnerUserRecordService.java +++ b/service/src/main/java/com/hfkj/service/partner/BsPartnerUserRecordService.java @@ -53,7 +53,7 @@ public interface BsPartnerUserRecordService { * @Author: Sum1Dream * @Date: 2024/10/17 下午5:01 */ - BsPartnerUserRecord queryDetail(String lotteryNo , Long userId); + BsPartnerUserRecord queryDetail(String lotteryNo , Long userId , Integer type); /** * @MethodName queryAllList diff --git a/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerUserRecordServiceImpl.java b/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerUserRecordServiceImpl.java index 3d50404..e536ebb 100644 --- a/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerUserRecordServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerUserRecordServiceImpl.java @@ -51,11 +51,11 @@ public class BsPartnerUserRecordServiceImpl implements BsPartnerUserRecordServic } @Override - public BsPartnerUserRecord queryDetail(String lotteryNo , Long userId) { + public BsPartnerUserRecord queryDetail(String lotteryNo , Long userId , Integer type) { BsPartnerUserRecordExample example = new BsPartnerUserRecordExample(); BsPartnerUserRecordExample.Criteria criteria = example.createCriteria(); - criteria.andLotteryNoEqualTo(lotteryNo).andUserIdEqualTo(userId); + criteria.andLotteryNoEqualTo(lotteryNo).andUserIdEqualTo(userId).andTypeEqualTo(type); List list = bsPartnerUserRecordMapper.selectByExample(example); if (!list.isEmpty()) { diff --git a/service/src/main/java/com/hfkj/service/partner/Impl/PartnerServiceImpl.java b/service/src/main/java/com/hfkj/service/partner/Impl/PartnerServiceImpl.java index f5d1e95..acf3e70 100644 --- a/service/src/main/java/com/hfkj/service/partner/Impl/PartnerServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/partner/Impl/PartnerServiceImpl.java @@ -11,6 +11,7 @@ import com.hfkj.common.utils.DateUtil; import com.hfkj.entity.*; import com.hfkj.model.CornucopiaLotteryRecordModel; import com.hfkj.service.partner.*; +import com.hfkj.service.sec.SecDictionaryService; import com.hfkj.service.user.BsUserAccountService; import com.hfkj.service.user.BsUserService; import com.hfkj.sysenum.cornucopia.CornucopiaEnum; @@ -45,7 +46,8 @@ public class PartnerServiceImpl implements PartnerService { private BsUserAccountService userAccountService; @Resource private BsUserService bsUserService; - + @Resource + private SecDictionaryService secDictionaryService; @Resource private RedisTemplate redisTemplate; private final String LOCK_KEY = "PARTNER_LOCK_"; @@ -413,6 +415,17 @@ public class PartnerServiceImpl implements PartnerService { // 查询分红等级 List partnerLevels = bsPartnerLevelService.queryAllList(new HashMap<>()); String lotteryNo = DateUtil.date2String(new Date() , DateUtil.YMD); + // 查询总奖池 + // 查询当期用户内容 + Map mapPool = new HashMap<>(); + mapPool.put("status" , 1); + mapPool.put("lotteryNo" , lotteryNo); + List list = bsPartnerPoolPreService.queryAllList(mapPool); + BigDecimal toDayPartner = list.stream().map(BsPartnerPoolPre::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add); + // 查询分红汇率 + // 查询数据 + SecDictionary dictionary = secDictionaryService.getDictionary("PARTNER_DIVIDENDS_RATE").get(0); + toDayPartner = toDayPartner.multiply(new BigDecimal(dictionary.getCodeValue())); for (BsPartnerPool pool : partnerPools) { // 判断合伙人是否有金币且用户ID不为空 if (pool.getGoldCoin().compareTo(new BigDecimal(0)) > 0 && pool.getUserId() != null) { @@ -420,7 +433,7 @@ public class PartnerServiceImpl implements PartnerService { BsPartnerLevel level = partnerLevels.stream().filter(s-> s.getLevel().equals(pool.getLevel())).findFirst().get(); // 根据彩票编号和用户ID查询合伙人用户记录 - BsPartnerUserRecord partnerUserRecord = bsPartnerUserRecordService.queryDetail(lotteryNo , pool.getUserId()); + BsPartnerUserRecord partnerUserRecord = bsPartnerUserRecordService.queryDetail(lotteryNo , pool.getUserId() , 1); // 根据用户ID查询用户信息 BsUser user = bsUserService.getUser(pool.getUserId()); @@ -434,7 +447,7 @@ public class PartnerServiceImpl implements PartnerService { partnerUserRecord.setUserId(pool.getUserId()); partnerUserRecord.setUserName(user.getName()); // 计算分红金额 - partnerUserRecord.setGoldCoin(pool.getGoldCoin().multiply(level.getDividendsPer())); + partnerUserRecord.setGoldCoin(toDayPartner.multiply(level.getDividendsPer())); partnerUserRecord.setProportion(level.getDividendsPer()); partnerUserRecord.setType(1); partnerUserRecord.setStatus(1);