张延森 hace 4 años
padre
commit
b5684dc2ef
Se han modificado 29 ficheros con 854 adiciones y 150 borrados
  1. 89
    0
      src/main/java/com/yunzhi/niucai/common/BizUtils.java
  2. 119
    0
      src/main/java/com/yunzhi/niucai/controller/TaCustomerBettingController.java
  3. 18
    2
      src/main/java/com/yunzhi/niucai/entity/TaBettingPlan.java
  4. 4
    4
      src/main/java/com/yunzhi/niucai/entity/TaBettingPlanItem.java
  5. 18
    24
      src/main/java/com/yunzhi/niucai/entity/TaBettingPlanSportDetail.java
  6. 100
    0
      src/main/java/com/yunzhi/niucai/entity/TaCustomerBetting.java
  7. 61
    0
      src/main/java/com/yunzhi/niucai/entity/TaCustomerBettingSport.java
  8. 10
    0
      src/main/java/com/yunzhi/niucai/entity/TdLottery.java
  9. 1
    1
      src/main/java/com/yunzhi/niucai/entity/TdSportPass.java
  10. 0
    18
      src/main/java/com/yunzhi/niucai/mapper/TaBettingPlanItemDetailMapper.java
  11. 18
    0
      src/main/java/com/yunzhi/niucai/mapper/TaBettingPlanSportDetailMapper.java
  12. 18
    0
      src/main/java/com/yunzhi/niucai/mapper/TaCustomerBettingMapper.java
  13. 18
    0
      src/main/java/com/yunzhi/niucai/mapper/TaCustomerBettingSportMapper.java
  14. 0
    16
      src/main/java/com/yunzhi/niucai/service/ITaBettingPlanItemDetailService.java
  15. 16
    0
      src/main/java/com/yunzhi/niucai/service/ITaBettingPlanSportDetailService.java
  16. 16
    0
      src/main/java/com/yunzhi/niucai/service/ITaCustomerBettingService.java
  17. 16
    0
      src/main/java/com/yunzhi/niucai/service/ITaCustomerBettingSportService.java
  18. 5
    0
      src/main/java/com/yunzhi/niucai/service/ITaMatchOddsService.java
  19. 5
    0
      src/main/java/com/yunzhi/niucai/service/ITaMatchWayService.java
  20. 0
    20
      src/main/java/com/yunzhi/niucai/service/impl/TaBettingPlanItemDetailServiceImpl.java
  21. 183
    64
      src/main/java/com/yunzhi/niucai/service/impl/TaBettingPlanServiceImpl.java
  22. 20
    0
      src/main/java/com/yunzhi/niucai/service/impl/TaBettingPlanSportDetailServiceImpl.java
  23. 20
    0
      src/main/java/com/yunzhi/niucai/service/impl/TaCustomerBettingServiceImpl.java
  24. 20
    0
      src/main/java/com/yunzhi/niucai/service/impl/TaCustomerBettingSportServiceImpl.java
  25. 32
    0
      src/main/java/com/yunzhi/niucai/service/impl/TaMatchOddsServiceImpl.java
  26. 36
    0
      src/main/java/com/yunzhi/niucai/service/impl/TaMatchWayServiceImpl.java
  27. 5
    0
      src/main/resources/mapper/TaBettingPlanSportDetailMapper.xml
  28. 1
    1
      src/main/resources/mapper/TaCustomerBettingMapper.xml
  29. 5
    0
      src/main/resources/mapper/TaCustomerBettingSportMapper.xml

+ 89
- 0
src/main/java/com/yunzhi/niucai/common/BizUtils.java Ver fichero

@@ -0,0 +1,89 @@
1
+package com.yunzhi.niucai.common;
2
+
3
+import java.util.ArrayList;
4
+import java.util.List;
5
+
6
+/**
7
+ * 业务相关工具类
8
+ */
9
+public class BizUtils {
10
+    /**
11
+     * 计算竞彩过关总数
12
+     * 计算方式如下, 比如购买 5 场  4串5
13
+     * 那么从第一场开始与剩下的4场进行组合,求可能的组合数
14
+     * 接着第二场与剩下的3场进行组合,求可能的组合数
15
+     * 依次下去,直到剩余的场次不能组合4串1
16
+     * 示例 5场的投注注数为 [1, 2, 3, 4, 2]
17
+     * 第一场则有 4种组合可能,即 剩余的 4场挑 3场与第一场组合, C3-4 就是 4
18
+     *     [1, 2, 3, 4] = 1 * 2 * 3 * 4 = 24
19
+     *     [1, 2, 3, 2] = 1 * 2 * 3 * 2 = 12
20
+     *     [1, 2, 4, 2] = 1 * 2 * 4 * 2 = 16
21
+     *     [1, 3, 4, 2] = 1 * 3 * 4 * 2 = 24
22
+     *   第一场结果就是 24 + 12 + 16 + 24 = 76
23
+     * 第二场有 1 种可能, 即 只能把剩余的 3场全部拿来组合
24
+     *     [2, 3, 4, 2] = 2 * 3 * 4 * 2 = 48
25
+     * 剩余的都不能再组合 4串1
26
+     * 因此总过关数是  (76 + 48) * 5  这个 5 来源 4串5
27
+     * @param unitNum
28
+     * @param amount
29
+     * @param noteNumList
30
+     * @return
31
+     */
32
+    public static int computeSportNoteNum(int unitNum, int amount, List<Integer> noteNumList) {
33
+        if (null == noteNumList || noteNumList.size() == 0) {
34
+            return 0;
35
+        }
36
+
37
+        List<List<Integer>> result = new ArrayList<>();
38
+        int times = 0;
39
+        int cursor = 0;
40
+
41
+        // 比如 5 场 投注 4串5, 只可能循环2次, 因为后面的都不能组合为 4串1
42
+        int max = noteNumList.size() - (unitNum - times);
43
+
44
+        // 遍历每场的可能
45
+        for(int i = cursor; i <= max; i++) {
46
+            List<Integer> last = new ArrayList<>();
47
+            last.add(noteNumList.get(i));
48
+            recursion(noteNumList, unitNum, times, cursor, last, result);
49
+        }
50
+
51
+        // 遍历结果, 外循环是场次的结果,需要相加
52
+        // 内循环是每场的组合可能, 需要相乘
53
+        int sum = 0;
54
+        for(List<Integer> noteNum: result) {
55
+            int multi = 1;
56
+            for(Integer n: noteNum) {
57
+                multi *= n;
58
+            }
59
+            sum += multi;
60
+        }
61
+
62
+        return sum * amount;
63
+    }
64
+
65
+    /**
66
+     * 递归遍历每种排列组合方式
67
+     * @param noteNumList
68
+     * @param unitNum 过关场数 比如 4串1 , 4 就是场数
69
+     * @param times 当前场数 0 开始
70
+     * @param cursor noteNumList 的 当前位置
71
+     * @param last  上一轮结果
72
+     * @param out 通过 ref 方式输出结果
73
+     */
74
+    private static void recursion(List<Integer> noteNumList, int unitNum, int times, int cursor, List<Integer> last, List<List<Integer>> out) {
75
+        int max = noteNumList.size() - (unitNum - times);
76
+
77
+        for (int i = cursor; i <= max; i ++) {
78
+            List<Integer> current = last;
79
+            current.add(noteNumList.get(i));
80
+
81
+            if (times == unitNum - 1) {
82
+                out.add(current);
83
+            } else {
84
+                // 每一轮只能取后面的一个位置数据
85
+                recursion(noteNumList, unitNum, times + 1, i + 1, current, out);
86
+            }
87
+        }
88
+    }
89
+}

+ 119
- 0
src/main/java/com/yunzhi/niucai/controller/TaCustomerBettingController.java Ver fichero

@@ -0,0 +1,119 @@
1
+package com.yunzhi.niucai.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.niucai.common.BaseController;
7
+import com.yunzhi.niucai.common.ResponseBean;
8
+import io.swagger.annotations.Api;
9
+import io.swagger.annotations.ApiOperation;
10
+import io.swagger.annotations.ApiParam;
11
+import org.slf4j.Logger;
12
+import org.slf4j.LoggerFactory;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.web.bind.annotation.PathVariable;
15
+import org.springframework.web.bind.annotation.RequestBody;
16
+import org.springframework.web.bind.annotation.RequestMapping;
17
+import org.springframework.web.bind.annotation.RequestMethod;
18
+import org.springframework.web.bind.annotation.RequestParam;
19
+import com.yunzhi.niucai.service.ITaCustomerBettingService;
20
+import com.yunzhi.niucai.entity.TaCustomerBetting;
21
+import org.springframework.web.bind.annotation.RestController;
22
+
23
+/**
24
+ * <p>
25
+    * 客户投注  前端控制器
26
+    * </p>
27
+ *
28
+ * @author yansen
29
+ * @since 2020-09-09
30
+ */
31
+
32
+@Api(tags = "客户投注 ")
33
+@RestController
34
+@RequestMapping("/")
35
+public class TaCustomerBettingController extends BaseController {
36
+
37
+    private final Logger logger = LoggerFactory.getLogger(TaCustomerBettingController.class);
38
+
39
+    @Autowired
40
+    public ITaCustomerBettingService iTaCustomerBettingService;
41
+
42
+//
43
+//    /**
44
+//     * 分页查询列表
45
+//     * @param pageNum
46
+//     * @param pageSize
47
+//     * @return
48
+//     */
49
+//    @RequestMapping(value="/taCustomerBetting",method= RequestMethod.GET)
50
+//    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
+//    public ResponseBean taCustomerBettingList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
+//									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
+//
54
+//		    IPage<TaCustomerBetting> pg = new Page<>(pageNum, pageSize);
55
+//            QueryWrapper<TaCustomerBetting> queryWrapper = new QueryWrapper<>();
56
+//            queryWrapper.orderByDesc("create_date");
57
+//
58
+//            IPage<TaCustomerBetting> result = iTaCustomerBettingService.page(pg, queryWrapper);
59
+//            return ResponseBean.success(result);
60
+//    }
61
+//
62
+//    /**
63
+//     * 保存对象
64
+//     * @param taCustomerBetting 实体对象
65
+//     * @return
66
+//     */
67
+//    @RequestMapping(value="/taCustomerBetting",method= RequestMethod.POST)
68
+//    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
+//    public ResponseBean taCustomerBettingAdd(@ApiParam("保存内容") @RequestBody TaCustomerBetting taCustomerBetting) throws Exception{
70
+//
71
+//        if (iTaCustomerBettingService.save(taCustomerBetting)){
72
+//            return ResponseBean.success(taCustomerBetting);
73
+//        }else {
74
+//            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75
+//        }
76
+//    }
77
+//
78
+//    /**
79
+//     * 根据id删除对象
80
+//     * @param id  实体ID
81
+//     */
82
+//    @RequestMapping(value="/taCustomerBetting/{id}", method= RequestMethod.DELETE)
83
+//    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
+//    public ResponseBean taCustomerBettingDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
+//        if(iTaCustomerBettingService.removeById(id)){
86
+//            return ResponseBean.success("success");
87
+//        }else {
88
+//            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
89
+//        }
90
+//    }
91
+//
92
+//    /**
93
+//     * 修改对象
94
+//     * @param id  实体ID
95
+//     * @param taCustomerBetting 实体对象
96
+//     * @return
97
+//     */
98
+//    @RequestMapping(value="/taCustomerBetting/{id}",method= RequestMethod.PUT)
99
+//    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
+//    public ResponseBean taCustomerBettingUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
+//                                        @ApiParam("更新内容") @RequestBody TaCustomerBetting taCustomerBetting) throws Exception{
102
+//
103
+//        if (iTaCustomerBettingService.updateById(taCustomerBetting)){
104
+//            return ResponseBean.success(iTaCustomerBettingService.getById(id));
105
+//        }else {
106
+//            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
107
+//        }
108
+//    }
109
+//
110
+//    /**
111
+//     * 根据id查询对象
112
+//     * @param id  实体ID
113
+//     */
114
+//    @RequestMapping(value="/taCustomerBetting/{id}",method= RequestMethod.GET)
115
+//    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
+//    public ResponseBean taCustomerBettingGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
+//        return ResponseBean.success(iTaCustomerBettingService.getById(id));
118
+//    }
119
+}

+ 18
- 2
src/main/java/com/yunzhi/niucai/entity/TaBettingPlan.java Ver fichero

@@ -70,9 +70,25 @@ public class TaBettingPlan implements Serializable {
70 70
     private Integer status;
71 71
 
72 72
 
73
-    @ApiModelProperty("总金额: 单位分")
73
+    @ApiModelProperty("总注数")
74 74
     @TableField(exist = false)
75
-    private Integer totalCharges;
75
+    private Integer notesNum;
76
+
77
+    @ApiModelProperty("投注金额: 单位分")
78
+    @TableField(exist = false)
79
+    private Integer totalPrice;
80
+
81
+    @ApiModelProperty("投注店铺")
82
+    @TableField(exist = false)
83
+    private Integer shopId;
84
+
85
+    @ApiModelProperty("投注店铺名称")
86
+    @TableField(exist = false)
87
+    private String shopName;
88
+
89
+    @ApiModelProperty("购彩期数")
90
+    @TableField(exist = false)
91
+    private String issueNo;
76 92
 
77 93
     @ApiModelProperty("方案明细")
78 94
     @TableField(exist = false)

+ 4
- 4
src/main/java/com/yunzhi/niucai/entity/TaBettingPlanItem.java Ver fichero

@@ -52,13 +52,13 @@ public class TaBettingPlanItem implements Serializable {
52 52
     private String matchDate;
53 53
 
54 54
     @ApiModelProperty(value = "主队")
55
-    private String homeTeamId;
55
+    private Integer homeTeamId;
56 56
 
57 57
     @ApiModelProperty(value = "主队名称")
58 58
     private String homeTeamName;
59 59
 
60 60
     @ApiModelProperty(value = "客队")
61
-    private String awayTeamId;
61
+    private Integer awayTeamId;
62 62
 
63 63
     @ApiModelProperty(value = "客队名称")
64 64
     private String awayTeamName;
@@ -97,7 +97,7 @@ public class TaBettingPlanItem implements Serializable {
97 97
     @TableField(exist = false)
98 98
     private Integer charges;
99 99
 
100
-    @ApiModelProperty("赔率明细")
100
+    @ApiModelProperty("体彩明细")
101 101
     @TableField(exist = false)
102
-    private List<TaBettingPlanItemDetail> detailList;
102
+    private List<TaBettingPlanSportDetail> detailList;
103 103
 }

src/main/java/com/yunzhi/niucai/entity/TaBettingPlanItemDetail.java → src/main/java/com/yunzhi/niucai/entity/TaBettingPlanSportDetail.java Ver fichero

@@ -12,17 +12,17 @@ import lombok.experimental.Accessors;
12 12
 
13 13
 /**
14 14
  * <p>
15
- * 方案条目详情
15
+ * 体彩方案玩法明细 
16 16
  * </p>
17 17
  *
18 18
  * @author yansen
19
- * @since 2020-09-08
19
+ * @since 2020-09-09
20 20
  */
21 21
 @Data
22 22
 @EqualsAndHashCode(callSuper = false)
23 23
 @Accessors(chain = true)
24
-@ApiModel(value="TaBettingPlanItemDetail对象", description="方案条目详情")
25
-public class TaBettingPlanItemDetail implements Serializable {
24
+@ApiModel(value="TaBettingPlanSportDetail对象", description="体彩方案玩法明细 ")
25
+public class TaBettingPlanSportDetail implements Serializable {
26 26
 
27 27
     private static final long serialVersionUID = 1L;
28 28
 
@@ -30,38 +30,32 @@ public class TaBettingPlanItemDetail implements Serializable {
30 30
     @TableId(value = "serial_no", type = IdType.AUTO)
31 31
     private Integer serialNo;
32 32
 
33
-    @ApiModelProperty(value = "条目")
34
-    private String itemNo;
35
-
36
-    @ApiModelProperty(value = "方案ID")
37
-    private String planId;
33
+    @ApiModelProperty(value = "条目编号")
34
+    private Integer itemNo;
38 35
 
39 36
     @ApiModelProperty(value = "比赛ID")
40
-    private String matchId;
41
-
42
-    @ApiModelProperty(value = "场次")
43
-    private String matchWeek;
44
-
45
-    @ApiModelProperty(value = "主队")
46
-    private String homeTeamName;
37
+    private Integer matchId;
47 38
 
48
-    @ApiModelProperty(value = "客队")
49
-    private String awayTeamName;
50
-
51
-    @ApiModelProperty(value = "玩法")
39
+    @ApiModelProperty(value = "玩法编码")
52 40
     private String wayCode;
53 41
 
54
-    @ApiModelProperty(value = "结果")
55
-    private String result;
42
+    @ApiModelProperty(value = "玩法名称")
43
+    private String wayName;
56 44
 
57 45
     @ApiModelProperty(value = "赔率")
58
-    private Integer odds;
46
+    private String odds;
47
+
48
+    @ApiModelProperty(value = "赛制编码")
49
+    private String ruleCode;
50
+
51
+    @ApiModelProperty(value = "赛制名称")
52
+    private String ruleName;
59 53
 
60 54
     @ApiModelProperty(value = "创建时间")
61 55
     private LocalDateTime createDate;
62 56
 
63 57
     @ApiModelProperty(value = "状态")
64
-    private Integer status;
58
+    private Boolean status;
65 59
 
66 60
 
67 61
 }

+ 100
- 0
src/main/java/com/yunzhi/niucai/entity/TaCustomerBetting.java Ver fichero

@@ -0,0 +1,100 @@
1
+package com.yunzhi.niucai.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import java.time.LocalDateTime;
6
+import java.io.Serializable;
7
+import io.swagger.annotations.ApiModel;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.Data;
10
+import lombok.EqualsAndHashCode;
11
+import lombok.experimental.Accessors;
12
+
13
+/**
14
+ * <p>
15
+ * 客户投注 
16
+ * </p>
17
+ *
18
+ * @author yansen
19
+ * @since 2020-09-09
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaCustomerBetting对象", description="客户投注 ")
25
+public class TaCustomerBetting implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "投注ID")
30
+    @TableId(value = "betting_id", type = IdType.AUTO)
31
+    private Integer bettingId;
32
+
33
+    @ApiModelProperty(value = "投注人")
34
+    private Integer customerId;
35
+
36
+    @ApiModelProperty(value = "投注人姓名")
37
+    private String customerName;
38
+
39
+    @ApiModelProperty(value = "投注店铺")
40
+    private Integer shopId;
41
+
42
+    @ApiModelProperty(value = "店铺名称")
43
+    private String shopName;
44
+
45
+    @ApiModelProperty(value = "投注方案")
46
+    private Integer planId;
47
+
48
+    @ApiModelProperty(value = "方案简称")
49
+    private String planName;
50
+
51
+    @ApiModelProperty(value = "投注彩种")
52
+    private String lotteryId;
53
+
54
+    @ApiModelProperty(value = "彩种名称")
55
+    private String lotteryName;
56
+
57
+    @ApiModelProperty(value = "投注期数")
58
+    private String issueNo;
59
+
60
+    @ApiModelProperty(value = "投注倍数")
61
+    private Integer bettingTimes;
62
+
63
+    @ApiModelProperty(value = "是否追加")
64
+    private Boolean isAdd;
65
+
66
+    @ApiModelProperty(value = "总注数")
67
+    private Integer notesNum;
68
+
69
+    @ApiModelProperty(value = "投注金额 单位分")
70
+    private Integer totalPrice;
71
+
72
+    @ApiModelProperty(value = "预期收益")
73
+    private String expectedEarning;
74
+
75
+    @ApiModelProperty(value = "是否打单")
76
+    private Boolean isPrinted;
77
+
78
+    @ApiModelProperty(value = "彩票图片")
79
+    private String lotteryPicture;
80
+
81
+    @ApiModelProperty(value = "是否开奖")
82
+    private Boolean isOpen;
83
+
84
+    @ApiModelProperty(value = "是否中奖")
85
+    private Boolean isWinning;
86
+
87
+    @ApiModelProperty(value = "中奖等级")
88
+    private String winLevel;
89
+
90
+    @ApiModelProperty(value = "中奖金额 单位分")
91
+    private Integer winAmount;
92
+
93
+    @ApiModelProperty(value = "投注时间")
94
+    private LocalDateTime createDate;
95
+
96
+    @ApiModelProperty(value = "状态")
97
+    private Boolean status;
98
+
99
+
100
+}

+ 61
- 0
src/main/java/com/yunzhi/niucai/entity/TaCustomerBettingSport.java Ver fichero

@@ -0,0 +1,61 @@
1
+package com.yunzhi.niucai.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import java.time.LocalDateTime;
6
+import java.io.Serializable;
7
+import io.swagger.annotations.ApiModel;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.Data;
10
+import lombok.EqualsAndHashCode;
11
+import lombok.experimental.Accessors;
12
+
13
+/**
14
+ * <p>
15
+ * 客户投注竞彩明细 
16
+ * </p>
17
+ *
18
+ * @author yansen
19
+ * @since 2020-09-09
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaCustomerBettingSport对象", description="客户投注竞彩明细 ")
25
+public class TaCustomerBettingSport implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "序号")
30
+    @TableId(value = "serial_no", type = IdType.AUTO)
31
+    private Integer serialNo;
32
+
33
+    @ApiModelProperty(value = "投注ID")
34
+    private Integer bettingId;
35
+
36
+    @ApiModelProperty(value = "方案条目")
37
+    private Integer itemNo;
38
+
39
+    @ApiModelProperty(value = "方案明细ID")
40
+    private Integer detailNo;
41
+
42
+    @ApiModelProperty(value = "比赛ID")
43
+    private Integer matchId;
44
+
45
+    @ApiModelProperty(value = "赛制编码")
46
+    private String ruleCode;
47
+
48
+    @ApiModelProperty(value = "下单赔率")
49
+    private String oddsOrdered;
50
+
51
+    @ApiModelProperty(value = "打单赔率")
52
+    private String oddsPrinted;
53
+
54
+    @ApiModelProperty(value = "创建时间")
55
+    private LocalDateTime createDate;
56
+
57
+    @ApiModelProperty(value = "状态")
58
+    private Boolean status;
59
+
60
+
61
+}

+ 10
- 0
src/main/java/com/yunzhi/niucai/entity/TdLottery.java Ver fichero

@@ -74,6 +74,16 @@ public class TdLottery implements Serializable {
74 74
      */
75 75
     private Boolean isRepeat;
76 76
 
77
+    /**
78
+     * 前区数字个数
79
+     */
80
+    private Integer firstNums;
81
+
82
+    /**
83
+     * 后区数字个数
84
+     */
85
+    private Integer secondNums;
86
+
77 87
     /**
78 88
      * 是否地方彩
79 89
      */

+ 1
- 1
src/main/java/com/yunzhi/niucai/entity/TdSportPass.java Ver fichero

@@ -48,7 +48,7 @@ public class TdSportPass implements Serializable {
48 48
      * 关数
49 49
      */
50 50
     @ApiModelProperty("关数")
51
-    private String amount;
51
+    private Integer amount;
52 52
 
53 53
     /**
54 54
      * 单场

+ 0
- 18
src/main/java/com/yunzhi/niucai/mapper/TaBettingPlanItemDetailMapper.java Ver fichero

@@ -1,18 +0,0 @@
1
-package com.yunzhi.niucai.mapper;
2
-
3
-import com.yunzhi.niucai.entity.TaBettingPlanItemDetail;
4
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
-import org.apache.ibatis.annotations.Mapper;
6
-
7
-/**
8
- * <p>
9
- * 方案条目详情 Mapper 接口
10
- * </p>
11
- *
12
- * @author yansen
13
- * @since 2020-09-08
14
- */
15
-@Mapper
16
-public interface TaBettingPlanItemDetailMapper extends BaseMapper<TaBettingPlanItemDetail> {
17
-
18
-}

+ 18
- 0
src/main/java/com/yunzhi/niucai/mapper/TaBettingPlanSportDetailMapper.java Ver fichero

@@ -0,0 +1,18 @@
1
+package com.yunzhi.niucai.mapper;
2
+
3
+import com.yunzhi.niucai.entity.TaBettingPlanSportDetail;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 体彩方案玩法明细  Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2020-09-09
14
+ */
15
+@Mapper
16
+public interface TaBettingPlanSportDetailMapper extends BaseMapper<TaBettingPlanSportDetail> {
17
+
18
+}

+ 18
- 0
src/main/java/com/yunzhi/niucai/mapper/TaCustomerBettingMapper.java Ver fichero

@@ -0,0 +1,18 @@
1
+package com.yunzhi.niucai.mapper;
2
+
3
+import com.yunzhi.niucai.entity.TaCustomerBetting;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 客户投注  Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2020-09-09
14
+ */
15
+@Mapper
16
+public interface TaCustomerBettingMapper extends BaseMapper<TaCustomerBetting> {
17
+
18
+}

+ 18
- 0
src/main/java/com/yunzhi/niucai/mapper/TaCustomerBettingSportMapper.java Ver fichero

@@ -0,0 +1,18 @@
1
+package com.yunzhi.niucai.mapper;
2
+
3
+import com.yunzhi.niucai.entity.TaCustomerBettingSport;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 客户投注竞彩明细  Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2020-09-09
14
+ */
15
+@Mapper
16
+public interface TaCustomerBettingSportMapper extends BaseMapper<TaCustomerBettingSport> {
17
+
18
+}

+ 0
- 16
src/main/java/com/yunzhi/niucai/service/ITaBettingPlanItemDetailService.java Ver fichero

@@ -1,16 +0,0 @@
1
-package com.yunzhi.niucai.service;
2
-
3
-import com.yunzhi.niucai.entity.TaBettingPlanItemDetail;
4
-import com.baomidou.mybatisplus.extension.service.IService;
5
-
6
-/**
7
- * <p>
8
- * 方案条目详情 服务类
9
- * </p>
10
- *
11
- * @author yansen
12
- * @since 2020-09-08
13
- */
14
-public interface ITaBettingPlanItemDetailService extends IService<TaBettingPlanItemDetail> {
15
-
16
-}

+ 16
- 0
src/main/java/com/yunzhi/niucai/service/ITaBettingPlanSportDetailService.java Ver fichero

@@ -0,0 +1,16 @@
1
+package com.yunzhi.niucai.service;
2
+
3
+import com.yunzhi.niucai.entity.TaBettingPlanSportDetail;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 体彩方案玩法明细  服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2020-09-09
13
+ */
14
+public interface ITaBettingPlanSportDetailService extends IService<TaBettingPlanSportDetail> {
15
+
16
+}

+ 16
- 0
src/main/java/com/yunzhi/niucai/service/ITaCustomerBettingService.java Ver fichero

@@ -0,0 +1,16 @@
1
+package com.yunzhi.niucai.service;
2
+
3
+import com.yunzhi.niucai.entity.TaCustomerBetting;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 客户投注  服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2020-09-09
13
+ */
14
+public interface ITaCustomerBettingService extends IService<TaCustomerBetting> {
15
+
16
+}

+ 16
- 0
src/main/java/com/yunzhi/niucai/service/ITaCustomerBettingSportService.java Ver fichero

@@ -0,0 +1,16 @@
1
+package com.yunzhi.niucai.service;
2
+
3
+import com.yunzhi.niucai.entity.TaCustomerBettingSport;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 客户投注竞彩明细  服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2020-09-09
13
+ */
14
+public interface ITaCustomerBettingSportService extends IService<TaCustomerBettingSport> {
15
+
16
+}

+ 5
- 0
src/main/java/com/yunzhi/niucai/service/ITaMatchOddsService.java Ver fichero

@@ -3,6 +3,8 @@ package com.yunzhi.niucai.service;
3 3
 import com.yunzhi.niucai.entity.TaMatchOdds;
4 4
 import com.baomidou.mybatisplus.extension.service.IService;
5 5
 
6
+import java.util.Map;
7
+
6 8
 /**
7 9
  * <p>
8 10
  * 赔率 服务类
@@ -13,4 +15,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 15
  */
14 16
 public interface ITaMatchOddsService extends IService<TaMatchOdds> {
15 17
 
18
+    TaMatchOdds getByMatchAndRule(String lotteryId, Integer matchId, String ruleCode) throws Exception;
19
+
20
+    Map<String, TaMatchOdds> getGroupedByRule(Integer matchId) throws Exception;
16 21
 }

+ 5
- 0
src/main/java/com/yunzhi/niucai/service/ITaMatchWayService.java Ver fichero

@@ -3,6 +3,8 @@ package com.yunzhi.niucai.service;
3 3
 import com.yunzhi.niucai.entity.TaMatchWay;
4 4
 import com.baomidou.mybatisplus.extension.service.IService;
5 5
 
6
+import java.util.Map;
7
+
6 8
 /**
7 9
  * <p>
8 10
  * 比赛玩法  服务类
@@ -13,4 +15,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 15
  */
14 16
 public interface ITaMatchWayService extends IService<TaMatchWay> {
15 17
 
18
+    TaMatchWay getByMatchAndWay(String lotteryId, Integer matchId, String wayCode) throws Exception;
19
+
20
+    Map<String, TaMatchWay> getGroupedByWay(Integer matchId) throws Exception;
16 21
 }

+ 0
- 20
src/main/java/com/yunzhi/niucai/service/impl/TaBettingPlanItemDetailServiceImpl.java Ver fichero

@@ -1,20 +0,0 @@
1
-package com.yunzhi.niucai.service.impl;
2
-
3
-import com.yunzhi.niucai.entity.TaBettingPlanItemDetail;
4
-import com.yunzhi.niucai.mapper.TaBettingPlanItemDetailMapper;
5
-import com.yunzhi.niucai.service.ITaBettingPlanItemDetailService;
6
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
-import org.springframework.stereotype.Service;
8
-
9
-/**
10
- * <p>
11
- * 方案条目详情 服务实现类
12
- * </p>
13
- *
14
- * @author yansen
15
- * @since 2020-09-08
16
- */
17
-@Service
18
-public class TaBettingPlanItemDetailServiceImpl extends ServiceImpl<TaBettingPlanItemDetailMapper, TaBettingPlanItemDetail> implements ITaBettingPlanItemDetailService {
19
-
20
-}

+ 183
- 64
src/main/java/com/yunzhi/niucai/service/impl/TaBettingPlanServiceImpl.java Ver fichero

@@ -1,19 +1,19 @@
1 1
 package com.yunzhi.niucai.service.impl;
2 2
 
3
+import com.yunzhi.niucai.common.BizUtils;
3 4
 import com.yunzhi.niucai.common.StringUtils;
4 5
 import com.yunzhi.niucai.entity.*;
5 6
 import com.yunzhi.niucai.enums.SportStatusEnum;
6 7
 import com.yunzhi.niucai.enums.StatusEnum;
7 8
 import com.yunzhi.niucai.mapper.TaBettingPlanMapper;
8
-import com.yunzhi.niucai.service.ITaBettingPlanService;
9
+import com.yunzhi.niucai.service.*;
9 10
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
10
-import com.yunzhi.niucai.service.ITaMatchService;
11
-import com.yunzhi.niucai.service.ITdLotteryService;
12
-import com.yunzhi.niucai.service.ITdSportPassService;
13 11
 import org.springframework.beans.factory.annotation.Autowired;
14 12
 import org.springframework.stereotype.Service;
15 13
 
14
+import java.util.ArrayList;
16 15
 import java.util.List;
16
+import java.util.Map;
17 17
 
18 18
 /**
19 19
  * <p>
@@ -36,10 +36,49 @@ public class TaBettingPlanServiceImpl extends ServiceImpl<TaBettingPlanMapper, T
36 36
     ITaMatchService iTaMatchService;
37 37
 
38 38
     @Autowired
39
-    ITdSportPassService iTdSportPassService;
39
+    ITaMatchWayService iTaMatchWayService;
40
+
41
+    @Autowired
42
+    ITaMatchOddsService iTaMatchOddsService;
43
+
44
+    @Autowired
45
+    ITaShopService iTaShopService;
40 46
 
41 47
     @Override
42 48
     public boolean betting(TaBettingPlan taBettingPlan, TaCustomer customer) throws Exception {
49
+        //
50
+        validateBetting(taBettingPlan);
51
+
52
+        taBettingPlan.setCustomerId(customer.getCustomerId());
53
+        taBettingPlan.setStatus(StatusEnum.READY.getCode());
54
+
55
+        // 入库
56
+
57
+        // 我的
58
+
59
+        // 下单
60
+        return true;
61
+    }
62
+
63
+    private void validateShop(TaBettingPlan taBettingPlan) throws Exception {
64
+        if (null == taBettingPlan.getShopId()) {
65
+            throw new Exception("请选择投注店铺");
66
+        }
67
+
68
+        TaShop taShop = iTaShopService.getById(taBettingPlan.getShopId());
69
+        if (null == taShop) {
70
+            throw new Exception("投注店铺不存在");
71
+        }
72
+
73
+        // 店铺状态不对
74
+        if (!StatusEnum.NORMAL.getCode().equals(taShop.getStatus())) {
75
+            throw new Exception("投注店铺状态异常, 请更换");
76
+        }
77
+
78
+        taBettingPlan.setShopName(taShop.getName());
79
+    }
80
+
81
+    private void validateBetting(TaBettingPlan taBettingPlan) throws Exception {
43 82
         if (null == taBettingPlan.getLotteryId()) {
44 83
             throw new Exception("投注彩种不能未空");
45 84
         }
@@ -48,44 +87,93 @@ public class TaBettingPlanServiceImpl extends ServiceImpl<TaBettingPlanMapper, T
48 87
         if (null == tdLottery) {
49 88
             throw new Exception("投注彩种不合法");
50 89
         }
51
-
90
+        taBettingPlan.setLotteryName(tdLottery.getName());
91
+        taBettingPlan.setIsDigit(tdLottery.getIsSport());
92
+        taBettingPlan.setIsDigit(tdLottery.getIsDigit());
52 93
 
53 94
         // 校验彩种
54 95
         validateLottery(taBettingPlan, tdLottery);
55 96
 
97
+        //
98
+        validateShop(taBettingPlan);
56 99
 
57 100
         // 校验明细
58
-        Integer totalCharges = 0
59 101
         if (null == taBettingPlan.getItemList()) {
60 102
             throw new Exception("请设置投注内容");
61 103
         }
62
-        for (TaBettingPlanItem item : taBettingPlan.getItemList()) {
63
-            if (null == item.getCharges() || 0 == item.getCharges()) {
64
-                throw new Exception("投注内容金额不能为空或者零")
104
+
105
+        // 如果是体彩
106
+        if (tdLottery.getIsSport()) {
107
+            if (StringUtils.isEmpty(taBettingPlan.getPassCode())) {
108
+                throw new Exception("过关方式不能为空");
65 109
             }
66 110
 
67
-            totalCharges += item.getCharges();
111
+            TdSportPass tdSportPass = iTdSportPassService.getById(taBettingPlan.getPassCode());
112
+            if (null == tdSportPass) {
113
+                throw new Exception("过关方式不合法");
114
+            }
115
+            taBettingPlan.setPassName(tdSportPass.getName());
116
+
117
+            List<TaBettingPlanItem> itemList = taBettingPlan.getItemList();
118
+            if (null == itemList || tdSportPass.getUnitNum() > itemList.size()) {
119
+                throw new Exception("投注比赛场次数量不正确");
120
+            }
68 121
 
69
-            // 依据彩种做不同校验
70
-            if (taBettingPlan.getIsSport()) {
122
+            List<Integer> noteNumList = new ArrayList<>();
123
+            for (TaBettingPlanItem item : taBettingPlan.getItemList()) {
71 124
                 validateSport(taBettingPlan, item, tdLottery);
125
+                noteNumList.add(item.getDetailList().size());
72 126
             }
73
-            if (taBettingPlan.getIsDigit()) {
74
-                validateDigit(taBettingPlan, item, tdLottery);
127
+
128
+            // 校验注数
129
+            int totalNums = BizUtils.computeSportNoteNum(tdSportPass.getUnitNum(), tdSportPass.getAmount(), noteNumList);
130
+            if (null == taBettingPlan.getNotesNum() || !taBettingPlan.getNotesNum().equals(totalNums)) {
131
+                throw new Exception("投注总注数计算不正确, 应该为: " + totalNums);
75 132
             }
76
-        }
77 133
 
134
+            // 总金额
135
+            int totalPrice = totalNums * tdLottery.getUnitPrice();
136
+            if (null == taBettingPlan.getTotalPrice() || !taBettingPlan.getTotalPrice().equals(totalPrice)) {
137
+                throw new Exception("投注总金额计算不正确");
138
+            }
78 139
 
79
-        // 校验投注额
80
-        if (null == taBettingPlan.getTotalCharges() || 0 == taBettingPlan.getTotalCharges()) {
81
-            taBettingPlan.setTotalCharges(totalCharges);
82
-        } else if (totalCharges != taBettingPlan.getTotalCharges()) {
83
-            throw new Exception("投注内容总额计算不正确");
140
+            if (totalPrice > tdLottery.getMaxPrice()) {
141
+                throw new Exception("投注总金额不能超过 " + String.format("%.2f", tdLottery.getMaxPrice() / 100 ) + "元");
142
+            }
84 143
         }
85 144
 
86
-        validateLotteryCharges(taBettingPlan, tdLottery);
145
+        // 如果是数字彩
146
+        if (tdLottery.getIsDigit()) {
147
+            Integer totalCharges = 0;
148
+            Integer totalNoteNum = 0;
149
+            for (TaBettingPlanItem item : taBettingPlan.getItemList()) {
150
+                validateDigit(taBettingPlan, item, tdLottery);
151
+                totalCharges += item.getCharges();
152
+                totalNoteNum += item.getAmount();
153
+            }
154
+
155
+            if (null == taBettingPlan.getTotalPrice()) {
156
+                taBettingPlan.setTotalPrice(totalCharges);
157
+            }
158
+            if (null == taBettingPlan.getNotesNum()) {
159
+                taBettingPlan.setNotesNum(totalNoteNum);
160
+            }
161
+
162
+            if (!taBettingPlan.getTotalPrice().equals(totalCharges)) {
163
+                throw new Exception("投注总金额计算不正确");
164
+            }
165
+
166
+            // 不能超过限额
167
+            Integer maxPrice = tdLottery.getMaxPrice();
168
+            if (tdLottery.getIsAdd()) {
169
+                maxPrice = tdLottery.getMaxAddPrice();
170
+            }
171
+            if (maxPrice < totalCharges) {
172
+                throw new Exception("投注总金额不能超过 " + String.format("%.2f", maxPrice / 100 ) + "元");
173
+            }
174
+        }
87 175
 
88
-        return false;
176
+        return;
89 177
     }
90 178
 
91 179
     private void validateLottery(TaBettingPlan taBettingPlan, TdLottery tdLottery) throws Exception {
@@ -97,46 +185,10 @@ public class TaBettingPlanServiceImpl extends ServiceImpl<TaBettingPlanMapper, T
97 185
             throw new Exception("当前投注倍数太大(小), 不能超过" + tdLottery.getMaxTimes());
98 186
         }
99 187
 
100
-        // todo 校验停售时间
101
-
102
-        // 如果是体彩, 校验过关方式
103
-        if (null != tdLottery.getIsSport() && tdLottery.getIsSport()) {
104
-            if (StringUtils.isEmpty(taBettingPlan.getPassCode())) {
105
-                throw new Exception("过关方式不能为空");
106
-            }
107
-
108
-            TdSportPass tdSportPass = iTdSportPassService.getById(taBettingPlan.getPassCode());
109
-            if (null == tdSportPass) {
110
-                throw new Exception("过关方式不合法");
111
-            }
112
-
113
-            List<TaBettingPlanItem> itemList = taBettingPlan.getItemList();
114
-            if (null == itemList || tdSportPass.getUnitNum() > itemList.size()) {
115
-                throw new Exception("投注比赛场次数量不正确");
116
-            }
117
-
118
-            taBettingPlan.setPassName(tdSportPass.getName());
119
-        }
120
-
121
-        // 如果一切正常
122
-        taBettingPlan.setLotteryName(tdLottery.getName());
123
-        taBettingPlan.setIsSport(tdLottery.getIsSport());
124
-    }
125
-
126
-    private void validateLotteryCharges(TaBettingPlan taBettingPlan, TdLottery tdLottery) throws Exception {
188
+        // todo 投注期数
127 189
 
128
-        if (null == taBettingPlan.getTotalCharges()) {
129
-            throw new Exception("请先计算投注总额");
130
-        }
190
+        // todo 校验停售时间
131 191
 
132
-        // 如果是追加
133
-        Integer maxPrice = tdLottery.getMaxPrice()
134
-        if (tdLottery.getIsAdd()) {
135
-            maxPrice = tdLottery.getMaxAddPrice();
136
-        }
137
-        if (maxPrice < taBettingPlan.getTotalCharges()) {
138
-            throw new Exception("当前投注额太大, 不能超过" + String.format("%.2f", maxPrice / 100) + "元");
139
-        }
140 192
     }
141 193
 
142 194
     private void validateSport(TaBettingPlan taBettingPlan,
@@ -145,21 +197,88 @@ public class TaBettingPlanServiceImpl extends ServiceImpl<TaBettingPlanMapper, T
145 197
         // 获取比赛信息
146 198
         TaMatch taMatch = iTaMatchService.getById(taBettingPlanItem.getMatchId());
147 199
         if (null == taMatch) {
148
-            throw new Exception("设置比赛不存在");
200
+            throw new Exception("未投注比赛或者比赛不存在");
149 201
         }
202
+        taBettingPlanItem.setLeagueId(taMatch.getLeagueId());
203
+        taBettingPlanItem.setLeagueName(taMatch.getLeagueName());
204
+        taBettingPlanItem.setMatchWeek(taMatch.getMatchWeek());
205
+        taBettingPlanItem.setMatchDate(taMatch.getMatchDate());
206
+        taBettingPlanItem.setHomeTeamId(taMatch.getHomeTeamId());
207
+        taBettingPlanItem.setHomeTeamName(taMatch.getHomeTeamName());
208
+        taBettingPlanItem.setAwayTeamId(taMatch.getAwayTeamId());
209
+        taBettingPlanItem.setAwayTeamName(taMatch.getAwayTeamName());
150 210
 
151 211
         // 如果当前比赛不是在售
152 212
         if (!SportStatusEnum.SALE.getCode().equals(taMatch.getStatus())) {
213
+            throw new Exception("投注比赛非在售状态");
214
+        }
215
+
216
+        // 投注内容
217
+        if (null == taBettingPlanItem.getDetailList() || taBettingPlanItem.getDetailList().size() == 0) {
218
+            throw new Exception("未找到比赛的投注内容");
219
+        }
220
+
221
+        // 当前比赛玩法
222
+        Map<String, TaMatchWay> taMatchWayMap = iTaMatchWayService.getGroupedByWay(taMatch.getMatchId());
223
+        if (null == taMatchWayMap) {
224
+            throw new Exception("未找到投注比赛玩法设置");
225
+        }
226
+
227
+//        // 当前比赛赔率
228
+//        Map<String, TaMatchOdds> taMatchOddsMap = iTaMatchOddsService.getGroupedByRule(taMatch.getMatchId());
229
+//        if (null == taMatchOddsMap) {
230
+//            throw new Exception("未找到投注比赛赔率设置");
231
+//        }
232
+
233
+        // 单关-过关验证
234
+        boolean isSinglePass = iTdSportPassService.getSinglePassCode().equals(taBettingPlan.getPassCode());
235
+
236
+        // 玩法等验证
237
+        for (TaBettingPlanSportDetail detail: taBettingPlanItem.getDetailList()) {
238
+            detail.setMatchId(taMatch.getMatchId());
153 239
 
240
+            if (StringUtils.isEmpty(detail.getOdds())) {
241
+                throw new Exception("未找到投注比赛明细赔率设置");
242
+            }
243
+
244
+            TaMatchWay taMatchWay = taMatchWayMap.get(detail.getWayCode());
245
+            if (null == taMatchWay) {
246
+                throw new Exception("未找到投注比赛明细玩法设置");
247
+            }
248
+
249
+            if (null == taMatchWay.getIsOn() || !taMatchWay.getIsOn()) {
250
+                throw new Exception("投注比赛明细未开启购彩玩法");
251
+            }
252
+
253
+            if (isSinglePass) {
254
+                if (null == taMatchWay.getIsSingle() || !taMatchWay.getIsSingle()) {
255
+                    throw new Exception("投注比赛明细未开启单关玩法");
256
+                }
257
+            } else {
258
+                if (null == taMatchWay.getIsPass() || !taMatchWay.getIsPass()) {
259
+                    throw new Exception("投注比赛明细未开启过关玩法");
260
+                }
261
+            }
154 262
         }
155 263
 
156
-        // 是否单关
157
-        boolean isSinglePass = iTdSportPassService.getSinglePassCode().equals(taBettingPlan.passCode());
158 264
     }
159 265
 
160 266
     private void validateDigit(TaBettingPlan taBettingPlan,
161 267
                                TaBettingPlanItem taBettingPlanItem,
162 268
                                TdLottery tdLottery) throws Exception {
269
+        if (null == taBettingPlanItem.getAmount() || 0 == taBettingPlanItem.getAmount()) {
270
+            throw new Exception("投注注数不能为空");
271
+        }
272
+
273
+        Integer charges = taBettingPlanItem.getAmount() * tdLottery.getUnitPrice();
274
+        if (null == taBettingPlanItem.getCharges() || 0 == taBettingPlanItem.getCharges()) {
275
+            taBettingPlanItem.setCharges(charges);
276
+        }
277
+
278
+        if (!charges.equals(taBettingPlanItem.getCharges())) {
279
+            throw new Exception("投注金额不正确");
280
+        }
163 281
 
282
+        return;
164 283
     }
165 284
 }

+ 20
- 0
src/main/java/com/yunzhi/niucai/service/impl/TaBettingPlanSportDetailServiceImpl.java Ver fichero

@@ -0,0 +1,20 @@
1
+package com.yunzhi.niucai.service.impl;
2
+
3
+import com.yunzhi.niucai.entity.TaBettingPlanSportDetail;
4
+import com.yunzhi.niucai.mapper.TaBettingPlanSportDetailMapper;
5
+import com.yunzhi.niucai.service.ITaBettingPlanSportDetailService;
6
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import org.springframework.stereotype.Service;
8
+
9
+/**
10
+ * <p>
11
+ * 体彩方案玩法明细  服务实现类
12
+ * </p>
13
+ *
14
+ * @author yansen
15
+ * @since 2020-09-09
16
+ */
17
+@Service
18
+public class TaBettingPlanSportDetailServiceImpl extends ServiceImpl<TaBettingPlanSportDetailMapper, TaBettingPlanSportDetail> implements ITaBettingPlanSportDetailService {
19
+
20
+}

+ 20
- 0
src/main/java/com/yunzhi/niucai/service/impl/TaCustomerBettingServiceImpl.java Ver fichero

@@ -0,0 +1,20 @@
1
+package com.yunzhi.niucai.service.impl;
2
+
3
+import com.yunzhi.niucai.entity.TaCustomerBetting;
4
+import com.yunzhi.niucai.mapper.TaCustomerBettingMapper;
5
+import com.yunzhi.niucai.service.ITaCustomerBettingService;
6
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import org.springframework.stereotype.Service;
8
+
9
+/**
10
+ * <p>
11
+ * 客户投注  服务实现类
12
+ * </p>
13
+ *
14
+ * @author yansen
15
+ * @since 2020-09-09
16
+ */
17
+@Service
18
+public class TaCustomerBettingServiceImpl extends ServiceImpl<TaCustomerBettingMapper, TaCustomerBetting> implements ITaCustomerBettingService {
19
+
20
+}

+ 20
- 0
src/main/java/com/yunzhi/niucai/service/impl/TaCustomerBettingSportServiceImpl.java Ver fichero

@@ -0,0 +1,20 @@
1
+package com.yunzhi.niucai.service.impl;
2
+
3
+import com.yunzhi.niucai.entity.TaCustomerBettingSport;
4
+import com.yunzhi.niucai.mapper.TaCustomerBettingSportMapper;
5
+import com.yunzhi.niucai.service.ITaCustomerBettingSportService;
6
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import org.springframework.stereotype.Service;
8
+
9
+/**
10
+ * <p>
11
+ * 客户投注竞彩明细  服务实现类
12
+ * </p>
13
+ *
14
+ * @author yansen
15
+ * @since 2020-09-09
16
+ */
17
+@Service
18
+public class TaCustomerBettingSportServiceImpl extends ServiceImpl<TaCustomerBettingSportMapper, TaCustomerBettingSport> implements ITaCustomerBettingSportService {
19
+
20
+}

+ 32
- 0
src/main/java/com/yunzhi/niucai/service/impl/TaMatchOddsServiceImpl.java Ver fichero

@@ -1,11 +1,16 @@
1 1
 package com.yunzhi.niucai.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3 4
 import com.yunzhi.niucai.entity.TaMatchOdds;
4 5
 import com.yunzhi.niucai.mapper.TaMatchOddsMapper;
5 6
 import com.yunzhi.niucai.service.ITaMatchOddsService;
6 7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 8
 import org.springframework.stereotype.Service;
8 9
 
10
+import java.util.HashMap;
11
+import java.util.List;
12
+import java.util.Map;
13
+
9 14
 /**
10 15
  * <p>
11 16
  * 赔率 服务实现类
@@ -17,4 +22,31 @@ import org.springframework.stereotype.Service;
17 22
 @Service
18 23
 public class TaMatchOddsServiceImpl extends ServiceImpl<TaMatchOddsMapper, TaMatchOdds> implements ITaMatchOddsService {
19 24
 
25
+    @Override
26
+    public TaMatchOdds getByMatchAndRule(String lotteryId, Integer matchId, String ruleCode) throws Exception {
27
+        QueryWrapper<TaMatchOdds> queryWrapper = new QueryWrapper<>();
28
+        queryWrapper.eq("lottery_id", lotteryId);
29
+        queryWrapper.eq("match_id", matchId);
30
+        queryWrapper.eq("rule_code", ruleCode);
31
+        queryWrapper.last("limit 1");
32
+
33
+        return getOne(queryWrapper);
34
+    }
35
+
36
+    @Override
37
+    public Map<String, TaMatchOdds> getGroupedByRule(Integer matchId) throws Exception {
38
+        QueryWrapper<TaMatchOdds> queryWrapper = new QueryWrapper<>();
39
+        queryWrapper.eq("match_id", matchId);
40
+
41
+        List<TaMatchOdds> list = list(queryWrapper);
42
+        if (null == list || list.size() == 0) {
43
+            return null;
44
+        }
45
+
46
+        Map<String, TaMatchOdds> res = new HashMap<>();
47
+        for (TaMatchOdds taMatchOdds: list) {
48
+            res.put(taMatchOdds.getRuleCode(), taMatchOdds);
49
+        }
50
+        return res;
51
+    }
20 52
 }

+ 36
- 0
src/main/java/com/yunzhi/niucai/service/impl/TaMatchWayServiceImpl.java Ver fichero

@@ -1,11 +1,17 @@
1 1
 package com.yunzhi.niucai.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3 4
 import com.yunzhi.niucai.entity.TaMatchWay;
5
+import com.yunzhi.niucai.enums.StatusEnum;
4 6
 import com.yunzhi.niucai.mapper.TaMatchWayMapper;
5 7
 import com.yunzhi.niucai.service.ITaMatchWayService;
6 8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 9
 import org.springframework.stereotype.Service;
8 10
 
11
+import java.util.HashMap;
12
+import java.util.List;
13
+import java.util.Map;
14
+
9 15
 /**
10 16
  * <p>
11 17
  * 比赛玩法  服务实现类
@@ -17,4 +23,34 @@ import org.springframework.stereotype.Service;
17 23
 @Service
18 24
 public class TaMatchWayServiceImpl extends ServiceImpl<TaMatchWayMapper, TaMatchWay> implements ITaMatchWayService {
19 25
 
26
+    @Override
27
+    public TaMatchWay getByMatchAndWay(String lotteryId, Integer matchId, String wayCode) throws Exception {
28
+        QueryWrapper<TaMatchWay> queryWrapper = new QueryWrapper<>();
29
+        queryWrapper.eq("lottery_id", lotteryId);
30
+        queryWrapper.eq("match_id", matchId);
31
+        queryWrapper.eq("way_code", wayCode);
32
+        queryWrapper.eq("status", StatusEnum.NORMAL.getCode());
33
+        queryWrapper.last("limit 1");
34
+
35
+        return getOne(queryWrapper);
36
+    }
37
+
38
+    @Override
39
+    public Map<String, TaMatchWay> getGroupedByWay(Integer matchId) throws Exception {
40
+        QueryWrapper<TaMatchWay> queryWrapper = new QueryWrapper<>();
41
+        queryWrapper.eq("match_id", matchId);
42
+        queryWrapper.eq("status", StatusEnum.NORMAL.getCode());
43
+//        queryWrapper.orderByAsc("way_code");
44
+
45
+        List<TaMatchWay> list = list(queryWrapper);
46
+        if (null == list || list.size() == 0) {
47
+            return null;
48
+        }
49
+
50
+        Map<String, TaMatchWay> res = new HashMap<>();
51
+        for (TaMatchWay taMatchWay: list) {
52
+            res.put(taMatchWay.getWayCode(), taMatchWay);
53
+        }
54
+        return res;
55
+    }
20 56
 }

+ 5
- 0
src/main/resources/mapper/TaBettingPlanSportDetailMapper.xml Ver fichero

@@ -0,0 +1,5 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.yunzhi.niucai.mapper.TaBettingPlanSportDetailMapper">
4
+
5
+</mapper>

src/main/resources/mapper/TaBettingPlanItemDetailMapper.xml → src/main/resources/mapper/TaCustomerBettingMapper.xml Ver fichero

@@ -1,5 +1,5 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
-<mapper namespace="com.yunzhi.niucai.mapper.TaBettingPlanItemDetailMapper">
3
+<mapper namespace="com.yunzhi.niucai.mapper.TaCustomerBettingMapper">
4 4
 
5 5
 </mapper>

+ 5
- 0
src/main/resources/mapper/TaCustomerBettingSportMapper.xml Ver fichero

@@ -0,0 +1,5 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.yunzhi.niucai.mapper.TaCustomerBettingSportMapper">
4
+
5
+</mapper>