张延森 4 years ago
parent
commit
4396edd10b
25 changed files with 840 additions and 39 deletions
  1. 12
    0
      src/main/java/com/yunzhi/niucai/common/EncryptUtils.java
  2. 141
    0
      src/main/java/com/yunzhi/niucai/common/SMSCaptcha.java
  3. 68
    0
      src/main/java/com/yunzhi/niucai/common/SMSUtils.java
  4. 24
    0
      src/main/java/com/yunzhi/niucai/config/SMSConfig.java
  5. 52
    0
      src/main/java/com/yunzhi/niucai/controller/CommController.java
  6. 39
    28
      src/main/java/com/yunzhi/niucai/controller/TaCustomerBettingController.java
  7. 36
    6
      src/main/java/com/yunzhi/niucai/controller/TaCustomerController.java
  8. 119
    0
      src/main/java/com/yunzhi/niucai/controller/TaShopLotteryController.java
  9. 5
    0
      src/main/java/com/yunzhi/niucai/entity/TaCustomer.java
  10. 6
    1
      src/main/java/com/yunzhi/niucai/entity/TaCustomerBetting.java
  11. 52
    0
      src/main/java/com/yunzhi/niucai/entity/TaShopLottery.java
  12. 16
    0
      src/main/java/com/yunzhi/niucai/enums/ReferralCodeEnum.java
  13. 18
    0
      src/main/java/com/yunzhi/niucai/mapper/TaShopLotteryMapper.java
  14. 2
    0
      src/main/java/com/yunzhi/niucai/service/ITaBettingPlanService.java
  15. 4
    0
      src/main/java/com/yunzhi/niucai/service/ITaCustomerBettingService.java
  16. 2
    0
      src/main/java/com/yunzhi/niucai/service/ITaCustomerService.java
  17. 17
    0
      src/main/java/com/yunzhi/niucai/service/ITaShopLotteryService.java
  18. 66
    3
      src/main/java/com/yunzhi/niucai/service/impl/TaBettingPlanServiceImpl.java
  19. 40
    0
      src/main/java/com/yunzhi/niucai/service/impl/TaCustomerBettingServiceImpl.java
  20. 41
    0
      src/main/java/com/yunzhi/niucai/service/impl/TaCustomerServiceImpl.java
  21. 31
    0
      src/main/java/com/yunzhi/niucai/service/impl/TaShopLotteryServiceImpl.java
  22. 25
    0
      src/main/java/com/yunzhi/niucai/vo/SignUpParam.java
  23. 9
    0
      src/main/resources/application-dev.yml
  24. 10
    1
      src/main/resources/application.yml
  25. 5
    0
      src/main/resources/mapper/TaShopLotteryMapper.xml

+ 12
- 0
src/main/java/com/yunzhi/niucai/common/EncryptUtils.java View File

@@ -2,6 +2,8 @@ package com.yunzhi.niucai.common;
2 2
 
3 3
 import org.springframework.util.DigestUtils;
4 4
 
5
+import java.util.Random;
6
+
5 7
 public class EncryptUtils {
6 8
 
7 9
     public static String md5(String str, String ...slats) {
@@ -14,4 +16,14 @@ public class EncryptUtils {
14 16
         String md5 = DigestUtils.md5DigestAsHex(base.getBytes());
15 17
         return md5;
16 18
     }
19
+
20
+    public static String randDigitStr(int length) {
21
+        Random random = new Random();
22
+        String res = "";
23
+        for (int i = 0; i < length; i ++) {
24
+            int num = random.nextInt(10);
25
+            res += String.valueOf(num);
26
+        }
27
+        return res;
28
+    }
17 29
 }

+ 141
- 0
src/main/java/com/yunzhi/niucai/common/SMSCaptcha.java View File

@@ -0,0 +1,141 @@
1
+package com.yunzhi.niucai.common;
2
+
3
+import com.yunzhi.niucai.config.SMSConfig;
4
+import lombok.Data;
5
+import lombok.experimental.Accessors;
6
+import lombok.extern.slf4j.Slf4j;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.scheduling.annotation.EnableScheduling;
9
+import org.springframework.scheduling.annotation.Scheduled;
10
+import org.springframework.stereotype.Component;
11
+
12
+import java.time.LocalDateTime;
13
+import java.util.Hashtable;
14
+import java.util.Random;
15
+
16
+@Slf4j
17
+@Component
18
+@EnableScheduling
19
+public class SMSCaptcha {
20
+    @Autowired
21
+    SMSConfig smsConfig;
22
+
23
+    @Autowired
24
+    SMSUtils smsUtils;
25
+
26
+    // 缓存电话列表
27
+    Hashtable<String, Phone> allPhones = new Hashtable<>();
28
+
29
+    /**
30
+     * 发送验证码
31
+     * @param tel
32
+     * @param captcha
33
+     * @throws Exception
34
+     */
35
+    public void send(String tel, String captcha) throws Exception {
36
+        if (null == captcha) {
37
+            throw new Exception("没有有效的验证码");
38
+        }
39
+
40
+        Phone phone = new Phone()
41
+                .setNumber(tel)
42
+                .setCaptcha(captcha)
43
+                .setExpire(expireTime());
44
+
45
+
46
+        SMSUtils.Message message = new SMSUtils.Message()
47
+                .setCode(smsConfig.getCaptcha().getCode())
48
+                .setTel(tel)
49
+                .setParams(new String[]{ captcha, smsConfig.getCaptcha().getSign() });
50
+
51
+        try {
52
+            smsUtils.sendMessage(message);
53
+        } catch (Exception e) {
54
+            // 修改友好点的错误
55
+            throw new Exception("发送验证码失败");
56
+        }
57
+
58
+        log.info(String.format("发送验证码 %s 到手机 %s", captcha, tel));
59
+
60
+        // 发送成功, 写入缓存
61
+        toCache(phone);
62
+    }
63
+
64
+    /**
65
+     * 校验验证码
66
+     * @param tel
67
+     * @param captcha
68
+     * @return
69
+     */
70
+    public boolean validate(String tel, String captcha) {
71
+        Phone phone = fromCache(tel);
72
+        if (null == phone) {
73
+            return false;
74
+        }
75
+
76
+        if (null == captcha || !captcha.equals(phone.getCaptcha())) {
77
+            return false;
78
+        }
79
+
80
+        // 过期则清除缓存
81
+        boolean res = checkExpire(phone);
82
+        if (res) {
83
+            clearCache(phone);
84
+        }
85
+
86
+        return !res;
87
+    }
88
+
89
+    /**
90
+     * 辅助方法: 随机生成验证码
91
+     * @param length
92
+     * @return
93
+     */
94
+    public String randCaptcha(int length) {
95
+        Random random = new Random();
96
+        String res = "";
97
+        for (int i = 0; i < length; i ++) {
98
+            int num = random.nextInt(10);
99
+            res += String.valueOf(num);
100
+        }
101
+        return res;
102
+    }
103
+
104
+    /**
105
+     * 定时任务 每半小时 清除一次不用的手机号
106
+     */
107
+    @Scheduled(fixedRate = 1000 * 60 * 30)
108
+    public void clearUnused() {
109
+        for (Phone phone: allPhones.values()) {
110
+            if (checkExpire(phone)) {
111
+                clearCache(phone);
112
+            }
113
+        }
114
+    }
115
+
116
+    private Phone fromCache(String phone) {
117
+        return allPhones.get(phone);
118
+    }
119
+    private void toCache(Phone phone) {
120
+        allPhones.put(phone.getNumber(), phone);
121
+    }
122
+    private void clearCache(Phone phone) { allPhones.remove(phone); }
123
+
124
+    private LocalDateTime expireTime() {
125
+        return LocalDateTime.now().plusSeconds(smsConfig.getCaptcha().getExpire());
126
+    }
127
+
128
+    // 过期返回 true
129
+    private boolean checkExpire(Phone phone) {
130
+        return LocalDateTime.now().isAfter(phone.getExpire());
131
+    }
132
+
133
+    @Data
134
+    @Accessors(chain = true)
135
+    public static class Phone {
136
+        String number;
137
+        String captcha;
138
+        LocalDateTime expire;
139
+    }
140
+
141
+}

+ 68
- 0
src/main/java/com/yunzhi/niucai/common/SMSUtils.java View File

@@ -0,0 +1,68 @@
1
+package com.yunzhi.niucai.common;
2
+
3
+import com.yunzhi.niucai.config.SMSConfig;
4
+import lombok.Data;
5
+import lombok.experimental.Accessors;
6
+import lombok.extern.slf4j.Slf4j;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.http.*;
9
+import org.springframework.stereotype.Component;
10
+import org.springframework.web.client.RestClientException;
11
+import org.springframework.web.client.RestTemplate;
12
+
13
+@Slf4j
14
+@Component
15
+public class SMSUtils {
16
+    @Autowired
17
+    SMSConfig smsConfig;
18
+
19
+    public void sendMessage(Message message) throws Exception {
20
+        request(message);
21
+    }
22
+
23
+    private void request(Message message) throws Exception {
24
+        HttpHeaders headers = new HttpHeaders();
25
+        headers.setContentType(MediaType.APPLICATION_JSON);
26
+        HttpEntity entity = new HttpEntity(message, headers);
27
+
28
+        try {
29
+            RestTemplate request = new RestTemplate();
30
+            ResponseEntity<String> response = request.exchange(
31
+                    smsConfig.getApi(),
32
+                    HttpMethod.POST,
33
+                    entity,
34
+                    String.class,
35
+                    new Object()
36
+            );
37
+
38
+            if (null == response || null == response.getStatusCode()) {
39
+                throw new Exception("发送短信失败, 未知异常");
40
+            }
41
+
42
+            if (HttpStatus.OK.value() != response.getStatusCodeValue()) {
43
+                throw new Exception("发送短信失败, 网络异常");
44
+            }
45
+
46
+            String body = response.getBody();
47
+            if (!StringUtils.isEmpty(body)) {
48
+                if (!(body.indexOf("成功") > -1 || body.indexOf("success") > -1)) {
49
+                    throw new Exception("发送短信失败, " + body);
50
+                }
51
+            }
52
+
53
+        } catch (RestClientException e) {
54
+            log.error("发送短信消息失败 {}", e.getMessage());
55
+            throw e;
56
+        }
57
+
58
+        return;
59
+    }
60
+
61
+    @Data
62
+    @Accessors(chain = true)
63
+    public static class Message {
64
+        String code;
65
+        String tel;
66
+        String[] params;
67
+    }
68
+}

+ 24
- 0
src/main/java/com/yunzhi/niucai/config/SMSConfig.java View File

@@ -0,0 +1,24 @@
1
+package com.yunzhi.niucai.config;
2
+
3
+
4
+import lombok.Data;
5
+import org.springframework.boot.context.properties.ConfigurationProperties;
6
+import org.springframework.boot.context.properties.NestedConfigurationProperty;
7
+import org.springframework.stereotype.Component;
8
+
9
+@Data
10
+@Component
11
+@ConfigurationProperties(prefix = "sms")
12
+public class SMSConfig {
13
+    private String api;
14
+
15
+    @NestedConfigurationProperty
16
+    private Captcha captcha = new Captcha();
17
+
18
+    @Data
19
+    public static class Captcha {
20
+        private String code;
21
+        private String sign;
22
+        private Integer expire;
23
+    }
24
+}

+ 52
- 0
src/main/java/com/yunzhi/niucai/controller/CommController.java View File

@@ -0,0 +1,52 @@
1
+package com.yunzhi.niucai.controller;
2
+
3
+import com.baomidou.mybatisplus.extension.api.R;
4
+import com.yunzhi.niucai.common.BaseController;
5
+import com.yunzhi.niucai.common.ResponseBean;
6
+import com.yunzhi.niucai.common.SMSCaptcha;
7
+import com.yunzhi.niucai.common.StringUtils;
8
+import com.yunzhi.niucai.vo.SportDicts;
9
+import io.swagger.annotations.Api;
10
+import io.swagger.annotations.ApiOperation;
11
+import io.swagger.annotations.ApiParam;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.web.bind.annotation.*;
14
+
15
+
16
+@Api(tags = "通用接口")
17
+@RestController
18
+@RequestMapping("/")
19
+public class CommController extends BaseController {
20
+
21
+    @Autowired
22
+    SMSCaptcha smsCaptcha;
23
+
24
+    @GetMapping("/{client}/sms/captcha/{phone}")
25
+    @ApiOperation(value="发送短信验证码", notes = "默认有效时长 5 分钟", httpMethod = "GET", response = ResponseBean.class)
26
+    public ResponseBean sendSMSCaptcha(@ApiParam(value = "客户端类型", allowableValues = "app,shop") @PathVariable String client,
27
+                                       @ApiParam(value = "手机号码") @PathVariable String phone) throws Exception {
28
+        if (StringUtils.isEmpty(phone)) {
29
+            return ResponseBean.error("手机号码不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
30
+        }
31
+
32
+        if (phone.length() != 11) {
33
+            return ResponseBean.error("手机号码只能为11位数字", ResponseBean.ERROR_ILLEGAL_PARAMS);
34
+        }
35
+
36
+        smsCaptcha.send(phone, smsCaptcha.randCaptcha(6));
37
+
38
+        return ResponseBean.success("发送验证码到手机号"+phone+"成功");
39
+    }
40
+
41
+    @PostMapping("/{client}/sms/captcha/{phone}")
42
+    @ApiOperation(value="校验短信验证码", notes = "校验短信验证码", httpMethod = "POST", response = ResponseBean.class)
43
+    public ResponseBean validateSMSCaptcha(@ApiParam(value = "客户端类型", allowableValues = "app,shop") @PathVariable String client,
44
+                                           @ApiParam(value = "手机号码") @PathVariable String phone,
45
+                                           @ApiParam(value = "验证码") @RequestParam String captcha) throws Exception {
46
+        if (!smsCaptcha.validate(phone, captcha)) {
47
+            return ResponseBean.error("验证码不正确或者已过期", ResponseBean.ERROR_ILLEGAL_PARAMS);
48
+        }
49
+
50
+        return ResponseBean.success("success");
51
+    }
52
+}

+ 39
- 28
src/main/java/com/yunzhi/niucai/controller/TaCustomerBettingController.java View File

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.niucai.common.BaseController;
7 7
 import com.yunzhi.niucai.common.ResponseBean;
8
+import com.yunzhi.niucai.entity.TaCustomer;
8 9
 import io.swagger.annotations.Api;
9 10
 import io.swagger.annotations.ApiOperation;
10 11
 import io.swagger.annotations.ApiParam;
@@ -20,6 +21,9 @@ import com.yunzhi.niucai.service.ITaCustomerBettingService;
20 21
 import com.yunzhi.niucai.entity.TaCustomerBetting;
21 22
 import org.springframework.web.bind.annotation.RestController;
22 23
 
24
+import javax.servlet.http.HttpServletRequest;
25
+import java.util.Map;
26
+
23 27
 /**
24 28
  * <p>
25 29
     * 客户投注  前端控制器
@@ -39,25 +43,31 @@ public class TaCustomerBettingController extends BaseController {
39 43
     @Autowired
40 44
     public ITaCustomerBettingService iTaCustomerBettingService;
41 45
 
42
-//
43
-//    /**
44
-//     * 分页查询列表
45
-//     * @param pageNum
46
-//     * @param pageSize
47
-//     * @return
48
-//     */
49
-//    @RequestMapping(value="/taCustomerBetting",method= RequestMethod.GET)
50
-//    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
-//    public ResponseBean taCustomerBettingList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-//									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
-//
54
-//		    IPage<TaCustomerBetting> pg = new Page<>(pageNum, pageSize);
55
-//            QueryWrapper<TaCustomerBetting> queryWrapper = new QueryWrapper<>();
56
-//            queryWrapper.orderByDesc("create_date");
57
-//
58
-//            IPage<TaCustomerBetting> result = iTaCustomerBettingService.page(pg, queryWrapper);
59
-//            return ResponseBean.success(result);
60
-//    }
46
+
47
+    /**
48
+     * 查询投注列表
49
+     * @param pageNum
50
+     * @param pageSize
51
+     * @return
52
+     */
53
+    @RequestMapping(value="/app/customer/betting/list",method= RequestMethod.GET)
54
+    @ApiOperation(value="查询投注列表", notes = "App 端只允许查询自己的", httpMethod = "GET", response = ResponseBean.class)
55
+    public ResponseBean taCustomerBettingList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
56
+                                              @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
57
+                                              HttpServletRequest request) throws Exception{
58
+            TaCustomer taCustomer = getCustomer(request);
59
+            if (null == taCustomer) {
60
+                return ResponseBean.error("账户不存在, 或重新登录", ResponseBean.ERROR_ILLEGAL_PARAMS);
61
+            }
62
+
63
+		    IPage<TaCustomerBetting> pg = new Page<>(pageNum, pageSize);
64
+            QueryWrapper<TaCustomerBetting> queryWrapper = new QueryWrapper<>();
65
+            queryWrapper.eq("customer_id", taCustomer.getCustomerId());
66
+            queryWrapper.orderByDesc("create_date");
67
+
68
+            IPage<TaCustomerBetting> result = iTaCustomerBettingService.page(pg, queryWrapper);
69
+            return ResponseBean.success(result);
70
+    }
61 71
 //
62 72
 //    /**
63 73
 //     * 保存对象
@@ -107,13 +117,14 @@ public class TaCustomerBettingController extends BaseController {
107 117
 //        }
108 118
 //    }
109 119
 //
110
-//    /**
111
-//     * 根据id查询对象
112
-//     * @param id  实体ID
113
-//     */
114
-//    @RequestMapping(value="/taCustomerBetting/{id}",method= RequestMethod.GET)
115
-//    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
-//    public ResponseBean taCustomerBettingGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
-//        return ResponseBean.success(iTaCustomerBettingService.getById(id));
118
-//    }
120
+    /**
121
+     * 查询具体投注内容
122
+     * @param id  实体ID
123
+     */
124
+    @RequestMapping(value="/app/customer/betting/{id}",method= RequestMethod.GET)
125
+    @ApiOperation(value="依据ID查询投注详情", notes = "依据ID查询投注详情", httpMethod = "GET", response = ResponseBean.class)
126
+    public ResponseBean taCustomerBettingGet(@ApiParam("投注ID") @PathVariable Integer id) throws Exception{
127
+        Map<String, Object> result = iTaCustomerBettingService.getSummaryOf(id);
128
+        return ResponseBean.success(result);
129
+    }
119 130
 }

+ 36
- 6
src/main/java/com/yunzhi/niucai/controller/TaCustomerController.java View File

@@ -5,21 +5,20 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.niucai.common.BaseController;
7 7
 import com.yunzhi.niucai.common.ResponseBean;
8
+import com.yunzhi.niucai.common.SMSCaptcha;
9
+import com.yunzhi.niucai.common.StringUtils;
8 10
 import com.yunzhi.niucai.enums.StatusEnum;
11
+import com.yunzhi.niucai.vo.SignUpParam;
9 12
 import io.swagger.annotations.Api;
13
+import io.swagger.annotations.ApiModelProperty;
10 14
 import io.swagger.annotations.ApiOperation;
11 15
 import io.swagger.annotations.ApiParam;
12 16
 import org.slf4j.Logger;
13 17
 import org.slf4j.LoggerFactory;
14 18
 import org.springframework.beans.factory.annotation.Autowired;
15
-import org.springframework.web.bind.annotation.PathVariable;
16
-import org.springframework.web.bind.annotation.RequestBody;
17
-import org.springframework.web.bind.annotation.RequestMapping;
18
-import org.springframework.web.bind.annotation.RequestMethod;
19
-import org.springframework.web.bind.annotation.RequestParam;
19
+import org.springframework.web.bind.annotation.*;
20 20
 import com.yunzhi.niucai.service.ITaCustomerService;
21 21
 import com.yunzhi.niucai.entity.TaCustomer;
22
-import org.springframework.web.bind.annotation.RestController;
23 22
 
24 23
 import javax.servlet.http.HttpServletRequest;
25 24
 
@@ -39,9 +38,40 @@ public class TaCustomerController extends BaseController {
39 38
 
40 39
     private final Logger logger = LoggerFactory.getLogger(TaCustomerController.class);
41 40
 
41
+    @Autowired
42
+    SMSCaptcha smsCaptcha;
43
+
42 44
     @Autowired
43 45
     public ITaCustomerService iTaCustomerService;
44 46
 
47
+    @PostMapping("/app/signup")
48
+    @ApiOperation(value="APP 用户注册", notes = "APP 用户注册", httpMethod = "POST", response = ResponseBean.class)
49
+    public ResponseBean signUp(@ApiParam("注册参数") @RequestBody SignUpParam signUpParam) throws Exception {
50
+        if (null == signUpParam) {
51
+            return ResponseBean.error("请填写注册信息", ResponseBean.ERROR_ILLEGAL_PARAMS);
52
+        }
53
+
54
+        if (StringUtils.isEmpty(signUpParam.getPhone())) {
55
+            return ResponseBean.error("请填写手机号码", ResponseBean.ERROR_ILLEGAL_PARAMS);
56
+        }
57
+
58
+        if (StringUtils.isEmpty(signUpParam.getCaptcha())) {
59
+            return ResponseBean.error("请填写手机验证码", ResponseBean.ERROR_ILLEGAL_PARAMS);
60
+        }
61
+
62
+        if (StringUtils.isEmpty(signUpParam.getPassword())) {
63
+            return ResponseBean.error("请填写登录密码", ResponseBean.ERROR_ILLEGAL_PARAMS);
64
+        }
65
+
66
+        if (!smsCaptcha.validate(signUpParam.getPhone(), signUpParam.getCaptcha())) {
67
+            return ResponseBean.error("验证码无效或者已过期", ResponseBean.ERROR_ILLEGAL_PARAMS);
68
+        }
69
+
70
+        iTaCustomerService.signUp(signUpParam);
71
+
72
+        return ResponseBean.success("success");
73
+    }
74
+
45 75
 //
46 76
 //    /**
47 77
 //     * 分页查询列表

+ 119
- 0
src/main/java/com/yunzhi/niucai/controller/TaShopLotteryController.java View File

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

+ 5
- 0
src/main/java/com/yunzhi/niucai/entity/TaCustomer.java View File

@@ -74,6 +74,11 @@ public class TaCustomer implements Serializable {
74 74
      */
75 75
     private Integer recPerson;
76 76
 
77
+    /**
78
+     * 推荐码
79
+     */
80
+    private String referralCode;
81
+
77 82
     /**
78 83
      * 粉丝数
79 84
      */

+ 6
- 1
src/main/java/com/yunzhi/niucai/entity/TaCustomerBetting.java View File

@@ -1,9 +1,12 @@
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;
9
+
7 10
 import io.swagger.annotations.ApiModel;
8 11
 import io.swagger.annotations.ApiModelProperty;
9 12
 import lombok.Data;
@@ -96,5 +99,7 @@ public class TaCustomerBetting implements Serializable {
96 99
     @ApiModelProperty(value = "状态")
97 100
     private Integer status;
98 101
 
99
-
102
+    @ApiModelProperty(value = "体彩相关明细")
103
+    @TableField(exist = false)
104
+    List<TaCustomerBettingSport> bettingSports;
100 105
 }

+ 52
- 0
src/main/java/com/yunzhi/niucai/entity/TaShopLottery.java View File

@@ -0,0 +1,52 @@
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-10
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaShopLottery对象", description="店铺彩种设置")
25
+public class TaShopLottery implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "设置ID")
30
+    @TableId(value = "setting_id", type = IdType.AUTO)
31
+    private Integer settingId;
32
+
33
+    @ApiModelProperty(value = "彩种ID")
34
+    private String lotteryId;
35
+
36
+    @ApiModelProperty(value = "店铺ID")
37
+    private Integer shopId;
38
+
39
+    @ApiModelProperty(value = "是否打开")
40
+    private Boolean isOpen;
41
+
42
+    @ApiModelProperty(value = "最低出票额 单位分")
43
+    private Integer minCash;
44
+
45
+    @ApiModelProperty(value = "创建时间")
46
+    private LocalDateTime createDate;
47
+
48
+    @ApiModelProperty(value = "状态")
49
+    private Integer status;
50
+
51
+
52
+}

+ 16
- 0
src/main/java/com/yunzhi/niucai/enums/ReferralCodeEnum.java View File

@@ -0,0 +1,16 @@
1
+package com.yunzhi.niucai.enums;
2
+
3
+
4
+import lombok.AllArgsConstructor;
5
+import lombok.Getter;
6
+
7
+@Getter
8
+@AllArgsConstructor
9
+public enum ReferralCodeEnum {
10
+
11
+    CUSTOMER_START("C", "客户推荐码前缀"),
12
+    SHOP_START("S", "店铺推荐码前缀");
13
+
14
+    private String code;
15
+    private String desc;
16
+}

+ 18
- 0
src/main/java/com/yunzhi/niucai/mapper/TaShopLotteryMapper.java View File

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

+ 2
- 0
src/main/java/com/yunzhi/niucai/service/ITaBettingPlanService.java View File

@@ -15,4 +15,6 @@ import com.yunzhi.niucai.entity.TaCustomer;
15 15
 public interface ITaBettingPlanService extends IService<TaBettingPlan> {
16 16
 
17 17
     boolean betting(TaBettingPlan taBettingPlan, TaCustomer customer) throws Exception;
18
+
19
+    TaBettingPlan getDetailOfPlanById(Integer planId) throws Exception;
18 20
 }

+ 4
- 0
src/main/java/com/yunzhi/niucai/service/ITaCustomerBettingService.java View File

@@ -4,6 +4,8 @@ import com.yunzhi.niucai.entity.TaBettingPlan;
4 4
 import com.yunzhi.niucai.entity.TaCustomerBetting;
5 5
 import com.baomidou.mybatisplus.extension.service.IService;
6 6
 
7
+import java.util.Map;
8
+
7 9
 /**
8 10
  * <p>
9 11
  * 客户投注  服务类
@@ -15,4 +17,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
15 17
 public interface ITaCustomerBettingService extends IService<TaCustomerBetting> {
16 18
 
17 19
     TaCustomerBetting saveByBetting(TaBettingPlan taBettingPlan) throws Exception;
20
+
21
+    Map<String, Object> getSummaryOf(Integer id) throws Exception;
18 22
 }

+ 2
- 0
src/main/java/com/yunzhi/niucai/service/ITaCustomerService.java View File

@@ -2,6 +2,7 @@ package com.yunzhi.niucai.service;
2 2
 
3 3
 import com.yunzhi.niucai.entity.TaCustomer;
4 4
 import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.yunzhi.niucai.vo.SignUpParam;
5 6
 
6 7
 /**
7 8
  * <p>
@@ -13,4 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 14
  */
14 15
 public interface ITaCustomerService extends IService<TaCustomer> {
15 16
 
17
+    boolean signUp(SignUpParam signUpParam) throws Exception;
16 18
 }

+ 17
- 0
src/main/java/com/yunzhi/niucai/service/ITaShopLotteryService.java View File

@@ -0,0 +1,17 @@
1
+package com.yunzhi.niucai.service;
2
+
3
+import com.yunzhi.niucai.entity.TaShopLottery;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 店铺彩种设置 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2020-09-10
13
+ */
14
+public interface ITaShopLotteryService extends IService<TaShopLottery> {
15
+
16
+    TaShopLottery getSettingBy(Integer shopId, String lotteryId) throws Exception;
17
+}

+ 66
- 3
src/main/java/com/yunzhi/niucai/service/impl/TaBettingPlanServiceImpl.java View File

@@ -1,5 +1,6 @@
1 1
 package com.yunzhi.niucai.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3 4
 import com.yunzhi.niucai.common.BizUtils;
4 5
 import com.yunzhi.niucai.common.StringUtils;
5 6
 import com.yunzhi.niucai.entity.*;
@@ -14,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
14 15
 import org.springframework.stereotype.Service;
15 16
 import org.springframework.transaction.annotation.Transactional;
16 17
 
18
+import javax.xml.namespace.QName;
17 19
 import java.util.ArrayList;
18 20
 import java.util.List;
19 21
 import java.util.Map;
@@ -53,6 +55,9 @@ public class TaBettingPlanServiceImpl extends ServiceImpl<TaBettingPlanMapper, T
53 55
     @Autowired
54 56
     ITaOrderService iTaOrderService;
55 57
 
58
+    @Autowired
59
+    ITaShopLotteryService iTaShopLotteryService;
60
+
56 61
     @Autowired
57 62
     TaBettingPlanItemMapper taBettingPlanItemMapper;
58 63
 
@@ -90,6 +95,45 @@ public class TaBettingPlanServiceImpl extends ServiceImpl<TaBettingPlanMapper, T
90 95
         return true;
91 96
     }
92 97
 
98
+    @Override
99
+    public TaBettingPlan getDetailOfPlanById(Integer planId) throws Exception {
100
+        TaBettingPlan taBettingPlan = getById(planId);
101
+        if (null == taBettingPlan || StatusEnum.DELETED.getCode().equals(taBettingPlan.getStatus())) {
102
+            return null;
103
+        }
104
+
105
+        List<TaBettingPlanItem> itemList = getBettingPlanItemsByPlan(taBettingPlan);
106
+        taBettingPlan.setItemList(itemList);
107
+
108
+        if (null != itemList && taBettingPlan.getIsSport()) {
109
+            for (TaBettingPlanItem item: itemList) {
110
+                List<TaBettingPlanSportDetail> detailList = getBettingPlanSprotsByItem(item);
111
+                item.setDetailList(detailList);
112
+            }
113
+        }
114
+
115
+        return taBettingPlan;
116
+    }
117
+
118
+    private List<TaBettingPlanSportDetail> getBettingPlanSprotsByItem(TaBettingPlanItem item) throws Exception {
119
+        QueryWrapper<TaBettingPlanSportDetail> queryWrapper = new QueryWrapper<>();
120
+        queryWrapper.eq("item_no", item.getItemNo());
121
+        queryWrapper.eq("status", StatusEnum.NORMAL.getCode());
122
+        queryWrapper.orderByAsc("item_no");
123
+        queryWrapper.orderByAsc("serial_no");
124
+
125
+        return taBettingPlanSportDetailMapper.selectList(queryWrapper);
126
+    }
127
+
128
+    private List<TaBettingPlanItem> getBettingPlanItemsByPlan(TaBettingPlan taBettingPlan) throws Exception {
129
+        QueryWrapper<TaBettingPlanItem> queryWrapper = new QueryWrapper<>();
130
+        queryWrapper.eq("plan_id", taBettingPlan.getPlanId());
131
+        queryWrapper.eq("status", StatusEnum.NORMAL.getCode());
132
+        queryWrapper.orderByAsc("item_no");
133
+
134
+        return taBettingPlanItemMapper.selectList(queryWrapper);
135
+    }
136
+
93 137
     private void validateShop(TaBettingPlan taBettingPlan) throws Exception {
94 138
         if (null == taBettingPlan.getShopId()) {
95 139
             throw new Exception("请选择投注店铺");
@@ -106,6 +150,25 @@ public class TaBettingPlanServiceImpl extends ServiceImpl<TaBettingPlanMapper, T
106 150
         }
107 151
 
108 152
         taBettingPlan.setShopName(taShop.getName());
153
+
154
+        // 店铺彩种
155
+        TaShopLottery taShopLottery = iTaShopLotteryService.getSettingBy(taBettingPlan.getShopId(), taBettingPlan.getLotteryId());
156
+        if (null == taShopLottery) {
157
+            throw new Exception("当前店铺没有相关彩种设置");
158
+        }
159
+
160
+        if (null == taShopLottery.getIsOpen() && !taShopLottery.getIsOpen()) {
161
+            throw new Exception("店铺没有开售当前彩种");
162
+        }
163
+
164
+        // 出票额限制
165
+        if (null != taShopLottery.getMinCash()) {
166
+            if (taBettingPlan.getTotalPrice() < taShopLottery.getMinCash()) {
167
+                throw new Exception("出票额不能低于 " + String.format(".2f", taShopLottery.getMinCash() / 100) + "元");
168
+            }
169
+        }
170
+
171
+        return;
109 172
     }
110 173
 
111 174
     private void validateBetting(TaBettingPlan taBettingPlan) throws Exception {
@@ -124,9 +187,6 @@ public class TaBettingPlanServiceImpl extends ServiceImpl<TaBettingPlanMapper, T
124 187
         // 校验彩种
125 188
         validateLottery(taBettingPlan, tdLottery);
126 189
 
127
-        //
128
-        validateShop(taBettingPlan);
129
-
130 190
         // 校验明细
131 191
         if (null == taBettingPlan.getItemList()) {
132 192
             throw new Exception("请设置投注内容");
@@ -209,6 +269,9 @@ public class TaBettingPlanServiceImpl extends ServiceImpl<TaBettingPlanMapper, T
209 269
             }
210 270
         }
211 271
 
272
+        // 校验店铺, 放到最后, 因为有金额校验
273
+        validateShop(taBettingPlan);
274
+
212 275
         return;
213 276
     }
214 277
 

+ 40
- 0
src/main/java/com/yunzhi/niucai/service/impl/TaCustomerBettingServiceImpl.java View File

@@ -1,15 +1,21 @@
1 1
 package com.yunzhi.niucai.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3 4
 import com.yunzhi.niucai.entity.*;
4 5
 import com.yunzhi.niucai.enums.StatusEnum;
5 6
 import com.yunzhi.niucai.mapper.TaCustomerBettingMapper;
6 7
 import com.yunzhi.niucai.mapper.TaCustomerBettingSportMapper;
8
+import com.yunzhi.niucai.service.ITaBettingPlanService;
7 9
 import com.yunzhi.niucai.service.ITaCustomerBettingService;
8 10
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9 11
 import org.springframework.beans.factory.annotation.Autowired;
10 12
 import org.springframework.stereotype.Service;
11 13
 import org.springframework.transaction.annotation.Transactional;
12 14
 
15
+import java.util.HashMap;
16
+import java.util.List;
17
+import java.util.Map;
18
+
13 19
 /**
14 20
  * <p>
15 21
  * 客户投注  服务实现类
@@ -21,9 +27,13 @@ import org.springframework.transaction.annotation.Transactional;
21 27
 @Service
22 28
 public class TaCustomerBettingServiceImpl extends ServiceImpl<TaCustomerBettingMapper, TaCustomerBetting> implements ITaCustomerBettingService {
23 29
 
30
+    @Autowired
31
+    ITaBettingPlanService iTaBettingPlanService;
32
+
24 33
     @Autowired
25 34
     TaCustomerBettingSportMapper taCustomerBettingSportMapper;
26 35
 
36
+
27 37
     @Override
28 38
     @Transactional(rollbackFor = Exception.class)
29 39
     public TaCustomerBetting saveByBetting(TaBettingPlan plan) throws Exception {
@@ -74,4 +84,34 @@ public class TaCustomerBettingServiceImpl extends ServiceImpl<TaCustomerBettingM
74 84
 
75 85
         return taCustomerBetting;
76 86
     }
87
+
88
+    @Override
89
+    public Map<String, Object> getSummaryOf(Integer id) throws Exception {
90
+        TaCustomerBetting betting = getById(id);
91
+        if (null == betting || StatusEnum.DELETED.getCode().equals(betting.getStatus())) {
92
+            throw new Exception("数据不存在, 投注ID不正确");
93
+        }
94
+
95
+        // 查询明细
96
+        List<TaCustomerBettingSport> bettingSports = getBettingSportByBetting(betting);
97
+        betting.setBettingSports(bettingSports);
98
+
99
+        // 查询方案
100
+        TaBettingPlan taBettingPlan = iTaBettingPlanService.getDetailOfPlanById(betting.getPlanId());
101
+
102
+        Map<String, Object> result = new HashMap<>();
103
+        result.put("betting", betting);
104
+        result.put("plan", taBettingPlan);
105
+
106
+        return result;
107
+    }
108
+
109
+    private List<TaCustomerBettingSport> getBettingSportByBetting(TaCustomerBetting betting) throws Exception {
110
+        QueryWrapper<TaCustomerBettingSport> queryWrapper = new QueryWrapper<>();
111
+        queryWrapper.eq("betting_id", betting.getBettingId());
112
+        queryWrapper.eq("status", StatusEnum.NORMAL.getCode());
113
+        queryWrapper.orderByAsc("serial_no");
114
+
115
+        return taCustomerBettingSportMapper.selectList(queryWrapper);
116
+    }
77 117
 }

+ 41
- 0
src/main/java/com/yunzhi/niucai/service/impl/TaCustomerServiceImpl.java View File

@@ -1,10 +1,16 @@
1 1
 package com.yunzhi.niucai.service.impl;
2 2
 
3
+import com.yunzhi.niucai.common.EncryptUtils;
4
+import com.yunzhi.niucai.common.StringUtils;
3 5
 import com.yunzhi.niucai.entity.TaCustomer;
6
+import com.yunzhi.niucai.enums.ReferralCodeEnum;
7
+import com.yunzhi.niucai.enums.StatusEnum;
4 8
 import com.yunzhi.niucai.mapper.TaCustomerMapper;
5 9
 import com.yunzhi.niucai.service.ITaCustomerService;
6 10
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
11
+import com.yunzhi.niucai.vo.SignUpParam;
7 12
 import org.springframework.stereotype.Service;
13
+import org.springframework.transaction.annotation.Transactional;
8 14
 
9 15
 /**
10 16
  * <p>
@@ -17,4 +23,39 @@ import org.springframework.stereotype.Service;
17 23
 @Service
18 24
 public class TaCustomerServiceImpl extends ServiceImpl<TaCustomerMapper, TaCustomer> implements ITaCustomerService {
19 25
 
26
+    @Override
27
+    @Transactional(rollbackFor = Exception.class)
28
+    public boolean signUp(SignUpParam signUpParam) throws Exception {
29
+        TaCustomer taCustomer = new TaCustomer();
30
+        taCustomer.setName(signUpParam.getName());
31
+        taCustomer.setPhone(signUpParam.getPhone());
32
+        taCustomer.setReferralCode(signUpParam.getReferralCode());
33
+        taCustomer.setStatus(StatusEnum.NORMAL.getCode());
34
+
35
+        if (!save(taCustomer)) {
36
+            throw new Exception("生成个人信息失败");
37
+        }
38
+
39
+        // 获取最新信息, 因为有部分字段是自动生成的
40
+        taCustomer = getById(taCustomer.getCustomerId());
41
+
42
+        // 更新推荐人或者店铺
43
+        if (!StringUtils.isEmpty(signUpParam.getReferralCode())) {
44
+            // C 开头说明是客户
45
+            if (signUpParam.getReferralCode().startsWith(ReferralCodeEnum.CUSTOMER_START.getCode())) {
46
+
47
+            }
48
+
49
+            // S 开头说明是店铺
50
+        }
51
+
52
+        // 更新密码
53
+        taCustomer.setLoginPass(EncryptUtils.md5(signUpParam.getPassword(), taCustomer.getCustomerId().toString()));
54
+
55
+        if (!updateById(taCustomer)) {
56
+            throw new Exception("生成个人信息失败");
57
+        }
58
+
59
+        return true;
60
+    }
20 61
 }

+ 31
- 0
src/main/java/com/yunzhi/niucai/service/impl/TaShopLotteryServiceImpl.java View File

@@ -0,0 +1,31 @@
1
+package com.yunzhi.niucai.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.yunzhi.niucai.entity.TaShopLottery;
5
+import com.yunzhi.niucai.enums.StatusEnum;
6
+import com.yunzhi.niucai.mapper.TaShopLotteryMapper;
7
+import com.yunzhi.niucai.service.ITaShopLotteryService;
8
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
+import org.springframework.stereotype.Service;
10
+
11
+/**
12
+ * <p>
13
+ * 店铺彩种设置 服务实现类
14
+ * </p>
15
+ *
16
+ * @author yansen
17
+ * @since 2020-09-10
18
+ */
19
+@Service
20
+public class TaShopLotteryServiceImpl extends ServiceImpl<TaShopLotteryMapper, TaShopLottery> implements ITaShopLotteryService {
21
+
22
+    @Override
23
+    public TaShopLottery getSettingBy(Integer shopId, String lotteryId) throws Exception {
24
+        QueryWrapper<TaShopLottery> queryWrapper = new QueryWrapper<>();
25
+        queryWrapper.eq("lottery_id", lotteryId);
26
+        queryWrapper.eq("shop_id", shopId);
27
+        queryWrapper.eq("status", StatusEnum.NORMAL.getCode());
28
+
29
+        return getOne(queryWrapper);
30
+    }
31
+}

+ 25
- 0
src/main/java/com/yunzhi/niucai/vo/SignUpParam.java View File

@@ -0,0 +1,25 @@
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 SignUpParam {
11
+    @ApiModelProperty("用户名")
12
+    String name;
13
+
14
+    @ApiModelProperty("密码, MD5 加密后数据")
15
+    String password;
16
+
17
+    @ApiModelProperty("手机")
18
+    String phone;
19
+
20
+    @ApiModelProperty("验证码")
21
+    String captcha;
22
+
23
+    @ApiModelProperty("推荐码")
24
+    String referralCode;
25
+}

+ 9
- 0
src/main/resources/application-dev.yml View File

@@ -10,3 +10,12 @@ logging:
10 10
   level:
11 11
     root: info
12 12
     springfox: info
13
+
14
+###
15
+#sms:
16
+#  api: http://101.200.84.17:8081/sms
17
+#  captcha:
18
+#    code: "0301"
19
+#    sign: 牛彩
20
+#    # 有效时间 单位秒
21
+#    expire: 300

+ 10
- 1
src/main/resources/application.yml View File

@@ -9,7 +9,7 @@ interceptor:
9 9
   permission:
10 10
     enable: true
11 11
     include-paths: /**
12
-    exclude-paths: /app/login, /app/logout,/swagger-ui/**,/swagger-resources/**,/v2/**
12
+    exclude-paths: /app/login, /app/logout, /app/signup, /swagger-ui/**,/swagger-resources/**,/v2/**
13 13
 
14 14
 ###
15 15
 mybatis-plus:
@@ -36,6 +36,15 @@ weixin:
36 36
     aesKey:
37 37
     msgDataFormat: JSON
38 38
 
39
+###
40
+sms:
41
+  api: http://micservice.ycjcjy.com/sms
42
+  captcha:
43
+    code: "0301"
44
+    sign: 牛彩
45
+    # 有效时间 单位秒
46
+    expire: 300
47
+
39 48
 ###
40 49
 spring:
41 50
   application:

+ 5
- 0
src/main/resources/mapper/TaShopLotteryMapper.xml View File

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