Browse Source

修复丢失投注记录问题

dos 2 months ago
parent
commit
7b2b250829

+ 3 - 0
game-business/src/main/java/com/game/business/mapper/AppUserCountMapper.java

@@ -27,4 +27,7 @@ public interface AppUserCountMapper extends BaseMapper<AppUserCount> {
             " </script>")
     public List<AppUserCount> selectTeamUserCount(@Param("pid") Long pid,@Param("beginTime") String beginTime,@Param("endTime") String endTime);
 
+
+    public int updateCount(AppUserCount appUserCount);
+
 }

+ 10 - 4
game-business/src/main/java/com/game/business/service/impl/AppUserCountServiceImpl.java

@@ -14,12 +14,14 @@ import com.game.common.core.redis.RedisCache;
 import com.game.common.entity.KeyValue;
 import com.game.common.utils.DateUtils;
 import com.game.common.utils.StringUtils;
+import org.redisson.api.RLock;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.Date;
@@ -95,7 +97,7 @@ public class AppUserCountServiceImpl extends ServiceImpl<AppUserCountMapper, App
                 }*/
                 if (!appUserCount.isUpdate()) {
                     //非全量更新
-                    if (appUserCount.getRechargeAmount() != null) {
+                    /*if (appUserCount.getRechargeAmount() != null) {
                         appUserCount.setRechargeAmount(userCount.getRechargeAmount() + appUserCount.getRechargeAmount());
                     }
                     if (appUserCount.getRechargeCommission() != null) {
@@ -104,7 +106,7 @@ public class AppUserCountServiceImpl extends ServiceImpl<AppUserCountMapper, App
                     if (appUserCount.getRechargeGive() != null) {
                         appUserCount.setRechargeGive(userCount.getRechargeGive() + appUserCount.getRechargeGive());
                     }
-                    if (appUserCount.getWithdrawalCommission() != null) {
+                    if (appUserCount.getWithdrawalAmount() != null) {
                         appUserCount.setWithdrawalAmount(userCount.getWithdrawalAmount() + appUserCount.getWithdrawalAmount());
                     }
                     if (appUserCount.getWithdrawalCommission() != null) {
@@ -136,9 +138,13 @@ public class AppUserCountServiceImpl extends ServiceImpl<AppUserCountMapper, App
                     }
                     if (appUserCount.getLiveProfit() != null) {
                         appUserCount.setLiveProfit(userCount.getLiveProfit() + appUserCount.getLiveProfit());
-                    }
+                    }*/
+                    //增量更新
+                    appUserCountMapper.updateCount(appUserCount);//增量累加
+                }else{
+                    res = appUserCountMapper.updateById(appUserCount);
                 }
-                res = appUserCountMapper.updateById(appUserCount);
+
             }
         }
     }

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

@@ -145,7 +145,7 @@ public class AppUserCountTask {
                     //游戏佣金
                     appUserCount.setGameCommission(gameRecordCountList.stream().filter(e -> e.getUserId().equals(appUser.getUserid())).mapToDouble(e -> e.getCommission()).sum());
                     //直播间下注佣金
-                    appUserCount.setGameCommission(gameRecordCountList.stream().filter(e -> e.getUserId().equals(appUser.getUserid()) && 1 == e.getType().intValue()).mapToDouble(e -> e.getCommission()).sum());
+                    appUserCount.setLiveBettingCommission(gameRecordCountList.stream().filter(e -> e.getUserId().equals(appUser.getUserid()) && 1 == e.getType().intValue()).mapToDouble(e -> e.getCommission()).sum());
                     //游戏输
                     appUserCount.setGameLoseAmount(gameBettingList.stream().filter(
                             e -> e.getUserId().equals(appUser.getUserid()) && e.getIsWinning().intValue() == 2

+ 65 - 0
game-business/src/main/resources/mapper/business/AppUserCountMapper.xml

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.game.business.mapper.AppUserCountMapper">
+
+    <update id="updateCount" parameterType="com.game.business.domain.AppUserCount">
+        update app_user_count
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="rechargeAmount != null">
+                recharge_amount = recharge_amount + #{rechargeAmount},
+            </if>
+            <if test="rechargeCommission != null">
+                recharge_commission = recharge_commission + #{rechargeCommission},
+            </if>
+            <if test="rechargeGive != null">
+                recharge_give = recharge_give + #{rechargeGive},
+            </if>
+            <if test="withdrawalAmount != null">
+                withdrawal_amount = withdrawal_amount + #{withdrawalAmount},
+            </if>
+            <if test="withdrawalCommission != null">
+                withdrawal_commission = withdrawal_commission + #{withdrawalCommission},
+            </if>
+            <if test="liveUseAmount != null">
+                live_use_amount = live_use_amount + #{liveUseAmount},
+            </if>
+            <if test="liveCommission != null">
+                live_commission = live_commission + #{liveCommission},
+            </if>
+            <if test="gameWinAmount != null">
+                game_win_amount = game_win_amount + #{gameWinAmount},
+            </if>
+            <if test="gameLoseAmount != null">
+                game_lose_amount = game_lose_amount + #{gameLoseAmount},
+            </if>
+            <if test="gameCommission != null">
+                game_commission = game_commission + #{gameCommission},
+            </if>
+            <if test="gameBetting != null">
+                game_betting = game_betting + #{gameBetting},
+            </if>
+            <if test="liveBettingCommission != null">
+                live_betting_commission = live_betting_commission + #{liveBettingCommission},
+            </if>
+            <if test="liveInvite != null">
+                live_invite = live_invite + #{liveInvite},
+            </if>
+            <if test="liveProfit != null">
+                live_profit = live_profit + #{liveProfit},
+            </if>
+            <if test="updateTime != null">
+                update_time = #{updateTime},
+            </if>
+            <if test="countTime != null">
+                count_time = #{countTime},
+            </if>
+            <if test="gameCountTime != null">
+                game_count_time = #{gameCountTime},
+            </if>
+        </trim>
+        where id = #{id}
+    </update>
+
+</mapper>