张延森 4 vuotta sitten
vanhempi
commit
269920b27e

+ 3
- 2
src/main/java/com/yunzhi/niucai/common/ListUtils.java Näytä tiedosto

43
             return result;
43
             return result;
44
         } else {
44
         } else {
45
             // 去掉第一个, 剩余的继续迭代
45
             // 去掉第一个, 剩余的继续迭代
46
-            src.remove(0);
47
-            List<List<T>> rtnList = descartes(src);
46
+            List<List<T>> srcCopy = getDeepCopy(src);   // 不影响原来 list
47
+            srcCopy.remove(0);
48
+            List<List<T>> rtnList = descartes(srcCopy);
48
 
49
 
49
             for (T a : srcA) {
50
             for (T a : srcA) {
50
                 for (List<T> rtn : rtnList) {
51
                 for (List<T> rtn : rtnList) {

+ 24
- 0
src/main/java/com/yunzhi/niucai/controller/TaCustomerController.java Näytä tiedosto

8
 import com.yunzhi.niucai.common.SMSCaptcha;
8
 import com.yunzhi.niucai.common.SMSCaptcha;
9
 import com.yunzhi.niucai.common.StringUtils;
9
 import com.yunzhi.niucai.common.StringUtils;
10
 import com.yunzhi.niucai.enums.StatusEnum;
10
 import com.yunzhi.niucai.enums.StatusEnum;
11
+import com.yunzhi.niucai.vo.CustIdentityInfo;
11
 import com.yunzhi.niucai.vo.SignUpParam;
12
 import com.yunzhi.niucai.vo.SignUpParam;
12
 import io.swagger.annotations.Api;
13
 import io.swagger.annotations.Api;
13
 import io.swagger.annotations.ApiModelProperty;
14
 import io.swagger.annotations.ApiModelProperty;
72
         return ResponseBean.success("success");
73
         return ResponseBean.success("success");
73
     }
74
     }
74
 
75
 
76
+    @PutMapping("/app/bind/identity")
77
+    @ApiOperation(value="绑定身份证号", notes = "绑定身份证号", httpMethod = "POST", response = ResponseBean.class)
78
+    public ResponseBean bindIDCardNo(@ApiParam("绑定信息") @RequestBody CustIdentityInfo custIdentityInfo,
79
+                                        HttpServletRequest request
80
+                                     ) throws Exception {
81
+        TaCustomer taCustomer = getCustomer(request);
82
+        if (null == taCustomer || StatusEnum.DELETED.getCode().equals(taCustomer.getStatus())) {
83
+            return ResponseBean.error("未登录或者已过期, 请重新登录", ResponseBean.ERROR_UNAVAILABLE);
84
+        }
85
+
86
+        if (null == custIdentityInfo
87
+                || StringUtils.isEmpty(custIdentityInfo.getIdCard())
88
+                || StringUtils.isEmpty(custIdentityInfo.getRealName())) {
89
+            return ResponseBean.error("用户真实姓名或者身份证号不能为空", ResponseBean.ERROR_MISSING_PARAMS);
90
+        }
91
+
92
+        taCustomer.setRealName(custIdentityInfo.getRealName());
93
+        taCustomer.setIdCard(custIdentityInfo.getIdCard());
94
+
95
+        iTaCustomerService.updateIdCard(taCustomer);
96
+        return ResponseBean.success("success");
97
+    }
98
+
75
 //
99
 //
76
 //    /**
100
 //    /**
77
 //     * 分页查询列表
101
 //     * 分页查询列表

+ 17
- 0
src/main/java/com/yunzhi/niucai/controller/TaMatchController.java Näytä tiedosto

1
 package com.yunzhi.niucai.controller;
1
 package com.yunzhi.niucai.controller;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
3
 import com.yunzhi.niucai.common.BaseController;
5
 import com.yunzhi.niucai.common.BaseController;
4
 import com.yunzhi.niucai.common.ResponseBean;
6
 import com.yunzhi.niucai.common.ResponseBean;
5
 import io.swagger.annotations.Api;
7
 import io.swagger.annotations.Api;
57
         return ResponseBean.success(result);
59
         return ResponseBean.success(result);
58
     }
60
     }
59
 
61
 
62
+    /**
63
+     * 分页查询列表
64
+     * @param pageNum
65
+     * @param pageSize
66
+     * @return
67
+     */
68
+    @RequestMapping(value="/app/sport/result",method= RequestMethod.GET)
69
+    @ApiOperation(value="竞彩开奖结果列表", notes = "竞彩开奖结果列表", httpMethod = "GET", response = ResponseBean.class)
70
+    public ResponseBean getResult(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
71
+                                  @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
72
+                                  @ApiParam("彩种类型: 可用类型, 请查阅彩种字典") @RequestParam(value ="lotteryId", required = false) String lotteryId) throws Exception {
60
 
73
 
74
+        IPage<TaMatch> page = new Page<>(pageNum, pageSize);
75
+        IPage<TaMatch> result = iTaMatchService.getResult(page, lotteryId);
76
+        return ResponseBean.success(result);
77
+    }
61
 
78
 
62
 //
79
 //
63
 //    /**
80
 //    /**

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

59
      */
59
      */
60
     private String cashPass;
60
     private String cashPass;
61
 
61
 
62
+    /**
63
+     * 真实姓名
64
+     */
65
+    private String realName;
66
+
62
     /**
67
     /**
63
      * 身份证
68
      * 身份证
64
      */
69
      */

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

1
 package com.yunzhi.niucai.mapper;
1
 package com.yunzhi.niucai.mapper;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.yunzhi.niucai.entity.TaMatch;
4
 import com.yunzhi.niucai.entity.TaMatch;
4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
 import org.apache.ibatis.annotations.Mapper;
6
 import org.apache.ibatis.annotations.Mapper;
30
     List<TaMatch> getLastResult() throws Exception;
31
     List<TaMatch> getLastResult() throws Exception;
31
 
32
 
32
     List<TaMatch> getLastOpenAndUndoMatch(@Param("days") int days) throws Exception;
33
     List<TaMatch> getLastOpenAndUndoMatch(@Param("days") int days) throws Exception;
34
+
35
+    IPage<TaMatch> getResult(IPage<TaMatch> page, @Param("lotteryId") String lotteryId) throws Exception;
33
 }
36
 }

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

17
     boolean signUp(SignUpParam signUpParam) throws Exception;
17
     boolean signUp(SignUpParam signUpParam) throws Exception;
18
 
18
 
19
     TaCustomer getCustomerByPhone(String phone) throws Exception;
19
     TaCustomer getCustomerByPhone(String phone) throws Exception;
20
+
21
+    boolean updateIdCard(TaCustomer taCustomer) throws Exception;
20
 }
22
 }

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

1
 package com.yunzhi.niucai.service;
1
 package com.yunzhi.niucai.service;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.yunzhi.niucai.entity.TaMatch;
4
 import com.yunzhi.niucai.entity.TaMatch;
4
 import com.baomidou.mybatisplus.extension.service.IService;
5
 import com.baomidou.mybatisplus.extension.service.IService;
5
 
6
 
18
     List<TaMatch> getMixedMatch(String lottery) throws Exception;
19
     List<TaMatch> getMixedMatch(String lottery) throws Exception;
19
 
20
 
20
     List<TaMatch> getLastResult() throws Exception;
21
     List<TaMatch> getLastResult() throws Exception;
22
+
23
+    IPage<TaMatch> getResult(IPage<TaMatch> page, String lotteryId) throws Exception;
21
 }
24
 }

+ 31
- 17
src/main/java/com/yunzhi/niucai/service/impl/TaBettingPlanServiceImpl.java Näytä tiedosto

229
                 throw new Exception("投注比赛场次数量不正确");
229
                 throw new Exception("投注比赛场次数量不正确");
230
             }
230
             }
231
 
231
 
232
-            List<Integer> noteNumList = new ArrayList<>();
232
+//            List<Integer> noteNumList = new ArrayList<>();
233
+            List<List<String>> noteList = new ArrayList<>();
233
             for (TaBettingPlanItem item : taBettingPlan.getItemList()) {
234
             for (TaBettingPlanItem item : taBettingPlan.getItemList()) {
234
                 validateSport(taBettingPlan, item, tdLottery);
235
                 validateSport(taBettingPlan, item, tdLottery);
235
-                noteNumList.add(item.getDetailList().size());
236
+//                noteNumList.add(item.getDetailList().size());
237
+                List<String> playList = new ArrayList<>();
238
+                for (TaBettingPlanSportDetail sportDetail : item.getDetailList()) {
239
+                    playList.add(sportDetail.getOdds());
240
+                }
241
+
242
+                noteList.add(playList);
236
             }
243
             }
237
 
244
 
238
-//            // 校验注数
239
-//            int totalNums = BizUtils.computeSportNoteNum(tdSportPass.getUnitNum(), tdSportPass.getAmount(), noteNumList);
240
-//            if (null == taBettingPlan.getNotesNum() || !taBettingPlan.getNotesNum().equals(totalNums)) {
241
-//                throw new Exception("投注总注数计算不正确, 应该为: " + totalNums);
242
-//            }
243
-//
244
-//            // 总金额
245
-//            int totalPrice = totalNums * tdLottery.getUnitPrice() * taBettingPlan.getTimes();
246
-//            if (null == taBettingPlan.getTotalPrice() || !taBettingPlan.getTotalPrice().equals(totalPrice)) {
247
-//                throw new Exception("投注总金额计算不正确");
248
-//            }
249
-//
250
-//            if (totalPrice > tdLottery.getMaxPrice()) {
251
-//                throw new Exception("投注总金额不能超过" + String.format("%.2f", (float) tdLottery.getMaxPrice() / 100 ) + "元");
252
-//            }
245
+            // 校验注数
246
+            List<List<List<String>>> mockCombList = BizUtils.mockAllCombination(noteList, tdSportPass);
247
+            int totalNums = 0;
248
+            for (List<List<String>> it : mockCombList) {
249
+                if (null != it) {
250
+                    totalNums += it.size();
251
+                }
252
+            }
253
+
254
+            if (null == taBettingPlan.getNotesNum() || !taBettingPlan.getNotesNum().equals(totalNums)) {
255
+                throw new Exception("投注总注数计算不正确, 应该为: " + totalNums);
256
+            }
257
+
258
+            // 总金额
259
+            int totalPrice = totalNums * tdLottery.getUnitPrice() * taBettingPlan.getTimes();
260
+            if (null == taBettingPlan.getTotalPrice() || !taBettingPlan.getTotalPrice().equals(totalPrice)) {
261
+                throw new Exception("投注总金额计算不正确");
262
+            }
263
+
264
+            if (totalPrice > tdLottery.getMaxPrice()) {
265
+                throw new Exception("投注总金额不能超过" + String.format("%.2f", (float) tdLottery.getMaxPrice() / 100 ) + "元");
266
+            }
253
         }
267
         }
254
 
268
 
255
         // 如果是数字彩
269
         // 如果是数字彩

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

1
 package com.yunzhi.niucai.service.impl;
1
 package com.yunzhi.niucai.service.impl;
2
 
2
 
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
4
 import com.yunzhi.niucai.common.EncryptUtils;
5
 import com.yunzhi.niucai.common.EncryptUtils;
5
 import com.yunzhi.niucai.common.StringUtils;
6
 import com.yunzhi.niucai.common.StringUtils;
6
 import com.yunzhi.niucai.entity.TaCustomer;
7
 import com.yunzhi.niucai.entity.TaCustomer;
118
         return getOne(queryWrapper);
119
         return getOne(queryWrapper);
119
     }
120
     }
120
 
121
 
122
+    @Override
123
+    public boolean updateIdCard(TaCustomer taCustomer) throws Exception {
124
+        UpdateWrapper<TaCustomer> updateWrapper = new UpdateWrapper<>();
125
+        updateWrapper.set("real_name", taCustomer.getRealName());
126
+        updateWrapper.set("id_card", taCustomer.getIdCard());
127
+        updateWrapper.eq("customer_id", taCustomer.getCustomerId());
128
+
129
+        return update(updateWrapper);
130
+    }
131
+
121
     private TaCustomer getByInviteCode(String inviteCode) throws Exception {
132
     private TaCustomer getByInviteCode(String inviteCode) throws Exception {
122
         QueryWrapper<TaCustomer> queryWrapper = new QueryWrapper<>();
133
         QueryWrapper<TaCustomer> queryWrapper = new QueryWrapper<>();
123
         queryWrapper.eq("invite_code", inviteCode);
134
         queryWrapper.eq("invite_code", inviteCode);

+ 129
- 26
src/main/java/com/yunzhi/niucai/service/impl/TaMatchServiceImpl.java Näytä tiedosto

1
 package com.yunzhi.niucai.service.impl;
1
 package com.yunzhi.niucai.service.impl;
2
 
2
 
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.yunzhi.niucai.common.BizUtils;
4
 import com.yunzhi.niucai.common.DateUtils;
7
 import com.yunzhi.niucai.common.DateUtils;
5
 import com.yunzhi.niucai.entity.*;
8
 import com.yunzhi.niucai.entity.*;
6
 import com.yunzhi.niucai.enums.SportOpeningStatusEnum;
9
 import com.yunzhi.niucai.enums.SportOpeningStatusEnum;
7
 import com.yunzhi.niucai.enums.SportStatusEnum;
10
 import com.yunzhi.niucai.enums.SportStatusEnum;
11
+import com.yunzhi.niucai.mapper.TaCustomerBettingMapper;
8
 import com.yunzhi.niucai.mapper.TaMatchMapper;
12
 import com.yunzhi.niucai.mapper.TaMatchMapper;
9
 import com.yunzhi.niucai.mapper.TaMatchOddsMapper;
13
 import com.yunzhi.niucai.mapper.TaMatchOddsMapper;
10
 import com.yunzhi.niucai.service.*;
14
 import com.yunzhi.niucai.service.*;
45
     @Autowired
49
     @Autowired
46
     ITaCustomerBettingSportService iTaCustomerBettingSportService;
50
     ITaCustomerBettingSportService iTaCustomerBettingSportService;
47
 
51
 
52
+    @Autowired
53
+    ITaBettingPlanService iTaBettingPlanService;
54
+
55
+    @Autowired
56
+    ITdSportPassService iTdSportPassService;
57
+
48
     @Autowired
58
     @Autowired
49
     TaMatchMapper taMatchMapper;
59
     TaMatchMapper taMatchMapper;
50
 
60
 
51
     @Autowired
61
     @Autowired
52
     TaMatchOddsMapper taMatchOddsMapper;
62
     TaMatchOddsMapper taMatchOddsMapper;
53
 
63
 
64
+    @Autowired
65
+    TaCustomerBettingMapper taCustomerBettingMapper;
66
+
54
     @Override
67
     @Override
55
     public List<TaMatch> getMixedMatch(String lottery) throws Exception {
68
     public List<TaMatch> getMixedMatch(String lottery) throws Exception {
56
         List<TaMatch> taMatches = taMatchMapper.getMixedMatch(lottery, SportStatusEnum.SALE.getCode());
69
         List<TaMatch> taMatches = taMatchMapper.getMixedMatch(lottery, SportStatusEnum.SALE.getCode());
90
         return taMatchMapper.getLastResult();
103
         return taMatchMapper.getLastResult();
91
     }
104
     }
92
 
105
 
106
+    @Override
107
+    public IPage<TaMatch> getResult(IPage<TaMatch> page, String lotteryId) throws Exception {
108
+        IPage<TaMatch> result = taMatchMapper.getResult(page, lotteryId);
109
+
110
+        if (null != result.getRecords() && result.getRecords().size() > 0) {
111
+            for (TaMatch taMatch : result.getRecords()) {
112
+
113
+            }
114
+        }
115
+
116
+        return null;
117
+    }
118
+
93
     /**
119
     /**
94
      * 体彩是否中奖
120
      * 体彩是否中奖
95
      * @throws Exception
121
      * @throws Exception
104
             try {
130
             try {
105
                 taMatch.setOpeningStatus(SportOpeningStatusEnum.DOING.getCode());
131
                 taMatch.setOpeningStatus(SportOpeningStatusEnum.DOING.getCode());
106
                 updateById(taMatch);
132
                 updateById(taMatch);
107
-
108
-                String lotteryId = taMatch.getLotteryId();
109
-                switch (lotteryId) {
110
-                    case "football":
111
-                        setFootballPrize(taMatch);
112
-                        break;
113
-                    case "basketball":
114
-                        setBasketballPrize(taMatch);
115
-                        break;
116
-                    default:
117
-                        break;
118
-                }
119
-
133
+                validateMatch(taMatch);
120
             } catch (Exception e) {
134
             } catch (Exception e) {
121
                 // TODO 比如错误日志记录
135
                 // TODO 比如错误日志记录
122
                 taMatch.setOpeningStatus(SportOpeningStatusEnum.READY.getCode());
136
                 taMatch.setOpeningStatus(SportOpeningStatusEnum.READY.getCode());
126
     }
140
     }
127
 
141
 
128
     /**
142
     /**
129
-     * 足球开奖
143
+     * 校验比赛
130
      * @param taMatch
144
      * @param taMatch
131
      * @throws Exception
145
      * @throws Exception
132
      */
146
      */
133
     @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
147
     @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
134
-    private void setFootballPrize(TaMatch taMatch) throws Exception {
148
+    private void validateMatch (TaMatch taMatch) throws Exception {
135
         // 获取当前比赛的投注列表
149
         // 获取当前比赛的投注列表
136
         List<TaCustomerBettingItem> bettingItemList = iTaCustomerBettingItemService.getByMatch(taMatch);
150
         List<TaCustomerBettingItem> bettingItemList = iTaCustomerBettingItemService.getByMatch(taMatch);
137
         if (null == bettingItemList || bettingItemList.size() == 0) {
151
         if (null == bettingItemList || bettingItemList.size() == 0) {
165
         }
179
         }
166
     }
180
     }
167
 
181
 
182
+    /**
183
+     * 校验投注
184
+     * @param betting
185
+     * @param item
186
+     * @throws Exception
187
+     */
168
     private void checkAndSetBetting(TaCustomerBetting betting, TaCustomerBettingItem item) throws Exception {
188
     private void checkAndSetBetting(TaCustomerBetting betting, TaCustomerBettingItem item) throws Exception {
169
         List<TaCustomerBettingItem> itemList = iTaCustomerBettingItemService.getByBetting(betting);
189
         List<TaCustomerBettingItem> itemList = iTaCustomerBettingItemService.getByBetting(betting);
170
         if (null == itemList || itemList.size() == 0) {
190
         if (null == itemList || itemList.size() == 0) {
172
         }
192
         }
173
 
193
 
174
         boolean done = true;
194
         boolean done = true;
175
-        for (TaCustomerBettingItem bettingItem : itemList) {
195
+        boolean existWinningRec = false;
196
+        for (int i = 0; i < itemList.size(); i++) {
197
+            TaCustomerBettingItem bettingItem = itemList.get(0);
176
             if (bettingItem.getItemNo().equals(item.getItemNo())) {
198
             if (bettingItem.getItemNo().equals(item.getItemNo())) {
177
-                bettingItem = item;
199
+                itemList.set(i, item);
200
+
201
+                if (item.getIsWinning()) {
202
+                    existWinningRec = true;
203
+                }
204
+
178
                 continue;
205
                 continue;
179
             }
206
             }
180
 
207
 
208
+            if (bettingItem.getIsWinning()) {
209
+                existWinningRec = true;
210
+            }
211
+
181
             // 如果还有未处理完成的, 跳出循环
212
             // 如果还有未处理完成的, 跳出循环
182
             if (!SportOpeningStatusEnum.FINISHED.getCode().equals(bettingItem.getOpeningStatus())) {
213
             if (!SportOpeningStatusEnum.FINISHED.getCode().equals(bettingItem.getOpeningStatus())) {
183
                 done = false;
214
                 done = false;
190
             return;
221
             return;
191
         }
222
         }
192
 
223
 
224
+        // 所有奖都开了
225
+        betting.setIsOpen(true);
226
+        betting.setOpeningDate(DateUtils.today());
227
+        UpdateWrapper<TaCustomerBetting> updateWrapper = new UpdateWrapper<>();
228
+        updateWrapper.set("is_open", betting.getIsOpen());
229
+        updateWrapper.set("opening_date", betting.getOpeningDate());
230
+        updateWrapper.eq("betting_id", betting.getBettingId());
231
+        taCustomerBettingMapper.update(betting, updateWrapper);
232
+
233
+        // 如果一场都没中, 直接 pass
234
+        if (!existWinningRec) {
235
+            return;
236
+        }
237
+
238
+        // 投注方案
239
+        TaBettingPlan bettingPlan = iTaBettingPlanService.getById(betting.getPlanId());
240
+        if (null == bettingPlan) {
241
+            throw new Exception("校验投注方案失败");
242
+        }
243
+        betting.setBettingPlan(bettingPlan);
244
+
193
         // 结算最终奖金
245
         // 结算最终奖金
194
         computePirzeAmount(betting, itemList);
246
         computePirzeAmount(betting, itemList);
195
     }
247
     }
223
             }
275
             }
224
 
276
 
225
             // 只有中奖的投注才会参与计算
277
             // 只有中奖的投注才会参与计算
226
-            // 所以会出现 size = 0 情况
227
             List<String> oddsOfNote = new ArrayList<>();
278
             List<String> oddsOfNote = new ArrayList<>();
228
             for (TaCustomerBettingSport sportItem : sportList) {
279
             for (TaCustomerBettingSport sportItem : sportList) {
229
                 if (sportItem.getIsWinning()) {
280
                 if (sportItem.getIsWinning()) {
230
                     oddsOfNote.add(sportItem.getOddsPrinted());
281
                     oddsOfNote.add(sportItem.getOddsPrinted());
282
+                } else {
283
+                    // 未中奖的赔率是 0
284
+                    oddsOfNote.add("0");
231
                 }
285
                 }
232
             }
286
             }
233
 
287
 
234
             noteList.add(oddsOfNote);
288
             noteList.add(oddsOfNote);
235
         }
289
         }
236
-    }
237
 
290
 
238
-    /**
239
-     * 篮球开奖
240
-     * @param taMatch
241
-     * @throws Exception
242
-     */
243
-    @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
244
-    private void setBasketballPrize(TaMatch taMatch) throws Exception {
291
+        // 玩法字典
292
+        if (null == betting.getBettingPlan().getPassCode()) {
293
+            throw new Exception("校验过关模式失败");
294
+        }
295
+        TdSportPass tdSportPass = iTdSportPassService.getById(betting.getBettingPlan().getPassCode());
296
+        if (null == tdSportPass) {
297
+            throw new Exception("校验过关模式失败");
298
+        }
299
+
300
+        List<List<List<String>>> mockCombList = BizUtils.mockAllCombination(noteList, tdSportPass);
301
+
302
+        // 计算方法:  https://www.lottery.gov.cn/bzzx/yxgz/20191119/1273604.html
303
+        float totalCharge = 0.0f;
304
+        for (List<List<String>> notes : mockCombList) {
305
+
306
+            // 多种可能的结果会直接相加
307
+            float perCombCharge = 0.0f;
308
+            for (List<String> oddsList : notes) {
309
+
310
+                // 比如购买的 3串4
311
+                // 3串4的金额是 2串1 + 2串1 + 2串1 + 3串1
312
+                float perNoteCharge = 0.0f;
313
+                for (String oddsStr : oddsList) {
314
+
315
+                    // 比如2串1
316
+                    // 2串1的金额是  第一场比赛赔率*第二次比赛赔率
317
+                    // 依次类推, 如果是 3串1 则是3场相乘
318
+                    float odds = Float.parseFloat(oddsStr);
319
+
320
+                    // 此处判断是否第一次循环, float 不能用 == 判断
321
+                    if (perNoteCharge < 0.01f) {
322
+                        perNoteCharge = odds;
323
+                    } else {
324
+                        perNoteCharge += odds;
325
+                    }
326
+                }
327
+
328
+                perCombCharge += perNoteCharge;
329
+            }
330
+
331
+            // 金额 = 2块(200分) * 赔率 * 投注倍数
332
+            totalCharge += 200 * perCombCharge * betting.getBettingTimes();
333
+        }
334
+
335
+        // 如果没有中奖
336
+        if (totalCharge < 0.01f) {
337
+            return;
338
+        }
339
+
340
+        betting.setIsWinning(true);
341
+        betting.setWinAmount((int) totalCharge);
342
+        UpdateWrapper<TaCustomerBetting> updateWrapper = new UpdateWrapper<>();
343
+        updateWrapper.set("is_winning", betting.getIsWinning());
344
+        updateWrapper.set("win_amount", betting.getWinAmount());
345
+        updateWrapper.eq("betting_id", betting.getBettingId());
346
+        taCustomerBettingMapper.update(betting, updateWrapper);
245
 
347
 
348
+        // TODO 发送通知
246
     }
349
     }
247
 
350
 
248
     private boolean isWining(TaMatch taMatch, TaCustomerBettingSport bettingSport) {
351
     private boolean isWining(TaMatch taMatch, TaCustomerBettingSport bettingSport) {

+ 17
- 0
src/main/java/com/yunzhi/niucai/vo/CustIdentityInfo.java Näytä tiedosto

1
+package com.yunzhi.niucai.vo;
2
+
3
+
4
+import io.swagger.annotations.ApiModel;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+
8
+@ApiModel(description = "登录参数")
9
+@Data
10
+public class CustIdentityInfo {
11
+
12
+    @ApiModelProperty("真实姓名")
13
+    String realName;
14
+
15
+    @ApiModelProperty("身份证号码")
16
+    String idCard;
17
+}

+ 10
- 0
src/main/resources/mapper/TaMatchMapper.xml Näytä tiedosto

40
         ORDER BY
40
         ORDER BY
41
             t.match_id ASC
41
             t.match_id ASC
42
     </select>
42
     </select>
43
+    <select id="getResult" resultType="com.yunzhi.niucai.entity.TaMatch">
44
+        SELECT
45
+            *
46
+        FROM
47
+            ta_match t
48
+        WHERE
49
+            t.`status` &gt; 1
50
+        ORDER BY
51
+            t.match_id DESC
52
+    </select>
43
 </mapper>
53
 </mapper>