Procházet zdrojové kódy

收银台功能 服务费 功能修改 删除功能

liudongzhi před 3 týdny
rodič
revize
ae9ca54d43

+ 2 - 1
alien-store/src/main/java/shop/alien/store/controller/StoreServiceFeeRuleController.java

@@ -65,7 +65,8 @@ public class StoreServiceFeeRuleController {
             @ApiImplicitParam(name = "id", value = "规则ID", dataType = "Integer", paramType = "query", required = true)
     })
     @PostMapping("/delete")
-    public R<Boolean> delete(@RequestParam Integer id) {
+    public R<Boolean> delete(@RequestBody StoreServiceFeeRuleSaveDto dto) {
+        Integer id = dto.getId();
         return storeServiceFeeRuleService.deleteRule(id);
     }
 

+ 7 - 14
alien-store/src/main/java/shop/alien/store/service/impl/StoreServiceFeeRuleServiceImpl.java

@@ -2,6 +2,7 @@ package shop.alien.store.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
@@ -262,20 +263,12 @@ public class StoreServiceFeeRuleServiceImpl implements StoreServiceFeeRuleServic
         if (id == null) {
             return R.fail("规则ID不能为空");
         }
-        StoreServiceFeeRule existing = ruleMapper.selectById(id);
-        if (existing == null) {
-            return R.fail("服务费规则不存在");
-        }
-        ruleMapper.delete(new LambdaQueryWrapper<StoreServiceFeeRule>()
-                .eq(StoreServiceFeeRule::getStoreId, existing.getStoreId())
-                .eq(StoreServiceFeeRule::getFeeName, existing.getFeeName())
-                .eq(StoreServiceFeeRule::getFeeType, existing.getFeeType())
-                .eq(StoreServiceFeeRule::getFeeValue, existing.getFeeValue())
-                .eq(StoreServiceFeeRule::getStatus, existing.getStatus())
-                .eq(StoreServiceFeeRule::getEffectiveMode, existing.getEffectiveMode())
-                .eq(StoreServiceFeeRule::getStartDate, existing.getStartDate())
-                .eq(StoreServiceFeeRule::getEndDate, existing.getEndDate()));
-        return R.data(true);
+
+        LambdaUpdateWrapper<StoreServiceFeeRule> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.eq(StoreServiceFeeRule::getId, id);
+        updateWrapper.set(StoreServiceFeeRule::getDeleteFlag, 1);
+        int result = ruleMapper.update(null, updateWrapper);
+        return R.data(result > 0);
     }
 
     @Override