张延森 il y a 3 ans
Parent
révision
e81925ba09

+ 6
- 1
deploy/bootstrap Voir le fichier

@@ -4,4 +4,9 @@
4 4
 
5 5
 appVer="3.0.4"
6 6
 
7
-java -jar ./shigongli-${appVer}.jar
7
+baseDIR=`pwd`
8
+
9
+export JAVA_HOME=${baseDIR}/jdk1.8.0_281
10
+export PATH=${JAVA_HOME}/bin:${PATH}
11
+
12
+${JAVA_HOME}/bin/java -jar ./shigongli-${appVer}.jar

+ 7
- 0
deploy/bootstrap - 副本 Voir le fichier

@@ -0,0 +1,7 @@
1
+#!/bin/bash
2
+#
3
+#
4
+
5
+appVer="3.0.4"
6
+
7
+java -jar ./shigongli-${appVer}.jar

+ 1
- 1
pom.xml Voir le fichier

@@ -10,7 +10,7 @@
10 10
 	</parent>
11 11
 	<groupId>com.yunzhi</groupId>
12 12
 	<artifactId>shigongli</artifactId>
13
-	<version>3.0.4</version>
13
+	<version>3.0.5</version>
14 14
 	<name>shigongli</name>
15 15
 	<description>Shi Gong Li</description>
16 16
 

+ 102
- 102
src/main/java/com/yunzhi/shigongli/common/WxPayUtils.java Voir le fichier

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

+ 22
- 19
src/main/java/com/yunzhi/shigongli/config/CorsConfig.java Voir le fichier

@@ -4,22 +4,25 @@ import org.springframework.boot.SpringBootConfiguration;
4 4
 import org.springframework.web.servlet.config.annotation.CorsRegistry;
5 5
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
6 6
 
7
-@SpringBootConfiguration
8
-public class CorsConfig implements WebMvcConfigurer {
9
-    @Override
10
-    public void addCorsMappings(CorsRegistry registry) {
11
-        //添加映射路径
12
-        registry.addMapping("/**")
13
-                //是否发送Cookie
14
-                .allowCredentials(true)
15
-                //设置放行哪些原始域
16
-                .allowedOrigins("*")
17
-                //放行哪些请求方式
18
-                .allowedMethods("GET", "POST", "PUT", "DELETE")
19
-                //.allowedMethods("*") //或者放行全部
20
-                //放行哪些原始请求头部信息
21
-                .allowedHeaders("*")
22
-                //暴露哪些原始请求头部信息
23
-                .exposedHeaders("X-Authorization-JWT");
24
-    }
25
-}
7
+//@SpringBootConfiguration
8
+//public class CorsConfig implements WebMvcConfigurer {
9
+//    @Override
10
+//    public void addCorsMappings(CorsRegistry registry) {
11
+//        //添加映射路径
12
+//        registry.addMapping("/**")
13
+//                //是否发送Cookie
14
+//                .allowCredentials(true)
15
+//                //设置放行哪些原始域
16
+//                .allowedOrigins("*")
17
+//                //放行哪些请求方式
18
+//                .allowedMethods("GET", "POST", "PUT", "DELETE")
19
+//                //.allowedMethods("*") //或者放行全部
20
+//                //放行哪些原始请求头部信息
21
+//                .allowedHeaders("*")
22
+//                //暴露哪些原始请求头部信息
23
+//                .exposedHeaders("X-Authorization-JWT");
24
+//    }
25
+//}
26
+
27
+
28
+public class CorsConfig {}

+ 18
- 7
src/main/java/com/yunzhi/shigongli/controller/TaNoteController.java Voir le fichier

@@ -5,12 +5,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5 5
 import com.yunzhi.shigongli.common.BaseController;
6 6
 import com.yunzhi.shigongli.common.Constants;
7 7
 import com.yunzhi.shigongli.common.ResponseBean;
8
-import com.yunzhi.shigongli.entity.TaImage;
9
-import com.yunzhi.shigongli.entity.TaNote;
10
-import com.yunzhi.shigongli.entity.TaNoteResource;
11
-import com.yunzhi.shigongli.service.ITaImageService;
12
-import com.yunzhi.shigongli.service.ITaNoteResourceService;
13
-import com.yunzhi.shigongli.service.ITaNoteService;
8
+import com.yunzhi.shigongli.entity.*;
9
+import com.yunzhi.shigongli.service.*;
14 10
 import com.yunzhi.shigongli.vo.NoteVO;
15 11
 import io.swagger.annotations.Api;
16 12
 import io.swagger.annotations.ApiOperation;
@@ -49,6 +45,12 @@ public class TaNoteController extends BaseController {
49 45
     @Autowired
50 46
     public ITaNoteResourceService iTaNoteResourceService;
51 47
 
48
+    @Autowired
49
+    public ITaSaveService iTaSaveService;
50
+
51
+    @Autowired
52
+    public ITaLikeService iTaLikeService;
53
+
52 54
     /**
53 55
      * 分页查询列表
54 56
      * @param pageNum
@@ -250,6 +252,7 @@ public class TaNoteController extends BaseController {
250 252
     @RequestMapping(value="/wx/note/{id}",method= RequestMethod.GET)
251 253
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
252 254
     public ResponseBean getWxDetail(@ApiParam("对象ID") @PathVariable String id) throws Exception {
255
+        String personId = getCurrentPerson().getPersonId();
253 256
         TaNote taNote = iTaNoteService.getById(id);
254 257
         if (null == taNote || Constants.STATUS_DELETED == taNote.getStatus()) {
255 258
             return ResponseBean.error("没有找到更新内容", ResponseBean.ERROR_UNAVAILABLE);
@@ -258,9 +261,17 @@ public class TaNoteController extends BaseController {
258 261
         NoteVO noteVO = new NoteVO();
259 262
         BeanUtils.copyProperties(taNote, noteVO);
260 263
 
264
+        TaSave taSave = iTaSaveService.getByTarget(Constants.TARGET_NOTE, id, personId);
265
+        if (null != taSave) {
266
+            noteVO.setIsSaved(1);
267
+        }
268
+        TaLike taLike = iTaLikeService.getByTarget(Constants.TARGET_NOTE, id, personId);
269
+        if (null != taLike) {
270
+            noteVO.setIsLike(1);
271
+        }
261 272
 
262 273
         noteVO.setImageList(iTaImageService.getListBy(Constants.TARGET_NOTE, id));
263
-        noteVO.setWxResourceList(iTaNoteResourceService.getResourceListBy(id, getCurrentPerson().getPersonId()));
274
+        noteVO.setWxResourceList(iTaNoteResourceService.getResourceListBy(id, personId));
264 275
 
265 276
         return ResponseBean.success(noteVO);
266 277
     }

+ 7
- 0
src/main/java/com/yunzhi/shigongli/entity/TaNote.java Voir le fichier

@@ -1,6 +1,7 @@
1 1
 package com.yunzhi.shigongli.entity;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
4 5
 import com.baomidou.mybatisplus.annotation.TableId;
5 6
 import io.swagger.annotations.ApiModel;
6 7
 import io.swagger.annotations.ApiModelProperty;
@@ -61,5 +62,11 @@ public class TaNote implements Serializable {
61 62
     @ApiModelProperty(value = "创建时间")
62 63
     private LocalDateTime createDate;
63 64
 
65
+    @TableField(exist = false)
66
+    @ApiModelProperty(value = "是否收藏")
67
+    Integer isSaved;
64 68
 
69
+    @TableField(exist = false)
70
+    @ApiModelProperty(value = "距离")
71
+    Float distance;
65 72
 }

+ 9
- 1
src/main/java/com/yunzhi/shigongli/vo/NoteVO.java Voir le fichier

@@ -2,7 +2,6 @@ package com.yunzhi.shigongli.vo;
2 2
 
3 3
 import com.yunzhi.shigongli.entity.TaImage;
4 4
 import com.yunzhi.shigongli.entity.TaNoteResource;
5
-import com.yunzhi.shigongli.entity.TaResource;
6 5
 import io.swagger.annotations.ApiModel;
7 6
 import io.swagger.annotations.ApiModelProperty;
8 7
 import lombok.Data;
@@ -55,4 +54,13 @@ public class NoteVO {
55 54
 
56 55
     @ApiModelProperty(value = "笔记资源-微信端")
57 56
     private List<ResourceListVO> wxResourceList;
57
+
58
+    @ApiModelProperty(value = "是否收藏")
59
+    private Integer isSaved;
60
+
61
+    @ApiModelProperty(value = "是否爆赞")
62
+    private Integer isLike;
63
+
64
+    @ApiModelProperty(value = "距离")
65
+    private Float distance;
58 66
 }

+ 15
- 20
src/main/resources/mapper/TaNoteMapper.xml Voir le fichier

@@ -21,29 +21,24 @@
21 21
     </select>
22 22
     <select id="getWxPageBy" resultType="com.yunzhi.shigongli.entity.TaNote">
23 23
         SELECT
24
-            t.*
24
+            t.*,
25
+            IFNULL(n.saved_num, 0) as is_saved
25 26
         FROM
26 27
             ta_note t
27
-                LEFT JOIN (
28
+            LEFT JOIN (
28 29
                 SELECT
29
-                    *
30
+                    a.target_type,
31
+                    a.target_id,
32
+                    count( 1 ) AS saved_num
30 33
                 FROM
31
-                    (
32
-                        SELECT
33
-                            c.*,
34
-                            fn_distance ( #{location}, concat( a.lng, ',', a.lat ) ) AS distance
35
-                        FROM
36
-                            ta_resource a
37
-                                INNER JOIN ta_save b ON b.target_type = a.target_type
38
-                                AND b.target_id = a.target_id
39
-                                INNER JOIN ta_note_resource c ON c.resource_no = a.resource_no
40
-                        WHERE
41
-                            b.person_id = #{personId}
42
-                    ) d
43
-                ORDER BY
44
-                    d.distance DESC
45
-                    LIMIT 1
46
-            ) s ON s.note_id = t.note_id
34
+                    ta_save a
35
+                WHERE
36
+                    a.person_id = #{personId}
37
+                    AND a.target_type = 'note'
38
+                GROUP BY
39
+                    a.target_type,
40
+                    a.target_id
41
+                ) n ON n.target_id = t.note_id
47 42
         WHERE
48 43
             t.`status` > - 1
49 44
         <if test="summary != null and summary != ''">
@@ -51,7 +46,7 @@
51 46
         </if>
52 47
         ORDER BY
53 48
             IF
54
-                ( s.note_id IS NULL, 0, 1 ) DESC,
49
+                ( t.note_id IS NULL, 0, 1 ) DESC,
55 50
             t.create_date DESC
56 51
     </select>
57 52
 </mapper>