leon il y a 5 ans
Parent
commit
cadc1e9b81

+ 16 - 1
src/main/java/com/mokamrp/privates/controller/pangu/PromoteCodeController.java

@@ -11,6 +11,8 @@ import com.mokamrp.privates.entity.DelHandle;
 import com.mokamrp.privates.entity.EditHandle;
 import com.mokamrp.privates.entity.pangu.PromoteCodeListHandle;
 import com.mokamrp.privates.help.AjaxResult;
+import com.mokamrp.privates.mapper.pangu.pojo.PromoteQrcodePool;
+import com.mokamrp.privates.service.pangu.PromoteQrcodePoolService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.validation.BindingResult;
@@ -39,6 +41,9 @@ public class PromoteCodeController extends BaseController<PromoteCode> {
     public PromoteCodeService promoteCodeService;
 
     @Autowired
+    public PromoteQrcodePoolService promoteQrcodePoolService;
+
+    @Autowired
     public StringRedisTemplate stringRedisTemplate;
 
     /*
@@ -82,10 +87,11 @@ public class PromoteCodeController extends BaseController<PromoteCode> {
         String[] ids = delHandle.getIds().split(",");
         QueryWrapper.in("id", ids);
         boolean res = service.remove(QueryWrapper);
+        promoteQrcodePoolService.remove(new QueryWrapper<PromoteQrcodePool>().in("promote_id",ids));
         if (!res) {
-            this.sync();
             return AjaxResult.error("删除失败");
         }
+        this.delRedis(ids);
         return AjaxResult.success(Constants.SUCCESS, res);
     }
 
@@ -118,6 +124,15 @@ public class PromoteCodeController extends BaseController<PromoteCode> {
         return AjaxResult.success(res);
     }
 
+    public Boolean delRedis(String[] ids){
+        for (String id : ids){
+            stringRedisTemplate.opsForHash().delete(RedisKey.PanPromoteCodeInfo,id);
+            stringRedisTemplate.delete(RedisKey.PanCustServiceIdView+id);
+            stringRedisTemplate.delete(RedisKey.PanCustServiceIdDayView+id);
+        }
+        return true;
+    }
+
     public Boolean sync() {
         List<PromoteCode> list = promoteCodeService.list();
         for (PromoteCode promoteCode : list) {