张延森 vor 3 Jahren
Ursprung
Commit
057e4ef255

+ 13
- 0
src/main/java/com/yunzhi/shigongli/controller/TaShopPackageController.java Datei anzeigen

@@ -8,6 +8,7 @@ import com.yunzhi.shigongli.common.Constants;
8 8
 import com.yunzhi.shigongli.common.ResponseBean;
9 9
 import com.yunzhi.shigongli.entity.TaExtendContent;
10 10
 import com.yunzhi.shigongli.entity.TaShopPackageSetting;
11
+import com.yunzhi.shigongli.vo.ShopPackageRecommend;
11 12
 import com.yunzhi.shigongli.vo.ShopPackageVO;
12 13
 import io.swagger.annotations.Api;
13 14
 import io.swagger.annotations.ApiOperation;
@@ -143,5 +144,17 @@ public class TaShopPackageController extends BaseController {
143 144
     }
144 145
 
145 146
 
147
+    /**
148
+     * 商铺套餐列表
149
+     * @param id  实体ID
150
+     */
151
+    @RequestMapping(value="/wx/package/recommend",method= RequestMethod.GET)
152
+    @ApiOperation(value="推荐套餐列表", notes = "推荐套餐列表", httpMethod = "GET", response = ResponseBean.class)
153
+    public ResponseBean getWxRecommendList(@ApiParam("当前定位") @RequestParam(value ="location") String location) throws Exception{
154
+        List<ShopPackageRecommend> packageList = iTaShopPackageService.getWxRecommendList(location, getCurrentPerson());
155
+
156
+        return ResponseBean.success(packageList);
157
+    }
158
+
146 159
 
147 160
 }

+ 44
- 13
src/main/java/com/yunzhi/shigongli/controller/TaTouristController.java Datei anzeigen

@@ -7,9 +7,8 @@ import com.yunzhi.shigongli.common.BaseController;
7 7
 import com.yunzhi.shigongli.common.Constants;
8 8
 import com.yunzhi.shigongli.common.ResponseBean;
9 9
 import com.yunzhi.shigongli.entity.TaResource;
10
-import com.yunzhi.shigongli.service.ITaImageService;
11
-import com.yunzhi.shigongli.service.ITaResourceService;
12
-import com.yunzhi.shigongli.service.ITaTargetTypeService;
10
+import com.yunzhi.shigongli.entity.TaSave;
11
+import com.yunzhi.shigongli.service.*;
13 12
 import com.yunzhi.shigongli.vo.ResourceFieldVO;
14 13
 import io.swagger.annotations.Api;
15 14
 import io.swagger.annotations.ApiOperation;
@@ -23,7 +22,6 @@ import org.springframework.web.bind.annotation.RequestBody;
23 22
 import org.springframework.web.bind.annotation.RequestMapping;
24 23
 import org.springframework.web.bind.annotation.RequestMethod;
25 24
 import org.springframework.web.bind.annotation.RequestParam;
26
-import com.yunzhi.shigongli.service.ITaTouristService;
27 25
 import com.yunzhi.shigongli.entity.TaTourist;
28 26
 import org.springframework.web.bind.annotation.RestController;
29 27
 
@@ -55,6 +53,9 @@ public class TaTouristController extends BaseController {
55 53
     @Autowired
56 54
     public ITaTargetTypeService taTargetTypeService;
57 55
 
56
+    @Autowired
57
+    public ITaSaveService iTaSaveService;
58
+
58 59
 
59 60
     /**
60 61
      * 分页查询列表
@@ -139,10 +140,38 @@ public class TaTouristController extends BaseController {
139 140
      * 根据id查询对象
140 141
      * @param id  实体ID
141 142
      */
142
-    @RequestMapping(value="/{plat}/taTourist/{id}",method= RequestMethod.GET)
143
+    @RequestMapping(value="/admin/taTourist/{id}",method= RequestMethod.GET)
144
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
145
+    public ResponseBean taTouristGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
146
+        TaTourist taTourist = iTaTouristService.getById(id);
147
+        if (Constants.STATUS_DELETED.equals(taTourist.getStatus())) {
148
+            return ResponseBean.error("景点不存在", ResponseBean.ERROR_ILLEGAL_PARAMS);
149
+        }
150
+
151
+        TaResource taResource = taResourceService.getByTarget(Constants.TARGET_TOURIST, id);
152
+        taTourist.setPvNum(taResource.getPvNum());
153
+        taTourist.setUvNum(taResource.getUvNum());
154
+        taTourist.setLikeNum(taResource.getLikeNum());
155
+        taTourist.setImageList(iTaImageService.getListBy(Constants.TARGET_TOURIST, id));
156
+        taTourist.setTypeList(taTargetTypeService.getListBy(Constants.TARGET_TOURIST, id));
157
+
158
+        try {
159
+            taResourceService.recordPerson(Constants.TARGET_TOURIST, id, getCurrentPerson());
160
+        } catch (Exception e) {
161
+            e.printStackTrace();
162
+        }
163
+
164
+        return ResponseBean.success(taTourist);
165
+    }
166
+
167
+
168
+    /**
169
+     * 根据id查询对象
170
+     * @param id  实体ID
171
+     */
172
+    @RequestMapping(value="/admin/tourist/{id}",method= RequestMethod.GET)
143 173
     @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
144
-    public ResponseBean taTouristGet(@ApiParam(value = "客户端", allowableValues = "wx,admin") @PathVariable String plat,
145
-                                     @ApiParam("对象ID") @PathVariable String id) throws Exception{
174
+    public ResponseBean getWxDetail(@ApiParam("对象ID") @PathVariable String id) throws Exception{
146 175
         TaTourist taTourist = iTaTouristService.getById(id);
147 176
         if (Constants.STATUS_DELETED.equals(taTourist.getStatus())) {
148 177
             return ResponseBean.error("景点不存在", ResponseBean.ERROR_ILLEGAL_PARAMS);
@@ -155,12 +184,14 @@ public class TaTouristController extends BaseController {
155 184
         taTourist.setImageList(iTaImageService.getListBy(Constants.TARGET_TOURIST, id));
156 185
         taTourist.setTypeList(taTargetTypeService.getListBy(Constants.TARGET_TOURIST, id));
157 186
 
158
-        if ("wx".equals(plat)) {
159
-            try {
160
-                taResourceService.recordPerson(Constants.TARGET_TOURIST, id, getCurrentPerson());
161
-            } catch (Exception e) {
162
-                e.printStackTrace();
163
-            }
187
+        // 是否收藏
188
+        TaSave taSave = iTaSaveService.getByTarget(Constants.TARGET_TOURIST, id, getCurrentPerson().getPersonId());
189
+        taTourist.setIsSaved(null == taSave ? 0 : 1);
190
+
191
+        try {
192
+            taResourceService.recordPerson(Constants.TARGET_TOURIST, id, getCurrentPerson());
193
+        } catch (Exception e) {
194
+            e.printStackTrace();
164 195
         }
165 196
 
166 197
         return ResponseBean.success(taTourist);

+ 19
- 9
src/main/java/com/yunzhi/shigongli/controller/TdCityController.java Datei anzeigen

@@ -112,13 +112,23 @@ public class TdCityController extends BaseController {
112 112
 //        }
113 113
 //    }
114 114
 //
115
-//    /**
116
-//     * 根据id查询对象
117
-//     * @param id  实体ID
118
-//     */
119
-//    @RequestMapping(value="/tdCity/{id}",method= RequestMethod.GET)
120
-//    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
121
-//    public ResponseBean tdCityGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
122
-//        return ResponseBean.success(iTdCityService.getById(id));
123
-//    }
115
+    /**
116
+     * 根据id查询对象
117
+     * @param id  实体ID
118
+     */
119
+    @RequestMapping(value="/wx/city/{id}",method= RequestMethod.GET)
120
+    @ApiOperation(value="获取地域信息", notes = "获取地域信息", httpMethod = "GET", response = ResponseBean.class)
121
+    public ResponseBean tdCityGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
122
+        TdCity tdCity = iTdCityService.getById(id);
123
+        if (null == tdCity) {
124
+            return ResponseBean.error("未找到指定地区", ResponseBean.ERROR_ILLEGAL_PARAMS);
125
+        }
126
+
127
+        TdCity parent = iTdCityService.getById(tdCity.getAreaPId());
128
+        if (null != parent) {
129
+            tdCity.setAreaPName(parent.getAreaPName());
130
+        }
131
+
132
+        return ResponseBean.success(tdCity);
133
+    }
124 134
 }

+ 3
- 0
src/main/java/com/yunzhi/shigongli/entity/TaResource.java Datei anzeigen

@@ -64,4 +64,7 @@ public class TaResource implements Serializable {
64 64
 
65 65
     @ApiModelProperty(value = "权重")
66 66
     private Integer weight;
67
+
68
+    @ApiModelProperty(value = "所属区")
69
+    private String cityId;
67 70
 }

+ 5
- 1
src/main/java/com/yunzhi/shigongli/entity/TaShopPackage.java Datei anzeigen

@@ -3,6 +3,8 @@ package com.yunzhi.shigongli.entity;
3 3
 import java.math.BigDecimal;
4 4
 import com.baomidou.mybatisplus.annotation.IdType;
5 5
 import java.time.LocalDateTime;
6
+
7
+import com.baomidou.mybatisplus.annotation.TableField;
6 8
 import com.baomidou.mybatisplus.annotation.TableId;
7 9
 import java.io.Serializable;
8 10
 import io.swagger.annotations.ApiModel;
@@ -70,5 +72,7 @@ public class TaShopPackage implements Serializable {
70 72
     @ApiModelProperty(value = "创建时间")
71 73
     private LocalDateTime createDate;
72 74
 
73
-
75
+    @ApiModelProperty(value = "是否收藏")
76
+    @TableField(exist = false)
77
+    private Integer isSaved;
74 78
 }

+ 4
- 0
src/main/java/com/yunzhi/shigongli/entity/TaTourist.java Datei anzeigen

@@ -96,4 +96,8 @@ public class TaTourist implements Serializable {
96 96
     @ApiModelProperty(value = "分类标签")
97 97
     @TableField(exist = false)
98 98
     private List<TaTargetType> typeList;
99
+
100
+    @ApiModelProperty(value = "是否收藏")
101
+    @TableField(exist = false)
102
+    private Integer isSaved;
99 103
 }

+ 5
- 0
src/main/java/com/yunzhi/shigongli/entity/TdCity.java Datei anzeigen

@@ -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 java.io.Serializable;
6 7
 import io.swagger.annotations.ApiModel;
@@ -35,6 +36,10 @@ public class TdCity implements Serializable {
35 36
     @ApiModelProperty(value = "父级ID")
36 37
     private String areaPId;
37 38
 
39
+    @ApiModelProperty(value = "父级ID")
40
+    @TableField(exist = false)
41
+    private String areaPName;
42
+
38 43
     @ApiModelProperty(value = "等级")
39 44
     private String areaLevel;
40 45
 

+ 13
- 0
src/main/java/com/yunzhi/shigongli/mapper/TaShopPackageMapper.java Datei anzeigen

@@ -3,10 +3,13 @@ package com.yunzhi.shigongli.mapper;
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 4
 import com.yunzhi.shigongli.entity.TaShopPackage;
5 5
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
+import com.yunzhi.shigongli.vo.ShopPackageRecommend;
6 7
 import com.yunzhi.shigongli.vo.ShopPackageVO;
7 8
 import org.apache.ibatis.annotations.Mapper;
8 9
 import org.apache.ibatis.annotations.Param;
9 10
 
11
+import java.util.List;
12
+
10 13
 /**
11 14
  * <p>
12 15
  * 商铺套餐 Mapper 接口
@@ -19,4 +22,14 @@ import org.apache.ibatis.annotations.Param;
19 22
 public interface TaShopPackageMapper extends BaseMapper<TaShopPackage> {
20 23
 
21 24
     IPage<ShopPackageVO> getProfilePage(IPage<TaShopPackage> pg, @Param("shopId") String shopId);
25
+
26
+    IPage<TaShopPackage> getWxPackageList(IPage<TaShopPackage> pg,
27
+                                          @Param("targetType") String targetType,
28
+                                          @Param("shopId") String shopId,
29
+                                          @Param("personId") String personId);
30
+
31
+    List<ShopPackageRecommend> getWxRecommendList(@Param("targetType") String targetType,
32
+                                                  @Param("location") String location,
33
+                                                  @Param("personId") String personId,
34
+                                                  @Param("limit") Integer limit);
22 35
 }

+ 3
- 0
src/main/java/com/yunzhi/shigongli/service/ITaShopPackageService.java Datei anzeigen

@@ -3,6 +3,7 @@ package com.yunzhi.shigongli.service;
3 3
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 4
 import com.yunzhi.shigongli.entity.TaPerson;
5 5
 import com.yunzhi.shigongli.entity.TaShopPackage;
6
+import com.yunzhi.shigongli.vo.ShopPackageRecommend;
6 7
 import com.yunzhi.shigongli.vo.ShopPackageVO;
7 8
 
8 9
 import java.util.List;
@@ -27,4 +28,6 @@ public interface ITaShopPackageService extends IBaseService<TaShopPackage> {
27 28
     IPage<ShopPackageVO> getProfilePage(IPage<TaShopPackage> pg, String shopId);
28 29
 
29 30
     IPage<TaShopPackage> getWxPackageList(IPage<TaShopPackage> page, String shopId, TaPerson currentPerson);
31
+
32
+    List<ShopPackageRecommend> getWxRecommendList(String location, TaPerson taPerson) throws Exception ;
30 33
 }

+ 8
- 6
src/main/java/com/yunzhi/shigongli/service/impl/TaShopPackageServiceImpl.java Datei anzeigen

@@ -12,6 +12,7 @@ import com.yunzhi.shigongli.mapper.TaShopPackageMapper;
12 12
 import com.yunzhi.shigongli.mapper.TaShopPackageSettingMapper;
13 13
 import com.yunzhi.shigongli.service.ITaShopPackageService;
14 14
 
15
+import com.yunzhi.shigongli.vo.ShopPackageRecommend;
15 16
 import com.yunzhi.shigongli.vo.ShopPackageVO;
16 17
 import org.springframework.beans.BeanUtils;
17 18
 import org.springframework.beans.factory.annotation.Autowired;
@@ -146,12 +147,13 @@ public class TaShopPackageServiceImpl extends BaseServiceImpl<TaShopPackageMappe
146 147
 
147 148
     @Override
148 149
     public IPage<TaShopPackage> getWxPackageList(IPage<TaShopPackage> pg, String shopId, TaPerson currentPerson) {
149
-        LambdaQueryWrapper<TaShopPackage> queryWrapper = new LambdaQueryWrapper<>();
150
-        queryWrapper.eq(TaShopPackage::getShopId, shopId);
151
-        queryWrapper.eq(TaShopPackage::getStatus, Constants.STATUS_NORMAL);
152
-        queryWrapper.orderByDesc(TaShopPackage::getWeight);
153
-        queryWrapper.orderByDesc(TaShopPackage::getCreateDate);
150
+        return baseMapper.getWxPackageList(pg, Constants.TARGET_SHOP_PACKAGE, shopId, currentPerson.getPersonId());
151
+    }
154 152
 
155
-        return page(pg, queryWrapper);
153
+    @Override
154
+    public List<ShopPackageRecommend> getWxRecommendList(String location, TaPerson taPerson) {
155
+        // 默认获取 3 个
156
+        Integer limit = 3;
157
+        return baseMapper.getWxRecommendList(Constants.TARGET_SHOP_PACKAGE, location, taPerson.getPersonId(), limit);
156 158
     }
157 159
 }

+ 3
- 0
src/main/java/com/yunzhi/shigongli/vo/ResourceFieldVO.java Datei anzeigen

@@ -37,4 +37,7 @@ public class ResourceFieldVO {
37 37
 
38 38
     @ApiModelProperty(value = "权重")
39 39
     private Integer weight;
40
+
41
+    @ApiModelProperty(value = "所属区")
42
+    private String cityId;
40 43
 }

+ 24
- 0
src/main/java/com/yunzhi/shigongli/vo/ShopPackageRecommend.java Datei anzeigen

@@ -0,0 +1,24 @@
1
+package com.yunzhi.shigongli.vo;
2
+
3
+
4
+import com.yunzhi.shigongli.entity.TaShopPackage;
5
+import io.swagger.annotations.ApiModel;
6
+import io.swagger.annotations.ApiModelProperty;
7
+import lombok.Data;
8
+
9
+@ApiModel(description = "商铺列表")
10
+@Data
11
+public class ShopPackageRecommend extends TaShopPackage {
12
+
13
+    @ApiModelProperty(value = "区位ID")
14
+    private String areaId;
15
+
16
+    @ApiModelProperty(value = "区位名称")
17
+    private String areaName;
18
+
19
+    @ApiModelProperty(value = "区位父级名称")
20
+    private String areaPName;
21
+
22
+    @ApiModelProperty(value = "评分")
23
+    private Float score;
24
+}

+ 42
- 0
src/main/resources/mapper/TaShopPackageMapper.xml Datei anzeigen

@@ -21,4 +21,46 @@
21 21
             t.weight DESC,
22 22
             t.create_date DESC
23 23
     </select>
24
+    <select id="getWxPackageList" resultType="com.yunzhi.shigongli.entity.TaShopPackage">
25
+        SELECT
26
+            t.*,
27
+            IF
28
+                ( s.save_id IS NOT NULL, 1, 0 ) is_saved
29
+        FROM
30
+            ta_shop_package t
31
+                LEFT JOIN ta_save s ON s.target_type = #{targetType}
32
+                AND s.target_id = t.package_id
33
+                AND s.person_id = #{personId}
34
+        WHERE
35
+            t.`status` = 1
36
+          AND t.shop_id = #{shopId}
37
+        ORDER BY
38
+            t.weight DESC,
39
+            t.create_date DESC
40
+    </select>
41
+    <select id="getWxRecommendList" resultType="com.yunzhi.shigongli.vo.ShopPackageRecommend">
42
+        SELECT
43
+            *
44
+        FROM
45
+            (
46
+                SELECT
47
+                    t.*,
48
+                    fn_distance ( #{location}, s.locaton ) AS distance,
49
+                    ( s.sweet_score + s.environment_score + s.service_score ) / 3 AS score,
50
+                    IF ( m.save_id IS NULL, 0, 1 ) AS is_saved
51
+                FROM
52
+                    ta_shop_package t
53
+                        INNER JOIN ta_shop s ON s.shop_id = t.shop_id
54
+                        LEFT JOIN ta_save m ON m.target_type = #{targetType}
55
+                        AND m.target_id = t.package_id
56
+                        AND m.person_id = #{personId}
57
+                WHERE
58
+                    t.`status` = 1
59
+                  AND s.`status` = 1
60
+            ) a
61
+        ORDER BY
62
+            a.distance DESC,
63
+            a.weight DESC
64
+        LIMIT #{limit}
65
+    </select>
24 66
 </mapper>