From e50954f0708ecbbc672352102ae3b24279d40cc1 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期四, 16 四月 2026 20:12:50 +0800
Subject: [PATCH] Merge branch 'master' of http://139.186.142.91:10010/r/productDev/gtzxinglijicun

---
 server/services/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java |  101 +++++++++++++++++++++++++++++++++-----------------
 1 files changed, 66 insertions(+), 35 deletions(-)

diff --git a/server/services/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java b/server/services/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java
index 56d9001..46ee50f 100644
--- a/server/services/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java
@@ -11,7 +11,9 @@
 import com.doumee.core.model.PageWrap;
 import com.doumee.core.utils.Utils;
 import com.doumee.dao.business.CategoryMapper;
+import com.doumee.dao.business.PricingRuleMapper;
 import com.doumee.dao.business.model.Category;
+import com.doumee.dao.business.model.PricingRule;
 import com.doumee.dao.system.model.SystemUser;
 import com.doumee.service.business.CategoryService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -44,6 +46,9 @@
     private CategoryMapper categoryMapper;
 
     @Autowired
+    private PricingRuleMapper pricingRuleMapper;
+
+    @Autowired
     private SystemDictDataBiz systemDictDataBiz;
 
     @Override
@@ -52,24 +57,17 @@
         if(Objects.isNull(category)
         || Objects.isNull(category.getType())
         || Objects.isNull(category.getName())
-        || (!Constants.equalsInteger(category.getType(),Constants.ZERO)&& CollectionUtils.isEmpty(category.getDetailList()))
-        || (Constants.equalsInteger(category.getType(),Constants.ONE) && (Objects.isNull(category.getIcon())||Objects.isNull(category.getIsFixed())) )
+        || StringUtils.isBlank(category.getDetail())
         ){
             throw new BusinessException(ResponseStatus.BAD_REQUEST);
         }
+        validateByType(category);
         LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
         category.setDeleted(Constants.ZERO);
         category.setCreateTime(new Date());
         category.setCreateUser(loginUserInfo.getId());
         category.setUpdateTime(new Date());
         category.setUpdateUser(loginUserInfo.getId());
-        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(category.getDetailList())
-                && !Constants.equalsInteger(category.getType(),Constants.THREE)){
-            category.setDetail(category.getDetailList().toJSONString());
-        }
-        if(!Constants.equalsInteger(category.getType(),Constants.ONE)){
-            category.setIsFixed(Constants.ZERO);
-        }
         categoryMapper.insert(category);
         return category.getId();
     }
@@ -102,19 +100,14 @@
                 || Objects.isNull(category.getId())
                 || Objects.isNull(category.getType())
                 || Objects.isNull(category.getName())
-                || (!Constants.equalsInteger(category.getType(),Constants.ZERO)&& CollectionUtils.isEmpty(category.getDetailList()))
-                || (Constants.equalsInteger(category.getType(),Constants.ONE) && (Objects.isNull(category.getIcon())||Objects.isNull(category.getIsFixed())) )
+                || StringUtils.isBlank(category.getDetail())
         ){
             throw new BusinessException(ResponseStatus.BAD_REQUEST);
         }
+        validateByType(category);
         LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
         category.setUpdateTime(new Date());
-        category.setIsFixed(null);
         category.setUpdateUser(loginUserInfo.getId());
-        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(category.getDetailList())
-                && !Constants.equalsInteger(category.getType(),Constants.THREE)){
-            category.setDetail(category.getDetailList().toJSONString());
-        }
         categoryMapper.updateById(category);
     }
     @Override
@@ -125,11 +118,7 @@
         }
         LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
         category.setUpdateTime(new Date());
-        category.setIsFixed(null);
         category.setUpdateUser(loginUserInfo.getId());
-        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(category.getDetailList())){
-            category.setDetail(category.getDetailList().toJSONString());
-        }
         categoryMapper.updateById(category);
     }
 
@@ -149,11 +138,8 @@
         if(Objects.isNull(category)){
             throw new BusinessException(ResponseStatus.DATA_EMPTY);
         }
-        if(StringUtils.isNotBlank(category.getDetail())){
-            category.setDetailList(JSONArray.parseArray(category.getDetail()));
-        }
         if(StringUtils.isNotBlank(category.getIcon())){
-            String path  = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RESOURCE_PATH).getCode()
+            String path  = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()
                     +systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.CATEGORY_FILES).getCode();
             category.setIconFull(path + category.getIcon());
         }
@@ -219,19 +205,13 @@
         if (pageWrap.getModel().getIcon() != null) {
             queryWrapper.eq(Category::getIcon, pageWrap.getModel().getIcon());
         }
-        if (pageWrap.getModel().getIsFixed() != null) {
-            queryWrapper.eq(Category::getIsFixed, pageWrap.getModel().getIsFixed());
-        }
         queryWrapper.orderByAsc(Category::getSortnum);
         PageData<Category> result =PageData.from(categoryMapper.selectJoinPage(page, Category.class,queryWrapper));
         if(result!=null && result.getRecords()!=null){
-            String path  = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RESOURCE_PATH).getCode()
+            String path  = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()
                     +systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.CATEGORY_FILES).getCode();
             for(Category cate : result.getRecords()){
                 try {
-                    if(StringUtils.isNotBlank(cate.getDetail())){
-                        cate.setDetailList(JSONArray.parseArray(cate.getDetail()));
-                    }
                     if(StringUtils.isNotBlank(cate.getIcon())){
                         cate.setIconFull(path + cate.getIcon());
                     }
@@ -256,12 +236,9 @@
                 .orderByAsc(Category::getSortnum)
         );
         if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(categoryList)){
-            String path  = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RESOURCE_PATH).getCode()
+            String path  = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()
                     +systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.CATEGORY_FILES).getCode();
             for (Category category:categoryList) {
-                if(StringUtils.isNotBlank(category.getDetail())){
-                    category.setDetailList(JSONArray.parseArray(category.getDetail()));
-                }
                 if(StringUtils.isNotBlank(category.getIcon())){
                     category.setIconFull(path + category.getIcon());
                 }
@@ -270,5 +247,59 @@
         return categoryList;
     }
 
+    @Override
+    public List<Category> getCitySizeList(Integer cityId) {
+        // 1. 鏌ヨ璇ュ煄甯傚凡閰嶇疆鐨勫紓鍦板瘎閫佽鍒�(pricing_rule type=1)锛岃幏鍙杅ieldA(鐗╁搧灏哄涓婚敭)
+        List<PricingRule> rules = pricingRuleMapper.selectList(new QueryWrapper<PricingRule>().lambda()
+                .eq(PricingRule::getDeleted, Constants.ZERO)
+                .eq(PricingRule::getType, Constants.ONE)
+                .eq(PricingRule::getCityId, cityId));
+        if (CollectionUtils.isEmpty(rules)) {
+            return java.util.Collections.emptyList();
+        }
+        List<Integer> sizeIds = new java.util.ArrayList<>();
+        for (PricingRule rule : rules) {
+            if (StringUtils.isNotBlank(rule.getFieldA())) {
+                sizeIds.add(Integer.parseInt(rule.getFieldA()));
+            }
+        }
+        if (sizeIds.isEmpty()) {
+            return java.util.Collections.emptyList();
+        }
+        // 2. 鏌ヨ瀵瑰簲鐨勭墿鍝佸昂瀵�(category type=4)
+        List<Category> sizeList = categoryMapper.selectList(new QueryWrapper<Category>().lambda()
+                .eq(Category::getDeleted, Constants.ZERO)
+                .eq(Category::getStatus, Constants.ZERO)
+                .eq(Category::getType, Constants.FOUR)
+                .in(Category::getId, sizeIds)
+                .orderByAsc(Category::getSortnum));
+        // 3. 鎷兼帴鍥炬爣鍏ㄨ矾寰�
+        if (!CollectionUtils.isEmpty(sizeList)) {
+            String path = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.RESOURCE_PATH).getCode()
+                    + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.CATEGORY_FILES).getCode();
+            for (Category cate : sizeList) {
+                if (StringUtils.isNotBlank(cate.getIcon())) {
+                    cate.setIconFull(path + cate.getIcon());
+                }
+            }
+        }
+        return sizeList;
+    }
+
+    private void validateByType(Category category) {
+        if (Constants.equalsInteger(category.getType(), Constants.ONE)) {
+            if (StringUtils.isBlank(category.getOtherField())) {
+                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "杞﹁締绫诲瀷蹇呴』濉啓闄勫睘瀛楁");
+            }
+        } else if (Constants.equalsInteger(category.getType(), Constants.TWO)) {
+            if (Objects.isNull(category.getRelationId())) {
+                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鐗╁搧鍒嗙被蹇呴』閫夋嫨鍏宠仈鐗╁搧绛夌骇");
+            }
+        } else if (Constants.equalsInteger(category.getType(), Constants.FOUR)) {
+            if (StringUtils.isBlank(category.getIcon())) {
+                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "鐗╁搧灏哄蹇呴』涓婁紶鍥炬爣");
+            }
+        }
+    }
 
 }

--
Gitblit v1.9.3