Browse Source

关注推荐新品接口提交

zjy 3 weeks ago
parent
commit
ac7f95273b

+ 1 - 1
alien-entity/src/main/java/shop/alien/mapper/second/SecondRecommendMapper.java

@@ -17,7 +17,7 @@ public interface SecondRecommendMapper extends BaseMapper<SecondGoodsRecommendVo
     /**
      * 自定义分页查询
      */
-    IPage<SecondGoodsRecommendVo> getSecondRecommendByPage(IPage<SecondGoodsRecommendVo> page, @Param("userId") Integer userId, @Param("position") String position, @Param("typeId") Integer typeId);
+    IPage<SecondGoodsRecommendVo> getSecondRecommendByPage(IPage<SecondGoodsRecommendVo> page, @Param("userId") Integer userId, @Param("position") String position, @Param("typeId") Integer typeId, @Param("phoneId") String phoneId);
 
     IPage<SecondGoodsRecommendVo> querySecondConcernByPage(IPage<SecondGoodsRecommendVo> page, @Param("phoneId") String phoneId, @Param("position") String position);
 

+ 5 - 2
alien-entity/src/main/resources/mapper/second/SecondGoodsInfoMapper.xml

@@ -62,10 +62,11 @@
             g.delete_flag,
             ROUND(ST_Distance_Sphere(ST_GeomFromText(CONCAT('POINT(', REPLACE(#{position}, ',', ' '), ')' )), ST_GeomFromText(CONCAT('POINT(', REPLACE(g.position, ',', ' '), ')' ))) / 1000, 2) AS dist,
             case when llr.id is null then '0' else '1' end likeStatus,
-            g.home_image
+            g.home_image,
+            CONCAT('user_', u.user_phone) as user_phone
         FROM
             second_goods g inner join life_user u on u.id =  g.user_id and u.delete_flag = 0
-            left join life_like_record llr on llr.dianzan_id = g.user_id and llr.huifu_id = g.id and llr.type = 6 and llr.delete_flag = 0
+            left join life_like_record llr on llr.dianzan_id = #{phoneId} and llr.huifu_id = g.id and llr.type = 6 and llr.delete_flag = 0
         where g.delete_flag = 0
             <if test="typeId != null and typeId != '' ">
                 and (g.category_one_id = #{typeId} or g.category_two_id =#{typeId} )
@@ -96,6 +97,7 @@
             g.updated_user_id,
             u.user_name,
             u.user_image,
+            CONCAT('user_', u.user_phone) as user_phone,
             g.goods_status,
             g.home_image,
             case when llr.id is null then '0' else '1' end likeStatus,
@@ -168,6 +170,7 @@
             g.updated_user_id,
             u.user_name,
             u.user_image,
+            CONCAT('user_', u.user_phone) as user_phone,
             g.goods_status,
             g.delete_flag,
             ROUND(ST_Distance_Sphere(ST_GeomFromText(CONCAT('POINT(', REPLACE(#{position}, ',', ' '), ')' )), ST_GeomFromText(CONCAT('POINT(', REPLACE(g.position, ',', ' '), ')' ))) / 1000, 2) AS dist,

+ 3 - 1
alien-second/src/main/java/shop/alien/second/service/impl/SecondRecommendServiceImpl.java

@@ -50,14 +50,16 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
         try{
             JSONObject data = JwtUtil.getCurrentUserInfo();
             Integer userId = null;
+            String phoneId = null;
             if (data != null) {
                 userId = data.getInteger("userId");
+                phoneId = data.getString("phone");
                 log.info("获取用户ID:userId={}", userId);
             }
             if (userId == null) {
                 return null;
             }
-            IPage<SecondGoodsRecommendVo> result = mapper.getSecondRecommendByPage(page, userId, longitude + "," + latitude, typeId);
+            IPage<SecondGoodsRecommendVo> result = mapper.getSecondRecommendByPage(page, userId, longitude + "," + latitude, typeId, "user_" + phoneId);
             for (SecondGoodsRecommendVo row : result.getRecords()) {
                 if (StringUtil.isNotBlank(row.getDist())) {
                     row.setPosition("距离" + row.getDist() + "km");