张延森 4 vuotta sitten
vanhempi
commit
ceab7caeb7
20 muutettua tiedostoa jossa 881 lisäystä ja 54 poistoa
  1. 87
    0
      src/main/java/com/yunzhi/niucai/common/ArrayUtils.java
  2. 65
    4
      src/main/java/com/yunzhi/niucai/common/BizUtils.java
  3. 7
    0
      src/main/java/com/yunzhi/niucai/entity/TaCustomerBetting.java
  4. 61
    0
      src/main/java/com/yunzhi/niucai/entity/TaCustomerBettingItem.java
  5. 5
    1
      src/main/java/com/yunzhi/niucai/entity/TaLotteryResult.java
  6. 58
    0
      src/main/java/com/yunzhi/niucai/entity/TaLotteryResultDetail.java
  7. 3
    0
      src/main/java/com/yunzhi/niucai/entity/TdLotteryPrize.java
  8. 18
    0
      src/main/java/com/yunzhi/niucai/mapper/TaCustomerBettingItemMapper.java
  9. 18
    0
      src/main/java/com/yunzhi/niucai/mapper/TaLotteryResultDetailMapper.java
  10. 16
    0
      src/main/java/com/yunzhi/niucai/service/ITaCustomerBettingItemService.java
  11. 16
    0
      src/main/java/com/yunzhi/niucai/service/ITaLotteryResultDetailService.java
  12. 2
    0
      src/main/java/com/yunzhi/niucai/service/ITaLotteryResultService.java
  13. 4
    0
      src/main/java/com/yunzhi/niucai/service/ITdLotteryPrizeService.java
  14. 20
    0
      src/main/java/com/yunzhi/niucai/service/impl/TaCustomerBettingItemServiceImpl.java
  15. 29
    5
      src/main/java/com/yunzhi/niucai/service/impl/TaCustomerBettingServiceImpl.java
  16. 20
    0
      src/main/java/com/yunzhi/niucai/service/impl/TaLotteryResultDetailServiceImpl.java
  17. 428
    44
      src/main/java/com/yunzhi/niucai/service/impl/TaLotteryResultServiceImpl.java
  18. 14
    0
      src/main/java/com/yunzhi/niucai/service/impl/TdLotteryPrizeServiceImpl.java
  19. 5
    0
      src/main/resources/mapper/TaCustomerBettingItemMapper.xml
  20. 5
    0
      src/main/resources/mapper/TaLotteryResultDetailMapper.xml

+ 87
- 0
src/main/java/com/yunzhi/niucai/common/ArrayUtils.java Näytä tiedosto

@@ -1,4 +1,91 @@
1 1
 package com.yunzhi.niucai.common;
2 2
 
3
+
4
+import java.util.Arrays;
5
+
3 6
 public class ArrayUtils {
7
+
8
+    /**
9
+     * 抽取 数组 中指定部分内容, 返回新数组
10
+     * @param src
11
+     * @param start
12
+     * @param end
13
+     * @param <T>
14
+     * @return
15
+     */
16
+    public static <T> T[] slice(T[] src, int start, int ... end) {
17
+        if (null == src) {
18
+            return null;
19
+        }
20
+
21
+        int from = start;
22
+        int to = -1;
23
+        if (end.length == 0) {
24
+            to = src.length;
25
+        } else {
26
+            to = end[0];
27
+        }
28
+
29
+        if (from < 0) {
30
+            from = 0;
31
+        }
32
+
33
+        if (from > src.length) {
34
+            from = src.length;
35
+        }
36
+
37
+        if (from > to) {
38
+            from = 0;
39
+            to = 0;
40
+        }
41
+
42
+        return Arrays.copyOfRange(src, from, to);
43
+    }
44
+
45
+    /**
46
+     * 合并两个数组, 返回新数组
47
+     * @param a1
48
+     * @param a2
49
+     * @param <T>
50
+     * @return
51
+     */
52
+    public static <T> T[] join(T[] a1, T[] a2) {
53
+        if (a1 == null && a2 == null) {
54
+            return null;
55
+        }
56
+
57
+        if (a1 == null) {
58
+            return slice(a2, 0);
59
+        }
60
+
61
+        if (a2 == null) {
62
+            return slice(a1, 0);
63
+        }
64
+
65
+        T[] res = Arrays.copyOf(a1, a1.length + a2.length);
66
+        System.arraycopy(a2, 0, res, a1.length, a2.length);
67
+        return res;
68
+    }
69
+
70
+    /**
71
+     * 从数组指定位置删除一个元素, 返回新数组
72
+     * @param src
73
+     * @param index
74
+     * @param <T>
75
+     * @return
76
+     */
77
+    public static <T> T[] omit(T[] src, int index) {
78
+        return join(slice(src, 0, index), slice(src,index + 1));
79
+    }
80
+
81
+    /**
82
+     * indexOf
83
+     * @param src
84
+     * @param search
85
+     * @param <T>
86
+     * @return
87
+     */
88
+    public static <T> int indexOf(T[] src, T search) {
89
+        return Arrays.asList(src).indexOf(search);
90
+    }
4 91
 }

+ 65
- 4
src/main/java/com/yunzhi/niucai/common/BizUtils.java Näytä tiedosto

@@ -3,6 +3,7 @@ package com.yunzhi.niucai.common;
3 3
 import io.swagger.models.auth.In;
4 4
 
5 5
 import java.util.ArrayList;
6
+import java.util.Arrays;
6 7
 import java.util.List;
7 8
 
8 9
 /**
@@ -113,15 +114,75 @@ public class BizUtils {
113 114
         return EncryptUtils.combination(leftSize, canUse);
114 115
     }
115 116
 
116
-    public static int getSameNums(List<String> tar, List<String> src, List<String> dan) {
117
-        if (null == tar || tar.size() == 0) {
117
+    /**
118
+     * 获取相同号码数量
119
+     * @param tar 对比目标
120
+     * @param src 数据源
121
+     * @param dan 胆拖数据
122
+     * @return
123
+     */
124
+    public static int getSameNums(String[] tar, String[] src, String[] dan) {
125
+        if (null == tar || tar.length == 0) {
118 126
             return 0;
119 127
         }
120 128
 
121
-        if (null == src && src.size() == 0) {
129
+        if (null == src && src.length == 0) {
122 130
             return 0;
123 131
         }
124 132
 
125
-        return 0;
133
+        String[] tarArr = ArrayUtils.slice(tar, 0);
134
+        String[] srcArr = ArrayUtils.slice(src, 0);
135
+        String[] danArr = null == dan ? new String[0] : ArrayUtils.slice(dan, 0);
136
+
137
+        int danNum = 0;
138
+        int maxSrcNum = tarArr.length - danArr.length;
139
+        int srcNum = 0;
140
+
141
+        for (String t : tarArr) {
142
+            int danInx = ArrayUtils.indexOf(danArr, t);
143
+            if (danInx > -1) {
144
+                danNum += 1;
145
+                danArr = ArrayUtils.omit(danArr, danInx);
146
+                continue;
147
+            }
148
+
149
+            int srcInx = ArrayUtils.indexOf(srcArr, t);
150
+            if (srcInx > -1) {
151
+                srcNum += 1;
152
+                srcArr = ArrayUtils.omit(srcArr, srcInx);
153
+            }
154
+        }
155
+
156
+        if (srcNum > maxSrcNum) {
157
+            srcNum = maxSrcNum;
158
+        }
159
+
160
+        return srcNum + danNum;
161
+    }
162
+
163
+    /**
164
+     * 校验是否中奖, 目前只有 排列三直选, 排列五 用到
165
+     * @param tar
166
+     * @param src
167
+     * @return
168
+     */
169
+    public static boolean checkPrizeNumStrict(String[] tar, String[] src) {
170
+        if (null == tar || tar.length == 0 || null == src || src.length == 0) {
171
+            return false;
172
+        }
173
+
174
+        if (tar.length != src.length) {
175
+            return false;
176
+        }
177
+
178
+        for (int i = 0; i < tar.length; i++) {
179
+            String num = tar[i];
180
+            String[] srcList = src[i].split(" ");
181
+            if (!Arrays.asList(srcList).contains(num)) {
182
+                return false;
183
+            }
184
+        }
185
+
186
+        return true;
126 187
     }
127 188
 }

+ 7
- 0
src/main/java/com/yunzhi/niucai/entity/TaCustomerBetting.java Näytä tiedosto

@@ -96,12 +96,19 @@ public class TaCustomerBetting implements Serializable {
96 96
     @ApiModelProperty(value = "中奖金额 单位分")
97 97
     private Integer winAmount;
98 98
 
99
+    @ApiModelProperty(value = "是否派奖")
100
+    private Boolean isCashed;
101
+
99 102
     @ApiModelProperty(value = "投注时间")
100 103
     private LocalDateTime createDate;
101 104
 
102 105
     @ApiModelProperty(value = "状态")
103 106
     private Integer status;
104 107
 
108
+    @ApiModelProperty(value = "投注明细")
109
+    @TableField(exist = false)
110
+    List<TaCustomerBettingItem> itemList;
111
+
105 112
     @ApiModelProperty(value = "体彩相关明细")
106 113
     @TableField(exist = false)
107 114
     List<TaCustomerBettingSport> bettingSports;

+ 61
- 0
src/main/java/com/yunzhi/niucai/entity/TaCustomerBettingItem.java Näytä tiedosto

@@ -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-14
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaCustomerBettingItem对象", description="客户投注明细 ")
25
+public class TaCustomerBettingItem implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "明细ID")
30
+    @TableId(value = "item_no", type = IdType.AUTO)
31
+    private Integer itemNo;
32
+
33
+    @ApiModelProperty(value = "投注ID")
34
+    private Integer bettingId;
35
+
36
+    @ApiModelProperty(value = "对应方案明细")
37
+    private Integer planItemNo;
38
+
39
+    @ApiModelProperty(value = "是否开奖")
40
+    private Boolean isOpen;
41
+
42
+    @ApiModelProperty(value = "开奖日期")
43
+    private String openingDate;
44
+
45
+    @ApiModelProperty(value = "是否中奖")
46
+    private Boolean isWinning;
47
+
48
+    @ApiModelProperty(value = "中奖等级")
49
+    private String winLevel;
50
+
51
+    @ApiModelProperty(value = "中奖金额 单位分")
52
+    private Integer winAmount;
53
+
54
+    @ApiModelProperty(value = "创建时间")
55
+    private LocalDateTime createDate;
56
+
57
+    @ApiModelProperty(value = "状态")
58
+    private Integer status;
59
+
60
+
61
+}

+ 5
- 1
src/main/java/com/yunzhi/niucai/entity/TaLotteryResult.java Näytä tiedosto

@@ -1,9 +1,11 @@
1 1
 package com.yunzhi.niucai.entity;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
4 5
 import com.baomidou.mybatisplus.annotation.TableId;
5 6
 import java.time.LocalDateTime;
6 7
 import java.io.Serializable;
8
+import java.util.List;
7 9
 
8 10
 import io.swagger.annotations.ApiModel;
9 11
 import io.swagger.annotations.ApiModelProperty;
@@ -89,5 +91,7 @@ public class TaLotteryResult implements Serializable {
89 91
     @ApiModelProperty("状态")
90 92
     private Integer status;
91 93
 
92
-
94
+    @ApiModelProperty("结果明细")
95
+    @TableField(exist = false)
96
+    List<TaLotteryResultDetail> detailList;
93 97
 }

+ 58
- 0
src/main/java/com/yunzhi/niucai/entity/TaLotteryResultDetail.java Näytä tiedosto

@@ -0,0 +1,58 @@
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-14
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaLotteryResultDetail对象", description="数字彩开奖明细 ")
25
+public class TaLotteryResultDetail 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 resultNo;
35
+
36
+    @ApiModelProperty(value = "等级")
37
+    private String level;
38
+
39
+    @ApiModelProperty(value = "注数")
40
+    private String piece;
41
+
42
+    @ApiModelProperty(value = "单注奖金")
43
+    private String money;
44
+
45
+    @ApiModelProperty(value = "追加注数")
46
+    private String xPiece;
47
+
48
+    @ApiModelProperty(value = "追加奖金")
49
+    private String xMoney;
50
+
51
+    @ApiModelProperty(value = "创建时间")
52
+    private LocalDateTime createDate;
53
+
54
+    @ApiModelProperty(value = "状态")
55
+    private Boolean status;
56
+
57
+
58
+}

+ 3
- 0
src/main/java/com/yunzhi/niucai/entity/TdLotteryPrize.java Näytä tiedosto

@@ -38,6 +38,9 @@ public class TdLotteryPrize implements Serializable {
38 38
     @ApiModelProperty(value = "玩法")
39 39
     private String playWay;
40 40
 
41
+    @ApiModelProperty(value = "数字彩中奖规则")
42
+    private String bingoRule;
43
+
41 44
     @ApiModelProperty(value = "场次")
42 45
     private Boolean round;
43 46
 

+ 18
- 0
src/main/java/com/yunzhi/niucai/mapper/TaCustomerBettingItemMapper.java Näytä tiedosto

@@ -0,0 +1,18 @@
1
+package com.yunzhi.niucai.mapper;
2
+
3
+import com.yunzhi.niucai.entity.TaCustomerBettingItem;
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-14
14
+ */
15
+@Mapper
16
+public interface TaCustomerBettingItemMapper extends BaseMapper<TaCustomerBettingItem> {
17
+
18
+}

+ 18
- 0
src/main/java/com/yunzhi/niucai/mapper/TaLotteryResultDetailMapper.java Näytä tiedosto

@@ -0,0 +1,18 @@
1
+package com.yunzhi.niucai.mapper;
2
+
3
+import com.yunzhi.niucai.entity.TaLotteryResultDetail;
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-14
14
+ */
15
+@Mapper
16
+public interface TaLotteryResultDetailMapper extends BaseMapper<TaLotteryResultDetail> {
17
+
18
+}

+ 16
- 0
src/main/java/com/yunzhi/niucai/service/ITaCustomerBettingItemService.java Näytä tiedosto

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

+ 16
- 0
src/main/java/com/yunzhi/niucai/service/ITaLotteryResultDetailService.java Näytä tiedosto

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

+ 2
- 0
src/main/java/com/yunzhi/niucai/service/ITaLotteryResultService.java Näytä tiedosto

@@ -19,4 +19,6 @@ public interface ITaLotteryResultService extends IService<TaLotteryResult> {
19 19
     List<TaLotteryResult> getLastResult() throws Exception;
20 20
 
21 21
     TaLotteryResult getLastResultByLottery(TdLottery tdLottery) throws Exception;
22
+
23
+    TaLotteryResult getResultBy(TdLottery lottery, String today) throws Exception;
22 24
 }

+ 4
- 0
src/main/java/com/yunzhi/niucai/service/ITdLotteryPrizeService.java Näytä tiedosto

@@ -1,8 +1,11 @@
1 1
 package com.yunzhi.niucai.service;
2 2
 
3
+import com.yunzhi.niucai.entity.TdLottery;
3 4
 import com.yunzhi.niucai.entity.TdLotteryPrize;
4 5
 import com.baomidou.mybatisplus.extension.service.IService;
5 6
 
7
+import java.util.List;
8
+
6 9
 /**
7 10
  * <p>
8 11
  * 彩种中奖设置  服务类
@@ -13,4 +16,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 16
  */
14 17
 public interface ITdLotteryPrizeService extends IService<TdLotteryPrize> {
15 18
 
19
+    List<TdLotteryPrize> getByLottery(TdLottery lottery) throws Exception;
16 20
 }

+ 20
- 0
src/main/java/com/yunzhi/niucai/service/impl/TaCustomerBettingItemServiceImpl.java Näytä tiedosto

@@ -0,0 +1,20 @@
1
+package com.yunzhi.niucai.service.impl;
2
+
3
+import com.yunzhi.niucai.entity.TaCustomerBettingItem;
4
+import com.yunzhi.niucai.mapper.TaCustomerBettingItemMapper;
5
+import com.yunzhi.niucai.service.ITaCustomerBettingItemService;
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-14
16
+ */
17
+@Service
18
+public class TaCustomerBettingItemServiceImpl extends ServiceImpl<TaCustomerBettingItemMapper, TaCustomerBettingItem> implements ITaCustomerBettingItemService {
19
+
20
+}

+ 29
- 5
src/main/java/com/yunzhi/niucai/service/impl/TaCustomerBettingServiceImpl.java Näytä tiedosto

@@ -3,6 +3,7 @@ package com.yunzhi.niucai.service.impl;
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.yunzhi.niucai.entity.*;
5 5
 import com.yunzhi.niucai.enums.StatusEnum;
6
+import com.yunzhi.niucai.mapper.TaCustomerBettingItemMapper;
6 7
 import com.yunzhi.niucai.mapper.TaCustomerBettingMapper;
7 8
 import com.yunzhi.niucai.mapper.TaCustomerBettingSportMapper;
8 9
 import com.yunzhi.niucai.service.ITaBettingPlanService;
@@ -30,6 +31,9 @@ public class TaCustomerBettingServiceImpl extends ServiceImpl<TaCustomerBettingM
30 31
     @Autowired
31 32
     ITaBettingPlanService iTaBettingPlanService;
32 33
 
34
+    @Autowired
35
+    TaCustomerBettingItemMapper taCustomerBettingItemMapper;
36
+
33 37
     @Autowired
34 38
     TaCustomerBettingSportMapper taCustomerBettingSportMapper;
35 39
 
@@ -63,11 +67,20 @@ public class TaCustomerBettingServiceImpl extends ServiceImpl<TaCustomerBettingM
63 67
 
64 68
         if (null != plan.getItemList()) {
65 69
             for (TaBettingPlanItem item: plan.getItemList()) {
70
+                TaCustomerBettingItem bettingItem = new TaCustomerBettingItem();
71
+                bettingItem.setBettingId(taCustomerBetting.getBettingId());
72
+                bettingItem.setPlanItemNo(item.getItemNo());
73
+                bettingItem.setStatus(StatusEnum.NORMAL.getCode());
74
+
75
+                if (taCustomerBettingItemMapper.insert(bettingItem) < 1) {
76
+                    throw new Exception("生成我的投注明细失败");
77
+                }
78
+
66 79
                 if (null != item.getDetailList()) {
67 80
                     for (TaBettingPlanSportDetail detail: item.getDetailList()) {
68 81
                         TaCustomerBettingSport bettingSport = new TaCustomerBettingSport();
69 82
                         bettingSport.setBettingId(taCustomerBetting.getBettingId());
70
-                        bettingSport.setItemNo(item.getItemNo());
83
+                        bettingSport.setItemNo(bettingItem.getItemNo());
71 84
                         bettingSport.setDetailNo(detail.getSerialNo());
72 85
                         bettingSport.setMatchId(item.getMatchId());
73 86
                         bettingSport.setRuleCode(detail.getRuleCode());
@@ -92,9 +105,11 @@ public class TaCustomerBettingServiceImpl extends ServiceImpl<TaCustomerBettingM
92 105
             throw new Exception("数据不存在, 投注ID不正确");
93 106
         }
94 107
 
95
-        // 查询明细
96
-        List<TaCustomerBettingSport> bettingSports = getBettingSportByBetting(betting);
97
-        betting.setBettingSports(bettingSports);
108
+        // 投注明细
109
+        betting.setItemList(getBettingItemByBetting(betting));
110
+
111
+        // 竞彩明细
112
+        betting.setBettingSports(getBettingSportByBetting(betting));
98 113
 
99 114
         // 查询方案
100 115
         TaBettingPlan taBettingPlan = iTaBettingPlanService.getDetailOfPlanById(betting.getPlanId());
@@ -120,7 +135,7 @@ public class TaCustomerBettingServiceImpl extends ServiceImpl<TaCustomerBettingM
120 135
                 if (lottery.getIsSport()) {
121 136
                     betting.setBettingSports(getBettingSportByBetting(betting));
122 137
                 }
123
-
138
+                betting.setItemList(getBettingItemByBetting(betting));
124 139
                 betting.setBettingPlan(iTaBettingPlanService.getDetailOfPlanById(betting.getPlanId()));
125 140
             }
126 141
         }
@@ -136,4 +151,13 @@ public class TaCustomerBettingServiceImpl extends ServiceImpl<TaCustomerBettingM
136 151
 
137 152
         return taCustomerBettingSportMapper.selectList(queryWrapper);
138 153
     }
154
+
155
+    private List<TaCustomerBettingItem> getBettingItemByBetting(TaCustomerBetting betting) throws Exception {
156
+        QueryWrapper<TaCustomerBettingItem> queryWrapper = new QueryWrapper<>();
157
+        queryWrapper.eq("betting_id", betting.getBettingId());
158
+        queryWrapper.eq("status", StatusEnum.NORMAL.getCode());
159
+        queryWrapper.orderByAsc("serial_no");
160
+
161
+        return taCustomerBettingItemMapper.selectList(queryWrapper);
162
+    }
139 163
 }

+ 20
- 0
src/main/java/com/yunzhi/niucai/service/impl/TaLotteryResultDetailServiceImpl.java Näytä tiedosto

@@ -0,0 +1,20 @@
1
+package com.yunzhi.niucai.service.impl;
2
+
3
+import com.yunzhi.niucai.entity.TaLotteryResultDetail;
4
+import com.yunzhi.niucai.mapper.TaLotteryResultDetailMapper;
5
+import com.yunzhi.niucai.service.ITaLotteryResultDetailService;
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-14
16
+ */
17
+@Service
18
+public class TaLotteryResultDetailServiceImpl extends ServiceImpl<TaLotteryResultDetailMapper, TaLotteryResultDetail> implements ITaLotteryResultDetailService {
19
+
20
+}

+ 428
- 44
src/main/java/com/yunzhi/niucai/service/impl/TaLotteryResultServiceImpl.java Näytä tiedosto

@@ -1,15 +1,16 @@
1 1
 package com.yunzhi.niucai.service.impl;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.yunzhi.niucai.common.BizUtils;
4 5
 import com.yunzhi.niucai.common.CommConstants;
6
+import com.yunzhi.niucai.common.DateUtils;
7
+import com.yunzhi.niucai.common.StringUtils;
5 8
 import com.yunzhi.niucai.entity.*;
6 9
 import com.yunzhi.niucai.enums.StatusEnum;
10
+import com.yunzhi.niucai.mapper.TaLotteryResultDetailMapper;
7 11
 import com.yunzhi.niucai.mapper.TaLotteryResultMapper;
8
-import com.yunzhi.niucai.service.ITaCustomerBettingService;
9
-import com.yunzhi.niucai.service.ITaLotteryResultService;
12
+import com.yunzhi.niucai.service.*;
10 13
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
11
-import com.yunzhi.niucai.service.ITdLotteryOnSaleService;
12
-import com.yunzhi.niucai.service.ITdLotteryService;
13 14
 import lombok.extern.slf4j.Slf4j;
14 15
 import org.springframework.beans.factory.annotation.Autowired;
15 16
 import org.springframework.stereotype.Service;
@@ -39,9 +40,18 @@ public class TaLotteryResultServiceImpl extends ServiceImpl<TaLotteryResultMappe
39 40
     @Autowired
40 41
     ITaCustomerBettingService iTaCustomerBettingService;
41 42
 
43
+    @Autowired
44
+    ITaCustomerBettingItemService iTaCustomerBettingItemService;
45
+
46
+    @Autowired
47
+    ITdLotteryPrizeService iTdLotteryPrizeService;
48
+
42 49
     @Autowired
43 50
     TaLotteryResultMapper taLotteryResultMapper;
44 51
 
52
+    @Autowired
53
+    TaLotteryResultDetailMapper taLotteryResultDetailMapper;
54
+
45 55
     @Override
46 56
     public List<TaLotteryResult> getLastResult() throws Exception {
47 57
         return taLotteryResultMapper.getLastResult();
@@ -58,6 +68,11 @@ public class TaLotteryResultServiceImpl extends ServiceImpl<TaLotteryResultMappe
58 68
         return getOne(queryWrapper);
59 69
     }
60 70
 
71
+    @Override
72
+    public TaLotteryResult getResultBy(TdLottery lottery, String today) throws Exception {
73
+        return null;
74
+    }
75
+
61 76
     /**
62 77
      * 校验客户是否中奖, 如果中奖,则进行中奖相关更新
63 78
      * @throws Exception
@@ -68,7 +83,7 @@ public class TaLotteryResultServiceImpl extends ServiceImpl<TaLotteryResultMappe
68 83
         int weekDay = now.getDayOfWeek().getValue();
69 84
         List<TdLotteryOnSale> onSaleList = iTdLotteryOnSaleService.getByWeekDay(weekDay);
70 85
         if (null == onSaleList || onSaleList.size() == 0) {
71
-            log.info(today + "未找到有开设置");
86
+            log.info(today + "未找到有开设置");
72 87
             return;
73 88
         }
74 89
 
@@ -79,6 +94,13 @@ public class TaLotteryResultServiceImpl extends ServiceImpl<TaLotteryResultMappe
79 94
             // 彩种字典
80 95
             TdLottery lottery = iTdLotteryService.getById(lotteryId);
81 96
 
97
+            // 中奖设置
98
+            List<TdLotteryPrize> prizeSettings = iTdLotteryPrizeService.getByLottery(lottery);
99
+            if (null == prizeSettings && prizeSettings.size() == 0) {
100
+                log.error(String.format("彩种 %s 没有开奖相关设置", lotteryId));
101
+                continue;
102
+            }
103
+
82 104
             // 当前彩种的开奖结果
83 105
             TaLotteryResult lotteryResult = getLotteryResultBy(onSale.getLotteryId(), today);
84 106
             if (null == lotteryResult) {
@@ -86,67 +108,419 @@ public class TaLotteryResultServiceImpl extends ServiceImpl<TaLotteryResultMappe
86 108
                 continue;
87 109
             }
88 110
 
89
-            switch (lotteryId) {
90
-                case CommConstants.LOTTERY_LOTTERY:
91
-                    validLotteryCustomer(lottery, lotteryResult);
92
-                    break;
93
-                case CommConstants.LOTTERY_P3:
94
-                    validP3Customer(lottery, lotteryResult);
95
-                    break;
96
-                case CommConstants.LOTTERY_P5:
97
-                    validP5Customer(lottery, lotteryResult);
98
-                    break;
99
-                case CommConstants.LOTTERY_DOUBLE:
100
-                    validDoubleCustomer(lottery, lotteryResult);
101
-                    break;
102
-                case CommConstants.LOTTERY_FOOTBALL:
103
-                    validFootballCustomer(lottery, lotteryResult);
104
-                    break;
105
-                case CommConstants.LOTTERY_BASKETBALL:
106
-                    validBasketballCustomer(lottery, lotteryResult);
107
-                    break;
108
-                default:
109
-                    break;
111
+            if (null == lotteryResult.getDetailList() || lotteryResult.getDetailList().size() == 0) {
112
+                log.error(String.format("彩种 %s 未抓取到开奖明细结果", lotteryId));
113
+                continue;
114
+            }
115
+
116
+            // 当前彩种的投注列表
117
+            List<TaCustomerBetting> customerBettingList = iTaCustomerBettingService.getAllUnOpenBettingsBy(lottery, lotteryResult);
118
+            if (null == customerBettingList || customerBettingList.size() == 0) {
119
+                log.info(String.format("彩种 %s 本期无人投注", lotteryId));
120
+                continue;
121
+            }
122
+
123
+            // 遍历校验中奖情况
124
+            for (TaCustomerBetting customerBetting : customerBettingList) {
125
+                try {
126
+                    switch (lotteryId) {
127
+                        case CommConstants.LOTTERY_LOTTERY:
128
+                            validLotteryCustomer(lottery, prizeSettings, lotteryResult, customerBetting);
129
+                            break;
130
+                        case CommConstants.LOTTERY_P3:
131
+                            validP3Customer(lottery, prizeSettings, lotteryResult, customerBetting);
132
+                            break;
133
+                        case CommConstants.LOTTERY_P5:
134
+                            validP5Customer(lottery, prizeSettings, lotteryResult, customerBetting);
135
+                            break;
136
+                        case CommConstants.LOTTERY_DOUBLE:
137
+                            validDoubleCustomer(lottery, prizeSettings, lotteryResult, customerBetting);
138
+                            break;
139
+                        case CommConstants.LOTTERY_FOOTBALL:
140
+                            validFootballCustomer(lottery, prizeSettings, lotteryResult, customerBetting);
141
+                            break;
142
+                        case CommConstants.LOTTERY_BASKETBALL:
143
+                            validBasketballCustomer(lottery, prizeSettings, lotteryResult, customerBetting);
144
+                            break;
145
+                        default:
146
+                            break;
147
+                    }
148
+                } catch (Exception e) {
149
+                    e.printStackTrace();
150
+                    continue;
151
+                }
110 152
             }
111 153
         }
112 154
     }
113 155
 
114
-    private void validLotteryCustomer(TdLottery lottery, TaLotteryResult lotteryResult) throws Exception {
115
-        List<TaCustomerBetting> customerBettingList = iTaCustomerBettingService.getAllUnOpenBettingsBy(lottery, lotteryResult);
116
-        if (null == customerBettingList || customerBettingList.size() == 0) {
117
-            log.info(String.format("大乐透 %s 期无人投注", lotteryResult.getIssueNo()));
156
+    private void validLotteryCustomer(TdLottery lottery, List<TdLotteryPrize> prizeSettings, TaLotteryResult lotteryResult, TaCustomerBetting customerBetting) throws Exception {
157
+        TaBettingPlan taBettingPlan = customerBetting.getBettingPlan();
158
+        if (null == taBettingPlan) {
159
+            log.error(String.format("ID %s 的投注没有投注方案", customerBetting.getBettingId()));
118 160
             return;
119 161
         }
120
-        
121
-        for (TaCustomerBetting customerBetting : customerBettingList) {
122
-            TaBettingPlan taBettingPlan = customerBetting.getBettingPlan();
123
-            if (null == taBettingPlan) {
124
-                log.error(String.format("ID %s 的投注没有投注方案", customerBetting.getBettingId()));
162
+
163
+        if (null == taBettingPlan.getItemList() || taBettingPlan.getItemList().size() == 0
164
+                || null == customerBetting.getItemList() || customerBetting.getItemList().size() == 0) {
165
+            log.error(String.format("ID %s 的投注没有投注明细", customerBetting.getBettingId()));
166
+            return;
167
+        }
168
+
169
+        int winTotalCharges = 0;
170
+        for (TaBettingPlanItem item : taBettingPlan.getItemList()) {
171
+            try {
172
+                TaCustomerBettingItem bettingItem = getBettingItemMap(customerBetting.getItemList(), item);
173
+                if (bettingItem == null) {
174
+                    log.error(String.format("ID %s 的投注查询映射投注明细失败", customerBetting.getBettingId()));
175
+                    continue;
176
+                }
177
+
178
+                String firstNums = item.getFirstNums();
179
+                if (StringUtils.isEmpty(firstNums)) {
180
+                    log.error(String.format("ID %s 的投注明细无前区内容", customerBetting.getBettingId()));
181
+                    continue;
182
+                }
183
+
184
+                String firstDanNums = item.getFirstDan();
185
+                if (StringUtils.isEmpty(firstDanNums)) {
186
+                    firstDanNums = "";
187
+                }
188
+
189
+                // 前区中奖数
190
+                int firstSameNums = BizUtils.getSameNums(
191
+                        lotteryResult.getFirstResult().split(","),
192
+                        firstNums.split(","),
193
+                        firstDanNums.split(",")
194
+                );
195
+
196
+                String secondNums = item.getFirstNums();
197
+                if (StringUtils.isEmpty(secondNums)) {
198
+                    log.error(String.format("ID %s 的投注明细无后区内容", customerBetting.getBettingId()));
199
+                    continue;
200
+                }
201
+
202
+                String secondDanNums = item.getFirstDan();
203
+                if (StringUtils.isEmpty(secondDanNums)) {
204
+                    secondDanNums = "";
205
+                }
206
+
207
+                // 后区中奖数
208
+                int secondSameNums = BizUtils.getSameNums(lotteryResult.getSecondResult().split(","), secondNums.split(","), secondDanNums.split(","));
209
+
210
+                // 选择结果
211
+                String curNums = String.format("%d-%d", firstSameNums, secondSameNums);
212
+
213
+                boolean needContinue = false;
214
+                TdLotteryPrize bingo = null;
215
+                for(TdLotteryPrize prize : prizeSettings) {
216
+                    if (StringUtils.isEmpty(prize.getBingoRule())) {
217
+                        log.error("大乐透的中奖结果规则未维护");
218
+                        needContinue = true;
219
+                        break;
220
+                    }
221
+
222
+                    if (prize.getBingoRule().contains(curNums)) {
223
+                        bingo = prize;
224
+                        break;
225
+                    }
226
+                }
227
+
228
+                if (needContinue) {
229
+                    continue;
230
+                }
231
+
232
+                bettingItem.setIsOpen(true);
233
+                if (null != bingo) {
234
+                    log.info(String.format("恭喜 %s 大乐透中了 %s", customerBetting.getCustomerId(), bingo.getLevel()));
235
+                    bettingItem.setIsWinning(true);
236
+                    bettingItem.setWinLevel(bingo.getLevel());
237
+                    TaLotteryResultDetail resultDetail = filterResultDetail(lotteryResult.getDetailList(), bingo.getLevel());
238
+                    if (null == resultDetail) {
239
+                        log.error("大乐透的中奖结果明细未成功抓取");
240
+                        continue;
241
+                    }
242
+
243
+                    int winAmount = Math.round(Float.parseFloat(resultDetail.getMoney()) * 100);
244
+                    // 是否追加
245
+                    boolean isAdd = customerBetting.getIsAdd();
246
+                    if (isAdd && !StringUtils.isEmpty(resultDetail.getXMoney())) {
247
+                        winAmount += Math.round(Float.parseFloat(resultDetail.getXMoney()) * 100);
248
+                    }
249
+                    bettingItem.setWinAmount(winAmount);
250
+
251
+                    winTotalCharges += winAmount;
252
+                } else {
253
+                    bettingItem.setIsWinning(false);
254
+                }
255
+
256
+                iTaCustomerBettingItemService.updateById(bettingItem);
257
+            } catch (Exception e) {
258
+                e.printStackTrace();
125 259
                 continue;
126 260
             }
261
+        }
127 262
 
128
-            if (null == taBettingPlan.getItemList() || taBettingPlan.getItemList().size() == 0) {
129
-                log.error(String.format("ID %s 的投注没有投注明细", customerBetting.getBettingId()));
130
-                continue;
263
+        if (winTotalCharges > 0) {
264
+            customerBetting.setIsWinning(true);
265
+            customerBetting.setWinAmount(winTotalCharges * customerBetting.getBettingTimes());
266
+        } else {
267
+            customerBetting.setIsWinning(false);
268
+        }
269
+        customerBetting.setIsOpen(true);
270
+        customerBetting.setOpeningDate(DateUtils.today());
271
+        iTaCustomerBettingService.updateById(customerBetting);
272
+    }
273
+
274
+    private TaLotteryResultDetail filterResultDetail(List<TaLotteryResultDetail> detailList, String level) {
275
+        for (TaLotteryResultDetail d: detailList) {
276
+            if (d.getLevel().equals(level)) {
277
+                return d;
131 278
             }
279
+        }
132 280
 
281
+        return null;
282
+    }
133 283
 
284
+    private TaCustomerBettingItem getBettingItemMap(List<TaCustomerBettingItem> bettingItemList, TaBettingPlanItem item) {
285
+        for (TaCustomerBettingItem it : bettingItemList) {
286
+            if (item.getItemNo().equals(it.getPlanItemNo())) {
287
+                return it;
288
+            }
134 289
         }
290
+        return null;
135 291
     }
136 292
 
137
-    private void validP3Customer(TdLottery lottery, TaLotteryResult lotteryResult) throws Exception {
293
+    private void validP3Customer(TdLottery lottery, List<TdLotteryPrize> prizeSettings, TaLotteryResult lotteryResult, TaCustomerBetting customerBetting) throws Exception {
138 294
     }
139 295
 
140
-    private void validP5Customer(TdLottery lottery, TaLotteryResult lotteryResult) throws Exception {
296
+    private void validP5Customer(TdLottery lottery, List<TdLotteryPrize> prizeSettings, TaLotteryResult lotteryResult, TaCustomerBetting customerBetting) throws Exception {
297
+        TaBettingPlan taBettingPlan = customerBetting.getBettingPlan();
298
+        if (null == taBettingPlan) {
299
+            log.error(String.format("ID %s 的投注没有投注方案", customerBetting.getBettingId()));
300
+            return;
301
+        }
302
+
303
+        if (null == taBettingPlan.getItemList() || taBettingPlan.getItemList().size() == 0
304
+                || null == customerBetting.getItemList() || customerBetting.getItemList().size() == 0) {
305
+            log.error(String.format("ID %s 的投注没有投注明细", customerBetting.getBettingId()));
306
+            return;
307
+        }
308
+
309
+        int winTotalCharges = 0;
310
+        for (TaBettingPlanItem item : taBettingPlan.getItemList()) {
311
+            try {
312
+                TaCustomerBettingItem bettingItem = getBettingItemMap(customerBetting.getItemList(), item);
313
+                if (bettingItem == null) {
314
+                    log.error(String.format("ID %s 的投注查询映射投注明细失败", customerBetting.getBettingId()));
315
+                    continue;
316
+                }
317
+
318
+                String firstNums = item.getFirstNums();
319
+                if (StringUtils.isEmpty(firstNums)) {
320
+                    log.error(String.format("ID %s 的投注明细无前区内容", customerBetting.getBettingId()));
321
+                    continue;
322
+                }
323
+
324
+                String firstDanNums = item.getFirstDan();
325
+                if (StringUtils.isEmpty(firstDanNums)) {
326
+                    firstDanNums = "";
327
+                }
328
+
329
+                // 前区中奖数
330
+                int firstSameNums = BizUtils.getSameNums(
331
+                        lotteryResult.getFirstResult().split(","),
332
+                        firstNums.split(","),
333
+                        firstDanNums.split(",")
334
+                );
335
+
336
+                String secondNums = item.getFirstNums();
337
+                if (StringUtils.isEmpty(secondNums)) {
338
+                    log.error(String.format("ID %s 的投注明细无后区内容", customerBetting.getBettingId()));
339
+                    continue;
340
+                }
341
+
342
+                String secondDanNums = item.getFirstDan();
343
+                if (StringUtils.isEmpty(secondDanNums)) {
344
+                    secondDanNums = "";
345
+                }
346
+
347
+                // 后区中奖数
348
+                int secondSameNums = BizUtils.getSameNums(lotteryResult.getSecondResult().split(","), secondNums.split(","), secondDanNums.split(","));
349
+
350
+                // 选择结果
351
+                String curNums = String.format("%d-%d", firstSameNums, secondSameNums);
352
+
353
+                boolean needContinue = false;
354
+                TdLotteryPrize bingo = null;
355
+                for(TdLotteryPrize prize : prizeSettings) {
356
+                    if (StringUtils.isEmpty(prize.getBingoRule())) {
357
+                        log.error("双色球的中奖结果规则未维护");
358
+                        needContinue = true;
359
+                        break;
360
+                    }
361
+
362
+                    if (prize.getBingoRule().contains(curNums)) {
363
+                        bingo = prize;
364
+                        break;
365
+                    }
366
+                }
367
+
368
+                if (needContinue) {
369
+                    continue;
370
+                }
371
+
372
+                bettingItem.setIsOpen(true);
373
+                if (null != bingo) {
374
+                    log.info(String.format("恭喜 %s 双色球中了 %s", customerBetting.getCustomerId(), bingo.getLevel()));
375
+                    bettingItem.setIsWinning(true);
376
+                    bettingItem.setWinLevel(bingo.getLevel());
377
+                    TaLotteryResultDetail resultDetail = filterResultDetail(lotteryResult.getDetailList(), bingo.getLevel());
378
+                    if (null == resultDetail) {
379
+                        log.error("双色球的中奖结果明细未成功抓取");
380
+                        continue;
381
+                    }
382
+
383
+                    int winAmount = Math.round(Float.parseFloat(resultDetail.getMoney()) * 100);
384
+                    bettingItem.setWinAmount(winAmount);
385
+                    winTotalCharges += winAmount;
386
+                } else {
387
+                    bettingItem.setIsWinning(false);
388
+                }
389
+
390
+                iTaCustomerBettingItemService.updateById(bettingItem);
391
+            } catch (Exception e) {
392
+                e.printStackTrace();
393
+                continue;
394
+            }
395
+        }
396
+
397
+        if (winTotalCharges > 0) {
398
+            customerBetting.setIsWinning(true);
399
+            customerBetting.setWinAmount(winTotalCharges * customerBetting.getBettingTimes());
400
+        } else {
401
+            customerBetting.setIsWinning(false);
402
+        }
403
+        customerBetting.setIsOpen(true);
404
+        customerBetting.setOpeningDate(DateUtils.today());
405
+        iTaCustomerBettingService.updateById(customerBetting);
141 406
     }
142 407
 
143
-    private void validDoubleCustomer(TdLottery lottery, TaLotteryResult lotteryResult) throws Exception {
408
+    private void validDoubleCustomer(TdLottery lottery, List<TdLotteryPrize> prizeSettings, TaLotteryResult lotteryResult, TaCustomerBetting customerBetting) throws Exception {
409
+        TaBettingPlan taBettingPlan = customerBetting.getBettingPlan();
410
+        if (null == taBettingPlan) {
411
+            log.error(String.format("ID %s 的投注没有投注方案", customerBetting.getBettingId()));
412
+            return;
413
+        }
414
+
415
+        if (null == taBettingPlan.getItemList() || taBettingPlan.getItemList().size() == 0
416
+                || null == customerBetting.getItemList() || customerBetting.getItemList().size() == 0) {
417
+            log.error(String.format("ID %s 的投注没有投注明细", customerBetting.getBettingId()));
418
+            return;
419
+        }
420
+
421
+        int winTotalCharges = 0;
422
+        for (TaBettingPlanItem item : taBettingPlan.getItemList()) {
423
+            try {
424
+                TaCustomerBettingItem bettingItem = getBettingItemMap(customerBetting.getItemList(), item);
425
+                if (bettingItem == null) {
426
+                    log.error(String.format("ID %s 的投注查询映射投注明细失败", customerBetting.getBettingId()));
427
+                    continue;
428
+                }
429
+
430
+                String firstNums = item.getFirstNums();
431
+                if (StringUtils.isEmpty(firstNums)) {
432
+                    log.error(String.format("ID %s 的投注明细无前区内容", customerBetting.getBettingId()));
433
+                    continue;
434
+                }
435
+
436
+                String firstDanNums = item.getFirstDan();
437
+                if (StringUtils.isEmpty(firstDanNums)) {
438
+                    firstDanNums = "";
439
+                }
440
+
441
+                // 前区中奖数
442
+                int firstSameNums = BizUtils.getSameNums(
443
+                        lotteryResult.getFirstResult().split(","),
444
+                        firstNums.split(","),
445
+                        firstDanNums.split(",")
446
+                );
447
+
448
+                String secondNums = item.getFirstNums();
449
+                if (StringUtils.isEmpty(secondNums)) {
450
+                    log.error(String.format("ID %s 的投注明细无后区内容", customerBetting.getBettingId()));
451
+                    continue;
452
+                }
453
+
454
+                String secondDanNums = item.getFirstDan();
455
+                if (StringUtils.isEmpty(secondDanNums)) {
456
+                    secondDanNums = "";
457
+                }
458
+
459
+                // 后区中奖数
460
+                int secondSameNums = BizUtils.getSameNums(lotteryResult.getSecondResult().split(","), secondNums.split(","), secondDanNums.split(","));
461
+
462
+                // 选择结果
463
+                String curNums = String.format("%d-%d", firstSameNums, secondSameNums);
464
+
465
+                boolean needContinue = false;
466
+                TdLotteryPrize bingo = null;
467
+                for(TdLotteryPrize prize : prizeSettings) {
468
+                    if (StringUtils.isEmpty(prize.getBingoRule())) {
469
+                        log.error("双色球的中奖结果规则未维护");
470
+                        needContinue = true;
471
+                        break;
472
+                    }
473
+
474
+                    if (prize.getBingoRule().contains(curNums)) {
475
+                        bingo = prize;
476
+                        break;
477
+                    }
478
+                }
479
+
480
+                if (needContinue) {
481
+                    continue;
482
+                }
483
+
484
+                bettingItem.setIsOpen(true);
485
+                if (null != bingo) {
486
+                    log.info(String.format("恭喜 %s 双色球中了 %s", customerBetting.getCustomerId(), bingo.getLevel()));
487
+                    bettingItem.setIsWinning(true);
488
+                    bettingItem.setWinLevel(bingo.getLevel());
489
+                    TaLotteryResultDetail resultDetail = filterResultDetail(lotteryResult.getDetailList(), bingo.getLevel());
490
+                    if (null == resultDetail) {
491
+                        log.error("双色球的中奖结果明细未成功抓取");
492
+                        continue;
493
+                    }
494
+
495
+                    int winAmount = Math.round(Float.parseFloat(resultDetail.getMoney()) * 100);
496
+                    bettingItem.setWinAmount(winAmount);
497
+                    winTotalCharges += winAmount;
498
+                } else {
499
+                    bettingItem.setIsWinning(false);
500
+                }
501
+
502
+                iTaCustomerBettingItemService.updateById(bettingItem);
503
+            } catch (Exception e) {
504
+                e.printStackTrace();
505
+                continue;
506
+            }
507
+        }
508
+
509
+        if (winTotalCharges > 0) {
510
+            customerBetting.setIsWinning(true);
511
+            customerBetting.setWinAmount(winTotalCharges * customerBetting.getBettingTimes());
512
+        } else {
513
+            customerBetting.setIsWinning(false);
514
+        }
515
+        customerBetting.setIsOpen(true);
516
+        customerBetting.setOpeningDate(DateUtils.today());
517
+        iTaCustomerBettingService.updateById(customerBetting);
144 518
     }
145 519
 
146
-    private void validFootballCustomer(TdLottery lottery, TaLotteryResult lotteryResult) throws Exception {
520
+    private void validFootballCustomer(TdLottery lottery, List<TdLotteryPrize> prizeSettings, TaLotteryResult lotteryResult, TaCustomerBetting customerBetting) throws Exception {
147 521
     }
148 522
 
149
-    private void validBasketballCustomer(TdLottery lottery, TaLotteryResult lotteryResult) throws Exception {
523
+    private void validBasketballCustomer(TdLottery lottery, List<TdLotteryPrize> prizeSettings, TaLotteryResult lotteryResult, TaCustomerBetting customerBetting) throws Exception {
150 524
     }
151 525
 
152 526
     public TaLotteryResult getLotteryResultBy(String lotteryId, String openingDate) throws Exception {
@@ -154,6 +528,16 @@ public class TaLotteryResultServiceImpl extends ServiceImpl<TaLotteryResultMappe
154 528
         queryWrapper.eq("lottery_id", lotteryId);
155 529
         queryWrapper.eq("opening_date", openingDate);
156 530
         queryWrapper.eq("status", StatusEnum.NORMAL.getCode());
157
-        return getOne(queryWrapper);
531
+
532
+        TaLotteryResult result = getOne(queryWrapper);
533
+        if (null != result) {
534
+            QueryWrapper<TaLotteryResultDetail> query2 = new QueryWrapper<>();
535
+            query2.eq("result_no", result.getSerialNo());
536
+            query2.eq("status", StatusEnum.NORMAL.getCode());
537
+            query2.orderByAsc("serial_no");
538
+            result.setDetailList(taLotteryResultDetailMapper.selectList(query2));
539
+        }
540
+
541
+        return result;
158 542
     }
159 543
 }

+ 14
- 0
src/main/java/com/yunzhi/niucai/service/impl/TdLotteryPrizeServiceImpl.java Näytä tiedosto

@@ -1,11 +1,16 @@
1 1
 package com.yunzhi.niucai.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.yunzhi.niucai.entity.TdLottery;
3 5
 import com.yunzhi.niucai.entity.TdLotteryPrize;
6
+import com.yunzhi.niucai.enums.StatusEnum;
4 7
 import com.yunzhi.niucai.mapper.TdLotteryPrizeMapper;
5 8
 import com.yunzhi.niucai.service.ITdLotteryPrizeService;
6 9
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 10
 import org.springframework.stereotype.Service;
8 11
 
12
+import java.util.List;
13
+
9 14
 /**
10 15
  * <p>
11 16
  * 彩种中奖设置  服务实现类
@@ -17,4 +22,13 @@ import org.springframework.stereotype.Service;
17 22
 @Service
18 23
 public class TdLotteryPrizeServiceImpl extends ServiceImpl<TdLotteryPrizeMapper, TdLotteryPrize> implements ITdLotteryPrizeService {
19 24
 
25
+    @Override
26
+    public List<TdLotteryPrize> getByLottery(TdLottery lottery) throws Exception {
27
+        QueryWrapper<TdLotteryPrize> queryWrapper = new QueryWrapper<>();
28
+        queryWrapper.eq("lottery_id", lottery.getLotteryId());
29
+        queryWrapper.eq("statsu", StatusEnum.NORMAL.getCode());
30
+        queryWrapper.orderByAsc("serial_no");
31
+
32
+        return list(queryWrapper);
33
+    }
20 34
 }

+ 5
- 0
src/main/resources/mapper/TaCustomerBettingItemMapper.xml Näytä tiedosto

@@ -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.TaCustomerBettingItemMapper">
4
+
5
+</mapper>

+ 5
- 0
src/main/resources/mapper/TaLotteryResultDetailMapper.xml Näytä tiedosto

@@ -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.TaLotteryResultDetailMapper">
4
+
5
+</mapper>