Ver Fonte

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

yjwang há 2 dias atrás
pai
commit
c73456a444

+ 4 - 0
fs-admin/src/main/java/com/fs/hisStore/FsStoreSCRMController.java

@@ -16,6 +16,7 @@ import com.fs.hisStore.service.IFsStoreScrmService;
 import com.fs.hisStore.vo.FsStoreScrmVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.util.Assert;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -84,6 +85,9 @@ public class FsStoreSCRMController extends BaseController
     @PostMapping
     public AjaxResult add(@RequestBody FsStoreScrm fsStore)
     {
+        Assert.notNull(fsStore.getBusinessCode(),"营业执照编码/统一社会信用代码不能为空!");
+        Assert.notNull(fsStore.getStoreName(),"店铺名称不能为空!");
+        Assert.notNull(fsStore.getAccount(),"商家需要添写账号不能为空,否者无法登录!");
         return AjaxResult.success(fsStoreService.insertFsStore(fsStore));
     }
 

+ 7 - 0
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreScrmController.java

@@ -19,6 +19,7 @@ import com.fs.hisStore.utils.StoreAuditLogUtil;
 import com.fs.hisStore.vo.FsStoreScrmExcelVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.util.Assert;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -66,6 +67,9 @@ public class FsStoreScrmController extends BaseController {
     @Log(title = "店铺管理", businessType = BusinessType.INSERT,logParam = {"店铺","新增店铺信息"},isStoreLog = true)
     @PostMapping
     public AjaxResult add(@RequestBody FsStoreScrm fsStore) {
+        Assert.notNull(fsStore.getBusinessCode(),"营业执照编码/统一社会信用代码不能为空!");
+        Assert.notNull(fsStore.getStoreName(),"店铺名称不能为空!");
+        Assert.notNull(fsStore.getAccount(),"商家需要添写账号不能为空,否者无法登录!");
         storeAuditLogUtil.addOperLog(fsStoreService.insertFsStore(fsStore));
         return AjaxResult.success();
     }
@@ -77,6 +81,9 @@ public class FsStoreScrmController extends BaseController {
     @Log(title = "店铺管理", businessType = BusinessType.UPDATE,logParam = {"店铺","修改店铺信息"},isStoreLog = true)
     @PutMapping
     public AjaxResult edit(@RequestBody FsStoreScrm fsStore) {
+        Assert.notNull(fsStore.getBusinessCode(),"营业执照编码/统一社会信用代码不能为空!");
+        Assert.notNull(fsStore.getStoreName(),"店铺名称不能为空!");
+        Assert.notNull(fsStore.getAccount(),"商家需要添写账号不能为空,否者无法登录!");
         if (fsStore.getPhone()!=null&&fsStore.getPhone().contains("*")) {
             fsStore.setPhone(null);
         }

+ 5 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreScrmMapper.java

@@ -224,4 +224,9 @@ public interface FsStoreScrmMapper
      * **/
     @Select("select count(*) from  fs_store_scrm where  store_id = #{storeId} and perm_status = 2")
     Integer checkStorePerm(@Param("storeId") Long storeId);
+
+    /**
+     * 店铺名称是否已存在
+     * **/
+    Boolean isStoreNameExist(@Param("storeName") String storeName, @Param("storeId") Long storeId);
 }

+ 24 - 17
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreScrmServiceImpl.java

@@ -108,29 +108,31 @@ public class FsStoreScrmServiceImpl implements IFsStoreScrmService {
      */
     @Override
     public Long insertFsStore(FsStoreScrm fsStore) {
+        //店铺名称检查
+        Boolean storeNameExist = fsStoreMapper.isStoreNameExist(fsStore.getStoreName(), null);
+        if(storeNameExist){
+            throw new CustomException("已存在相同店铺名称,请修改店铺名称!");
+        }
         //检查商家填写的账号是否重复
-        if (fsStore.getAccount() != null) {
-            FsStoreScrm fs = fsStoreMapper.selectFsStoreByAccount(fsStore.getAccount());
-            if (fs != null) {
-                throw new CustomException("店铺账号重复");
+        FsStoreScrm fs = fsStoreMapper.selectFsStoreByAccount(fsStore.getAccount());
+        if (fs != null) {
+            throw new CustomException("店铺账号重复");
+        }
+        //FIXME
+        boolean exists = fsStoreMapper.existsByBusinessCode(fsStore.getBusinessCode());
+        if (exists) {
+            // 检查是否是同一个商家
+            String existingMerchantId = fsStoreMapper.findMerchantIdByBusinessCode(fsStore.getBusinessCode());
+            if (existingMerchantId != null) {
+                // 同一商家下检查店铺名称是否重复
+                if (fsStoreMapper.existsStoreNameInMerchant(existingMerchantId, fsStore.getStoreName())) {
+                    throw new CustomException("该商家下已存在同名店铺");
+                }
             }
         }
         StoreMD5PasswordEncoder storeMD5PasswordEncoder = new StoreMD5PasswordEncoder();
         fsStore.setPassword(storeMD5PasswordEncoder.encode("XyzAbc~12"));
         fsStore.setCreateTime(DateUtils.getNowDate());
-        if (fsStore.getBusinessCode() != null && !fsStore.getBusinessCode().trim().isEmpty()) {
-            boolean exists = fsStoreMapper.existsByBusinessCode(fsStore.getBusinessCode());
-            if (exists) {
-                // 检查是否是同一个商家
-                String existingMerchantId = fsStoreMapper.findMerchantIdByBusinessCode(fsStore.getBusinessCode());
-                if (existingMerchantId != null) {
-                    // 同一商家下检查店铺名称是否重复
-                    if (fsStoreMapper.existsStoreNameInMerchant(existingMerchantId, fsStore.getStoreName())) {
-                        throw new CustomException("该商家下已存在同名店铺");
-                    }
-                }
-            }
-        }
         //生成商家id
         String merchantId = generateMerchantId(fsStore.getBusinessCode());
         //生成店铺id
@@ -216,6 +218,11 @@ public class FsStoreScrmServiceImpl implements IFsStoreScrmService {
      */
     @Override
     public int updateFsStore(FsStoreScrm fsStore) {
+        //店铺名称检查
+        Boolean storeNameExist = fsStoreMapper.isStoreNameExist(fsStore.getStoreName(), fsStore.getStoreId());
+        if(storeNameExist){
+            throw new CustomException("已存在相同店铺名称,请修改店铺名称!");
+        }
         fsStore.setUpdateTime(DateUtils.getNowDate());
         storeAuditLogUtil.addOperLog(fsStore.getStoreId());
         FsStoreScrm oldFsStore = fsStoreMapper.selectFsStoreByStoreId(fsStore.getStoreId());

+ 14 - 0
fs-service/src/main/resources/mapper/hisStore/FsStoreScrmMapper.xml

@@ -940,4 +940,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         from fs_store_scrm
         where store_seq= #{storeSeq}
     </select>
+
+    <select id="isStoreNameExist" resultType="java.lang.Boolean">
+        select count(store_id) from fs_store_scrm
+        <where>
+            <if test="storeName != null and '' != storeName">
+                store_name = #{storeName}
+            </if>
+            <if test="storeId != null">
+                and store_id != #{storeId}
+            </if>
+        </where>
+    </select>
+
+
 </mapper>

+ 4 - 0
fs-store/src/main/java/com/fs/hisStore/controller/store/FsStoreScrmController.java

@@ -103,6 +103,9 @@ public class FsStoreScrmController extends BaseController {
     @Log(title = "店铺管理", businessType = BusinessType.INSERT, logParam = {"店铺", "新增店铺信息"}, isStoreLog = true)
     @PostMapping
     public AjaxResult add(@RequestBody FsStoreScrm fsStore) {
+        Assert.notNull(fsStore.getBusinessCode(),"营业执照编码/统一社会信用代码不能为空!");
+        Assert.notNull(fsStore.getStoreName(),"店铺名称不能为空!");
+        Assert.notNull(fsStore.getAccount(),"商家需要添写账号不能为空,否者无法登录!");
         return toAjax(fsStoreService.insertFsStore(fsStore).intValue());
     }
 
@@ -113,6 +116,7 @@ public class FsStoreScrmController extends BaseController {
     @Log(title = "店铺管理", businessType = BusinessType.UPDATE, logParam = {"店铺", "修改店铺信息"}, isStoreLog = true)
     @PutMapping
     public AjaxResult edit(@RequestBody FsStoreScrmInfoParam fsStore) {
+        Assert.notNull(fsStore.getBusinessCode(),"营业执照编码/统一社会信用代码不能为空!");
         return toAjax(fsStoreService.updateStoreInfo(fsStore));
     }
 

+ 4 - 0
fs-user-app/src/main/java/com/fs/app/controller/store/StoreScrmController.java

@@ -20,6 +20,7 @@ import com.fs.hisStore.vo.FsStoreRecommendListVO;
 import com.fs.hisStore.vo.FsStoreScrmVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.util.Assert;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.ArrayList;
@@ -85,6 +86,9 @@ public class StoreScrmController extends BaseController
     @PostMapping
     public AjaxResult add(@RequestBody FsStoreScrm fsStore)
     {
+        Assert.notNull(fsStore.getBusinessCode(),"营业执照编码/统一社会信用代码不能为空!");
+        Assert.notNull(fsStore.getStoreName(),"店铺名称不能为空!");
+        Assert.notNull(fsStore.getAccount(),"商家需要添写账号不能为空,否者无法登录!");
         storeAuditLogUtil.addOperLog(fsStoreService.insertFsStore(fsStore));
         return AjaxResult.success();
     }