|
|
@ -57,6 +57,14 @@ public class PartnerServiceImpl implements PartnerService { |
|
|
|
if (isPartner(jsonObject.getLong("userId"))) { |
|
|
|
if (isPartner(jsonObject.getLong("userId"))) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户当期已投入!"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户当期已投入!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
// 获取当前的小时
|
|
|
|
|
|
|
|
int hour = calendar.get(Calendar.HOUR_OF_DAY); |
|
|
|
|
|
|
|
// 判断当前时间是否在 23点-24点之间
|
|
|
|
|
|
|
|
if (hour >= 23) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前时间不允许投入!"); |
|
|
|
|
|
|
|
} |
|
|
|
Long userId = jsonObject.getLong("userId"); |
|
|
|
Long userId = jsonObject.getLong("userId"); |
|
|
|
BigDecimal goldCoin = jsonObject.getBigDecimal("goldCoin"); |
|
|
|
BigDecimal goldCoin = jsonObject.getBigDecimal("goldCoin"); |
|
|
|
// 锁编号
|
|
|
|
// 锁编号
|
|
|
@ -164,30 +172,40 @@ public class PartnerServiceImpl implements PartnerService { |
|
|
|
List<BsPartnerPoolPre> partnerPoolsPreL5 = partnerPoolPres.stream().filter(s-> s.getLevel().equals(5)).sorted(Comparator.comparing(BsPartnerPoolPre::getCampaignNo)).sorted(Comparator.comparing(BsPartnerPoolPre::getGoldCoin).reversed()).collect(Collectors.toList()); |
|
|
|
List<BsPartnerPoolPre> partnerPoolsPreL5 = partnerPoolPres.stream().filter(s-> s.getLevel().equals(5)).sorted(Comparator.comparing(BsPartnerPoolPre::getCampaignNo)).sorted(Comparator.comparing(BsPartnerPoolPre::getGoldCoin).reversed()).collect(Collectors.toList()); |
|
|
|
List<BsPartnerPoolPre> pres = new ArrayList<>(); |
|
|
|
List<BsPartnerPoolPre> pres = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<BsPartnerLevel> levelList = bsPartnerLevelService.queryAllList(new HashMap<>()); |
|
|
|
|
|
|
|
|
|
|
|
// 查询开奖记录
|
|
|
|
// 查询开奖记录
|
|
|
|
|
|
|
|
// 根据彩票号码查询合伙人池记录
|
|
|
|
BsPartnerPoolRecord partnerPoolRecord = bsPartnerPoolRecordService.queryDetail(lotteryNo); |
|
|
|
BsPartnerPoolRecord partnerPoolRecord = bsPartnerPoolRecordService.queryDetail(lotteryNo); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果合伙人池记录不为空
|
|
|
|
if (partnerPoolRecord != null) { |
|
|
|
if (partnerPoolRecord != null) { |
|
|
|
|
|
|
|
// 如果合伙人池记录状态为2,抛出异常
|
|
|
|
if (partnerPoolRecord.getStatus().equals(2)) { |
|
|
|
if (partnerPoolRecord.getStatus().equals(2)) { |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当期已经竞选结算!"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当期已经竞选结算!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将合伙人池记录状态设置为2
|
|
|
|
partnerPoolRecord.setStatus(2); |
|
|
|
partnerPoolRecord.setStatus(2); |
|
|
|
|
|
|
|
// 设置彩票时间
|
|
|
|
partnerPoolRecord.setLotteryTime(new Date()); |
|
|
|
partnerPoolRecord.setLotteryTime(new Date()); |
|
|
|
|
|
|
|
// 更新合伙人池记录
|
|
|
|
bsPartnerPoolRecordService.edit(partnerPoolRecord); |
|
|
|
bsPartnerPoolRecordService.edit(partnerPoolRecord); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// todo 计算当期的时候需要先预站一个位置 如果当前用户大那么顺序往下走
|
|
|
|
|
|
|
|
// L1参选
|
|
|
|
// L1参选
|
|
|
|
for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL1) { |
|
|
|
for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL1) { |
|
|
|
|
|
|
|
// 如果合伙人池预约状态为1
|
|
|
|
if (partnerPoolPre.getStatus().equals(1)) { |
|
|
|
if (partnerPoolPre.getStatus().equals(1)) { |
|
|
|
// 查询还未被占位的合伙人位置并且当前合伙人金额大于
|
|
|
|
// 查询还未被占位的合伙人位置并且当前合伙人金额大于
|
|
|
|
List<BsPartnerPool> poolList = partnerPoolsL1.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); |
|
|
|
List<BsPartnerPool> poolList = partnerPoolsL1.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 如果查询结果不为空
|
|
|
|
if (!poolList.isEmpty()) { |
|
|
|
if (!poolList.isEmpty()) { |
|
|
|
BsPartnerPool pool = poolList.get(0); |
|
|
|
BsPartnerPool pool = poolList.get(0); |
|
|
|
// 竞选成功
|
|
|
|
// 竞选成功
|
|
|
|
if (pool.getUserId() != null) { |
|
|
|
if (pool.getUserId() != null) { |
|
|
|
campaignPartner(partnerPoolPre , pool); |
|
|
|
BsPartnerLevel level = levelList.stream().filter(s-> s.getLevel().equals(pool.getLevel())).findFirst().orElse(null); |
|
|
|
|
|
|
|
campaignPartner(partnerPoolPre , pool , level); |
|
|
|
} |
|
|
|
} |
|
|
|
// 配置参数
|
|
|
|
// 配置参数
|
|
|
|
pool.setUserId(partnerPoolPre.getUserId()); |
|
|
|
pool.setUserId(partnerPoolPre.getUserId()); |
|
|
@ -212,14 +230,20 @@ public class PartnerServiceImpl implements PartnerService { |
|
|
|
|
|
|
|
|
|
|
|
// L2参选
|
|
|
|
// L2参选
|
|
|
|
for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL2) { |
|
|
|
for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL2) { |
|
|
|
|
|
|
|
// 如果合伙人池预约状态为1
|
|
|
|
if (partnerPoolPre.getStatus().equals(1)) { |
|
|
|
if (partnerPoolPre.getStatus().equals(1)) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询还未被占位的合伙人位置并且当前合伙人金额大于
|
|
|
|
List<BsPartnerPool> poolList = partnerPoolsL2.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); |
|
|
|
List<BsPartnerPool> poolList = partnerPoolsL2.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 如果查询结果不为空
|
|
|
|
if (!poolList.isEmpty()) { |
|
|
|
if (!poolList.isEmpty()) { |
|
|
|
BsPartnerPool pool = poolList.get(0); |
|
|
|
BsPartnerPool pool = poolList.get(0); |
|
|
|
|
|
|
|
// 竞选成功
|
|
|
|
if (pool.getUserId() != null) { |
|
|
|
if (pool.getUserId() != null) { |
|
|
|
campaignPartner(partnerPoolPre , pool); |
|
|
|
BsPartnerLevel level = levelList.stream().filter(s-> s.getLevel().equals(pool.getLevel())).findFirst().orElse(null); |
|
|
|
|
|
|
|
campaignPartner(partnerPoolPre , pool , level); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 配置参数
|
|
|
|
pool.setUserId(partnerPoolPre.getUserId()); |
|
|
|
pool.setUserId(partnerPoolPre.getUserId()); |
|
|
|
pool.setGoldCoin(partnerPoolPre.getGoldCoin()); |
|
|
|
pool.setGoldCoin(partnerPoolPre.getGoldCoin()); |
|
|
|
pools.add(pool); |
|
|
|
pools.add(pool); |
|
|
@ -232,6 +256,7 @@ public class PartnerServiceImpl implements PartnerService { |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 配置预约竞选参数
|
|
|
|
partnerPoolPre.setStatus(2); |
|
|
|
partnerPoolPre.setStatus(2); |
|
|
|
partnerPoolPre.setNum(pool.getNum()); |
|
|
|
partnerPoolPre.setNum(pool.getNum()); |
|
|
|
pres.add(partnerPoolPre); |
|
|
|
pres.add(partnerPoolPre); |
|
|
@ -242,13 +267,19 @@ public class PartnerServiceImpl implements PartnerService { |
|
|
|
|
|
|
|
|
|
|
|
// L3参选
|
|
|
|
// L3参选
|
|
|
|
for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL3) { |
|
|
|
for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL3) { |
|
|
|
|
|
|
|
// 如果合伙人池预约状态为1
|
|
|
|
if (partnerPoolPre.getStatus().equals(1)) { |
|
|
|
if (partnerPoolPre.getStatus().equals(1)) { |
|
|
|
|
|
|
|
// 查询还未被占位的合伙人位置并且当前合伙人金额大于
|
|
|
|
List<BsPartnerPool> poolList = partnerPoolsL3.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); |
|
|
|
List<BsPartnerPool> poolList = partnerPoolsL3.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 如果查询结果不为空
|
|
|
|
if (!poolList.isEmpty()) { |
|
|
|
if (!poolList.isEmpty()) { |
|
|
|
BsPartnerPool pool = poolList.get(0); |
|
|
|
BsPartnerPool pool = poolList.get(0); |
|
|
|
|
|
|
|
// 竞选成功
|
|
|
|
if (pool.getUserId() != null) { |
|
|
|
if (pool.getUserId() != null) { |
|
|
|
campaignPartner(partnerPoolPre , pool); |
|
|
|
BsPartnerLevel level = levelList.stream().filter(s-> s.getLevel().equals(pool.getLevel())).findFirst().orElse(null); |
|
|
|
|
|
|
|
campaignPartner(partnerPoolPre , pool , level); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 配置参数
|
|
|
|
pool.setUserId(partnerPoolPre.getUserId()); |
|
|
|
pool.setUserId(partnerPoolPre.getUserId()); |
|
|
|
pool.setGoldCoin(partnerPoolPre.getGoldCoin()); |
|
|
|
pool.setGoldCoin(partnerPoolPre.getGoldCoin()); |
|
|
|
pools.add(pool); |
|
|
|
pools.add(pool); |
|
|
@ -261,6 +292,7 @@ public class PartnerServiceImpl implements PartnerService { |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 配置预约竞选参数
|
|
|
|
partnerPoolPre.setStatus(2); |
|
|
|
partnerPoolPre.setStatus(2); |
|
|
|
partnerPoolPre.setNum(pool.getNum()); |
|
|
|
partnerPoolPre.setNum(pool.getNum()); |
|
|
|
pres.add(partnerPoolPre); |
|
|
|
pres.add(partnerPoolPre); |
|
|
@ -270,13 +302,19 @@ public class PartnerServiceImpl implements PartnerService { |
|
|
|
|
|
|
|
|
|
|
|
// L4参选
|
|
|
|
// L4参选
|
|
|
|
for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL4) { |
|
|
|
for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL4) { |
|
|
|
|
|
|
|
// 如果合伙人池预约状态为1
|
|
|
|
if (partnerPoolPre.getStatus().equals(1)) { |
|
|
|
if (partnerPoolPre.getStatus().equals(1)) { |
|
|
|
|
|
|
|
// 查询还未被占位的合伙人位置并且当前合伙人金额大于
|
|
|
|
List<BsPartnerPool> poolList = partnerPoolsL4.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); |
|
|
|
List<BsPartnerPool> poolList = partnerPoolsL4.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 如果查询结果不为空
|
|
|
|
if (!poolList.isEmpty()) { |
|
|
|
if (!poolList.isEmpty()) { |
|
|
|
BsPartnerPool pool = poolList.get(0); |
|
|
|
BsPartnerPool pool = poolList.get(0); |
|
|
|
|
|
|
|
// 竞选成功
|
|
|
|
if (pool.getUserId() != null) { |
|
|
|
if (pool.getUserId() != null) { |
|
|
|
campaignPartner(partnerPoolPre , pool); |
|
|
|
BsPartnerLevel level = levelList.stream().filter(s-> s.getLevel().equals(pool.getLevel())).findFirst().orElse(null); |
|
|
|
|
|
|
|
campaignPartner(partnerPoolPre , pool , level); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 配置参数
|
|
|
|
pool.setUserId(partnerPoolPre.getUserId()); |
|
|
|
pool.setUserId(partnerPoolPre.getUserId()); |
|
|
|
pool.setGoldCoin(partnerPoolPre.getGoldCoin()); |
|
|
|
pool.setGoldCoin(partnerPoolPre.getGoldCoin()); |
|
|
|
pools.add(pool); |
|
|
|
pools.add(pool); |
|
|
@ -289,6 +327,7 @@ public class PartnerServiceImpl implements PartnerService { |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 配置预约竞选参数
|
|
|
|
partnerPoolPre.setStatus(2); |
|
|
|
partnerPoolPre.setStatus(2); |
|
|
|
partnerPoolPre.setNum(pool.getNum()); |
|
|
|
partnerPoolPre.setNum(pool.getNum()); |
|
|
|
pres.add(partnerPoolPre); |
|
|
|
pres.add(partnerPoolPre); |
|
|
@ -298,13 +337,19 @@ public class PartnerServiceImpl implements PartnerService { |
|
|
|
|
|
|
|
|
|
|
|
// L5参选
|
|
|
|
// L5参选
|
|
|
|
for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL5) { |
|
|
|
for (BsPartnerPoolPre partnerPoolPre : partnerPoolsPreL5) { |
|
|
|
|
|
|
|
// 如果合伙人池预约状态为1
|
|
|
|
if (partnerPoolPre.getStatus().equals(1)) { |
|
|
|
if (partnerPoolPre.getStatus().equals(1)) { |
|
|
|
|
|
|
|
// 查询还未被占位的合伙人位置并且当前合伙人金额大于
|
|
|
|
List<BsPartnerPool> poolList = partnerPoolsL5.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); |
|
|
|
List<BsPartnerPool> poolList = partnerPoolsL5.stream().filter(s-> s.getGoldCoin().compareTo(partnerPoolPre.getGoldCoin()) < 0).filter(s->s.getStatus().equals(1)).collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 如果查询结果不为空
|
|
|
|
if (!poolList.isEmpty()) { |
|
|
|
if (!poolList.isEmpty()) { |
|
|
|
BsPartnerPool pool = poolList.get(0); |
|
|
|
BsPartnerPool pool = poolList.get(0); |
|
|
|
|
|
|
|
// 竞选成功
|
|
|
|
if (pool.getUserId() != null) { |
|
|
|
if (pool.getUserId() != null) { |
|
|
|
campaignPartner(partnerPoolPre , pool); |
|
|
|
BsPartnerLevel level = levelList.stream().filter(s-> s.getLevel().equals(pool.getLevel())).findFirst().orElse(null); |
|
|
|
|
|
|
|
campaignPartner(partnerPoolPre , pool , level); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 配置参数
|
|
|
|
pool.setUserId(partnerPoolPre.getUserId()); |
|
|
|
pool.setUserId(partnerPoolPre.getUserId()); |
|
|
|
pool.setGoldCoin(partnerPoolPre.getGoldCoin()); |
|
|
|
pool.setGoldCoin(partnerPoolPre.getGoldCoin()); |
|
|
|
pools.add(pool); |
|
|
|
pools.add(pool); |
|
|
@ -317,6 +362,7 @@ public class PartnerServiceImpl implements PartnerService { |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 配置预约竞选参数
|
|
|
|
partnerPoolPre.setStatus(2); |
|
|
|
partnerPoolPre.setStatus(2); |
|
|
|
partnerPoolPre.setNum(pool.getNum()); |
|
|
|
partnerPoolPre.setNum(pool.getNum()); |
|
|
|
pres.add(partnerPoolPre); |
|
|
|
pres.add(partnerPoolPre); |
|
|
@ -324,14 +370,18 @@ public class PartnerServiceImpl implements PartnerService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新合伙人池状态
|
|
|
|
for (BsPartnerPool pool : pools) { |
|
|
|
for (BsPartnerPool pool : pools) { |
|
|
|
pool.setStatus(1); |
|
|
|
pool.setStatus(1); |
|
|
|
pool.setUpdateTime(new Date()); |
|
|
|
pool.setUpdateTime(new Date()); |
|
|
|
bsPartnerPoolService.edit(pool); |
|
|
|
bsPartnerPoolService.edit(pool); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新合伙人池预约状态
|
|
|
|
for (BsPartnerPoolPre partnerPoolPre: pres) { |
|
|
|
for (BsPartnerPoolPre partnerPoolPre: pres) { |
|
|
|
|
|
|
|
// 如果合伙人池预约状态为1
|
|
|
|
if (partnerPoolPre.getStatus().equals(1)) { |
|
|
|
if (partnerPoolPre.getStatus().equals(1)) { |
|
|
|
|
|
|
|
// 将合伙人池预约状态设置为3
|
|
|
|
partnerPoolPre.setStatus(3); |
|
|
|
partnerPoolPre.setStatus(3); |
|
|
|
partnerPoolPre.setUpdateTime(new Date()); |
|
|
|
partnerPoolPre.setUpdateTime(new Date()); |
|
|
|
BsUser user = bsUserService.getUser(partnerPoolPre.getUserId()); |
|
|
|
BsUser user = bsUserService.getUser(partnerPoolPre.getUserId()); |
|
|
@ -347,7 +397,6 @@ public class PartnerServiceImpl implements PartnerService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -358,12 +407,17 @@ public class PartnerServiceImpl implements PartnerService { |
|
|
|
List<BsPartnerLevel> partnerLevels = bsPartnerLevelService.queryAllList(new HashMap<>()); |
|
|
|
List<BsPartnerLevel> partnerLevels = bsPartnerLevelService.queryAllList(new HashMap<>()); |
|
|
|
String lotteryNo = DateUtil.date2String(new Date() , DateUtil.YMD); |
|
|
|
String lotteryNo = DateUtil.date2String(new Date() , DateUtil.YMD); |
|
|
|
for (BsPartnerPool pool : partnerPools) { |
|
|
|
for (BsPartnerPool pool : partnerPools) { |
|
|
|
|
|
|
|
// 判断合伙人是否有金币且用户ID不为空
|
|
|
|
if (pool.getGoldCoin().compareTo(new BigDecimal(0)) > 0 && pool.getUserId() != null) { |
|
|
|
if (pool.getGoldCoin().compareTo(new BigDecimal(0)) > 0 && pool.getUserId() != null) { |
|
|
|
|
|
|
|
// 根据合伙人等级查询分红等级
|
|
|
|
BsPartnerLevel level = partnerLevels.stream().filter(s-> s.getLevel().equals(pool.getLevel())).findFirst().get(); |
|
|
|
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()); |
|
|
|
|
|
|
|
// 根据用户ID查询用户信息
|
|
|
|
BsUser user = bsUserService.getUser(pool.getUserId()); |
|
|
|
BsUser user = bsUserService.getUser(pool.getUserId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果合伙人用户记录为空,则创建新的合伙人用户记录
|
|
|
|
if (partnerUserRecord == null) { |
|
|
|
if (partnerUserRecord == null) { |
|
|
|
partnerUserRecord = new BsPartnerUserRecord(); |
|
|
|
partnerUserRecord = new BsPartnerUserRecord(); |
|
|
|
partnerUserRecord.setCreateTime(new Date()); |
|
|
|
partnerUserRecord.setCreateTime(new Date()); |
|
|
@ -372,6 +426,7 @@ public class PartnerServiceImpl implements PartnerService { |
|
|
|
partnerUserRecord.setLotteryTime(new Date()); |
|
|
|
partnerUserRecord.setLotteryTime(new Date()); |
|
|
|
partnerUserRecord.setUserId(pool.getUserId()); |
|
|
|
partnerUserRecord.setUserId(pool.getUserId()); |
|
|
|
partnerUserRecord.setUserName(user.getName()); |
|
|
|
partnerUserRecord.setUserName(user.getName()); |
|
|
|
|
|
|
|
// 计算分红金额
|
|
|
|
partnerUserRecord.setGoldCoin(pool.getGoldCoin().multiply(level.getDividendsPer())); |
|
|
|
partnerUserRecord.setGoldCoin(pool.getGoldCoin().multiply(level.getDividendsPer())); |
|
|
|
partnerUserRecord.setProportion(level.getDividendsPer()); |
|
|
|
partnerUserRecord.setProportion(level.getDividendsPer()); |
|
|
|
partnerUserRecord.setType(1); |
|
|
|
partnerUserRecord.setType(1); |
|
|
@ -387,59 +442,124 @@ public class PartnerServiceImpl implements PartnerService { |
|
|
|
userAccountService.recharge(user.getId(),partnerUserRecord.getGoldCoin(), UserAccountRecordSourceTypeEnum.type4, userRechargeParam); |
|
|
|
userAccountService.recharge(user.getId(),partnerUserRecord.getGoldCoin(), UserAccountRecordSourceTypeEnum.type4, userRechargeParam); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<JSONObject> partnerData(Long startTime, Long endTime) throws Exception { |
|
|
|
public List<JSONObject> partnerData(Long createTimeS, Long createTimeE) throws Exception { |
|
|
|
|
|
|
|
// 创建一个Map,用于存储查询参数
|
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("startTime", startTime); |
|
|
|
// 将createTimeS参数放入Map中
|
|
|
|
params.put("endTime", endTime); |
|
|
|
params.put("createTimeS", createTimeS); |
|
|
|
|
|
|
|
// 将createTimeE参数放入Map中
|
|
|
|
|
|
|
|
params.put("createTimeE", createTimeE); |
|
|
|
|
|
|
|
// 调用bsPartnerPoolPreService的queryAllList方法,查询所有符合条件的BsPartnerPoolPre对象,并将结果存入list中
|
|
|
|
List<BsPartnerPoolPre> list = bsPartnerPoolPreService.queryAllList(params); |
|
|
|
List<BsPartnerPoolPre> list = bsPartnerPoolPreService.queryAllList(params); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 使用stream流将list中的BsPartnerPoolPre对象按照level进行分组,并将结果存入collect中
|
|
|
|
Map<Integer, List<BsPartnerPoolPre>> collect = list.stream().collect(Collectors.groupingBy(BsPartnerPoolPre::getLevel)); |
|
|
|
Map<Integer, List<BsPartnerPoolPre>> collect = list.stream().collect(Collectors.groupingBy(BsPartnerPoolPre::getLevel)); |
|
|
|
|
|
|
|
|
|
|
|
List<JSONObject> countRecords = collect.keySet().stream().map(key -> { |
|
|
|
// 如果collect不为空,则将collect中的数据转换为JSONObject对象,并存入list中
|
|
|
|
|
|
|
|
if (!collect.isEmpty()) { |
|
|
|
|
|
|
|
return collect.keySet().stream().map(key -> { |
|
|
|
|
|
|
|
// 创建一个JSONObject对象
|
|
|
|
|
|
|
|
JSONObject goodObject = new JSONObject(true); |
|
|
|
|
|
|
|
// 将level放入JSONObject中
|
|
|
|
|
|
|
|
goodObject.put("level",key); |
|
|
|
|
|
|
|
// 获取collect中level为key的BsPartnerPoolPre对象列表
|
|
|
|
|
|
|
|
List<BsPartnerPoolPre> pres = collect.get(key); |
|
|
|
|
|
|
|
// 将pres的大小放入JSONObject中
|
|
|
|
|
|
|
|
goodObject.put("campaignUserNum", pres.size()); |
|
|
|
|
|
|
|
// 将pres中所有BsPartnerPoolPre对象的goldCoin相加,并存入JSONObject中
|
|
|
|
|
|
|
|
goodObject.put("campaignGoldCoin", pres.stream().map(BsPartnerPoolPre::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add)); |
|
|
|
|
|
|
|
// 返回JSONObject对象
|
|
|
|
|
|
|
|
return goodObject; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 调用bsPartnerLevelService的queryAllList方法,查询所有BsPartnerLevel对象,并将结果存入levelList中
|
|
|
|
|
|
|
|
List<BsPartnerLevel> levelList = bsPartnerLevelService.queryAllList(new HashMap<>()); |
|
|
|
|
|
|
|
// 使用stream流将levelList中的BsPartnerLevel对象按照level进行分组,并将结果存入listMap中
|
|
|
|
|
|
|
|
Map<Integer, List<BsPartnerLevel>> listMap = levelList.stream().collect(Collectors.groupingBy(BsPartnerLevel::getLevel)); |
|
|
|
|
|
|
|
// 将listMap中的数据转换为JSONObject对象,并存入list中
|
|
|
|
|
|
|
|
return listMap.keySet().stream().map(key -> { |
|
|
|
|
|
|
|
// 创建一个JSONObject对象
|
|
|
|
JSONObject goodObject = new JSONObject(true); |
|
|
|
JSONObject goodObject = new JSONObject(true); |
|
|
|
|
|
|
|
// 将level放入JSONObject中
|
|
|
|
goodObject.put("level",key); |
|
|
|
goodObject.put("level",key); |
|
|
|
List<BsPartnerPoolPre> pres = collect.get(key); |
|
|
|
// 将campaignUserNum设置为0
|
|
|
|
goodObject.put("campaignUserNum", pres.size()); |
|
|
|
goodObject.put("campaignUserNum", 0); |
|
|
|
goodObject.put("campaignGoldCoin", pres.stream().map(BsPartnerPoolPre::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add)); |
|
|
|
// 将campaignGoldCoin设置为BigDecimal.ZERO
|
|
|
|
|
|
|
|
goodObject.put("campaignGoldCoin", BigDecimal.ZERO); |
|
|
|
|
|
|
|
// 返回JSONObject对象
|
|
|
|
return goodObject; |
|
|
|
return goodObject; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
return countRecords; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<JSONObject> dividendData(Long startTime, Long endTime) throws Exception { |
|
|
|
public List<JSONObject> dividendData(Long createTimeS, Long createTimeE) throws Exception { |
|
|
|
|
|
|
|
// 创建一个Map,用于存储查询参数
|
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("startTime", startTime); |
|
|
|
// 将createTimeS参数存入Map
|
|
|
|
params.put("endTime", endTime); |
|
|
|
params.put("createTimeS", createTimeS); |
|
|
|
|
|
|
|
// 将createTimeE参数存入Map
|
|
|
|
|
|
|
|
params.put("createTimeE", createTimeE); |
|
|
|
|
|
|
|
// 将type参数存入Map
|
|
|
|
params.put("type", 1); |
|
|
|
params.put("type", 1); |
|
|
|
|
|
|
|
// 根据参数查询所有用户记录
|
|
|
|
List<BsPartnerUserRecord> userRecords = bsPartnerUserRecordService.queryAllList(params); |
|
|
|
List<BsPartnerUserRecord> userRecords = bsPartnerUserRecordService.queryAllList(params); |
|
|
|
|
|
|
|
|
|
|
|
Map<Integer, List<BsPartnerUserRecord>> collect = userRecords.stream().collect(Collectors.groupingBy(BsPartnerUserRecord::getLevel)); |
|
|
|
// 如果查询结果不为空
|
|
|
|
List<JSONObject> countRecords = collect.keySet().stream().map(key -> { |
|
|
|
if (!userRecords.isEmpty()) { |
|
|
|
|
|
|
|
// 将查询结果按照level进行分组
|
|
|
|
|
|
|
|
Map<Integer, List<BsPartnerUserRecord>> collect = userRecords.stream().collect(Collectors.groupingBy(BsPartnerUserRecord::getLevel)); |
|
|
|
|
|
|
|
// 返回分组后的结果
|
|
|
|
|
|
|
|
return collect.keySet().stream().map(key -> { |
|
|
|
|
|
|
|
// 创建一个JSONObject对象
|
|
|
|
|
|
|
|
JSONObject goodObject = new JSONObject(true); |
|
|
|
|
|
|
|
// 将level存入JSONObject
|
|
|
|
|
|
|
|
goodObject.put("level",key); |
|
|
|
|
|
|
|
// 获取当前level的用户记录
|
|
|
|
|
|
|
|
List<BsPartnerUserRecord> pres = collect.get(key); |
|
|
|
|
|
|
|
// 将用户记录数量存入JSONObject
|
|
|
|
|
|
|
|
goodObject.put("dividendCount", pres.size()); |
|
|
|
|
|
|
|
// 将用户记录的金币数量累加存入JSONObject
|
|
|
|
|
|
|
|
goodObject.put("dividendGoldCoin", pres.stream().map(BsPartnerUserRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add)); |
|
|
|
|
|
|
|
// 返回JSONObject
|
|
|
|
|
|
|
|
return goodObject; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果查询结果为空,查询所有等级
|
|
|
|
|
|
|
|
List<BsPartnerLevel> list = bsPartnerLevelService.queryAllList(new HashMap<>()); |
|
|
|
|
|
|
|
// 将查询结果按照level进行分组
|
|
|
|
|
|
|
|
Map<Integer, List<BsPartnerLevel>> listMap = list.stream().collect(Collectors.groupingBy(BsPartnerLevel::getLevel)); |
|
|
|
|
|
|
|
// 返回分组后的结果
|
|
|
|
|
|
|
|
return listMap.keySet().stream().map(key -> { |
|
|
|
|
|
|
|
// 创建一个JSONObject对象
|
|
|
|
JSONObject goodObject = new JSONObject(true); |
|
|
|
JSONObject goodObject = new JSONObject(true); |
|
|
|
|
|
|
|
// 将level存入JSONObject
|
|
|
|
goodObject.put("level",key); |
|
|
|
goodObject.put("level",key); |
|
|
|
List<BsPartnerUserRecord> pres = collect.get(key); |
|
|
|
// 将用户记录数量存入JSONObject
|
|
|
|
goodObject.put("dividendCount", pres.size()); |
|
|
|
goodObject.put("dividendCount", 0); |
|
|
|
goodObject.put("dividendGoldCoin", pres.stream().map(BsPartnerUserRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add)); |
|
|
|
// 将用户记录的金币数量存入JSONObject
|
|
|
|
|
|
|
|
goodObject.put("dividendGoldCoin", BigDecimal.ZERO); |
|
|
|
|
|
|
|
// 返回JSONObject
|
|
|
|
return goodObject; |
|
|
|
return goodObject; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
return countRecords; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 竞选成功返利
|
|
|
|
// 竞选成功返利
|
|
|
|
private void campaignPartner(BsPartnerPoolPre partnerPoolPre , BsPartnerPool pool) throws Exception { |
|
|
|
private void campaignPartner(BsPartnerPoolPre partnerPoolPre , BsPartnerPool pool , BsPartnerLevel level) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建BsPartnerUserRecord对象
|
|
|
|
BsPartnerUserRecord userRecord = new BsPartnerUserRecord(); |
|
|
|
BsPartnerUserRecord userRecord = new BsPartnerUserRecord(); |
|
|
|
|
|
|
|
// 根据pool.getUserId()获取BsUser对象
|
|
|
|
BsUser bsUser = bsUserService.getUser(pool.getUserId()); |
|
|
|
BsUser bsUser = bsUserService.getUser(pool.getUserId()); |
|
|
|
// 查询差价
|
|
|
|
// 查询差价
|
|
|
|
BigDecimal differencePrice = partnerPoolPre.getGoldCoin().subtract(pool.getGoldCoin()); |
|
|
|
BigDecimal differencePrice = partnerPoolPre.getGoldCoin().subtract(pool.getGoldCoin()); |
|
|
@ -462,6 +582,16 @@ public class PartnerServiceImpl implements PartnerService { |
|
|
|
pre.setUpdateTime(new Date()); |
|
|
|
pre.setUpdateTime(new Date()); |
|
|
|
bsPartnerPoolPreService.edit(pre); |
|
|
|
bsPartnerPoolPreService.edit(pre); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果level不为空
|
|
|
|
|
|
|
|
if (level != null) { |
|
|
|
|
|
|
|
// 设置用户合伙人收入比例
|
|
|
|
|
|
|
|
bsUser.setPartnerIncomePer(level.getIncomePer()); |
|
|
|
|
|
|
|
// 设置用户合伙人等级
|
|
|
|
|
|
|
|
bsUser.setPartnerLevel(level.getLevel()); |
|
|
|
|
|
|
|
// 编辑用户数据
|
|
|
|
|
|
|
|
bsUserService.updateInfo(bsUser); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 收益记录
|
|
|
|
// 收益记录
|
|
|
|
Map<String, Object> userRechargeParam = new HashMap<>(); |
|
|
|
Map<String, Object> userRechargeParam = new HashMap<>(); |
|
|
|
userRechargeParam.put("sourceId", userRecord.getId()); |
|
|
|
userRechargeParam.put("sourceId", userRecord.getId()); |
|
|
|