|
@@ -2,17 +2,17 @@ package com.yunzhi.niucai.service.impl;
|
2
|
2
|
|
3
|
3
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
4
|
4
|
import com.yunzhi.niucai.common.DateUtils;
|
5
|
|
-import com.yunzhi.niucai.entity.TaMatch;
|
6
|
|
-import com.yunzhi.niucai.entity.TaMatchOdds;
|
7
|
|
-import com.yunzhi.niucai.entity.TaMatchWay;
|
|
5
|
+import com.yunzhi.niucai.entity.*;
|
|
6
|
+import com.yunzhi.niucai.enums.SportOpeningStatusEnum;
|
8
|
7
|
import com.yunzhi.niucai.enums.SportStatusEnum;
|
9
|
8
|
import com.yunzhi.niucai.mapper.TaMatchMapper;
|
10
|
9
|
import com.yunzhi.niucai.mapper.TaMatchOddsMapper;
|
11
|
|
-import com.yunzhi.niucai.service.ITaMatchService;
|
|
10
|
+import com.yunzhi.niucai.service.*;
|
12
|
11
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
13
|
|
-import com.yunzhi.niucai.service.ITaMatchWayService;
|
14
|
12
|
import org.springframework.beans.factory.annotation.Autowired;
|
15
|
13
|
import org.springframework.stereotype.Service;
|
|
14
|
+import org.springframework.transaction.annotation.Propagation;
|
|
15
|
+import org.springframework.transaction.annotation.Transactional;
|
16
|
16
|
|
17
|
17
|
import java.util.ArrayList;
|
18
|
18
|
import java.util.HashMap;
|
|
@@ -33,6 +33,15 @@ public class TaMatchServiceImpl extends ServiceImpl<TaMatchMapper, TaMatch> impl
|
33
|
33
|
@Autowired
|
34
|
34
|
ITaMatchWayService iTaMatchWayService;
|
35
|
35
|
|
|
36
|
+ @Autowired
|
|
37
|
+ ITaCustomerBettingService iTaCustomerBettingService;
|
|
38
|
+
|
|
39
|
+ @Autowired
|
|
40
|
+ ITaCustomerBettingItemService iTaCustomerBettingItemService;
|
|
41
|
+
|
|
42
|
+ @Autowired
|
|
43
|
+ ITaCustomerBettingSportService iTaCustomerBettingSportService;
|
|
44
|
+
|
36
|
45
|
@Autowired
|
37
|
46
|
TaMatchMapper taMatchMapper;
|
38
|
47
|
|
|
@@ -77,4 +86,78 @@ public class TaMatchServiceImpl extends ServiceImpl<TaMatchMapper, TaMatch> impl
|
77
|
86
|
public List<TaMatch> getLastResult() throws Exception {
|
78
|
87
|
return taMatchMapper.getLastResult();
|
79
|
88
|
}
|
|
89
|
+
|
|
90
|
+ /**
|
|
91
|
+ * 体彩是否中奖
|
|
92
|
+ * @throws Exception
|
|
93
|
+ */
|
|
94
|
+ public void checkAndSetSportPrize() throws Exception {
|
|
95
|
+ List<TaMatch> matchList = taMatchMapper.getLastOpenAndUndoMatch(3);
|
|
96
|
+ if (null == matchList || matchList.size() == 0) {
|
|
97
|
+ return;
|
|
98
|
+ }
|
|
99
|
+
|
|
100
|
+ for (TaMatch taMatch : matchList) {
|
|
101
|
+ try {
|
|
102
|
+ taMatch.setOpeningStatus(SportOpeningStatusEnum.DOING.getCode());
|
|
103
|
+ updateById(taMatch);
|
|
104
|
+
|
|
105
|
+ String lotteryId = taMatch.getLotteryId();
|
|
106
|
+ switch (lotteryId) {
|
|
107
|
+ case "football":
|
|
108
|
+ setFootballPrize(taMatch);
|
|
109
|
+ break;
|
|
110
|
+ case "basketball":
|
|
111
|
+ setBasketballPrize(taMatch);
|
|
112
|
+ break;
|
|
113
|
+ default:
|
|
114
|
+ break;
|
|
115
|
+ }
|
|
116
|
+
|
|
117
|
+ } catch (Exception e) {
|
|
118
|
+ // TODO 比如错误日志记录
|
|
119
|
+ taMatch.setOpeningStatus(SportOpeningStatusEnum.READY.getCode());
|
|
120
|
+ updateById(taMatch);
|
|
121
|
+ }
|
|
122
|
+ }
|
|
123
|
+ }
|
|
124
|
+
|
|
125
|
+ /**
|
|
126
|
+ * 足球开奖
|
|
127
|
+ * @param taMatch
|
|
128
|
+ * @throws Exception
|
|
129
|
+ */
|
|
130
|
+ @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
|
|
131
|
+ private void setFootballPrize(TaMatch taMatch) throws Exception {
|
|
132
|
+ // 获取当前比赛的投注列表
|
|
133
|
+ List<TaCustomerBettingItem> bettingItemList = iTaCustomerBettingItemService.getUnDealItems(taMatch);
|
|
134
|
+ if (null == bettingItemList || bettingItemList.size() == 0) {
|
|
135
|
+ return;
|
|
136
|
+ }
|
|
137
|
+
|
|
138
|
+ for (TaCustomerBettingItem item: bettingItemList) {
|
|
139
|
+ // 主记录
|
|
140
|
+ TaCustomerBetting betting = iTaCustomerBettingService.getById(item.getBettingId());
|
|
141
|
+ // 投注列表
|
|
142
|
+ List<TaCustomerBettingSport> bettingSportList = iTaCustomerBettingSportService.getListByBetting(item.getBettingId(), item.getItemNo());
|
|
143
|
+
|
|
144
|
+ for (TaCustomerBettingSport bettingSport : bettingSportList) {
|
|
145
|
+
|
|
146
|
+ }
|
|
147
|
+ }
|
|
148
|
+ }
|
|
149
|
+
|
|
150
|
+ /**
|
|
151
|
+ * 篮球开奖
|
|
152
|
+ * @param taMatch
|
|
153
|
+ * @throws Exception
|
|
154
|
+ */
|
|
155
|
+ @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
|
|
156
|
+ private void setBasketballPrize(TaMatch taMatch) throws Exception {
|
|
157
|
+
|
|
158
|
+ }
|
|
159
|
+
|
|
160
|
+ private boolean isWining(TaMatch taMatch, TaCustomerBettingSport bettingSport) {
|
|
161
|
+ return false;
|
|
162
|
+ }
|
80
|
163
|
}
|