Quellcode durchsuchen

bugfix:解决门店入驻存草稿有字段没存入

penghao vor 3 Monaten
Ursprung
Commit
b4ce4fbc76

+ 21 - 0
alien-entity/src/main/java/shop/alien/entity/store/StoreInfoDraft.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableField;
 import java.io.Serializable;
+import java.util.List;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -187,6 +188,26 @@ public class StoreInfoDraft extends Model<StoreInfoDraft> {
     @TableField("food_licence_url")
     private String foodLicenceUrl;
 
+    @ApiModelProperty(value = "店铺评价")
+    @TableField("store_evaluate")
+    private String storeEvaluate;
+
+    @ApiModelProperty(value = "经营种类名称")
+    @TableField("business_type_name")
+    private String businessTypeName;
+
+    @ApiModelProperty(value = "经营类目名称")
+    @TableField("business_category_name")
+    private String businessCategoryName;
+
+    @ApiModelProperty(value = "其它资质证明(多个URL以逗号分隔,最多9张)")
+    @TableField("other_licenses")
+    private String otherLicenses;
+
+    @ApiModelProperty(value = "其他资质证明图片地址列表(临时字段,用于接收前端数据)")
+    @TableField(exist = false)
+    private List<String> otherQualificationImages;
+
 
     @Override
     protected Serializable pkVal() {

+ 39 - 8
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -1312,16 +1312,29 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                 storeInfoDraft.setAdministrativeRegionDistrictName(essentialCityCode3.getAreaName());
             }
         }
-        if (storeInfoDraft.getBusinessLicenseUrl().isEmpty()) {
+        if (StringUtils.isEmpty(storeInfoDraft.getBusinessLicenseUrl())) {
             storeInfoDraft.setBusinessLicenseUrl(null);
         }
-        if (storeInfoDraft.getContractUrl().isEmpty()) {
-            storeInfoDraft.setContractUrl(null);
-        }
-
-        if (storeInfoDraft.getFoodLicenceUrl().isEmpty()) {
-            storeInfoDraft.setFoodLicenceUrl(null);
+        // if (StringUtils.isEmpty(storeInfoDraft.getContractUrl())) {
+        //     storeInfoDraft.setContractUrl(null);
+        // }
+        // if (StringUtils.isEmpty(storeInfoDraft.getFoodLicenceUrl())) {
+        //     storeInfoDraft.setFoodLicenceUrl(null);
+        // }
+        
+        // 处理其他资质证明图片列表(最多9张),转换为逗号分隔的字符串
+        if (!CollectionUtils.isEmpty(storeInfoDraft.getOtherQualificationImages())) {
+            List<String> otherQualificationImages = storeInfoDraft.getOtherQualificationImages();
+            // 限制最多9张
+            int maxCount = Math.min(otherQualificationImages.size(), 9);
+            List<String> limitedImages = otherQualificationImages.subList(0, maxCount);
+            String otherLicensesStr = String.join(",", limitedImages);
+            storeInfoDraft.setOtherLicenses(otherLicensesStr);
+        } else if (storeInfoDraft.getOtherQualificationImages() != null) {
+            // 如果传入空列表,清空 otherLicenses
+            storeInfoDraft.setOtherLicenses(null);
         }
+        
         return storeInfoDraftMapper.insert(storeInfoDraft);
     }
 
@@ -1331,7 +1344,24 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         wrapper.eq(StoreInfoDraft::getStoreUserId, storeUserId);
         wrapper.orderByDesc(StoreInfoDraft::getCreatedTime);
         List<StoreInfoDraft> list = storeInfoDraftMapper.selectList(wrapper);
-        return CollectionUtils.isEmpty(list) ? null : list.get(0);
+        StoreInfoDraft draft = CollectionUtils.isEmpty(list) ? null : list.get(0);
+        
+        // 将 otherLicenses 字段(逗号分隔的字符串)转换为 otherQualificationImages 列表
+        if (draft != null && StringUtils.isNotEmpty(draft.getOtherLicenses())) {
+            String[] urls = draft.getOtherLicenses().split(",");
+            List<String> otherQualificationImages = new ArrayList<>();
+            for (String url : urls) {
+                if (StringUtils.isNotEmpty(url.trim())) {
+                    otherQualificationImages.add(url.trim());
+                }
+            }
+            draft.setOtherQualificationImages(otherQualificationImages);
+        } else if (draft != null) {
+            // 如果 otherLicenses 为空,设置空列表
+            draft.setOtherQualificationImages(new ArrayList<>());
+        }
+        
+        return draft;
     }
 
     @Override
@@ -6770,3 +6800,4 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
 
 }
 
+