张延森 hace 4 años
padre
commit
958e336110
Se han modificado 36 ficheros con 777 adiciones y 53 borrados
  1. 1
    1
      pom.xml
  2. 46
    3
      src/main/java/com/yunzhi/niucai/alipay/AliPayService.java
  3. 29
    4
      src/main/java/com/yunzhi/niucai/alipay/AlipayFactory.java
  4. 52
    0
      src/main/java/com/yunzhi/niucai/alipay/vo/AliPayFundTransParam.java
  5. 14
    0
      src/main/java/com/yunzhi/niucai/common/StringUtils.java
  6. 1
    1
      src/main/java/com/yunzhi/niucai/controller/PayController.java
  7. 84
    2
      src/main/java/com/yunzhi/niucai/controller/TaAlipayController.java
  8. 35
    17
      src/main/java/com/yunzhi/niucai/controller/TaCustomerController.java
  9. 22
    0
      src/main/java/com/yunzhi/niucai/controller/TaShopController.java
  10. 119
    0
      src/main/java/com/yunzhi/niucai/controller/TaShopkeeperThirdController.java
  11. 8
    0
      src/main/java/com/yunzhi/niucai/entity/TaCustomer.java
  12. 5
    2
      src/main/java/com/yunzhi/niucai/entity/TaCustomerBetting.java
  13. 1
    1
      src/main/java/com/yunzhi/niucai/entity/TaCustomerBettingSport.java
  14. 5
    0
      src/main/java/com/yunzhi/niucai/entity/TaShop.java
  15. 10
    0
      src/main/java/com/yunzhi/niucai/entity/TaShopkeeper.java
  16. 58
    0
      src/main/java/com/yunzhi/niucai/entity/TaShopkeeperThird.java
  17. 3
    3
      src/main/java/com/yunzhi/niucai/entity/TdCity.java
  18. 9
    0
      src/main/java/com/yunzhi/niucai/mapper/TaShopMapper.java
  19. 18
    0
      src/main/java/com/yunzhi/niucai/mapper/TaShopkeeperThirdMapper.java
  20. 2
    0
      src/main/java/com/yunzhi/niucai/service/ITaOrderService.java
  21. 6
    0
      src/main/java/com/yunzhi/niucai/service/ITaShopService.java
  22. 2
    0
      src/main/java/com/yunzhi/niucai/service/ITaShopkeeperService.java
  23. 18
    0
      src/main/java/com/yunzhi/niucai/service/ITaShopkeeperThirdService.java
  24. 1
    1
      src/main/java/com/yunzhi/niucai/service/ITdCityService.java
  25. 17
    1
      src/main/java/com/yunzhi/niucai/service/impl/TaCustomerBettingServiceImpl.java
  26. 1
    1
      src/main/java/com/yunzhi/niucai/service/impl/TaMatchServiceImpl.java
  27. 14
    2
      src/main/java/com/yunzhi/niucai/service/impl/TaOrderServiceImpl.java
  28. 81
    11
      src/main/java/com/yunzhi/niucai/service/impl/TaShopServiceImpl.java
  29. 21
    0
      src/main/java/com/yunzhi/niucai/service/impl/TaShopkeeperServiceImpl.java
  30. 36
    0
      src/main/java/com/yunzhi/niucai/service/impl/TaShopkeeperThirdServiceImpl.java
  31. 7
    3
      src/main/java/com/yunzhi/niucai/service/impl/TdCityServiceImpl.java
  32. 14
    0
      src/main/java/com/yunzhi/niucai/vo/AlipayAuthUser.java
  33. 19
    0
      src/main/java/com/yunzhi/niucai/vo/ShopValidParam.java
  34. 2
    0
      src/main/resources/application.yml
  35. 11
    0
      src/main/resources/mapper/TaShopMapper.xml
  36. 5
    0
      src/main/resources/mapper/TaShopkeeperThirdMapper.xml

+ 1
- 1
pom.xml Ver fichero

@@ -10,7 +10,7 @@
10 10
 	</parent>
11 11
 	<groupId>com.yunzhi</groupId>
12 12
 	<artifactId>niucai-app</artifactId>
13
-	<version>0.0.3</version>
13
+	<version>0.0.4</version>
14 14
 	<name>niucai</name>
15 15
 	<description>Demo project for Spring Boot</description>
16 16
 

+ 46
- 3
src/main/java/com/yunzhi/niucai/alipay/AliPayService.java Ver fichero

@@ -4,11 +4,14 @@ package com.yunzhi.niucai.alipay;
4 4
 import com.alibaba.fastjson.JSONObject;
5 5
 import com.alipay.api.AlipayApiException;
6 6
 import com.alipay.api.AlipayClient;
7
+import com.alipay.api.request.AlipayFundTransUniTransferRequest;
7 8
 import com.alipay.api.request.AlipayOpenAuthTokenAppRequest;
8 9
 import com.alipay.api.request.AlipayTradeAppPayRequest;
10
+import com.alipay.api.response.AlipayFundTransUniTransferResponse;
9 11
 import com.alipay.api.response.AlipayOpenAuthTokenAppResponse;
10 12
 import com.alipay.api.response.AlipayTradeAppPayResponse;
11 13
 import com.yunzhi.niucai.alipay.vo.AliPayParam;
14
+import com.yunzhi.niucai.alipay.vo.AliPayFundTransParam;
12 15
 import lombok.extern.slf4j.Slf4j;
13 16
 
14 17
 import java.util.HashMap;
@@ -70,9 +73,49 @@ public class AliPayService {
70 73
         }
71 74
     }
72 75
 
73
-    public String getCallbackURL(AlipayTradeAppPayResponse response) {
74
-        // todo
75
-        return null;
76
+    /**
77
+     * 支付宝转账
78
+     * https://opendocs.alipay.com/apis/api_28/alipay.fund.trans.uni.transfer
79
+     * @param fundTransParam
80
+     * @return
81
+     * @throws Exception
82
+     */
83
+    public boolean FundTrans(AliPayFundTransParam fundTransParam) throws Exception {
84
+        AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest();
85
+
86
+        if (null == fundTransParam) {
87
+            throw new Exception("未找到有效转账信息");
88
+        }
89
+
90
+        if (null == fundTransParam.getPayeeInfo()) {
91
+            throw new Exception("未找到有效转账收款方信息");
92
+        }
93
+
94
+        if (null == fundTransParam.getProductCode()) {
95
+            fundTransParam.setProductCode("TRANS_ACCOUNT_NO_PWD");
96
+        }
97
+
98
+        if (null == fundTransParam.getPayeeInfo().getIdentityType()) {
99
+            fundTransParam.getPayeeInfo().setIdentityType("ALIPAY_LOGON_ID");
100
+        }
101
+
102
+        String content = JSONObject.toJSONString(fundTransParam);
103
+        request.setBizContent(content);
104
+
105
+        try {
106
+            AlipayFundTransUniTransferResponse response = alipayClient.execute(request);
107
+            if (response.isSuccess()) {
108
+                return true;
109
+            } else {
110
+                log.error("支付转账提现失败: [{}]:{} \n\t[{}]:{}", response.getCode(), response.getMsg(), response.getSubCode(), response.getSubMsg());
111
+                throw new Exception(String.format("支付转账提现失败: %s", response.getSubMsg()));
112
+            }
113
+        } catch (AlipayApiException e) {
114
+            log.error("支付转账提现失败: {}", e.getErrMsg());
115
+            log.error("失败明细: {}", content);
116
+            e.printStackTrace();
117
+            throw e;
118
+        }
76 119
     }
77 120
 
78 121
     /**

+ 29
- 4
src/main/java/com/yunzhi/niucai/alipay/AlipayFactory.java Ver fichero

@@ -1,16 +1,20 @@
1 1
 package com.yunzhi.niucai.alipay;
2 2
 
3
+import com.alipay.api.AlipayApiException;
3 4
 import com.alipay.api.AlipayClient;
4 5
 import com.alipay.api.DefaultAlipayClient;
6
+import com.alipay.api.request.AlipaySystemOauthTokenRequest;
7
+import com.alipay.api.response.AlipaySystemOauthTokenResponse;
5 8
 import com.yunzhi.niucai.entity.TaAlipay;
6 9
 import com.yunzhi.niucai.service.ITaAlipayService;
7
-import com.yunzhi.niucai.service.ITaShopAppService;
10
+import lombok.extern.slf4j.Slf4j;
8 11
 import org.springframework.beans.factory.InitializingBean;
9 12
 import org.springframework.beans.factory.annotation.Autowired;
10 13
 import org.springframework.stereotype.Component;
11 14
 
12 15
 import javax.annotation.Resource;
13 16
 
17
+@Slf4j
14 18
 @Component
15 19
 public class AlipayFactory implements InitializingBean {
16 20
     private AlipayClient alipayClient;
@@ -21,9 +25,6 @@ public class AlipayFactory implements InitializingBean {
21 25
     @Autowired
22 26
     private Config config;
23 27
 
24
-    @Autowired
25
-    ITaShopAppService iTaShopAppService;
26
-
27 28
     @Autowired
28 29
     ITaAlipayService iTaAlipayService;
29 30
 
@@ -41,6 +42,30 @@ public class AlipayFactory implements InitializingBean {
41 42
                 config.getSignType());
42 43
     }
43 44
 
45
+    public String getAppID() {
46
+        return config.getAppid();
47
+    }
48
+
49
+    /**
50
+     * 获取授权用户ID
51
+     * @param authCode
52
+     * @return
53
+     * @throws Exception
54
+     */
55
+    public String getUserId(String authCode) throws Exception {
56
+        AlipaySystemOauthTokenRequest oauthTokenRequest = new AlipaySystemOauthTokenRequest();
57
+        oauthTokenRequest.setCode(authCode);
58
+        oauthTokenRequest.setGrantType("authorization_code");
59
+        try {
60
+            AlipaySystemOauthTokenResponse oauthTokenResponse = alipayClient.execute(oauthTokenRequest);
61
+            return oauthTokenResponse.getUserId();
62
+        } catch (AlipayApiException e) {
63
+            log.error("授权支付宝用户信息失败: {}", e.getErrMsg());
64
+            e.printStackTrace();
65
+            throw e;
66
+        }
67
+    }
68
+
44 69
     @Override
45 70
     public void afterPropertiesSet() throws Exception {
46 71
         // 写死, 取第一个

+ 52
- 0
src/main/java/com/yunzhi/niucai/alipay/vo/AliPayFundTransParam.java Ver fichero

@@ -0,0 +1,52 @@
1
+package com.yunzhi.niucai.alipay.vo;
2
+
3
+
4
+import com.alibaba.fastjson.annotation.JSONField;
5
+import io.swagger.annotations.ApiModel;
6
+import io.swagger.annotations.ApiModelProperty;
7
+import lombok.Data;
8
+import lombok.experimental.Accessors;
9
+
10
+@ApiModel(description = "支付宝转账参数")
11
+@Data
12
+@Accessors(chain = true)
13
+public class AliPayFundTransParam {
14
+
15
+    @ApiModelProperty("商户端的唯一订单号")
16
+    @JSONField(name = "out_biz_no")
17
+    String outBizNO;
18
+
19
+    @ApiModelProperty("订单总金额,单位为元,精确到小数点后两位")
20
+    @JSONField(name = "trans_amount")
21
+    Float transAmount;
22
+
23
+    @ApiModelProperty("业务产品码")
24
+    @JSONField(name = "product_code")
25
+    String productCode;
26
+
27
+    @ApiModelProperty("转账业务的标题,用于在支付宝用户的账单里显示")
28
+    @JSONField(name = "order_title")
29
+    String orderTitle;
30
+
31
+    @ApiModelProperty("收款方信息")
32
+    @JSONField(name = "payee_info")
33
+    PayeeInfo payeeInfo;
34
+
35
+    @ApiModel(description = "支付宝转账收款方信息")
36
+    @Data
37
+    @Accessors(chain = true)
38
+    public static class PayeeInfo {
39
+
40
+        @ApiModelProperty("唯一标识")
41
+        @JSONField(name = "identity")
42
+        String identity;
43
+
44
+        @ApiModelProperty("标识类型: 1 ALIPAY_USER_ID 支付宝的会员ID, 2 ALIPAY_LOGON_ID 支付宝登录号 ")
45
+        @JSONField(name = "identity_type")
46
+        String identityType;
47
+
48
+        @ApiModelProperty("真实姓名")
49
+        @JSONField(name = "name")
50
+        String name;
51
+    }
52
+}

+ 14
- 0
src/main/java/com/yunzhi/niucai/common/StringUtils.java Ver fichero

@@ -117,4 +117,18 @@ public class StringUtils {
117 117
         prefix = prefix.substring(0, padLen);
118 118
         return prefix + src;
119 119
     }
120
+
121
+    public static boolean isNumeric(String str) {
122
+        if (isEmpty(str)) {
123
+            return false;
124
+        }
125
+
126
+        try {
127
+            Double.parseDouble(str.trim());
128
+        } catch (Exception e) {
129
+            return false;
130
+        }
131
+
132
+        return true;
133
+    }
120 134
 }

+ 1
- 1
src/main/java/com/yunzhi/niucai/controller/PayController.java Ver fichero

@@ -93,7 +93,7 @@ public class PayController extends BaseController {
93 93
                 return ResponseBean.error("生成支付宝交易失败", ResponseBean.ERROR_UNAVAILABLE);
94 94
             }
95 95
 
96
-            taOrderPay.setH5CallbackUrl(aliPayService.getCallbackURL(response));
96
+//            taOrderPay.setH5CallbackUrl(aliPayService.getCallbackURL(response));
97 97
         } else {
98 98
             // 微信支付
99 99
             WxPayParam wxPayParam = new WxPayParam()

+ 84
- 2
src/main/java/com/yunzhi/niucai/controller/TaAlipayController.java Ver fichero

@@ -1,15 +1,29 @@
1 1
 package com.yunzhi.niucai.controller;
2 2
 
3
+import com.alibaba.fastjson.JSONObject;
3 4
 import com.alipay.api.AlipayApiException;
4 5
 import com.yunzhi.niucai.alipay.AlipayFactory;
5 6
 import com.yunzhi.niucai.alipay.AliPayService;
6 7
 import com.yunzhi.niucai.common.BaseController;
8
+import com.yunzhi.niucai.common.ResponseBean;
9
+import com.yunzhi.niucai.common.StringUtils;
10
+import com.yunzhi.niucai.entity.TaShop;
11
+import com.yunzhi.niucai.entity.TaShopkeeper;
12
+import com.yunzhi.niucai.enums.StatusEnum;
13
+import com.yunzhi.niucai.service.ITaShopService;
14
+import com.yunzhi.niucai.service.ITaShopkeeperService;
15
+import com.yunzhi.niucai.vo.AlipayAuthUser;
16
+import com.yunzhi.niucai.vo.SportDicts;
7 17
 import io.swagger.annotations.Api;
18
+import io.swagger.annotations.ApiOperation;
19
+import lombok.extern.slf4j.Slf4j;
8 20
 import org.slf4j.Logger;
9 21
 import org.slf4j.LoggerFactory;
10 22
 import org.springframework.beans.factory.annotation.Autowired;
11 23
 import org.springframework.web.bind.annotation.*;
12 24
 
25
+import javax.servlet.http.HttpServletRequest;
26
+
13 27
 /**
14 28
  * <p>
15 29
     *  前端控制器
@@ -19,16 +33,51 @@ import org.springframework.web.bind.annotation.*;
19 33
  * @since 2020-09-27
20 34
  */
21 35
 
36
+@Slf4j
22 37
 @Api(tags = "")
23 38
 @RestController
24 39
 @RequestMapping("/")
25 40
 public class TaAlipayController extends BaseController {
26 41
 
27
-    private final Logger logger = LoggerFactory.getLogger(TaAlipayController.class);
28
-
29 42
     @Autowired
30 43
     private AlipayFactory alipayFactory;
31 44
 
45
+    @Autowired
46
+    private ITaShopService iTaShopService;
47
+
48
+    @Autowired
49
+    private ITaShopkeeperService iTaShopkeeperService;
50
+
51
+    @GetMapping("/shop/alipay/appid")
52
+    @ApiOperation(value="获取平台支付宝应用AppID", notes = "获取平台支付宝应用AppID", httpMethod = "GET", response = SportDicts.class)
53
+    public ResponseBean getPlatAppID() {
54
+        return ResponseBean.success(alipayFactory.getAppID());
55
+    }
56
+
57
+    @PostMapping("/shop/alipay/auth/user")
58
+    @ApiOperation(value="绑定支付宝用户", notes = "绑定支付宝用户", httpMethod = "GET", response = SportDicts.class)
59
+    public ResponseBean authUser(@RequestBody AlipayAuthUser alipayAuthUser,
60
+                                 HttpServletRequest request) throws Exception {
61
+        if (null == alipayAuthUser || StringUtils.isEmpty(alipayAuthUser.getAuthCode())) {
62
+            return ResponseBean.error("未设置授权码", ResponseBean.ERROR_MISSING_PARAMS);
63
+        }
64
+
65
+        TaShopkeeper taShopkeeper = getShopKeeper(request);
66
+        if (null == taShopkeeper || StatusEnum.DELETED.getCode().equals(taShopkeeper.getStatus())) {
67
+            return ResponseBean.error("账户登录状态异常, 请重新登录", ResponseBean.ERROR_UNAVAILABLE);
68
+        }
69
+
70
+        String aliUserId = alipayFactory.getUserId(alipayAuthUser.getAuthCode());
71
+        boolean b = iTaShopkeeperService.bindThirdPartId(taShopkeeper, aliUserId, "ali");
72
+
73
+        if (b) {
74
+            taShopkeeper.setIsValidAli(true);
75
+            iTaShopkeeperService.updateById(taShopkeeper);
76
+        }
77
+
78
+        return b ? ResponseBean.success("success") : ResponseBean.error("授权用户失败", ResponseBean.ERROR_UNAVAILABLE);
79
+    }
80
+
32 81
     /**
33 82
      * 应用授权成功回调
34 83
      * @param appId
@@ -42,4 +91,37 @@ public class TaAlipayController extends BaseController {
42 91
         AliPayService payService = alipayFactory.getService(-1);
43 92
         payService.persistToken(appAuthCode);
44 93
     }
94
+
95
+    @GetMapping("/app/callback/alipay")
96
+    public void aliPayCallback(@RequestParam("app_id") String appId,
97
+                               @RequestParam("msg_app_id") String shopAppId,
98
+                               @RequestParam("msg_method") String msgMethod,
99
+                               @RequestParam("biz_content") String content,
100
+                               HttpServletRequest request) {
101
+
102
+        // 转账结果提醒
103
+        if ("alipay.fund.trans.order.changed".equals(msgMethod)) {
104
+            try {
105
+                JSONObject transRes = JSONObject.parseObject(content);
106
+                String actionType = transRes.getString("action_type");
107
+                if (StringUtils.isEmpty(actionType)) {
108
+                    log.error("解析转账结果提醒失败: 内容【{}】", content);
109
+                    return;
110
+                }
111
+
112
+                // 支付宝有 CREATE-创建, FINISH- 订单处理已完结, CLOSE-超时关闭
113
+                // 三种提醒
114
+                if (!"CREATE".equals(actionType)) {
115
+                    String outBizNO = transRes.getString("out_biz_no");
116
+                    String status = transRes.getString("status");
117
+                    String payDate = transRes.getString("pay_date");
118
+
119
+                }
120
+
121
+            } catch (Exception e) {
122
+                log.error("解析转账结果提醒失败: {}", e.getMessage());
123
+                e.printStackTrace();
124
+            }
125
+        }
126
+    }
45 127
 }

+ 35
- 17
src/main/java/com/yunzhi/niucai/controller/TaCustomerController.java Ver fichero

@@ -154,23 +154,41 @@ public class TaCustomerController extends BaseController {
154 154
 //        }
155 155
 //    }
156 156
 //
157
-//    /**
158
-//     * 修改对象
159
-//     * @param id  实体ID
160
-//     * @param taCustomer 实体对象
161
-//     * @return
162
-//     */
163
-//    @RequestMapping(value="/taCustomer/{id}",method= RequestMethod.PUT)
164
-//    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
165
-//    public ResponseBean taCustomerUpdate(@ApiParam("对象ID") @PathVariable Integer id,
166
-//                                        @ApiParam("更新内容") @RequestBody TaCustomer taCustomer) throws Exception{
167
-//
168
-//        if (iTaCustomerService.updateById(taCustomer)){
169
-//            return ResponseBean.success(iTaCustomerService.getById(id));
170
-//        }else {
171
-//            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
172
-//        }
173
-//    }
157
+    /**
158
+     * 修改对象
159
+     * @param id  实体ID
160
+     * @param taCustomer 实体对象
161
+     * @return
162
+     */
163
+    @RequestMapping(value="/app/customer/{id}",method= RequestMethod.PUT)
164
+    @ApiOperation(value="更新客户信息", notes = "更新客户信息", httpMethod = "PUT", response = ResponseBean.class)
165
+    public ResponseBean taCustomerUpdate(@ApiParam("当前客户ID") @PathVariable Integer id,
166
+                                         @ApiParam("更新内容") @RequestBody TaCustomer taCustomer,
167
+                                         HttpServletRequest request) throws Exception{
168
+        TaCustomer customer = getCustomer(request);
169
+        if (null == customer || StatusEnum.DELETED.getCode().equals(customer.getStatus())) {
170
+            return ResponseBean.error("校验登录状态出错, 请重新登录", ResponseBean.ERROR_UNAVAILABLE);
171
+        }
172
+
173
+        if (!customer.getCustomerId().equals(id)) {
174
+            return ResponseBean.error("不支持更新非当前人员", ResponseBean.ERROR_ILLEGAL_PARAMS);
175
+        }
176
+
177
+        customer.setAvatar(taCustomer.getAvatar());
178
+        customer.setPhone(taCustomer.getPhone());
179
+        customer.setName(taCustomer.getName());
180
+//        customer.setRealName(taCustomer.getRealName());
181
+        customer.setAlipayUser(taCustomer.getAlipayUser());
182
+
183
+        if (iTaCustomerService.updateById(customer)){
184
+            customer = iTaCustomerService.getById(id);
185
+            customer.setCashPass(null);
186
+            customer.setLoginPass(null);
187
+            return ResponseBean.success(customer);
188
+        }else {
189
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
190
+        }
191
+    }
174 192
 
175 193
     /**
176 194
      * 根据id查询对象

+ 22
- 0
src/main/java/com/yunzhi/niucai/controller/TaShopController.java Ver fichero

@@ -8,6 +8,7 @@ import com.yunzhi.niucai.common.ResponseBean;
8 8
 import com.yunzhi.niucai.entity.TaCustomer;
9 9
 import com.yunzhi.niucai.entity.TaShopkeeper;
10 10
 import com.yunzhi.niucai.enums.StatusEnum;
11
+import com.yunzhi.niucai.vo.ShopValidParam;
11 12
 import io.swagger.annotations.Api;
12 13
 import io.swagger.annotations.ApiOperation;
13 14
 import io.swagger.annotations.ApiParam;
@@ -55,6 +56,27 @@ public class TaShopController extends BaseController {
55 56
         return ResponseBean.success(result);
56 57
     }
57 58
 
59
+
60
+    @PutMapping("/app/shop/valid")
61
+    @ApiOperation(value = "认证店铺", notes = "认证店铺", httpMethod = "GET", response = ResponseBean.class)
62
+    public ResponseBean updateValidInfo(@RequestBody ShopValidParam shopValidParam,
63
+                                      HttpServletRequest request) throws Exception {
64
+        if (null == shopValidParam || null == shopValidParam.getShop() || null == shopValidParam.getShopkeeper() ) {
65
+            return ResponseBean.error("请设置店铺认证参数", ResponseBean.ERROR_MISSING_PARAMS);
66
+        }
67
+
68
+        TaShopkeeper taShopkeeper = getShopKeeper(request);
69
+        if (null == taShopkeeper || StatusEnum.DELETED.getCode().equals(taShopkeeper.getStatus())) {
70
+            return ResponseBean.error("当前账户登录状态异常, 请重新登录", ResponseBean.ERROR_MISSING_PARAMS);
71
+        }
72
+
73
+        TaShop taShop = iTaShopService.getProfileBy(taShopkeeper);
74
+
75
+        // 仅替换目前支持的字段
76
+        ShopValidParam updatedValidInfo = iTaShopService.updateValidInfo(shopValidParam, taShop, taShopkeeper);
77
+        return ResponseBean.success(updatedValidInfo);
78
+    }
79
+
58 80
 //    /**
59 81
 //     * 分页查询列表
60 82
 //     * @param pageNum

+ 119
- 0
src/main/java/com/yunzhi/niucai/controller/TaShopkeeperThirdController.java Ver fichero

@@ -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.ITaShopkeeperThirdService;
20
+import com.yunzhi.niucai.entity.TaShopkeeperThird;
21
+import org.springframework.web.bind.annotation.RestController;
22
+
23
+/**
24
+ * <p>
25
+    * 店主的第三方账号  前端控制器
26
+    * </p>
27
+ *
28
+ * @author yansen
29
+ * @since 2020-10-10
30
+ */
31
+
32
+@Api(tags = "店主的第三方账号 ")
33
+@RestController
34
+@RequestMapping("/")
35
+public class TaShopkeeperThirdController extends BaseController {
36
+
37
+    private final Logger logger = LoggerFactory.getLogger(TaShopkeeperThirdController.class);
38
+
39
+    @Autowired
40
+    public ITaShopkeeperThirdService iTaShopkeeperThirdService;
41
+
42
+//
43
+//    /**
44
+//     * 分页查询列表
45
+//     * @param pageNum
46
+//     * @param pageSize
47
+//     * @return
48
+//     */
49
+//    @RequestMapping(value="/taShopkeeperThird",method= RequestMethod.GET)
50
+//    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
+//    public ResponseBean taShopkeeperThirdList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
+//									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
+//
54
+//		    IPage<TaShopkeeperThird> pg = new Page<>(pageNum, pageSize);
55
+//            QueryWrapper<TaShopkeeperThird> queryWrapper = new QueryWrapper<>();
56
+//            queryWrapper.orderByDesc("create_date");
57
+//
58
+//            IPage<TaShopkeeperThird> result = iTaShopkeeperThirdService.page(pg, queryWrapper);
59
+//            return ResponseBean.success(result);
60
+//    }
61
+//
62
+//    /**
63
+//     * 保存对象
64
+//     * @param taShopkeeperThird 实体对象
65
+//     * @return
66
+//     */
67
+//    @RequestMapping(value="/taShopkeeperThird",method= RequestMethod.POST)
68
+//    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
+//    public ResponseBean taShopkeeperThirdAdd(@ApiParam("保存内容") @RequestBody TaShopkeeperThird taShopkeeperThird) throws Exception{
70
+//
71
+//        if (iTaShopkeeperThirdService.save(taShopkeeperThird)){
72
+//            return ResponseBean.success(taShopkeeperThird);
73
+//        }else {
74
+//            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75
+//        }
76
+//    }
77
+//
78
+//    /**
79
+//     * 根据id删除对象
80
+//     * @param id  实体ID
81
+//     */
82
+//    @RequestMapping(value="/taShopkeeperThird/{id}", method= RequestMethod.DELETE)
83
+//    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
+//    public ResponseBean taShopkeeperThirdDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
+//        if(iTaShopkeeperThirdService.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 taShopkeeperThird 实体对象
96
+//     * @return
97
+//     */
98
+//    @RequestMapping(value="/taShopkeeperThird/{id}",method= RequestMethod.PUT)
99
+//    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
+//    public ResponseBean taShopkeeperThirdUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
+//                                        @ApiParam("更新内容") @RequestBody TaShopkeeperThird taShopkeeperThird) throws Exception{
102
+//
103
+//        if (iTaShopkeeperThirdService.updateById(taShopkeeperThird)){
104
+//            return ResponseBean.success(iTaShopkeeperThirdService.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="/taShopkeeperThird/{id}",method= RequestMethod.GET)
115
+//    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
+//    public ResponseBean taShopkeeperThirdGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
+//        return ResponseBean.success(iTaShopkeeperThirdService.getById(id));
118
+//    }
119
+}

+ 8
- 0
src/main/java/com/yunzhi/niucai/entity/TaCustomer.java Ver fichero

@@ -114,5 +114,13 @@ public class TaCustomer implements Serializable {
114 114
      */
115 115
     private Integer recChannel;
116 116
 
117
+    /**
118
+     * 支付宝账号
119
+     */
120
+    private String alipayUser;
117 121
 
122
+    /**
123
+     * 微信openid
124
+     */
125
+    private String wxOpenid;
118 126
 }

+ 5
- 2
src/main/java/com/yunzhi/niucai/entity/TaCustomerBetting.java Ver fichero

@@ -78,8 +78,11 @@ public class TaCustomerBetting implements Serializable {
78 78
     @ApiModelProperty(value = "预期收益")
79 79
     private String expectedEarning;
80 80
 
81
-    @ApiModelProperty(value = "是否打单")
82
-    private Boolean isPrinted;
81
+    @ApiModelProperty(value = "是否出票")
82
+    private Boolean isDrawn;
83
+
84
+    @ApiModelProperty(value = "出票时间")
85
+    private LocalDateTime drawnDate;
83 86
 
84 87
     @ApiModelProperty(value = "彩票图片")
85 88
     private String lotteryPicture;

+ 1
- 1
src/main/java/com/yunzhi/niucai/entity/TaCustomerBettingSport.java Ver fichero

@@ -49,7 +49,7 @@ public class TaCustomerBettingSport implements Serializable {
49 49
     private String oddsOrdered;
50 50
 
51 51
     @ApiModelProperty(value = "打单赔率")
52
-    private String oddsPrinted;
52
+    private String oddsDrawn;
53 53
 
54 54
     @ApiModelProperty(value = "是否中奖")
55 55
     private Boolean isWinning;

+ 5
- 0
src/main/java/com/yunzhi/niucai/entity/TaShop.java Ver fichero

@@ -92,6 +92,11 @@ public class TaShop implements Serializable {
92 92
      */
93 93
     private Integer status;
94 94
 
95
+    /**
96
+     * 营业执照
97
+     */
98
+    private String businessLicense;
99
+
95 100
     /**
96 101
      * 彩种
97 102
      */

+ 10
- 0
src/main/java/com/yunzhi/niucai/entity/TaShopkeeper.java Ver fichero

@@ -48,5 +48,15 @@ public class TaShopkeeper implements Serializable {
48 48
     @ApiModelProperty(value = "状态")
49 49
     private Integer status;
50 50
 
51
+    @ApiModelProperty(value = "是否支付宝会员认证")
52
+    private Boolean isValidAli;
51 53
 
54
+    @ApiModelProperty(value = "身份证正面")
55
+    private String frontIdCard;
56
+
57
+    @ApiModelProperty(value = "身份证反面")
58
+    private String backIdCard;
59
+
60
+    @ApiModelProperty(value = "身份证号码")
61
+    private String idCard;
52 62
 }

+ 58
- 0
src/main/java/com/yunzhi/niucai/entity/TaShopkeeperThird.java Ver fichero

@@ -0,0 +1,58 @@
1
+package com.yunzhi.niucai.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import java.time.LocalDateTime;
6
+import java.io.Serializable;
7
+import io.swagger.annotations.ApiModel;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.Data;
10
+import lombok.EqualsAndHashCode;
11
+import lombok.experimental.Accessors;
12
+
13
+/**
14
+ * <p>
15
+ * 店主的第三方账号 
16
+ * </p>
17
+ *
18
+ * @author yansen
19
+ * @since 2020-10-10
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaShopkeeperThird对象", description="店主的第三方账号 ")
25
+public class TaShopkeeperThird implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "序号")
30
+    @TableId(value = "serial_no", type = IdType.AUTO)
31
+    private Integer serialNo;
32
+
33
+    @ApiModelProperty(value = "第三方类型 wx微信,ali支付宝")
34
+    private String thirdPartType;
35
+
36
+    @ApiModelProperty(value = "第三方ID")
37
+    private String thirdPartId;
38
+
39
+    @ApiModelProperty(value = "店主ID")
40
+    private Integer keeperId;
41
+
42
+    @ApiModelProperty(value = "昵称")
43
+    private String nickName;
44
+
45
+    @ApiModelProperty(value = "头像")
46
+    private String avatar;
47
+
48
+    @ApiModelProperty(value = "性别 1男2女9未知")
49
+    private Integer sex;
50
+
51
+    @ApiModelProperty(value = "创建时间")
52
+    private LocalDateTime createDate;
53
+
54
+    @ApiModelProperty(value = "状态")
55
+    private Boolean status;
56
+
57
+
58
+}

+ 3
- 3
src/main/java/com/yunzhi/niucai/entity/TdCity.java Ver fichero

@@ -25,9 +25,9 @@ public class TdCity implements Serializable {
25 25
 
26 26
     private static final long serialVersionUID = 1L;
27 27
 
28
-//    @TableId(value = "id", type = IdType.INPUT)
29
-//    @ApiModelProperty(value = "主键")
30
-//    private Integer id;
28
+    @TableId(value = "id", type = IdType.INPUT)
29
+    @ApiModelProperty(value = "主键")
30
+    private Integer areaId;
31 31
 
32 32
     @ApiModelProperty(value = "省市区名称")
33 33
     private String name;

+ 9
- 0
src/main/java/com/yunzhi/niucai/mapper/TaShopMapper.java Ver fichero

@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
6 6
 import org.apache.ibatis.annotations.Param;
7 7
 
8 8
 import java.util.List;
9
+import java.util.Map;
9 10
 
10 11
 /**
11 12
  * <p>
@@ -37,4 +38,12 @@ public interface TaShopMapper extends BaseMapper<TaShop> {
37 38
                                  @Param("lat") String lat,
38 39
                                  @Param("notIn") List<Integer> notIn,
39 40
                                  @Param("limit") int limit);
41
+
42
+    /**
43
+     * 获取店铺相关信息
44
+     * @param shopId
45
+     * @return
46
+     * @throws Exception
47
+     */
48
+    Map<String, Object> getSummeryById(@Param("shopId") Integer shopId) throws Exception;
40 49
 }

+ 18
- 0
src/main/java/com/yunzhi/niucai/mapper/TaShopkeeperThirdMapper.java Ver fichero

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

+ 2
- 0
src/main/java/com/yunzhi/niucai/service/ITaOrderService.java Ver fichero

@@ -27,4 +27,6 @@ public interface ITaOrderService extends IService<TaOrder> {
27 27
     boolean drawOrder(TaOrder taOrder, DrawOrderParam drawOrderParam) throws Exception;
28 28
 
29 29
     TaOrder getByOutTradeNo(String outTradeNo);
30
+
31
+    TaOrder getByBetting(TaCustomerBetting betting) throws Exception;
30 32
 }

+ 6
- 0
src/main/java/com/yunzhi/niucai/service/ITaShopService.java Ver fichero

@@ -1,10 +1,12 @@
1 1
 package com.yunzhi.niucai.service;
2 2
 
3 3
 import com.yunzhi.niucai.entity.TaCustomer;
4
+import com.yunzhi.niucai.entity.TaOrder;
4 5
 import com.yunzhi.niucai.entity.TaShop;
5 6
 import com.baomidou.mybatisplus.extension.service.IService;
6 7
 import com.yunzhi.niucai.entity.TaShopkeeper;
7 8
 import com.yunzhi.niucai.vo.ShopKeeperSignUp;
9
+import com.yunzhi.niucai.vo.ShopValidParam;
8 10
 
9 11
 import java.util.Map;
10 12
 
@@ -33,4 +35,8 @@ public interface ITaShopService extends IService<TaShop> {
33 35
     TaShop getProfileBy(TaShopkeeper shopkeeper) throws Exception;
34 36
 
35 37
     boolean createBy(TaShopkeeper shopkeeper, ShopKeeperSignUp signUpParam) throws Exception;
38
+
39
+    ShopValidParam updateValidInfo(ShopValidParam shopValidParam, TaShop taShop, TaShopkeeper taShopkeeper) throws Exception;
40
+
41
+    Map<String, Object> getSummeryByOrder(TaOrder taOrder) throws Exception;
36 42
 }

+ 2
- 0
src/main/java/com/yunzhi/niucai/service/ITaShopkeeperService.java Ver fichero

@@ -15,4 +15,6 @@ import com.yunzhi.niucai.vo.ShopKeeperSignUp;
15 15
 public interface ITaShopkeeperService extends IService<TaShopkeeper> {
16 16
 
17 17
     boolean signUp(ShopKeeperSignUp signUpParam) throws Exception;
18
+
19
+    boolean bindThirdPartId(TaShopkeeper taShopkeeper, String thirdPartId, String thirdPartType) throws Exception;
18 20
 }

+ 18
- 0
src/main/java/com/yunzhi/niucai/service/ITaShopkeeperThirdService.java Ver fichero

@@ -0,0 +1,18 @@
1
+package com.yunzhi.niucai.service;
2
+
3
+import com.yunzhi.niucai.entity.TaShopkeeper;
4
+import com.yunzhi.niucai.entity.TaShopkeeperThird;
5
+import com.baomidou.mybatisplus.extension.service.IService;
6
+
7
+/**
8
+ * <p>
9
+ * 店主的第三方账号  服务类
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2020-10-10
14
+ */
15
+public interface ITaShopkeeperThirdService extends IService<TaShopkeeperThird> {
16
+
17
+    TaShopkeeperThird getByKeeper(TaShopkeeper taShopkeeper, String thirdPartType) throws Exception;
18
+}

+ 1
- 1
src/main/java/com/yunzhi/niucai/service/ITdCityService.java Ver fichero

@@ -13,5 +13,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 13
  */
14 14
 public interface ITdCityService extends IService<TdCity> {
15 15
 
16
-    Integer getIdByLevel(String province, int levelType) throws Exception;
16
+    TdCity getByLevel(String name, int level) throws Exception;
17 17
 }

+ 17
- 1
src/main/java/com/yunzhi/niucai/service/impl/TaCustomerBettingServiceImpl.java Ver fichero

@@ -9,6 +9,8 @@ import com.yunzhi.niucai.mapper.TaCustomerBettingSportMapper;
9 9
 import com.yunzhi.niucai.service.ITaBettingPlanService;
10 10
 import com.yunzhi.niucai.service.ITaCustomerBettingService;
11 11
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
12
+import com.yunzhi.niucai.service.ITaOrderService;
13
+import com.yunzhi.niucai.service.ITaShopService;
12 14
 import org.springframework.beans.factory.annotation.Autowired;
13 15
 import org.springframework.stereotype.Service;
14 16
 import org.springframework.transaction.annotation.Transactional;
@@ -31,6 +33,12 @@ public class TaCustomerBettingServiceImpl extends ServiceImpl<TaCustomerBettingM
31 33
     @Autowired
32 34
     ITaBettingPlanService iTaBettingPlanService;
33 35
 
36
+    @Autowired
37
+    ITaOrderService iTaOrderService;
38
+
39
+    @Autowired
40
+    ITaShopService iTaShopService;
41
+
34 42
     @Autowired
35 43
     TaCustomerBettingItemMapper taCustomerBettingItemMapper;
36 44
 
@@ -56,7 +64,7 @@ public class TaCustomerBettingServiceImpl extends ServiceImpl<TaCustomerBettingM
56 64
         taCustomerBetting.setNotesNum(plan.getNotesNum());
57 65
         taCustomerBetting.setTotalPrice(plan.getTotalPrice());
58 66
         taCustomerBetting.setExpectedEarning(plan.getExpectedEarning());
59
-        taCustomerBetting.setIsPrinted(false);
67
+        taCustomerBetting.setIsDrawn(false);
60 68
         taCustomerBetting.setIsOpen(false);
61 69
         taCustomerBetting.setIsWinning(false);
62 70
         taCustomerBetting.setStatus(StatusEnum.READY.getCode());
@@ -114,9 +122,17 @@ public class TaCustomerBettingServiceImpl extends ServiceImpl<TaCustomerBettingM
114 122
         // 查询方案
115 123
         TaBettingPlan taBettingPlan = iTaBettingPlanService.getDetailOfPlanById(betting.getPlanId());
116 124
 
125
+        // 订单查询
126
+        TaOrder taOrder = iTaOrderService.getByBetting(betting);
127
+
128
+        // 投注店铺信息
129
+        Map<String, Object> shop = iTaShopService.getSummeryByOrder(taOrder);
130
+
117 131
         Map<String, Object> result = new HashMap<>();
118 132
         result.put("betting", betting);
119 133
         result.put("plan", taBettingPlan);
134
+        result.put("order", taOrder);
135
+        result.put("shop", shop);
120 136
 
121 137
         return result;
122 138
     }

+ 1
- 1
src/main/java/com/yunzhi/niucai/service/impl/TaMatchServiceImpl.java Ver fichero

@@ -284,7 +284,7 @@ public class TaMatchServiceImpl extends ServiceImpl<TaMatchMapper, TaMatch> impl
284 284
             List<String> oddsOfNote = new ArrayList<>();
285 285
             for (TaCustomerBettingSport sportItem : sportList) {
286 286
                 if (sportItem.getIsWinning()) {
287
-                    oddsOfNote.add(sportItem.getOddsPrinted());
287
+                    oddsOfNote.add(sportItem.getOddsDrawn());
288 288
                 } else {
289 289
                     // 未中奖的赔率是 0
290 290
                     oddsOfNote.add("0");

+ 14
- 2
src/main/java/com/yunzhi/niucai/service/impl/TaOrderServiceImpl.java Ver fichero

@@ -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.baomidou.mybatisplus.core.metadata.IPage;
4 5
 import com.yunzhi.niucai.common.CommConstants;
5 6
 import com.yunzhi.niucai.common.DateUtils;
@@ -114,11 +115,11 @@ public class TaOrderServiceImpl extends ServiceImpl<TaOrderMapper, TaOrder> impl
114 115
             throw new Exception("未找到有效的投注记录");
115 116
         }
116 117
 
117
-        if (customerBetting.getIsPrinted()) {
118
+        if (customerBetting.getIsDrawn()) {
118 119
             throw new Exception("已经出票, 无需操作");
119 120
         }
120 121
 
121
-        customerBetting.setIsPrinted(true);
122
+        customerBetting.setIsDrawn(true);
122 123
         customerBetting.setLotteryPicture(drawOrderParam.getLotteryPicture());
123 124
 
124 125
         return iTaCustomerBettingService.updateById(customerBetting);
@@ -129,6 +130,17 @@ public class TaOrderServiceImpl extends ServiceImpl<TaOrderMapper, TaOrder> impl
129 130
         return taOrderMapper.getByOutTradeNo(outTradeNo);
130 131
     }
131 132
 
133
+    @Override
134
+    public TaOrder getByBetting(TaCustomerBetting betting) throws Exception {
135
+        QueryWrapper<TaOrder> queryWrapper = new QueryWrapper<>();
136
+        queryWrapper.eq("betting_id", betting.getBettingId());
137
+        queryWrapper.gt("status", StatusEnum.DELETED.getCode());
138
+
139
+        TaOrder taOrder = getOne(queryWrapper);
140
+
141
+        return taOrder;
142
+    }
143
+
132 144
     private String nextOrderNo(String prefix, int length, boolean padDate) throws Exception {
133 145
         List<String> parts = new ArrayList<>();
134 146
         parts.add(prefix);

+ 81
- 11
src/main/java/com/yunzhi/niucai/service/impl/TaShopServiceImpl.java Ver fichero

@@ -5,19 +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.ResponseBean;
7 7
 import com.yunzhi.niucai.common.StringUtils;
8
-import com.yunzhi.niucai.entity.TaCustomer;
9
-import com.yunzhi.niucai.entity.TaShop;
10
-import com.yunzhi.niucai.entity.TaShopLottery;
11
-import com.yunzhi.niucai.entity.TaShopkeeper;
8
+import com.yunzhi.niucai.entity.*;
12 9
 import com.yunzhi.niucai.enums.StatusEnum;
13 10
 import com.yunzhi.niucai.mapper.TaShopMapper;
14 11
 import com.yunzhi.niucai.service.ITaShopLotteryService;
15 12
 import com.yunzhi.niucai.service.ITaShopService;
16 13
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
14
+import com.yunzhi.niucai.service.ITaShopkeeperService;
17 15
 import com.yunzhi.niucai.service.ITdCityService;
18 16
 import com.yunzhi.niucai.vo.ShopKeeperSignUp;
17
+import com.yunzhi.niucai.vo.ShopValidParam;
18
+import io.swagger.models.auth.In;
19 19
 import org.springframework.beans.factory.annotation.Autowired;
20 20
 import org.springframework.stereotype.Service;
21
+import org.springframework.transaction.annotation.Transactional;
21 22
 
22 23
 import java.util.ArrayList;
23 24
 import java.util.HashMap;
@@ -38,6 +39,9 @@ public class TaShopServiceImpl extends ServiceImpl<TaShopMapper, TaShop> impleme
38 39
     @Autowired
39 40
     ITaShopLotteryService iTaShopLotteryService;
40 41
 
42
+    @Autowired
43
+    ITaShopkeeperService iTaShopkeeperService;
44
+
41 45
     @Autowired
42 46
     ITdCityService iTdCityService;
43 47
 
@@ -118,20 +122,25 @@ public class TaShopServiceImpl extends ServiceImpl<TaShopMapper, TaShop> impleme
118 122
         // 校验店主
119 123
         // 是否允许店主唯一, 业务暂时没有说明, 所以先不做校验
120 124
 
121
-        Integer provinceId = iTdCityService.getIdByLevel(signUpParam.getProvince(), 1);
122
-        if (null == provinceId) {
125
+        TdCity province = iTdCityService.getByLevel(signUpParam.getProvince(), 1);
126
+        if (null == province) {
123 127
             throw new Exception("未找到匹配的省份信息");
124 128
         }
129
+        Integer provinceId = province.getAreaId();
125 130
 
126 131
         // 地级市
127
-        Integer cityId = iTdCityService.getIdByLevel(signUpParam.getCity(), 2);
128
-        if (null == cityId) {
129
-            // 县级市
130
-            cityId = iTdCityService.getIdByLevel(signUpParam.getCity(), 3);
131
-            if (null == cityId) {
132
+        TdCity city = iTdCityService.getByLevel(signUpParam.getCity(), 2);
133
+        if (null == city) {
134
+            city = iTdCityService.getByLevel(signUpParam.getCity(), 3);
135
+            if (null == city) {
132 136
                 throw new Exception("未找到匹配的城市信息");
133 137
             }
134 138
         }
139
+        Integer cityId = city.getAreaId();
140
+
141
+        if (!city.getParentid().equals(provinceId)) {
142
+            throw new Exception("内部映射店铺地址出错");
143
+        }
135 144
 
136 145
         if (StringUtils.isEmpty(signUpParam.getLng()) || StringUtils.isEmpty(signUpParam.getLat())) {
137 146
             throw new Exception("请设置店铺经纬度");
@@ -152,4 +161,65 @@ public class TaShopServiceImpl extends ServiceImpl<TaShopMapper, TaShop> impleme
152 161
 
153 162
         return save(taShop);
154 163
     }
164
+
165
+    @Override
166
+    @Transactional(rollbackFor = Exception.class)
167
+    public ShopValidParam updateValidInfo(ShopValidParam shopValidParam, TaShop taShop, TaShopkeeper taShopkeeper) throws Exception {
168
+
169
+        // 店铺
170
+        taShop.setName(shopValidParam.getShop().getName());
171
+        taShop.setBusinessLicense(shopValidParam.getShop().getBusinessLicense());
172
+        taShop.setLat(shopValidParam.getShop().getLat());
173
+        taShop.setLng(shopValidParam.getShop().getLng());
174
+        taShop.setAddress(shopValidParam.getShop().getAddress());
175
+
176
+        if (!StringUtils.isNumeric(shopValidParam.getShop().getProvinceId())) {
177
+            TdCity province = iTdCityService.getByLevel(shopValidParam.getShop().getProvinceId(), 1);
178
+            if (null != province) {
179
+                taShop.setProvinceId(province.getAreaId().toString());
180
+            }
181
+        }
182
+
183
+        if (!StringUtils.isNumeric(shopValidParam.getShop().getCityId())) {
184
+            TdCity city = iTdCityService.getByLevel(shopValidParam.getShop().getCityId(), 2);
185
+            if (null == city) {
186
+                city = iTdCityService.getByLevel(shopValidParam.getShop().getCityId(), 3);
187
+            }
188
+
189
+            if (null != city) {
190
+                taShop.setCityId(city.getAreaId().toString());
191
+            }
192
+        }
193
+
194
+        if (!updateById(taShop)) {
195
+            throw new Exception("更新店铺信息失败");
196
+        }
197
+
198
+        // 店主
199
+        taShopkeeper.setName(shopValidParam.getShopkeeper().getName());
200
+        taShopkeeper.setPhone(shopValidParam.getShopkeeper().getPhone());
201
+        taShopkeeper.setPassword(null); // 不更新
202
+
203
+        if (!StringUtils.isEmpty(shopValidParam.getShopkeeper().getFrontIdCard())) {
204
+            taShopkeeper.setFrontIdCard(shopValidParam.getShopkeeper().getFrontIdCard());
205
+            taShopkeeper.setBackIdCard(shopValidParam.getShopkeeper().getBackIdCard());
206
+        }
207
+
208
+        if (!iTaShopkeeperService.updateById(taShopkeeper)) {
209
+            throw new Exception("更新店主信息失败");
210
+        }
211
+
212
+        shopValidParam.setShop(taShop);
213
+        shopValidParam.setShopkeeper(taShopkeeper);
214
+        return shopValidParam;
215
+    }
216
+
217
+    @Override
218
+    public Map<String, Object> getSummeryByOrder(TaOrder taOrder) throws Exception {
219
+        if (null == taOrder || null == taOrder.getShopId()) {
220
+            return null;
221
+        }
222
+
223
+        return taShopMapper.getSummeryById(taOrder.getShopId());
224
+    }
155 225
 }

+ 21
- 0
src/main/java/com/yunzhi/niucai/service/impl/TaShopkeeperServiceImpl.java Ver fichero

@@ -3,14 +3,17 @@ package com.yunzhi.niucai.service.impl;
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.yunzhi.niucai.common.EncryptUtils;
5 5
 import com.yunzhi.niucai.entity.TaShopkeeper;
6
+import com.yunzhi.niucai.entity.TaShopkeeperThird;
6 7
 import com.yunzhi.niucai.enums.StatusEnum;
7 8
 import com.yunzhi.niucai.mapper.TaShopkeeperMapper;
8 9
 import com.yunzhi.niucai.service.ITaShopService;
9 10
 import com.yunzhi.niucai.service.ITaShopkeeperService;
10 11
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
12
+import com.yunzhi.niucai.service.ITaShopkeeperThirdService;
11 13
 import com.yunzhi.niucai.vo.ShopKeeperSignUp;
12 14
 import org.springframework.beans.factory.annotation.Autowired;
13 15
 import org.springframework.stereotype.Service;
16
+import org.springframework.transaction.annotation.Transactional;
14 17
 
15 18
 /**
16 19
  * <p>
@@ -26,6 +29,9 @@ public class TaShopkeeperServiceImpl extends ServiceImpl<TaShopkeeperMapper, TaS
26 29
     @Autowired
27 30
     ITaShopService iTaShopService;
28 31
 
32
+    @Autowired
33
+    ITaShopkeeperThirdService iTaShopkeeperThirdService;
34
+
29 35
     @Override
30 36
     public boolean signUp(ShopKeeperSignUp signUpParam) throws Exception {
31 37
         // 校验手机号唯一
@@ -52,6 +58,21 @@ public class TaShopkeeperServiceImpl extends ServiceImpl<TaShopkeeperMapper, TaS
52 58
         return iTaShopService.createBy(shopkeeper, signUpParam);
53 59
     }
54 60
 
61
+    @Override
62
+    public boolean bindThirdPartId(TaShopkeeper taShopkeeper, String thirdPartId, String thirdPartType) throws Exception {
63
+        TaShopkeeperThird taShopkeeperThird = iTaShopkeeperThirdService.getByKeeper(taShopkeeper, thirdPartType);
64
+        if (null == taShopkeeperThird) {
65
+            taShopkeeperThird = new TaShopkeeperThird();
66
+            taShopkeeperThird.setThirdPartType(thirdPartType);
67
+            taShopkeeperThird.setKeeperId(taShopkeeper.getKeeperId());
68
+            taShopkeeperThird.setThirdPartId(thirdPartId);
69
+            return iTaShopkeeperThirdService.save(taShopkeeperThird);
70
+        } else {
71
+            taShopkeeperThird.setThirdPartId(thirdPartId);
72
+            return iTaShopkeeperThirdService.updateById(taShopkeeperThird);
73
+        }
74
+    }
75
+
55 76
     public TaShopkeeper getByPhone(String phone) {
56 77
         QueryWrapper<TaShopkeeper> queryWrapper = new QueryWrapper<>();
57 78
         queryWrapper.eq("phone", phone);

+ 36
- 0
src/main/java/com/yunzhi/niucai/service/impl/TaShopkeeperThirdServiceImpl.java Ver fichero

@@ -0,0 +1,36 @@
1
+package com.yunzhi.niucai.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.yunzhi.niucai.entity.TaShopkeeper;
5
+import com.yunzhi.niucai.entity.TaShopkeeperThird;
6
+import com.yunzhi.niucai.enums.StatusEnum;
7
+import com.yunzhi.niucai.mapper.TaShopkeeperThirdMapper;
8
+import com.yunzhi.niucai.service.ITaShopkeeperThirdService;
9
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
10
+import org.springframework.stereotype.Service;
11
+
12
+/**
13
+ * <p>
14
+ * 店主的第三方账号  服务实现类
15
+ * </p>
16
+ *
17
+ * @author yansen
18
+ * @since 2020-10-10
19
+ */
20
+@Service
21
+public class TaShopkeeperThirdServiceImpl extends ServiceImpl<TaShopkeeperThirdMapper, TaShopkeeperThird> implements ITaShopkeeperThirdService {
22
+
23
+    @Override
24
+    public TaShopkeeperThird getByKeeper(TaShopkeeper taShopkeeper, String thirdPartType) throws Exception {
25
+        if (null == taShopkeeper || StatusEnum.DELETED.getCode().equals(taShopkeeper.getStatus())) {
26
+            throw new Exception("未找到有效的店主信息");
27
+        }
28
+
29
+        QueryWrapper<TaShopkeeperThird> queryWrapper = new QueryWrapper<>();
30
+        queryWrapper.eq("keeper_id", taShopkeeper.getKeeperId());
31
+        queryWrapper.eq("third_part_type", thirdPartType);
32
+        queryWrapper.eq("status", StatusEnum.NORMAL.getCode());
33
+
34
+        return getOne(queryWrapper);
35
+    }
36
+}

+ 7
- 3
src/main/java/com/yunzhi/niucai/service/impl/TdCityServiceImpl.java Ver fichero

@@ -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.entity.TdCity;
4 5
 import com.yunzhi.niucai.mapper.TdCityMapper;
5 6
 import com.yunzhi.niucai.service.ITdCityService;
@@ -18,8 +19,11 @@ import org.springframework.stereotype.Service;
18 19
 public class TdCityServiceImpl extends ServiceImpl<TdCityMapper, TdCity> implements ITdCityService {
19 20
 
20 21
     @Override
21
-    public Integer getIdByLevel(String province, int levelType) throws Exception {
22
-        // todo
23
-        return null;
22
+    public TdCity getByLevel(String name, int level) throws Exception {
23
+        QueryWrapper<TdCity> queryWrapper = new QueryWrapper<>();
24
+        queryWrapper.like("name", name);
25
+        queryWrapper.eq("leveltype", level);
26
+
27
+        return getOne(queryWrapper);
24 28
     }
25 29
 }

+ 14
- 0
src/main/java/com/yunzhi/niucai/vo/AlipayAuthUser.java Ver fichero

@@ -0,0 +1,14 @@
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 AlipayAuthUser {
11
+
12
+    @ApiModelProperty("授权码")
13
+    String authCode;
14
+}

+ 19
- 0
src/main/java/com/yunzhi/niucai/vo/ShopValidParam.java Ver fichero

@@ -0,0 +1,19 @@
1
+package com.yunzhi.niucai.vo;
2
+
3
+
4
+import com.yunzhi.niucai.entity.TaShop;
5
+import com.yunzhi.niucai.entity.TaShopkeeper;
6
+import io.swagger.annotations.ApiModel;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.Data;
9
+
10
+@ApiModel(description = "店铺认证参数")
11
+@Data
12
+public class ShopValidParam {
13
+
14
+    @ApiModelProperty("店铺信息")
15
+    TaShop shop;
16
+
17
+    @ApiModelProperty("店主信息")
18
+    TaShopkeeper shopkeeper;
19
+}

+ 2
- 0
src/main/resources/application.yml Ver fichero

@@ -10,6 +10,8 @@ interceptor:
10 10
     enable: true
11 11
     include-paths: /**
12 12
     exclude-paths:
13
+      - /app/sms/**
14
+      - /shop/sms/**
13 15
       - /app/login
14 16
       - /app/logout
15 17
       - /app/signup

+ 11
- 0
src/main/resources/mapper/TaShopMapper.xml Ver fichero

@@ -62,4 +62,15 @@
62 62
             fn_distance ( t.lng, t.lat, #{lng}, #{lat} ) DESC
63 63
         LIMIT #{limit}
64 64
     </select>
65
+    <select id="getSummeryById" resultType="java.util.Map">
66
+        SELECT
67
+            t.`name`,
68
+            s.`name` AS keeperName,
69
+            s.phone AS keeperPhone
70
+        FROM
71
+        ta_shop t
72
+        INNER JOIN ta_shopkeeper s ON t.keeper_id = s.keeper_id
73
+        WHERE
74
+            t.shop_id = #{shopId}
75
+    </select>
65 76
 </mapper>

+ 5
- 0
src/main/resources/mapper/TaShopkeeperThirdMapper.xml Ver fichero

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