|
@@ -518,4 +518,108 @@ public class AppUserCountTask {
|
|
|
return money<0?money*-1:money;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ * 更新用户充值后是否满足流水
|
|
|
+ *
|
|
|
+ * */
|
|
|
+ @DSTransactional
|
|
|
+ public void calculationWithdraw(Long userId){
|
|
|
+
|
|
|
+ String chargeType3 = FinTranType3.ON_LINE_CHARGE.getType() + "," + FinTranType3.CHARGE_IN.getType()+ "," + FinTranType3.CHARGE_IN_Back.getType()
|
|
|
+ + "," + FinTranType3.TRANSFER_TO_TEAM_DiamondCoin.getType();
|
|
|
+ List<FinTranRecord> chargeList = finTranRecordService.selectUserTran(FinTranType1.U_Income_Coin_Balance.getType(),chargeType3,userId,null,null,0);
|
|
|
+ if(null != chargeList && chargeList.size() > 0) {
|
|
|
+ Map<Long, List<FinTranRecord>> chargeMap = chargeList.stream().collect(Collectors.groupingBy(FinTranRecord::getUid));
|
|
|
+ for(Long uid:chargeMap.keySet()){
|
|
|
+ List<FinTranRecord> userChargeList = chargeMap.get(uid);
|
|
|
+
|
|
|
+ userChargeList.stream().sorted(Comparator.comparing(FinTranRecord::getCreateTime)).collect(Collectors.toList());
|
|
|
+ Date beginDate= null;
|
|
|
+ Double money = 0.00;
|
|
|
+ Date endDate = new Date();
|
|
|
+ int i = 1;
|
|
|
+ List<FinTranRecord> dealTranList = new ArrayList<>();
|
|
|
+ for (FinTranRecord tranRecord : userChargeList) {
|
|
|
+ dealTranList.add(tranRecord);
|
|
|
+ if (null == beginDate){
|
|
|
+ beginDate = tranRecord.getCreateTime();
|
|
|
+ }
|
|
|
+ if(userChargeList.size() > i){
|
|
|
+ endDate = new Date(userChargeList.get(i).getCreateTime().getTime() - 1);
|
|
|
+ }
|
|
|
+ money += tranRecord.getDiamondCoinChange();
|
|
|
+
|
|
|
+ AppUsersCharge appUsersCharge = appUsersChargeService.selectByOrderNo(String.valueOf(tranRecord.getTranGroupId()));
|
|
|
+ if(null != appUsersCharge && null != appUsersCharge.getCoinGive()){
|
|
|
+ money += appUsersCharge.getCoinGive().doubleValue();
|
|
|
+ }
|
|
|
+ dealTran(dealTranList,beginDate,endDate,uid,money);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void dealTran(List<FinTranRecord> userChargeList,Date beginDate,Date endDate,Long userId,Double money){
|
|
|
+
|
|
|
+ List<FinTranRecord> curTranList = finTranRecordService.selectUserTran(null,String.valueOf(FinTranType3.CONSUM_GAME_ANCHOR_ZHUANPAN.getType()),userId,beginDate,endDate,0);
|
|
|
+ if(null != curTranList && curTranList.size() > 0){
|
|
|
+
|
|
|
+ double bettingAmount = curTranList.stream().filter(e->
|
|
|
+ e.getTranType3().equals(FinTranType3.CONSUM_GAME_ANCHOR_ZHUANPAN.getType())
|
|
|
+ &&
|
|
|
+ e.getCurrencyType().intValue() == 4
|
|
|
+ ).mapToDouble(FinTranRecord::getDiamondCoinChange).sum() * -1;
|
|
|
+ if(bettingAmount >= money * 2){
|
|
|
+
|
|
|
+ userChargeList.forEach(e->{
|
|
|
+ FinTranRecord updateTran = new FinTranRecord();
|
|
|
+ updateTran.setId(e.getId());
|
|
|
+ updateTran.setWithdrawFlag(1);
|
|
|
+ finTranRecordService.updateFinTranRecord(updateTran);
|
|
|
+ });
|
|
|
+
|
|
|
+ updateWithdrawAble(userId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 更新用户可提现余额
|
|
|
+ * */
|
|
|
+ @DSTransactional
|
|
|
+ public void updateWithdrawAble(Long userId){
|
|
|
+
|
|
|
+ String chargeType3 = FinTranType3.ON_LINE_CHARGE.getType() + "," + FinTranType3.CHARGE_IN.getType()+ "," + FinTranType3.CHARGE_IN_Back.getType()
|
|
|
+ + "," + FinTranType3.TRANSFER_TO_TEAM_DiamondCoin.getType();
|
|
|
+ List<FinTranRecord> chargeList = finTranRecordService.selectUserTran(FinTranType1.U_Income_Coin_Balance.getType(),chargeType3,userId,null,null,1);
|
|
|
+ if(null != chargeList && chargeList.size() > 0){
|
|
|
+ Map<Long, List<FinTranRecord>> chargeMap = chargeList.stream().collect(Collectors.groupingBy(FinTranRecord::getUid));
|
|
|
+ for(Long uid : chargeMap.keySet()) {
|
|
|
+ int i = 1;
|
|
|
+ double withdrawAble = 0;
|
|
|
+ List<FinTranRecord> tranRecordList = chargeMap.get(uid);
|
|
|
+ for (FinTranRecord finTranRecord : tranRecordList) {
|
|
|
+ Date beginDate = finTranRecord.getCreateTime();
|
|
|
+ Date endDate = new Date();
|
|
|
+ if (chargeList.size() > i) {
|
|
|
+ endDate = new Date(chargeList.get(i).getCreateTime().getTime() - 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FinTranRecord> curTranList = finTranRecordService.selectUserTran(null, null, uid, beginDate, endDate, null);
|
|
|
+ withdrawAble += curTranList.stream().mapToDouble(FinTranRecord::getDiamondCoinChange).sum();
|
|
|
+
|
|
|
+ }
|
|
|
+ AppUser updateUser = new AppUser();
|
|
|
+ updateUser.setUserid(uid);
|
|
|
+ updateUser.setWithdrawAble(withdrawAble);
|
|
|
+ appUserService.updateAppUser(updateUser);
|
|
|
+
|
|
|
+ redisCache.deleteObject("U:UserInfo:".concat(String.valueOf(uid)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|