From d8689abdb2378bdd1c97317ca881173eca26283c Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期三, 14 一月 2026 17:13:52 +0800
Subject: [PATCH] 经销商管理

---
 server/dmmall_service/src/main/java/com/doumee/service/business/impl/CouponServiceImpl.java |   30 ++++++++++++++++++------------
 1 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/server/dmmall_service/src/main/java/com/doumee/service/business/impl/CouponServiceImpl.java b/server/dmmall_service/src/main/java/com/doumee/service/business/impl/CouponServiceImpl.java
index 78e2ed2..53fd9d8 100644
--- a/server/dmmall_service/src/main/java/com/doumee/service/business/impl/CouponServiceImpl.java
+++ b/server/dmmall_service/src/main/java/com/doumee/service/business/impl/CouponServiceImpl.java
@@ -1,5 +1,6 @@
 package com.doumee.service.business.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.doumee.core.constants.ResponseStatus;
 import com.doumee.core.exception.BusinessException;
@@ -30,6 +31,7 @@
 import java.util.Date;
 import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 /**
  * 浼樻儬鍒镐俊鎭〃Service瀹炵幇
@@ -55,24 +57,21 @@
     @Override
     public Integer create(Coupon coupon) {
         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+        coupon.setType(Constants.ONE);
+        coupon.setGetMethod(Constants.ZERO);
         isCreateParamValid(coupon);
 
-        /**骞冲彴浼樻儬鍒告槸鍏戞崲浼樻儬鍒革紝鍟嗗浼樻儬鍒告槸棰嗗彇浼樻儬鍒�*/
-        if(Constants.equalsInteger(coupon.getType(),Constants.ZERO)){
-            coupon.setGetMethod(Constants.ZERO);
-        }else if(Constants.equalsInteger(coupon.getType(),Constants.ONE)){
-          coupon.setGetMethod(Constants.ONE);
-        }
         coupon.setIsdeleted(Constants.ZERO);
         coupon.setCreator(user.getId());
         coupon.setCreateDate(new Date());
-        coupon.setStatus(Constants.ONE);
+        coupon.setEditor(user.getId());
+        coupon.setEditDate(new Date());
+        coupon.setStatus(Constants.ONE);//榛樿绂佺敤
         couponMapper.insert(coupon);
         return coupon.getId();
     }
 
     public void isCreateParamValid(Coupon coupon){
-
         if(StringUtils.isBlank(coupon.getName())
                 || coupon.getType()==null
                 ||coupon.getLimitPrice()==null
@@ -81,7 +80,7 @@
               /*  ||coupon.getIntegral()==null*/
                 ||coupon.getStartDate()==null
                 ||coupon.getEndDate()==null
-                ||coupon.getValidDays()==null
+//                ||coupon.getValidDays()==null
 
         ){
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage());
@@ -98,11 +97,17 @@
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "鍏宠仈鐨勫簵閾轰笉瀛樺湪锛�");
             }
         }
+        coupon.setApplyIds("");
+        if(Constants.equalsInteger(coupon.getApplyType(),Constants.TWO) && coupon.getApplyIdList()!=null){
+            coupon.setApplyIds(coupon.getApplyIdList().stream().map(String::valueOf).collect(Collectors.joining(",")));//浣跨敤瀵硅薄缂栫爜闆嗗悎
+        }
+        if(Constants.equalsInteger(coupon.getApplyType(),Constants.ONE) && coupon.getApplyCateIdList()!=null){
+            coupon.setApplyIds(coupon.getApplyCateIdList().stream().map(String::valueOf).collect(Collectors.joining(",")));//浣跨敤瀵硅薄缂栫爜闆嗗悎
+        }
     }
 
     @Override
     public void deleteById(Integer id) {
-
         Coupon query= couponMapper.selectById(id);
         initCouponStatus(query);
         if(!Constants.equalsInteger(query.getCouponStatus(),Constants.ZERO)){
@@ -134,9 +139,9 @@
         isCreateParamValid(coupon);
         Coupon query= couponMapper.selectById(coupon.getId());
         initCouponStatus(query);
-        if(!Constants.equalsInteger(query.getCouponStatus(),Constants.ZERO)){
+     /*   if(!Constants.equalsInteger(query.getCouponStatus(),Constants.ZERO)){
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "娲诲姩宸插紑濮�/宸茬粨鏉熺姸鎬侊紝涓嶆敮鎸佺紪杈戞搷浣�");
-        }
+        }*/
         coupon.setEditor(user.getId());
         coupon.setEditDate(new Date());
         couponMapper.updateById(coupon);
@@ -207,6 +212,7 @@
         queryWrapper.select("(select count(id) from member_coupon where ISDELETED=0 and COUPON_ID=t.id and STATUS=1) as used");
 
         queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getName()),Coupon::getName,pageWrap.getModel().getName());
+        queryWrapper.eq(pageWrap.getModel().getCouponType()!=null,Coupon::getCouponType,pageWrap.getModel().getCouponType());
         queryWrapper.eq(Coupon::getIsdeleted,Constants.ZERO);
         queryWrapper.orderByDesc(Coupon::getCreateDate);
         IPage<Coupon> result =  couponJoinMapper.selectJoinPage(page,Coupon.class, queryWrapper);

--
Gitblit v1.9.3