Browse Source

关注推荐新品接口提交

zjy 2 weeks ago
parent
commit
602a7d8518
17 changed files with 521 additions and 184 deletions
  1. 85 0
      alien-entity/src/main/java/shop/alien/entity/second/SecondComplaint.java
  2. 73 2
      alien-entity/src/main/java/shop/alien/entity/second/vo/SecondGoodsRecommendVo.java
  3. 12 0
      alien-entity/src/main/java/shop/alien/entity/store/LifeUserViolation.java
  4. 17 0
      alien-entity/src/main/java/shop/alien/mapper/second/SecondComplaintMapper.java
  5. 2 0
      alien-entity/src/main/java/shop/alien/mapper/second/SecondRecommendMapper.java
  6. 12 0
      alien-entity/src/main/java/shop/alien/mapper/second/SecondShieldMapper.java
  7. 43 10
      alien-entity/src/main/resources/mapper/second/SecondGoodsInfoMapper.xml
  8. 1 1
      alien-second/src/main/java/shop/alien/second/controller/SecondGoodsCategoryController.java
  9. 18 45
      alien-second/src/main/java/shop/alien/second/controller/SecondRecommendController.java
  10. 58 0
      alien-second/src/main/java/shop/alien/second/controller/SecondShieldController.java
  11. 1 1
      alien-second/src/main/java/shop/alien/second/service/SecondGoodsCategoryService.java
  12. 27 4
      alien-second/src/main/java/shop/alien/second/service/SecondRecommendService.java
  13. 9 2
      alien-second/src/main/java/shop/alien/second/service/impl/SecondGoodsCategoryServiceImpl.java
  14. 154 112
      alien-second/src/main/java/shop/alien/second/service/impl/SecondRecommendServiceImpl.java
  15. 7 5
      alien-store/src/main/java/shop/alien/store/controller/LifeCollectController.java
  16. 1 1
      alien-store/src/main/java/shop/alien/store/controller/StoreCommentController.java
  17. 1 1
      alien-store/src/main/java/shop/alien/store/service/impl/StoreCommentServiceImpl.java

+ 85 - 0
alien-entity/src/main/java/shop/alien/entity/second/SecondComplaint.java

@@ -0,0 +1,85 @@
+package shop.alien.entity.second;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author ssk
+ * @since 2025-07-09
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="SecondComplaint对象", description="")
+public class SecondComplaint extends Model<SecondComplaint> {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "主键id")
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    @ApiModelProperty(value = "用户id")
+    @TableField("user_id")
+    private Integer userId;
+
+    @ApiModelProperty(value = "投诉id")
+    @TableField("complaint_id")
+    private Integer complaintId;
+
+    @ApiModelProperty(value = "投诉类型  1-用户  2-商品")
+    @TableField("complaint_type")
+    private Integer complaintType;
+
+    @ApiModelProperty(value = "投诉原因")
+    @TableField("complaint_reason")
+    private String complaintReason;
+
+    @ApiModelProperty(value = "投诉状态  0-审核中  1-成功  2-失败")
+    @TableField("complaint_status")
+    private Integer complaintStatus;
+
+    @ApiModelProperty(value = "投诉结果")
+    @TableField("complaint_result")
+    private String complaintResult;
+
+    @ApiModelProperty(value = "删除标记 0:未删除 1:已删除")
+    @TableField("delete_flag")
+    @TableLogic
+    private Integer deleteFlag;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField(value = "created_time", fill = FieldFill.INSERT)
+    private Date createdTime;
+
+    @ApiModelProperty(value = "创建人ID")
+    @TableField(value = "created_user_id", fill = FieldFill.INSERT)
+    private Integer createdUserId;
+
+    @ApiModelProperty(value = "修改时间")
+    @TableField(value = "updated_time", fill = FieldFill.INSERT_UPDATE)
+    private Date updatedTime;
+
+    @ApiModelProperty(value = "修改人ID")
+    @TableField(value = "updated_user_id", fill = FieldFill.INSERT_UPDATE)
+    private Integer updatedUserId;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+}

+ 73 - 2
alien-entity/src/main/java/shop/alien/entity/second/vo/SecondGoodsRecommendVo.java

@@ -1,13 +1,19 @@
 package shop.alien.entity.second.vo;
 
 import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import shop.alien.entity.second.SecondGoods;
 import shop.alien.entity.store.StoreComment;
+import shop.alien.entity.store.StoreImg;
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 @Data
 @JsonInclude
@@ -17,12 +23,18 @@ public class SecondGoodsRecommendVo extends SecondGoods {
     @ApiModelProperty(value = "用户名称")
     private String userName;
 
+    @ApiModelProperty(value = "用户PHONE")
+    private String userPhone;
+
     @ApiModelProperty(value = "用户头像")
     private String userImage;
 
     @ApiModelProperty(value = "距离")
     private String dist;
 
+    @ApiModelProperty(value = "是否关注")
+    private Integer fansStatus = 0;
+
     @ApiModelProperty(value = "是否点赞")
     private String likeStatus;
 
@@ -33,8 +45,67 @@ public class SecondGoodsRecommendVo extends SecondGoods {
     private String commentCount;
 
     @ApiModelProperty(value = "评论列表")
-    List<StoreComment> commentList;
+    private List<StoreComment> commentList;
 
     @ApiModelProperty(value = "话题列表")
-    List<String> topicList;
+    @JsonProperty("topicList")
+    private List<String> topicList() {
+        return parseTopic(getTopic());
+    }
+
+    @ApiModelProperty(value = "图片列表")
+    private String[] imgList;
+
+    @ApiModelProperty(value = "发布时间")
+    @JsonProperty("timeAgo")
+    public String getFormattedTimeAgo() {
+        return getTimeAgo(getReleaseTime());
+    }
+
+
+    /**
+     * 解析话题列表
+     *
+     * @param topic 话题列表字符串
+     * @return 解析后的话题列表
+     */
+    public List<String> parseTopic(String topic) {
+        if (topic != null && !topic.isEmpty()) {
+            return Arrays.asList(topic.split(","));
+        } else {
+            return Collections.emptyList();
+        }
+    }
+
+    public String getTimeAgo(Date releaseTime) {
+        if (releaseTime == null) {
+            return "未知时间";
+        }
+
+        long now = System.currentTimeMillis();
+        long diff = now - releaseTime.getTime();
+
+        // 新增分钟级判断
+        long minutes = TimeUnit.MILLISECONDS.toMinutes(diff);
+        if (minutes < 1) {
+            return "刚刚";
+        } else if (minutes < 60) {
+            return minutes + "分钟前";
+        }
+
+        long hours = TimeUnit.MILLISECONDS.toHours(diff);
+        long days = TimeUnit.MILLISECONDS.toDays(diff);
+        long months = days / 31;
+        long years = days / 365;
+
+        if (hours < 24) {
+            return hours + "小时前";
+        } else if (days <= 31) {
+            return days + "天前";
+        } else if (years >= 1) {
+            return years + "年前";
+        } else {
+            return months + "个月前";
+        }
+    }
 }

+ 12 - 0
alien-entity/src/main/java/shop/alien/entity/store/LifeUserViolation.java

@@ -107,6 +107,18 @@ public class LifeUserViolation extends Model<LifeUserViolation> {
     @TableField(value = "report_result")
     private String reportResult;
 
+    @ApiModelProperty(value = "业务ID")
+    @TableField(value = "business_id")
+    private Integer businessId;
+
+    @ApiModelProperty(value = "举报类型")
+    @TableField(value = "dict_type")
+    private String dictType;
+
+    @ApiModelProperty(value = "举报类型ID")
+    @TableField(value = "dict_id")
+    private Integer dictId;
+
     @Override
     protected Serializable pkVal() {
         return this.id;

+ 17 - 0
alien-entity/src/main/java/shop/alien/mapper/second/SecondComplaintMapper.java

@@ -0,0 +1,17 @@
+package shop.alien.mapper.second;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import shop.alien.entity.second.SecondComplaint;
+
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author ssk
+ * @since 2025-07-09
+ */
+public interface SecondComplaintMapper extends BaseMapper<SecondComplaint> {
+
+}

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

@@ -23,4 +23,6 @@ public interface SecondRecommendMapper extends BaseMapper<SecondGoodsRecommendVo
     IPage<SecondGoodsRecommendVo> querySecondNewGoodsByPage(IPage<SecondGoodsRecommendVo> page,@Param("userId") String userId, @Param("phoneId") String phoneId, @Param("position") String position);
 
     List<StoreComment> querySecondCommentInfo(@Param("ids") List<Integer> ids);
+
+    SecondGoodsRecommendVo querySecondGoodsDetail(@Param("goodsId") Integer goodsId, @Param("phoneId") String phoneId, @Param("position") String position);
 }

+ 12 - 0
alien-entity/src/main/java/shop/alien/mapper/second/SecondShieldMapper.java

@@ -0,0 +1,12 @@
+package shop.alien.mapper.second;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import shop.alien.entity.second.SecondShield;
+
+
+/**
+ * 二手商品映射器
+ */
+public interface SecondShieldMapper extends BaseMapper<SecondShield> {
+
+}

+ 43 - 10
alien-entity/src/main/resources/mapper/second/SecondGoodsInfoMapper.xml

@@ -27,14 +27,16 @@
         <result column="dist" property="dist" jdbcType="VARCHAR"/>
         <result column="isLike" property="isLike" jdbcType="VARCHAR"/>
         <result column="home_image" property="homeImage" jdbcType="VARCHAR"/>
+        <result column="user_phone" property="userPhone" jdbcType="VARCHAR"/>
     </resultMap>
 
     <!-- 分页查询推荐数据 -->
     <select id="getSecondRecommendByPage" resultType="shop.alien.entity.second.vo.SecondGoodsRecommendVo">
         with shieldUser as (
-            select g.id from second_shield s inner join second_goods g
-                on s.shield_id = g.user_id  and g.delete_flag = '0' and goods_status = '3' and s.delete_flag = '0'
-            where s.user_id = #{userId} and s.shield_type = 2
+            select g.id from life_blacklist lb inner join second_goods g
+                on lb.blocked_id = g.user_id  and g.delete_flag = '0' and g.goods_status = '3'
+            where lb.delete_flag = 0 and lb.blocker_type = 2 and lb.blocked_type = 2
+                and lb.blocker_id = #{userId}
         )
         SELECT
             g.id,
@@ -68,7 +70,7 @@
             <if test="typeId != null and typeId != '' ">
                 and (g.category_one_id = #{typeId} or g.category_two_id =#{typeId} )
             </if>
-            and not exists (select 1 from second_shield s where s.id = g.id)
+            and not exists (select 1 from shieldUser s where s.id = g.id)
             and not exists (select 1 from second_shield s where s.user_id = #{userId} and s.shield_type = 1 and s.shield_id = g.id and s.delete_flag = 0)
             and g.goods_status = 3
         order by dist, like_count desc, created_time desc
@@ -80,7 +82,7 @@
             g.id,
             g.user_id,
             g.title,
-            g.describe,
+            g.description,
             g.price,
             ROUND(ST_Distance_Sphere(ST_GeomFromText(CONCAT('POINT(', REPLACE(#{position}, ',', ' '), ')' )), ST_GeomFromText(CONCAT('POINT(', REPLACE(g.position, ',', ' '), ')' ))) / 1000, 2) AS dist,
             g.like_count,
@@ -107,7 +109,7 @@
                 and g.goods_status = 3
                 and g.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
-            left join life_collect lc on lc.goods_id = g.id and lc.user_id = #{phoneId} and lc.delete_flag = 0
+            left join life_collect lc on lc.business_id = g.id and lc.user_id = #{phoneId} and lc.delete_flag = 0 and lc.business_type = 1
         where
             f.fans_id = #{phoneId} and f.delete_flag = 0
     </select>
@@ -141,9 +143,10 @@
     <!-- 分页查询推荐数据 -->
     <select id="querySecondNewGoodsByPage" resultType="shop.alien.entity.second.vo.SecondGoodsRecommendVo">
         with shieldUser as (
-            select g.id from second_shield s inner join second_goods g
-            on s.shield_id = g.user_id  and g.delete_flag = '0' and goods_status = '3' and s.delete_flag = '0'
-            where s.user_id = #{userId} and s.shield_type = 2
+            select g.id from life_blacklist lb inner join second_goods g
+                on lb.blocked_id = g.user_id  and g.delete_flag = '0' and g.goods_status = '3'
+            where lb.delete_flag = 0 and lb.blocker_type = 2 and lb.blocked_type = 2
+                and lb.blocker_id = #{userId}
         )
         SELECT
             g.id,
@@ -175,11 +178,41 @@
         FROM
             second_goods g inner join life_user u on u.id =  g.user_id
             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
-            left join life_collect lc on lc.goods_id = g.id and lc.user_id = #{phoneId} and lc.delete_flag = 0
+            left join life_collect lc on lc.business_id = g.id and lc.user_id = #{phoneId} and lc.delete_flag = 0 and lc.business_type = 1
         where g.delete_flag = 0
             and not exists (select 1 from shieldUser s where s.id = g.id)
             and not exists (select 1 from second_shield s where s.user_id = #{userId} and s.shield_type = 1 and s.shield_id = g.id)
             and g.goods_status = 3
     </select>
 
+    <select id="querySecondGoodsDetail" resultType="shop.alien.entity.second.vo.SecondGoodsRecommendVo">
+        select
+            g.id,
+            g.user_id,
+            g.title,
+            g.description,
+            g.price,
+            g.position,
+            g.like_count,
+            g.collect_count,
+            g.category_one_id,
+            g.category_two_id,
+            g.label,
+            g.topic,
+            g.home_image,
+            g.release_time,
+            lu.user_name,
+            CONCAT('user_', lu.user_phone) as user_phone,
+            lu.user_image,
+            goods_status,
+            ROUND(ST_Distance_Sphere(ST_GeomFromText(CONCAT('POINT(', REPLACE(#{position}, ',', ' '), ')' )), ST_GeomFromText(CONCAT('POINT(', REPLACE(g.position, ',', ' '), ')' ))) / 1000, 2) AS dist,
+            (select count(1) from store_comment c where c.business_id = g.id and c.business_type = 6 and c.delete_flag = 0) as commentCount,
+            case when llr.id is null then '0' else '1' end likeStatus,
+            case when lc.id is null then '0' else '1' end collectStatus
+        from second_goods g inner join life_user lu on g.user_id = lu.id and lu.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
+            left join life_collect lc on lc.business_id = g.id and lc.user_id = #{phoneId} and lc.delete_flag = 0 and lc.business_type = 1
+        where g.id = #{goodsId} and g.delete_flag = 0
+    </select>
+
 </mapper>

+ 1 - 1
alien-second/src/main/java/shop/alien/second/controller/SecondGoodsCategoryController.java

@@ -26,7 +26,7 @@ public class SecondGoodsCategoryController {
     @ApiOperation("搜索商品类型")
     @PostMapping("/querySecondGoodsByParentId")
     public R<List<SecondGoodsCategory>> querySecondGoodsByParentId(
-            @RequestParam(value = "parentId", required = false) Integer parentId) {
+            @RequestParam(value = "parentId", required = false) Integer parentId) throws Exception {
         return R.data(service.querySecondGoodsByParentId(parentId), "查询成功");
     }
 

+ 18 - 45
alien-second/src/main/java/shop/alien/second/controller/SecondRecommendController.java

@@ -7,8 +7,12 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiSort;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.kie.api.KieBase;
+import org.kie.api.runtime.KieSession;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
+import shop.alien.entity.second.Order;
 import shop.alien.entity.second.vo.SecondGoodsRecommendVo;
 import shop.alien.second.service.SecondRecommendService;
 
@@ -23,6 +27,9 @@ public class SecondRecommendController {
 
     private final SecondRecommendService service;
 
+    @Autowired
+    private static KieBase kieBase;
+
     @ApiOperation("搜索推荐商品列表")
     @PostMapping("/queryRecommendList")
     public R<IPage<SecondGoodsRecommendVo>> queryRecommendList(
@@ -30,7 +37,8 @@ public class SecondRecommendController {
             @RequestParam(value = "pageSize", required = false) Integer pageSize,
             @RequestParam(value = "typeId", required = false) Integer typeId,
             @RequestParam(value = "longitude", required = false) String longitude,
-            @RequestParam(value = "latitude", required = false) String latitude) {
+            @RequestParam(value = "latitude", required = false) String latitude) throws Exception {
+        log.info("LifeCollectController.cancelCollect?pageNum={},pageSize={},longitude={},latitude={},typeId={}", pageNum, pageSize, longitude, latitude, typeId);
         IPage<SecondGoodsRecommendVo> page = new Page<>(pageNum, pageSize);
         IPage<SecondGoodsRecommendVo> result = service.getSecondRecommendByPage(page, longitude, latitude, typeId);
         return R.data(result, "查询成功");
@@ -42,7 +50,8 @@ public class SecondRecommendController {
             @RequestParam(value = "pageNum", required = false) Integer pageNum,
             @RequestParam(value = "pageSize", required = false) Integer pageSize,
             @RequestParam(value = "longitude", required = false) String longitude,
-            @RequestParam(value = "latitude", required = false) String latitude) {
+            @RequestParam(value = "latitude", required = false) String latitude) throws Exception {
+        log.info("LifeCollectController.cancelCollect?pageNum={},pageSize={},longitude={},latitude={}", pageNum, pageSize, longitude, latitude);
         IPage<SecondGoodsRecommendVo> page = new Page<>(pageNum, pageSize);
         IPage<SecondGoodsRecommendVo> result = service.querySecondConcernByPage(page, longitude + "," + latitude);
         return R.data(result, "查询成功");
@@ -54,7 +63,8 @@ public class SecondRecommendController {
             @RequestParam(value = "pageNum", required = false) Integer pageNum,
             @RequestParam(value = "pageSize", required = false) Integer pageSize,
             @RequestParam(value = "longitude", required = false) String longitude,
-            @RequestParam(value = "latitude", required = false) String latitude) {
+            @RequestParam(value = "latitude", required = false) String latitude) throws Exception {
+        log.info("LifeCollectController.cancelCollect?pageNum={},pageSize={},longitude={},latitude={}", pageNum, pageSize, longitude, latitude);
         IPage<SecondGoodsRecommendVo> page = new Page<>(pageNum, pageSize);
         IPage<SecondGoodsRecommendVo> result = service.querySecondNewGoodsByPage(page, longitude + "," + latitude);
         return R.data(result, "查询成功");
@@ -63,48 +73,11 @@ public class SecondRecommendController {
     @ApiOperation("搜索商品详情")
     @PostMapping("/querySecondGoodsDetail")
     public R<SecondGoodsRecommendVo> querySecondGoodsDetail(
-            @RequestParam(value = "goodsId", required = false) Integer goodsId) {
-        //IPage<SecondGoodsRecommendVo> result = service.querySecondNewGoodsByPage(goodsId);
-        return R.data(null, "查询成功");
-    }
-
-
-
-    private static final double EARTH_RADIUS = 6371; // 地球半径 (千米)
-
-    /**
-     * 计算两个经纬度之间的距离
-     * @param lat1 第一个点的纬度
-     * @param lon1 第一个点的经度
-     * @param lat2 第二个点的纬度
-     * @param lon2 第二个点的经度
-     * @return 距离(千米)
-     */
-    public static double calculateDistance(double lat1, double lon1, double lat2, double lon2) {
-        // 将经纬度从度数转换为弧度
-        double radLat1 = Math.toRadians(lat1);
-        double radLon1 = Math.toRadians(lon1);
-        double radLat2 = Math.toRadians(lat2);
-        double radLon2 = Math.toRadians(lon2);
-
-        // 计算经纬度差值
-        double deltaLat = radLat2 - radLat1;
-        double deltaLon = radLon2 - radLon1;
-
-        // Haversine 公式
-        double a = Math.sin(deltaLat / 2) * Math.sin(deltaLat / 2) +
-                Math.cos(radLat1) * Math.cos(radLat2) *
-                        Math.sin(deltaLon / 2) * Math.sin(deltaLon / 2);
-        double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
-
-        // 计算最终距离
-        return EARTH_RADIUS * c;
-    }
-
-    public static void main(String[] args) {
-        // 示例:计算北京 (39.9042° N, 116.4074° E) 到上海 (31.2304° N, 121.4737° E) 的距离
-        double distance = calculateDistance(39.01, 121.49, 41.48, 123.25);
-        System.out.printf("两地距离: %.2f 公里%n", distance);
+            @RequestParam(value = "goodsId", required = false) Integer goodsId,
+            @RequestParam(value = "longitude", required = false) String longitude,
+            @RequestParam(value = "latitude", required = false) String latitude) throws Exception {
+        log.info("LifeCollectController.cancelCollect?goodsId={},longitude={},latitude={}", goodsId, longitude, latitude);
+        return R.data(service.querySecondGoodsDetail(goodsId, longitude + "," + latitude), "查询成功");
     }
 
 }

+ 58 - 0
alien-second/src/main/java/shop/alien/second/controller/SecondShieldController.java

@@ -0,0 +1,58 @@
+package shop.alien.second.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiSort;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.ss.formula.functions.T;
+import org.springframework.web.bind.annotation.*;
+import shop.alien.entity.result.R;
+import shop.alien.entity.second.SecondShield;
+import shop.alien.mapper.second.SecondShieldMapper;
+import shop.alien.util.common.JwtUtil;
+
+import java.util.Date;
+
+@Slf4j
+@Api(tags = {"二手平台-拉黑"})
+@ApiSort(9)
+@CrossOrigin
+@RestController
+@RequestMapping("/second/shield")
+@RequiredArgsConstructor
+public class SecondShieldController {
+
+    private final SecondShieldMapper mapper;
+
+    @ApiOperation("商品拉黑")
+    @PostMapping("/saveGoodsShield")
+    public R<T> saveGoodsShield(
+            @RequestParam(value = "shieldId", required = false) Integer shieldId) {
+        JSONObject data = JwtUtil.getCurrentUserInfo();
+        Integer userId = null;
+        if (data != null) {
+            userId = data.getInteger("userId");
+        }
+        if (userId == null) {
+            return null;
+        }
+        SecondShield shield = new SecondShield();
+        shield.setUserId(userId);
+        shield.setShieldId(shieldId);
+        shield.setShieldType(1);
+        shield.setCreatedUserId(userId);
+        shield.setCreatedTime(new Date());
+        shield.setUpdatedUserId(userId);
+        shield.setUpdatedTime(new Date());
+        Integer num = mapper.insert(shield);
+
+        if(num == 1) {
+            return R.success("拉黑成功");
+        }
+        return R.fail("拉黑失败");
+
+    }
+
+}

+ 1 - 1
alien-second/src/main/java/shop/alien/second/service/SecondGoodsCategoryService.java

@@ -15,6 +15,6 @@ public interface SecondGoodsCategoryService extends IService<SecondGoodsCategory
      * @param parentId 父ID
      * @return 分页后的屏蔽商品列
      */
-    List<SecondGoodsCategory> querySecondGoodsByParentId(Integer parentId);
+    List<SecondGoodsCategory> querySecondGoodsByParentId(Integer parentId) throws Exception;
 
 }

+ 27 - 4
alien-second/src/main/java/shop/alien/second/service/SecondRecommendService.java

@@ -13,13 +13,36 @@ public interface SecondRecommendService extends IService<SecondGoodsRecommendVo>
     /**
      * 查询推荐信息
      * @param page 分页信息
-     * @return 是否成功保存
+     * @param longitude 经度信息
+     * @param latitude 维度信息
+     * @param typeId 类型ID
+     * @return 推荐商品信息
      */
-    IPage<SecondGoodsRecommendVo> getSecondRecommendByPage(IPage<SecondGoodsRecommendVo> page, String longitude, String latitude, Integer typeId);
+    IPage<SecondGoodsRecommendVo> getSecondRecommendByPage(IPage<SecondGoodsRecommendVo> page, String longitude, String latitude, Integer typeId) throws Exception;
 
-    IPage<SecondGoodsRecommendVo> querySecondConcernByPage(IPage<SecondGoodsRecommendVo> page, String position);
+    /**
+     * 查询关注信息
+     * @param page 分页信息
+     * @param position 经纬度
+     * @return 关注商品信息
+     */
+    IPage<SecondGoodsRecommendVo> querySecondConcernByPage(IPage<SecondGoodsRecommendVo> page, String position) throws Exception;
 
-    IPage<SecondGoodsRecommendVo> querySecondNewGoodsByPage(IPage<SecondGoodsRecommendVo> page, String position);
+    /**
+     * 查询新品信息
+     * @param page 分页信息
+     * @param position 经纬度
+     * @return 新品商品信息
+     */
+    IPage<SecondGoodsRecommendVo> querySecondNewGoodsByPage(IPage<SecondGoodsRecommendVo> page, String position) throws Exception;
+
+    /**
+     * 查询商品详情信息
+     * @param goodsId 商品ID
+     * @param position 经纬度
+     * @return 商品详情信息
+     */
+    SecondGoodsRecommendVo querySecondGoodsDetail(Integer goodsId, String position) throws Exception;
 
 
 }

+ 9 - 2
alien-second/src/main/java/shop/alien/second/service/impl/SecondGoodsCategoryServiceImpl.java

@@ -2,6 +2,7 @@ package shop.alien.second.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import shop.alien.entity.second.SecondGoodsCategory;
@@ -13,6 +14,7 @@ import java.util.List;
 /**
  * 二手商品服务实现类
  */
+@Slf4j
 @Service
 @RequiredArgsConstructor
 public class SecondGoodsCategoryServiceImpl extends ServiceImpl<SecondGoodsCategoryMapper, SecondGoodsCategory> implements SecondGoodsCategoryService {
@@ -25,7 +27,12 @@ public class SecondGoodsCategoryServiceImpl extends ServiceImpl<SecondGoodsCateg
      * @return 是否成功保存
      */
     @Override
-    public List<SecondGoodsCategory> querySecondGoodsByParentId(Integer parentId) {
-        return mapper.querySecondGoodsByParentId(parentId);
+    public List<SecondGoodsCategory> querySecondGoodsByParentId(Integer parentId) throws Exception {
+        try {
+            return mapper.querySecondGoodsByParentId(parentId);
+        } catch (Exception e) {
+            log.error("SecondGoodsCategoryServiceImpl.querySecondGoodsByParentId Error Mgs={}", e.getMessage());
+            throw new Exception("查询二级商品分类失败", e);
+        }
     }
 }

+ 154 - 112
alien-second/src/main/java/shop/alien/second/service/impl/SecondRecommendServiceImpl.java

@@ -2,28 +2,43 @@ package shop.alien.second.service.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.flogger.Flogger;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.util.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import shop.alien.entity.second.vo.SecondGoodsRecommendVo;
+import shop.alien.entity.store.LifeFans;
 import shop.alien.entity.store.StoreComment;
+import shop.alien.entity.store.StoreImg;
+import shop.alien.mapper.LifeFansMapper;
+import shop.alien.mapper.StoreImgMapper;
 import shop.alien.mapper.second.SecondRecommendMapper;
 import shop.alien.second.service.SecondRecommendService;
 import shop.alien.util.common.JwtUtil;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.stream.Collectors;
 
 /**
  * 二手商品服务实现类
  */
+@Slf4j
 @Service
 public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMapper, SecondGoodsRecommendVo> implements SecondRecommendService {
 
     @Autowired
     private SecondRecommendMapper mapper;
+
+    @Autowired
+    private StoreImgMapper storeImgMapper;
+
+    @Autowired
+    private LifeFansMapper lifeFansMapper;
     /**
      * 获取二手商品推荐列表
      * @param page 分页信息
@@ -31,26 +46,28 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
      */
     @Override
     public IPage<SecondGoodsRecommendVo> getSecondRecommendByPage(
-            IPage<SecondGoodsRecommendVo> page, String longitude, String latitude, Integer typeId) {
-        JSONObject data = JwtUtil.getCurrentUserInfo();
-        Integer userId = null;
-        if (data != null) {
-            userId = data.getInteger("userId");
-        }
-        if (userId == null) {
-            return null;
-        }
-        IPage<SecondGoodsRecommendVo> result = mapper.getSecondRecommendByPage(page, userId, longitude + "," + latitude, typeId);
-        for (SecondGoodsRecommendVo row : result.getRecords()){
-            if (StringUtil.isNotBlank(row.getDist())) {
-                row.setPosition("距离" + row.getDist() + "km");
+            IPage<SecondGoodsRecommendVo> page, String longitude, String latitude, Integer typeId) throws Exception {
+        try{
+            JSONObject data = JwtUtil.getCurrentUserInfo();
+            Integer userId = null;
+            if (data != null) {
+                userId = data.getInteger("userId");
+                log.info("获取用户ID:userId={}", userId);
             }
-            if (StringUtil.isNotBlank(row.getTopic())) {
-                List<String> topicList = Arrays.asList(row.getTopic().split(","));
-                row.setTopicList(topicList);
+            if (userId == null) {
+                return null;
             }
+            IPage<SecondGoodsRecommendVo> result = mapper.getSecondRecommendByPage(page, userId, longitude + "," + latitude, typeId);
+            for (SecondGoodsRecommendVo row : result.getRecords()) {
+                if (StringUtil.isNotBlank(row.getDist())) {
+                    row.setPosition("距离" + row.getDist() + "km");
+                }
+            }
+            return result;
+        } catch (Exception e) {
+            log.error("SecondRecommendServiceImpl.getSecondRecommendByPage Error Mgs={}", e.getMessage());
+            throw new Exception(e);
         }
-        return result;
     }
 
     /**
@@ -59,45 +76,46 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
      * @return 关注列表
      */
     public IPage<SecondGoodsRecommendVo> querySecondConcernByPage(
-            IPage<SecondGoodsRecommendVo> page, String position) {
-        JSONObject data = JwtUtil.getCurrentUserInfo();
-        String phoneId = null;
-        if (data != null) {
-            phoneId = data.getString("phone");
-        }
-        if (StringUtil.isBlank(phoneId)) {
-            return null;
-        }
-        IPage<SecondGoodsRecommendVo> list = mapper.querySecondConcernByPage(page, "user_" + phoneId, position);
-        List<Integer> idList = list.getRecords().stream() // 创建流
-                .map(obj -> obj.getId())   // 提取每个元素的 ID
-                .collect(Collectors.toList());
-        if (CollectionUtil.isEmpty(idList)) {
-            return list;
-        }
-        List<StoreComment> commentList =mapper.querySecondCommentInfo(idList);
-        list.getRecords().forEach(item -> {
-            // 距离拼接
-            if (StringUtil.isNotBlank(item.getDist())) {
-                item.setPosition("距离" + item.getDist() + "km");
+            IPage<SecondGoodsRecommendVo> page, String position) throws Exception {
+        try {
+            JSONObject data = JwtUtil.getCurrentUserInfo();
+            String phoneId = null;
+            if (data != null) {
+                phoneId = data.getString("phone");
             }
-            // 话题列表
-            if (StringUtil.isNotBlank(item.getTopic())) {
-                List<String> topicList = Arrays.asList(item.getTopic().split(","));
-                item.setTopicList(topicList);
+            if (StringUtil.isBlank(phoneId)) {
+                return null;
             }
-            // 评论列表
-            List<StoreComment> cList = new ArrayList<>();
-            commentList.forEach(comment -> {
-                if (item.getId() == comment.getBusinessId()) {
-                    cList.add(comment);
+            IPage<SecondGoodsRecommendVo> list = mapper.querySecondConcernByPage(page, "user_" + phoneId, position);
+            List<Integer> idList = list.getRecords().stream() // 创建流
+                    .map(obj -> obj.getId())   // 提取每个元素的 ID
+                    .collect(Collectors.toList());
+            if (CollectionUtil.isEmpty(idList)) {
+                return list;
+            }
+            List<StoreComment> commentList =mapper.querySecondCommentInfo(idList);
+            list.getRecords().forEach(item -> {
+                // 距离拼接
+                if (StringUtil.isNotBlank(item.getDist())) {
+                    item.setPosition("距离" + item.getDist() + "km");
+                }
+
+                // 评论列表
+                List<StoreComment> cList = new ArrayList<>();
+                commentList.forEach(comment -> {
+                    if (item.getId() == comment.getBusinessId()) {
+                        cList.add(comment);
+                    }
+                });
+                if (cList.size() > 0) {
+                    item.setCommentList(cList);
                 }
             });
-            if (cList.size() > 0) {
-                item.setCommentList(cList);
-            }
-        });
-        return list;
+            return list;
+        } catch (Exception e){
+            log.error("SecondRecommendServiceImpl.querySecondConcernByPage Error Mgs={}", e.getMessage());
+            throw new Exception(e);
+        }
     }
 
 
@@ -107,70 +125,94 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
      * @return 关注列表
      */
     public IPage<SecondGoodsRecommendVo> querySecondNewGoodsByPage(
-            IPage<SecondGoodsRecommendVo> page, String position) {
-        JSONObject data = JwtUtil.getCurrentUserInfo();
-        String phoneId = null;
-        String userId = null;
-        if (data != null) {
-            phoneId = data.getString("phone");
-            userId = data.getString("userId");
-        }
-        if (StringUtil.isBlank(phoneId)) {
-            return null;
-        }
-        IPage<SecondGoodsRecommendVo> list = mapper.querySecondNewGoodsByPage(page, userId,"user_" + phoneId, position);
-        List<Integer> idList = list.getRecords().stream() // 创建流
-                .map(obj -> obj.getId())   // 提取每个元素的 ID
-                .collect(Collectors.toList());
-        if (CollectionUtil.isEmpty(idList)) {
-            return list;
-        }
-        List<StoreComment> commentList =mapper.querySecondCommentInfo(idList);
-        list.getRecords().forEach(item -> {
-            // 距离拼接
-            if (StringUtil.isNotBlank(item.getDist())) {
-                item.setPosition("距离" + item.getDist() + "km");
+            IPage<SecondGoodsRecommendVo> page, String position) throws Exception{
+        try {
+            JSONObject data = JwtUtil.getCurrentUserInfo();
+            String phoneId = null;
+            String userId = null;
+            if (data != null) {
+                phoneId = data.getString("phone");
+                userId = data.getString("userId");
+            }
+            if (StringUtil.isBlank(phoneId)) {
+                return null;
             }
-            // 话题列表
-            if (StringUtil.isNotBlank(item.getTopic())) {
-                List<String> topicList = Arrays.asList(item.getTopic().split(","));
-                item.setTopicList(topicList);
+            IPage<SecondGoodsRecommendVo> list = mapper.querySecondNewGoodsByPage(page, userId,"user_" + phoneId, position);
+            List<Integer> idList = list.getRecords().stream() // 创建流
+                    .map(obj -> obj.getId())   // 提取每个元素的 ID
+                    .collect(Collectors.toList());
+            if (CollectionUtil.isEmpty(idList)) {
+                return list;
             }
-            // 评论列表
-            List<StoreComment> cList = new ArrayList<>();
-            commentList.forEach(comment -> {
-                if (item.getId() == comment.getBusinessId()) {
-                    cList.add(comment);
+            List<StoreComment> commentList = mapper.querySecondCommentInfo(idList);
+            list.getRecords().forEach(item -> {
+                // 距离拼接
+                if (StringUtil.isNotBlank(item.getDist())) {
+                    item.setPosition("距离" + item.getDist() + "km");
+                }
+
+                // 评论列表
+                List<StoreComment> cList = new ArrayList<>();
+                commentList.forEach(comment -> {
+                    if (item.getId() == comment.getBusinessId()) {
+                        cList.add(comment);
+                    }
+                });
+                if (cList.size() > 0) {
+                    item.setCommentList(cList);
                 }
             });
-            if (cList.size() > 0) {
-                item.setCommentList(cList);
-            }
-        });
-        return list;
+            return list;
+        } catch (Exception e) {
+            log.error("SecondRecommendServiceImpl.querySecondNewGoodsByPage Error Mgs={}", e.getMessage());
+            throw new Exception(e);
+        }
     }
-    public static void main(String[] args) {
-        List<Map<String, Object>> list = new ArrayList<>();
-        Map<String, Object> map = new HashMap<>();
-        map.put("id", 1);
-        map.put("name", "张三");
-        list.add(map);
-        Map<String, Object> map1 = new HashMap<>();
-        map1.put("id", 2);
-        map1.put("name", "张三");
-        list.add(map1);
-        Map<String, Object> map2 = new HashMap<>();
-        map2.put("id", 3);
-        map2.put("name", "张三");
-        list.add(map2);
-        Map<String, Object> map3 = new HashMap<>();
-        map3.put("id", 4);
-        map3.put("name", "张三");
-        list.add(map3);
-        List<String> idList = list.stream() // 创建流
-                .map(obj -> obj.get("id").toString())   // 提取每个元素的 ID
-                .collect(Collectors.toList());
 
-        System.out.println(idList);
+    public SecondGoodsRecommendVo querySecondGoodsDetail(Integer goodsId, String position) throws Exception {
+        try {
+            JSONObject data = JwtUtil.getCurrentUserInfo();
+            String phoneId = null;
+            if (data != null) {
+                phoneId = data.getString("phone");
+            }
+            if (StringUtil.isBlank(phoneId)) {
+                return null;
+            }
+            SecondGoodsRecommendVo item = mapper.querySecondGoodsDetail(goodsId, "user_" + phoneId, position);
+
+            // 设置图片信息
+            QueryWrapper<StoreImg> query = new QueryWrapper<>();
+            query.lambda()
+                    .eq(StoreImg::getImgType, 18) // 商品 图片
+                    .eq(StoreImg::getDeleteFlag, 0)
+                    .eq(StoreImg::getStoreId, goodsId);
+            List<StoreImg> storeImgs = storeImgMapper.selectList(query);
+            // 设置图片信息
+            if (storeImgs.size() > 0) {
+                item.setImgList(storeImgs.stream().map(StoreImg::getImgUrl).toArray(String[]::new));
+            }
+
+            // 查看是否关注
+            QueryWrapper<LifeFans> query1 = new QueryWrapper<>();
+            query1.lambda()
+                    .eq(LifeFans::getFollowedId, item.getUserPhone()) // 商品 图片
+                    .eq(LifeFans::getDeleteFlag, 0)
+                    .eq(LifeFans::getFansId, "user_" + phoneId);
+            List<LifeFans> lifeFans = lifeFansMapper.selectList(query1);
+            // 关注状态添加
+            if (lifeFans.size() > 0) {
+                item.setFansStatus(1);
+            }
+
+            // 距离拼接
+            if (StringUtil.isNotBlank(item.getDist())) {
+                item.setPosition("距离" + item.getDist() + "km");
+            }
+            return item;
+        } catch (Exception e) {
+            log.error("SecondRecommendServiceImpl.querySecondGoodsDetail Error Mgs={}", e.getMessage());
+            throw new Exception(e);
+        }
     }
 }

+ 7 - 5
alien-store/src/main/java/shop/alien/store/controller/LifeCollectController.java

@@ -209,7 +209,7 @@ public class LifeCollectController {
         lifeCollect.setCreatedTime(new Date());
         int num = lifeCollectMapper.insert(lifeCollect);
         // 二手商品收藏数量+1
-        if (StringUtil.isBlank(lifeCollect.getBusinessType()) && lifeCollect.getBusinessType().equals(1)) {
+        if (StringUtil.isNotBlank(lifeCollect.getBusinessType()) && lifeCollect.getBusinessType().equals("1")) {
             LambdaUpdateWrapper<SecondGoods> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
             lambdaUpdateWrapper.eq(SecondGoods::getId, lifeCollect.getBusinessId());
             lambdaUpdateWrapper.setSql("collect_count = collect_count + 1");
@@ -224,7 +224,9 @@ public class LifeCollectController {
     @ApiOperation("取消收藏")
     @ApiOperationSupport(order = 3)
     @ApiImplicitParams({@ApiImplicitParam(name = "userId", value = "用户id", dataType = "String", paramType = "query"),
-            @ApiImplicitParam(name = "storeId", value = "storeId", dataType = "String", paramType = "query")})
+            @ApiImplicitParam(name = "storeId", value = "店铺id", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "businessId", value = "业务id", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "businessType", value = "业务类型", dataType = "String", paramType = "query")})
     @PostMapping("cancelCollect")
     public R<Boolean> cancelCollect(
             @RequestParam(value = "userId", required = false) String userId,
@@ -232,7 +234,7 @@ public class LifeCollectController {
             @RequestParam(value = "businessId", required = false) String businessId,
             @RequestParam(value = "businessType", required = false) String businessType,
             @RequestParam(value = "couponId", required = false) String couponId) {
-        log.info("LifeCollectController.cancelCollect?userId={},storeId={}", userId, storeId);
+        log.info("LifeCollectController.cancelCollect?userId={},storeId={},businessId={},businessType={}", userId, storeId, businessId, businessType);
         LambdaUpdateWrapper<LifeCollect> wrapper = new LambdaUpdateWrapper<>();
         wrapper.eq(LifeCollect::getUserId, userId);
         if(!StringUtils.isEmpty(storeId)) {
@@ -240,7 +242,7 @@ public class LifeCollectController {
         } else if (!StringUtils.isEmpty(couponId)){
             wrapper.eq(LifeCollect::getCouponId, couponId);
         }
-        if (StringUtil.isBlank(businessType) && businessType.equals(1)) {
+        if (StringUtil.isNotBlank(businessType) && businessType.equals("1")) {
             wrapper.eq(LifeCollect::getBusinessId, businessId);
             wrapper.eq(LifeCollect::getBusinessType, businessType);
         } else {
@@ -249,7 +251,7 @@ public class LifeCollectController {
         wrapper.set(LifeCollect::getDeleteFlag, 1);
         int num = lifeCollectMapper.update(null, wrapper);
         // 二手交易收藏数量-1
-        if (StringUtil.isBlank(businessType) && businessType.equals(1)) {
+        if (StringUtil.isNotBlank(businessType) && businessType.equals("1")) {
             // 创建LambdaUpdateWrapper实例用于构建更新条件
             LambdaUpdateWrapper<SecondGoods> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
             // 设置更新条件:根据商品ID匹配且收藏数大于0

+ 1 - 1
alien-store/src/main/java/shop/alien/store/controller/StoreCommentController.java

@@ -104,7 +104,7 @@ public class StoreCommentController {
             @ApiImplicitParam(name = "id", value = "主键", dataType = "Integer", paramType = "query"),
             @ApiImplicitParam(name = "businessId", value = "业务id", dataType = "Integer", paramType = "query"),
             @ApiImplicitParam(name = "businessType", value = "业务类型(1:订单评论, 2:动态社区评论, 3:活动评论, 4:店铺打卡评论, 5:订单评价)", dataType = "Integer", paramType = "query"),
-            @ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query"),
             @ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", paramType = "query", required = true),
             @ApiImplicitParam(name = "replyId", value = "回复id", dataType = "Integer", paramType = "query"),
             @ApiImplicitParam(name = "commentContent", value = "评论内容", dataType = "String", paramType = "query"),

+ 1 - 1
alien-store/src/main/java/shop/alien/store/service/impl/StoreCommentServiceImpl.java

@@ -417,7 +417,7 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
             storeComment.setEvaluationTags(evaluationTags);
             storeComment.setPhoneId(phoneId);
             List<String> fileNameSet = new ArrayList<>(multipartRequest.getMultiFileMap().keySet());
-            if (!fileNameSet.isEmpty()) {
+            if (!fileNameSet.isEmpty() && storeId != null) {
                 StringBuilder imgId = new StringBuilder();
                 for (int i = 0; i < fileNameSet.size(); i++) {
                     MultipartFile multipartFile = multipartRequest.getFileMap().get(fileNameSet.get(i));