|
@@ -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
|
}
|