dos 2 месяцев назад
Родитель
Сommit
a082d28935

+ 6 - 0
game-business/src/main/java/com/game/business/service/IAppGameBettingService.java

@@ -11,6 +11,7 @@ import com.game.business.vo.AppUserGameBettingWebCountVO;
 import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
+import java.util.Date;
 
 public interface IAppGameBettingService extends IService<AppGameBetting> {
 
@@ -109,4 +110,9 @@ public interface IAppGameBettingService extends IService<AppGameBetting> {
     public int deleteAppGameBettingById(Long id);
 
     public Double sumBettingAmount(Long userId,Integer bettingType,String beginTime,String endTime,Long gameId);
+
+    /**
+     * 查询在当前时间断内投注是否有大于结束时间的开奖
+     * */
+    public int selectBettingCount(Long userId,Date beginTime,Date endTime);
 }

+ 25 - 0
game-business/src/main/java/com/game/business/service/impl/AppGameBettingServiceImpl.java

@@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -269,5 +270,29 @@ public class AppGameBettingServiceImpl extends ServiceImpl<AppGameBettingMapper,
         return appGameBettingMapper.sumBettingAmount(userId,bettingType,beginTime,endTime,gameId);
     }
 
+    @Override
+    public int selectBettingCount(Long userId, Date beginTime, Date endTime) {
+        //查询时间段内投注且时间断外已开奖数量
+        LambdaQueryWrapper<AppGameBetting> queryKjWrapper = new LambdaQueryWrapper<>();
+        queryKjWrapper.eq(AppGameBetting::getUserId,userId);
+        queryKjWrapper.ne(AppGameBetting::getIsWinning,0);
+        queryKjWrapper.between(AppGameBetting::getCreateTime,beginTime,endTime);
+        queryKjWrapper.gt(AppGameBetting::getUpdateTime,endTime);//开奖时间大于结束时间
+        Long count = appGameBettingMapper.selectCount(queryKjWrapper);
+        if(null == count){
+            count = 0L;
+        }
+        //查询时间段内投注且时间断外未开奖数量
+        LambdaQueryWrapper<AppGameBetting> queryWKjWrapper = new LambdaQueryWrapper<>();
+        queryWKjWrapper.eq(AppGameBetting::getUserId,userId);
+        queryWKjWrapper.eq(AppGameBetting::getIsWinning,0);
+        queryWKjWrapper.between(AppGameBetting::getCreateTime,beginTime,endTime);
+        Long wkjCount = appGameBettingMapper.selectCount(queryWKjWrapper);
+        if(null != wkjCount){
+            count += wkjCount;
+        }
+        return count.intValue();
+    }
+
 
 }

+ 20 - 13
game-business/src/main/java/com/game/business/task/AppUserCountTask.java

@@ -634,8 +634,10 @@ public class AppUserCountTask {
         List<FinTranRecord> curTranList = finTranRecordService.selectUserTran(null,type3s,userId,beginDate,endDate,0);
         //获取用户资产
         AppUser appUser = appUserService.getUserAsset(userId);
+        //查询是否有该时间段以外的开奖
+        int count = appGameBettingService.selectBettingCount(userId,beginDate,endDate);
         //资产为0 则充值两倍流水条件设为已作废
-        if(null != appUser && appUser.getDiamondCoin().doubleValue() < 1){
+        if(null != appUser && appUser.getDiamondCoin().doubleValue() < 1 && count < 1){
             //更新为已满足提现
 //            userChargeList.forEach(e->{
                 FinTranRecord updateTran = new FinTranRecord();
@@ -643,28 +645,20 @@ public class AppUserCountTask {
                 updateTran.setWithdrawFlag(2);
                 finTranRecordService.updateFinTranRecord(updateTran);
                 log.info("用户{},流水单号:{} 因金额已使用完,该笔订单流水条件已作废",userId,tranRecord.getId());
-
                 //将本次之前的充值订单置为已作废
-                if(null != userChargeList && userChargeList.size() > 0){
-                    userChargeList.forEach(e->{
-                        FinTranRecord updateTran2 = new FinTranRecord();
-                        updateTran2.setId(e.getId());
-                        updateTran2.setWithdrawFlag(2);
-                        finTranRecordService.updateFinTranRecord(updateTran2);
-                        log.info("用户{},流水单号:{} 因金额已使用完,该笔订单流水条件已作废",userId,e.getId());
-                    });
-                    userChargeList.clear();
-                }
+                dealRechare(userChargeList,userId);
 //            });
         }else{
             //查询本次充值到下次充值期间资产除去返佣后是否已归零
             double amount  = finTranRecordService.sumUserRechareTran(userId,beginDate,endDate);
-            if(amount < 1){
+            if(amount < 1 && count < 1){
                 FinTranRecord updateTran = new FinTranRecord();
                 updateTran.setId(tranRecord.getId());
                 updateTran.setWithdrawFlag(2);
                 finTranRecordService.updateFinTranRecord(updateTran);
                 log.info("用户{},流水单号:{} 因充值金额已使用完,该笔订单流水条件已作废",userId,tranRecord.getId());
+                //将本次之前的充值订单置为已作废
+                dealRechare(userChargeList,userId);
             }else{
                 //未归零,则叠加
                 userChargeList.add(tranRecord);
@@ -796,4 +790,17 @@ public class AppUserCountTask {
             });
         }
     }
+
+    private void dealRechare(List<FinTranRecord> userChargeList,Long userId){
+        if(null != userChargeList && userChargeList.size() > 0) {
+            userChargeList.forEach(e -> {
+                FinTranRecord updateTran2 = new FinTranRecord();
+                updateTran2.setId(e.getId());
+                updateTran2.setWithdrawFlag(2);
+                finTranRecordService.updateFinTranRecord(updateTran2);
+                log.info("用户{},流水单号:{} 因金额已使用完,该笔订单流水条件已作废", userId, e.getId());
+            });
+            userChargeList.clear();
+        }
+    }
 }