|
|
@ -4,10 +4,14 @@ import com.hfkj.common.exception.BaseException; |
|
|
|
import com.hfkj.common.exception.ErrorCode; |
|
|
|
import com.hfkj.common.exception.ErrorCode; |
|
|
|
import com.hfkj.common.exception.ErrorHelp; |
|
|
|
import com.hfkj.common.exception.ErrorHelp; |
|
|
|
import com.hfkj.common.exception.SysCode; |
|
|
|
import com.hfkj.common.exception.SysCode; |
|
|
|
|
|
|
|
import com.hfkj.common.utils.DateUtil; |
|
|
|
import com.hfkj.dao.BsCornucopiaPoolMapper; |
|
|
|
import com.hfkj.dao.BsCornucopiaPoolMapper; |
|
|
|
import com.hfkj.dao.BsCornucopiaPoolRecordMapper; |
|
|
|
import com.hfkj.dao.BsCornucopiaPoolRecordMapper; |
|
|
|
import com.hfkj.entity.*; |
|
|
|
import com.hfkj.entity.*; |
|
|
|
|
|
|
|
import com.hfkj.service.cornucopia.BsCornucopiaConfigService; |
|
|
|
|
|
|
|
import com.hfkj.service.cornucopia.BsCornucopiaLotteryRecordService; |
|
|
|
import com.hfkj.service.cornucopia.BsCornucopiaPoolService; |
|
|
|
import com.hfkj.service.cornucopia.BsCornucopiaPoolService; |
|
|
|
|
|
|
|
import com.hfkj.service.cornucopia.BsCornucopiaUserRecordService; |
|
|
|
import com.hfkj.service.user.BsUserAccountService; |
|
|
|
import com.hfkj.service.user.BsUserAccountService; |
|
|
|
import com.hfkj.sysenum.cornucopia.CornucopiaEnum; |
|
|
|
import com.hfkj.sysenum.cornucopia.CornucopiaEnum; |
|
|
|
import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum; |
|
|
|
import com.hfkj.sysenum.user.UserAccountRecordSourceTypeEnum; |
|
|
@ -23,6 +27,7 @@ import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
@Service("bsCornucopiaPoolService") |
|
|
|
@Service("bsCornucopiaPoolService") |
|
|
|
public class BsCornucopiaPoolServiceImpl implements BsCornucopiaPoolService { |
|
|
|
public class BsCornucopiaPoolServiceImpl implements BsCornucopiaPoolService { |
|
|
@ -37,6 +42,15 @@ public class BsCornucopiaPoolServiceImpl implements BsCornucopiaPoolService { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private BsUserAccountService userAccountService; |
|
|
|
private BsUserAccountService userAccountService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private BsCornucopiaConfigService cornucopiaConfigService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private BsCornucopiaLotteryRecordService cornucopiaLotteryRecordService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private BsCornucopiaUserRecordService cornucopiaUserRecordService; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private RedisTemplate<String,Object> redisTemplate; |
|
|
|
private RedisTemplate<String,Object> redisTemplate; |
|
|
|
private final String LOCK_KEY = "POOL_TRADE_LOCK_"; |
|
|
|
private final String LOCK_KEY = "POOL_TRADE_LOCK_"; |
|
|
@ -103,6 +117,12 @@ public class BsCornucopiaPoolServiceImpl implements BsCornucopiaPoolService { |
|
|
|
if (MapUtils.getLong(map, "userId") != null) { |
|
|
|
if (MapUtils.getLong(map, "userId") != null) { |
|
|
|
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); |
|
|
|
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (MapUtils.getLong(map, "createTimeS") != null) { |
|
|
|
|
|
|
|
criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeS"))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (MapUtils.getLong(map, "createTimeE") != null) { |
|
|
|
|
|
|
|
criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE"))); |
|
|
|
|
|
|
|
} |
|
|
|
if (MapUtils.getInteger(map, "status") != null) { |
|
|
|
if (MapUtils.getInteger(map, "status") != null) { |
|
|
|
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); |
|
|
|
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); |
|
|
|
} |
|
|
|
} |
|
|
@ -184,6 +204,68 @@ public class BsCornucopiaPoolServiceImpl implements BsCornucopiaPoolService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
@Transactional(propagation= Propagation.REQUIRED,rollbackFor= {RuntimeException.class}) |
|
|
|
|
|
|
|
public void recoveryCornucopia(Integer type, Long userId, String userName, BigDecimal goldCoin) throws Exception { |
|
|
|
|
|
|
|
// 锁编号
|
|
|
|
|
|
|
|
String lockKey = LOCK_KEY+userId; |
|
|
|
|
|
|
|
// 获取锁
|
|
|
|
|
|
|
|
Boolean lock = redisTemplate.opsForValue().setIfAbsent(lockKey, ""); |
|
|
|
|
|
|
|
if (Boolean.TRUE.equals(lock)) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// 获取锁成功
|
|
|
|
|
|
|
|
// 锁超时时间 10秒
|
|
|
|
|
|
|
|
redisTemplate.expire(lockKey, 10, TimeUnit.SECONDS); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 插入投入记录
|
|
|
|
|
|
|
|
BsCornucopiaPoolRecord record = new BsCornucopiaPoolRecord(); |
|
|
|
|
|
|
|
record.setUserId(userId); |
|
|
|
|
|
|
|
record.setType(type); |
|
|
|
|
|
|
|
record.setGoldCoin(goldCoin); |
|
|
|
|
|
|
|
record.setStatus(2); |
|
|
|
|
|
|
|
record.setCreateTime(new Date()); |
|
|
|
|
|
|
|
record.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
record.setUserName(userName); |
|
|
|
|
|
|
|
create(record); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询投入
|
|
|
|
|
|
|
|
BsCornucopiaPool cornucopiaPool = queryDetail(userId , type); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cornucopiaPool == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "您还没有参加活动哟!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cornucopiaPool.getGoldCoin().compareTo(goldCoin) < 0) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "元宝不够哟!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 扣除
|
|
|
|
|
|
|
|
cornucopiaPool.setGoldCoin(cornucopiaPool.getGoldCoin().subtract(goldCoin)); |
|
|
|
|
|
|
|
cornucopiaPool.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
edit(cornucopiaPool); |
|
|
|
|
|
|
|
// 充值记录
|
|
|
|
|
|
|
|
Map<String, Object> userRechargeParam = new HashMap<>(); |
|
|
|
|
|
|
|
userRechargeParam.put("sourceId", record.getId()); |
|
|
|
|
|
|
|
userRechargeParam.put("sourceOrderNo", ""); |
|
|
|
|
|
|
|
userRechargeParam.put("sourceContent", userName + "回收" + CornucopiaEnum.getDataByType(type).getName() + goldCoin); |
|
|
|
|
|
|
|
// 用户账户充值
|
|
|
|
|
|
|
|
userAccountService.recharge(userId,goldCoin, UserAccountRecordSourceTypeEnum.type3, userRechargeParam); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (BaseException e) { |
|
|
|
|
|
|
|
// 释放锁
|
|
|
|
|
|
|
|
redisTemplate.delete(lockKey); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, e.getErrorMsg()); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
// 释放锁
|
|
|
|
|
|
|
|
redisTemplate.delete(lockKey); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "啊偶~交易出现未知问题!请稍后重试"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Thread.sleep(100); |
|
|
|
|
|
|
|
recoveryCornucopia(type , userId , userName ,goldCoin); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void create(BsCornucopiaPoolRecord cornucopiaPoolRecord) { |
|
|
|
public void create(BsCornucopiaPoolRecord cornucopiaPoolRecord) { |
|
|
|
cornucopiaPoolRecordMapper.insert(cornucopiaPoolRecord); |
|
|
|
cornucopiaPoolRecordMapper.insert(cornucopiaPoolRecord); |
|
|
@ -204,9 +286,217 @@ public class BsCornucopiaPoolServiceImpl implements BsCornucopiaPoolService { |
|
|
|
if (MapUtils.getLong(map, "userId") != null) { |
|
|
|
if (MapUtils.getLong(map, "userId") != null) { |
|
|
|
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); |
|
|
|
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (MapUtils.getLong(map, "createTimeS") != null) { |
|
|
|
|
|
|
|
criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(map, "createTimeS"))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (MapUtils.getLong(map, "createTimeE") != null) { |
|
|
|
|
|
|
|
criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE"))); |
|
|
|
|
|
|
|
} |
|
|
|
if (MapUtils.getInteger(map, "status") != null) { |
|
|
|
if (MapUtils.getInteger(map, "status") != null) { |
|
|
|
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); |
|
|
|
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
criteria.andStatusNotEqualTo(0); |
|
|
|
} |
|
|
|
} |
|
|
|
return cornucopiaPoolRecordMapper.selectByExample(example); |
|
|
|
return cornucopiaPoolRecordMapper.selectByExample(example); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void cornucopiaLottery() throws Exception { |
|
|
|
|
|
|
|
// 查询聚宝盆配置参数
|
|
|
|
|
|
|
|
List<BsCornucopiaConfig> cornucopiaConfigList = cornucopiaConfigService.queryAllList(new HashMap<>()); |
|
|
|
|
|
|
|
if (cornucopiaConfigList.isEmpty()) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "啊偶~没有配置参数!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 判断是否当天已经开奖
|
|
|
|
|
|
|
|
List<BsCornucopiaLotteryRecord> lotteryRecord = cornucopiaLotteryRecordService.cornucopiaLottery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!lotteryRecord.isEmpty()) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当期已开奖!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String lotteryNo = DateUtil.date2String(new Date() , DateUtil.YMD); |
|
|
|
|
|
|
|
Date LotteryTime = new Date(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询投入玩家
|
|
|
|
|
|
|
|
List<BsCornucopiaPool> cornucopiaPoolList = queryAllList(new HashMap<>()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (lotteryRecord.isEmpty()) { |
|
|
|
|
|
|
|
// 获取时间
|
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) -1); |
|
|
|
|
|
|
|
calendar.set(Calendar.HOUR_OF_DAY, 7); |
|
|
|
|
|
|
|
calendar.set(Calendar.MINUTE, 59); |
|
|
|
|
|
|
|
calendar.set(Calendar.SECOND, 59); |
|
|
|
|
|
|
|
Long time = calendar.getTime().getTime(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询用户开奖周期元宝记录
|
|
|
|
|
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("createTimeE" , time); |
|
|
|
|
|
|
|
List<BsCornucopiaPoolRecord> beforePoolRecordList = queryAllListRecord(map); |
|
|
|
|
|
|
|
// 查询用户开奖周期之后的元宝记录
|
|
|
|
|
|
|
|
Map<String , Object> mapS = new HashMap<>(); |
|
|
|
|
|
|
|
mapS.put("createTimeS" , time); |
|
|
|
|
|
|
|
List<BsCornucopiaPoolRecord> afterPoolRecordList = queryAllListRecord(mapS); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 定义开奖期数记录
|
|
|
|
|
|
|
|
BsCornucopiaLotteryRecord cornucopiaLotteryRecord; |
|
|
|
|
|
|
|
// 定义用户元宝收益记录
|
|
|
|
|
|
|
|
BsCornucopiaUserRecord userRecord; |
|
|
|
|
|
|
|
// 记录金玉聚宝盆总投入
|
|
|
|
|
|
|
|
BigDecimal goldIncomeAll = BigDecimal.ZERO; |
|
|
|
|
|
|
|
BigDecimal jadeIncomeAll = BigDecimal.ZERO; |
|
|
|
|
|
|
|
Integer userGoldNum = 0; |
|
|
|
|
|
|
|
Integer userJadeNum = 0; |
|
|
|
|
|
|
|
if (!beforePoolRecordList.isEmpty()) { |
|
|
|
|
|
|
|
for (BsCornucopiaPool cornucopiaPool : cornucopiaPoolList) { |
|
|
|
|
|
|
|
// 查询用户开奖周期内金聚宝盆投入元宝
|
|
|
|
|
|
|
|
BigDecimal enterBeforeGoldPrice = beforePoolRecordList.stream() |
|
|
|
|
|
|
|
.filter(s->s.getUserId().equals(cornucopiaPool.getUserId())) |
|
|
|
|
|
|
|
.filter(s->s.getStatus().equals(1)) |
|
|
|
|
|
|
|
.filter(s->s.getType().equals(1)) |
|
|
|
|
|
|
|
.map(BsCornucopiaPoolRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
|
|
|
|
// 查询用户开奖周期内金聚宝盆投出元宝
|
|
|
|
|
|
|
|
BigDecimal outBeforeGoldPrice = beforePoolRecordList.stream() |
|
|
|
|
|
|
|
.filter(s->s.getUserId().equals(cornucopiaPool.getUserId())) |
|
|
|
|
|
|
|
.filter(s->s.getStatus().equals(2)) |
|
|
|
|
|
|
|
.filter(s->s.getType().equals(1)) |
|
|
|
|
|
|
|
.map(BsCornucopiaPoolRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
|
|
|
|
// 查询用户开奖周期后金聚宝盆投入元宝
|
|
|
|
|
|
|
|
BigDecimal enterAfterGoldPrice = afterPoolRecordList.stream() |
|
|
|
|
|
|
|
.filter(s->s.getUserId().equals(cornucopiaPool.getUserId())) |
|
|
|
|
|
|
|
.filter(s->s.getStatus().equals(1)) |
|
|
|
|
|
|
|
.filter(s->s.getType().equals(1)) |
|
|
|
|
|
|
|
.map(BsCornucopiaPoolRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
|
|
|
|
// 查询用户开奖周期后金聚宝盆投出元宝
|
|
|
|
|
|
|
|
BigDecimal outAfterGoldPrice = afterPoolRecordList.stream() |
|
|
|
|
|
|
|
.filter(s->s.getUserId().equals(cornucopiaPool.getUserId())) |
|
|
|
|
|
|
|
.filter(s->s.getStatus().equals(2)) |
|
|
|
|
|
|
|
.filter(s->s.getType().equals(1)) |
|
|
|
|
|
|
|
.map(BsCornucopiaPoolRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询用户开奖周期内玉聚宝盆投入元宝
|
|
|
|
|
|
|
|
BigDecimal enterBeforeJadePrice = beforePoolRecordList.stream() |
|
|
|
|
|
|
|
.filter(s->s.getUserId().equals(cornucopiaPool.getUserId())) |
|
|
|
|
|
|
|
.filter(s->s.getStatus().equals(1)) |
|
|
|
|
|
|
|
.filter(s->s.getType().equals(2)) |
|
|
|
|
|
|
|
.map(BsCornucopiaPoolRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
|
|
|
|
// 查询用户开奖周期内玉聚宝盆投出元宝
|
|
|
|
|
|
|
|
BigDecimal outBeforeJadePrice = beforePoolRecordList.stream() |
|
|
|
|
|
|
|
.filter(s->s.getUserId().equals(cornucopiaPool.getUserId())) |
|
|
|
|
|
|
|
.filter(s->s.getStatus().equals(2)) |
|
|
|
|
|
|
|
.filter(s->s.getType().equals(2)) |
|
|
|
|
|
|
|
.map(BsCornucopiaPoolRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
|
|
|
|
// 查询用户开奖周期后玉聚宝盆投入元宝
|
|
|
|
|
|
|
|
BigDecimal enterAfterJadePrice = afterPoolRecordList.stream() |
|
|
|
|
|
|
|
.filter(s->s.getUserId().equals(cornucopiaPool.getUserId())) |
|
|
|
|
|
|
|
.filter(s->s.getStatus().equals(1)) |
|
|
|
|
|
|
|
.filter(s->s.getType().equals(2)) |
|
|
|
|
|
|
|
.map(BsCornucopiaPoolRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
|
|
|
|
// 查询用户开奖周期后玉聚宝盆投出元宝
|
|
|
|
|
|
|
|
BigDecimal outAfterJadePrice = afterPoolRecordList.stream() |
|
|
|
|
|
|
|
.filter(s->s.getUserId().equals(cornucopiaPool.getUserId())) |
|
|
|
|
|
|
|
.filter(s->s.getStatus().equals(2)) |
|
|
|
|
|
|
|
.filter(s->s.getType().equals(2)) |
|
|
|
|
|
|
|
.map(BsCornucopiaPoolRecord::getGoldCoin).reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 计算金聚宝盆实际收益
|
|
|
|
|
|
|
|
// 计算金聚宝盆开奖周期内的剩余元宝
|
|
|
|
|
|
|
|
BigDecimal gold = enterBeforeGoldPrice.subtract(outBeforeGoldPrice); |
|
|
|
|
|
|
|
// 计算金聚宝盆开奖周期之后的剩余元宝
|
|
|
|
|
|
|
|
BigDecimal goldAfter = enterAfterGoldPrice.subtract(outAfterGoldPrice); |
|
|
|
|
|
|
|
if (goldAfter.compareTo(new BigDecimal(0)) < 1) { |
|
|
|
|
|
|
|
gold = gold.add(goldAfter); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 计算玉聚宝盆实际收益
|
|
|
|
|
|
|
|
// 计算玉聚宝盆开奖周期内的剩余元宝
|
|
|
|
|
|
|
|
BigDecimal jade = enterBeforeJadePrice.subtract(outBeforeJadePrice); |
|
|
|
|
|
|
|
// 计算玉聚宝盆开奖周期之后的剩余元宝
|
|
|
|
|
|
|
|
BigDecimal jadeAfter = enterAfterJadePrice.subtract(outAfterJadePrice); |
|
|
|
|
|
|
|
if (jadeAfter.compareTo(new BigDecimal(0)) < 1) { |
|
|
|
|
|
|
|
jade = jade.add(jadeAfter); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<BsCornucopiaConfig> list = cornucopiaConfigList.stream().filter(s->s.getType().equals(cornucopiaPool.getType())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal goldCoin = BigDecimal.ZERO; |
|
|
|
|
|
|
|
// 计算金聚宝盆收益
|
|
|
|
|
|
|
|
if (cornucopiaPool.getType().equals(1)) { |
|
|
|
|
|
|
|
if (gold.compareTo(new BigDecimal(0)) > 0) { |
|
|
|
|
|
|
|
userGoldNum++; |
|
|
|
|
|
|
|
// 计算总投入
|
|
|
|
|
|
|
|
goldIncomeAll = goldIncomeAll.add(gold); |
|
|
|
|
|
|
|
// 实际收益
|
|
|
|
|
|
|
|
goldCoin = gold.multiply(list.get(0).getProportion()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//计算玉聚宝盆收益
|
|
|
|
|
|
|
|
if (cornucopiaPool.getType().equals(2)) { |
|
|
|
|
|
|
|
if (jade.compareTo(new BigDecimal(0)) > 0) { |
|
|
|
|
|
|
|
userJadeNum++; |
|
|
|
|
|
|
|
jadeIncomeAll = jadeIncomeAll.add(jade); |
|
|
|
|
|
|
|
goldCoin = jade.multiply(list.get(0).getProportion()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 赠送用户收益
|
|
|
|
|
|
|
|
userRecord = new BsCornucopiaUserRecord(); |
|
|
|
|
|
|
|
userRecord.setCreateTime(new Date()); |
|
|
|
|
|
|
|
userRecord.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
userRecord.setLotteryTime(LotteryTime); |
|
|
|
|
|
|
|
userRecord.setUserId(cornucopiaPool.getUserId()); |
|
|
|
|
|
|
|
userRecord.setUserName(cornucopiaPool.getUserName()); |
|
|
|
|
|
|
|
userRecord.setStatus(1); |
|
|
|
|
|
|
|
userRecord.setLotteryNo(lotteryNo); |
|
|
|
|
|
|
|
userRecord.setType(cornucopiaPool.getType()); |
|
|
|
|
|
|
|
userRecord.setGoldCoin(goldCoin); |
|
|
|
|
|
|
|
userRecord.setProportion(list.get(0).getProportion()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cornucopiaUserRecordService.create(userRecord); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 充值记录
|
|
|
|
|
|
|
|
Map<String, Object> userRechargeParam = new HashMap<>(); |
|
|
|
|
|
|
|
userRechargeParam.put("sourceId", userRecord.getId()); |
|
|
|
|
|
|
|
userRechargeParam.put("sourceOrderNo", ""); |
|
|
|
|
|
|
|
userRechargeParam.put("sourceContent", cornucopiaPool.getUserName() + CornucopiaEnum.getDataByType(cornucopiaPool.getType()).getName() + "收益" + goldCoin); |
|
|
|
|
|
|
|
// 用户账户充值
|
|
|
|
|
|
|
|
userAccountService.recharge(cornucopiaPool.getUserId(),goldCoin, UserAccountRecordSourceTypeEnum.type3, userRechargeParam); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (BsCornucopiaConfig cornucopiaConfig : cornucopiaConfigList) { |
|
|
|
|
|
|
|
cornucopiaLotteryRecord = new BsCornucopiaLotteryRecord(); |
|
|
|
|
|
|
|
// 金聚宝盆
|
|
|
|
|
|
|
|
if (cornucopiaConfig.getType().equals(1)) { |
|
|
|
|
|
|
|
cornucopiaLotteryRecord.setUserNum(userGoldNum); |
|
|
|
|
|
|
|
cornucopiaLotteryRecord.setGoldCoin(goldIncomeAll); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//计算玉聚宝盆收益
|
|
|
|
|
|
|
|
if (cornucopiaConfig.getType().equals(2)) { |
|
|
|
|
|
|
|
cornucopiaLotteryRecord.setUserNum(userJadeNum); |
|
|
|
|
|
|
|
cornucopiaLotteryRecord.setGoldCoin(jadeIncomeAll); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 开奖记录
|
|
|
|
|
|
|
|
cornucopiaLotteryRecord.setCreateTime(new Date()); |
|
|
|
|
|
|
|
cornucopiaLotteryRecord.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
cornucopiaLotteryRecord.setLotteryTime(LotteryTime); |
|
|
|
|
|
|
|
cornucopiaLotteryRecord.setLotteryNo(lotteryNo); |
|
|
|
|
|
|
|
cornucopiaLotteryRecord.setType(cornucopiaConfig.getType()); |
|
|
|
|
|
|
|
cornucopiaLotteryRecord.setStatus(1); |
|
|
|
|
|
|
|
cornucopiaLotteryRecord.setConfigMsg(cornucopiaConfig.toString()); |
|
|
|
|
|
|
|
cornucopiaLotteryRecord.setProportion(cornucopiaConfig.getProportion()); |
|
|
|
|
|
|
|
cornucopiaLotteryRecord.setTypeName(CornucopiaEnum.getDataByType(cornucopiaConfig.getType()).getName()); |
|
|
|
|
|
|
|
cornucopiaLotteryRecordService.create(cornucopiaLotteryRecord); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|