Browse Source

fixed 删除商户业务逻辑处理完善

fushengqian 1 month ago
parent
commit
57e8c74f8f

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/service/MemberService.java

@@ -140,7 +140,7 @@ public interface MemberService extends IService<MtUser> {
     MtUser queryMemberByUserNo(Integer merchantId, String userNo) throws BusinessCheckException;
 
     /**
-     * 根据会员ID 删除店铺信息
+     * 根据会员ID删除会员信息
      *
      * @param  id 会员ID
      * @param  operator 操作人

+ 8 - 0
fuint-application/src/main/java/com/fuint/common/service/StoreService.java

@@ -114,4 +114,12 @@ public interface StoreService extends IService<MtStore> {
      * */
     String getStoreIds(Integer merchantId, String storeNames);
 
+    /**
+     * 根据商户ID删除店铺信息
+     *
+     * @param merchantId 商户ID
+     * @return
+     * */
+    void deleteStoreByMerchant(Integer merchantId);
+
 }

+ 11 - 1
fuint-application/src/main/java/com/fuint/common/service/impl/MerchantServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fuint.common.enums.StatusEnum;
 import com.fuint.common.service.MerchantService;
+import com.fuint.common.service.StoreService;
 import com.fuint.common.util.CommonUtil;
 import com.fuint.framework.annoation.OperationServiceLog;
 import com.fuint.framework.exception.BusinessCheckException;
@@ -39,13 +40,18 @@ import java.util.*;
 @AllArgsConstructor
 public class MerchantServiceImpl extends ServiceImpl<MtMerchantMapper, MtMerchant> implements MerchantService {
 
+    private static final Logger logger = LoggerFactory.getLogger(MerchantServiceImpl.class);
+
     private MtMerchantMapper mtMerchantMapper;
 
     private MtStoreMapper mtStoreMapper;
 
     private MtGoodsMapper mtGoodsMapper;
 
-    private static final Logger logger = LoggerFactory.getLogger(MerchantServiceImpl.class);
+    /**
+     * 店铺服务接口
+     * */
+    private StoreService storeService;
 
     /**
      * 分页查询商户列表
@@ -217,6 +223,10 @@ public class MerchantServiceImpl extends ServiceImpl<MtMerchantMapper, MtMerchan
 
         // 如果是删除,检查是否有商品等数据
         if (status.equals(StatusEnum.DISABLE.getKey())) {
+            // 删除店铺
+            storeService.deleteStoreByMerchant(id);
+
+            // 删除商品
             Map<String, Object> params = new HashMap<>();
             params.put("status", StatusEnum.ENABLED.getKey());
             params.put("merchant_id", id);

+ 15 - 3
fuint-application/src/main/java/com/fuint/common/service/impl/StoreServiceImpl.java

@@ -358,9 +358,7 @@ public class StoreServiceImpl extends ServiceImpl<MtStoreMapper, MtStore> implem
         }
 
         lambdaQueryWrapper.orderByAsc(MtStore::getStatus).orderByDesc(MtStore::getIsDefault);
-        List<MtStore> dataList = mtStoreMapper.selectList(lambdaQueryWrapper);
-
-        return dataList;
+        return mtStoreMapper.selectList(lambdaQueryWrapper);
     }
 
     /**
@@ -453,4 +451,18 @@ public class StoreServiceImpl extends ServiceImpl<MtStoreMapper, MtStore> implem
         return String.join(",", storeIds);
     }
 
+    /**
+     * 根据商户ID删除店铺信息
+     *
+     * @param merchantId 商户ID
+     * @return
+     * */
+    @Override
+    public void deleteStoreByMerchant(Integer merchantId) {
+        if (merchantId == null || merchantId <= 0) {
+            return;
+        }
+        mtStoreMapper.deleteStoreByMerchant(merchantId);
+    }
+
 }

+ 8 - 14
fuint-application/src/main/resources/vm/java/BackendController.java.vm

@@ -30,7 +30,7 @@ import java.util.Map;
 @Api(tags="管理端-${moduleName}相关接口")
 @RestController
 @AllArgsConstructor
-@RequestMapping(value = "/backendApi/${tableName}")
+@RequestMapping(value = "/backendApi/${serviceName}")
 public class Backend${tableClass}Controller extends BaseController {
 
     /**
@@ -47,7 +47,7 @@ public class Backend${tableClass}Controller extends BaseController {
     @ApiOperation(value = "${moduleName}列表查询")
     @RequestMapping(value = "/list", method = RequestMethod.GET)
     @CrossOrigin
-    @PreAuthorize("@pms.hasPermission('${tableName}:list')")
+    @PreAuthorize("@pms.hasPermission('${serviceName}:list')")
     public ResponseObject list(HttpServletRequest request) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
         Integer page = request.getParameter("page") == null ? Constants.PAGE_NUMBER : Integer.parseInt(request.getParameter("page"));
@@ -105,7 +105,7 @@ public class Backend${tableClass}Controller extends BaseController {
     @ApiOperation(value = "更新${moduleName}状态")
     @RequestMapping(value = "/updateStatus", method = RequestMethod.POST)
     @CrossOrigin
-    @PreAuthorize("@pms.hasPermission('${tableName}:edit')")
+    @PreAuthorize("@pms.hasPermission('${serviceName}:edit')")
     public ResponseObject updateStatus(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
         String status = params.get("status") != null ? params.get("status").toString() : StatusEnum.ENABLED.getKey();
@@ -135,7 +135,7 @@ public class Backend${tableClass}Controller extends BaseController {
     @ApiOperation(value = "保存${moduleName}")
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @CrossOrigin
-    @PreAuthorize("@pms.hasPermission('${tableName}:add')")
+    @PreAuthorize("@pms.hasPermission('${serviceName}:add')")
     public ResponseObject saveHandler(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
         String id = params.get("id") == null ? "" : params.get("id").toString();
@@ -168,18 +168,12 @@ public class Backend${tableClass}Controller extends BaseController {
     @ApiOperation(value = "获取${moduleName}详情")
     @RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
     @CrossOrigin
-    @PreAuthorize("@pms.hasPermission('${tableName}:list')")
-    public ResponseObject info(HttpServletRequest request, @PathVariable("id") Integer id) throws BusinessCheckException {
-        String token = request.getHeader("Access-Token");
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
-        if (accountInfo == null) {
-            return getFailureResult(1001, "请先登录");
-        }
-
-        ${className} ${tableName}Info = ${serviceName}Service.query${tableClass}ById(id);
+    @PreAuthorize("@pms.hasPermission('${serviceName}:list')")
+    public ResponseObject info(@PathVariable("id") Integer id) throws BusinessCheckException {
+        ${className} ${serviceName}Info = ${serviceName}Service.query${tableClass}ById(id);
 
         Map<String, Object> result = new HashMap<>();
-        result.put("${tableName}Info", ${tableName}Info);
+        result.put("${serviceName}Info", ${serviceName}Info);
 
         return getSuccessResult(result);
     }

+ 2 - 0
fuint-repository/src/main/java/com/fuint/repository/mapper/MtStoreMapper.java

@@ -23,4 +23,6 @@ public interface MtStoreMapper extends BaseMapper<MtStore> {
 
     List<StoreDistanceBean> queryByDistance(@Param("merchantId") Integer merchantId, @Param("keyword") String keyword, @Param("latitude") String latitude, @Param("longitude") String longitude);
 
+    void deleteStoreByMerchant(@Param("merchantId") Integer merchantId);
+
 }

+ 4 - 0
fuint-repository/src/main/resources/mapper/MtStoreMapper.xml

@@ -30,4 +30,8 @@
         </if>
         ORDER BY distance LIMIT 0,1000
     </select>
+
+    <update id="deleteStoreByMerchant">
+        update mt_store set STATUS = 'D' where MERCHANT_ID = #{merchantId}
+    </update>
 </mapper>