| | |
| | | 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){ |
| | |
| | | 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)); |
| | |
| | | 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)); |
| | |
| | | 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(); |
| | |
| | | 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); |