Selaa lähdekoodia

投注选项限制个数

kk 1 kuukausi sitten
vanhempi
commit
eab0545b8b

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

@@ -155,10 +155,11 @@ public class AppGameBettingController extends BaseController{
             return HttpRet.fail("投注次数已超过限额,无法下单。");
         }
 
+        // 每期可投注多少个选项:比如设置为3 则只能投3个不同的选项,不能超过3个
         Integer bettingCount = appGameBettingService.getBettingCount(gameBetting.getUserId(), gameBetting.getGameId(), appGame.getGameDate(), gameBetting.getBettingItem());
         if(bettingCount != null && bettingCount > 0 ){
             if(bettingCount.intValue() >= appGame.getBettingCount().intValue()){
-                return HttpRet.fail("投注次数已超过限额,无法下单。");
+                return HttpRet.fail("当前期投注选项已超过限额,无法下单。");
             }
         }
 
@@ -185,6 +186,13 @@ public class AppGameBettingController extends BaseController{
                 }
             }
 
+            Integer bettingItemCount = appGameBettingService.getBettingItemCount(gameBetting.getUserId(), gameBetting.getGameId(), appGame.getGameDate(), gameBetting.getBettingItem());
+            if(bettingItemCount != null && bettingItemCount > 0 ){
+                if(bettingItemCount.intValue() >= appGameItem.getBettingCount().intValue()){
+                    return HttpRet.fail("当前期投注选项数量已超过限额,无法下单。");
+                }
+            }
+
             BigDecimal bettingAmountCheck = new BigDecimal(appGameItem.getBettingMoney() + "");
             BigDecimal bettingAmountSum = appGameBettingService.getBettingAmount(gameBetting.getUserId(), gameBetting.getGameId(), appGame.getGameDate(), gameBetting.getBettingItem());
             BigDecimal bettingAmountAdd = bettingAmountSum.add(new BigDecimal(gameBetting.getBettingAmount() + ""));

+ 6 - 0
game-business/src/main/java/com/game/business/domain/AppGameItem.java

@@ -56,6 +56,12 @@ private static final long serialVersionUID=1L;
     @TableField(value = "item_location")
     private String itemLocation;
 
+    /** 每期投注个数 */
+    @ApiModelProperty(value = "每期投注个数")
+    @Excel(name = "每期投注个数")
+    @TableField(value = "betting_count")
+    private Integer bettingCount;
+
     /** 每期投注金额 */
     @ApiModelProperty(value = "每期投注金额")
     @Excel(name = "每期投注金额")

+ 1 - 0
game-business/src/main/java/com/game/business/mapper/AppGameBettingMapper.java

@@ -22,6 +22,7 @@ public interface AppGameBettingMapper extends BaseMapper<AppGameBetting> {
     Map<String, BigDecimal> getBettingAmountByDateSum(FinTranRecordDTO finTranRecordDTO);
 
     Integer getBettingCount(@Param(value = "userId") Long userId, @Param(value = "gameId") Long gameId, @Param(value = "gameDate") String gameDate, @Param(value = "bettingItem") String bettingItem);
+    Integer getBettingItemCount(@Param(value = "userId") Long userId, @Param(value = "gameId") Long gameId, @Param(value = "gameDate") String gameDate, @Param(value = "bettingItem") String bettingItem);
     BigDecimal getBettingAmount(@Param(value = "userId") Long userId, @Param(value = "gameId") Long gameId, @Param(value = "gameDate") String gameDate, @Param(value = "bettingItem") String bettingItem);
 
     /**

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

@@ -47,6 +47,8 @@ public interface IAppGameBettingService extends IService<AppGameBetting> {
 
     Integer getBettingCount(Long userId, Long gameId, String gameDate, String bettingItem);
 
+    Integer getBettingItemCount(Long userId, Long gameId, String gameDate, String bettingItem);
+
     BigDecimal getBettingAmount(Long userId, Long gameId, String gameDate, String bettingItem);
 
     /**

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

@@ -165,6 +165,11 @@ public class AppGameBettingServiceImpl extends ServiceImpl<AppGameBettingMapper,
         return appGameBettingMapper.getBettingCount(userId, gameId, gameDate, bettingItem);
     }
 
+    @Override
+    public Integer getBettingItemCount(Long userId, Long gameId, String gameDate, String bettingItem) {
+        return appGameBettingMapper.getBettingItemCount(userId, gameId, gameDate, bettingItem);
+    }
+
     @Override
     public BigDecimal getBettingAmount(Long userId, Long gameId, String gameDate, String bettingItem) {
         return appGameBettingMapper.getBettingAmount(userId, gameId, gameDate, bettingItem);

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

@@ -100,6 +100,15 @@
         ) tmp
     </select>
 
+    <select id="getBettingItemCount" 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}
+        <if test="bettingItem != null and bettingItem != ''">
+            and betting_item = #{bettingItem}
+        </if>
+    </select>
+
     <select id="getBettingAmount" resultType="java.math.BigDecimal">
         select
             ifnull(sum(betting_amount), 0.00) as bettingAmount

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

@@ -10,13 +10,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="itemName"    column="item_name"    />
         <result property="itemMultiple"    column="item_multiple"    />
         <result property="itemLocation"    column="item_location"    />
+        <result property="bettingCount"    column="betting_count"    />
         <result property="bettingMoney"    column="betting_money"    />
         <result property="lotteryCount"    column="lottery_count"    />
         <result property="consecutive"    column="consecutive"    />
     </resultMap>
 
     <sql id="selectAppGameItemVo">
-        select id, game_id, item_name, item_multiple, item_location, betting_money, lottery_count, consecutive from app_game_item
+        select id, game_id, item_name, item_multiple, item_location, betting_count, betting_money, lottery_count, consecutive from app_game_item
     </sql>
 
     <select id="selectAppGameItemList" parameterType="com.game.business.domain.AppGameItem" resultMap="AppGameItemResult">
@@ -26,6 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="itemName != null  and itemName != ''"> and item_name like concat('%', #{itemName}, '%')</if>
             <if test="itemMultiple != null "> and item_multiple = #{itemMultiple}</if>
             <if test="itemLocation != null  and itemLocation != ''"> and item_location = #{itemLocation}</if>
+            <if test="bettingCount != null "> and betting_count = #{bettingCount}</if>
             <if test="bettingMoney != null "> and betting_money = #{bettingMoney}</if>
             <if test="lotteryCount != null "> and lottery_count = #{lotteryCount}</if>
             <if test="consecutive != null "> and consecutive = #{consecutive}</if>
@@ -46,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="itemMultiple != null">item_multiple,</if>
             <if test="itemLocation != null">item_location,</if>
             <if test="bettingMoney != null">betting_money,</if>
+            <if test="bettingCount != null">betting_count,</if>
             <if test="lotteryCount != null">lottery_count,</if>
             <if test="consecutive != null">consecutive,</if>
          </trim>
@@ -54,6 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="itemName != null">#{itemName},</if>
             <if test="itemMultiple != null">#{itemMultiple},</if>
             <if test="itemLocation != null">#{itemLocation},</if>
+            <if test="bettingCount != null">#{bettingCount},</if>
             <if test="bettingMoney != null">#{bettingMoney},</if>
             <if test="lotteryCount != null">#{lotteryCount},</if>
             <if test="consecutive != null">#{consecutive},</if>
@@ -67,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="itemName != null">item_name = #{itemName},</if>
             <if test="itemMultiple != null">item_multiple = #{itemMultiple},</if>
             <if test="itemLocation != null">item_location = #{itemLocation},</if>
+            <if test="bettingCount != null">betting_count = #{bettingCount},</if>
             <if test="bettingMoney != null">betting_money = #{bettingMoney},</if>
             <if test="lotteryCount != null">lottery_count = #{lotteryCount},</if>
             <if test="consecutive != null">consecutive = #{consecutive},</if>