张延森 3 jaren geleden
bovenliggende
commit
41c42437a4
46 gewijzigde bestanden met toevoegingen van 982 en 178 verwijderingen
  1. 8
    2
      src/main/java/com/yunzhi/shigongli/common/Constants.java
  2. 37
    36
      src/main/java/com/yunzhi/shigongli/common/WxPayUtils.java
  3. 48
    37
      src/main/java/com/yunzhi/shigongli/controller/TaEvaluationController.java
  4. 22
    5
      src/main/java/com/yunzhi/shigongli/controller/TaLikeController.java
  5. 87
    4
      src/main/java/com/yunzhi/shigongli/controller/TaOrderController.java
  6. 57
    2
      src/main/java/com/yunzhi/shigongli/controller/TaOrderSubController.java
  7. 14
    0
      src/main/java/com/yunzhi/shigongli/controller/TaShopController.java
  8. 9
    1
      src/main/java/com/yunzhi/shigongli/controller/TaTouristController.java
  9. 3
    0
      src/main/java/com/yunzhi/shigongli/controller/WxMaController.java
  10. 6
    3
      src/main/java/com/yunzhi/shigongli/entity/TaOrderPay.java
  11. 3
    0
      src/main/java/com/yunzhi/shigongli/entity/TaOrderSub.java
  12. 37
    0
      src/main/java/com/yunzhi/shigongli/entity/TaSequence.java
  13. 8
    0
      src/main/java/com/yunzhi/shigongli/entity/TaShop.java
  14. 4
    0
      src/main/java/com/yunzhi/shigongli/entity/TaTourist.java
  15. 6
    6
      src/main/java/com/yunzhi/shigongli/event/PaySuccessEvent.java
  16. 6
    12
      src/main/java/com/yunzhi/shigongli/event/RefundSuccessEvent.java
  17. 1
    1
      src/main/java/com/yunzhi/shigongli/event/listener/PaySuccessEventListener.java
  18. 2
    2
      src/main/java/com/yunzhi/shigongli/event/listener/RefundSuccessEventListener.java
  19. 2
    0
      src/main/java/com/yunzhi/shigongli/mapper/TaOrderMapper.java
  20. 4
    0
      src/main/java/com/yunzhi/shigongli/mapper/TaOrderPayMapper.java
  21. 9
    0
      src/main/java/com/yunzhi/shigongli/mapper/TaOrderSubMapper.java
  22. 22
    0
      src/main/java/com/yunzhi/shigongli/mapper/TaSequenceMapper.java
  23. 5
    0
      src/main/java/com/yunzhi/shigongli/mapper/TaShopMapper.java
  24. 3
    0
      src/main/java/com/yunzhi/shigongli/service/ITaEvaluationService.java
  25. 1
    0
      src/main/java/com/yunzhi/shigongli/service/ITaLikeService.java
  26. 12
    0
      src/main/java/com/yunzhi/shigongli/service/ITaOrderPayService.java
  27. 3
    1
      src/main/java/com/yunzhi/shigongli/service/ITaOrderService.java
  28. 11
    0
      src/main/java/com/yunzhi/shigongli/service/ITaOrderSubService.java
  29. 2
    1
      src/main/java/com/yunzhi/shigongli/service/ITaPersonAccountService.java
  30. 3
    0
      src/main/java/com/yunzhi/shigongli/service/ITaResourceService.java
  31. 93
    0
      src/main/java/com/yunzhi/shigongli/service/impl/TaEvaluationServiceImpl.java
  32. 10
    0
      src/main/java/com/yunzhi/shigongli/service/impl/TaLikeServiceImpl.java
  33. 149
    43
      src/main/java/com/yunzhi/shigongli/service/impl/TaOrderPayServiceImpl.java
  34. 15
    8
      src/main/java/com/yunzhi/shigongli/service/impl/TaOrderServiceImpl.java
  35. 33
    2
      src/main/java/com/yunzhi/shigongli/service/impl/TaOrderSubServiceImpl.java
  36. 20
    12
      src/main/java/com/yunzhi/shigongli/service/impl/TaPersonAccountServiceImpl.java
  37. 12
    0
      src/main/java/com/yunzhi/shigongli/service/impl/TaResourceServiceImpl.java
  38. 28
    0
      src/main/java/com/yunzhi/shigongli/vo/EvaluateTarget.java
  39. 63
    0
      src/main/java/com/yunzhi/shigongli/vo/MineOrder.java
  40. 20
    0
      src/main/java/com/yunzhi/shigongli/vo/MineOrderSummary.java
  41. 9
    0
      src/main/resources/mapper/TaOrderMapper.xml
  42. 24
    0
      src/main/resources/mapper/TaOrderPayMapper.xml
  43. 44
    0
      src/main/resources/mapper/TaOrderSubMapper.xml
  44. 5
    0
      src/main/resources/mapper/TaSequenceMapper.xml
  45. 21
    0
      src/main/resources/mapper/TaShopMapper.xml
  46. 1
    0
      src/main/resources/mapper/TaTargetQuotaMapper.xml

+ 8
- 2
src/main/java/com/yunzhi/shigongli/common/Constants.java Bestand weergeven

@@ -14,7 +14,7 @@ public class Constants {
14 14
 
15 15
     // 支付结果
16 16
     public final static Integer PAY_SUCCESS = 1;
17
-    public final static Integer PAY_FAIL = 0;
17
+    public final static Integer PAY_FAIL = 2;
18 18
 
19 19
     // 抽成分类
20 20
     public final static String COMMISSION_TRAFFIC = "traffic";  // 引流抽成
@@ -34,10 +34,11 @@ public class Constants {
34 34
 
35 35
     // 系统模块
36 36
     public final static String TARGET_ORDER = "order";                  // 订单
37
+    public final static String TARGET_ORDER_SUB = "order_sub";          // 订单项目
37 38
     public final static String TARGET_HOTEL = "hotel";                  // 民宿
38 39
     public final static String TARGET_SHOP = "shop";                    // 商铺
39 40
     public final static String TARGET_SHOP_PACKAGE = "shop_package";    // 商铺套餐
40
-    public final static String TARGET_TOURIST = "tourist";                // 景点
41
+    public final static String TARGET_TOURIST = "tourist";              // 景点
41 42
 
42 43
     // 商品套餐类型
43 44
     public final static String PACKAGE_NORMAL = "normal";           // 普通套餐
@@ -47,6 +48,11 @@ public class Constants {
47 48
     public final static String RECOMMEND_SHOP = "shop";     // 商铺
48 49
     public final static String RECOMMEND_HOTEL = "hotel";   // 民宿
49 50
 
51
+    // 评价
52
+    public final static String EVALUATE_ENVIRONMENT = "environment";    // 环境评分
53
+    public final static String EVALUATE_SWEET = "sweet";                // 口味评分
54
+    public final static String EVALUATE_SERVICE = "service";            // 服务评分
55
+
50 56
     // 系统参数
51 57
     public final static String CONF_HOTEL_RECOMMEND_VALID_DAYS = "hotel_recommend_valid_days";      // 民宿推广客户有效时间
52 58
     public final static String CONF_SHOP_RECOMMEND_VALID_DAYS = "shop_recommend_valid_days";        // 商铺推广客户有效时间

+ 37
- 36
src/main/java/com/yunzhi/shigongli/common/WxPayUtils.java Bestand weergeven

@@ -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.TaOrderPay;
11 12
 import com.yunzhi.shigongli.entity.TaOrderSub;
12 13
 import com.yunzhi.shigongli.entity.TaPerson;
13 14
 import org.springframework.beans.factory.annotation.Autowired;
@@ -26,18 +27,18 @@ public class WxPayUtils {
26 27
     /**
27 28
      * 下单
28 29
      * @param person
29
-     * @param taOrder
30
+     * @param orderPay
30 31
      * @return
31 32
      * @throws Exception
32 33
      */
33
-    public WxPayMpOrderResult createOrder(TaPerson person, TaOrder taOrder) throws Exception {
34
+    public WxPayMpOrderResult createOrder(TaPerson person, TaOrderPay orderPay) throws Exception {
34 35
         LocalDateTime now = LocalDateTime.now();
35 36
         WxPayService payService = wxUtils.getPayService();
36 37
 
37 38
         WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
38
-        orderRequest.setBody(taOrder.getDescription());
39
-        orderRequest.setOutTradeNo(taOrder.getOrderId());
40
-        orderRequest.setTotalFee(taOrder.getCharges());
39
+        orderRequest.setBody(orderPay.getDescription());
40
+        orderRequest.setOutTradeNo(orderPay.getPayId());
41
+        orderRequest.setTotalFee(orderPay.getCharges());
41 42
         orderRequest.setOpenid(person.getOpenid());
42 43
         orderRequest.setNotifyUrl(config.getPay().getNotifyUrl());
43 44
         orderRequest.setSpbillCreateIp("218.91.253.51");  // 随便写个 IP
@@ -49,44 +50,44 @@ public class WxPayUtils {
49 50
         return payResult;
50 51
     }
51 52
 
52
-    /**
53
-     * 订单退款
54
-     * @param taOrder
55
-     * @param cashback
56
-     * @return
57
-     * @throws Exception
58
-     */
59
-    public WxPayRefundResult refund(TaOrder taOrder, Integer cashback) throws Exception {
60
-        WxPayService payService = wxUtils.getPayService();
61
-        WxPayRefundRequest refundRequest = new WxPayRefundRequest();
62
-        refundRequest.setOutTradeNo(taOrder.getOrderId());
63
-        refundRequest.setOutRefundNo("R"+taOrder.getOrderId());
64
-        refundRequest.setTotalFee(taOrder.getCharges());
65
-        refundRequest.setRefundFee(taOrder.getCharges() - cashback);
66
-        refundRequest.setNotifyUrl(config.getPay().getRefundNotifyUrl());
67
-        WxPayRefundResult result = payService.refund(refundRequest);
68
-
69
-        if (!WxPayConstants.ResultCode.SUCCESS.equals(result.getResultCode())) {
70
-            throw new Exception(result.getErrCodeDes());
71
-        }
72
-
73
-        return result;
74
-    }
53
+//    /**
54
+//     * 订单退款
55
+//     * @param taOrder
56
+//     * @param cashback
57
+//     * @return
58
+//     * @throws Exception
59
+//     */
60
+//    public WxPayRefundResult refund(TaOrder taOrder, Integer cashback) throws Exception {
61
+//        WxPayService payService = wxUtils.getPayService();
62
+//        WxPayRefundRequest refundRequest = new WxPayRefundRequest();
63
+//        refundRequest.setOutTradeNo(taOrder.getOrderId());
64
+//        refundRequest.setOutRefundNo("R"+taOrder.getOrderId());
65
+//        refundRequest.setTotalFee(taOrder.getCharges());
66
+//        refundRequest.setRefundFee(taOrder.getCharges() - cashback);
67
+//        refundRequest.setNotifyUrl(config.getPay().getRefundNotifyUrl());
68
+//        WxPayRefundResult result = payService.refund(refundRequest);
69
+//
70
+//        if (!WxPayConstants.ResultCode.SUCCESS.equals(result.getResultCode())) {
71
+//            throw new Exception(result.getErrCodeDes());
72
+//        }
73
+//
74
+//        return result;
75
+//    }
75 76
 
76 77
     /**
77
-     * 订单项目退款
78
-     * @param taOrder
79
-     * @param taOrderSub
78
+     * 订单退款
79
+     * @param originOrderPay
80
+     * @param orderPay
80 81
      * @return
81 82
      * @throws Exception
82 83
      */
83
-    public WxPayRefundResult refund(TaOrder taOrder, TaOrderSub taOrderSub) throws Exception {
84
+    public WxPayRefundResult refund(TaOrderPay originOrderPay, TaOrderPay orderPay) throws Exception {
84 85
         WxPayService payService = wxUtils.getPayService();
85 86
         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());
87
+        refundRequest.setOutTradeNo(originOrderPay.getPayId());
88
+        refundRequest.setOutRefundNo(orderPay.getPayId());
89
+        refundRequest.setTotalFee(originOrderPay.getCharges());
90
+        refundRequest.setRefundFee(orderPay.getCharges());
90 91
         refundRequest.setNotifyUrl(config.getPay().getRefundNotifyUrl());
91 92
         WxPayRefundResult result = payService.refund(refundRequest);
92 93
 

+ 48
- 37
src/main/java/com/yunzhi/shigongli/controller/TaEvaluationController.java Bestand weergeven

@@ -5,6 +5,8 @@ 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 7
 import com.yunzhi.shigongli.common.ResponseBean;
8
+import com.yunzhi.shigongli.entity.TaPerson;
9
+import com.yunzhi.shigongli.vo.EvaluateTarget;
8 10
 import io.swagger.annotations.Api;
9 11
 import io.swagger.annotations.ApiOperation;
10 12
 import io.swagger.annotations.ApiParam;
@@ -42,38 +44,38 @@ public class TaEvaluationController extends BaseController {
42 44
 
43 45
     /**
44 46
      * 分页查询列表
45
-     * @param pageNum
46
-     * @param pageSize
47
-     * @return
48
-     */
49
-    @RequestMapping(value="/admin/taEvaluation",method= RequestMethod.GET)
50
-    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
-    public ResponseBean taEvaluationList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
-
54
-		    IPage<TaEvaluation> pg = new Page<>(pageNum, pageSize);
55
-            QueryWrapper<TaEvaluation> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.orderByDesc("create_date");
57
-
58
-            IPage<TaEvaluation> result = iTaEvaluationService.page(pg, queryWrapper);
59
-            return ResponseBean.success(result);
60
-    }
61
-
62
-    /**
63
-     * 保存对象
64
-     * @param taEvaluation 实体对象
65
-     * @return
66
-     */
67
-    @RequestMapping(value="/wx/taEvaluation",method= RequestMethod.POST)
68
-    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-    public ResponseBean taEvaluationAdd(@ApiParam("保存内容") @RequestBody TaEvaluation taEvaluation) throws Exception{
70
-
71
-        if (iTaEvaluationService.save(taEvaluation)){
72
-            return ResponseBean.success(taEvaluation);
73
-        }else {
74
-            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75
-        }
76
-    }
47
+//     * @param pageNum
48
+//     * @param pageSize
49
+//     * @return
50
+//     */
51
+//    @RequestMapping(value="/admin/taEvaluation",method= RequestMethod.GET)
52
+//    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
53
+//    public ResponseBean taEvaluationList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
54
+//									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
55
+//
56
+//		    IPage<TaEvaluation> pg = new Page<>(pageNum, pageSize);
57
+//            QueryWrapper<TaEvaluation> queryWrapper = new QueryWrapper<>();
58
+//            queryWrapper.orderByDesc("create_date");
59
+//
60
+//            IPage<TaEvaluation> result = iTaEvaluationService.page(pg, queryWrapper);
61
+//            return ResponseBean.success(result);
62
+//    }
63
+//
64
+//    /**
65
+//     * 保存对象
66
+//     * @param taEvaluation 实体对象
67
+//     * @return
68
+//     */
69
+//    @RequestMapping(value="/wx/taEvaluation",method= RequestMethod.POST)
70
+//    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
71
+//    public ResponseBean taEvaluationAdd(@ApiParam("保存内容") @RequestBody TaEvaluation taEvaluation) throws Exception{
72
+//
73
+//        if (iTaEvaluationService.save(taEvaluation)){
74
+//            return ResponseBean.success(taEvaluation);
75
+//        }else {
76
+//            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
77
+//        }
78
+//    }
77 79
 //
78 80
 //    /**
79 81
 //     * 根据id删除对象
@@ -108,12 +110,21 @@ public class TaEvaluationController extends BaseController {
108 110
 //    }
109 111
 
110 112
     /**
111
-     * 根据id查询对象
113
+     * 用户评分
112 114
      * @param id  实体ID
113 115
      */
114
-    @RequestMapping(value="/wx/taEvaluation/{id}",method= RequestMethod.GET)
115
-    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
-    public ResponseBean taEvaluationGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
-        return ResponseBean.success(iTaEvaluationService.getById(id));
116
+    @RequestMapping(value="/wx/{targetType}/{targetId}/evaluate",method= RequestMethod.POST)
117
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "POST", response = ResponseBean.class)
118
+    public ResponseBean taEvaluationGet(@ApiParam("对象类型") @PathVariable String targetType,
119
+                                        @ApiParam("对象ID") @PathVariable String targetId,
120
+                                        @ApiParam("评价内容") @RequestBody EvaluateTarget evaluateTarget) throws Exception{
121
+        TaPerson taPerson = getCurrentPerson();
122
+
123
+        evaluateTarget.setTargetType(targetType);
124
+        evaluateTarget.setTargetId(targetId);
125
+
126
+        iTaEvaluationService.evaluateSomething(taPerson, evaluateTarget);
127
+
128
+        return ResponseBean.success("ok");
118 129
     }
119 130
 }

+ 22
- 5
src/main/java/com/yunzhi/shigongli/controller/TaLikeController.java Bestand weergeven

@@ -5,6 +5,8 @@ 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 7
 import com.yunzhi.shigongli.common.ResponseBean;
8
+import com.yunzhi.shigongli.entity.TaSave;
9
+import com.yunzhi.shigongli.service.ITaResourceService;
8 10
 import io.swagger.annotations.Api;
9 11
 import io.swagger.annotations.ApiOperation;
10 12
 import io.swagger.annotations.ApiParam;
@@ -20,6 +22,8 @@ import com.yunzhi.shigongli.service.ITaLikeService;
20 22
 import com.yunzhi.shigongli.entity.TaLike;
21 23
 import org.springframework.web.bind.annotation.RestController;
22 24
 
25
+import java.time.LocalDateTime;
26
+
23 27
 /**
24 28
  * <p>
25 29
     * 点赞表 前端控制器
@@ -39,6 +43,8 @@ public class TaLikeController extends BaseController {
39 43
     @Autowired
40 44
     public ITaLikeService iTaLikeService;
41 45
 
46
+    @Autowired
47
+    public ITaResourceService iTaResourceService;
42 48
 
43 49
     /**
44 50
      * 分页查询列表
@@ -64,11 +70,18 @@ public class TaLikeController extends BaseController {
64 70
      * @param taLike 实体对象
65 71
      * @return
66 72
      */
67
-    @RequestMapping(value="/wx/taLike",method= RequestMethod.POST)
73
+    @RequestMapping(value="/wx/{targetType}/like/{targetId}",method= RequestMethod.POST)
68 74
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
-    public ResponseBean taLikeAdd(@ApiParam("保存内容") @RequestBody TaLike taLike) throws Exception{
75
+    public ResponseBean taLikeAdd(@ApiParam("对象类型") @PathVariable String targetType,
76
+                                  @ApiParam("对象ID") @PathVariable String targetId) throws Exception{
70 77
 
78
+        TaLike taLike = new TaLike();
79
+        taLike.setTargetType(targetType);
80
+        taLike.setTargetId(targetId);
81
+        taLike.setPersonId(getCurrentPerson().getPersonId());
82
+        taLike.setCreateDate(LocalDateTime.now());
71 83
         if (iTaLikeService.save(taLike)){
84
+            iTaResourceService.updateLike(taLike, 1);
72 85
             return ResponseBean.success(taLike);
73 86
         }else {
74 87
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
@@ -79,10 +92,14 @@ public class TaLikeController extends BaseController {
79 92
      * 根据id删除对象
80 93
      * @param id  实体ID
81 94
      */
82
-    @RequestMapping(value="/wx/taLike/{id}", method= RequestMethod.DELETE)
95
+    @RequestMapping(value="/wx/{targetType}/like/{targetId}", method= RequestMethod.DELETE)
83 96
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
-    public ResponseBean taLikeDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
-        if(iTaLikeService.removeLogicById(id)){
97
+    public ResponseBean taLikeDelete(@ApiParam("对象类型") @PathVariable String targetType,
98
+                                     @ApiParam("对象ID") @PathVariable String targetId) throws Exception{
99
+        TaLike taLike = iTaLikeService.getByTarget(targetType, targetId, getCurrentPerson().getPersonId());
100
+
101
+        if(iTaLikeService.removeById(taLike.getLikeId())){
102
+            iTaResourceService.updateLike(taLike, -1);
86 103
             return ResponseBean.success("success");
87 104
         }else {
88 105
             return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);

+ 87
- 4
src/main/java/com/yunzhi/shigongli/controller/TaOrderController.java Bestand weergeven

@@ -5,8 +5,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
7 7
 import com.yunzhi.shigongli.common.BaseController;
8
+import com.yunzhi.shigongli.common.Constants;
8 9
 import com.yunzhi.shigongli.common.ResponseBean;
10
+import com.yunzhi.shigongli.entity.TaOrderSub;
9 11
 import com.yunzhi.shigongli.entity.TaPerson;
12
+import com.yunzhi.shigongli.service.ITaOrderPayService;
13
+import com.yunzhi.shigongli.service.ITaOrderSubService;
10 14
 import com.yunzhi.shigongli.vo.OrderItem;
11 15
 import io.swagger.annotations.Api;
12 16
 import io.swagger.annotations.ApiOperation;
@@ -24,6 +28,7 @@ import com.yunzhi.shigongli.entity.TaOrder;
24 28
 import org.springframework.web.bind.annotation.RestController;
25 29
 
26 30
 import javax.servlet.http.HttpServletRequest;
31
+import java.util.List;
27 32
 
28 33
 /**
29 34
  * <p>
@@ -44,6 +49,12 @@ public class TaOrderController extends BaseController {
44 49
     @Autowired
45 50
     public ITaOrderService iTaOrderService;
46 51
 
52
+    @Autowired
53
+    public ITaOrderSubService iTaOrderSubService;
54
+
55
+    @Autowired
56
+    public ITaOrderPayService iTaOrderPayService;
57
+
47 58
 
48 59
 //    /**
49 60
 //     * 分页查询列表
@@ -80,7 +91,33 @@ public class TaOrderController extends BaseController {
80 91
         }
81 92
 
82 93
         TaPerson person = getCurrentPerson();
83
-        WxPayMpOrderResult result = iTaOrderService.order(person, orderItems);
94
+        TaOrder taOrder = iTaOrderService.order(person, orderItems);
95
+        WxPayMpOrderResult result = iTaOrderPayService.prePay(person, taOrder);
96
+        return ResponseBean.success(result);
97
+    }
98
+
99
+    /**
100
+     * 小程序发起支付
101
+     * @param id
102
+     * @param request
103
+     * @return
104
+     * @throws Exception
105
+     */
106
+    @RequestMapping(value="/wx/order/{id}/pay",method= RequestMethod.POST)
107
+    @ApiOperation(value="发起支付", notes = "发起支付", httpMethod = "POST", response = ResponseBean.class)
108
+    public ResponseBean taOrderPay(@ApiParam("订单号") @PathVariable String id,
109
+                                   HttpServletRequest request) throws Exception{
110
+        TaOrder taOrder = iTaOrderService.getById(id);
111
+        if (null == taOrder || Constants.STATUS_DELETED.equals(taOrder.getStatus())) {
112
+            return ResponseBean.error("未找到订单信息", ResponseBean.ERROR_ILLEGAL_PARAMS);
113
+        }
114
+
115
+        if (!Constants.ORDER_READY.equals(taOrder.getStatus())) {
116
+            return ResponseBean.error("订单非未支付状态, 不能完成操作", ResponseBean.ERROR_ILLEGAL_PARAMS);
117
+        }
118
+
119
+        TaPerson person = getCurrentPerson();
120
+        WxPayMpOrderResult result = iTaOrderPayService.prePay(person, taOrder);
84 121
         return ResponseBean.success(result);
85 122
     }
86 123
 
@@ -91,12 +128,12 @@ public class TaOrderController extends BaseController {
91 128
      * @return
92 129
      * @throws Exception
93 130
      */
94
-    @RequestMapping(value="/wx/order/{id}",method= RequestMethod.POST)
95
-    @ApiOperation(value="生成订单", notes = "生成订单", httpMethod = "POST", response = ResponseBean.class)
131
+    @RequestMapping(value="/wx/order/{id}",method= RequestMethod.DELETE)
132
+    @ApiOperation(value="取消订单", notes = "取消订单", httpMethod = "DELETE", response = ResponseBean.class)
96 133
     public ResponseBean taOrderDelete(@ApiParam("订单ID") @PathVariable String id,
97 134
                                    HttpServletRequest request) throws Exception{
98 135
         TaOrder taOrder = iTaOrderService.getById(id);
99
-        if (null == taOrder) {
136
+        if (null == taOrder || Constants.STATUS_DELETED.equals(taOrder.getStatus())) {
100 137
             return ResponseBean.error("订单不存在", ResponseBean.ERROR_ILLEGAL_PARAMS);
101 138
         }
102 139
 
@@ -109,6 +146,52 @@ public class TaOrderController extends BaseController {
109 146
         return ResponseBean.success("取消成功");
110 147
     }
111 148
 
149
+    /**
150
+     * 订单退款
151
+     * @param id
152
+     * @param request
153
+     * @return
154
+     * @throws Exception
155
+     */
156
+    @RequestMapping(value="/wx/order/{id}/refund",method= RequestMethod.DELETE)
157
+    @ApiOperation(value="订单退款", notes = "订单退款", httpMethod = "DELETE", response = ResponseBean.class)
158
+    public ResponseBean taOrderPayCancel(@ApiParam("订单号") @PathVariable String id,
159
+                                   HttpServletRequest request) throws Exception{
160
+        TaOrder taOrder = iTaOrderService.getById(id);
161
+        if (null == taOrder || Constants.STATUS_DELETED.equals(taOrder.getStatus())) {
162
+            return ResponseBean.error("未找到订单信息", ResponseBean.ERROR_ILLEGAL_PARAMS);
163
+        }
164
+
165
+        if (!Constants.ORDER_PAYED.equals(taOrder.getStatus())) {
166
+            return ResponseBean.error("订单非未支付状态, 不能完成操作", ResponseBean.ERROR_ILLEGAL_PARAMS);
167
+        }
168
+
169
+        TaPerson taPerson = getCurrentPerson();
170
+        if (!taPerson.getPersonId().equals(taOrder.getPersonId())) {
171
+            return ResponseBean.error("您无权取消当前订单", ResponseBean.ERROR_UNAVAILABLE);
172
+        }
173
+
174
+        List<TaOrderSub> orderSubList = iTaOrderSubService.getListByOrder(taOrder);
175
+        if (null == orderSubList || orderSubList.size() < 1) {
176
+            throw new Exception("未找到订单详情");
177
+        }
178
+
179
+        // 只有全部为已支付的可以取消
180
+        Object[] o1 = orderSubList.stream().filter(x -> !Constants.ORDER_PAYED.equals(x.getStatus()) || x.getIsVerified()).toArray();
181
+        if (o1.length > 0) {
182
+            throw new Exception("订单存在非支付状态项目, 不能退款");
183
+        }
184
+
185
+        // 计算返现总额
186
+        Integer totalCashback = orderSubList.stream().mapToInt(TaOrderSub::getCashback).reduce(Integer::sum).getAsInt();
187
+
188
+        TaPerson person = getCurrentPerson();
189
+        iTaOrderService.refundOrder(taOrder, taPerson);
190
+        iTaOrderPayService.refundOrder(person, taOrder, totalCashback);
191
+
192
+        return ResponseBean.success("success");
193
+    }
194
+
112 195
 //    /**
113 196
 //     * 根据id删除对象
114 197
 //     * @param id  实体ID

+ 57
- 2
src/main/java/com/yunzhi/shigongli/controller/TaOrderSubController.java Bestand weergeven

@@ -3,12 +3,16 @@ 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.Constants;
8 9
 import com.yunzhi.shigongli.common.ResponseBean;
9 10
 import com.yunzhi.shigongli.entity.TaOrder;
10 11
 import com.yunzhi.shigongli.entity.TaPerson;
12
+import com.yunzhi.shigongli.service.ITaOrderPayService;
11 13
 import com.yunzhi.shigongli.service.ITaOrderService;
14
+import com.yunzhi.shigongli.vo.MineOrder;
15
+import com.yunzhi.shigongli.vo.MineOrderSummary;
12 16
 import io.swagger.annotations.Api;
13 17
 import io.swagger.annotations.ApiOperation;
14 18
 import io.swagger.annotations.ApiParam;
@@ -19,6 +23,8 @@ import org.springframework.web.bind.annotation.*;
19 23
 import com.yunzhi.shigongli.service.ITaOrderSubService;
20 24
 import com.yunzhi.shigongli.entity.TaOrderSub;
21 25
 
26
+import javax.servlet.http.HttpServletRequest;
27
+
22 28
 /**
23 29
  * <p>
24 30
     * 子订单表 前端控制器
@@ -41,6 +47,9 @@ public class TaOrderSubController extends BaseController {
41 47
     @Autowired
42 48
     public ITaOrderService iTaOrderService;
43 49
 
50
+    @Autowired
51
+    public ITaOrderPayService iTaOrderPayService;
52
+
44 53
     /**
45 54
      * 分页查询列表
46 55
      * @param pageNum
@@ -60,6 +69,36 @@ public class TaOrderSubController extends BaseController {
60 69
             return ResponseBean.success(result);
61 70
     }
62 71
 
72
+    /**
73
+     * 订单项目发起支付
74
+     * @param id
75
+     * @param request
76
+     * @return
77
+     * @throws Exception
78
+     */
79
+    @RequestMapping(value="/wx/orderSub/{id}/pay",method= RequestMethod.POST)
80
+    @ApiOperation(value="订单项目发起支付", notes = "订单项目发起支付", httpMethod = "POST", response = ResponseBean.class)
81
+    public ResponseBean taOrderPay(@ApiParam("订单项目ID") @PathVariable String id,
82
+                                   HttpServletRequest request) throws Exception{
83
+        TaOrderSub taOrderSub = iTaOrderSubService.getById(id);
84
+        if (null == taOrderSub || Constants.STATUS_DELETED.equals(taOrderSub.getStatus())) {
85
+            return ResponseBean.error("未找到订单信息", ResponseBean.ERROR_ILLEGAL_PARAMS);
86
+        }
87
+
88
+        TaOrder taOrder = iTaOrderService.getById(taOrderSub.getSubOrderId());
89
+        if (null == taOrder || Constants.STATUS_DELETED.equals(taOrder.getStatus())) {
90
+            return ResponseBean.error("未找到订单信息", ResponseBean.ERROR_ILLEGAL_PARAMS);
91
+        }
92
+
93
+        if (!Constants.ORDER_READY.equals(taOrderSub.getStatus())) {
94
+            return ResponseBean.error("订单非未支付状态, 不能完成操作", ResponseBean.ERROR_ILLEGAL_PARAMS);
95
+        }
96
+
97
+        TaPerson person = getCurrentPerson();
98
+        WxPayMpOrderResult result = iTaOrderPayService.prePay(person, taOrder, taOrderSub);
99
+        return ResponseBean.success(result);
100
+    }
101
+
63 102
     /**
64 103
      * 订单项目退款
65 104
      * @param id
@@ -89,6 +128,7 @@ public class TaOrderSubController extends BaseController {
89 128
             return ResponseBean.error("您无权操作当前订单项目", ResponseBean.ERROR_ILLEGAL_PARAMS);
90 129
         }
91 130
 
131
+        iTaOrderPayService.refundOrderSub(taPerson, taOrder, taOrderSub);
92 132
         iTaOrderSubService.refund(taPerson, taOrder, taOrderSub);
93 133
 
94 134
         return ResponseBean.success("操作完成");
@@ -173,10 +213,25 @@ public class TaOrderSubController extends BaseController {
173 213
 //    }
174 214
 
175 215
     @GetMapping("/wx/orderSub")
176
-    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = TaOrderSub.class)
216
+    @ApiOperation(value="订单列表", notes = "订单列表", httpMethod = "GET", response = MineOrder.class)
177 217
     public ResponseBean getWxMyOrders(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
178 218
                                       @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
179 219
                                       @ApiParam("状态") @RequestParam(value ="status", required = false) Integer status) {
180
-        return ResponseBean.success(null);
220
+        TaPerson taPerson = getCurrentPerson();
221
+
222
+        IPage<MineOrder> pg = new Page<>(pageNum, pageSize);
223
+        IPage<MineOrder> result = iTaOrderSubService.getOrderSubListOf(pg, taPerson, status);
224
+
225
+        return ResponseBean.success(result);
226
+    }
227
+
228
+    @GetMapping("/wx/orderSub/summary/mine")
229
+    @ApiOperation(value="我的订单概况", notes = "我的订单概况", httpMethod = "GET", response = MineOrder.class)
230
+    public ResponseBean getWxMyOrders() {
231
+        TaPerson taPerson = getCurrentPerson();
232
+
233
+        MineOrderSummary result = iTaOrderSubService.getOrderSummary(taPerson);
234
+
235
+        return ResponseBean.success(result);
181 236
     }
182 237
 }

+ 14
- 0
src/main/java/com/yunzhi/shigongli/controller/TaShopController.java Bestand weergeven

@@ -51,6 +51,12 @@ public class TaShopController extends BaseController {
51 51
     public ITaResourceService taResourceService;
52 52
 
53 53
 
54
+    @Autowired
55
+    public ITaSaveService iTaSaveService;
56
+
57
+    @Autowired
58
+    public ITaLikeService iTaLikeService;
59
+
54 60
     /**
55 61
      * 分页查询列表
56 62
      * @param pageNum
@@ -221,6 +227,14 @@ public class TaShopController extends BaseController {
221 227
         taShop.setLikeNum(taResource.getLikeNum());
222 228
         taShop.setImageList(shopImagesService.getListBy(Constants.TARGET_SHOP, id));
223 229
 
230
+        // 是否收藏
231
+        TaSave taSave = iTaSaveService.getByTarget(Constants.TARGET_SHOP, id, getCurrentPerson().getPersonId());
232
+        taShop.setIsSaved(null == taSave ? 0 : 1);
233
+
234
+        // 是否点赞
235
+        TaLike taLike = iTaLikeService.getByTarget(Constants.TARGET_SHOP, id, getCurrentPerson().getPersonId());
236
+        taShop.setIsLike(null == taLike ? 0 : 1);
237
+
224 238
         // 统计 PV, UV
225 239
         try {
226 240
             taResourceService.recordPerson(Constants.TARGET_SHOP, id, getCurrentPerson());

+ 9
- 1
src/main/java/com/yunzhi/shigongli/controller/TaTouristController.java Bestand weergeven

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.shigongli.common.BaseController;
7 7
 import com.yunzhi.shigongli.common.Constants;
8 8
 import com.yunzhi.shigongli.common.ResponseBean;
9
+import com.yunzhi.shigongli.entity.TaLike;
9 10
 import com.yunzhi.shigongli.entity.TaResource;
10 11
 import com.yunzhi.shigongli.entity.TaSave;
11 12
 import com.yunzhi.shigongli.service.*;
@@ -56,6 +57,9 @@ public class TaTouristController extends BaseController {
56 57
     @Autowired
57 58
     public ITaSaveService iTaSaveService;
58 59
 
60
+    @Autowired
61
+    public ITaLikeService iTaLikeService;
62
+
59 63
 
60 64
     /**
61 65
      * 分页查询列表
@@ -169,7 +173,7 @@ public class TaTouristController extends BaseController {
169 173
      * 根据id查询对象
170 174
      * @param id  实体ID
171 175
      */
172
-    @RequestMapping(value="/admin/tourist/{id}",method= RequestMethod.GET)
176
+    @RequestMapping(value="/wx/tourist/{id}",method= RequestMethod.GET)
173 177
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
174 178
     public ResponseBean getWxDetail(@ApiParam("对象ID") @PathVariable String id) throws Exception{
175 179
         TaTourist taTourist = iTaTouristService.getById(id);
@@ -188,6 +192,10 @@ public class TaTouristController extends BaseController {
188 192
         TaSave taSave = iTaSaveService.getByTarget(Constants.TARGET_TOURIST, id, getCurrentPerson().getPersonId());
189 193
         taTourist.setIsSaved(null == taSave ? 0 : 1);
190 194
 
195
+        // 是否点赞
196
+        TaLike taLike = iTaLikeService.getByTarget(Constants.TARGET_TOURIST, id, getCurrentPerson().getPersonId());
197
+        taTourist.setIsLike(null == taLike ? 0 : 1);
198
+
191 199
         try {
192 200
             taResourceService.recordPerson(Constants.TARGET_TOURIST, id, getCurrentPerson());
193 201
         } catch (Exception e) {

+ 3
- 0
src/main/java/com/yunzhi/shigongli/controller/WxMaController.java Bestand weergeven

@@ -79,6 +79,9 @@ public class WxMaController extends BaseController {
79 79
         rtn.put("sessionKey", info.getSessionKey());
80 80
 
81 81
         TaPerson taPerson = iTaPersonService.getById(params.getPersonId());
82
+        if (null == taPerson) {
83
+            taPerson = iTaPersonService.getByOpenid(info.getOpenid());
84
+        }
82 85
         rtn.put("person", taPerson);
83 86
 
84 87
         // 查询人员角色

+ 6
- 3
src/main/java/com/yunzhi/shigongli/entity/TaOrderPay.java Bestand weergeven

@@ -3,6 +3,8 @@ package com.yunzhi.shigongli.entity;
3 3
 import java.math.BigDecimal;
4 4
 import com.baomidou.mybatisplus.annotation.IdType;
5 5
 import java.time.LocalDateTime;
6
+
7
+import com.baomidou.mybatisplus.annotation.TableField;
6 8
 import com.baomidou.mybatisplus.annotation.TableId;
7 9
 import java.io.Serializable;
8 10
 import io.swagger.annotations.ApiModel;
@@ -28,7 +30,7 @@ public class TaOrderPay implements Serializable {
28 30
     private static final long serialVersionUID = 1L;
29 31
 
30 32
     @ApiModelProperty(value = "支付ID")
31
-    @TableId(value = "pay_id", type = IdType.UUID)
33
+    @TableId(value = "pay_id", type = IdType.INPUT)
32 34
     private String payId;
33 35
 
34 36
     @ApiModelProperty(value = "订单ID")
@@ -52,6 +54,9 @@ public class TaOrderPay implements Serializable {
52 54
     @ApiModelProperty(value = "支付金额;单位分")
53 55
     private Integer charges;
54 56
 
57
+    @ApiModelProperty(value = "商品描述")
58
+    private String description;
59
+
55 60
     @ApiModelProperty(value = "状态")
56 61
     private Integer status;
57 62
 
@@ -60,6 +65,4 @@ public class TaOrderPay implements Serializable {
60 65
 
61 66
     @ApiModelProperty(value = "支付时间")
62 67
     private LocalDateTime payDate;
63
-
64
-
65 68
 }

+ 3
- 0
src/main/java/com/yunzhi/shigongli/entity/TaOrderSub.java Bestand weergeven

@@ -40,6 +40,9 @@ public class TaOrderSub implements Serializable {
40 40
     @ApiModelProperty(value = "套餐ID")
41 41
     private String packageId;
42 42
 
43
+    @ApiModelProperty(value = "子订单描述")
44
+    private String description;
45
+
43 46
     @ApiModelProperty(value = "总金额;单位分")
44 47
     private Integer charges;
45 48
 

+ 37
- 0
src/main/java/com/yunzhi/shigongli/entity/TaSequence.java Bestand weergeven

@@ -0,0 +1,37 @@
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="TaSequence对象", description="序列号")
26
+public class TaSequence implements Serializable {
27
+
28
+    private static final long serialVersionUID = 1L;
29
+
30
+    @TableId(value = "seq_name", type = IdType.INPUT)
31
+    @ApiModelProperty(value = "序列号名称")
32
+    private String seqName;
33
+
34
+    @ApiModelProperty(value = "序列号")
35
+    private Integer val;
36
+
37
+}

+ 8
- 0
src/main/java/com/yunzhi/shigongli/entity/TaShop.java Bestand weergeven

@@ -104,4 +104,12 @@ public class TaShop implements Serializable {
104 104
     @TableField(exist = false)
105 105
     private List<TaTargetType> typeList;
106 106
 
107
+
108
+    @ApiModelProperty(value = "是否收藏")
109
+    @TableField(exist = false)
110
+    private Integer isSaved;
111
+
112
+    @ApiModelProperty(value = "是否点赞")
113
+    @TableField(exist = false)
114
+    private Integer isLike;
107 115
 }

+ 4
- 0
src/main/java/com/yunzhi/shigongli/entity/TaTourist.java Bestand weergeven

@@ -104,4 +104,8 @@ public class TaTourist implements Serializable {
104 104
     @ApiModelProperty(value = "是否收藏")
105 105
     @TableField(exist = false)
106 106
     private Integer isSaved;
107
+
108
+    @ApiModelProperty(value = "是否点赞")
109
+    @TableField(exist = false)
110
+    private Integer isLike;
107 111
 }

+ 6
- 6
src/main/java/com/yunzhi/shigongli/event/PaySuccessEvent.java Bestand weergeven

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

+ 6
- 12
src/main/java/com/yunzhi/shigongli/event/RefundSuccessEvent.java Bestand weergeven

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

+ 1
- 1
src/main/java/com/yunzhi/shigongli/event/listener/PaySuccessEventListener.java Bestand weergeven

@@ -16,7 +16,7 @@ public class PaySuccessEventListener implements ApplicationListener<PaySuccessEv
16 16
         try {
17 17
 
18 18
             // 支付成功之后, 给个人返现
19
-            personAccountService.cashback(evt.getTaOrder());
19
+            personAccountService.cashback(evt.getTaOrderPay());
20 20
         } catch (Exception e) {
21 21
             e.printStackTrace();
22 22
         }

+ 2
- 2
src/main/java/com/yunzhi/shigongli/event/listener/RefundSuccessEventListener.java Bestand weergeven

@@ -1,6 +1,7 @@
1 1
 package com.yunzhi.shigongli.event.listener;
2 2
 
3 3
 import com.yunzhi.shigongli.entity.TaOrder;
4
+import com.yunzhi.shigongli.entity.TaOrderPay;
4 5
 import com.yunzhi.shigongli.entity.TaOrderSub;
5 6
 import com.yunzhi.shigongli.event.RefundSuccessEvent;
6 7
 import com.yunzhi.shigongli.service.ITaPersonAccountService;
@@ -15,8 +16,7 @@ public class RefundSuccessEventListener  implements ApplicationListener<RefundSu
15 16
 
16 17
     @Override
17 18
     public void onApplicationEvent(RefundSuccessEvent evt) {
18
-        TaOrder taOrder = evt.getTaOrder();
19
-        TaOrderSub taOrderSub = evt.getTaOrderSub();
19
+        TaOrderPay taOrderPay = evt.getTaOrderPay();
20 20
 
21 21
         // 暂时不需要处理什么
22 22
     }

+ 2
- 0
src/main/java/com/yunzhi/shigongli/mapper/TaOrderMapper.java Bestand weergeven

@@ -17,4 +17,6 @@ import org.apache.ibatis.annotations.Param;
17 17
 public interface TaOrderMapper extends BaseMapper<TaOrder> {
18 18
 
19 19
     int updateStatus(@Param("orderId") String orderId, @Param("status") Integer status);
20
+
21
+    int getOrderNum(@Param("personId") String personId, @Param("status") Integer status);
20 22
 }

+ 4
- 0
src/main/java/com/yunzhi/shigongli/mapper/TaOrderPayMapper.java Bestand weergeven

@@ -17,4 +17,8 @@ import org.apache.ibatis.annotations.Param;
17 17
 public interface TaOrderPayMapper extends BaseMapper<TaOrderPay> {
18 18
 
19 19
     TaOrderPay getByOrder(@Param("orderId") String orderId, @Param("subOrderId") String subOrderId);
20
+
21
+    TaOrderPay getLastRowByOrder(@Param("orderId") String orderId);
22
+
23
+    TaOrderPay getLastRowByOrderSub(@Param("orderId") String orderId, @Param("subOrderId") String subOrderId);
20 24
 }

+ 9
- 0
src/main/java/com/yunzhi/shigongli/mapper/TaOrderSubMapper.java Bestand weergeven

@@ -1,7 +1,9 @@
1 1
 package com.yunzhi.shigongli.mapper;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.yunzhi.shigongli.entity.TaOrderSub;
4 5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
+import com.yunzhi.shigongli.vo.MineOrder;
5 7
 import org.apache.ibatis.annotations.Mapper;
6 8
 import org.apache.ibatis.annotations.Param;
7 9
 
@@ -25,4 +27,11 @@ public interface TaOrderSubMapper extends BaseMapper<TaOrderSub> {
25 27
     int updateStatus(@Param("subOrderId") String subOrderId, @Param("status") Integer status);
26 28
 
27 29
     int updateVerified(@Param("subOrderId") String subOrderId, @Param("isVerified") int isVerified);
30
+
31
+    IPage<MineOrder> getOrderSubListOf(IPage<MineOrder> pg,
32
+                                       @Param("personId") String personId,
33
+                                       @Param("shopTarget") String shopTarget,
34
+                                       @Param("status") Integer status);
35
+
36
+    int getOrderNum(@Param("personId") String personId, @Param("status") Integer status);
28 37
 }

+ 22
- 0
src/main/java/com/yunzhi/shigongli/mapper/TaSequenceMapper.java Bestand weergeven

@@ -0,0 +1,22 @@
1
+package com.yunzhi.shigongli.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.yunzhi.shigongli.entity.TaSequence;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+import org.apache.ibatis.annotations.Select;
8
+
9
+/**
10
+ * <p>
11
+ * 访问人 Mapper 接口
12
+ * </p>
13
+ *
14
+ * @author yansen
15
+ * @since 2021-08-17
16
+ */
17
+@Mapper
18
+public interface TaSequenceMapper extends BaseMapper<TaSequence> {
19
+
20
+    @Select("select fn_nextval(#{seqName})")
21
+    int nextval(@Param("seqName") String seqName);
22
+}

+ 5
- 0
src/main/java/com/yunzhi/shigongli/mapper/TaShopMapper.java Bestand weergeven

@@ -21,4 +21,9 @@ public interface TaShopMapper extends BaseMapper<TaShop> {
21 21
     IPage<ShopListVO> getPageListBy(IPage<ShopListVO> pg, @Param("shopName") String shopName, @Param("phone") String phone);
22 22
 
23 23
     int updatePVNum(@Param("phone") String id);
24
+
25
+    int updateScore(@Param("field") String field,
26
+                    @Param("evaluateType") String evaluateType,
27
+                    @Param("targetType") String targetType,
28
+                    @Param("targetId") String targetId);
24 29
 }

+ 3
- 0
src/main/java/com/yunzhi/shigongli/service/ITaEvaluationService.java Bestand weergeven

@@ -1,6 +1,8 @@
1 1
 package com.yunzhi.shigongli.service;
2 2
 
3 3
 import com.yunzhi.shigongli.entity.TaEvaluation;
4
+import com.yunzhi.shigongli.entity.TaPerson;
5
+import com.yunzhi.shigongli.vo.EvaluateTarget;
4 6
 
5 7
 
6 8
 /**
@@ -13,4 +15,5 @@ import com.yunzhi.shigongli.entity.TaEvaluation;
13 15
  */
14 16
 public interface ITaEvaluationService extends IBaseService<TaEvaluation> {
15 17
 
18
+    void evaluateSomething(TaPerson taPerson, EvaluateTarget evaluateTarget) throws Exception;
16 19
 }

+ 1
- 0
src/main/java/com/yunzhi/shigongli/service/ITaLikeService.java Bestand weergeven

@@ -13,4 +13,5 @@ import com.yunzhi.shigongli.entity.TaLike;
13 13
  */
14 14
 public interface ITaLikeService extends IBaseService<TaLike> {
15 15
 
16
+    TaLike getByTarget(String targetType, String targetId, String personId);
16 17
 }

+ 12
- 0
src/main/java/com/yunzhi/shigongli/service/ITaOrderPayService.java Bestand weergeven

@@ -2,7 +2,11 @@ package com.yunzhi.shigongli.service;
2 2
 
3 3
 import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
4 4
 import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
5
+import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
6
+import com.yunzhi.shigongli.entity.TaOrder;
5 7
 import com.yunzhi.shigongli.entity.TaOrderPay;
8
+import com.yunzhi.shigongli.entity.TaOrderSub;
9
+import com.yunzhi.shigongli.entity.TaPerson;
6 10
 
7 11
 
8 12
 /**
@@ -18,4 +22,12 @@ public interface ITaOrderPayService extends IBaseService<TaOrderPay> {
18 22
     void notifyOrder(WxPayOrderNotifyResult notifyResult) throws Exception;
19 23
 
20 24
     void refundNotifyOrder(WxPayRefundNotifyResult result) throws Exception;
25
+
26
+    WxPayMpOrderResult prePay(TaPerson person, TaOrder taOrder) throws Exception;
27
+
28
+    void refundOrderSub(TaPerson taPerson, TaOrder taOrder, TaOrderSub taOrderSub) throws Exception;
29
+
30
+    void refundOrder(TaPerson person, TaOrder taOrder, Integer totalCashback) throws Exception;
31
+
32
+    WxPayMpOrderResult prePay(TaPerson person, TaOrder taOrder, TaOrderSub taOrderSub) throws Exception;
21 33
 }

+ 3
- 1
src/main/java/com/yunzhi/shigongli/service/ITaOrderService.java Bestand weergeven

@@ -17,7 +17,9 @@ import com.yunzhi.shigongli.vo.OrderItem;
17 17
  */
18 18
 public interface ITaOrderService extends IBaseService<TaOrder> {
19 19
 
20
-    WxPayMpOrderResult order(TaPerson person, OrderItem[] orderItems) throws Exception;
20
+    TaOrder order(TaPerson person, OrderItem[] orderItems) throws Exception;
21 21
 
22 22
     void cancelOrder(TaOrder taOrder, TaPerson taPerson) throws Exception;
23
+
24
+    void refundOrder(TaOrder taOrder, TaPerson taPerson) throws Exception;
23 25
 }

+ 11
- 0
src/main/java/com/yunzhi/shigongli/service/ITaOrderSubService.java Bestand weergeven

@@ -1,9 +1,14 @@
1 1
 package com.yunzhi.shigongli.service;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.yunzhi.shigongli.entity.TaOrder;
4 5
 import com.yunzhi.shigongli.entity.TaOrderSub;
5 6
 
6 7
 import com.yunzhi.shigongli.entity.TaPerson;
8
+import com.yunzhi.shigongli.vo.MineOrder;
9
+import com.yunzhi.shigongli.vo.MineOrderSummary;
10
+
11
+import java.util.List;
7 12
 
8 13
 /**
9 14
  * <p>
@@ -18,4 +23,10 @@ public interface ITaOrderSubService extends IBaseService<TaOrderSub> {
18 23
     void refund(TaPerson person, TaOrder taOrder, TaOrderSub taOrderSub) throws Exception;
19 24
 
20 25
     void validation(TaPerson taPerson, TaOrder taOrder, TaOrderSub taOrderSub) throws Exception;
26
+
27
+    IPage<MineOrder> getOrderSubListOf(IPage<MineOrder> pg, TaPerson taPerson, Integer status);
28
+
29
+    MineOrderSummary getOrderSummary(TaPerson taPerson);
30
+
31
+    List<TaOrderSub> getListByOrder(TaOrder taOrder);
21 32
 }

+ 2
- 1
src/main/java/com/yunzhi/shigongli/service/ITaPersonAccountService.java Bestand weergeven

@@ -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.TaOrderPay;
4 5
 import com.yunzhi.shigongli.entity.TaOrderSub;
5 6
 import com.yunzhi.shigongli.entity.TaPersonAccount;
6 7
 
@@ -15,6 +16,6 @@ import com.yunzhi.shigongli.entity.TaPersonAccount;
15 16
  */
16 17
 public interface ITaPersonAccountService extends IBaseService<TaPersonAccount> {
17 18
 
18
-    void cashback(TaOrder taOrder) throws Exception;
19
+    void cashback(TaOrderPay orderPay) throws Exception;
19 20
 
20 21
 }

+ 3
- 0
src/main/java/com/yunzhi/shigongli/service/ITaResourceService.java Bestand weergeven

@@ -1,6 +1,7 @@
1 1
 package com.yunzhi.shigongli.service;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.shigongli.entity.TaLike;
4 5
 import com.yunzhi.shigongli.entity.TaPerson;
5 6
 import com.yunzhi.shigongli.entity.TaResource;
6 7
 import com.yunzhi.shigongli.entity.TaSave;
@@ -26,4 +27,6 @@ public interface ITaResourceService extends IBaseService<TaResource> {
26 27
     void updateSave(TaSave taSave, int num);
27 28
 
28 29
     IPage<ResourceListVO> getWxPagedBy(IPage<ResourceListVO> pg, TaPerson taPerso, String location, String typeId);
30
+
31
+    void updateLike(TaLike taLike, int num);
29 32
 }

+ 93
- 0
src/main/java/com/yunzhi/shigongli/service/impl/TaEvaluationServiceImpl.java Bestand weergeven

@@ -1,10 +1,19 @@
1 1
 package com.yunzhi.shigongli.service.impl;
2 2
 
3
+import com.yunzhi.shigongli.common.Constants;
3 4
 import com.yunzhi.shigongli.entity.TaEvaluation;
5
+import com.yunzhi.shigongli.entity.TaPerson;
6
+import com.yunzhi.shigongli.entity.TaShop;
4 7
 import com.yunzhi.shigongli.mapper.TaEvaluationMapper;
8
+import com.yunzhi.shigongli.mapper.TaShopMapper;
5 9
 import com.yunzhi.shigongli.service.ITaEvaluationService;
6 10
 
11
+import com.yunzhi.shigongli.vo.EvaluateTarget;
12
+import org.springframework.beans.factory.annotation.Autowired;
7 13
 import org.springframework.stereotype.Service;
14
+import org.springframework.transaction.annotation.Transactional;
15
+
16
+import java.time.LocalDateTime;
8 17
 
9 18
 /**
10 19
  * <p>
@@ -17,4 +26,88 @@ import org.springframework.stereotype.Service;
17 26
 @Service
18 27
 public class TaEvaluationServiceImpl extends BaseServiceImpl<TaEvaluationMapper, TaEvaluation> implements ITaEvaluationService {
19 28
 
29
+    @Autowired
30
+    TaShopMapper taShopMapper;
31
+
32
+    @Transactional(rollbackFor = Exception.class)
33
+    @Override
34
+    public void evaluateSomething(TaPerson taPerson, EvaluateTarget evaluateTarget) throws Exception {
35
+        if (null == evaluateTarget.getEnvironmentScore()
36
+                && null == evaluateTarget.getSweetScore()
37
+                && null == evaluateTarget.getServiceScore()) {
38
+            throw new Exception("未找到评价内容");
39
+        }
40
+
41
+        if (evaluateTarget.getEnvironmentScore() < 1
42
+                && evaluateTarget.getSweetScore() < 1
43
+                && evaluateTarget.getServiceScore() < 1) {
44
+            throw new Exception("未找到评价内容");
45
+        }
46
+
47
+        // 环境评分
48
+        if (evaluateTarget.getEnvironmentScore() > 0) {
49
+            TaEvaluation taEvaluation = new TaEvaluation();
50
+            taEvaluation.setEvaluateType(Constants.EVALUATE_ENVIRONMENT);
51
+            taEvaluation.setTargetType(evaluateTarget.getTargetType());
52
+            taEvaluation.setTargetId(evaluateTarget.getTargetId());
53
+            taEvaluation.setScore(evaluateTarget.getEnvironmentScore());
54
+            taEvaluation.setPersonId(taPerson.getPersonId());
55
+            taEvaluation.setCreateDate(LocalDateTime.now());
56
+            baseMapper.insert(taEvaluation);
57
+
58
+            // 暂时不将用户评分纳入系统
59
+//            if (Constants.TARGET_SHOP.equals(evaluateTarget.getTargetType())) {
60
+//                //
61
+//                taShopMapper.updateScore("environment_score",
62
+//                        taEvaluation.getEvaluateType(),
63
+//                        taEvaluation.getTargetType(),
64
+//                        taEvaluation.getTargetId());
65
+//            }
66
+        }
67
+
68
+        // 口味评分
69
+        if (evaluateTarget.getSweetScore() > 0) {
70
+            TaEvaluation taEvaluation = new TaEvaluation();
71
+            taEvaluation.setEvaluateType(Constants.EVALUATE_SWEET);
72
+            taEvaluation.setTargetType(evaluateTarget.getTargetType());
73
+            taEvaluation.setTargetId(evaluateTarget.getTargetId());
74
+            taEvaluation.setScore(evaluateTarget.getSweetScore());
75
+            taEvaluation.setPersonId(taPerson.getPersonId());
76
+            taEvaluation.setCreateDate(LocalDateTime.now());
77
+            baseMapper.insert(taEvaluation);
78
+
79
+            // 暂时不将用户评分纳入系统
80
+//            if (Constants.TARGET_SHOP.equals(evaluateTarget.getTargetType())) {
81
+//                //
82
+//                taShopMapper.updateScore("sweet_score",
83
+//                        taEvaluation.getEvaluateType(),
84
+//                        taEvaluation.getTargetType(),
85
+//                        taEvaluation.getTargetId());
86
+//            }
87
+        }
88
+
89
+        // 服务评分
90
+        if (evaluateTarget.getServiceScore() > 0) {
91
+            TaEvaluation taEvaluation = new TaEvaluation();
92
+            taEvaluation.setEvaluateType(Constants.EVALUATE_SERVICE);
93
+            taEvaluation.setTargetType(evaluateTarget.getTargetType());
94
+            taEvaluation.setTargetId(evaluateTarget.getTargetId());
95
+            taEvaluation.setScore(evaluateTarget.getServiceScore());
96
+            taEvaluation.setPersonId(taPerson.getPersonId());
97
+            taEvaluation.setCreateDate(LocalDateTime.now());
98
+            baseMapper.insert(taEvaluation);
99
+
100
+            // 暂时不将用户评分纳入系统
101
+//            if (Constants.TARGET_SHOP.equals(evaluateTarget.getTargetType())) {
102
+//                //
103
+//                taShopMapper.updateScore("service_score",
104
+//                        taEvaluation.getEvaluateType(),
105
+//                        taEvaluation.getTargetType(),
106
+//                        taEvaluation.getTargetId());
107
+//            }
108
+        }
109
+
110
+    }
111
+
112
+
20 113
 }

+ 10
- 0
src/main/java/com/yunzhi/shigongli/service/impl/TaLikeServiceImpl.java Bestand weergeven

@@ -1,5 +1,6 @@
1 1
 package com.yunzhi.shigongli.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
3 4
 import com.yunzhi.shigongli.entity.TaLike;
4 5
 import com.yunzhi.shigongli.mapper.TaLikeMapper;
5 6
 import com.yunzhi.shigongli.service.ITaLikeService;
@@ -17,4 +18,13 @@ import org.springframework.stereotype.Service;
17 18
 @Service
18 19
 public class TaLikeServiceImpl extends BaseServiceImpl<TaLikeMapper, TaLike> implements ITaLikeService {
19 20
 
21
+    @Override
22
+    public TaLike getByTarget(String targetType, String targetId, String personId) {
23
+        LambdaQueryWrapper<TaLike> queryWrapper = new LambdaQueryWrapper<>();
24
+        queryWrapper.eq(TaLike::getTargetType, targetType);
25
+        queryWrapper.eq(TaLike::getTargetId, targetId);
26
+        queryWrapper.eq(TaLike::getPersonId, personId);
27
+
28
+        return getOne(queryWrapper);
29
+    }
20 30
 }

+ 149
- 43
src/main/java/com/yunzhi/shigongli/service/impl/TaOrderPayServiceImpl.java Bestand weergeven

@@ -2,21 +2,22 @@ package com.yunzhi.shigongli.service.impl;
2 2
 
3 3
 import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
4 4
 import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
5
+import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
5 6
 import com.github.binarywang.wxpay.constant.WxPayConstants;
6 7
 import com.yunzhi.shigongli.common.Constants;
7 8
 import com.yunzhi.shigongli.common.DateUtils;
8
-import com.yunzhi.shigongli.entity.TaOrder;
9
-import com.yunzhi.shigongli.entity.TaOrderPay;
9
+import com.yunzhi.shigongli.common.StringUtils;
10
+import com.yunzhi.shigongli.common.WxPayUtils;
11
+import com.yunzhi.shigongli.entity.*;
10 12
 import com.yunzhi.shigongli.event.PaySuccessEvent;
11 13
 import com.yunzhi.shigongli.event.RefundSuccessEvent;
12
-import com.yunzhi.shigongli.mapper.TaOrderMapper;
13
-import com.yunzhi.shigongli.mapper.TaOrderPayMapper;
14
-import com.yunzhi.shigongli.mapper.TaOrderSubMapper;
14
+import com.yunzhi.shigongli.mapper.*;
15 15
 import com.yunzhi.shigongli.service.ITaOrderPayService;
16 16
 
17 17
 import org.springframework.beans.factory.annotation.Autowired;
18 18
 import org.springframework.context.ApplicationEventPublisher;
19 19
 import org.springframework.stereotype.Service;
20
+import org.springframework.transaction.annotation.Transactional;
20 21
 
21 22
 /**
22 23
  * <p>
@@ -29,6 +30,9 @@ import org.springframework.stereotype.Service;
29 30
 @Service
30 31
 public class TaOrderPayServiceImpl extends BaseServiceImpl<TaOrderPayMapper, TaOrderPay> implements ITaOrderPayService {
31 32
 
33
+    @Autowired
34
+    WxPayUtils wxPayUtils;
35
+
32 36
     @Autowired
33 37
     TaOrderPayMapper orderPayMapper;
34 38
 
@@ -41,6 +45,12 @@ public class TaOrderPayServiceImpl extends BaseServiceImpl<TaOrderPayMapper, TaO
41 45
     @Autowired
42 46
     ApplicationEventPublisher eventPublisher;
43 47
 
48
+    @Autowired
49
+    TaSequenceMapper taSequenceMapper;
50
+
51
+    @Autowired
52
+    TaShopPackageMapper shopPackageMapper;
53
+
44 54
     /**
45 55
      * 支付回调
46 56
      * @param notifyResult
@@ -48,34 +58,28 @@ public class TaOrderPayServiceImpl extends BaseServiceImpl<TaOrderPayMapper, TaO
48 58
      */
49 59
     @Override
50 60
     public void notifyOrder(WxPayOrderNotifyResult notifyResult) throws Exception {
51
-        TaOrder taOrder = taOrderMapper.selectById(notifyResult.getOutTradeNo());
61
+        TaOrderPay orderPay = getById(notifyResult.getOutTradeNo());
62
+        String orderId = orderPay.getOrderId();
63
+        String orderSubId = orderPay.getSubOrderId();
64
+
52 65
         boolean isSuccess = WxPayConstants.ResultCode.SUCCESS.equals(notifyResult.getResultCode());
53 66
 
54
-        TaOrderPay orderPay = new TaOrderPay();
55
-        orderPay.setOrderId(taOrder.getOrderId());
56
-        orderPay.setPersonId(taOrder.getPersonId());
57
-        orderPay.setCharges(notifyResult.getTotalFee());
58 67
         orderPay.setPayDate(DateUtils.from(notifyResult.getTimeEnd(), "yyyyMMddHHmmss"));
59 68
         orderPay.setStatus(isSuccess ? Constants.PAY_SUCCESS : Constants.PAY_FAIL);
60 69
         orderPay.setMessage(isSuccess ? null : notifyResult.getErrCodeDes());
61 70
 
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
-        }
71
+        orderPayMapper.updateById(orderPay);
69 72
 
70 73
         // 更新订单为已支付
71 74
         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);
75
+            if (!StringUtils.isEmpty(orderSubId)) {
76
+                taOrderSubMapper.updateStatus(orderSubId, Constants.ORDER_PAYED);
77
+            } else {
78
+                taOrderMapper.updateStatus(orderId, Constants.ORDER_PAYED);
79
+                taOrderSubMapper.updateStatusByOrder(orderId, Constants.ORDER_PAYED);
80
+            }
81
+
82
+            PaySuccessEvent evt = new PaySuccessEvent(this, orderPay);
79 83
             eventPublisher.publishEvent(evt);
80 84
         }
81 85
     }
@@ -87,33 +91,135 @@ public class TaOrderPayServiceImpl extends BaseServiceImpl<TaOrderPayMapper, TaO
87 91
             return;
88 92
         }
89 93
 
90
-        // 退款成功
91
-        boolean isSuccess = WxPayConstants.RefundStatus.SUCCESS.equals(reqInfo.getRefundStatus());
92
-        if (!isSuccess) {
94
+        // 退款处理中
95
+        if (WxPayConstants.RefundStatus.PROCESSING.equals(reqInfo.getRefundStatus())) {
93 96
             return;
94 97
         }
95 98
 
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());
99
+        // 退款成功
100
+        boolean isSuccess = WxPayConstants.RefundStatus.SUCCESS.equals(reqInfo.getRefundStatus());
101
+
102
+        TaOrderPay orderPay = getById(reqInfo.getOutTradeNo());
101 103
         orderPay.setPayDate(DateUtils.from(reqInfo.getSuccessTime(), "yyyyMMddHHmmss"));
102
-        orderPay.setStatus(Constants.PAY_SUCCESS);
103
-        orderPay.setMessage(null);
104
-
105
-        // 如果退款单号 = R + 订单号, 说明是全订单退款
106
-        // 否则是订单项退款
107
-        if (!reqInfo.getOutRefundNo().equals("R"+taOrder.getOrderId())) {
108
-            orderPay.setSubOrderId(reqInfo.getOutRefundNo().substring(1));
109
-            taOrderSubMapper.updateStatus(orderPay.getSubOrderId(), Constants.ORDER_REFUND);
104
+        orderPay.setStatus(isSuccess ? Constants.PAY_SUCCESS : Constants.PAY_FAIL);
105
+        orderPay.setMessage(isSuccess ? null : reqInfo.getRefundStatus());
106
+
107
+        orderPayMapper.updateById(orderPay);
108
+
109
+        String orderId = orderPay.getOrderId();
110
+        String orderSubId = orderPay.getSubOrderId();
111
+        if (isSuccess) {
112
+            if (StringUtils.isEmpty(orderSubId)) {
113
+                taOrderMapper.updateStatus(orderId, Constants.ORDER_REFUND);
114
+                taOrderSubMapper.updateStatusByOrder(orderId, Constants.ORDER_REFUND);
115
+            } else {
116
+                taOrderSubMapper.updateStatus(orderSubId, Constants.ORDER_REFUND);
117
+            }
118
+
119
+            RefundSuccessEvent evt = new RefundSuccessEvent(this, orderPay);
120
+            eventPublisher.publishEvent(evt);
121
+        }
122
+    }
123
+
124
+    @Override
125
+    public WxPayMpOrderResult prePay(TaPerson person, TaOrder taOrder) throws Exception {
126
+        TaOrderPay orderPay = createByOrder(taOrder);
127
+        orderPayMapper.insert(orderPay);
128
+
129
+        return wxPayUtils.createOrder(person, orderPay);
130
+    }
131
+
132
+    @Override
133
+    public void refundOrderSub(TaPerson taPerson, TaOrder taOrder, TaOrderSub taOrderSub) throws Exception {
134
+        TaOrderPay originOrderPay = null;
135
+
136
+        // 找当前子项目对应的支付记录
137
+        originOrderPay = orderPayMapper.getLastRowByOrderSub(taOrder.getOrderId(), taOrderSub.getSubOrderId());
138
+        if (null != originOrderPay) {
139
+            if (Constants.PAY_SUCCESS.equals(originOrderPay.getStatus())) {
140
+                throw new Exception("未找到当前订单有效的支付记录");
141
+            }
110 142
         } else {
111
-            taOrderMapper.updateStatus(orderPay.getOrderId(), Constants.ORDER_REFUND);
143
+            // 找到主订单对应的那个支付记录
144
+            originOrderPay = orderPayMapper.getLastRowByOrder(taOrder.getOrderId());
145
+            if (null != originOrderPay) {
146
+                if (Constants.PAY_SUCCESS.equals(originOrderPay.getStatus())) {
147
+                    throw new Exception("未找到当前订单有效的支付记录");
148
+                }
149
+            } else {
150
+                throw new Exception("未找到当前订单有效的支付记录");
151
+            }
112 152
         }
113 153
 
154
+        TaOrderPay orderPay = createByOrderSub(taOrderSub, taPerson);
155
+        // 退款金额 = 订单金额 - 返现金额
156
+        orderPay.setCharges(taOrderSub.getCharges() - taOrderSub.getCashback());
157
+
158
+        // 发起退款
159
+        wxPayUtils.refund(originOrderPay, orderPay);
160
+    }
161
+
162
+    @Override
163
+    public void refundOrder(TaPerson person, TaOrder taOrder, Integer totalCashback) throws Exception {
164
+        // 找到主订单对应的那个支付记录
165
+        TaOrderPay originOrderPay = orderPayMapper.getLastRowByOrder(taOrder.getOrderId());
166
+        if (null != originOrderPay) {
167
+            if (Constants.PAY_SUCCESS.equals(originOrderPay.getStatus())) {
168
+                throw new Exception("未找到当前订单有效的支付记录");
169
+            }
170
+        } else {
171
+            throw new Exception("未找到当前订单有效的支付记录");
172
+        }
173
+
174
+        TaOrderPay orderPay = createByOrder(taOrder);
175
+        // 退款金额 = 订单金额 - 返现金额
176
+        orderPay.setCharges(taOrder.getCharges() - totalCashback);
177
+
178
+        // 发起退款
179
+        wxPayUtils.refund(originOrderPay, orderPay);
180
+    }
181
+
182
+    @Transactional(rollbackFor = Exception.class)
183
+    @Override
184
+    public WxPayMpOrderResult prePay(TaPerson person, TaOrder taOrder, TaOrderSub taOrderSub) throws Exception {
185
+        TaOrderPay orderPay = createByOrderSub(taOrderSub, person);
114 186
         orderPayMapper.insert(orderPay);
115 187
 
116
-        RefundSuccessEvent evt = new RefundSuccessEvent(this, taOrder, null);
117
-        eventPublisher.publishEvent(evt);
188
+        return wxPayUtils.createOrder(person, orderPay);
189
+    }
190
+
191
+    private TaOrderPay createByOrder(TaOrder taOrder) throws Exception {
192
+        // 发给微信的订单号为  订单ID-01 这种
193
+        Integer no = taSequenceMapper.nextval(taOrder.getOrderId());
194
+        String payNo = StringUtils.lpad(no.toString(), "0", 2);
195
+        String payId = taOrder.getOrderId() + "-" + payNo;
196
+
197
+        TaOrderPay orderPay = new TaOrderPay();
198
+        orderPay.setPayId(payId);
199
+        orderPay.setOrderId(taOrder.getOrderId());
200
+        orderPay.setPersonId(taOrder.getPersonId());
201
+        orderPay.setCharges(taOrder.getCharges());
202
+        orderPay.setDescription(taOrder.getDescription());
203
+        orderPay.setStatus(Constants.STATUS_READY);
204
+
205
+        return orderPay;
206
+    }
207
+
208
+    private TaOrderPay createByOrderSub(TaOrderSub taOrderSub, TaPerson person) throws Exception {
209
+        // 发给微信的订单号为  订单ID-01 这种
210
+        Integer no = taSequenceMapper.nextval(taOrderSub.getSubOrderId());
211
+        String payNo = StringUtils.lpad(no.toString(), "0", 2);
212
+        String payId = taOrderSub.getSubOrderId() + "-" + payNo;
213
+
214
+        TaOrderPay orderPay = new TaOrderPay();
215
+        orderPay.setPayId(payId);
216
+        orderPay.setOrderId(taOrderSub.getOrderId());
217
+        orderPay.setSubOrderId(taOrderSub.getSubOrderId());
218
+        orderPay.setPersonId(person.getPersonId());
219
+        orderPay.setCharges(taOrderSub.getCharges());
220
+        orderPay.setDescription(taOrderSub.getDescription());
221
+        orderPay.setStatus(Constants.STATUS_READY);
222
+
223
+        return orderPay;
118 224
     }
119 225
 }

+ 15
- 8
src/main/java/com/yunzhi/shigongli/service/impl/TaOrderServiceImpl.java Bestand weergeven

@@ -31,9 +31,6 @@ import java.util.List;
31 31
 @Service
32 32
 public class TaOrderServiceImpl extends BaseServiceImpl<TaOrderMapper, TaOrder> implements ITaOrderService {
33 33
 
34
-    @Autowired
35
-    WxPayUtils wxPayUtils;
36
-
37 34
     @Autowired
38 35
     TaShopPackageMapper taShopPackageMapper;
39 36
 
@@ -61,14 +58,14 @@ public class TaOrderServiceImpl extends BaseServiceImpl<TaOrderMapper, TaOrder>
61 58
      */
62 59
     @Transactional(rollbackFor = Exception.class)
63 60
     @Override
64
-    public WxPayMpOrderResult order(TaPerson person, OrderItem[] orderItems) throws Exception {
61
+    public TaOrder order(TaPerson person, OrderItem[] orderItems) throws Exception {
65 62
         LocalDateTime now = LocalDateTime.now();
66 63
 
67 64
         // 是否首单
68 65
         TaOrder lastOrder = getPersonLastOrder(person.getPersonId());
69 66
         boolean isFirstOrder = null == lastOrder;
70 67
 
71
-                // 先生成主订单
68
+        // 先生成主订单
72 69
         TaOrder taOrder = new TaOrder();
73 70
         taOrder.setOrderId(getOrderNo());
74 71
         taOrder.setDescription("套餐");
@@ -82,8 +79,7 @@ public class TaOrderServiceImpl extends BaseServiceImpl<TaOrderMapper, TaOrder>
82 79
         taOrder.setCharges(charge);
83 80
         save(taOrder);
84 81
 
85
-        // 发起微信支付订单
86
-        return wxPayUtils.createOrder(person, taOrder);
82
+        return taOrder;
87 83
     }
88 84
 
89 85
     /**
@@ -123,6 +119,15 @@ public class TaOrderServiceImpl extends BaseServiceImpl<TaOrderMapper, TaOrder>
123 119
         taOrderSubMapper.updateStatusByOrder(taOrder.getOrderId(), Constants.ORDER_CANCEL);
124 120
     }
125 121
 
122
+    @Transactional(rollbackFor = Exception.class)
123
+    @Override
124
+    public void refundOrder(TaOrder taOrder, TaPerson taPerson) throws Exception {
125
+
126
+        // 只需要更新状态即可
127
+        taOrderMapper.updateStatus(taOrder.getOrderId(), Constants.ORDER_REFUND);
128
+        taOrderSubMapper.updateStatusByOrder(taOrder.getOrderId(), Constants.ORDER_REFUND);
129
+    }
130
+
126 131
     /**
127 132
      * 获取订单号
128 133
      * @return
@@ -133,7 +138,7 @@ public class TaOrderServiceImpl extends BaseServiceImpl<TaOrderMapper, TaOrder>
133 138
         String orderNo = null;
134 139
         do {
135 140
             String random = StringUtils.random(4);
136
-            orderNo = String.format("%s-%s", today, random);
141
+            orderNo = String.format("%s%s", today, random);
137 142
             TaOrder taOrder = getById(orderNo);
138 143
             if (null == taOrder) {
139 144
                 break;
@@ -197,6 +202,8 @@ public class TaOrderServiceImpl extends BaseServiceImpl<TaOrderMapper, TaOrder>
197 202
                     && shopPackage.getShopId().equals(taPerson.getRecommender());
198 203
 
199 204
             orderSub.setPackageId(packageId);
205
+            String desc = StringUtils.ifNull(shopPackage.getDescription(), "套餐项目");
206
+            orderSub.setDescription(desc.substring(0, 128));
200 207
 
201 208
             // 价格
202 209
             if (!item.getPrice().equals(shopPackage.getActualPrice())) {

+ 33
- 2
src/main/java/com/yunzhi/shigongli/service/impl/TaOrderSubServiceImpl.java Bestand weergeven

@@ -1,11 +1,14 @@
1 1
 package com.yunzhi.shigongli.service.impl;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.yunzhi.shigongli.common.Constants;
4 5
 import com.yunzhi.shigongli.common.WxPayUtils;
5 6
 import com.yunzhi.shigongli.entity.*;
6 7
 import com.yunzhi.shigongli.mapper.*;
7 8
 import com.yunzhi.shigongli.service.ITaOrderSubService;
8 9
 
10
+import com.yunzhi.shigongli.vo.MineOrder;
11
+import com.yunzhi.shigongli.vo.MineOrderSummary;
9 12
 import org.omg.PortableInterceptor.ACTIVE;
10 13
 import org.springframework.beans.factory.annotation.Autowired;
11 14
 import org.springframework.stereotype.Service;
@@ -28,6 +31,9 @@ public class TaOrderSubServiceImpl extends BaseServiceImpl<TaOrderSubMapper, TaO
28 31
     @Autowired
29 32
     WxPayUtils wxPayUtils;
30 33
 
34
+    @Autowired
35
+    TaOrderMapper taOrderMapper;
36
+
31 37
     @Autowired
32 38
     TaOrderSubMapper taOrderSubMapper;
33 39
 
@@ -59,8 +65,6 @@ public class TaOrderSubServiceImpl extends BaseServiceImpl<TaOrderSubMapper, TaO
59 65
     @Transactional(rollbackFor = Exception.class)
60 66
     @Override
61 67
     public void refund(TaPerson person, TaOrder taOrder, TaOrderSub taOrderSub) throws Exception {
62
-        wxPayUtils.refund(taOrder, taOrderSub);
63
-
64 68
         // 更新表
65 69
         taOrderSubMapper.updateStatus(taOrderSub.getSubOrderId(), Constants.ORDER_REFUND);
66 70
 
@@ -100,6 +104,33 @@ public class TaOrderSubServiceImpl extends BaseServiceImpl<TaOrderSubMapper, TaO
100 104
         }
101 105
     }
102 106
 
107
+    @Override
108
+    public IPage<MineOrder> getOrderSubListOf(IPage<MineOrder> pg, TaPerson taPerson, Integer status) {
109
+
110
+        return baseMapper.getOrderSubListOf(pg, taPerson.getPersonId(), Constants.TARGET_SHOP, status);
111
+    }
112
+
113
+    @Override
114
+    public MineOrderSummary getOrderSummary(TaPerson taPerson) {
115
+        MineOrderSummary orderSummary = new MineOrderSummary();
116
+
117
+        int unPayNum = taOrderMapper.getOrderNum(taPerson.getPersonId(), Constants.ORDER_READY);
118
+        orderSummary.setUnPayNum(unPayNum);
119
+
120
+        int unVerifiedNum = taOrderSubMapper.getOrderNum(taPerson.getPersonId(), Constants.ORDER_PAYED);
121
+        orderSummary.setUnVerifiedNum(unVerifiedNum);
122
+
123
+        int refundNum = taOrderSubMapper.getOrderNum(taPerson.getPersonId(), Constants.ORDER_REFUND);
124
+        orderSummary.setRefundNum(refundNum);
125
+
126
+        return orderSummary;
127
+    }
128
+
129
+    @Override
130
+    public List<TaOrderSub> getListByOrder(TaOrder taOrder) {
131
+        return taOrderSubMapper.getListByOrder(taOrder.getOrderId());
132
+    }
133
+
103 134
     /**
104 135
      * 商铺抽成入账户
105 136
      * @param shopId

+ 20
- 12
src/main/java/com/yunzhi/shigongli/service/impl/TaPersonAccountServiceImpl.java Bestand weergeven

@@ -1,10 +1,9 @@
1 1
 package com.yunzhi.shigongli.service.impl;
2 2
 
3 3
 import com.yunzhi.shigongli.common.Constants;
4
-import com.yunzhi.shigongli.entity.TaOrder;
5
-import com.yunzhi.shigongli.entity.TaOrderSub;
6
-import com.yunzhi.shigongli.entity.TaPersonAccount;
7
-import com.yunzhi.shigongli.entity.TaPersonAccountLog;
4
+import com.yunzhi.shigongli.common.StringUtils;
5
+import com.yunzhi.shigongli.entity.*;
6
+import com.yunzhi.shigongli.mapper.TaOrderMapper;
8 7
 import com.yunzhi.shigongli.mapper.TaOrderSubMapper;
9 8
 import com.yunzhi.shigongli.mapper.TaPersonAccountLogMapper;
10 9
 import com.yunzhi.shigongli.mapper.TaPersonAccountMapper;
@@ -30,6 +29,9 @@ import java.util.List;
30 29
 @Service
31 30
 public class TaPersonAccountServiceImpl extends BaseServiceImpl<TaPersonAccountMapper, TaPersonAccount> implements ITaPersonAccountService {
32 31
 
32
+    @Autowired
33
+    TaOrderMapper taOrderMapper;
34
+
33 35
     @Autowired
34 36
     TaOrderSubMapper orderSubMapper;
35 37
 
@@ -45,12 +47,18 @@ public class TaPersonAccountServiceImpl extends BaseServiceImpl<TaPersonAccountM
45 47
     @Async
46 48
     @Transactional(rollbackFor = Exception.class)
47 49
     @Override
48
-    public void cashback(TaOrder taOrder) throws Exception {
49
-        List<TaOrderSub> orderSubList = orderSubMapper.getListByOrder(taOrder.getOrderId());
50
-
50
+    public void cashback(TaOrderPay taOrderPay) throws Exception {
51
+        String orderId = taOrderPay.getOrderId();
52
+        String orderSubId = taOrderPay.getSubOrderId();
53
+        TaOrder taOrder = taOrderMapper.selectById(orderId);
51 54
         Integer cashback = 0;
52
-        for(TaOrderSub item : orderSubList) {
53
-            cashback += item.getCashback();
55
+        boolean isOrderSub = !StringUtils.isEmpty(orderSubId);
56
+        if (isOrderSub) {
57
+            TaOrderSub taOrderSub = orderSubMapper.selectById(orderSubId);
58
+            cashback = taOrderSub.getCashback();
59
+        } else {
60
+            List<TaOrderSub> orderSubList = orderSubMapper.getListByOrder(taOrder.getOrderId());
61
+            cashback = orderSubList.stream().mapToInt(TaOrderSub::getCashback).reduce(Integer::sum).getAsInt();
54 62
         }
55 63
 
56 64
         TaPersonAccount personAccount = personAccountMapper.getByPerson(taOrder.getPersonId());
@@ -62,9 +70,9 @@ public class TaPersonAccountServiceImpl extends BaseServiceImpl<TaPersonAccountM
62 70
         accountLog.setAmountType(Constants.ACCOUNT_CASHBACK);
63 71
         accountLog.setAmount(cashback);
64 72
         accountLog.setSignType(Constants.ACCOUNT_INCOME);
65
-        accountLog.setTargetType(Constants.TARGET_ORDER);
66
-        accountLog.setTargetId(taOrder.getOrderId());
67
-        accountLog.setOrderId(taOrder.getOrderId());
73
+        accountLog.setTargetType(isOrderSub ? Constants.TARGET_ORDER_SUB : Constants.TARGET_ORDER);
74
+        accountLog.setTargetId(isOrderSub ? orderSubId : orderId);
75
+        accountLog.setOrderId(orderId);
68 76
         accountLogMapper.insert(accountLog);
69 77
     }
70 78
 

+ 12
- 0
src/main/java/com/yunzhi/shigongli/service/impl/TaResourceServiceImpl.java Bestand weergeven

@@ -101,4 +101,16 @@ public class TaResourceServiceImpl extends BaseServiceImpl<TaResourceMapper, TaR
101 101
 
102 102
         return baseMapper.getWxPagedBy(pg, taPerson.getPersonId(), location, typeId);
103 103
     }
104
+
105
+    @Override
106
+    public void updateLike(TaLike taLike, int num) {
107
+        if (null == taLike) return;
108
+
109
+        TaResource taResource = getByTarget(taLike.getTargetType(), taLike.getTargetId());
110
+        if (null == taResource) {
111
+            return;
112
+        }
113
+
114
+        baseMapper.updateQuota("like_num", taLike.getTargetType(), taLike.getTargetId(), num);
115
+    }
104 116
 }

+ 28
- 0
src/main/java/com/yunzhi/shigongli/vo/EvaluateTarget.java Bestand weergeven

@@ -0,0 +1,28 @@
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
+import java.math.BigDecimal;
9
+
10
+@ApiModel(description = "民宿列表")
11
+@Data
12
+public class EvaluateTarget {
13
+
14
+    @ApiModelProperty(value = "对象类型")
15
+    private String TargetType;
16
+
17
+    @ApiModelProperty(value = "对象ID")
18
+    private String TargetId;
19
+
20
+    @ApiModelProperty(value = "口味评分")
21
+    private Integer sweetScore;
22
+
23
+    @ApiModelProperty(value = "环境评分")
24
+    private Integer environmentScore;
25
+
26
+    @ApiModelProperty(value = "服务评分")
27
+    private Integer serviceScore;
28
+}

+ 63
- 0
src/main/java/com/yunzhi/shigongli/vo/MineOrder.java Bestand weergeven

@@ -0,0 +1,63 @@
1
+package com.yunzhi.shigongli.vo;
2
+
3
+import io.swagger.annotations.ApiModel;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.Data;
6
+
7
+import java.time.LocalDateTime;
8
+
9
+@ApiModel(value="MineOrder", description="我的订单")
10
+@Data
11
+public class MineOrder {
12
+
13
+    @ApiModelProperty(value = "订单号")
14
+    private String orderId;
15
+
16
+    @ApiModelProperty(value = "子订单ID")
17
+    private String subOrderId;
18
+
19
+    @ApiModelProperty(value = "商铺ID")
20
+    private String shopId;
21
+
22
+    @ApiModelProperty(value = "套餐ID")
23
+    private String packageId;
24
+
25
+    @ApiModelProperty(value = "描述")
26
+    private String packageDescription;
27
+
28
+    @ApiModelProperty(value = "主图")
29
+    private String poster;
30
+
31
+    @ApiModelProperty(value = "综合评分")
32
+    private Float score;
33
+
34
+    @ApiModelProperty(value = "总金额;单位分")
35
+    private Integer charges;
36
+
37
+    @ApiModelProperty(value = "数量")
38
+    private Integer amount;
39
+
40
+    @ApiModelProperty(value = "单价;单位分")
41
+    private Integer unitPrice;
42
+
43
+    @ApiModelProperty(value = "抽成;单位分")
44
+    private Integer commissionCharge;
45
+
46
+    @ApiModelProperty(value = "返现金额;单位分")
47
+    private Integer cashback;
48
+
49
+    @ApiModelProperty(value = "是否核销")
50
+    private Boolean isVerified;
51
+
52
+    @ApiModelProperty(value = "状态")
53
+    private Integer status;
54
+
55
+    @ApiModelProperty(value = "创建时间")
56
+    private LocalDateTime createDate;
57
+
58
+    @ApiModelProperty(value = "核销时间")
59
+    private LocalDateTime verifiedDate;
60
+
61
+    @ApiModelProperty(value = "是否已评价")
62
+    private Integer isEvaluated;
63
+}

+ 20
- 0
src/main/java/com/yunzhi/shigongli/vo/MineOrderSummary.java Bestand weergeven

@@ -0,0 +1,20 @@
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(value="MineOrderSummary", description="我的订单")
9
+@Data
10
+public class MineOrderSummary {
11
+
12
+    @ApiModelProperty(value = "待支付订单数")
13
+    private Integer unPayNum;
14
+
15
+    @ApiModelProperty(value = "待核销订单数")
16
+    private Integer unVerifiedNum;
17
+
18
+    @ApiModelProperty(value = "退款订单数")
19
+    private Integer refundNum;
20
+}

+ 9
- 0
src/main/resources/mapper/TaOrderMapper.xml Bestand weergeven

@@ -8,4 +8,13 @@
8 8
         WHERE
9 9
             order_id = #{orderId}
10 10
     </update>
11
+    <select id="getOrderNum" resultType="java.lang.Integer">
12
+        SELECT
13
+            count( 1 ) AS cnt
14
+        FROM
15
+            ta_order t
16
+        WHERE
17
+            t.person_id = #{personId}
18
+          AND t.`status` = #{status}
19
+    </select>
11 20
 </mapper>

+ 24
- 0
src/main/resources/mapper/TaOrderPayMapper.xml Bestand weergeven

@@ -17,4 +17,28 @@
17 17
           </if>
18 18
             AND is_refund = 0
19 19
     </select>
20
+    <select id="getLastRowByOrder" resultType="com.yunzhi.shigongli.entity.TaOrderPay">
21
+        SELECT
22
+            *
23
+        FROM
24
+            ta_order_pay t
25
+        WHERE
26
+            t.order_id = #{orderId}
27
+          AND ( t.sub_order_id IS NULL OR t.sub_order_id = '' )
28
+        ORDER BY
29
+            t.create_date DESC
30
+            LIMIT 1
31
+    </select>
32
+    <select id="getLastRowByOrderSub" resultType="com.yunzhi.shigongli.entity.TaOrderPay">
33
+        SELECT
34
+            *
35
+        FROM
36
+            ta_order_pay t
37
+        WHERE
38
+            t.order_id = #{orderId}
39
+          AND t.sub_order_id = #{subOrderId}
40
+        ORDER BY
41
+            t.create_date DESC
42
+            LIMIT 1
43
+    </select>
20 44
 </mapper>

+ 44
- 0
src/main/resources/mapper/TaOrderSubMapper.xml Bestand weergeven

@@ -27,4 +27,48 @@
27 27
             order_id = #{orderId}
28 28
             AND `status` &gt; -1
29 29
     </select>
30
+    <select id="getOrderSubListOf" resultType="com.yunzhi.shigongli.vo.MineOrder">
31
+        SELECT
32
+            t.*,
33
+            ( m.sweet_score + m.environment_score + m.service_score ) / 3 AS score,
34
+            n.description AS package_description,
35
+            n.poster,
36
+            (
37
+            SELECT
38
+                count( 1 )
39
+            FROM
40
+                ta_evaluation a
41
+            WHERE
42
+                a.target_type = #{shopTarget}
43
+                AND a.target_id = t.shop_id
44
+                AND a.person_id = s.person_id
45
+            ) AS is_evaluated
46
+        FROM
47
+            ta_order_sub t
48
+                INNER JOIN ta_order s ON s.order_id = t.order_id
49
+                INNER JOIN ta_shop m ON m.shop_id = t.shop_id
50
+
51
+        WHERE
52
+            s.person_id = #{personId}
53
+          AND s.`status` &gt; - 1
54
+          <if test="status == null">
55
+              AND t.`status` &gt; - 1
56
+          </if>
57
+          <if test="status != null">
58
+              AND t.`status` = #{status}
59
+          </if>
60
+        ORDER BY
61
+            t.create_date DESC
62
+    </select>
63
+    <select id="getOrderNum" resultType="java.lang.Integer">
64
+        SELECT
65
+            COUNT( 1 ) AS cnt
66
+        FROM
67
+            ta_order_sub t
68
+                INNER JOIN ta_order s ON s.order_id = t.order_id
69
+        WHERE
70
+            s.person_id = #{personId}
71
+          AND t.`status` = #{status}
72
+          AND s.`status` &gt; -1
73
+    </select>
30 74
 </mapper>

+ 5
- 0
src/main/resources/mapper/TaSequenceMapper.xml Bestand weergeven

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

+ 21
- 0
src/main/resources/mapper/TaShopMapper.xml Bestand weergeven

@@ -7,6 +7,27 @@
7 7
         WHERE
8 8
             t.shop_id = #{id}
9 9
     </update>
10
+    <update id="updateScore">
11
+        UPDATE ta_shop t
12
+        INNER JOIN (
13
+            SELECT
14
+                s.target_type,
15
+                s.target_id,
16
+                s.evaluate_type,
17
+                ( sum( s.score ) / count( 1 ) ) AS score
18
+            FROM
19
+                ta_evaluation s
20
+            WHERE
21
+                s.target_type = #{targetType}
22
+                AND s.target_id = #{targetId}
23
+                AND s.evaluate_type = #{evaluateType}
24
+            GROUP BY
25
+                s.target_type,
26
+                s.target_id,
27
+                s.evaluate_type
28
+            ) a ON a.target_id = t.shop_id
29
+            SET t.${field} = score
30
+    </update>
10 31
 
11 32
     <select id="getPageListBy" resultType="com.yunzhi.shigongli.vo.ShopListVO">
12 33
         SELECT

+ 1
- 0
src/main/resources/mapper/TaTargetQuotaMapper.xml Bestand weergeven

@@ -41,6 +41,7 @@
41 41
                     AND s.target_id = t.target_id
42 42
                     AND s.type_id = #{typeId}
43 43
             </if>
44
+            WHERE t.`status` = 1
44 45
         ) w
45 46
         ORDER BY
46 47
             IFNULL( w.weight, 0 ) DESC,