Your Name 3 lat temu
rodzic
commit
f8e51097d6
48 zmienionych plików z 1078 dodań i 75 usunięć
  1. 22
    0
      src/main/java/com/yunzhi/shigongli/common/Constants.java
  2. 5
    0
      src/main/java/com/yunzhi/shigongli/common/DateUtils.java
  3. 74
    0
      src/main/java/com/yunzhi/shigongli/common/WxPayUtils.java
  4. 3
    1
      src/main/java/com/yunzhi/shigongli/common/WxUtils.java
  5. 10
    0
      src/main/java/com/yunzhi/shigongli/config/WeixinConfig.java
  6. 7
    0
      src/main/java/com/yunzhi/shigongli/controller/CommController.java
  7. 3
    3
      src/main/java/com/yunzhi/shigongli/controller/TaHotelController.java
  8. 43
    9
      src/main/java/com/yunzhi/shigongli/controller/TaOrderController.java
  9. 3
    3
      src/main/java/com/yunzhi/shigongli/controller/TaRoomController.java
  10. 114
    0
      src/main/java/com/yunzhi/shigongli/controller/TaShopWorkerController.java
  11. 50
    0
      src/main/java/com/yunzhi/shigongli/controller/WxPayController.java
  12. 6
    7
      src/main/java/com/yunzhi/shigongli/entity/TaHotelAccount.java
  13. 2
    2
      src/main/java/com/yunzhi/shigongli/entity/TaHotelAccountLog.java
  14. 3
    0
      src/main/java/com/yunzhi/shigongli/entity/TaHotelWorker.java
  15. 11
    2
      src/main/java/com/yunzhi/shigongli/entity/TaOrder.java
  16. 4
    4
      src/main/java/com/yunzhi/shigongli/entity/TaOrderCommission.java
  17. 5
    5
      src/main/java/com/yunzhi/shigongli/entity/TaOrderPay.java
  18. 10
    10
      src/main/java/com/yunzhi/shigongli/entity/TaOrderSub.java
  19. 6
    7
      src/main/java/com/yunzhi/shigongli/entity/TaPersonAccount.java
  20. 2
    2
      src/main/java/com/yunzhi/shigongli/entity/TaPersonAccountLog.java
  21. 6
    6
      src/main/java/com/yunzhi/shigongli/entity/TaShopAccount.java
  22. 2
    2
      src/main/java/com/yunzhi/shigongli/entity/TaShopAccountLog.java
  23. 6
    6
      src/main/java/com/yunzhi/shigongli/entity/TaShopPackage.java
  24. 4
    4
      src/main/java/com/yunzhi/shigongli/entity/TaShopPackageSetting.java
  25. 56
    0
      src/main/java/com/yunzhi/shigongli/entity/TaShopWorker.java
  26. 21
    0
      src/main/java/com/yunzhi/shigongli/event/PaySuccessEvent.java
  27. 29
    0
      src/main/java/com/yunzhi/shigongli/event/RefundSuccessEvent.java
  28. 24
    0
      src/main/java/com/yunzhi/shigongli/event/listener/PaySuccessEventListener.java
  29. 2
    0
      src/main/java/com/yunzhi/shigongli/mapper/TaOrderMapper.java
  30. 2
    0
      src/main/java/com/yunzhi/shigongli/mapper/TaOrderPayMapper.java
  31. 6
    0
      src/main/java/com/yunzhi/shigongli/mapper/TaOrderSubMapper.java
  32. 5
    0
      src/main/java/com/yunzhi/shigongli/mapper/TaPersonAccountMapper.java
  33. 18
    0
      src/main/java/com/yunzhi/shigongli/mapper/TaShopWorkerMapper.java
  34. 5
    0
      src/main/java/com/yunzhi/shigongli/service/ITaOrderPayService.java
  35. 7
    0
      src/main/java/com/yunzhi/shigongli/service/ITaOrderService.java
  36. 2
    0
      src/main/java/com/yunzhi/shigongli/service/ITaPersonAccountService.java
  37. 16
    0
      src/main/java/com/yunzhi/shigongli/service/ITaShopWorkerService.java
  38. 99
    0
      src/main/java/com/yunzhi/shigongli/service/impl/TaOrderPayServiceImpl.java
  39. 241
    2
      src/main/java/com/yunzhi/shigongli/service/impl/TaOrderServiceImpl.java
  40. 49
    0
      src/main/java/com/yunzhi/shigongli/service/impl/TaPersonAccountServiceImpl.java
  41. 20
    0
      src/main/java/com/yunzhi/shigongli/service/impl/TaShopWorkerServiceImpl.java
  42. 19
    0
      src/main/java/com/yunzhi/shigongli/vo/OrderItem.java
  43. 3
    0
      src/main/resources/application.yml
  44. 6
    0
      src/main/resources/mapper/TaOrderMapper.xml
  45. 15
    0
      src/main/resources/mapper/TaOrderPayMapper.xml
  46. 12
    0
      src/main/resources/mapper/TaOrderSubMapper.xml
  47. 15
    0
      src/main/resources/mapper/TaPersonAccountMapper.xml
  48. 5
    0
      src/main/resources/mapper/TaShopWorkerMapper.xml

+ 22
- 0
src/main/java/com/yunzhi/shigongli/common/Constants.java Wyświetl plik

@@ -6,4 +6,26 @@ public class Constants {
6 6
     public final static Integer STATUS_READY = 0;
7 7
     public final static Integer STATUS_NORMAL = 1;
8 8
 
9
+    // 订单状态
10
+    public final static Integer ORDER_READY = 0;    // 未支付
11
+    public final static Integer ORDER_PAYED = 1;    // 已支付
12
+    public final static Integer ORDER_REFUND = 2;   // 已退款
13
+    public final static Integer ORDER_CANCEL = 9;   // 已取消
14
+
15
+    // 支付结果
16
+    public final static Integer PAY_SUCCESS = 1;
17
+    public final static Integer PAY_FAIL = 0;
18
+
19
+    // 抽成分类
20
+    public final static String COMMISSION_TRAFFIC = "traffic";  // 引流抽成
21
+    public final static String COMMISSION_PLATFORM = "platform";  // 平台抽成
22
+
23
+    // 账户流水
24
+    public final static Integer ACCOUNT_INCOME = 1;     // 收入
25
+    public final static Integer ACCOUNT_EXPENSE = -1;   // 支出
26
+
27
+    // 系统模块
28
+    public final static String TARGET_ORDER = "order";  // 订单
29
+    public final static String TARGET_HOTEL = "hotel";  // 民宿
30
+    public final static String TARGET_SHOP = "shop";    // 商铺
9 31
 }

+ 5
- 0
src/main/java/com/yunzhi/shigongli/common/DateUtils.java Wyświetl plik

@@ -14,4 +14,9 @@ public class DateUtils {
14 14
         Duration duration = Duration.between(dt1, dt2);
15 15
         return duration.toDays();
16 16
     }
17
+
18
+    public static String toString(LocalDateTime dt, String formater) {
19
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formater);
20
+        return dt.format(formatter);
21
+    }
17 22
 }

+ 74
- 0
src/main/java/com/yunzhi/shigongli/common/WxPayUtils.java Wyświetl plik

@@ -0,0 +1,74 @@
1
+package com.yunzhi.shigongli.common;
2
+
3
+import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
4
+import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
5
+import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
6
+import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
7
+import com.github.binarywang.wxpay.constant.WxPayConstants;
8
+import com.github.binarywang.wxpay.service.WxPayService;
9
+import com.yunzhi.shigongli.config.WeixinConfig;
10
+import com.yunzhi.shigongli.entity.TaOrder;
11
+import com.yunzhi.shigongli.entity.TaPerson;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.stereotype.Component;
14
+
15
+import java.time.LocalDateTime;
16
+
17
+@Component
18
+public class WxPayUtils {
19
+    @Autowired
20
+    WeixinConfig config;
21
+
22
+    @Autowired
23
+    WxUtils wxUtils;
24
+
25
+    /**
26
+     * 下单
27
+     * @param person
28
+     * @param taOrder
29
+     * @return
30
+     * @throws Exception
31
+     */
32
+    public WxPayMpOrderResult createOrder(TaPerson person, TaOrder taOrder) throws Exception {
33
+        LocalDateTime now = LocalDateTime.now();
34
+        WxPayService payService = wxUtils.getPayService();
35
+
36
+        WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
37
+        orderRequest.setBody(taOrder.getDescription());
38
+        orderRequest.setOutTradeNo(taOrder.getOrderId());
39
+        orderRequest.setTotalFee(taOrder.getCharges());
40
+        orderRequest.setOpenid(person.getOpenid());
41
+        orderRequest.setNotifyUrl(config.getPay().getNotifyUrl());
42
+        orderRequest.setSpbillCreateIp("218.91.253.51");  // 随便写个 IP
43
+        orderRequest.setTimeStart(DateUtils.toString(now, "yyyyMMddHHmmss"));
44
+        // 默认支付 30 分钟有效期
45
+        orderRequest.setTimeExpire(DateUtils.toString(now.plusMinutes(30), "yyyyMMddHHmmss"));
46
+
47
+        WxPayMpOrderResult payResult = payService.createOrder(orderRequest);
48
+        return payResult;
49
+    }
50
+
51
+    /**
52
+     * 退款
53
+     * @param taOrder
54
+     * @param cashback
55
+     * @return
56
+     * @throws Exception
57
+     */
58
+    public WxPayRefundResult refund(TaOrder taOrder, Integer cashback) throws Exception {
59
+        WxPayService payService = wxUtils.getPayService();
60
+        WxPayRefundRequest refundRequest = new WxPayRefundRequest();
61
+        refundRequest.setOutTradeNo(taOrder.getOrderId());
62
+        refundRequest.setOutRefundNo("R"+taOrder.getOrderId());
63
+        refundRequest.setTotalFee(taOrder.getCharges());
64
+        refundRequest.setRefundFee(taOrder.getCharges() - cashback);
65
+        refundRequest.setNotifyUrl(config.getPay().getRefundNotifyUrl());
66
+        WxPayRefundResult result = payService.refund(refundRequest);
67
+
68
+        if (!WxPayConstants.ResultCode.SUCCESS.equals(result.getResultCode())) {
69
+            throw new Exception(result.getErrCodeDes());
70
+        }
71
+
72
+        return result;
73
+    }
74
+}

+ 3
- 1
src/main/java/com/yunzhi/shigongli/common/WxUtils.java Wyświetl plik

@@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
4 4
 import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
5 5
 import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
6 6
 import com.github.binarywang.wxpay.config.WxPayConfig;
7
+import com.github.binarywang.wxpay.constant.WxPayConstants;
7 8
 import com.github.binarywang.wxpay.service.WxPayService;
8 9
 import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
9 10
 import com.yunzhi.shigongli.config.WeixinConfig;
@@ -41,7 +42,8 @@ public class WxUtils {
41 42
         payConfig.setSubAppId(config.getPay().getSubAppId());
42 43
         payConfig.setSubMchId(config.getPay().getSubMchId());
43 44
         payConfig.setKeyPath(config.getPay().getKeyPath());
44
-
45
+        // 固定小程序支付
46
+        payConfig.setTradeType(WxPayConstants.TradeType.JSAPI);
45 47
         // 可以指定是否使用沙箱环境
46 48
         payConfig.setUseSandboxEnv(false);
47 49
 

+ 10
- 0
src/main/java/com/yunzhi/shigongli/config/WeixinConfig.java Wyświetl plik

@@ -54,5 +54,15 @@ public class WeixinConfig {
54 54
          * apiclient_cert.p12文件的绝对路径,或者如果放在项目中,请以classpath:开头指定
55 55
          */
56 56
         private String keyPath;
57
+
58
+        /**
59
+         * 异步支付回调通知地址
60
+         */
61
+        private String notifyUrl;
62
+
63
+        /**
64
+         * 退款回调通知
65
+         */
66
+        private String refundNotifyUrl;
57 67
     }
58 68
 }

+ 7
- 0
src/main/java/com/yunzhi/shigongli/controller/CommController.java Wyświetl plik

@@ -4,6 +4,7 @@ import com.yunzhi.shigongli.common.BaseController;
4 4
 import com.yunzhi.shigongli.common.OSSUtils;
5 5
 import com.yunzhi.shigongli.common.ResponseBean;
6 6
 import com.yunzhi.shigongli.config.AliyunConfig;
7
+import com.yunzhi.shigongli.service.ITaOrderService;
7 8
 import io.swagger.annotations.Api;
8 9
 import io.swagger.annotations.ApiOperation;
9 10
 import org.springframework.beans.factory.annotation.Autowired;
@@ -26,6 +27,11 @@ public class CommController extends BaseController {
26 27
     @Autowired
27 28
     AliyunConfig aliyunConfig;
28 29
 
30
+
31
+    @Autowired
32
+    ITaOrderService taOrderService;
33
+
34
+
29 35
     /**
30 36
      * 图片
31 37
      * @param multipartFile
@@ -68,4 +74,5 @@ public class CommController extends BaseController {
68 74
     private String getMonth() {
69 75
         return DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDateTime.now());
70 76
     }
77
+
71 78
 }

+ 3
- 3
src/main/java/com/yunzhi/shigongli/controller/TaHotelController.java Wyświetl plik

@@ -82,7 +82,7 @@ public class TaHotelController extends BaseController {
82 82
      */
83 83
     @RequestMapping(value="/admin/taHotel/{id}", method= RequestMethod.DELETE)
84 84
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
85
-    public ResponseBean taHotelDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
+    public ResponseBean taHotelDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
86 86
         if(iTaHotelService.removeById(id)){
87 87
             return ResponseBean.success("success");
88 88
         }else {
@@ -98,7 +98,7 @@ public class TaHotelController extends BaseController {
98 98
      */
99 99
     @RequestMapping(value="/admin/taHotel/{id}",method= RequestMethod.PUT)
100 100
     @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
101
-    public ResponseBean taHotelUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
+    public ResponseBean taHotelUpdate(@ApiParam("对象ID") @PathVariable String id,
102 102
                                         @ApiParam("更新内容") @RequestBody TaHotel taHotel) throws Exception{
103 103
 
104 104
         if (iTaHotelService.updateById(taHotel)){
@@ -114,7 +114,7 @@ public class TaHotelController extends BaseController {
114 114
      */
115 115
     @RequestMapping(value="/admin/taHotel/{id}",method= RequestMethod.GET)
116 116
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
117
-    public ResponseBean taHotelGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
+    public ResponseBean taHotelGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
118 118
         return ResponseBean.success(iTaHotelService.getById(id));
119 119
     }
120 120
 }

+ 43
- 9
src/main/java/com/yunzhi/shigongli/controller/TaOrderController.java Wyświetl plik

@@ -3,8 +3,11 @@ package com.yunzhi.shigongli.controller;
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
6 7
 import com.yunzhi.shigongli.common.BaseController;
7 8
 import com.yunzhi.shigongli.common.ResponseBean;
9
+import com.yunzhi.shigongli.entity.TaPerson;
10
+import com.yunzhi.shigongli.vo.OrderItem;
8 11
 import io.swagger.annotations.Api;
9 12
 import io.swagger.annotations.ApiOperation;
10 13
 import io.swagger.annotations.ApiParam;
@@ -20,6 +23,8 @@ import com.yunzhi.shigongli.service.ITaOrderService;
20 23
 import com.yunzhi.shigongli.entity.TaOrder;
21 24
 import org.springframework.web.bind.annotation.RestController;
22 25
 
26
+import javax.servlet.http.HttpServletRequest;
27
+
23 28
 /**
24 29
  * <p>
25 30
     * 订单表 前端控制器
@@ -60,19 +65,48 @@ public class TaOrderController extends BaseController {
60 65
 //    }
61 66
 
62 67
     /**
63
-     * 保存对象
64
-     * @param taOrder 实体对象
68
+     * 小程序下单
69
+     * @param orderItems
70
+     * @param request
65 71
      * @return
72
+     * @throws Exception
66 73
      */
67
-    @RequestMapping(value="/wx/taOrder",method= RequestMethod.POST)
68
-    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-    public ResponseBean taOrderAdd(@ApiParam("保存内容") @RequestBody TaOrder taOrder) throws Exception{
74
+    @RequestMapping(value="/wx/order",method= RequestMethod.POST)
75
+    @ApiOperation(value="生成订单", notes = "生成订单", httpMethod = "POST", response = ResponseBean.class)
76
+    public ResponseBean taOrderAdd(@ApiParam("订单内容") @RequestBody OrderItem[] orderItems,
77
+                                   HttpServletRequest request) throws Exception{
78
+        if (null == orderItems|| orderItems.length < 1) {
79
+            return ResponseBean.error("未找到订单内容", ResponseBean.ERROR_ILLEGAL_PARAMS);
80
+        }
70 81
 
71
-        if (iTaOrderService.save(taOrder)){
72
-            return ResponseBean.success(taOrder);
73
-        }else {
74
-            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
82
+        TaPerson person = getCurrentPerson();
83
+        WxPayMpOrderResult result = iTaOrderService.order(person, orderItems);
84
+        return ResponseBean.success(result);
85
+    }
86
+
87
+    /**
88
+     * 取消订单
89
+     * @param id
90
+     * @param request
91
+     * @return
92
+     * @throws Exception
93
+     */
94
+    @RequestMapping(value="/wx/order/{id}",method= RequestMethod.POST)
95
+    @ApiOperation(value="生成订单", notes = "生成订单", httpMethod = "POST", response = ResponseBean.class)
96
+    public ResponseBean taOrderDelete(@ApiParam("订单ID") @PathVariable String id,
97
+                                   HttpServletRequest request) throws Exception{
98
+        TaOrder taOrder = iTaOrderService.getById(id);
99
+        if (null == taOrder) {
100
+            return ResponseBean.error("订单不存在", ResponseBean.ERROR_ILLEGAL_PARAMS);
75 101
         }
102
+
103
+        TaPerson taPerson = getCurrentPerson();
104
+        if (!taPerson.getPersonId().equals(taOrder.getPersonId())) {
105
+            return ResponseBean.error("您无权取消当前订单", ResponseBean.ERROR_UNAVAILABLE);
106
+        }
107
+
108
+        iTaOrderService.cancelOrder(taOrder, taPerson);
109
+        return ResponseBean.success("取消成功");
76 110
     }
77 111
 
78 112
 //    /**

+ 3
- 3
src/main/java/com/yunzhi/shigongli/controller/TaRoomController.java Wyświetl plik

@@ -84,7 +84,7 @@ public class TaRoomController extends BaseController {
84 84
     @RequestMapping(value="/{plat}//taRoom/{id}", method= RequestMethod.DELETE)
85 85
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
86 86
     public ResponseBean taRoomDelete(@ApiParam(value = "客户端", allowableValues = "wx,admin") @PathVariable String plat,
87
-                                     @ApiParam("对象ID") @PathVariable Integer id) throws Exception{
87
+                                     @ApiParam("对象ID") @PathVariable String id) throws Exception{
88 88
         if(iTaRoomService.removeById(id)){
89 89
             return ResponseBean.success("success");
90 90
         }else {
@@ -101,7 +101,7 @@ public class TaRoomController extends BaseController {
101 101
     @RequestMapping(value="/{plat}/taRoom/{id}",method= RequestMethod.PUT)
102 102
     @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
103 103
     public ResponseBean taRoomUpdate(@ApiParam(value = "客户端", allowableValues = "wx,admin") @PathVariable String plat,
104
-                                     @ApiParam("对象ID") @PathVariable Integer id,
104
+                                     @ApiParam("对象ID") @PathVariable String id,
105 105
                                      @ApiParam("更新内容") @RequestBody TaRoom taRoom) throws Exception{
106 106
 
107 107
         if (iTaRoomService.updateById(taRoom)){
@@ -118,7 +118,7 @@ public class TaRoomController extends BaseController {
118 118
     @RequestMapping(value="/{plat}/taRoom/{id}",method= RequestMethod.GET)
119 119
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
120 120
     public ResponseBean taRoomGet(@ApiParam(value = "客户端", allowableValues = "wx,admin") @PathVariable String plat,
121
-                                  @ApiParam("对象ID") @PathVariable Integer id) throws Exception{
121
+                                  @ApiParam("对象ID") @PathVariable String id) throws Exception{
122 122
         return ResponseBean.success(iTaRoomService.getById(id));
123 123
     }
124 124
 }

+ 114
- 0
src/main/java/com/yunzhi/shigongli/controller/TaShopWorkerController.java Wyświetl plik

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

+ 50
- 0
src/main/java/com/yunzhi/shigongli/controller/WxPayController.java Wyświetl plik

@@ -0,0 +1,50 @@
1
+package com.yunzhi.shigongli.controller;
2
+
3
+import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
4
+import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
5
+import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
6
+import com.github.binarywang.wxpay.service.WxPayService;
7
+import com.yunzhi.shigongli.common.BaseController;
8
+import com.yunzhi.shigongli.common.WxUtils;
9
+import com.yunzhi.shigongli.service.ITaOrderPayService;
10
+import io.swagger.annotations.Api;
11
+import org.springframework.beans.factory.annotation.Autowired;
12
+import org.springframework.web.bind.annotation.RequestBody;
13
+import org.springframework.web.bind.annotation.RequestMapping;
14
+import org.springframework.web.bind.annotation.ResponseBody;
15
+import org.springframework.web.bind.annotation.RestController;
16
+
17
+@Api(tags = "微信小程序")
18
+@RestController
19
+@RequestMapping("/wxpay")
20
+public class WxPayController  extends BaseController {
21
+
22
+    @Autowired
23
+    WxUtils wxUtils;
24
+
25
+    @Autowired
26
+    ITaOrderPayService orderPayService;
27
+
28
+    @ResponseBody
29
+    @RequestMapping("/notify/order")
30
+    public String payNotify(@RequestBody String xmlData) throws Exception {
31
+        WxPayService payService = wxUtils.getPayService();
32
+        final WxPayOrderNotifyResult result = payService.parseOrderNotifyResult(xmlData);
33
+
34
+        orderPayService.notifyOrder(result);
35
+
36
+        return WxPayNotifyResponse.success("成功");
37
+    }
38
+
39
+    @ResponseBody
40
+    @RequestMapping("/notify/refund")
41
+    public String refundNotify(@RequestBody String xmlData) throws Exception {
42
+        WxPayService payService = wxUtils.getPayService();
43
+        final WxPayRefundNotifyResult result = payService.parseRefundNotifyResult(xmlData);
44
+
45
+        orderPayService.refundNotifyOrder(result);
46
+
47
+        return WxPayNotifyResponse.success("成功");
48
+    }
49
+
50
+}

+ 6
- 7
src/main/java/com/yunzhi/shigongli/entity/TaHotelAccount.java Wyświetl plik

@@ -34,16 +34,15 @@ public class TaHotelAccount implements Serializable {
34 34
     @ApiModelProperty(value = "民宿ID")
35 35
     private String hotelId;
36 36
 
37
-    @ApiModelProperty(value = "总金额")
38
-    private BigDecimal amounts;
37
+    @ApiModelProperty(value = "总金额;单位分")
38
+    private Integer amounts;
39 39
 
40
-    @ApiModelProperty(value = "佣金")
41
-    private BigDecimal brokerageCharges;
40
+    @ApiModelProperty(value = "佣金;单位分")
41
+    private Integer brokerageCharges;
42 42
 
43
-    @ApiModelProperty(value = "已结佣金")
44
-    private BigDecimal paidCharges;
43
+    @ApiModelProperty(value = "已结佣金;单位分")
44
+    private Integer paidCharges;
45 45
 
46 46
     private LocalDateTime createDate;
47 47
 
48
-
49 48
 }

+ 2
- 2
src/main/java/com/yunzhi/shigongli/entity/TaHotelAccountLog.java Wyświetl plik

@@ -43,8 +43,8 @@ public class TaHotelAccountLog implements Serializable {
43 43
     @ApiModelProperty(value = "金额类型")
44 44
     private String amountType;
45 45
 
46
-    @ApiModelProperty(value = "金额")
47
-    private BigDecimal amount;
46
+    @ApiModelProperty(value = "金额;单位分")
47
+    private Integer amount;
48 48
 
49 49
     @ApiModelProperty(value = "关联类型")
50 50
     private String targetType;

+ 3
- 0
src/main/java/com/yunzhi/shigongli/entity/TaHotelWorker.java Wyświetl plik

@@ -30,6 +30,9 @@ public class TaHotelWorker implements Serializable {
30 30
     @TableId(value = "worker_id", type = IdType.UUID)
31 31
     private String workerId;
32 32
 
33
+    @ApiModelProperty(value = "民宿ID")
34
+    private String hotelId;
35
+
33 36
     @ApiModelProperty(value = "名称")
34 37
     private String workerName;
35 38
 

+ 11
- 2
src/main/java/com/yunzhi/shigongli/entity/TaOrder.java Wyświetl plik

@@ -27,20 +27,29 @@ public class TaOrder implements Serializable {
27 27
 
28 28
     private static final long serialVersionUID = 1L;
29 29
 
30
+    @ApiModelProperty(value = "订单ID;订单号")
30 31
     @TableId(value = "order_id", type = IdType.INPUT)
31 32
     private String orderId;
32 33
 
34
+    @ApiModelProperty(value = "订单描述")
35
+    private String description;
36
+
37
+    @ApiModelProperty(value = "订单类型")
33 38
     private String orderType;
34 39
 
40
+    @ApiModelProperty(value = "人员ID")
35 41
     private String personId;
36 42
 
43
+    @ApiModelProperty(value = "攻略ID")
37 44
     private String strategyId;
38 45
 
39
-    private BigDecimal charges;
46
+    @ApiModelProperty(value = "金额")
47
+    private Integer charges;
40 48
 
49
+    @ApiModelProperty(value = "状态")
41 50
     private Integer status;
42 51
 
52
+    @ApiModelProperty(value = "创建时间")
43 53
     private LocalDateTime createDate;
44 54
 
45
-
46 55
 }

+ 4
- 4
src/main/java/com/yunzhi/shigongli/entity/TaOrderCommission.java Wyświetl plik

@@ -40,11 +40,11 @@ public class TaOrderCommission implements Serializable {
40 40
     @ApiModelProperty(value = "抽成类型")
41 41
     private String commissionType;
42 42
 
43
-    @ApiModelProperty(value = "抽成比例")
44
-    private BigDecimal commissionRate;
43
+    @ApiModelProperty(value = "抽成比例;单位千分之一")
44
+    private Integer commissionRate;
45 45
 
46
-    @ApiModelProperty(value = "抽成金额")
47
-    private BigDecimal charge;
46
+    @ApiModelProperty(value = "抽成金额;单位分")
47
+    private Integer charge;
48 48
 
49 49
     @ApiModelProperty(value = "时间")
50 50
     private LocalDateTime createDate;

+ 5
- 5
src/main/java/com/yunzhi/shigongli/entity/TaOrderPay.java Wyświetl plik

@@ -44,13 +44,13 @@ public class TaOrderPay implements Serializable {
44 44
     private String payType;
45 45
 
46 46
     @ApiModelProperty(value = "是否退款")
47
-    private Integer isRefund;
47
+    private Boolean isRefund;
48 48
 
49
-    @ApiModelProperty(value = "prepay_id")
50
-    private String prepayId;
49
+    @ApiModelProperty(value = "支付结果描述")
50
+    private String message;
51 51
 
52
-    @ApiModelProperty(value = "支付金额")
53
-    private BigDecimal charges;
52
+    @ApiModelProperty(value = "支付金额;单位分")
53
+    private Integer charges;
54 54
 
55 55
     @ApiModelProperty(value = "状态")
56 56
     private Integer status;

+ 10
- 10
src/main/java/com/yunzhi/shigongli/entity/TaOrderSub.java Wyświetl plik

@@ -28,7 +28,7 @@ public class TaOrderSub implements Serializable {
28 28
     private static final long serialVersionUID = 1L;
29 29
 
30 30
     @ApiModelProperty(value = "子订单ID")
31
-    @TableId(value = "sub_order_id", type = IdType.UUID)
31
+    @TableId(value = "sub_order_id", type = IdType.INPUT)
32 32
     private String subOrderId;
33 33
 
34 34
     @ApiModelProperty(value = "主订单ID")
@@ -40,23 +40,23 @@ public class TaOrderSub implements Serializable {
40 40
     @ApiModelProperty(value = "套餐ID")
41 41
     private String packageId;
42 42
 
43
-    @ApiModelProperty(value = "总金额")
44
-    private BigDecimal charges;
43
+    @ApiModelProperty(value = "总金额;单位分")
44
+    private Integer charges;
45 45
 
46 46
     @ApiModelProperty(value = "数量")
47 47
     private Integer amount;
48 48
 
49
-    @ApiModelProperty(value = "单价")
50
-    private BigDecimal unitPrice;
49
+    @ApiModelProperty(value = "单价;单位分")
50
+    private Integer unitPrice;
51 51
 
52
-    @ApiModelProperty(value = "抽成")
53
-    private BigDecimal commissionCharge;
52
+    @ApiModelProperty(value = "抽成;单位分")
53
+    private Integer commissionCharge;
54 54
 
55
-    @ApiModelProperty(value = "返现金额")
56
-    private BigDecimal cashback;
55
+    @ApiModelProperty(value = "返现金额;单位分")
56
+    private Integer cashback;
57 57
 
58 58
     @ApiModelProperty(value = "是否核销")
59
-    private Integer isVerified;
59
+    private Boolean isVerified;
60 60
 
61 61
     @ApiModelProperty(value = "状态")
62 62
     private Integer status;

+ 6
- 7
src/main/java/com/yunzhi/shigongli/entity/TaPersonAccount.java Wyświetl plik

@@ -34,16 +34,15 @@ public class TaPersonAccount implements Serializable {
34 34
     @ApiModelProperty(value = "民宿ID")
35 35
     private String personId;
36 36
 
37
-    @ApiModelProperty(value = "总金额")
38
-    private BigDecimal amounts;
37
+    @ApiModelProperty(value = "总金额;单位分")
38
+    private Integer amounts;
39 39
 
40
-    @ApiModelProperty(value = "返现总金额")
41
-    private BigDecimal cashbackCharges;
40
+    @ApiModelProperty(value = "返现总金额;单位分")
41
+    private Integer cashbackCharges;
42 42
 
43
-    @ApiModelProperty(value = "消费总金额")
44
-    private BigDecimal paidCharges;
43
+    @ApiModelProperty(value = "消费总金额;单位分")
44
+    private Integer paidCharges;
45 45
 
46 46
     private LocalDateTime createDate;
47 47
 
48
-
49 48
 }

+ 2
- 2
src/main/java/com/yunzhi/shigongli/entity/TaPersonAccountLog.java Wyświetl plik

@@ -43,8 +43,8 @@ public class TaPersonAccountLog implements Serializable {
43 43
     @ApiModelProperty(value = "金额类型")
44 44
     private String amountType;
45 45
 
46
-    @ApiModelProperty(value = "金额")
47
-    private BigDecimal amount;
46
+    @ApiModelProperty(value = "金额;单位分")
47
+    private Integer amount;
48 48
 
49 49
     @ApiModelProperty(value = "关联类型")
50 50
     private String targetType;

+ 6
- 6
src/main/java/com/yunzhi/shigongli/entity/TaShopAccount.java Wyświetl plik

@@ -34,14 +34,14 @@ public class TaShopAccount implements Serializable {
34 34
     @ApiModelProperty(value = "民宿ID")
35 35
     private String shopId;
36 36
 
37
-    @ApiModelProperty(value = "总金额")
38
-    private BigDecimal amounts;
37
+    @ApiModelProperty(value = "总金额;单位分")
38
+    private Integer amounts;
39 39
 
40
-    @ApiModelProperty(value = "佣金")
41
-    private BigDecimal brokerageCharges;
40
+    @ApiModelProperty(value = "佣金;单位分")
41
+    private Integer brokerageCharges;
42 42
 
43
-    @ApiModelProperty(value = "已结佣金")
44
-    private BigDecimal paidCharges;
43
+    @ApiModelProperty(value = "已结佣金;单位分")
44
+    private Integer paidCharges;
45 45
 
46 46
     private LocalDateTime createDate;
47 47
 

+ 2
- 2
src/main/java/com/yunzhi/shigongli/entity/TaShopAccountLog.java Wyświetl plik

@@ -43,8 +43,8 @@ public class TaShopAccountLog implements Serializable {
43 43
     @ApiModelProperty(value = "金额类型")
44 44
     private String amountType;
45 45
 
46
-    @ApiModelProperty(value = "金额")
47
-    private BigDecimal amount;
46
+    @ApiModelProperty(value = "金额;单位分")
47
+    private Integer amount;
48 48
 
49 49
     @ApiModelProperty(value = "关联类型")
50 50
     private String targetType;

+ 6
- 6
src/main/java/com/yunzhi/shigongli/entity/TaShopPackage.java Wyświetl plik

@@ -46,14 +46,14 @@ public class TaShopPackage implements Serializable {
46 46
     @ApiModelProperty(value = "主图")
47 47
     private String poster;
48 48
 
49
-    @ApiModelProperty(value = "门市价格")
50
-    private BigDecimal standardPrice;
49
+    @ApiModelProperty(value = "门市价格,单位分")
50
+    private Integer standardPrice;
51 51
 
52
-    @ApiModelProperty(value = "实售价格")
53
-    private BigDecimal actualPrice;
52
+    @ApiModelProperty(value = "实售价格,单位分")
53
+    private Integer actualPrice;
54 54
 
55
-    @ApiModelProperty(value = "返现")
56
-    private BigDecimal cashback;
55
+    @ApiModelProperty(value = "返现,单位分")
56
+    private Integer cashback;
57 57
 
58 58
     @ApiModelProperty(value = "有效期始")
59 59
     private LocalDateTime startTime;

+ 4
- 4
src/main/java/com/yunzhi/shigongli/entity/TaShopPackageSetting.java Wyświetl plik

@@ -30,11 +30,11 @@ public class TaShopPackageSetting implements Serializable {
30 30
     @TableId(value = "package_id", type = IdType.INPUT)
31 31
     private String packageId;
32 32
 
33
-    @ApiModelProperty(value = "引流分成")
34
-    private BigDecimal trafficRate;
33
+    @ApiModelProperty(value = "引流分成;单位千分之一")
34
+    private Integer trafficRate;
35 35
 
36
-    @ApiModelProperty(value = "平台分成")
37
-    private BigDecimal platformRate;
36
+    @ApiModelProperty(value = "平台分成;单位千分之一")
37
+    private Integer platformRate;
38 38
 
39 39
     @ApiModelProperty(value = "参与攻略")
40 40
     private Integer isStrategy;

+ 56
- 0
src/main/java/com/yunzhi/shigongli/entity/TaShopWorker.java Wyświetl plik

@@ -0,0 +1,56 @@
1
+package com.yunzhi.shigongli.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import io.swagger.annotations.ApiModel;
6
+import io.swagger.annotations.ApiModelProperty;
7
+import lombok.Data;
8
+import lombok.EqualsAndHashCode;
9
+import lombok.experimental.Accessors;
10
+
11
+import java.io.Serializable;
12
+import java.time.LocalDateTime;
13
+
14
+/**
15
+ * <p>
16
+ * 民宿员工
17
+ * </p>
18
+ *
19
+ * @author yansen
20
+ * @since 2021-08-17
21
+ */
22
+@Data
23
+@EqualsAndHashCode(callSuper = false)
24
+@Accessors(chain = true)
25
+@ApiModel(value="TaShopWorker对象", description="商铺员工")
26
+public class TaShopWorker implements Serializable {
27
+
28
+    private static final long serialVersionUID = 1L;
29
+
30
+    @ApiModelProperty(value = "员工ID")
31
+    @TableId(value = "worker_id", type = IdType.UUID)
32
+    private String workerId;
33
+
34
+    @ApiModelProperty(value = "商铺ID")
35
+    private String shopId;
36
+
37
+    @ApiModelProperty(value = "名称")
38
+    private String workerName;
39
+
40
+    @ApiModelProperty(value = "手机号")
41
+    private String phone;
42
+
43
+    @ApiModelProperty(value = "关联人员")
44
+    private String personId;
45
+
46
+    @ApiModelProperty(value = "是否管理员")
47
+    private Integer isManager;
48
+
49
+    @ApiModelProperty(value = "状态")
50
+    private Integer status;
51
+
52
+    @ApiModelProperty(value = "创建时间")
53
+    private LocalDateTime createDate;
54
+
55
+
56
+}

+ 21
- 0
src/main/java/com/yunzhi/shigongli/event/PaySuccessEvent.java Wyświetl plik

@@ -0,0 +1,21 @@
1
+package com.yunzhi.shigongli.event;
2
+
3
+import com.yunzhi.shigongli.entity.TaOrder;
4
+import org.springframework.context.ApplicationEvent;
5
+
6
+/**
7
+ * 支付成功事件
8
+ */
9
+public class PaySuccessEvent extends ApplicationEvent {
10
+
11
+    TaOrder taOrder;
12
+
13
+    public PaySuccessEvent(Object source, TaOrder taOrder) {
14
+        super(source);
15
+        this.taOrder = taOrder;
16
+    }
17
+
18
+    public TaOrder getTaOrder() {
19
+        return taOrder;
20
+    }
21
+}

+ 29
- 0
src/main/java/com/yunzhi/shigongli/event/RefundSuccessEvent.java Wyświetl plik

@@ -0,0 +1,29 @@
1
+package com.yunzhi.shigongli.event;
2
+
3
+import com.yunzhi.shigongli.entity.TaOrder;
4
+import com.yunzhi.shigongli.entity.TaOrderSub;
5
+import org.springframework.context.ApplicationEvent;
6
+
7
+/**
8
+ * 退款成功事件
9
+ */
10
+public class RefundSuccessEvent extends ApplicationEvent {
11
+
12
+    TaOrder taOrder;
13
+
14
+    TaOrderSub taOrderSub;
15
+
16
+    public RefundSuccessEvent(Object source, TaOrder taOrder, TaOrderSub taOrderSub) {
17
+        super(source);
18
+        this.taOrder = taOrder;
19
+        this.taOrderSub = taOrderSub;
20
+    }
21
+
22
+    public TaOrder getTaOrder() {
23
+        return taOrder;
24
+    }
25
+
26
+    public TaOrderSub getTaOrderSub() {
27
+        return taOrderSub;
28
+    }
29
+}

+ 24
- 0
src/main/java/com/yunzhi/shigongli/event/listener/PaySuccessEventListener.java Wyświetl plik

@@ -0,0 +1,24 @@
1
+package com.yunzhi.shigongli.event.listener;
2
+
3
+import com.yunzhi.shigongli.event.PaySuccessEvent;
4
+import com.yunzhi.shigongli.service.ITaPersonAccountService;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.context.ApplicationListener;
7
+import org.springframework.stereotype.Component;
8
+
9
+@Component
10
+public class PaySuccessEventListener implements ApplicationListener<PaySuccessEvent> {
11
+    @Autowired
12
+    ITaPersonAccountService personAccountService;
13
+
14
+    @Override
15
+    public void onApplicationEvent(PaySuccessEvent evt) {
16
+        try {
17
+
18
+            // 支付成功之后, 给个人返现
19
+            personAccountService.cashback(evt.getTaOrder());
20
+        } catch (Exception e) {
21
+            e.printStackTrace();
22
+        }
23
+    }
24
+}

+ 2
- 0
src/main/java/com/yunzhi/shigongli/mapper/TaOrderMapper.java Wyświetl plik

@@ -3,6 +3,7 @@ package com.yunzhi.shigongli.mapper;
3 3
 import com.yunzhi.shigongli.entity.TaOrder;
4 4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 5
 import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
6 7
 
7 8
 /**
8 9
  * <p>
@@ -15,4 +16,5 @@ import org.apache.ibatis.annotations.Mapper;
15 16
 @Mapper
16 17
 public interface TaOrderMapper extends BaseMapper<TaOrder> {
17 18
 
19
+    int updateStatus(@Param("orderId") String orderId, @Param("status") Integer status);
18 20
 }

+ 2
- 0
src/main/java/com/yunzhi/shigongli/mapper/TaOrderPayMapper.java Wyświetl plik

@@ -3,6 +3,7 @@ package com.yunzhi.shigongli.mapper;
3 3
 import com.yunzhi.shigongli.entity.TaOrderPay;
4 4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 5
 import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
6 7
 
7 8
 /**
8 9
  * <p>
@@ -15,4 +16,5 @@ import org.apache.ibatis.annotations.Mapper;
15 16
 @Mapper
16 17
 public interface TaOrderPayMapper extends BaseMapper<TaOrderPay> {
17 18
 
19
+    TaOrderPay getByOrder(@Param("orderId") String orderId, @Param("subOrderId") String subOrderId);
18 20
 }

+ 6
- 0
src/main/java/com/yunzhi/shigongli/mapper/TaOrderSubMapper.java Wyświetl plik

@@ -3,6 +3,9 @@ package com.yunzhi.shigongli.mapper;
3 3
 import com.yunzhi.shigongli.entity.TaOrderSub;
4 4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 5
 import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
6 9
 
7 10
 /**
8 11
  * <p>
@@ -15,4 +18,7 @@ import org.apache.ibatis.annotations.Mapper;
15 18
 @Mapper
16 19
 public interface TaOrderSubMapper extends BaseMapper<TaOrderSub> {
17 20
 
21
+    int updateStatusByOrder(@Param("orderId") String orderId, @Param("status") Integer status);
22
+
23
+    List<TaOrderSub> getListByOrder(@Param("orderId") String orderId);
18 24
 }

+ 5
- 0
src/main/java/com/yunzhi/shigongli/mapper/TaPersonAccountMapper.java Wyświetl plik

@@ -3,6 +3,7 @@ package com.yunzhi.shigongli.mapper;
3 3
 import com.yunzhi.shigongli.entity.TaPersonAccount;
4 4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 5
 import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
6 7
 
7 8
 /**
8 9
  * <p>
@@ -15,4 +16,8 @@ import org.apache.ibatis.annotations.Mapper;
15 16
 @Mapper
16 17
 public interface TaPersonAccountMapper extends BaseMapper<TaPersonAccount> {
17 18
 
19
+    TaPersonAccount getByPerson(@Param("personId") String personId);
20
+
21
+    int updateCashBack(@Param("accountId") String accountId, @Param("cashback") Integer cashback);
22
+
18 23
 }

+ 18
- 0
src/main/java/com/yunzhi/shigongli/mapper/TaShopWorkerMapper.java Wyświetl plik

@@ -0,0 +1,18 @@
1
+package com.yunzhi.shigongli.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.yunzhi.shigongli.entity.TaShopWorker;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 民宿员工 Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2021-08-17
14
+ */
15
+@Mapper
16
+public interface TaShopWorkerMapper extends BaseMapper<TaShopWorker> {
17
+
18
+}

+ 5
- 0
src/main/java/com/yunzhi/shigongli/service/ITaOrderPayService.java Wyświetl plik

@@ -1,5 +1,7 @@
1 1
 package com.yunzhi.shigongli.service;
2 2
 
3
+import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
4
+import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
3 5
 import com.yunzhi.shigongli.entity.TaOrderPay;
4 6
 import com.baomidou.mybatisplus.extension.service.IService;
5 7
 
@@ -13,4 +15,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 15
  */
14 16
 public interface ITaOrderPayService extends IService<TaOrderPay> {
15 17
 
18
+    void notifyOrder(WxPayOrderNotifyResult notifyResult) throws Exception;
19
+
20
+    void refundNotifyOrder(WxPayRefundNotifyResult result) throws Exception;
16 21
 }

+ 7
- 0
src/main/java/com/yunzhi/shigongli/service/ITaOrderService.java Wyświetl plik

@@ -1,7 +1,11 @@
1 1
 package com.yunzhi.shigongli.service;
2 2
 
3
+import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
4
+import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
3 5
 import com.yunzhi.shigongli.entity.TaOrder;
4 6
 import com.baomidou.mybatisplus.extension.service.IService;
7
+import com.yunzhi.shigongli.entity.TaPerson;
8
+import com.yunzhi.shigongli.vo.OrderItem;
5 9
 
6 10
 /**
7 11
  * <p>
@@ -13,4 +17,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 17
  */
14 18
 public interface ITaOrderService extends IService<TaOrder> {
15 19
 
20
+    WxPayMpOrderResult order(TaPerson person, OrderItem[] orderItems) throws Exception;
21
+
22
+    void cancelOrder(TaOrder taOrder, TaPerson taPerson) throws Exception;
16 23
 }

+ 2
- 0
src/main/java/com/yunzhi/shigongli/service/ITaPersonAccountService.java Wyświetl plik

@@ -1,5 +1,6 @@
1 1
 package com.yunzhi.shigongli.service;
2 2
 
3
+import com.yunzhi.shigongli.entity.TaOrder;
3 4
 import com.yunzhi.shigongli.entity.TaPersonAccount;
4 5
 import com.baomidou.mybatisplus.extension.service.IService;
5 6
 
@@ -13,4 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 14
  */
14 15
 public interface ITaPersonAccountService extends IService<TaPersonAccount> {
15 16
 
17
+    void cashback(TaOrder taOrder) throws Exception;
16 18
 }

+ 16
- 0
src/main/java/com/yunzhi/shigongli/service/ITaShopWorkerService.java Wyświetl plik

@@ -0,0 +1,16 @@
1
+package com.yunzhi.shigongli.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.yunzhi.shigongli.entity.TaShopWorker;
5
+
6
+/**
7
+ * <p>
8
+ * 民宿员工 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2021-08-17
13
+ */
14
+public interface ITaShopWorkerService extends IService<TaShopWorker> {
15
+
16
+}

+ 99
- 0
src/main/java/com/yunzhi/shigongli/service/impl/TaOrderPayServiceImpl.java Wyświetl plik

@@ -1,9 +1,21 @@
1 1
 package com.yunzhi.shigongli.service.impl;
2 2
 
3
+import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
4
+import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
5
+import com.github.binarywang.wxpay.constant.WxPayConstants;
6
+import com.yunzhi.shigongli.common.Constants;
7
+import com.yunzhi.shigongli.common.DateUtils;
8
+import com.yunzhi.shigongli.entity.TaOrder;
3 9
 import com.yunzhi.shigongli.entity.TaOrderPay;
10
+import com.yunzhi.shigongli.event.PaySuccessEvent;
11
+import com.yunzhi.shigongli.event.RefundSuccessEvent;
12
+import com.yunzhi.shigongli.mapper.TaOrderMapper;
4 13
 import com.yunzhi.shigongli.mapper.TaOrderPayMapper;
14
+import com.yunzhi.shigongli.mapper.TaOrderSubMapper;
5 15
 import com.yunzhi.shigongli.service.ITaOrderPayService;
6 16
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
17
+import org.springframework.beans.factory.annotation.Autowired;
18
+import org.springframework.context.ApplicationEventPublisher;
7 19
 import org.springframework.stereotype.Service;
8 20
 
9 21
 /**
@@ -17,4 +29,91 @@ import org.springframework.stereotype.Service;
17 29
 @Service
18 30
 public class TaOrderPayServiceImpl extends ServiceImpl<TaOrderPayMapper, TaOrderPay> implements ITaOrderPayService {
19 31
 
32
+    @Autowired
33
+    TaOrderPayMapper orderPayMapper;
34
+
35
+    @Autowired
36
+    TaOrderMapper taOrderMapper;
37
+
38
+    @Autowired
39
+    TaOrderSubMapper taOrderSubMapper;
40
+
41
+    @Autowired
42
+    ApplicationEventPublisher eventPublisher;
43
+
44
+    /**
45
+     * 支付回调
46
+     * @param notifyResult
47
+     * @throws Exception
48
+     */
49
+    @Override
50
+    public void notifyOrder(WxPayOrderNotifyResult notifyResult) throws Exception {
51
+        TaOrder taOrder = taOrderMapper.selectById(notifyResult.getOutTradeNo());
52
+        boolean isSuccess = WxPayConstants.ResultCode.SUCCESS.equals(notifyResult.getResultCode());
53
+
54
+        TaOrderPay orderPay = new TaOrderPay();
55
+        orderPay.setOrderId(taOrder.getOrderId());
56
+        orderPay.setPersonId(taOrder.getPersonId());
57
+        orderPay.setCharges(notifyResult.getTotalFee());
58
+        orderPay.setPayDate(DateUtils.from(notifyResult.getTimeEnd(), "yyyyMMddHHmmss"));
59
+        orderPay.setStatus(isSuccess ? Constants.PAY_SUCCESS : Constants.PAY_FAIL);
60
+        orderPay.setMessage(isSuccess ? null : notifyResult.getErrCodeDes());
61
+
62
+        TaOrderPay origin = orderPayMapper.getByOrder(taOrder.getOrderId(), null);
63
+        if (null != origin) {
64
+            orderPay.setPayId(orderPay.getPayId());
65
+            orderPayMapper.updateById(orderPay);
66
+        } else {
67
+            orderPayMapper.insert(orderPay);
68
+        }
69
+
70
+        // 更新订单为已支付
71
+        if (isSuccess) {
72
+            taOrderMapper.updateStatus(taOrder.getOrderId(), Constants.ORDER_PAYED);
73
+            taOrderSubMapper.updateStatusByOrder(taOrder.getOrderId(), Constants.ORDER_PAYED);
74
+        }
75
+
76
+        // 支付成功, 发布返现事件
77
+        if (isSuccess) {
78
+            PaySuccessEvent evt = new PaySuccessEvent(this, taOrder);
79
+            eventPublisher.publishEvent(evt);
80
+        }
81
+    }
82
+
83
+    @Override
84
+    public void refundNotifyOrder(WxPayRefundNotifyResult result) throws Exception {
85
+        WxPayRefundNotifyResult.ReqInfo reqInfo = result.getReqInfo();
86
+        if (null == reqInfo) {
87
+            return;
88
+        }
89
+
90
+        // 退款成功
91
+        boolean isSuccess = WxPayConstants.RefundStatus.SUCCESS.equals(reqInfo.getRefundStatus());
92
+        if (!isSuccess) {
93
+            return;
94
+        }
95
+
96
+        // 此处不能更新订单状态
97
+        // 因为退款分2种情况, 1退款申请, 2订单取消
98
+
99
+        TaOrder taOrder = taOrderMapper.selectById(reqInfo.getOutTradeNo());
100
+
101
+        // 如果退款单号 = R + 订单号, 说明是全订单退款
102
+        if (reqInfo.getOutRefundNo().equals("R"+taOrder.getOrderId())) {
103
+            TaOrderPay orderPay = new TaOrderPay();
104
+            orderPay.setOrderId(taOrder.getOrderId());
105
+            orderPay.setPersonId(taOrder.getPersonId());
106
+            orderPay.setCharges(reqInfo.getRefundFee());
107
+            orderPay.setPayDate(DateUtils.from(reqInfo.getSuccessTime(), "yyyyMMddHHmmss"));
108
+            orderPay.setStatus(isSuccess ? Constants.PAY_SUCCESS : Constants.PAY_FAIL);
109
+            orderPay.setMessage(isSuccess ? null : result.getReturnMsg());
110
+            orderPayMapper.insert(orderPay);
111
+
112
+            RefundSuccessEvent evt = new RefundSuccessEvent(this, taOrder, null);
113
+            eventPublisher.publishEvent(evt);
114
+            return;
115
+        }
116
+
117
+
118
+    }
20 119
 }

+ 241
- 2
src/main/java/com/yunzhi/shigongli/service/impl/TaOrderServiceImpl.java Wyświetl plik

@@ -1,10 +1,22 @@
1 1
 package com.yunzhi.shigongli.service.impl;
2 2
 
3
-import com.yunzhi.shigongli.entity.TaOrder;
4
-import com.yunzhi.shigongli.mapper.TaOrderMapper;
3
+import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
4
+import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
5
+import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
6
+import com.github.binarywang.wxpay.constant.WxPayConstants;
7
+import com.yunzhi.shigongli.common.*;
8
+import com.yunzhi.shigongli.entity.*;
9
+import com.yunzhi.shigongli.mapper.*;
5 10
 import com.yunzhi.shigongli.service.ITaOrderService;
6 11
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
12
+import com.yunzhi.shigongli.vo.OrderItem;
13
+import lombok.extern.slf4j.Slf4j;
14
+import org.springframework.beans.factory.annotation.Autowired;
7 15
 import org.springframework.stereotype.Service;
16
+import org.springframework.transaction.annotation.Transactional;
17
+
18
+import java.time.LocalDateTime;
19
+import java.util.List;
8 20
 
9 21
 /**
10 22
  * <p>
@@ -14,7 +26,234 @@ import org.springframework.stereotype.Service;
14 26
  * @author yansen
15 27
  * @since 2021-08-17
16 28
  */
29
+@Slf4j
17 30
 @Service
18 31
 public class TaOrderServiceImpl extends ServiceImpl<TaOrderMapper, TaOrder> implements ITaOrderService {
19 32
 
33
+    @Autowired
34
+    WxPayUtils wxPayUtils;
35
+
36
+    @Autowired
37
+    TaShopPackageMapper taShopPackageMapper;
38
+
39
+    @Autowired
40
+    TaShopPackageSettingMapper packageSettingMapper;
41
+
42
+    @Autowired
43
+    TaOrderMapper taOrderMapper;
44
+
45
+    @Autowired
46
+    TaOrderSubMapper taOrderSubMapper;
47
+
48
+    @Autowired
49
+    TaOrderCommissionMapper commissionMapper;
50
+
51
+    @Autowired
52
+    TaOrderPayMapper orderPayMapper;
53
+
54
+    /**
55
+     * 下单支付
56
+     * @param person
57
+     * @param orderItems
58
+     * @return
59
+     * @throws Exception
60
+     */
61
+    @Transactional(rollbackFor = Exception.class)
62
+    @Override
63
+    public WxPayMpOrderResult order(TaPerson person, OrderItem[] orderItems) throws Exception {
64
+        LocalDateTime now = LocalDateTime.now();
65
+
66
+        // 先生成主订单
67
+        TaOrder taOrder = new TaOrder();
68
+        taOrder.setOrderId(getOrderNo());
69
+        taOrder.setDescription("套餐");
70
+        taOrder.setPersonId(person.getPersonId());
71
+        // 默认未支付
72
+        taOrder.setStatus(Constants.ORDER_READY);
73
+        taOrder.setCreateDate(now);
74
+
75
+        // 子订单列表
76
+        Integer charge = createAndSaveOrderSubList(taOrder, orderItems);
77
+        taOrder.setCharges(charge);
78
+        save(taOrder);
79
+
80
+        // 发起微信支付订单
81
+        return wxPayUtils.createOrder(person, taOrder);
82
+    }
83
+
84
+    /**
85
+     * 取消订单
86
+     * @param taOrder
87
+     * @param taPerson
88
+     * @throws Exception
89
+     */
90
+    @Transactional(rollbackFor = Exception.class)
91
+    @Override
92
+    public void cancelOrder(TaOrder taOrder, TaPerson taPerson) throws Exception {
93
+        List<TaOrderSub> orderSubList = taOrderSubMapper.getListByOrder(taOrder.getOrderId());
94
+        if (null == orderSubList || orderSubList.size() < 1) {
95
+            throw new Exception("未找到订单详情");
96
+        }
97
+
98
+        // 如果有已核销的, 则不能取消
99
+        Object[] o1 = orderSubList.stream().filter(x -> x.getIsVerified()).toArray();
100
+        if (o1.length > 0) {
101
+            throw new Exception("订单存在已核销内容, 不能取消");
102
+        }
103
+
104
+        // 如果已支付, 则不能取消
105
+        if (Constants.ORDER_PAYED.equals(taOrder.getStatus())) {
106
+            throw new Exception("订单已支付, 请先申请退款");
107
+        }
108
+
109
+        // 只有未支付的, 或者已退款的可以取消
110
+        if (!Constants.ORDER_READY.equals(taOrder.getStatus())
111
+            && !Constants.ORDER_REFUND.equals(taOrder.getStatus())) {
112
+            log.error("退款订单【{}】, 状态为 {}", taOrder.getOrderId(), taOrder.getStatus());
113
+            throw new Exception("订单状态异常, 请联系相关人员");
114
+        }
115
+
116
+        // 只需要更新状态即可
117
+        taOrderMapper.updateStatus(taOrder.getOrderId(), Constants.ORDER_CANCEL);
118
+        taOrderSubMapper.updateStatusByOrder(taOrder.getOrderId(), Constants.ORDER_CANCEL);
119
+    }
120
+
121
+    /**
122
+     * 获取订单号
123
+     * @return
124
+     */
125
+    private String getOrderNo() {
126
+        LocalDateTime now = LocalDateTime.now();
127
+        String today = DateUtils.toString(now, "yyyyMMddHHmm");
128
+        String orderNo = null;
129
+        do {
130
+            String random = StringUtils.random(4);
131
+            orderNo = String.format("%s-%s", today, random);
132
+            TaOrder taOrder = getById(orderNo);
133
+            if (null == taOrder) {
134
+                break;
135
+            }
136
+        } while (true);
137
+
138
+        return orderNo;
139
+    }
140
+
141
+    /**
142
+     * 生成并保存子订单
143
+     * @param taOrder
144
+     * @param orderItems
145
+     * @return
146
+     * @throws Exception
147
+     */
148
+    private Integer createAndSaveOrderSubList(TaOrder taOrder, OrderItem[] orderItems) throws Exception {
149
+        LocalDateTime now = LocalDateTime.now();
150
+
151
+        Integer totalCharge = 0;
152
+        for (int i = 0; i < orderItems.length; i += 1) {
153
+            OrderItem item = orderItems[i];
154
+            String subOrderId = taOrder.getOrderId() + "-" + (i + 1);
155
+            TaOrderSub orderSub = new TaOrderSub();
156
+            orderSub.setSubOrderId(subOrderId);
157
+            orderSub.setOrderId(taOrder.getOrderId());
158
+            // 默认未核销
159
+            orderSub.setIsVerified(false);
160
+            // 未支付
161
+            orderSub.setStatus(Constants.ORDER_READY);
162
+            // 时间
163
+            orderSub.setCreateDate(now);
164
+
165
+            if (StringUtils.isEmpty(item.getItemId())) {
166
+                throw new Exception("订单中存在空的订单项");
167
+            }
168
+            if (null == item.getPrice() || item.getPrice() < 0) {
169
+                throw new Exception("订单中存在不正常的金额");
170
+            }
171
+            if (null == item.getAmount() || item.getAmount() < 0) {
172
+                throw new Exception("订单中存在不正常的数量");
173
+            }
174
+
175
+            // 套餐ID
176
+            String packageId = item.getItemId();
177
+            if (StringUtils.isEmpty(packageId)) {
178
+                throw new Exception("订单中存在空的订单项");
179
+            }
180
+
181
+            // 套餐
182
+            TaShopPackage shopPackage = taShopPackageMapper.selectById(packageId);
183
+            if (null == shopPackage || !Constants.STATUS_NORMAL.equals(shopPackage.getStatus())) {
184
+                throw new Exception("订单中存在异常状态套餐");
185
+            }
186
+            if (shopPackage.getCashback() >= shopPackage.getActualPrice()) {
187
+                throw new Exception("订单中存在异常套餐, 请联系管理员");
188
+            }
189
+
190
+            orderSub.setPackageId(packageId);
191
+
192
+            // 价格
193
+            if (!item.getPrice().equals(shopPackage.getActualPrice())) {
194
+                throw new Exception("订单中存在变化的价格, 请刷新重试");
195
+            }
196
+
197
+            orderSub.setUnitPrice(item.getPrice());
198
+            orderSub.setCharges(item.getPrice() * item.getAmount());
199
+            totalCharge += orderSub.getCharges();
200
+
201
+            // 数量
202
+            orderSub.setAmount(item.getAmount());
203
+
204
+            // 返现设置
205
+            orderSub.setCashback(shopPackage.getCashback());
206
+
207
+            // 套餐分成设置
208
+            TaShopPackageSetting packageSetting = packageSettingMapper.selectById(packageId);
209
+            if (null != packageSetting) {
210
+                // 引流分成
211
+                Integer trafficRate = packageSetting.getTrafficRate();
212
+                Integer trafficCommission = orderSub.getCharges() * (trafficRate / 1000);
213
+                // 平台分成
214
+                Integer platformRate = packageSetting.getPlatformRate();
215
+                Integer platformCommission = orderSub.getCharges() * (platformRate / 1000);
216
+                // 总提成
217
+                Integer commissionCharge = trafficCommission + platformCommission;
218
+                if (commissionCharge + orderSub.getCashback() >= orderSub.getCharges()) {
219
+                    log.error("下单失败; 套餐[{}]抽成与返现设置有问题", packageId);
220
+                    throw new Exception("订单中存在异常套餐, 请联系相关人员");
221
+                }
222
+
223
+                if (trafficCommission > 0) {
224
+                    createAndSaveOrderCommission(orderSub, trafficCommission, Constants.COMMISSION_TRAFFIC);
225
+                }
226
+
227
+                if (platformCommission > 0) {
228
+                    createAndSaveOrderCommission(orderSub, trafficCommission, Constants.COMMISSION_PLATFORM);
229
+                }
230
+
231
+                orderSub.setCommissionCharge(commissionCharge);
232
+            } else {
233
+                orderSub.setCommissionCharge(0);
234
+            }
235
+
236
+            taOrderSubMapper.insert(orderSub);
237
+        }
238
+
239
+        return totalCharge;
240
+    }
241
+
242
+    /**
243
+     * 生成并保存抽成表
244
+     * @param orderSub
245
+     * @param charge
246
+     * @param commissionType
247
+     * @throws Exception
248
+     */
249
+    private void createAndSaveOrderCommission(TaOrderSub orderSub, Integer charge, String commissionType) throws Exception {
250
+        LocalDateTime now = LocalDateTime.now();
251
+        TaOrderCommission orderCommission = new TaOrderCommission();
252
+        orderCommission.setOrderId(orderSub.getOrderId());
253
+        orderCommission.setSubOrderId(orderSub.getSubOrderId());
254
+        orderCommission.setCommissionType(commissionType);
255
+        orderCommission.setCharge(charge);
256
+        orderCommission.setCreateDate(now);
257
+        commissionMapper.insert(orderCommission);
258
+    }
20 259
 }

+ 49
- 0
src/main/java/com/yunzhi/shigongli/service/impl/TaPersonAccountServiceImpl.java Wyświetl plik

@@ -1,10 +1,22 @@
1 1
 package com.yunzhi.shigongli.service.impl;
2 2
 
3
+import com.yunzhi.shigongli.common.Constants;
4
+import com.yunzhi.shigongli.entity.TaOrder;
5
+import com.yunzhi.shigongli.entity.TaOrderSub;
3 6
 import com.yunzhi.shigongli.entity.TaPersonAccount;
7
+import com.yunzhi.shigongli.entity.TaPersonAccountLog;
8
+import com.yunzhi.shigongli.mapper.TaOrderSubMapper;
9
+import com.yunzhi.shigongli.mapper.TaPersonAccountLogMapper;
4 10
 import com.yunzhi.shigongli.mapper.TaPersonAccountMapper;
5 11
 import com.yunzhi.shigongli.service.ITaPersonAccountService;
6 12
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
13
+import lombok.extern.slf4j.Slf4j;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.scheduling.annotation.Async;
7 16
 import org.springframework.stereotype.Service;
17
+import org.springframework.transaction.annotation.Transactional;
18
+
19
+import java.util.List;
8 20
 
9 21
 /**
10 22
  * <p>
@@ -14,7 +26,44 @@ import org.springframework.stereotype.Service;
14 26
  * @author yansen
15 27
  * @since 2021-08-17
16 28
  */
29
+@Slf4j
17 30
 @Service
18 31
 public class TaPersonAccountServiceImpl extends ServiceImpl<TaPersonAccountMapper, TaPersonAccount> implements ITaPersonAccountService {
19 32
 
33
+    @Autowired
34
+    TaOrderSubMapper orderSubMapper;
35
+
36
+    @Autowired
37
+    TaPersonAccountMapper personAccountMapper;
38
+
39
+    @Autowired
40
+    TaPersonAccountMapper accountMapper;
41
+
42
+    @Autowired
43
+    TaPersonAccountLogMapper accountLogMapper;
44
+
45
+    @Async
46
+    @Transactional(rollbackFor = Exception.class)
47
+    @Override
48
+    public void cashback(TaOrder taOrder) throws Exception {
49
+        List<TaOrderSub> orderSubList = orderSubMapper.getListByOrder(taOrder.getOrderId());
50
+
51
+        Integer cashback = 0;
52
+        for(TaOrderSub item : orderSubList) {
53
+            cashback += item.getCashback();
54
+        }
55
+
56
+        TaPersonAccount personAccount = personAccountMapper.getByPerson(taOrder.getPersonId());
57
+        accountMapper.updateCashBack(personAccount.getAccountId(), cashback);
58
+
59
+        TaPersonAccountLog accountLog = new TaPersonAccountLog();
60
+        accountLog.setAccountId(personAccount.getAccountId());
61
+        accountLog.setPersonId(taOrder.getPersonId());
62
+        accountLog.setAmount(cashback);
63
+        accountLog.setSignType(Constants.ACCOUNT_INCOME);
64
+        accountLog.setTargetType(Constants.TARGET_ORDER);
65
+        accountLog.setTargetId(taOrder.getOrderId());
66
+        accountLog.setOrderId(taOrder.getOrderId());
67
+        accountLogMapper.insert(accountLog);
68
+    }
20 69
 }

+ 20
- 0
src/main/java/com/yunzhi/shigongli/service/impl/TaShopWorkerServiceImpl.java Wyświetl plik

@@ -0,0 +1,20 @@
1
+package com.yunzhi.shigongli.service.impl;
2
+
3
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4
+import com.yunzhi.shigongli.entity.TaShopWorker;
5
+import com.yunzhi.shigongli.mapper.TaShopWorkerMapper;
6
+import com.yunzhi.shigongli.service.ITaShopWorkerService;
7
+import org.springframework.stereotype.Service;
8
+
9
+/**
10
+ * <p>
11
+ * 民宿员工 服务实现类
12
+ * </p>
13
+ *
14
+ * @author yansen
15
+ * @since 2021-08-17
16
+ */
17
+@Service
18
+public class TaShopWorkerServiceImpl extends ServiceImpl<TaShopWorkerMapper, TaShopWorker> implements ITaShopWorkerService {
19
+
20
+}

+ 19
- 0
src/main/java/com/yunzhi/shigongli/vo/OrderItem.java Wyświetl plik

@@ -0,0 +1,19 @@
1
+package com.yunzhi.shigongli.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 OrderItem {
11
+    @ApiModelProperty("订单项目ID/套餐ID")
12
+    String itemId;
13
+
14
+    @ApiModelProperty("价格")
15
+    Integer price;
16
+
17
+    @ApiModelProperty("数量")
18
+    Integer amount;
19
+}

+ 3
- 0
src/main/resources/application.yml Wyświetl plik

@@ -13,6 +13,7 @@ interceptor:
13 13
       - /admin/login
14 14
       - /admin/logout
15 15
       - /ma/login
16
+      - /wxpay/notify/order
16 17
       - /swagger-ui/**
17 18
       - /swagger-resources/**
18 19
       - /v2/**
@@ -57,6 +58,8 @@ weixin:
57 58
     subAppId:
58 59
     subMchId:
59 60
     keyPath: /yunpan/shigongli/cert/apiclient_cert.p12
61
+    notifyUrl: https://sgl.njyunzhi.com/api/wxpay/notify/order
62
+    refundNotifyUrl: https://sgl.njyunzhi.com/api/wxpay/notify/refund
60 63
 
61 64
 ###
62 65
 spring:

+ 6
- 0
src/main/resources/mapper/TaOrderMapper.xml Wyświetl plik

@@ -2,4 +2,10 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.yunzhi.shigongli.mapper.TaOrderMapper">
4 4
 
5
+    <update id="updateStatus">
6
+        UPDATE ta_order
7
+        SET `status` = #{status}
8
+        WHERE
9
+            order_id = #{orderId}
10
+    </update>
5 11
 </mapper>

+ 15
- 0
src/main/resources/mapper/TaOrderPayMapper.xml Wyświetl plik

@@ -2,4 +2,19 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.yunzhi.shigongli.mapper.TaOrderPayMapper">
4 4
 
5
+    <select id="getByOrder" resultType="com.yunzhi.shigongli.entity.TaOrderPay">
6
+        SELECT
7
+            *
8
+        FROM
9
+            ta_order_pay t
10
+        WHERE
11
+            t.order_id = #{orderId}
12
+          <if test="subOrderId != null and subOrderId != ''">
13
+              AND t.sub_order_id = #{subOrderId}
14
+          </if>
15
+          <if test="subOrderId == null or subOrderId == ''">
16
+              AND (t.sub_order_id IS NULL OR t.sub_order_id = '')
17
+          </if>
18
+            AND is_refund = 0
19
+    </select>
5 20
 </mapper>

+ 12
- 0
src/main/resources/mapper/TaOrderSubMapper.xml Wyświetl plik

@@ -2,4 +2,16 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.yunzhi.shigongli.mapper.TaOrderSubMapper">
4 4
 
5
+    <update id="updateStatusByOrder">
6
+        UPDATE ta_order_sub
7
+        SET `status` = #{status}
8
+        WHERE
9
+            order_id = #{orderId}
10
+    </update>
11
+    <select id="getListByOrder" resultType="com.yunzhi.shigongli.entity.TaOrderSub">
12
+        SELECT * FROM ta_order_sub
13
+        WHERE
14
+            order_id = #{orderId}
15
+            AND `status` &gt; -1
16
+    </select>
5 17
 </mapper>

+ 15
- 0
src/main/resources/mapper/TaPersonAccountMapper.xml Wyświetl plik

@@ -1,5 +1,20 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.yunzhi.shigongli.mapper.TaPersonAccountMapper">
4
+    <update id="updateCashBack">
5
+        UPDATE ta_person_account t
6
+        SET t.amounts = t.amounts + ${cashback},
7
+            t.cashback_charges = t.cashback_charges + ${cashback}
8
+        WHERE
9
+            t.account_id = #{accountId}
10
+    </update>
4 11
 
12
+    <select id="getByPerson" resultType="com.yunzhi.shigongli.entity.TaPersonAccount">
13
+        SELECT
14
+            *
15
+        FROM
16
+            ta_person_account
17
+        WHERE
18
+            person_id = #{personId}
19
+    </select>
5 20
 </mapper>

+ 5
- 0
src/main/resources/mapper/TaShopWorkerMapper.xml Wyświetl plik

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