胡锐 1 month ago
commit 09f4fa317c
  1. 25
      bweb/src/main/java/com/hfkj/controller/SysSettingController.java
  2. 26
      bweb/src/main/java/com/hfkj/controller/partner/PartnerController.java
  3. 2
      cweb/src/main/java/com/hfkj/controller/partner/PartnerController.java
  4. 12
      schedule/src/main/java/com/hfkj/schedule/LotterySchedule.java
  5. 2
      service/src/main/java/com/hfkj/service/partner/BsPartnerUserRecordService.java
  6. 4
      service/src/main/java/com/hfkj/service/partner/Impl/BsPartnerUserRecordServiceImpl.java
  7. 19
      service/src/main/java/com/hfkj/service/partner/Impl/PartnerServiceImpl.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);
}
}
}

@ -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<String , Object> map = new HashMap<>();
map.put("status" , 1);
map.put("level" , level);
map.put("lotteryNo" , lotteryNo);
List<BsPartnerPoolPre> 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);
}
}
}

@ -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();
// 查询当期用户内容

@ -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("分红失败!!!");
}
}

@ -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

@ -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<BsPartnerUserRecord> list = bsPartnerUserRecordMapper.selectByExample(example);
if (!list.isEmpty()) {

@ -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<String,Object> redisTemplate;
private final String LOCK_KEY = "PARTNER_LOCK_";
@ -413,6 +415,17 @@ public class PartnerServiceImpl implements PartnerService {
// 查询分红等级
List<BsPartnerLevel> partnerLevels = bsPartnerLevelService.queryAllList(new HashMap<>());
String lotteryNo = DateUtil.date2String(new Date() , DateUtil.YMD);
// 查询总奖池
// 查询当期用户内容
Map<String , Object> mapPool = new HashMap<>();
mapPool.put("status" , 1);
mapPool.put("lotteryNo" , lotteryNo);
List<BsPartnerPoolPre> 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);

Loading…
Cancel
Save