dos 2 недель назад
Родитель
Сommit
06d41c89b9

+ 4 - 0
game-business/src/main/java/com/game/business/mapper/FinTranRecordMapper.java

@@ -1,6 +1,7 @@
 package com.game.business.mapper;
 
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -9,6 +10,7 @@ import com.game.business.domain.FinTranRecord;
 import com.game.business.dto.FinTranDto;
 import com.game.business.dto.FinTranRecordDTO;
 import com.game.business.vo.FinTranVo;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 消费记录Mapper接口
@@ -78,4 +80,6 @@ public interface FinTranRecordMapper extends BaseMapper<FinTranRecord> {
     List<Map<String, Object>> getRechargeByDateSum(FinTranRecordDTO finTranRecordDTO);
 
     List<FinTranVo> selectTranList(FinTranDto finTranDto);
+
+    Double sumUserTran(@Param("type1") Integer type1, @Param("type3s") String type3s, @Param("userId") Long userId, @Param("beginDate") Date beginDate, @Param("endDate") Date endDate, @Param("withdrawFlag") Integer withDrawFlag);
 }

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

@@ -106,4 +106,6 @@ public interface IFinTranRecordService extends IService<FinTranRecord> {
      * 根据type查询流水
      * */
     List<FinTranRecord> selectUserTran(Integer type1, String type3s, Long userId, Date beginDate,Date endDate,Integer withDrawFlag);
+
+    Double sumUserTran(Integer type1, String type3s, Long userId, Date beginDate,Date endDate,Integer withDrawFlag);
 }

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

@@ -429,4 +429,10 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
         queryWrapper.eq(FinTranRecord::getCurrencyType,4);//余额流水
         return finTranRecordMapper.selectList(queryWrapper);
     }
+
+    @Override
+    @DataSource(DataSourceType.SLAVE)
+    public Double sumUserTran(Integer type1, String type3s, Long userId, Date beginDate, Date endDate, Integer withDrawFlag) {
+        return finTranRecordMapper.sumUserTran(type1,type3s,userId,beginDate,endDate,withDrawFlag);
+    }
 }

+ 6 - 4
game-business/src/main/java/com/game/business/task/AppUserCountTask.java

@@ -697,8 +697,9 @@ public class AppUserCountTask {
 
                 }
                 //查询用户这段时间流水记录
-                List<FinTranRecord> curTranList = finTranRecordService.selectUserTran(null, null, uid, null, endDate, null);
-                withdrawAble += curTranList.stream().filter(e->FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW.getType()!=e.getTranType3().intValue()).mapToDouble(FinTranRecord::getDiamondCoinChange).sum();
+                /*List<FinTranRecord> curTranList = finTranRecordService.selectUserTran(null, null, uid, null, endDate, null);
+                withdrawAble += curTranList.stream().filter(e->FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW.getType()!=e.getTranType3().intValue()).mapToDouble(FinTranRecord::getDiamondCoinChange).sum();*/
+                withdrawAble = finTranRecordService.sumUserTran(null, null, uid, null, endDate, null);
                 AppUser updateUser = new AppUser();
                 updateUser.setUserid(uid);
                 updateUser.setWithdrawAble(withdrawAble);
@@ -714,8 +715,9 @@ public class AppUserCountTask {
                 log.info("用户{},有为满足提现订单,停止更新可提现余额",userId);
             }else{
                 //查询用户这段时间流水记录
-                List<FinTranRecord> curTranList = finTranRecordService.selectUserTran(null, null, userId, null, null, null);
-                double withdrawAble = curTranList.stream().filter(e->FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW.getType()!=e.getTranType3().intValue()).mapToDouble(FinTranRecord::getDiamondCoinChange).sum();
+               /* List<FinTranRecord> curTranList = finTranRecordService.selectUserTran(null, null, userId, null, null, null);
+                double withdrawAble = curTranList.stream().filter(e->FinTranType3.CONSUM_GAME_ANCHOR_WITHDRAW.getType()!=e.getTranType3().intValue()).mapToDouble(FinTranRecord::getDiamondCoinChange).sum();*/
+                double withdrawAble = finTranRecordService.sumUserTran(null, null, userId, null, null, null);
                 AppUser updateUser = new AppUser();
                 updateUser.setUserid(userId);
                 updateUser.setWithdrawAble(withdrawAble);

+ 30 - 0
game-business/src/main/resources/mapper/business/FinTranRecordMapper.xml

@@ -347,4 +347,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </if>
     </select>
 
+    <select id="sumUserTran" resultType="java.lang.Double">
+        select sum(diamond_coin_change) from fin_tran_record
+        <where>
+            <if test="type1 != null">
+                and tran_type1 = #{type1}
+            </if>
+            <if test="userId != null">
+                and uid = #{userId}
+            </if>
+            <if test="type3s != null">
+                and tran_type3 in
+                <foreach item="item" collection="type3s" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="type3s == null">
+                and tran_type3 != 20002
+            </if>
+            <if test="beginDate != null">
+                and create_time &gt;= #{beginDate}
+            </if>
+            <if test="endDate != null">
+                and create_time &lt;= #{endDate}
+            </if>
+            <if test="withdrawFlag != null">
+                and withdraw_flag = #{withdrawFlag}
+            </if>
+        </where>
+    </select>
+
 </mapper>