浏览代码

后台投注记录

kk 1 月之前
父节点
当前提交
cce7265ba0

+ 87 - 3
game-business/src/main/java/com/game/business/controller/AppGameBettingController.java

@@ -563,9 +563,6 @@ public class AppGameBettingController extends BaseController{
     public HttpRetPageArr<AppUserGameBettingCountVO> listHistory(@RequestParam(name = "gameId") Long gameId , @RequestParam(name = "bettingType", required = false) Integer bettingType
             , @RequestParam(name = "bettingGameType", required = false) Integer bettingGameType)
     {
-        startPage();
-        Long userId = SecurityUtils.getUserId();
-        List<AppUserGameBettingCountVO> list = appGameBettingService.getUserCount(gameId, userId, bettingType);
 
         if(bettingGameType == null){
             bettingGameType = 0;
@@ -574,6 +571,10 @@ public class AppGameBettingController extends BaseController{
             bettingType = 0;
         }
 
+        startPage();
+        Long userId = SecurityUtils.getUserId();
+        List<AppUserGameBettingCountVO> list = appGameBettingService.getUserCount(gameId, userId, bettingType);
+
         if(list != null && !list.isEmpty()){
 
             if(bettingGameType == 0){
@@ -640,6 +641,89 @@ public class AppGameBettingController extends BaseController{
         return HttpRetPageArr.success("查询成功",getDataTable(list));
     }
 
+    /**
+     * 游戏投注记录(后台)
+     */
+    @PostMapping(value = "/listHistoryWeb")
+    @ApiOperation(value = "游戏投注记录", notes = "游戏投注记录")
+    public HttpRetPageArr<AppUserGameBettingWebCountVO> listHistoryWeb(@RequestParam(name = "gameId" , required = false) Long gameId ,
+                                                                       @RequestParam(name = "userId" , required = false) Long userId ,
+                                                                       @RequestParam(name = "bettingType", required = false) Integer bettingType)
+    {
+
+        startPage();
+        List<AppUserGameBettingWebCountVO> list = appGameBettingService.getUserWebCount(gameId, userId, bettingType);
+
+        if(list != null && !list.isEmpty()){
+
+            for (int i = 0; i < list.size(); i++) {
+
+                AppUserGameBettingWebCountVO appUserGameBettingWebCountVO = list.get(i);
+
+                // 单选
+                if(appUserGameBettingWebCountVO.getBettingGameType() == 0){
+                    List<AppUserGameBettingDetailsCountVO> detailsCountVOList = appGameBettingService.getUserBettingItemCount(appUserGameBettingWebCountVO.getGameId(),
+                            appUserGameBettingWebCountVO.getGameDate(), appUserGameBettingWebCountVO.getUserId(), appUserGameBettingWebCountVO.getBettingType());
+                    if(detailsCountVOList == null){
+                        detailsCountVOList  = new ArrayList<>();
+                    }
+
+                    appUserGameBettingWebCountVO.setDetailsCountVOList(detailsCountVOList);
+                // 写死多选
+                }else if(appUserGameBettingWebCountVO.getBettingGameType() == 1){
+
+                    List<AppGameBetting> bettingList = appGameBettingService.getUserBettingItem(appUserGameBettingWebCountVO.getGameId(),
+                            appUserGameBettingWebCountVO.getGameDate(), appUserGameBettingWebCountVO.getUserId(), appUserGameBettingWebCountVO.getBettingType());
+                    if(bettingList == null){
+                        bettingList  = new ArrayList<>();
+                    }
+                    Map<String, AppUserGameBettingDetailsCountVO> itemMap = new HashMap<>();
+                    for (int j = 0; j < bettingList.size(); j++) {
+                        AppGameBetting appGameBetting =  bettingList.get(j);
+
+                        List<AppGameItemBettingVO> itemList = JSON.parseArray(appGameBetting.getBettingItem(), AppGameItemBettingVO.class);
+
+                        for(AppGameItemBettingVO item : itemList){
+                            if(itemMap.containsKey(item.getBettingItem())){
+                                AppUserGameBettingDetailsCountVO appUserGameBettingDetailsCountVO = itemMap.get(item.getBettingItem());
+                                appUserGameBettingDetailsCountVO.setOrderAmount(appUserGameBettingDetailsCountVO.getOrderAmount() + item.getBettingAmount());
+                                if(appGameBetting.getIsWinning() == 1){
+                                    if(item.getBettingItem().equals(appUserGameBettingWebCountVO.getGameLotterySucc())) {
+                                        appUserGameBettingDetailsCountVO.setWinAmount(appUserGameBettingDetailsCountVO.getWinAmount() + (appGameBetting.getBettingAmount() * appGameBetting.getBettingMultiple()));
+                                    }
+                                }else if(appGameBetting.getIsWinning() == 2){
+                                    appUserGameBettingDetailsCountVO.setLoseAmount(appUserGameBettingDetailsCountVO.getLoseAmount() + item.getBettingAmount());
+                                }
+                                itemMap.put(item.getBettingItem(), appUserGameBettingDetailsCountVO);
+                            }else{
+                                AppUserGameBettingDetailsCountVO appUserGameBettingDetailsCountVO = new AppUserGameBettingDetailsCountVO();
+                                appUserGameBettingDetailsCountVO.setBettingTtem(item.getBettingItem());
+                                appUserGameBettingDetailsCountVO.setOrderAmount(item.getBettingAmount());
+                                if(appGameBetting.getIsWinning() == 1){
+                                    if(item.getBettingItem().equals(appUserGameBettingWebCountVO.getGameLotterySucc())){
+                                        appUserGameBettingDetailsCountVO.setWinAmount(appGameBetting.getBettingAmount() * appGameBetting.getBettingMultiple());
+                                    }
+                                }else if(appGameBetting.getIsWinning() == 2){
+                                    appUserGameBettingDetailsCountVO.setLoseAmount(item.getBettingAmount());
+                                }
+                                itemMap.put(item.getBettingItem(), appUserGameBettingDetailsCountVO);
+                            }
+                        }
+                    }
+                    List<AppUserGameBettingDetailsCountVO> detailsCountVOList = new ArrayList<>();
+                    Set<String> set = itemMap.keySet();
+                    Iterator<String> iterator = set.iterator();
+                    while (iterator.hasNext()){
+                        AppUserGameBettingDetailsCountVO appUserGameBettingDetailsCountVO = itemMap.get(iterator.next());
+                        detailsCountVOList.add(appUserGameBettingDetailsCountVO);
+                    }
+                    appUserGameBettingWebCountVO.setDetailsCountVOList(detailsCountVOList);
+                }
+            }
+        }
+        return HttpRetPageArr.success("查询成功",getDataTable(list));
+    }
+
     private double getMultiple(int size){
         double itemMultiple;
         switch (size){

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

@@ -7,6 +7,7 @@ import com.game.business.dto.FinTranRecordDTO;
 import com.game.business.vo.AppGameBettingDetailsCountVO;
 import com.game.business.vo.AppUserGameBettingCountVO;
 import com.game.business.vo.AppUserGameBettingDetailsCountVO;
+import com.game.business.vo.AppUserGameBettingWebCountVO;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
@@ -18,6 +19,7 @@ public interface AppGameBettingMapper extends BaseMapper<AppGameBetting> {
 
     List<AppGameBettingDetailsCountVO> getCount(@Param(value = "strDate") String strDate, @Param(value = "userId") Long userId,  @Param(value = "bettingType") Integer bettingType);
     List<AppUserGameBettingCountVO> getUserCount(@Param(value = "gameId") Long gameId, @Param(value = "userId") Long userId, @Param(value = "bettingType") Integer bettingType);
+    List<AppUserGameBettingWebCountVO> getUserWebCount(@Param(value = "gameId") Long gameId, @Param(value = "userId") Long userId, @Param(value = "bettingType") Integer bettingType);
     List<AppUserGameBettingDetailsCountVO> getUserBettingItemCount(@Param(value = "gameId") Long gameId, @Param(value = "gameDate") String gameDate, @Param(value = "userId") Long userId, @Param(value = "bettingType") Integer bettingType);
     Map<String, BigDecimal> getBettingAmountSum(Long userId);
     Map<String, BigDecimal> getBettingAmountByDateSum(FinTranRecordDTO finTranRecordDTO);

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

@@ -6,6 +6,7 @@ import com.game.business.dto.FinTranRecordDTO;
 import com.game.business.vo.AppGameBettingDetailsCountVO;
 import com.game.business.vo.AppUserGameBettingCountVO;
 import com.game.business.vo.AppUserGameBettingDetailsCountVO;
+import com.game.business.vo.AppUserGameBettingWebCountVO;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -23,6 +24,8 @@ public interface IAppGameBettingService extends IService<AppGameBetting> {
 
     List<AppUserGameBettingCountVO> getUserCount(Long gameId, Long userId, Integer bettingType);
 
+    List<AppUserGameBettingWebCountVO> getUserWebCount(Long gameId, Long userId, Integer bettingType);
+
     List<AppUserGameBettingDetailsCountVO> getUserBettingItemCount(Long gameId, String gameDate, Long userId, Integer bettingType);
 
     List<AppGameBetting> getUserBettingItem(Long gameId, String gameDate, Long userId, Integer bettingType);

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

@@ -10,6 +10,7 @@ import com.game.business.mapper.AppGameBettingMapper;
 import com.game.business.service.IAppGameBettingService;
 import com.game.business.vo.AppUserGameBettingCountVO;
 import com.game.business.vo.AppUserGameBettingDetailsCountVO;
+import com.game.business.vo.AppUserGameBettingWebCountVO;
 import com.game.common.utils.DateUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -58,6 +59,11 @@ public class AppGameBettingServiceImpl extends ServiceImpl<AppGameBettingMapper,
         return appGameBettingMapper.getUserCount(gameId, userId, bettingType);
     }
 
+    @Override
+    public List<AppUserGameBettingWebCountVO> getUserWebCount(Long gameId, Long userId, Integer bettingType) {
+        return appGameBettingMapper.getUserWebCount(gameId, userId, bettingType);
+    }
+
     @Override
     public List<AppUserGameBettingDetailsCountVO> getUserBettingItemCount(Long gameId, String gameDate, Long userId, Integer bettingType) {
         return appGameBettingMapper.getUserBettingItemCount(gameId, gameDate, userId, bettingType);

+ 58 - 0
game-business/src/main/java/com/game/business/vo/AppUserGameBettingWebCountVO.java

@@ -0,0 +1,58 @@
+package com.game.business.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+@ApiModel(value = "游戏投注记录", description = "游戏投注记录")
+public class AppUserGameBettingWebCountVO {
+
+    @ApiModelProperty(value = "用户Id")
+    private Long userId;
+
+    @ApiModelProperty(value = "游戏ID")
+    private Long gameId;
+
+    @ApiModelProperty(value = "游戏名称")
+    private String gameName;
+
+    @ApiModelProperty(value = "当前期号")
+    private String gameDate;
+
+    @ApiModelProperty(value = "本期第一次投注时间")
+    private Date bettingDate;
+
+    @ApiModelProperty(value = "投注类型:0:余额 1:金币")
+    private Integer bettingType;
+
+    @ApiModelProperty(value = "投注游戏类型 0:单选 1:写死多选:2:自由多选")
+    private Integer bettingGameType;
+
+    @ApiModelProperty(value = "数量")
+    private long bettingCount;
+
+    @ApiModelProperty(value = "下单金额")
+    private double orderAmount;
+
+    @ApiModelProperty(value = "赢")
+    private double winAmount;
+
+    @ApiModelProperty(value = "输")
+    private double loseAmount;
+
+    @ApiModelProperty(value = "当前开奖项")
+    private String gameLotterySucc;
+
+    @ApiModelProperty(value = "是否开奖:0 否;1是")
+    private Integer isLottery;
+
+    @ApiModelProperty(value = "当前开奖时间")
+    private Date gameRecordDate;
+
+    @ApiModelProperty(value = "投注选项统计")
+    List<AppUserGameBettingDetailsCountVO> detailsCountVOList;
+}

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

@@ -54,6 +54,41 @@
         order by tmp.gameDate desc
     </select>
 
+    <select id="getUserWebCount" resultType="com.game.business.vo.AppUserGameBettingWebCountVO">
+        select tmp.*,
+               ag.name as gameName,
+               agl.game_lottery_succ as gameLotterySucc,agl.game_record_date as gameRecordDate,agl.is_lottery as isLottery
+        from (
+                 select
+                     user_id as userId,
+                     game_id as gameId,
+                     game_date as gameDate,
+                     betting_type as bettingType,
+                     betting_game_type as bettingGameType,
+                     min(create_time) as bettingDate,
+                     count(id) as bettingCount,
+                     sum(betting_amount) as orderAmount,
+                     sum(case when is_winning = 1 then (betting_amount * betting_multiple) else 0.00 end) as winAmount,
+                     sum(case when is_winning = 2 then (betting_amount) else 0.00 end) as loseAmount
+                 from app_game_betting
+                 <where>
+                     <if test="userId != null">
+                         and user_id = #{userId}
+                     </if>
+                     <if test="gameId != null">
+                         and game_id = #{gameId}
+                     </if>
+                     <if test="bettingType != null">
+                         and betting_type = #{bettingType}
+                     </if>
+                 </where>
+                 group by user_id, game_id, game_date, betting_game_type
+             ) tmp
+            left join app_game ag on ag.id = tmp.gameId
+            left join app_game_lottery agl on agl.game_date = tmp.gameDate and agl.game_id = tmp.gameId
+        order by tmp.bettingDate desc
+    </select>
+
     <select id="getUserBettingItemCount" resultType="com.game.business.vo.AppUserGameBettingDetailsCountVO">
           select
               betting_item as bettingTtem,