Parcourir la source

feat:点赞记录插入修改(user_***修改)

刘云鑫 il y a 5 heures
Parent
commit
254c99e42f

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

@@ -11,15 +11,12 @@ import io.swagger.annotations.*;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.util.StringUtil;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
 import shop.alien.entity.second.SecondGoods;
-import shop.alien.entity.second.vo.SecondCommentVo;
 import shop.alien.entity.second.vo.SecondGoodsRecommendVo;
-import shop.alien.entity.second.vo.SecondGoodsVo;
 import shop.alien.entity.store.*;
 import shop.alien.entity.store.vo.StoreInfoVo;
 import shop.alien.mapper.*;
@@ -27,8 +24,6 @@ import shop.alien.mapper.second.SecondGoodsMapper;
 import shop.alien.mapper.second.SecondRecommendMapper;
 import shop.alien.store.annotation.TrackEvent;
 import shop.alien.store.config.GaoDeMapUtil;
-import shop.alien.store.service.LifeDiscountCouponService;
-import shop.alien.util.common.Constants;
 import shop.alien.util.common.JwtUtil;
 import shop.alien.util.common.ListToPage;
 import shop.alien.util.type.PhoneTypeIdResult;
@@ -36,7 +31,10 @@ import shop.alien.util.type.TypeUtil;
 
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -269,7 +267,7 @@ public class LifeCollectController {
             return;
         }
         String userId = lifeCollect.getUserId().trim();
-        if (!userId.contains("_")) {
+        if ( typeUtil.containsUnderscore(userId) ) {
             try {
                 LifeUser lifeUser = lifeUserMapper.selectById(Integer.parseInt(userId));
                 if (lifeUser == null || org.springframework.util.StringUtils.isEmpty(lifeUser.getUserPhone())) {

+ 13 - 0
alien-store/src/main/java/shop/alien/store/service/LifeCommentService.java

@@ -21,6 +21,8 @@ import shop.alien.mapper.*;
 import shop.alien.mapper.second.SecondGoodsMapper;
 import shop.alien.store.service.clockin.ClockInRecommendCacheService;
 import shop.alien.store.service.dynamics.DynamicsRecommendCacheService;
+import shop.alien.util.type.PhoneTypeIdResult;
+import shop.alien.util.type.TypeUtil;
 
 import java.time.LocalDate;
 import java.time.ZoneId;
@@ -81,6 +83,7 @@ public class LifeCommentService {
 
     private final ClockInRecommendCacheService clockInRecommendCacheService;
 
+    private final TypeUtil typeUtil;
     /**
      * 系统app通知开关
      */
@@ -132,6 +135,16 @@ public class LifeCommentService {
             
             // 插入点赞记录
             LifeLikeRecord lifeLikeRecord = new LifeLikeRecord();
+            if ( typeUtil.containsUnderscore(userId) ) {
+                PhoneTypeIdResult phoneTypeIdResult = typeUtil.resolveTypeAndId(userId);
+                lifeLikeRecord.setDianzanUserType(phoneTypeIdResult.getType());
+                lifeLikeRecord.setDianzanRefId(phoneTypeIdResult.getId());
+            }
+            // 员工点赞特殊处理
+            if( CommonConstant.LIKE_TYPE_STAFF.equals(type) ) {
+                lifeLikeRecord.setDianzanUserType(1);
+                lifeLikeRecord.setDianzanRefId(Integer.parseInt(userId));
+            }
             lifeLikeRecord.setCreatedTime(new Date());
             lifeLikeRecord.setHuifuId(huifuId);
             lifeLikeRecord.setDianzanId(userId);

+ 14 - 0
alien-util/src/main/java/shop/alien/util/type/TypeUtil.java

@@ -125,4 +125,18 @@ public class TypeUtil {
         log.debug("解析律师用户成功: phone={}, id={}", phone, lawyerUser.getId());
         return new PhoneTypeIdResult(TYPE_LAWYER, lawyerUser.getId());
     }
+
+
+    /**
+     * 判断传入的字符串参数是否包含下划线
+     *
+     * @param input 待检测的字符串
+     * @return 如果包含下划线则返回true,否则返回false
+     */
+    public boolean containsUnderscore(String input) {
+        if (input == null) {
+            return false;
+        }
+        return input.contains("_");
+    }
 }