Procházet zdrojové kódy

Merge remote-tracking branch 'origin/sit' into sit

wuchen před 2 měsíci
rodič
revize
51170d254f

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

@@ -68,4 +68,16 @@ public class LifeUserDynamicsVo extends LifeUserDynamics {
 
     @ApiModelProperty(value = "商家名称")
     private String storeName;
+
+    @ApiModelProperty(value = "评分")
+    private Double scoreAvg;
+
+     @ApiModelProperty(value = "行业")
+    private String businessSection;
+
+    @ApiModelProperty(value = "评价数量")
+    private String ratingCount;
+
+    @ApiModelProperty(value = "评价类型")
+    private String businessTypeName;
 }

+ 2 - 2
alien-entity/src/main/java/shop/alien/mapper/LifeUserDynamicsMapper.java

@@ -23,7 +23,7 @@ public interface LifeUserDynamicsMapper extends BaseMapper<LifeUserDynamics> {
             "where lud.delete_flag = 0 and lud.enable_status = 0 and lud.draft = 0 and " +
             "not exists (select 1 from life_user_violation luv where luv.delete_flag = 0 and luv.processing_status = 1 " +
             "AND luv.dynamics_id = lud.id) order by lud.created_time desc) " +
-            "select dynamice.*, info.store_name userName, user.head_img userImage, info.id storeUserId, user.id storeOrUserId, 0 isExpert " +
+            "select dynamice.*, info.store_name userName, user.head_img userImage, info.id storeUserId, user.id storeOrUserId, 0 isExpert, info.score_avg scoreAvg, info.business_section businessSection, info.business_type_name businessTypeName " +
             "from dynamice " +
             "join store_user user on dynamice.phone = user.phone and user.delete_flag = 0 " +
             "and user.status = 0 and user.logout_flag = 0 " +
@@ -33,7 +33,7 @@ public interface LifeUserDynamicsMapper extends BaseMapper<LifeUserDynamics> {
             "where dynamice.flag = 'store' " +
             "union " +
             "select dynamice.*, user.user_name userName, user.user_image userImage, user.id storeUserId, user.id storeOrUserId, " +
-            "IF(lue.expert_code IS NOT NULL , 1, 0) AS isExpert " +
+            "IF(lue.expert_code IS NOT NULL , 1, 0) AS isExpert, 0 scoreAvg, 0 businessSection, 0 businessTypeName " +
             "from dynamice " +
             "join life_user user on dynamice.phone = user.user_phone and user.delete_flag = 0 " +
             "and user.logout_flag = 0 " +

+ 6 - 9
alien-job/src/main/java/shop/alien/job/store/BadReviewAppealJob.java

@@ -273,16 +273,13 @@ public class BadReviewAppealJob {
             analyzeRequest.put("user_material",
                     storeCommentAppeal.get("comment_content") == null ? "" : storeCommentAppeal.get("comment_content").toString());
 
-            // 商家图片:支持多张,转成 Base64 数组
+            // 商家图片:支持多张,直接使用图片URL
             List<String> merchantImages = new ArrayList<>();
             String imgUrls = storeCommentAppeal.get("img_url") == null ? "" : storeCommentAppeal.get("img_url").toString();
             if (StringUtils.hasText(imgUrls)) {
                 // 假设 img_url 是多个图片用逗号分隔的字符串
                 for (String imageUrl : imgUrls.split(",")) {
-                    String base64 = convertImageToBase64(imageUrl.trim());
-                    if (StringUtils.hasText(base64)) {
-                        merchantImages.add(base64);
-                    }
+                    merchantImages.add(imageUrl.trim());
                 }
             }
             analyzeRequest.put("merchant_images", merchantImages);
@@ -292,11 +289,11 @@ public class BadReviewAppealJob {
             String userImgUrls = storeCommentAppeal.get("user_img_url") == null ? "" : storeCommentAppeal.get("user_img_url").toString();
             if (StringUtils.hasText(userImgUrls)) {
                 for (String imageUrl : userImgUrls.split(",")) {
-                    String base64 = convertImageToBase64(imageUrl.trim());
-                    if (StringUtils.hasText(base64)) {
-                        userImages.add(base64);
+//                    String base64 = convertImageToBase64(imageUrl.trim());
+//                    if (StringUtils.hasText(base64)) {
+                        userImages.add(imageUrl.trim());
                     }
-                }
+//                }
             }
             analyzeRequest.put("user_images", userImages);
 

+ 2 - 5
alien-store-platform/src/main/java/shop/alien/storeplatform/controller/StorePlatformUserRoleController.java

@@ -131,15 +131,12 @@ public class StorePlatformUserRoleController {
     public R<String> createAccountAndAssignRole(@RequestBody CreateAccountDto createAccountDto) {
         log.info("StorePlatformUserRoleController.createAccountAndAssignRole?phone={}, accountName={}, storeId={}, roleId={}", 
                 createAccountDto.getPhone(), createAccountDto.getAccountName(), createAccountDto.getStoreId(), createAccountDto.getRoleId());
-        boolean result = storePlatformUserRoleService.createAccountAndAssignRole(
+        R<String> result = storePlatformUserRoleService.createAccountAndAssignRole(
                 createAccountDto.getPhone(), 
                 createAccountDto.getAccountName(), 
                 createAccountDto.getStoreId(), 
                 createAccountDto.getRoleId());
-        if (result) {
-            return R.success("创建账号并分配角色成功");
-        }
-        return R.fail("创建账号并分配角色失败");
+        return result;
     }
 
 

+ 2 - 1
alien-store-platform/src/main/java/shop/alien/storeplatform/service/StorePlatformUserRoleService.java

@@ -1,6 +1,7 @@
 package shop.alien.storeplatform.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import shop.alien.entity.result.R;
 import shop.alien.entity.store.StorePlatformUserRole;
 import shop.alien.entity.store.vo.SubAccountDetailVo;
 import shop.alien.entity.store.vo.SubAccountVo;
@@ -73,7 +74,7 @@ public interface StorePlatformUserRoleService extends IService<StorePlatformUser
      * @param roleId      角色ID
      * @return 是否成功
      */
-    boolean createAccountAndAssignRole(String phone, String accountName, Integer storeId, Long roleId);
+    R<String> createAccountAndAssignRole(String phone, String accountName, Integer storeId, Long roleId);
 
     /**
      * 查询当前店铺下的子账号列表

+ 10 - 9
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/StorePlatformUserRoleServiceImpl.java

@@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import shop.alien.entity.result.R;
 import shop.alien.entity.store.StorePlatformMenu;
 import shop.alien.entity.store.StorePlatformRole;
 import shop.alien.entity.store.StorePlatformUserRole;
@@ -215,10 +216,10 @@ public class StorePlatformUserRoleServiceImpl extends ServiceImpl<StorePlatformU
 
 
     @Override
-    public boolean createAccountAndAssignRole(String phone, String accountName, Integer storeId, Long roleId) {
+    public R<String> createAccountAndAssignRole(String phone, String accountName, Integer storeId, Long roleId) {
         if (phone == null || phone.isEmpty() || storeId == null || roleId == null) {
             log.error("参数不能为空: phone={}, storeId={}, roleId={}", phone, storeId, roleId);
-            return false;
+            return R.fail("参数不能为空");
         }
 
         try {
@@ -239,7 +240,7 @@ public class StorePlatformUserRoleServiceImpl extends ServiceImpl<StorePlatformU
                 
                 if (existingSubAccount != null) {
                     log.error("该手机号在当前店铺已存在子账号,不支持创建: phone={}, storeId={}", phone, storeId);
-                    return false;
+                    return R.fail("该手机号在当前店铺已存在子账号,不支持创建");
                 }
             }
             
@@ -253,7 +254,7 @@ public class StorePlatformUserRoleServiceImpl extends ServiceImpl<StorePlatformU
                 
                 if (existingAccountName != null) {
                     log.error("该账号名称在当前店铺已存在子账号,不支持创建: accountName={}, storeId={}", accountName, storeId);
-                    return false;
+                    return R.fail("该账号名称在当前店铺已存在子账号,不支持创建");
                 }
             }
 
@@ -267,7 +268,7 @@ public class StorePlatformUserRoleServiceImpl extends ServiceImpl<StorePlatformU
                 int storeIdNew = storeUser.getStoreId();
                 if (storeIdNew == storeId) {
                     log.error("该手机号为当前当前店铺手机号,请勿重复创建: phone={}, storeId={}", phone, storeId);
-                    return false;
+                    return R.fail("该手机号为当前当前店铺手机号,请勿重复创建");
                 }
             }
 
@@ -292,7 +293,7 @@ public class StorePlatformUserRoleServiceImpl extends ServiceImpl<StorePlatformU
                 int insertResult = storeUserMapper.insert(newUser);
                 if (insertResult <= 0) {
                     log.error("插入 store_user 表失败: phone={}", phone);
-                    return false;
+                    return R.fail("创建子账号失败");
                 }
                 userId = newUser.getId();
                 log.info("成功创建新用户: phone={}, userId={}", phone, userId);
@@ -321,17 +322,17 @@ public class StorePlatformUserRoleServiceImpl extends ServiceImpl<StorePlatformU
                 boolean insertRoleResult = this.save(userRole);
                 if (!insertRoleResult) {
                     log.error("插入 store_platform_user_role 表失败: userId={}, storeId={}, roleId={}", userId, storeId, roleId);
-                    return false;
+                    return R.fail("创建子账号失败");
                 }
                 log.info("成功分配角色: userId={}, storeId={}, roleId={}", userId, storeId, roleId);
             } else {
                 log.info("用户角色关系已存在: userId={}, storeId={}, roleId={}", userId, storeId, roleId);
             }
 
-            return true;
+            return R.success("创建子账号成功");
         } catch (Exception e) {
             log.error("创建账号并分配角色失败: phone={}, storeId={}, roleId={}", phone, storeId, roleId, e);
-            return false;
+            return R.fail("创建账号并分配角色失败");
         }
     }
 

+ 33 - 0
alien-store/src/main/java/shop/alien/store/service/LifeUserDynamicsService.java

@@ -54,6 +54,8 @@ public class LifeUserDynamicsService extends ServiceImpl<LifeUserDynamicsMapper,
 
     private final CommonCommentMapper commonCommentMapper;
 
+    private final CommonRatingService commonRatingService;
+
     public int addLiulanCount(String id) {
         LambdaUpdateWrapper<LifeUserDynamics> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
         lambdaUpdateWrapper.eq(LifeUserDynamics::getId, id);
@@ -157,13 +159,38 @@ public class LifeUserDynamicsService extends ServiceImpl<LifeUserDynamicsMapper,
         // 查询动态数据并按类型过滤
         List<LifeUserDynamicsVo> lifeUserDynamicsVoList = lifeUserDynamicsMapper.getLifeUserDynamicsList();
 
+        // 店铺id
+        // TODO 可以优化小驴:优化方案直接sql分组查询评价数量,避免循环查询
+        List<String> storeUserIdList = new ArrayList<>();
+        Map<String, Integer> commitCountMap = new HashMap<>();
         //对lifeUserDynamicsVoList数据进行处理,当type为2的时候,把userName的数值赋值到storeName
         lifeUserDynamicsVoList.forEach(item -> {
             if (item.getType().equals("2")) {
                 item.setStoreName(item.getUserName());
+                storeUserIdList.add(item.getStoreUserId());
             }
         });
 
+        for (String storeId : storeUserIdList) {
+            Integer totalCount = 0;
+            double storeScore;
+            Object ratingObj =  commonRatingService.getRatingCount(Integer.parseInt(storeId), 1);
+            if (ratingObj != null) {
+                Map<String, Object> ratingMap = (Map<String, Object>) ratingObj;
+                Object totalCountObj = ratingMap.get("totalCount");
+                if (totalCountObj != null) {
+                    // 安全转换为整数
+                    try {
+                        totalCount = Integer.parseInt(totalCountObj.toString().trim());
+                    } catch (NumberFormatException e) {
+                        totalCount = 0; // 转换失败时默认值
+                    }
+                } else {
+                    totalCount = 0;
+                }
+            }
+            commitCountMap.put(storeId, totalCount);
+        }
         if (!StringUtils.isEmpty(type)) {
             lifeUserDynamicsVoList = lifeUserDynamicsVoList.stream().filter(item -> type.equals(item.getType())).collect(Collectors.toList());
         }
@@ -207,6 +234,12 @@ public class LifeUserDynamicsService extends ServiceImpl<LifeUserDynamicsMapper,
         // 设置动态对象的状态信息:是否关注对方、是否被关注、是否点赞及评论数量
         // 设置.imagePath。视频为mp4+jpg格式,图片为jpg/png格式。
         for (LifeUserDynamicsVo vo : lifeUserDynamicsVoList) {
+            // 设置评价数量
+            if (commitCountMap.containsKey(vo.getStoreUserId())) {
+                vo.setRatingCount(commitCountMap.get(vo.getStoreUserId()).toString());
+            } else {
+                vo.setRatingCount("0");
+            }
             if (followList.contains(vo.getPhoneId())) {
                 vo.setIsFollowThis("1");
             } else {