kk 1 месяц назад
Родитель
Сommit
eb8a0c1bf0

+ 18 - 1
game-business/src/main/java/com/game/business/controller/FinTranRecordController.java

@@ -1,9 +1,13 @@
 package com.game.business.controller;
 
+import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
 
+import com.alibaba.fastjson2.JSONObject;
 import com.game.business.dto.FinTranRecordDTO;
+import com.game.business.service.IAppGameBettingService;
 import com.game.common.core.domain.R;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -40,6 +44,9 @@ public class FinTranRecordController extends BaseController
     @Autowired
     private IFinTranRecordService finTranRecordService;
 
+    @Autowired
+    private IAppGameBettingService appGameBettingService;
+
     /**
      * 查询消费记录列表
      */
@@ -61,7 +68,17 @@ public class FinTranRecordController extends BaseController
     @ApiOperation(value = "查询消费记录统计", notes = "查询消费记录统计")
     public R count(FinTranRecordDTO finTranRecord)
     {
-        return finTranRecordService.selecFinTranRecordCount(finTranRecord);
+         JSONObject jsonObject = finTranRecordService.selecFinTranRecordCount(finTranRecord);
+
+        // 用户总统计(游戏投注)
+        Map<String, BigDecimal> bettingAmountSum = appGameBettingService.getBettingAmountSum(finTranRecord.getUserId());
+        jsonObject.put("bettingAmountSum", bettingAmountSum);
+
+        // 根据时间查询投注
+        Map<String, BigDecimal> bettingAmountDateSum = appGameBettingService.getBettingAmountByDateSum(finTranRecord);
+        jsonObject.put("bettingAmountDateSum", bettingAmountDateSum);
+
+        return R.ok(jsonObject);
     }
 
     /**

+ 2 - 1
game-business/src/main/java/com/game/business/service/IFinTranRecordService.java

@@ -2,6 +2,7 @@ package com.game.business.service;
 
 import java.util.List;
 
+import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.game.business.domain.FinTranRecord;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -89,5 +90,5 @@ public interface IFinTranRecordService extends IService<FinTranRecord> {
 
     public List<FinTranRecord> selecListByWrapper(LambdaQueryWrapper<FinTranRecord> queryWrapper);
 
-    public R selecFinTranRecordCount(FinTranRecordDTO finTranRecordDTO);
+    public JSONObject selecFinTranRecordCount(FinTranRecordDTO finTranRecordDTO);
 }

+ 4 - 13
game-business/src/main/java/com/game/business/service/impl/FinTranRecordServiceImpl.java

@@ -62,9 +62,6 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
     @Autowired
     private ICfgCommonService cfgCommonService;
 
-    @Autowired
-    private IAppGameBettingService appGameBettingService;
-
     /**
      * 查询消费记录
      *
@@ -270,7 +267,8 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
     }
 
     @Override
-    public R selecFinTranRecordCount(FinTranRecordDTO finTranRecordDTO) {
+    @DataSource(DataSourceType.SLAVE)
+    public JSONObject selecFinTranRecordCount(FinTranRecordDTO finTranRecordDTO) {
 
         JSONObject jsonObject = new JSONObject();
 
@@ -278,10 +276,6 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
         Map<String, BigDecimal> userCount = appUserService.getUserCount(finTranRecordDTO.getUserId());
         jsonObject.put("userCount", userCount);
 
-        // 用户总统计(游戏投注)
-        Map<String, BigDecimal> bettingAmountSum = appGameBettingService.getBettingAmountSum(finTranRecordDTO.getUserId());
-        jsonObject.put("bettingAmountSum", bettingAmountSum);
-
         // 用户总统计(充值)
         Map<String, BigDecimal> rechargeCount = finTranRecordMapper.getRechargeSum(finTranRecordDTO.getUserId());
         jsonObject.put("rechargeCount", rechargeCount);
@@ -294,10 +288,6 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
         BigDecimal withdraw = finTranRecordMapper.getWithdrawSum(finTranRecordDTO.getUserId());
         jsonObject.put("withdraw", withdraw);
 
-        // 根据时间查询投注
-        Map<String, BigDecimal> bettingAmountDateSum = appGameBettingService.getBettingAmountByDateSum(finTranRecordDTO);
-        jsonObject.put("bettingAmountDateSum", bettingAmountDateSum);
-
         // 根据时间查询充值分类统计
         List<Map<String, Object>> rechargeByDateSum =  finTranRecordMapper.getRechargeByDateSum(finTranRecordDTO);
         if(rechargeByDateSum == null){
@@ -312,6 +302,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
             withdrawByDateSum = new ArrayList<>();
         }
         jsonObject.put("withdrawByDateSum", withdrawByDateSum);
-        return R.ok(jsonObject);
+
+        return jsonObject;
     }
 }

+ 1 - 1
game-business/src/main/resources/mapper/business/AppGameBettingMapper.xml

@@ -43,7 +43,7 @@
           group by betting_item
     </select>
 
-    <select id="getBettingAmountSum" resultType="java.math.BigDecimal">
+    <select id="getBettingAmountSum" resultType="java.util.Map">
         select
             ifnull(sum(case when betting_type = 1 then betting_amount else 0.00 end), 0.00) as coinSum,
             ifnull(sum(case when betting_type = 0 then betting_amount else 0.00 end), 0.00) as diamondCoinSum