kk 3 ماه پیش
والد
کامیت
1ea681c069

+ 8 - 1
game-business/src/main/java/com/game/business/controller/AppGameBettingController.java

@@ -155,6 +155,13 @@ public class AppGameBettingController extends BaseController{
             }
         }
 
+        BigDecimal gameBettingAmountCheck = new BigDecimal("0");
+        BigDecimal gameBettingAmountSum = appGameBettingService.getBettingAmount(gameBetting.getUserId(), gameBetting.getGameId(), appGame.getGameDate(), null);
+        BigDecimal gameBettingAmountAdd = gameBettingAmountSum.add(new BigDecimal(gameBetting.getBettingAmount() + ""));
+        if(gameBettingAmountAdd.compareTo(gameBettingAmountCheck) == 1){
+            return HttpRet.fail("当前期投注金额已超过限额,无法下单。");
+        }
+
         // 单选
         if(gameBetting.getBettingGameType() == 0){
 
@@ -175,7 +182,7 @@ public class AppGameBettingController extends BaseController{
             BigDecimal bettingAmountSum = appGameBettingService.getBettingAmount(gameBetting.getUserId(), gameBetting.getGameId(), appGame.getGameDate(), gameBetting.getBettingItem());
             BigDecimal bettingAmountAdd = bettingAmountSum.add(new BigDecimal(gameBetting.getBettingAmount() + ""));
             if(bettingAmountAdd.compareTo(bettingAmountCheck) == 1){
-                return HttpRet.fail("投注金额已超过限额,无法下单。");
+                return HttpRet.fail("当前期选项投注金额已超过限额,无法下单。");
             }
 
             gameBetting.setBettingMultiple(appGameItem.getItemMultiple());

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

@@ -71,14 +71,20 @@
     </select>
 
     <select id="getBettingCount" resultType="java.lang.Integer">
-        select
-        ifnull(count(1), 0) as bettingCount
-        from app_game_betting where user_id = #{userId} and game_id = #{gameId} and game_date = #{gameDate}
+        select ifnull(count(1), 0) as bettingCount from (
+            select
+                betting_item
+            from app_game_betting where user_id = #{userId} and game_id = #{gameId} and game_date = #{gameDate}
+            group by betting_item
+        ) tmp
     </select>
 
     <select id="getBettingAmount" resultType="java.math.BigDecimal">
         select
             ifnull(sum(betting_amount), 0.00) as bettingAmount
-        from app_game_betting where user_id = #{userId} and game_id = #{gameId} and game_date = #{gameDate} and betting_item = #{bettingItem}
+        from app_game_betting where user_id = #{userId} and game_id = #{gameId} and game_date = #{gameDate}
+        <if test="bettingItem != null">
+            and betting_item = #{bettingItem}
+        </if>
     </select>
 </mapper>