Your Name 3 lat temu
rodzic
commit
bd3afda897
33 zmienionych plików z 623 dodań i 86 usunięć
  1. 19
    0
      src/main/java/com/yunzhi/shigongli/common/CommUtils.java
  2. 11
    0
      src/main/java/com/yunzhi/shigongli/common/Constants.java
  3. 26
    1
      src/main/java/com/yunzhi/shigongli/common/WxPayUtils.java
  4. 23
    9
      src/main/java/com/yunzhi/shigongli/controller/TaHotelController.java
  5. 28
    28
      src/main/java/com/yunzhi/shigongli/controller/TaOrderController.java
  6. 82
    27
      src/main/java/com/yunzhi/shigongli/controller/TaOrderSubController.java
  7. 1
    0
      src/main/java/com/yunzhi/shigongli/controller/WxPayController.java
  8. 2
    1
      src/main/java/com/yunzhi/shigongli/entity/TaOrderSub.java
  9. 23
    0
      src/main/java/com/yunzhi/shigongli/event/listener/RefundSuccessEventListener.java
  10. 4
    0
      src/main/java/com/yunzhi/shigongli/mapper/TaHotelAccountMapper.java
  11. 4
    0
      src/main/java/com/yunzhi/shigongli/mapper/TaHotelMapper.java
  12. 4
    0
      src/main/java/com/yunzhi/shigongli/mapper/TaOrderCommissionMapper.java
  13. 4
    0
      src/main/java/com/yunzhi/shigongli/mapper/TaOrderSubMapper.java
  14. 2
    0
      src/main/java/com/yunzhi/shigongli/mapper/TaPersonRecommenderMapper.java
  15. 4
    0
      src/main/java/com/yunzhi/shigongli/mapper/TaShopAccountMapper.java
  16. 9
    0
      src/main/java/com/yunzhi/shigongli/service/IBaseService.java
  17. 1
    0
      src/main/java/com/yunzhi/shigongli/service/ITaHotelAccountService.java
  18. 10
    1
      src/main/java/com/yunzhi/shigongli/service/ITaHotelService.java
  19. 5
    0
      src/main/java/com/yunzhi/shigongli/service/ITaOrderSubService.java
  20. 2
    0
      src/main/java/com/yunzhi/shigongli/service/ITaPersonAccountService.java
  21. 23
    0
      src/main/java/com/yunzhi/shigongli/service/impl/BaseServiceImpl.java
  22. 18
    0
      src/main/java/com/yunzhi/shigongli/service/impl/TaHotelAccountServiceImpl.java
  23. 42
    1
      src/main/java/com/yunzhi/shigongli/service/impl/TaHotelServiceImpl.java
  24. 16
    16
      src/main/java/com/yunzhi/shigongli/service/impl/TaOrderPayServiceImpl.java
  25. 138
    2
      src/main/java/com/yunzhi/shigongli/service/impl/TaOrderSubServiceImpl.java
  26. 2
    0
      src/main/java/com/yunzhi/shigongli/service/impl/TaPersonAccountServiceImpl.java
  27. 40
    0
      src/main/java/com/yunzhi/shigongli/vo/HotelListVO.java
  28. 15
    0
      src/main/resources/mapper/TaHotelAccountMapper.xml
  29. 18
    0
      src/main/resources/mapper/TaHotelMapper.xml
  30. 8
    0
      src/main/resources/mapper/TaOrderCommissionMapper.xml
  31. 13
    0
      src/main/resources/mapper/TaOrderSubMapper.xml
  32. 11
    0
      src/main/resources/mapper/TaPersonRecommenderMapper.xml
  33. 15
    0
      src/main/resources/mapper/TaShopAccountMapper.xml

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

@@ -0,0 +1,19 @@
1
+package com.yunzhi.shigongli.common;
2
+
3
+import com.yunzhi.shigongli.service.ITaHotelAccountService;
4
+import org.springframework.beans.factory.annotation.Autowired;
5
+import org.springframework.stereotype.Component;
6
+
7
+import javax.annotation.PostConstruct;
8
+
9
+@Component
10
+public class CommUtils {
11
+
12
+    @Autowired
13
+    ITaHotelAccountService iTaHotelAccountService;
14
+
15
+    @PostConstruct
16
+    public void init() {
17
+        iTaHotelAccountService.initSystemAccount();
18
+    }
19
+}

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

@@ -20,12 +20,23 @@ public class Constants {
20 20
     public final static String COMMISSION_TRAFFIC = "traffic";  // 引流抽成
21 21
     public final static String COMMISSION_PLATFORM = "platform";  // 平台抽成
22 22
 
23
+    // 平台账户ID
24
+    public final static String SYSTEM_ACCOUNT_ID = "sys_plat";
25
+
23 26
     // 账户流水
24 27
     public final static Integer ACCOUNT_INCOME = 1;     // 收入
25 28
     public final static Integer ACCOUNT_EXPENSE = -1;   // 支出
26 29
 
30
+    // 账户金额类型
31
+    public final static String ACCOUNT_CASHBACK = "cashback";       // 返现
32
+    public final static String ACCOUNT_COMMISSION = "commission";   // 抽成
33
+
27 34
     // 系统模块
28 35
     public final static String TARGET_ORDER = "order";  // 订单
29 36
     public final static String TARGET_HOTEL = "hotel";  // 民宿
30 37
     public final static String TARGET_SHOP = "shop";    // 商铺
38
+
39
+    // 推荐人类型
40
+    public final static String RECOMMEND_SHOP = "shop";     // 商铺
41
+    public final static String RECOMMEND_HOTEL = "hotel";   // 民宿
31 42
 }

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

@@ -8,6 +8,7 @@ import com.github.binarywang.wxpay.constant.WxPayConstants;
8 8
 import com.github.binarywang.wxpay.service.WxPayService;
9 9
 import com.yunzhi.shigongli.config.WeixinConfig;
10 10
 import com.yunzhi.shigongli.entity.TaOrder;
11
+import com.yunzhi.shigongli.entity.TaOrderSub;
11 12
 import com.yunzhi.shigongli.entity.TaPerson;
12 13
 import org.springframework.beans.factory.annotation.Autowired;
13 14
 import org.springframework.stereotype.Component;
@@ -49,7 +50,7 @@ public class WxPayUtils {
49 50
     }
50 51
 
51 52
     /**
52
-     * 退款
53
+     * 订单退款
53 54
      * @param taOrder
54 55
      * @param cashback
55 56
      * @return
@@ -71,4 +72,28 @@ public class WxPayUtils {
71 72
 
72 73
         return result;
73 74
     }
75
+
76
+    /**
77
+     * 订单项目退款
78
+     * @param taOrder
79
+     * @param taOrderSub
80
+     * @return
81
+     * @throws Exception
82
+     */
83
+    public WxPayRefundResult refund(TaOrder taOrder, TaOrderSub taOrderSub) throws Exception {
84
+        WxPayService payService = wxUtils.getPayService();
85
+        WxPayRefundRequest refundRequest = new WxPayRefundRequest();
86
+        refundRequest.setOutTradeNo(taOrderSub.getOrderId());
87
+        refundRequest.setOutRefundNo("R"+taOrderSub.getSubOrderId());
88
+        refundRequest.setTotalFee(taOrder.getCharges());
89
+        refundRequest.setRefundFee(taOrderSub.getCharges() - taOrderSub.getCashback());
90
+        refundRequest.setNotifyUrl(config.getPay().getRefundNotifyUrl());
91
+        WxPayRefundResult result = payService.refund(refundRequest);
92
+
93
+        if (!WxPayConstants.ResultCode.SUCCESS.equals(result.getResultCode())) {
94
+            throw new Exception(result.getErrCodeDes());
95
+        }
96
+
97
+        return result;
98
+    }
74 99
 }

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

@@ -1,10 +1,13 @@
1 1
 package com.yunzhi.shigongli.controller;
2 2
 
3
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.shigongli.common.BaseController;
7
+import com.yunzhi.shigongli.common.Constants;
7 8
 import com.yunzhi.shigongli.common.ResponseBean;
9
+import com.yunzhi.shigongli.common.StringUtils;
10
+import com.yunzhi.shigongli.vo.HotelListVO;
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.ITaHotelService;
20 23
 import com.yunzhi.shigongli.entity.TaHotel;
21 24
 import org.springframework.web.bind.annotation.RestController;
22 25
 
26
+import java.util.List;
27
+
23 28
 /**
24 29
  * <p>
25 30
     * 民宿 前端控制器
@@ -50,14 +55,13 @@ public class TaHotelController extends BaseController {
50 55
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51 56
     public ResponseBean taHotelList(@ApiParam(value = "客户端", allowableValues = "wx,admin") @PathVariable String plat,
52 57
                                     @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
53
-                                    @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
58
+                                    @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
59
+                                    @ApiParam("名称") @RequestParam(value = "hotelName",required = false) String hotelName) throws Exception{
54 60
 
55
-		    IPage<TaHotel> pg = new Page<>(pageNum, pageSize);
56
-            QueryWrapper<TaHotel> queryWrapper = new QueryWrapper<>();
57
-            queryWrapper.orderByDesc("create_date");
58 61
 
59
-            IPage<TaHotel> result = iTaHotelService.page(pg, queryWrapper);
60
-            return ResponseBean.success(result);
62
+        IPage<TaHotel> pg = new Page<>(pageNum, pageSize);
63
+        IPage<HotelListVO> result = iTaHotelService.getVOListBy(pg, hotelName);
64
+        return ResponseBean.success(result);
61 65
     }
62 66
 
63 67
     /**
@@ -69,7 +73,12 @@ public class TaHotelController extends BaseController {
69 73
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
70 74
     public ResponseBean taHotelAdd(@ApiParam("保存内容") @RequestBody TaHotel taHotel) throws Exception{
71 75
 
72
-        if (iTaHotelService.save(taHotel)){
76
+        List<TaHotel> lst = iTaHotelService.getByName(taHotel.getHotelName());
77
+        if (null != lst && lst.size() > 0) {
78
+            return ResponseBean.error("民宿名称已存在", ResponseBean.ERROR_ILLEGAL_PARAMS);
79
+        }
80
+
81
+        if (iTaHotelService.createNew(taHotel)){
73 82
             return ResponseBean.success(taHotel);
74 83
         }else {
75 84
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
@@ -83,7 +92,7 @@ public class TaHotelController extends BaseController {
83 92
     @RequestMapping(value="/admin/taHotel/{id}", method= RequestMethod.DELETE)
84 93
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
85 94
     public ResponseBean taHotelDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
86
-        if(iTaHotelService.removeById(id)){
95
+        if(iTaHotelService.removeLogicById(id)){
87 96
             return ResponseBean.success("success");
88 97
         }else {
89 98
             return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
@@ -101,6 +110,11 @@ public class TaHotelController extends BaseController {
101 110
     public ResponseBean taHotelUpdate(@ApiParam("对象ID") @PathVariable String id,
102 111
                                         @ApiParam("更新内容") @RequestBody TaHotel taHotel) throws Exception{
103 112
 
113
+        List<TaHotel> lst = iTaHotelService.getByName(taHotel.getHotelName());
114
+        if (null != lst && lst.size() > 0) {
115
+            return ResponseBean.error("民宿名称已存在", ResponseBean.ERROR_ILLEGAL_PARAMS);
116
+        }
117
+
104 118
         if (iTaHotelService.updateById(taHotel)){
105 119
             return ResponseBean.success(iTaHotelService.getById(id));
106 120
         }else {

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

@@ -123,32 +123,32 @@ public class TaOrderController extends BaseController {
123 123
 //        }
124 124
 //    }
125 125
 
126
-    /**
127
-     * 修改对象
128
-     * @param id  实体ID
129
-     * @param taOrder 实体对象
130
-     * @return
131
-     */
132
-    @RequestMapping(value="/wx/taOrder/{id}",method= RequestMethod.PUT)
133
-    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
134
-    public ResponseBean taOrderUpdate(@ApiParam("对象ID") @PathVariable Integer id,
135
-                                        @ApiParam("更新内容") @RequestBody TaOrder taOrder) throws Exception{
136
-
137
-        if (iTaOrderService.updateById(taOrder)){
138
-            return ResponseBean.success(iTaOrderService.getById(id));
139
-        }else {
140
-            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
141
-        }
142
-    }
143
-
144
-    /**
145
-     * 根据id查询对象
146
-     * @param id  实体ID
147
-     */
148
-    @RequestMapping(value="/{plat}/taOrder/{id}",method= RequestMethod.GET)
149
-    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
150
-    public ResponseBean taOrderGet(@ApiParam("客户端") @PathVariable String plat,
151
-                                   @ApiParam("对象ID") @PathVariable Integer id) throws Exception{
152
-        return ResponseBean.success(iTaOrderService.getById(id));
153
-    }
126
+//    /**
127
+//     * 修改对象
128
+//     * @param id  实体ID
129
+//     * @param taOrder 实体对象
130
+//     * @return
131
+//     */
132
+//    @RequestMapping(value="/wx/taOrder/{id}",method= RequestMethod.PUT)
133
+//    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
134
+//    public ResponseBean taOrderUpdate(@ApiParam("对象ID") @PathVariable Integer id,
135
+//                                        @ApiParam("更新内容") @RequestBody TaOrder taOrder) throws Exception{
136
+//
137
+//        if (iTaOrderService.updateById(taOrder)){
138
+//            return ResponseBean.success(iTaOrderService.getById(id));
139
+//        }else {
140
+//            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
141
+//        }
142
+//    }
143
+//
144
+//    /**
145
+//     * 根据id查询对象
146
+//     * @param id  实体ID
147
+//     */
148
+//    @RequestMapping(value="/{plat}/taOrder/{id}",method= RequestMethod.GET)
149
+//    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
150
+//    public ResponseBean taOrderGet(@ApiParam("客户端") @PathVariable String plat,
151
+//                                   @ApiParam("对象ID") @PathVariable Integer id) throws Exception{
152
+//        return ResponseBean.success(iTaOrderService.getById(id));
153
+//    }
154 154
 }

+ 82
- 27
src/main/java/com/yunzhi/shigongli/controller/TaOrderSubController.java Wyświetl plik

@@ -4,21 +4,20 @@ 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 6
 import com.yunzhi.shigongli.common.BaseController;
7
+import com.yunzhi.shigongli.common.Constants;
7 8
 import com.yunzhi.shigongli.common.ResponseBean;
9
+import com.yunzhi.shigongli.entity.TaOrder;
10
+import com.yunzhi.shigongli.entity.TaPerson;
11
+import com.yunzhi.shigongli.service.ITaOrderService;
8 12
 import io.swagger.annotations.Api;
9 13
 import io.swagger.annotations.ApiOperation;
10 14
 import io.swagger.annotations.ApiParam;
11 15
 import org.slf4j.Logger;
12 16
 import org.slf4j.LoggerFactory;
13 17
 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;
18
+import org.springframework.web.bind.annotation.*;
19 19
 import com.yunzhi.shigongli.service.ITaOrderSubService;
20 20
 import com.yunzhi.shigongli.entity.TaOrderSub;
21
-import org.springframework.web.bind.annotation.RestController;
22 21
 
23 22
 /**
24 23
  * <p>
@@ -39,6 +38,8 @@ public class TaOrderSubController extends BaseController {
39 38
     @Autowired
40 39
     public ITaOrderSubService iTaOrderSubService;
41 40
 
41
+    @Autowired
42
+    public ITaOrderService iTaOrderService;
42 43
 
43 44
     /**
44 45
      * 分页查询列表
@@ -61,35 +62,89 @@ public class TaOrderSubController extends BaseController {
61 62
     }
62 63
 
63 64
     /**
64
-     * 保存对象
65
-     * @param taOrderSub 实体对象
65
+     * 订单项目退款
66
+     * @param id
66 67
      * @return
68
+     * @throws Exception
67 69
      */
68
-    @RequestMapping(value="/wx/taOrderSub",method= RequestMethod.POST)
69
-    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
70
-    public ResponseBean taOrderSubAdd(@ApiParam("保存内容") @RequestBody TaOrderSub taOrderSub) throws Exception{
71
-
72
-        if (iTaOrderSubService.save(taOrderSub)){
73
-            return ResponseBean.success(taOrderSub);
74
-        }else {
75
-            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
70
+    @DeleteMapping("/wx/orderSub/{id}/refund")
71
+    @ApiOperation(value="订单项目退款", notes = "订单项目退款", httpMethod = "DELETE", response = ResponseBean.class)
72
+    public ResponseBean refund(@ApiParam(value = "订单项目ID") @PathVariable String id) throws Exception {
73
+        TaOrderSub taOrderSub = iTaOrderSubService.getById(id);
74
+        if (Constants.STATUS_DELETED.equals(taOrderSub.getStatus())) {
75
+            return ResponseBean.error("未找到退款项目", ResponseBean.ERROR_ILLEGAL_PARAMS);
76
+        }
77
+
78
+        TaOrder taOrder = iTaOrderService.getById(taOrderSub.getOrderId());
79
+        if (Constants.STATUS_DELETED.equals(taOrder.getStatus())) {
80
+            return ResponseBean.error("未找到当前订单", ResponseBean.ERROR_ILLEGAL_PARAMS);
81
+        }
82
+
83
+        if (!Constants.ORDER_PAYED.equals(taOrderSub.getStatus())) {
84
+            return ResponseBean.error("当前项目未支付", ResponseBean.ERROR_ILLEGAL_PARAMS);
76 85
         }
86
+
87
+        TaPerson taPerson = getCurrentPerson();
88
+
89
+        if (!taPerson.getPersonId().equals(taOrder.getPersonId())) {
90
+            return ResponseBean.error("您无权操作当前订单项目", ResponseBean.ERROR_ILLEGAL_PARAMS);
91
+        }
92
+
93
+        iTaOrderSubService.refund(taPerson, taOrder, taOrderSub);
94
+
95
+        return ResponseBean.success("操作完成");
77 96
     }
78 97
 
79
-    /**
80
-     * 根据id删除对象
81
-     * @param id  实体ID
82
-     */
83
-    @RequestMapping(value="/wx/taOrderSub/{id}", method= RequestMethod.DELETE)
84
-    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
85
-    public ResponseBean taOrderSubDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
86
-        if(iTaOrderSubService.removeById(id)){
87
-            return ResponseBean.success("success");
88
-        }else {
89
-            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
98
+    @PutMapping("/wx/orderSub/{id}/valid")
99
+    @ApiOperation(value="订单项目核销", notes = "订单项目核销", httpMethod = "PUT", response = ResponseBean.class)
100
+    public ResponseBean valdiation(@ApiParam(value = "订单项目ID") @PathVariable String id) throws Exception {
101
+        TaPerson taPerson = getCurrentPerson();
102
+        TaOrderSub taOrderSub = iTaOrderSubService.getById(id);
103
+        TaOrder taOrder = iTaOrderService.getById(taOrderSub.getOrderId());
104
+
105
+        if (!taPerson.getPersonId().equals(taOrder.getPersonId())) {
106
+            return ResponseBean.error("您不能核销当前套餐", ResponseBean.ERROR_ILLEGAL_PARAMS);
90 107
         }
108
+
109
+        if (!Constants.ORDER_PAYED.equals(taOrderSub.getStatus())) {
110
+            return ResponseBean.error("套餐未支付或者状态异常", ResponseBean.ERROR_ILLEGAL_PARAMS);
111
+        }
112
+
113
+        iTaOrderSubService.validation(taPerson, taOrder, taOrderSub);
114
+
115
+        return ResponseBean.success("核销成功");
91 116
     }
92 117
 
118
+//    /**
119
+//     * 保存对象
120
+//     * @param taOrderSub 实体对象
121
+//     * @return
122
+//     */
123
+//    @RequestMapping(value="/wx/taOrderSub",method= RequestMethod.POST)
124
+//    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
125
+//    public ResponseBean taOrderSubAdd(@ApiParam("保存内容") @RequestBody TaOrderSub taOrderSub) throws Exception{
126
+//
127
+//        if (iTaOrderSubService.save(taOrderSub)){
128
+//            return ResponseBean.success(taOrderSub);
129
+//        }else {
130
+//            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
131
+//        }
132
+//    }
133
+//
134
+//    /**
135
+//     * 根据id删除对象
136
+//     * @param id  实体ID
137
+//     */
138
+//    @RequestMapping(value="/wx/taOrderSub/{id}", method= RequestMethod.DELETE)
139
+//    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
140
+//    public ResponseBean taOrderSubDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
141
+//        if(iTaOrderSubService.removeById(id)){
142
+//            return ResponseBean.success("success");
143
+//        }else {
144
+//            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
145
+//        }
146
+//    }
147
+
93 148
 //    /**
94 149
 //     * 修改对象
95 150
 //     * @param id  实体ID

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

@@ -5,6 +5,7 @@ import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
5 5
 import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
6 6
 import com.github.binarywang.wxpay.service.WxPayService;
7 7
 import com.yunzhi.shigongli.common.BaseController;
8
+import com.yunzhi.shigongli.common.Constants;
8 9
 import com.yunzhi.shigongli.common.WxUtils;
9 10
 import com.yunzhi.shigongli.service.ITaOrderPayService;
10 11
 import io.swagger.annotations.Api;

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

@@ -64,5 +64,6 @@ public class TaOrderSub implements Serializable {
64 64
     @ApiModelProperty(value = "创建时间")
65 65
     private LocalDateTime createDate;
66 66
 
67
-
67
+    @ApiModelProperty(value = "核销时间")
68
+    private LocalDateTime verifiedDate;
68 69
 }

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

@@ -0,0 +1,23 @@
1
+package com.yunzhi.shigongli.event.listener;
2
+
3
+import com.yunzhi.shigongli.entity.TaOrder;
4
+import com.yunzhi.shigongli.entity.TaOrderSub;
5
+import com.yunzhi.shigongli.event.RefundSuccessEvent;
6
+import com.yunzhi.shigongli.service.ITaPersonAccountService;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.context.ApplicationListener;
9
+import org.springframework.stereotype.Component;
10
+
11
+@Component
12
+public class RefundSuccessEventListener  implements ApplicationListener<RefundSuccessEvent> {
13
+    @Autowired
14
+    ITaPersonAccountService personAccountService;
15
+
16
+    @Override
17
+    public void onApplicationEvent(RefundSuccessEvent evt) {
18
+        TaOrder taOrder = evt.getTaOrder();
19
+        TaOrderSub taOrderSub = evt.getTaOrderSub();
20
+
21
+        // 暂时不需要处理什么
22
+    }
23
+}

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

@@ -3,6 +3,7 @@ package com.yunzhi.shigongli.mapper;
3 3
 import com.yunzhi.shigongli.entity.TaHotelAccount;
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,7 @@ import org.apache.ibatis.annotations.Mapper;
15 16
 @Mapper
16 17
 public interface TaHotelAccountMapper extends BaseMapper<TaHotelAccount> {
17 18
 
19
+    TaHotelAccount selectByHotel(@Param("hotelId") String hotelId);
20
+
21
+    int updateCommission(@Param("accountId") String accountId, @Param("amount") Integer amount);
18 22
 }

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

@@ -1,8 +1,11 @@
1 1
 package com.yunzhi.shigongli.mapper;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.yunzhi.shigongli.entity.TaHotel;
4 5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
+import com.yunzhi.shigongli.vo.HotelListVO;
5 7
 import org.apache.ibatis.annotations.Mapper;
8
+import org.apache.ibatis.annotations.Param;
6 9
 
7 10
 /**
8 11
  * <p>
@@ -15,4 +18,5 @@ import org.apache.ibatis.annotations.Mapper;
15 18
 @Mapper
16 19
 public interface TaHotelMapper extends BaseMapper<TaHotel> {
17 20
 
21
+    IPage<HotelListVO> getVOListBy(IPage<TaHotel> pg, @Param("hotelName") String hotelName);
18 22
 }

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

@@ -3,6 +3,9 @@ package com.yunzhi.shigongli.mapper;
3 3
 import com.yunzhi.shigongli.entity.TaOrderCommission;
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,5 @@ import org.apache.ibatis.annotations.Mapper;
15 18
 @Mapper
16 19
 public interface TaOrderCommissionMapper extends BaseMapper<TaOrderCommission> {
17 20
 
21
+    List<TaOrderCommission> getListByOrderSub(@Param("subOrderId") String subOrderId);
18 22
 }

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

@@ -21,4 +21,8 @@ public interface TaOrderSubMapper extends BaseMapper<TaOrderSub> {
21 21
     int updateStatusByOrder(@Param("orderId") String orderId, @Param("status") Integer status);
22 22
 
23 23
     List<TaOrderSub> getListByOrder(@Param("orderId") String orderId);
24
+
25
+    int updateStatus(@Param("subOrderId") String subOrderId, @Param("status") Integer status);
26
+
27
+    int updateVerified(@Param("subOrderId") String subOrderId, @Param("isVerified") int isVerified);
24 28
 }

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

@@ -3,6 +3,7 @@ package com.yunzhi.shigongli.mapper;
3 3
 import com.yunzhi.shigongli.entity.TaPersonRecommender;
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 TaPersonRecommenderMapper extends BaseMapper<TaPersonRecommender> {
17 18
 
19
+    TaPersonRecommender getAcitveRecommender(@Param("personId") String personId);
18 20
 }

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

@@ -3,6 +3,7 @@ package com.yunzhi.shigongli.mapper;
3 3
 import com.yunzhi.shigongli.entity.TaShopAccount;
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,7 @@ import org.apache.ibatis.annotations.Mapper;
15 16
 @Mapper
16 17
 public interface TaShopAccountMapper extends BaseMapper<TaShopAccount> {
17 18
 
19
+    TaShopAccount selectByShop(@Param("shopId") String shopId);
20
+
21
+    int updateCommission(@Param("accountId") String accountId, @Param("amount") Integer amount);
18 22
 }

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

@@ -0,0 +1,9 @@
1
+package com.yunzhi.shigongli.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+
5
+import java.io.Serializable;
6
+
7
+public interface IBaseService<T> extends IService<T> {
8
+    boolean removeLogicById(Serializable id);
9
+}

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

@@ -13,4 +13,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 13
  */
14 14
 public interface ITaHotelAccountService extends IService<TaHotelAccount> {
15 15
 
16
+    void initSystemAccount();
16 17
 }

+ 10
- 1
src/main/java/com/yunzhi/shigongli/service/ITaHotelService.java Wyświetl plik

@@ -1,7 +1,11 @@
1 1
 package com.yunzhi.shigongli.service;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.yunzhi.shigongli.entity.TaHotel;
4 5
 import com.baomidou.mybatisplus.extension.service.IService;
6
+import com.yunzhi.shigongli.vo.HotelListVO;
7
+
8
+import java.util.List;
5 9
 
6 10
 /**
7 11
  * <p>
@@ -11,6 +15,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
11 15
  * @author yansen
12 16
  * @since 2021-08-17
13 17
  */
14
-public interface ITaHotelService extends IService<TaHotel> {
18
+public interface ITaHotelService extends IBaseService<TaHotel> {
19
+
20
+    List<TaHotel> getByName(String hotelName);
21
+
22
+    boolean createNew(TaHotel taHotel) throws Exception;
15 23
 
24
+    IPage<HotelListVO> getVOListBy(IPage<TaHotel> pg, String hotelName);
16 25
 }

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

@@ -1,7 +1,9 @@
1 1
 package com.yunzhi.shigongli.service;
2 2
 
3
+import com.yunzhi.shigongli.entity.TaOrder;
3 4
 import com.yunzhi.shigongli.entity.TaOrderSub;
4 5
 import com.baomidou.mybatisplus.extension.service.IService;
6
+import com.yunzhi.shigongli.entity.TaPerson;
5 7
 
6 8
 /**
7 9
  * <p>
@@ -13,4 +15,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 15
  */
14 16
 public interface ITaOrderSubService extends IService<TaOrderSub> {
15 17
 
18
+    void refund(TaPerson person, TaOrder taOrder, TaOrderSub taOrderSub) throws Exception;
19
+
20
+    void validation(TaPerson taPerson, TaOrder taOrder, TaOrderSub taOrderSub) throws Exception;
16 21
 }

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

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

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

@@ -0,0 +1,23 @@
1
+package com.yunzhi.shigongli.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import com.baomidou.mybatisplus.core.metadata.TableInfo;
6
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
8
+import com.yunzhi.shigongli.service.IBaseService;
9
+
10
+import java.io.Serializable;
11
+
12
+public class BaseServiceImpl <M extends BaseMapper<T>, T> extends ServiceImpl <M, T> implements IBaseService<T> {
13
+    @Override
14
+    public boolean removeLogicById(Serializable id) {
15
+
16
+        TableInfo tableInfo = SqlHelper.table(currentModelClass());
17
+        UpdateWrapper<T> updateWrapper = new UpdateWrapper<>();
18
+        updateWrapper.set("status", -1)
19
+                .eq(tableInfo.getKeyColumn(), id);
20
+
21
+        return update(updateWrapper);
22
+    }
23
+}

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

@@ -1,9 +1,12 @@
1 1
 package com.yunzhi.shigongli.service.impl;
2 2
 
3
+import com.yunzhi.shigongli.common.Constants;
3 4
 import com.yunzhi.shigongli.entity.TaHotelAccount;
4 5
 import com.yunzhi.shigongli.mapper.TaHotelAccountMapper;
5 6
 import com.yunzhi.shigongli.service.ITaHotelAccountService;
6 7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
+import org.omg.PortableInterceptor.ACTIVE;
9
+import org.springframework.scheduling.annotation.Async;
7 10
 import org.springframework.stereotype.Service;
8 11
 
9 12
 /**
@@ -17,4 +20,19 @@ import org.springframework.stereotype.Service;
17 20
 @Service
18 21
 public class TaHotelAccountServiceImpl extends ServiceImpl<TaHotelAccountMapper, TaHotelAccount> implements ITaHotelAccountService {
19 22
 
23
+    @Async
24
+    @Override
25
+    public void initSystemAccount() {
26
+        try {
27
+            TaHotelAccount account = getById(Constants.SYSTEM_ACCOUNT_ID);
28
+            if (null == account) {
29
+                account = new TaHotelAccount();
30
+                account.setAccountId(Constants.SYSTEM_ACCOUNT_ID);
31
+                account.setHotelId(Constants.SYSTEM_ACCOUNT_ID);
32
+                save(account);
33
+            }
34
+        } catch (Exception e) {
35
+            e.printStackTrace();
36
+        }
37
+    }
20 38
 }

+ 42
- 1
src/main/java/com/yunzhi/shigongli/service/impl/TaHotelServiceImpl.java Wyświetl plik

@@ -1,10 +1,20 @@
1 1
 package com.yunzhi.shigongli.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.yunzhi.shigongli.common.Constants;
3 6
 import com.yunzhi.shigongli.entity.TaHotel;
7
+import com.yunzhi.shigongli.entity.TaHotelAccount;
8
+import com.yunzhi.shigongli.mapper.TaHotelAccountMapper;
4 9
 import com.yunzhi.shigongli.mapper.TaHotelMapper;
5 10
 import com.yunzhi.shigongli.service.ITaHotelService;
6 11
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
12
+import com.yunzhi.shigongli.vo.HotelListVO;
13
+import org.springframework.beans.factory.annotation.Autowired;
7 14
 import org.springframework.stereotype.Service;
15
+import org.springframework.transaction.annotation.Transactional;
16
+
17
+import java.util.List;
8 18
 
9 19
 /**
10 20
  * <p>
@@ -15,6 +25,37 @@ import org.springframework.stereotype.Service;
15 25
  * @since 2021-08-17
16 26
  */
17 27
 @Service
18
-public class TaHotelServiceImpl extends ServiceImpl<TaHotelMapper, TaHotel> implements ITaHotelService {
28
+public class TaHotelServiceImpl extends BaseServiceImpl<TaHotelMapper, TaHotel> implements ITaHotelService {
29
+
30
+    @Autowired
31
+    TaHotelMapper hotelMapper;
32
+
33
+    @Autowired
34
+    TaHotelAccountMapper accountMapper;
35
+
36
+    @Override
37
+    public List<TaHotel> getByName(String hotelName) {
38
+        LambdaQueryWrapper<TaHotel> queryWrapper = new LambdaQueryWrapper<>();
39
+        queryWrapper.eq(TaHotel::getHotelName, hotelName)
40
+                .gt(TaHotel::getStatus, Constants.STATUS_DELETED)
41
+                .orderByDesc(TaHotel::getCreateDate);
42
+        return list(queryWrapper);
43
+    }
44
+
45
+    @Transactional(rollbackFor = Exception.class)
46
+    @Override
47
+    public boolean createNew(TaHotel taHotel) throws Exception {
48
+        save(taHotel);
49
+
50
+        TaHotelAccount account = new TaHotelAccount();
51
+        account.setHotelId(taHotel.getHotelId());
52
+        accountMapper.insert(account);
53
+
54
+        return false;
55
+    }
19 56
 
57
+    @Override
58
+    public IPage<HotelListVO> getVOListBy(IPage<TaHotel> pg, String hotelName) {
59
+        return hotelMapper.getVOListBy(pg, hotelName);
60
+    }
20 61
 }

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

@@ -93,27 +93,27 @@ public class TaOrderPayServiceImpl extends ServiceImpl<TaOrderPayMapper, TaOrder
93 93
             return;
94 94
         }
95 95
 
96
-        // 此处不能更新订单状态
97
-        // 因为退款分2种情况, 1退款申请, 2订单取消
98
-
99 96
         TaOrder taOrder = taOrderMapper.selectById(reqInfo.getOutTradeNo());
97
+        TaOrderPay orderPay = new TaOrderPay();
98
+        orderPay.setOrderId(taOrder.getOrderId());
99
+        orderPay.setPersonId(taOrder.getPersonId());
100
+        orderPay.setCharges(reqInfo.getRefundFee());
101
+        orderPay.setPayDate(DateUtils.from(reqInfo.getSuccessTime(), "yyyyMMddHHmmss"));
102
+        orderPay.setStatus(Constants.PAY_SUCCESS);
103
+        orderPay.setMessage(null);
100 104
 
101 105
         // 如果退款单号 = 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;
106
+        // 否则是订单项退款
107
+        if (!reqInfo.getOutRefundNo().equals("R"+taOrder.getOrderId())) {
108
+            orderPay.setSubOrderId(reqInfo.getOutRefundNo().substring(1));
109
+            taOrderSubMapper.updateStatus(orderPay.getSubOrderId(), Constants.ORDER_REFUND);
110
+        } else {
111
+            taOrderMapper.updateStatus(orderPay.getOrderId(), Constants.ORDER_REFUND);
115 112
         }
116 113
 
114
+        orderPayMapper.insert(orderPay);
117 115
 
116
+        RefundSuccessEvent evt = new RefundSuccessEvent(this, taOrder, null);
117
+        eventPublisher.publishEvent(evt);
118 118
     }
119 119
 }

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

@@ -1,10 +1,18 @@
1 1
 package com.yunzhi.shigongli.service.impl;
2 2
 
3
-import com.yunzhi.shigongli.entity.TaOrderSub;
4
-import com.yunzhi.shigongli.mapper.TaOrderSubMapper;
3
+import com.yunzhi.shigongli.common.Constants;
4
+import com.yunzhi.shigongli.common.WxPayUtils;
5
+import com.yunzhi.shigongli.entity.*;
6
+import com.yunzhi.shigongli.mapper.*;
5 7
 import com.yunzhi.shigongli.service.ITaOrderSubService;
6 8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
+import org.omg.PortableInterceptor.ACTIVE;
10
+import org.springframework.beans.factory.annotation.Autowired;
7 11
 import org.springframework.stereotype.Service;
12
+import org.springframework.transaction.annotation.Transactional;
13
+
14
+import java.time.LocalDateTime;
15
+import java.util.List;
8 16
 
9 17
 /**
10 18
  * <p>
@@ -17,4 +25,132 @@ import org.springframework.stereotype.Service;
17 25
 @Service
18 26
 public class TaOrderSubServiceImpl extends ServiceImpl<TaOrderSubMapper, TaOrderSub> implements ITaOrderSubService {
19 27
 
28
+    @Autowired
29
+    WxPayUtils wxPayUtils;
30
+
31
+    @Autowired
32
+    TaOrderSubMapper taOrderSubMapper;
33
+
34
+    @Autowired
35
+    TaOrderCommissionMapper commissionMapper;
36
+
37
+    @Autowired
38
+    TaPersonRecommenderMapper recommenderMapper;
39
+
40
+    @Autowired
41
+    TaShopAccountMapper shopAccountMapper;
42
+
43
+    @Autowired
44
+    TaShopAccountLogMapper shopAccountLogMapper;
45
+
46
+    @Autowired
47
+    TaHotelAccountMapper hotelAccountMapper;
48
+
49
+    @Autowired
50
+    TaHotelAccountLogMapper hotelAccountLogMapper;
51
+
52
+    /**
53
+     * 订单项目退款
54
+     * @param person
55
+     * @param taOrder
56
+     * @param taOrderSub
57
+     * @throws Exception
58
+     */
59
+    @Transactional(rollbackFor = Exception.class)
60
+    @Override
61
+    public void refund(TaPerson person, TaOrder taOrder, TaOrderSub taOrderSub) throws Exception {
62
+        wxPayUtils.refund(taOrder, taOrderSub);
63
+
64
+        // 更新表
65
+        taOrderSubMapper.updateStatus(taOrderSub.getSubOrderId(), Constants.ORDER_REFUND);
66
+
67
+        // 后面的业务, 比如退款之后, 扣除个人账户之类的
68
+        // 交给退款成功之后的回调处理
69
+    }
70
+
71
+    @Transactional(rollbackFor = Exception.class)
72
+    @Override
73
+    public void validation(TaPerson taPerson, TaOrder taOrder, TaOrderSub taOrderSub) throws Exception {
74
+        // 先更新状态
75
+        taOrderSubMapper.updateVerified(taOrderSub.getSubOrderId(), 1);
76
+
77
+        // 获取当前人员的推荐人
78
+        TaPersonRecommender recommender = recommenderMapper.getAcitveRecommender(taPerson.getPersonId());
79
+
80
+        // 查询分佣表
81
+        List<TaOrderCommission> commissionList = commissionMapper.getListByOrderSub(taOrderSub.getSubOrderId());
82
+
83
+        for (TaOrderCommission commission : commissionList) {
84
+            // 流量抽成
85
+            if (Constants.COMMISSION_TRAFFIC.equals(commission.getCommissionType())) {
86
+                if (Constants.RECOMMEND_SHOP.equals(recommender.getFromType())) {
87
+                    // 如果是商户推荐的
88
+                    createShopAccountLog(recommender.getRecommender(), commission);
89
+                } else if (Constants.RECOMMEND_HOTEL.equals(recommender.getFromType())) {
90
+                    // 如果是民宿推荐的
91
+                    createHotelAccountLog(recommender.getRecommender(), commission);
92
+                }
93
+            }
94
+
95
+            // 平台抽成
96
+            if (Constants.COMMISSION_PLATFORM.equals(commission.getCommissionType())) {
97
+                // 平台账户暂时用民宿代替
98
+                createHotelAccountLog(Constants.SYSTEM_ACCOUNT_ID, commission);
99
+            }
100
+        }
101
+    }
102
+
103
+    /**
104
+     * 商铺抽成入账户
105
+     * @param shopId
106
+     * @param commission
107
+     * @throws Exception
108
+     */
109
+    private void createShopAccountLog(String shopId, TaOrderCommission commission) throws Exception {
110
+        TaShopAccount account = shopAccountMapper.selectByShop(shopId);
111
+
112
+        // 先插入明细
113
+        TaShopAccountLog accountLog = new TaShopAccountLog();
114
+        accountLog.setAccountId(account.getAccountId());
115
+        accountLog.setShopId(shopId);
116
+        accountLog.setSignType(commission.getCharge() > 0 ? Constants.ACCOUNT_INCOME : Constants.ACCOUNT_EXPENSE);
117
+        accountLog.setAmountType(Constants.ACCOUNT_COMMISSION);
118
+        accountLog.setAmount(commission.getCharge());
119
+        accountLog.setTargetType(Constants.TARGET_ORDER);
120
+        accountLog.setTargetId(commission.getOrderId());
121
+        accountLog.setOrderId(commission.getOrderId());
122
+        accountLog.setSubOrderId(commission.getSubOrderId());
123
+        accountLog.setCreateDate(LocalDateTime.now());
124
+        shopAccountLogMapper.insert(accountLog);
125
+
126
+        // 再累计到账户
127
+        shopAccountMapper.updateCommission(account.getAccountId(), accountLog.getAmount());
128
+    }
129
+
130
+    /**
131
+     * 民宿抽成入账户
132
+     * @param hotelId
133
+     * @param commission
134
+     * @throws Exception
135
+     */
136
+    private void createHotelAccountLog(String hotelId, TaOrderCommission commission) throws Exception {
137
+        TaHotelAccount account = hotelAccountMapper.selectByHotel(hotelId);
138
+
139
+        // 先插入明细
140
+        TaHotelAccountLog accountLog = new TaHotelAccountLog();
141
+        accountLog.setAccountId(account.getAccountId());
142
+        accountLog.setHotelId(hotelId);
143
+        accountLog.setSignType(commission.getCharge() > 0 ? Constants.ACCOUNT_INCOME : Constants.ACCOUNT_EXPENSE);
144
+        accountLog.setAmountType(Constants.ACCOUNT_COMMISSION);
145
+        accountLog.setAmount(commission.getCharge());
146
+        accountLog.setTargetType(Constants.TARGET_ORDER);
147
+        accountLog.setTargetId(commission.getOrderId());
148
+        accountLog.setOrderId(commission.getOrderId());
149
+        accountLog.setSubOrderId(commission.getSubOrderId());
150
+        accountLog.setCreateDate(LocalDateTime.now());
151
+        hotelAccountLogMapper.insert(accountLog);
152
+
153
+        // 再累计到账户
154
+        hotelAccountMapper.updateCommission(account.getAccountId(), accountLog.getAmount());
155
+    }
20 156
 }

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

@@ -59,6 +59,7 @@ public class TaPersonAccountServiceImpl extends ServiceImpl<TaPersonAccountMappe
59 59
         TaPersonAccountLog accountLog = new TaPersonAccountLog();
60 60
         accountLog.setAccountId(personAccount.getAccountId());
61 61
         accountLog.setPersonId(taOrder.getPersonId());
62
+        accountLog.setAmountType(Constants.ACCOUNT_CASHBACK);
62 63
         accountLog.setAmount(cashback);
63 64
         accountLog.setSignType(Constants.ACCOUNT_INCOME);
64 65
         accountLog.setTargetType(Constants.TARGET_ORDER);
@@ -66,4 +67,5 @@ public class TaPersonAccountServiceImpl extends ServiceImpl<TaPersonAccountMappe
66 67
         accountLog.setOrderId(taOrder.getOrderId());
67 68
         accountLogMapper.insert(accountLog);
68 69
     }
70
+
69 71
 }

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

@@ -0,0 +1,40 @@
1
+package com.yunzhi.shigongli.vo;
2
+
3
+import com.alibaba.excel.annotation.ExcelProperty;
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 HotelListVO {
11
+
12
+    @ApiModelProperty(value = "民宿ID")
13
+    private String hotelId;
14
+
15
+    @ExcelProperty(value = "民宿名称", index = 0)
16
+    @ApiModelProperty(value = "民宿名称")
17
+    private String hotelName;
18
+
19
+    @ApiModelProperty(value = "logo")
20
+    private String logo;
21
+
22
+    @ExcelProperty(value = "员工数量", index = 1)
23
+    @ApiModelProperty("员工数量")
24
+    private Integer workerNum;
25
+
26
+    @ExcelProperty(value = "房源数", index = 2)
27
+    @ApiModelProperty("房源数")
28
+    private Integer roomNum;
29
+
30
+    @ExcelProperty(value = "佣金金额/单价分", index = 3)
31
+    @ApiModelProperty("佣金金额")
32
+    private Integer brokerageCharges;
33
+
34
+    @ExcelProperty(value = "已结算佣金/单价分", index = 4)
35
+    @ApiModelProperty("已结算佣金")
36
+    private Integer paidCharges;
37
+
38
+    @ApiModelProperty("状态")
39
+    private Integer status;
40
+}

+ 15
- 0
src/main/resources/mapper/TaHotelAccountMapper.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.TaHotelAccountMapper">
4
+    <update id="updateCommission">
5
+        UPDATE ta_hotel_account
6
+        SET amounts = amounts + ${amount},
7
+            brokerage_charges = brokerage_charges + ${amount}
8
+        WHERE
9
+            account_id = #{accountId}
10
+    </update>
4 11
 
12
+    <select id="selectByHotel" resultType="com.yunzhi.shigongli.entity.TaHotelAccount">
13
+        SELECT
14
+            *
15
+        FROM
16
+            ta_hotel_account
17
+        WHERE
18
+            hotel_id = #{hotelId}
19
+    </select>
5 20
 </mapper>

+ 18
- 0
src/main/resources/mapper/TaHotelMapper.xml Wyświetl plik

@@ -2,4 +2,22 @@
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.TaHotelMapper">
4 4
 
5
+    <select id="getVOListBy" resultType="com.yunzhi.shigongli.vo.HotelListVO">
6
+        SELECT
7
+            t.*,
8
+            s.brokerage_charges,
9
+            s.paid_charges,
10
+            ( SELECT count( * ) FROM ta_hotel_worker a WHERE a.hotel_id = t.hotel_id AND a.`status` > - 1 ) AS worker_num,
11
+            ( SELECT count( * ) FROM ta_room b WHERE b.hotel_id = t.hotel_id AND b.`status` > - 1 ) AS room_num
12
+        FROM
13
+            ta_hotel t
14
+                INNER JOIN ta_hotel_account s ON t.hotel_id = s.hotel_id
15
+        WHERE 1 = 1
16
+          <if test="hotelName != null and hotelName != ''">
17
+              AND t.hotel_name LIKE CONCAT( '%', #{hotelName}, '%' )
18
+          </if>
19
+            AND t.`status` > - 1
20
+        ORDER BY
21
+            t.create_date DESC
22
+    </select>
5 23
 </mapper>

+ 8
- 0
src/main/resources/mapper/TaOrderCommissionMapper.xml Wyświetl plik

@@ -2,4 +2,12 @@
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.TaOrderCommissionMapper">
4 4
 
5
+    <select id="getListByOrderSub" resultType="com.yunzhi.shigongli.entity.TaOrderCommission">
6
+        SELECT
7
+            *
8
+        FROM
9
+            ta_order_commission
10
+        WHERE
11
+            sub_order_id = #{subOrderId}
12
+    </select>
5 13
 </mapper>

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

@@ -8,6 +8,19 @@
8 8
         WHERE
9 9
             order_id = #{orderId}
10 10
     </update>
11
+    <update id="updateStatus">
12
+        UPDATE ta_order_sub
13
+        SET `status` = #{status}
14
+        WHERE
15
+            sub_order_id = #{subOrderId}
16
+    </update>
17
+    <update id="updateVerified">
18
+        UPDATE ta_order_sub
19
+        SET is_verified = #{isVerified},
20
+            verified_date = now()
21
+        WHERE
22
+            sub_order_id = #{subOrderId}
23
+    </update>
11 24
     <select id="getListByOrder" resultType="com.yunzhi.shigongli.entity.TaOrderSub">
12 25
         SELECT * FROM ta_order_sub
13 26
         WHERE

+ 11
- 0
src/main/resources/mapper/TaPersonRecommenderMapper.xml Wyświetl plik

@@ -2,4 +2,15 @@
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.TaPersonRecommenderMapper">
4 4
 
5
+    <select id="getAcitveRecommender" resultType="com.yunzhi.shigongli.entity.TaPersonRecommender">
6
+        SELECT
7
+            *
8
+        FROM
9
+            ta_person_recommender t
10
+        WHERE
11
+            t.person_id = #{personId}
12
+          AND t.create_date &lt; now( )
13
+          AND t.expire_date &gt; now( )
14
+          AND t.`status` = 1
15
+    </select>
5 16
 </mapper>

+ 15
- 0
src/main/resources/mapper/TaShopAccountMapper.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.TaShopAccountMapper">
4
+    <update id="updateCommission">
5
+        UPDATE ta_shop_account
6
+        SET amounts = amounts + ${amount},
7
+            brokerage_charges = brokerage_charges + ${amount}
8
+        WHERE
9
+            account_id = #{accountId}
10
+    </update>
4 11
 
12
+    <select id="selectByShop" resultType="com.yunzhi.shigongli.entity.TaShopAccount">
13
+        SELECT
14
+            *
15
+        FROM
16
+            ta_shop_account
17
+        WHERE
18
+            shop_id = #{shopId}
19
+    </select>
5 20
 </mapper>