Pārlūkot izejas kodu

中台 店铺编辑

qxy 1 nedēļu atpakaļ
vecāks
revīzija
720d4473a1

+ 1 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreThreeLevelStructureVo.java

@@ -30,3 +30,4 @@ public class StoreThreeLevelStructureVo {
 
 }
 
+

+ 12 - 0
alien-store/src/main/java/shop/alien/store/controller/StoreInfoController.java

@@ -128,6 +128,18 @@ public class StoreInfoController {
         return R.fail("失败");
     }
 
+    @ApiOperation("新中台web端修改门店")
+    @ApiOperationSupport(order = 22)
+    @PostMapping("/editNewStoreInfo")
+    public R editNewStoreInfo(@RequestBody StoreInfoDto storeInfoDto) {
+        log.info("StoreInfoController.editStoreInfo?storeInfoDto={}", storeInfoDto);
+        StoreInfoVo storeInfoVo = storeInfoService.editNewStoreInfo(storeInfoDto);
+        if (storeInfoVo != null) {
+            return R.data(storeInfoVo);
+        }
+        return R.fail("失败");
+    }
+
     @ApiOperation("web修改门店抽成")
     @ApiOperationSupport(order = 3)
     @PostMapping("/updateStoreCommissionRate")

+ 7 - 0
alien-store/src/main/java/shop/alien/store/service/StoreInfoService.java

@@ -138,6 +138,13 @@ public interface StoreInfoService extends IService<StoreInfo> {
     StoreInfoVo editStoreInfo(StoreInfoDto storeInfoDto);
 
     /**
+     * 新中台web端修改门店及门店用户
+     *
+     * @return ResponseEntity
+     */
+    StoreInfoVo editNewStoreInfo(StoreInfoDto storeInfoDto);
+
+    /**
      * web端删除门店及门店用户
      *
      * @return ResponseEntity

+ 65 - 0
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -1154,6 +1154,71 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
     }
 
     @Override
+    public StoreInfoVo editNewStoreInfo(StoreInfoDto storeInfoDto) {
+
+        //获取经营板块id
+        Integer businessSection = storeInfoDto.getBusinessSection();
+        //查询经营板块名称
+        StoreDictionary businessSectionName = storeDictionaryMapper.selectOne(new LambdaQueryWrapper<StoreDictionary>().eq(StoreDictionary::getDictId, businessSection).eq(StoreDictionary::getTypeName, "business_section"));
+        //查询经营种类
+        List<String> businessTypes = storeInfoDto.getBusinessTypes();
+        List<String> businessTypeNames = new ArrayList<>();
+        //获取经营种类名称
+        for (String businessType : businessTypes) {
+            StoreDictionary storeDictionary = storeDictionaryMapper.selectOne(new LambdaQueryWrapper<StoreDictionary>().eq(StoreDictionary::getDictId, businessType).eq(StoreDictionary::getParentId, businessSectionName.getId()));
+            businessTypeNames.add(storeDictionary.getDictDetail());
+        }
+
+        StoreInfoVo result = new StoreInfoVo();
+        StoreInfo storeInfo = new StoreInfo();
+        BeanUtils.copyProperties(storeInfoDto, storeInfo);
+//        List<String> storeTypeList = storeInfoDto.getStoreTypeList();
+//        String storeType = String.join(",", storeTypeList);
+        //存入营运类型
+//        storeInfo.setStoreType(storeType);
+
+        //板块及类型
+        storeInfo.setBusinessSection(businessSection);
+        storeInfo.setBusinessSectionName(businessSectionName.getDictDetail());
+        storeInfo.setBusinessTypes(String.join(",", businessTypes));
+        storeInfo.setBusinessTypesName(String.join(",", businessTypeNames));
+
+        //处理分类信息
+        List<String> businessClassify = storeInfoDto.getBusinessClassify();
+        if (!CollectionUtils.isEmpty(businessClassify)) {
+            List<String> businessClassifyNames = new ArrayList<>();
+            //批量查询分类名称
+            List<StoreDictionary> classifyDicts = storeDictionaryMapper.selectList(
+                    new LambdaQueryWrapper<StoreDictionary>()
+                            .in(StoreDictionary::getDictId, businessClassify)
+                            .eq(StoreDictionary::getTypeName, "business_classify")
+                            .eq(StoreDictionary::getDeleteFlag, 0)
+            );
+            //转为Map方便快速获取
+            Map<String, StoreDictionary> classifyDictMap = classifyDicts.stream()
+                    .collect(Collectors.toMap(
+                            dict -> dict.getDictId().toString(),
+                            Function.identity(),
+                            (existing, replacement) -> existing
+                    ));
+            //提取分类名称
+            for (String classifyId : businessClassify) {
+                StoreDictionary dict = classifyDictMap.get(classifyId);
+                if (Objects.nonNull(dict)) {
+                    businessClassifyNames.add(dict.getDictDetail());
+                } else {
+                    log.warn("无效的分类id:" + classifyId);
+                }
+            }
+            storeInfo.setBusinessClassify(String.join(",", businessClassify));
+            storeInfo.setBusinessClassifyName(String.join(",", businessClassifyNames));
+        }
+
+        storeInfoMapper.updateById(storeInfo);
+        return result;
+    }
+
+    @Override
     public String deleteStoreInfo(StoreInfoDto storeInfoDto) {
         StoreUser storeUser = storeUserMapper.selectOne(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getStoreId, storeInfoDto.getId()));
         //判断是否有未完成的订单