From 61b5f9863f14ab4fc9da504ca2b553a778eb2e2c Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期三, 24 一月 2024 15:10:32 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/HongRuiTang

---
 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/coupon/CouponServiceImpl.java |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/coupon/CouponServiceImpl.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/coupon/CouponServiceImpl.java
index 468865d..8062e06 100644
--- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/coupon/CouponServiceImpl.java
+++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/coupon/CouponServiceImpl.java
@@ -301,19 +301,19 @@
             if(!coupon.getSendType().equals(mgtCouponEditDto.getSendType())){
                 throw new ServiceException("不能修改优惠券发放方式");
             }
-            if(null != mgtCouponEditDto.getMoneyThreshold() && !coupon.getMoneyThreshold().equals(mgtCouponEditDto.getMoneyThreshold())){
+            if(null != mgtCouponEditDto.getMoneyThreshold() && coupon.getMoneyThreshold().compareTo(mgtCouponEditDto.getMoneyThreshold()) != 0){
                 throw new ServiceException("不能修改优惠券金额");
             }
-            if(null != mgtCouponEditDto.getDiscountMoney() && !coupon.getDiscountMoney().equals(mgtCouponEditDto.getDiscountMoney())){
+            if(null != mgtCouponEditDto.getDiscountMoney() && coupon.getDiscountMoney().compareTo(mgtCouponEditDto.getDiscountMoney()) != 0){
                 throw new ServiceException("不能修改优惠券金额");
             }
-            if(null != mgtCouponEditDto.getDiscountPercent() && !coupon.getDiscountPercent().equals(mgtCouponEditDto.getDiscountPercent())){
+            if(null != mgtCouponEditDto.getDiscountPercent() && coupon.getDiscountPercent().compareTo(mgtCouponEditDto.getDiscountPercent()) != 0){
                 throw new ServiceException("不能修改优惠券折扣");
             }
-            if(null != mgtCouponEditDto.getValidTimeType() && !coupon.getValidTimeType().equals(mgtCouponEditDto.getValidTimeType())){
+            if(coupon.getSendType() == 2 && coupon.getSendTimeType() == 2 && mgtCouponEditDto.getSendTimeType() == 2 && System.currentTimeMillis() >= coupon.getSendTime().getTime() && null != mgtCouponEditDto.getValidTimeType() && !coupon.getValidTimeType().equals(mgtCouponEditDto.getValidTimeType())){
                 throw new ServiceException("不能修改优惠券适用期限类型");
             }
-            if(null != mgtCouponEditDto.getValidTimeType() && coupon.getValidTimeType() == 1 && !coupon.getValidStartTime().equals(mgtCouponEditDto.getValidStartTime())){
+            if(coupon.getSendType() == 2 && coupon.getSendTimeType() == 2 && mgtCouponEditDto.getSendTimeType() == 2 && System.currentTimeMillis() >= coupon.getSendTime().getTime() && null != mgtCouponEditDto.getValidTimeType() && coupon.getValidTimeType() == 1 && !coupon.getValidStartTime().equals(mgtCouponEditDto.getValidStartTime())){
                 throw new ServiceException("不能修改优惠券有效期开始时间");
             }
             if(coupon.getSendType() == 2 && coupon.getSendTimeType() == 1 && mgtCouponEditDto.getSendTimeType() != 1){
@@ -322,12 +322,13 @@
             if(coupon.getSendType() == 2 && coupon.getSendTimeType() == 2 && mgtCouponEditDto.getSendTimeType() != 2 && System.currentTimeMillis() <= coupon.getSendTime().getTime()){
                 throw new ServiceException("不能修改优惠券发放方式");
             }
-            if(coupon.getSendType() == 2 && coupon.getSendTimeType() == 2 && mgtCouponEditDto.getSendTimeType() == 2 && !mgtCouponEditDto.getSendTime().equals(coupon.getSendTime()) && System.currentTimeMillis() <= coupon.getSendTime().getTime()){
+            if(coupon.getSendType() == 2 && coupon.getSendTimeType() == 2 && mgtCouponEditDto.getSendTimeType() == 2 && System.currentTimeMillis() >= coupon.getSendTime().getTime()){
                 throw new ServiceException("不能修改优惠券发放时间");
             }
-            if(coupon.getUseScope() == 1 && !coupon.getUseScope().equals(mgtCouponEditDto.getUseScope())){
+            if(coupon.getSendType() == 2 && coupon.getSendTimeType() == 2 && mgtCouponEditDto.getSendTimeType() == 2 && System.currentTimeMillis() >= coupon.getSendTime().getTime() && coupon.getUseScope() == 1 && !coupon.getUseScope().equals(mgtCouponEditDto.getUseScope())){
                 throw new ServiceException("不能修改优惠券适用范围");
             }
+
             if(coupon.getUseScope() == 2 && coupon.getUseScope().equals(mgtCouponEditDto.getUseScope())){
                 List<String> relGoodsIdList = mgtCouponEditDto.getRelGoodsIdList();
                 List<CouponRelGoods> list = couponRelGoodsService.list(new QueryWrapper<CouponRelGoods>().eq("coupon_id", coupon.getCouponId()).eq("del_flag", 0));
@@ -340,10 +341,10 @@
             if(coupon.getSendLimitFlag() == 0 && mgtCouponEditDto.getSendLimitFlag() != 0){
                 throw new ServiceException("不能修改优惠券发放数量限制");
             }
-            if(coupon.getSendLimitFlag() == 1 && !coupon.getSendLimitNumber().equals(mgtCouponEditDto.getSendLimitNumber())){
+            if(coupon.getSendLimitFlag() == 1 && mgtCouponEditDto.getSendLimitFlag() == 1 && coupon.getSendLimitNumber().compareTo(mgtCouponEditDto.getSendLimitNumber()) > 0){
                 throw new ServiceException("不能修改优惠券发放数量限制");
             }
-            if(coupon.getLimitNumber().compareTo(mgtCouponEditDto.getLimitNumber()) < 0){
+            if(coupon.getLimitNumber().compareTo(mgtCouponEditDto.getLimitNumber()) > 0){
                 throw new ServiceException("只能增加优惠券领取数量");
             }
             List<CouponRelUser> list = couponRelUserService.list(new QueryWrapper<CouponRelUser>().eq("coupon_id", coupon.getCouponId()).eq("del_flag", 0));
@@ -360,9 +361,9 @@
                 throw new ServiceException("只能修改优惠发放对象");
             }
 
+            couponRelUserService.deleteCouponRelByCouponId(coupon.getCouponId());
+            couponRelGoodsService.deleteCouponRelByCouponId(coupon.getCouponId());
 
-//            couponRelUserService.deleteCouponRelByCouponId(coupon.getCouponId());
-//            couponRelGoodsService.deleteCouponRelByCouponId(coupon.getCouponId());
         }else{
             coupon = new Coupon();
             String couponId = IdUtils.simpleUUID();
@@ -449,7 +450,7 @@
             coupon.setRelUserIds(userIdSj.toString());
         }
         //处理优惠券发放
-        if(coupon.getSendType()==2&&coupon.getSendTimeType()==1){
+        if(coupon.getSendFlag() == 0 && coupon.getSendType()==2&&coupon.getSendTimeType()==1){
             sendCoupon(coupon,relUserIdList);
             coupon.setSendFlag(1);
             this.saveOrUpdate(coupon);

--
Gitblit v1.7.1