张延森 3 년 전
부모
커밋
41c42437a4
46개의 변경된 파일982개의 추가작업 그리고 178개의 파일을 삭제
  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 파일 보기

14
 
14
 
15
     // 支付结果
15
     // 支付结果
16
     public final static Integer PAY_SUCCESS = 1;
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
     public final static String COMMISSION_TRAFFIC = "traffic";  // 引流抽成
20
     public final static String COMMISSION_TRAFFIC = "traffic";  // 引流抽成
34
 
34
 
35
     // 系统模块
35
     // 系统模块
36
     public final static String TARGET_ORDER = "order";                  // 订单
36
     public final static String TARGET_ORDER = "order";                  // 订单
37
+    public final static String TARGET_ORDER_SUB = "order_sub";          // 订单项目
37
     public final static String TARGET_HOTEL = "hotel";                  // 民宿
38
     public final static String TARGET_HOTEL = "hotel";                  // 民宿
38
     public final static String TARGET_SHOP = "shop";                    // 商铺
39
     public final static String TARGET_SHOP = "shop";                    // 商铺
39
     public final static String TARGET_SHOP_PACKAGE = "shop_package";    // 商铺套餐
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
     public final static String PACKAGE_NORMAL = "normal";           // 普通套餐
44
     public final static String PACKAGE_NORMAL = "normal";           // 普通套餐
47
     public final static String RECOMMEND_SHOP = "shop";     // 商铺
48
     public final static String RECOMMEND_SHOP = "shop";     // 商铺
48
     public final static String RECOMMEND_HOTEL = "hotel";   // 民宿
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
     public final static String CONF_HOTEL_RECOMMEND_VALID_DAYS = "hotel_recommend_valid_days";      // 民宿推广客户有效时间
57
     public final static String CONF_HOTEL_RECOMMEND_VALID_DAYS = "hotel_recommend_valid_days";      // 民宿推广客户有效时间
52
     public final static String CONF_SHOP_RECOMMEND_VALID_DAYS = "shop_recommend_valid_days";        // 商铺推广客户有效时间
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 파일 보기

8
 import com.github.binarywang.wxpay.service.WxPayService;
8
 import com.github.binarywang.wxpay.service.WxPayService;
9
 import com.yunzhi.shigongli.config.WeixinConfig;
9
 import com.yunzhi.shigongli.config.WeixinConfig;
10
 import com.yunzhi.shigongli.entity.TaOrder;
10
 import com.yunzhi.shigongli.entity.TaOrder;
11
+import com.yunzhi.shigongli.entity.TaOrderPay;
11
 import com.yunzhi.shigongli.entity.TaOrderSub;
12
 import com.yunzhi.shigongli.entity.TaOrderSub;
12
 import com.yunzhi.shigongli.entity.TaPerson;
13
 import com.yunzhi.shigongli.entity.TaPerson;
13
 import org.springframework.beans.factory.annotation.Autowired;
14
 import org.springframework.beans.factory.annotation.Autowired;
26
     /**
27
     /**
27
      * 下单
28
      * 下单
28
      * @param person
29
      * @param person
29
-     * @param taOrder
30
+     * @param orderPay
30
      * @return
31
      * @return
31
      * @throws Exception
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
         LocalDateTime now = LocalDateTime.now();
35
         LocalDateTime now = LocalDateTime.now();
35
         WxPayService payService = wxUtils.getPayService();
36
         WxPayService payService = wxUtils.getPayService();
36
 
37
 
37
         WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
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
         orderRequest.setOpenid(person.getOpenid());
42
         orderRequest.setOpenid(person.getOpenid());
42
         orderRequest.setNotifyUrl(config.getPay().getNotifyUrl());
43
         orderRequest.setNotifyUrl(config.getPay().getNotifyUrl());
43
         orderRequest.setSpbillCreateIp("218.91.253.51");  // 随便写个 IP
44
         orderRequest.setSpbillCreateIp("218.91.253.51");  // 随便写个 IP
49
         return payResult;
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
      * @return
81
      * @return
81
      * @throws Exception
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
         WxPayService payService = wxUtils.getPayService();
85
         WxPayService payService = wxUtils.getPayService();
85
         WxPayRefundRequest refundRequest = new WxPayRefundRequest();
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
         refundRequest.setNotifyUrl(config.getPay().getRefundNotifyUrl());
91
         refundRequest.setNotifyUrl(config.getPay().getRefundNotifyUrl());
91
         WxPayRefundResult result = payService.refund(refundRequest);
92
         WxPayRefundResult result = payService.refund(refundRequest);
92
 
93
 

+ 48
- 37
src/main/java/com/yunzhi/shigongli/controller/TaEvaluationController.java 파일 보기

5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.yunzhi.shigongli.common.BaseController;
6
 import com.yunzhi.shigongli.common.BaseController;
7
 import com.yunzhi.shigongli.common.ResponseBean;
7
 import com.yunzhi.shigongli.common.ResponseBean;
8
+import com.yunzhi.shigongli.entity.TaPerson;
9
+import com.yunzhi.shigongli.vo.EvaluateTarget;
8
 import io.swagger.annotations.Api;
10
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.ApiOperation;
11
 import io.swagger.annotations.ApiOperation;
10
 import io.swagger.annotations.ApiParam;
12
 import io.swagger.annotations.ApiParam;
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
 //     * 根据id删除对象
81
 //     * 根据id删除对象
108
 //    }
110
 //    }
109
 
111
 
110
     /**
112
     /**
111
-     * 根据id查询对象
113
+     * 用户评分
112
      * @param id  实体ID
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 파일 보기

5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.yunzhi.shigongli.common.BaseController;
6
 import com.yunzhi.shigongli.common.BaseController;
7
 import com.yunzhi.shigongli.common.ResponseBean;
7
 import com.yunzhi.shigongli.common.ResponseBean;
8
+import com.yunzhi.shigongli.entity.TaSave;
9
+import com.yunzhi.shigongli.service.ITaResourceService;
8
 import io.swagger.annotations.Api;
10
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.ApiOperation;
11
 import io.swagger.annotations.ApiOperation;
10
 import io.swagger.annotations.ApiParam;
12
 import io.swagger.annotations.ApiParam;
20
 import com.yunzhi.shigongli.entity.TaLike;
22
 import com.yunzhi.shigongli.entity.TaLike;
21
 import org.springframework.web.bind.annotation.RestController;
23
 import org.springframework.web.bind.annotation.RestController;
22
 
24
 
25
+import java.time.LocalDateTime;
26
+
23
 /**
27
 /**
24
  * <p>
28
  * <p>
25
     * 点赞表 前端控制器
29
     * 点赞表 前端控制器
39
     @Autowired
43
     @Autowired
40
     public ITaLikeService iTaLikeService;
44
     public ITaLikeService iTaLikeService;
41
 
45
 
46
+    @Autowired
47
+    public ITaResourceService iTaResourceService;
42
 
48
 
43
     /**
49
     /**
44
      * 分页查询列表
50
      * 分页查询列表
64
      * @param taLike 实体对象
70
      * @param taLike 实体对象
65
      * @return
71
      * @return
66
      */
72
      */
67
-    @RequestMapping(value="/wx/taLike",method= RequestMethod.POST)
73
+    @RequestMapping(value="/wx/{targetType}/like/{targetId}",method= RequestMethod.POST)
68
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
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
         if (iTaLikeService.save(taLike)){
83
         if (iTaLikeService.save(taLike)){
84
+            iTaResourceService.updateLike(taLike, 1);
72
             return ResponseBean.success(taLike);
85
             return ResponseBean.success(taLike);
73
         }else {
86
         }else {
74
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
87
             return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
79
      * 根据id删除对象
92
      * 根据id删除对象
80
      * @param id  实体ID
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
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
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
             return ResponseBean.success("success");
103
             return ResponseBean.success("success");
87
         }else {
104
         }else {
88
             return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
105
             return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);

+ 87
- 4
src/main/java/com/yunzhi/shigongli/controller/TaOrderController.java 파일 보기

5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
6
 import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
7
 import com.yunzhi.shigongli.common.BaseController;
7
 import com.yunzhi.shigongli.common.BaseController;
8
+import com.yunzhi.shigongli.common.Constants;
8
 import com.yunzhi.shigongli.common.ResponseBean;
9
 import com.yunzhi.shigongli.common.ResponseBean;
10
+import com.yunzhi.shigongli.entity.TaOrderSub;
9
 import com.yunzhi.shigongli.entity.TaPerson;
11
 import com.yunzhi.shigongli.entity.TaPerson;
12
+import com.yunzhi.shigongli.service.ITaOrderPayService;
13
+import com.yunzhi.shigongli.service.ITaOrderSubService;
10
 import com.yunzhi.shigongli.vo.OrderItem;
14
 import com.yunzhi.shigongli.vo.OrderItem;
11
 import io.swagger.annotations.Api;
15
 import io.swagger.annotations.Api;
12
 import io.swagger.annotations.ApiOperation;
16
 import io.swagger.annotations.ApiOperation;
24
 import org.springframework.web.bind.annotation.RestController;
28
 import org.springframework.web.bind.annotation.RestController;
25
 
29
 
26
 import javax.servlet.http.HttpServletRequest;
30
 import javax.servlet.http.HttpServletRequest;
31
+import java.util.List;
27
 
32
 
28
 /**
33
 /**
29
  * <p>
34
  * <p>
44
     @Autowired
49
     @Autowired
45
     public ITaOrderService iTaOrderService;
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
         }
91
         }
81
 
92
 
82
         TaPerson person = getCurrentPerson();
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
         return ResponseBean.success(result);
121
         return ResponseBean.success(result);
85
     }
122
     }
86
 
123
 
91
      * @return
128
      * @return
92
      * @throws Exception
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
     public ResponseBean taOrderDelete(@ApiParam("订单ID") @PathVariable String id,
133
     public ResponseBean taOrderDelete(@ApiParam("订单ID") @PathVariable String id,
97
                                    HttpServletRequest request) throws Exception{
134
                                    HttpServletRequest request) throws Exception{
98
         TaOrder taOrder = iTaOrderService.getById(id);
135
         TaOrder taOrder = iTaOrderService.getById(id);
99
-        if (null == taOrder) {
136
+        if (null == taOrder || Constants.STATUS_DELETED.equals(taOrder.getStatus())) {
100
             return ResponseBean.error("订单不存在", ResponseBean.ERROR_ILLEGAL_PARAMS);
137
             return ResponseBean.error("订单不存在", ResponseBean.ERROR_ILLEGAL_PARAMS);
101
         }
138
         }
102
 
139
 
109
         return ResponseBean.success("取消成功");
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
 //     * 根据id删除对象
196
 //     * 根据id删除对象
114
 //     * @param id  实体ID
197
 //     * @param id  实体ID

+ 57
- 2
src/main/java/com/yunzhi/shigongli/controller/TaOrderSubController.java 파일 보기

3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
6
 import com.yunzhi.shigongli.common.BaseController;
7
 import com.yunzhi.shigongli.common.BaseController;
7
 import com.yunzhi.shigongli.common.Constants;
8
 import com.yunzhi.shigongli.common.Constants;
8
 import com.yunzhi.shigongli.common.ResponseBean;
9
 import com.yunzhi.shigongli.common.ResponseBean;
9
 import com.yunzhi.shigongli.entity.TaOrder;
10
 import com.yunzhi.shigongli.entity.TaOrder;
10
 import com.yunzhi.shigongli.entity.TaPerson;
11
 import com.yunzhi.shigongli.entity.TaPerson;
12
+import com.yunzhi.shigongli.service.ITaOrderPayService;
11
 import com.yunzhi.shigongli.service.ITaOrderService;
13
 import com.yunzhi.shigongli.service.ITaOrderService;
14
+import com.yunzhi.shigongli.vo.MineOrder;
15
+import com.yunzhi.shigongli.vo.MineOrderSummary;
12
 import io.swagger.annotations.Api;
16
 import io.swagger.annotations.Api;
13
 import io.swagger.annotations.ApiOperation;
17
 import io.swagger.annotations.ApiOperation;
14
 import io.swagger.annotations.ApiParam;
18
 import io.swagger.annotations.ApiParam;
19
 import com.yunzhi.shigongli.service.ITaOrderSubService;
23
 import com.yunzhi.shigongli.service.ITaOrderSubService;
20
 import com.yunzhi.shigongli.entity.TaOrderSub;
24
 import com.yunzhi.shigongli.entity.TaOrderSub;
21
 
25
 
26
+import javax.servlet.http.HttpServletRequest;
27
+
22
 /**
28
 /**
23
  * <p>
29
  * <p>
24
     * 子订单表 前端控制器
30
     * 子订单表 前端控制器
41
     @Autowired
47
     @Autowired
42
     public ITaOrderService iTaOrderService;
48
     public ITaOrderService iTaOrderService;
43
 
49
 
50
+    @Autowired
51
+    public ITaOrderPayService iTaOrderPayService;
52
+
44
     /**
53
     /**
45
      * 分页查询列表
54
      * 分页查询列表
46
      * @param pageNum
55
      * @param pageNum
60
             return ResponseBean.success(result);
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
      * @param id
104
      * @param id
89
             return ResponseBean.error("您无权操作当前订单项目", ResponseBean.ERROR_ILLEGAL_PARAMS);
128
             return ResponseBean.error("您无权操作当前订单项目", ResponseBean.ERROR_ILLEGAL_PARAMS);
90
         }
129
         }
91
 
130
 
131
+        iTaOrderPayService.refundOrderSub(taPerson, taOrder, taOrderSub);
92
         iTaOrderSubService.refund(taPerson, taOrder, taOrderSub);
132
         iTaOrderSubService.refund(taPerson, taOrder, taOrderSub);
93
 
133
 
94
         return ResponseBean.success("操作完成");
134
         return ResponseBean.success("操作完成");
173
 //    }
213
 //    }
174
 
214
 
175
     @GetMapping("/wx/orderSub")
215
     @GetMapping("/wx/orderSub")
176
-    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = TaOrderSub.class)
216
+    @ApiOperation(value="订单列表", notes = "订单列表", httpMethod = "GET", response = MineOrder.class)
177
     public ResponseBean getWxMyOrders(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
217
     public ResponseBean getWxMyOrders(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
178
                                       @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
218
                                       @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
179
                                       @ApiParam("状态") @RequestParam(value ="status", required = false) Integer status) {
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 파일 보기

51
     public ITaResourceService taResourceService;
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
      * @param pageNum
62
      * @param pageNum
221
         taShop.setLikeNum(taResource.getLikeNum());
227
         taShop.setLikeNum(taResource.getLikeNum());
222
         taShop.setImageList(shopImagesService.getListBy(Constants.TARGET_SHOP, id));
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
         // 统计 PV, UV
238
         // 统计 PV, UV
225
         try {
239
         try {
226
             taResourceService.recordPerson(Constants.TARGET_SHOP, id, getCurrentPerson());
240
             taResourceService.recordPerson(Constants.TARGET_SHOP, id, getCurrentPerson());

+ 9
- 1
src/main/java/com/yunzhi/shigongli/controller/TaTouristController.java 파일 보기

6
 import com.yunzhi.shigongli.common.BaseController;
6
 import com.yunzhi.shigongli.common.BaseController;
7
 import com.yunzhi.shigongli.common.Constants;
7
 import com.yunzhi.shigongli.common.Constants;
8
 import com.yunzhi.shigongli.common.ResponseBean;
8
 import com.yunzhi.shigongli.common.ResponseBean;
9
+import com.yunzhi.shigongli.entity.TaLike;
9
 import com.yunzhi.shigongli.entity.TaResource;
10
 import com.yunzhi.shigongli.entity.TaResource;
10
 import com.yunzhi.shigongli.entity.TaSave;
11
 import com.yunzhi.shigongli.entity.TaSave;
11
 import com.yunzhi.shigongli.service.*;
12
 import com.yunzhi.shigongli.service.*;
56
     @Autowired
57
     @Autowired
57
     public ITaSaveService iTaSaveService;
58
     public ITaSaveService iTaSaveService;
58
 
59
 
60
+    @Autowired
61
+    public ITaLikeService iTaLikeService;
62
+
59
 
63
 
60
     /**
64
     /**
61
      * 分页查询列表
65
      * 分页查询列表
169
      * 根据id查询对象
173
      * 根据id查询对象
170
      * @param id  实体ID
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
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
177
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
174
     public ResponseBean getWxDetail(@ApiParam("对象ID") @PathVariable String id) throws Exception{
178
     public ResponseBean getWxDetail(@ApiParam("对象ID") @PathVariable String id) throws Exception{
175
         TaTourist taTourist = iTaTouristService.getById(id);
179
         TaTourist taTourist = iTaTouristService.getById(id);
188
         TaSave taSave = iTaSaveService.getByTarget(Constants.TARGET_TOURIST, id, getCurrentPerson().getPersonId());
192
         TaSave taSave = iTaSaveService.getByTarget(Constants.TARGET_TOURIST, id, getCurrentPerson().getPersonId());
189
         taTourist.setIsSaved(null == taSave ? 0 : 1);
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
         try {
199
         try {
192
             taResourceService.recordPerson(Constants.TARGET_TOURIST, id, getCurrentPerson());
200
             taResourceService.recordPerson(Constants.TARGET_TOURIST, id, getCurrentPerson());
193
         } catch (Exception e) {
201
         } catch (Exception e) {

+ 3
- 0
src/main/java/com/yunzhi/shigongli/controller/WxMaController.java 파일 보기

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

+ 6
- 3
src/main/java/com/yunzhi/shigongli/entity/TaOrderPay.java 파일 보기

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

+ 3
- 0
src/main/java/com/yunzhi/shigongli/entity/TaOrderSub.java 파일 보기

40
     @ApiModelProperty(value = "套餐ID")
40
     @ApiModelProperty(value = "套餐ID")
41
     private String packageId;
41
     private String packageId;
42
 
42
 
43
+    @ApiModelProperty(value = "子订单描述")
44
+    private String description;
45
+
43
     @ApiModelProperty(value = "总金额;单位分")
46
     @ApiModelProperty(value = "总金额;单位分")
44
     private Integer charges;
47
     private Integer charges;
45
 
48
 

+ 37
- 0
src/main/java/com/yunzhi/shigongli/entity/TaSequence.java 파일 보기

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 파일 보기

104
     @TableField(exist = false)
104
     @TableField(exist = false)
105
     private List<TaTargetType> typeList;
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 파일 보기

104
     @ApiModelProperty(value = "是否收藏")
104
     @ApiModelProperty(value = "是否收藏")
105
     @TableField(exist = false)
105
     @TableField(exist = false)
106
     private Integer isSaved;
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 파일 보기

1
 package com.yunzhi.shigongli.event;
1
 package com.yunzhi.shigongli.event;
2
 
2
 
3
-import com.yunzhi.shigongli.entity.TaOrder;
3
+import com.yunzhi.shigongli.entity.TaOrderPay;
4
 import org.springframework.context.ApplicationEvent;
4
 import org.springframework.context.ApplicationEvent;
5
 
5
 
6
 /**
6
 /**
8
  */
8
  */
9
 public class PaySuccessEvent extends ApplicationEvent {
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
         super(source);
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 파일 보기

1
 package com.yunzhi.shigongli.event;
1
 package com.yunzhi.shigongli.event;
2
 
2
 
3
 import com.yunzhi.shigongli.entity.TaOrder;
3
 import com.yunzhi.shigongli.entity.TaOrder;
4
+import com.yunzhi.shigongli.entity.TaOrderPay;
4
 import com.yunzhi.shigongli.entity.TaOrderSub;
5
 import com.yunzhi.shigongli.entity.TaOrderSub;
5
 import org.springframework.context.ApplicationEvent;
6
 import org.springframework.context.ApplicationEvent;
6
 
7
 
9
  */
10
  */
10
 public class RefundSuccessEvent extends ApplicationEvent {
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
         super(source);
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 파일 보기

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

+ 2
- 2
src/main/java/com/yunzhi/shigongli/event/listener/RefundSuccessEventListener.java 파일 보기

1
 package com.yunzhi.shigongli.event.listener;
1
 package com.yunzhi.shigongli.event.listener;
2
 
2
 
3
 import com.yunzhi.shigongli.entity.TaOrder;
3
 import com.yunzhi.shigongli.entity.TaOrder;
4
+import com.yunzhi.shigongli.entity.TaOrderPay;
4
 import com.yunzhi.shigongli.entity.TaOrderSub;
5
 import com.yunzhi.shigongli.entity.TaOrderSub;
5
 import com.yunzhi.shigongli.event.RefundSuccessEvent;
6
 import com.yunzhi.shigongli.event.RefundSuccessEvent;
6
 import com.yunzhi.shigongli.service.ITaPersonAccountService;
7
 import com.yunzhi.shigongli.service.ITaPersonAccountService;
15
 
16
 
16
     @Override
17
     @Override
17
     public void onApplicationEvent(RefundSuccessEvent evt) {
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 파일 보기

17
 public interface TaOrderMapper extends BaseMapper<TaOrder> {
17
 public interface TaOrderMapper extends BaseMapper<TaOrder> {
18
 
18
 
19
     int updateStatus(@Param("orderId") String orderId, @Param("status") Integer status);
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 파일 보기

17
 public interface TaOrderPayMapper extends BaseMapper<TaOrderPay> {
17
 public interface TaOrderPayMapper extends BaseMapper<TaOrderPay> {
18
 
18
 
19
     TaOrderPay getByOrder(@Param("orderId") String orderId, @Param("subOrderId") String subOrderId);
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 파일 보기

1
 package com.yunzhi.shigongli.mapper;
1
 package com.yunzhi.shigongli.mapper;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.yunzhi.shigongli.entity.TaOrderSub;
4
 import com.yunzhi.shigongli.entity.TaOrderSub;
4
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
+import com.yunzhi.shigongli.vo.MineOrder;
5
 import org.apache.ibatis.annotations.Mapper;
7
 import org.apache.ibatis.annotations.Mapper;
6
 import org.apache.ibatis.annotations.Param;
8
 import org.apache.ibatis.annotations.Param;
7
 
9
 
25
     int updateStatus(@Param("subOrderId") String subOrderId, @Param("status") Integer status);
27
     int updateStatus(@Param("subOrderId") String subOrderId, @Param("status") Integer status);
26
 
28
 
27
     int updateVerified(@Param("subOrderId") String subOrderId, @Param("isVerified") int isVerified);
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 파일 보기

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 파일 보기

21
     IPage<ShopListVO> getPageListBy(IPage<ShopListVO> pg, @Param("shopName") String shopName, @Param("phone") String phone);
21
     IPage<ShopListVO> getPageListBy(IPage<ShopListVO> pg, @Param("shopName") String shopName, @Param("phone") String phone);
22
 
22
 
23
     int updatePVNum(@Param("phone") String id);
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 파일 보기

1
 package com.yunzhi.shigongli.service;
1
 package com.yunzhi.shigongli.service;
2
 
2
 
3
 import com.yunzhi.shigongli.entity.TaEvaluation;
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
  */
15
  */
14
 public interface ITaEvaluationService extends IBaseService<TaEvaluation> {
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 파일 보기

13
  */
13
  */
14
 public interface ITaLikeService extends IBaseService<TaLike> {
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 파일 보기

2
 
2
 
3
 import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
3
 import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
4
 import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
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
 import com.yunzhi.shigongli.entity.TaOrderPay;
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
     void notifyOrder(WxPayOrderNotifyResult notifyResult) throws Exception;
22
     void notifyOrder(WxPayOrderNotifyResult notifyResult) throws Exception;
19
 
23
 
20
     void refundNotifyOrder(WxPayRefundNotifyResult result) throws Exception;
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 파일 보기

17
  */
17
  */
18
 public interface ITaOrderService extends IBaseService<TaOrder> {
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
     void cancelOrder(TaOrder taOrder, TaPerson taPerson) throws Exception;
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 파일 보기

1
 package com.yunzhi.shigongli.service;
1
 package com.yunzhi.shigongli.service;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.yunzhi.shigongli.entity.TaOrder;
4
 import com.yunzhi.shigongli.entity.TaOrder;
4
 import com.yunzhi.shigongli.entity.TaOrderSub;
5
 import com.yunzhi.shigongli.entity.TaOrderSub;
5
 
6
 
6
 import com.yunzhi.shigongli.entity.TaPerson;
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
  * <p>
14
  * <p>
18
     void refund(TaPerson person, TaOrder taOrder, TaOrderSub taOrderSub) throws Exception;
23
     void refund(TaPerson person, TaOrder taOrder, TaOrderSub taOrderSub) throws Exception;
19
 
24
 
20
     void validation(TaPerson taPerson, TaOrder taOrder, TaOrderSub taOrderSub) throws Exception;
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 파일 보기

1
 package com.yunzhi.shigongli.service;
1
 package com.yunzhi.shigongli.service;
2
 
2
 
3
 import com.yunzhi.shigongli.entity.TaOrder;
3
 import com.yunzhi.shigongli.entity.TaOrder;
4
+import com.yunzhi.shigongli.entity.TaOrderPay;
4
 import com.yunzhi.shigongli.entity.TaOrderSub;
5
 import com.yunzhi.shigongli.entity.TaOrderSub;
5
 import com.yunzhi.shigongli.entity.TaPersonAccount;
6
 import com.yunzhi.shigongli.entity.TaPersonAccount;
6
 
7
 
15
  */
16
  */
16
 public interface ITaPersonAccountService extends IBaseService<TaPersonAccount> {
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 파일 보기

1
 package com.yunzhi.shigongli.service;
1
 package com.yunzhi.shigongli.service;
2
 
2
 
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.shigongli.entity.TaLike;
4
 import com.yunzhi.shigongli.entity.TaPerson;
5
 import com.yunzhi.shigongli.entity.TaPerson;
5
 import com.yunzhi.shigongli.entity.TaResource;
6
 import com.yunzhi.shigongli.entity.TaResource;
6
 import com.yunzhi.shigongli.entity.TaSave;
7
 import com.yunzhi.shigongli.entity.TaSave;
26
     void updateSave(TaSave taSave, int num);
27
     void updateSave(TaSave taSave, int num);
27
 
28
 
28
     IPage<ResourceListVO> getWxPagedBy(IPage<ResourceListVO> pg, TaPerson taPerso, String location, String typeId);
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 파일 보기

1
 package com.yunzhi.shigongli.service.impl;
1
 package com.yunzhi.shigongli.service.impl;
2
 
2
 
3
+import com.yunzhi.shigongli.common.Constants;
3
 import com.yunzhi.shigongli.entity.TaEvaluation;
4
 import com.yunzhi.shigongli.entity.TaEvaluation;
5
+import com.yunzhi.shigongli.entity.TaPerson;
6
+import com.yunzhi.shigongli.entity.TaShop;
4
 import com.yunzhi.shigongli.mapper.TaEvaluationMapper;
7
 import com.yunzhi.shigongli.mapper.TaEvaluationMapper;
8
+import com.yunzhi.shigongli.mapper.TaShopMapper;
5
 import com.yunzhi.shigongli.service.ITaEvaluationService;
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
 import org.springframework.stereotype.Service;
13
 import org.springframework.stereotype.Service;
14
+import org.springframework.transaction.annotation.Transactional;
15
+
16
+import java.time.LocalDateTime;
8
 
17
 
9
 /**
18
 /**
10
  * <p>
19
  * <p>
17
 @Service
26
 @Service
18
 public class TaEvaluationServiceImpl extends BaseServiceImpl<TaEvaluationMapper, TaEvaluation> implements ITaEvaluationService {
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 파일 보기

1
 package com.yunzhi.shigongli.service.impl;
1
 package com.yunzhi.shigongli.service.impl;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
3
 import com.yunzhi.shigongli.entity.TaLike;
4
 import com.yunzhi.shigongli.entity.TaLike;
4
 import com.yunzhi.shigongli.mapper.TaLikeMapper;
5
 import com.yunzhi.shigongli.mapper.TaLikeMapper;
5
 import com.yunzhi.shigongli.service.ITaLikeService;
6
 import com.yunzhi.shigongli.service.ITaLikeService;
17
 @Service
18
 @Service
18
 public class TaLikeServiceImpl extends BaseServiceImpl<TaLikeMapper, TaLike> implements ITaLikeService {
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 파일 보기

2
 
2
 
3
 import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
3
 import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
4
 import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
4
 import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
5
+import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
5
 import com.github.binarywang.wxpay.constant.WxPayConstants;
6
 import com.github.binarywang.wxpay.constant.WxPayConstants;
6
 import com.yunzhi.shigongli.common.Constants;
7
 import com.yunzhi.shigongli.common.Constants;
7
 import com.yunzhi.shigongli.common.DateUtils;
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
 import com.yunzhi.shigongli.event.PaySuccessEvent;
12
 import com.yunzhi.shigongli.event.PaySuccessEvent;
11
 import com.yunzhi.shigongli.event.RefundSuccessEvent;
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
 import com.yunzhi.shigongli.service.ITaOrderPayService;
15
 import com.yunzhi.shigongli.service.ITaOrderPayService;
16
 
16
 
17
 import org.springframework.beans.factory.annotation.Autowired;
17
 import org.springframework.beans.factory.annotation.Autowired;
18
 import org.springframework.context.ApplicationEventPublisher;
18
 import org.springframework.context.ApplicationEventPublisher;
19
 import org.springframework.stereotype.Service;
19
 import org.springframework.stereotype.Service;
20
+import org.springframework.transaction.annotation.Transactional;
20
 
21
 
21
 /**
22
 /**
22
  * <p>
23
  * <p>
29
 @Service
30
 @Service
30
 public class TaOrderPayServiceImpl extends BaseServiceImpl<TaOrderPayMapper, TaOrderPay> implements ITaOrderPayService {
31
 public class TaOrderPayServiceImpl extends BaseServiceImpl<TaOrderPayMapper, TaOrderPay> implements ITaOrderPayService {
31
 
32
 
33
+    @Autowired
34
+    WxPayUtils wxPayUtils;
35
+
32
     @Autowired
36
     @Autowired
33
     TaOrderPayMapper orderPayMapper;
37
     TaOrderPayMapper orderPayMapper;
34
 
38
 
41
     @Autowired
45
     @Autowired
42
     ApplicationEventPublisher eventPublisher;
46
     ApplicationEventPublisher eventPublisher;
43
 
47
 
48
+    @Autowired
49
+    TaSequenceMapper taSequenceMapper;
50
+
51
+    @Autowired
52
+    TaShopPackageMapper shopPackageMapper;
53
+
44
     /**
54
     /**
45
      * 支付回调
55
      * 支付回调
46
      * @param notifyResult
56
      * @param notifyResult
48
      */
58
      */
49
     @Override
59
     @Override
50
     public void notifyOrder(WxPayOrderNotifyResult notifyResult) throws Exception {
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
         boolean isSuccess = WxPayConstants.ResultCode.SUCCESS.equals(notifyResult.getResultCode());
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
         orderPay.setPayDate(DateUtils.from(notifyResult.getTimeEnd(), "yyyyMMddHHmmss"));
67
         orderPay.setPayDate(DateUtils.from(notifyResult.getTimeEnd(), "yyyyMMddHHmmss"));
59
         orderPay.setStatus(isSuccess ? Constants.PAY_SUCCESS : Constants.PAY_FAIL);
68
         orderPay.setStatus(isSuccess ? Constants.PAY_SUCCESS : Constants.PAY_FAIL);
60
         orderPay.setMessage(isSuccess ? null : notifyResult.getErrCodeDes());
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
         if (isSuccess) {
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
             eventPublisher.publishEvent(evt);
83
             eventPublisher.publishEvent(evt);
80
         }
84
         }
81
     }
85
     }
87
             return;
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
             return;
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
         orderPay.setPayDate(DateUtils.from(reqInfo.getSuccessTime(), "yyyyMMddHHmmss"));
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
         } else {
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
         orderPayMapper.insert(orderPay);
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 파일 보기

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

+ 33
- 2
src/main/java/com/yunzhi/shigongli/service/impl/TaOrderSubServiceImpl.java 파일 보기

1
 package com.yunzhi.shigongli.service.impl;
1
 package com.yunzhi.shigongli.service.impl;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3
 import com.yunzhi.shigongli.common.Constants;
4
 import com.yunzhi.shigongli.common.Constants;
4
 import com.yunzhi.shigongli.common.WxPayUtils;
5
 import com.yunzhi.shigongli.common.WxPayUtils;
5
 import com.yunzhi.shigongli.entity.*;
6
 import com.yunzhi.shigongli.entity.*;
6
 import com.yunzhi.shigongli.mapper.*;
7
 import com.yunzhi.shigongli.mapper.*;
7
 import com.yunzhi.shigongli.service.ITaOrderSubService;
8
 import com.yunzhi.shigongli.service.ITaOrderSubService;
8
 
9
 
10
+import com.yunzhi.shigongli.vo.MineOrder;
11
+import com.yunzhi.shigongli.vo.MineOrderSummary;
9
 import org.omg.PortableInterceptor.ACTIVE;
12
 import org.omg.PortableInterceptor.ACTIVE;
10
 import org.springframework.beans.factory.annotation.Autowired;
13
 import org.springframework.beans.factory.annotation.Autowired;
11
 import org.springframework.stereotype.Service;
14
 import org.springframework.stereotype.Service;
28
     @Autowired
31
     @Autowired
29
     WxPayUtils wxPayUtils;
32
     WxPayUtils wxPayUtils;
30
 
33
 
34
+    @Autowired
35
+    TaOrderMapper taOrderMapper;
36
+
31
     @Autowired
37
     @Autowired
32
     TaOrderSubMapper taOrderSubMapper;
38
     TaOrderSubMapper taOrderSubMapper;
33
 
39
 
59
     @Transactional(rollbackFor = Exception.class)
65
     @Transactional(rollbackFor = Exception.class)
60
     @Override
66
     @Override
61
     public void refund(TaPerson person, TaOrder taOrder, TaOrderSub taOrderSub) throws Exception {
67
     public void refund(TaPerson person, TaOrder taOrder, TaOrderSub taOrderSub) throws Exception {
62
-        wxPayUtils.refund(taOrder, taOrderSub);
63
-
64
         // 更新表
68
         // 更新表
65
         taOrderSubMapper.updateStatus(taOrderSub.getSubOrderId(), Constants.ORDER_REFUND);
69
         taOrderSubMapper.updateStatus(taOrderSub.getSubOrderId(), Constants.ORDER_REFUND);
66
 
70
 
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
      * @param shopId
136
      * @param shopId

+ 20
- 12
src/main/java/com/yunzhi/shigongli/service/impl/TaPersonAccountServiceImpl.java 파일 보기

1
 package com.yunzhi.shigongli.service.impl;
1
 package com.yunzhi.shigongli.service.impl;
2
 
2
 
3
 import com.yunzhi.shigongli.common.Constants;
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
 import com.yunzhi.shigongli.mapper.TaOrderSubMapper;
7
 import com.yunzhi.shigongli.mapper.TaOrderSubMapper;
9
 import com.yunzhi.shigongli.mapper.TaPersonAccountLogMapper;
8
 import com.yunzhi.shigongli.mapper.TaPersonAccountLogMapper;
10
 import com.yunzhi.shigongli.mapper.TaPersonAccountMapper;
9
 import com.yunzhi.shigongli.mapper.TaPersonAccountMapper;
30
 @Service
29
 @Service
31
 public class TaPersonAccountServiceImpl extends BaseServiceImpl<TaPersonAccountMapper, TaPersonAccount> implements ITaPersonAccountService {
30
 public class TaPersonAccountServiceImpl extends BaseServiceImpl<TaPersonAccountMapper, TaPersonAccount> implements ITaPersonAccountService {
32
 
31
 
32
+    @Autowired
33
+    TaOrderMapper taOrderMapper;
34
+
33
     @Autowired
35
     @Autowired
34
     TaOrderSubMapper orderSubMapper;
36
     TaOrderSubMapper orderSubMapper;
35
 
37
 
45
     @Async
47
     @Async
46
     @Transactional(rollbackFor = Exception.class)
48
     @Transactional(rollbackFor = Exception.class)
47
     @Override
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
         Integer cashback = 0;
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
         TaPersonAccount personAccount = personAccountMapper.getByPerson(taOrder.getPersonId());
64
         TaPersonAccount personAccount = personAccountMapper.getByPerson(taOrder.getPersonId());
62
         accountLog.setAmountType(Constants.ACCOUNT_CASHBACK);
70
         accountLog.setAmountType(Constants.ACCOUNT_CASHBACK);
63
         accountLog.setAmount(cashback);
71
         accountLog.setAmount(cashback);
64
         accountLog.setSignType(Constants.ACCOUNT_INCOME);
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
         accountLogMapper.insert(accountLog);
76
         accountLogMapper.insert(accountLog);
69
     }
77
     }
70
 
78
 

+ 12
- 0
src/main/java/com/yunzhi/shigongli/service/impl/TaResourceServiceImpl.java 파일 보기

101
 
101
 
102
         return baseMapper.getWxPagedBy(pg, taPerson.getPersonId(), location, typeId);
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 파일 보기

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 파일 보기

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 파일 보기

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 파일 보기

8
         WHERE
8
         WHERE
9
             order_id = #{orderId}
9
             order_id = #{orderId}
10
     </update>
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
 </mapper>
20
 </mapper>

+ 24
- 0
src/main/resources/mapper/TaOrderPayMapper.xml 파일 보기

17
           </if>
17
           </if>
18
             AND is_refund = 0
18
             AND is_refund = 0
19
     </select>
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
 </mapper>
44
 </mapper>

+ 44
- 0
src/main/resources/mapper/TaOrderSubMapper.xml 파일 보기

27
             order_id = #{orderId}
27
             order_id = #{orderId}
28
             AND `status` &gt; -1
28
             AND `status` &gt; -1
29
     </select>
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
 </mapper>
74
 </mapper>

+ 5
- 0
src/main/resources/mapper/TaSequenceMapper.xml 파일 보기

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 파일 보기

7
         WHERE
7
         WHERE
8
             t.shop_id = #{id}
8
             t.shop_id = #{id}
9
     </update>
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
     <select id="getPageListBy" resultType="com.yunzhi.shigongli.vo.ShopListVO">
32
     <select id="getPageListBy" resultType="com.yunzhi.shigongli.vo.ShopListVO">
12
         SELECT
33
         SELECT

+ 1
- 0
src/main/resources/mapper/TaTargetQuotaMapper.xml 파일 보기

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