| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | |
| | | import com.ruoyi.system.api.service.RemoteConfigService; |
| | | import com.ruoyi.system.api.service.RemoteGoodsService; |
| | | import com.ruoyi.system.api.service.RemoteShopService; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.concurrent.TimeUnit; |
| | |
| | | |
| | | @Resource |
| | | private CouponRelGoodsService couponRelGoodsService; |
| | | |
| | | |
| | | @Resource |
| | | private CouponMapper couponMapper; |
| | | |
| | | |
| | | @Resource |
| | | private RemoteGoodsService remoteGoodsService; |
| | | |
| | | |
| | | @Resource |
| | | private CouponTotalService couponTotalService; |
| | | |
| | | |
| | | @Lazy |
| | | @Resource |
| | | private MemberService memberService; |
| | | |
| | | |
| | | @Lazy |
| | | @Resource |
| | | private MemberCouponService memberCouponService; |
| | | |
| | | |
| | | @Resource |
| | | private RemoteActivityService remoteActivityService; |
| | | |
| | | |
| | | @Resource |
| | | private MemberCouponRecordService memberCouponRecordService; |
| | | |
| | | |
| | | @Resource |
| | | private RemoteShopService remoteShopService; |
| | | |
| | |
| | | * @return void |
| | | */ |
| | | @Override |
| | | public void editMgtCoupon(MgtCouponEditDto mgtCouponEditDto){ |
| | | public void editMgtCoupon(MgtCouponEditDto mgtCouponEditDto){ |
| | | //编辑优惠券 |
| | | Coupon coupon; |
| | | CouponTotal couponTotal; |
| | |
| | | * 三:可修改 |
| | | * 1、优惠券名称 |
| | | * 2、宣传海报 |
| | | * 3、分享文案、分享图片 |
| | | * 四:发放对象 |
| | | * 1、未到发放时间都可以修改 |
| | | * 2、已到发放时间,只有自定义时可修改,且只能增加用户 |
| | |
| | | coupon.setRelationActivityType(mgtCouponEditDto.getRelationActivityType()); |
| | | coupon.setRelationActivityId(mgtCouponEditDto.getRelationActivityId()); |
| | | coupon.setPropagandaPoster(mgtCouponEditDto.getPropagandaPoster()); |
| | | coupon.setSharePassage(mgtCouponEditDto.getSharePassage()); |
| | | coupon.setSharePic(mgtCouponEditDto.getSharePic()); |
| | | //指定发放优惠券不做发放数限制 |
| | | if(coupon.getSendType()==2){ |
| | | mgtCouponEditDto.setSendLimitFlag(0); |
| | |
| | | } |
| | | } |
| | | } |
| | | String useLimit = ""; |
| | | for(MgtCouponAuditPageVo mgtCouponAuditPageVo : mgtCouponAuditPageVoList){ |
| | | useLimit = null; |
| | | //处理使用限制 |
| | | String couponType = mgtCouponAuditPageVo.getCouponType(); |
| | | if(couponType.equals("满减")){ |
| | | BigDecimal moneyThreshold = mgtCouponAuditPageVo.getMoneyThreshold(); |
| | | BigDecimal discountMoney = mgtCouponAuditPageVo.getDiscountMoney(); |
| | | useLimit = "满" + moneyThreshold.toString() + "减" + discountMoney.toString() + "元"; |
| | | } |
| | | if(couponType.equals("折扣")){ |
| | | BigDecimal discountPercent = mgtCouponAuditPageVo.getDiscountPercent(); |
| | | useLimit = discountPercent.toString() + "折"; |
| | | } |
| | | if(couponType.equals("代金")){ |
| | | BigDecimal discountMoney = mgtCouponAuditPageVo.getDiscountMoney(); |
| | | useLimit = discountMoney.toString(); |
| | | } |
| | | mgtCouponAuditPageVo.setUseLimit(useLimit); |
| | | } |
| | | return mgtCouponAuditPageVoList; |
| | | } |
| | | |
| | |
| | | CouponTotal couponTotal; |
| | | if(StringUtils.isNotBlank(merCouponEditDto.getCouponId())){ |
| | | coupon = this.getById(merCouponEditDto.getCouponId()); |
| | | if(coupon.getAuditStatus()!=3){ |
| | | throw new ServiceException(AppErrorConstant.COUPON_AUDIT_EDIT); |
| | | } |
| | | // if(coupon.getAuditStatus()!=3){ |
| | | // throw new ServiceException(AppErrorConstant.COUPON_AUDIT_EDIT); |
| | | // } |
| | | couponRelUserService.deleteCouponRelByCouponId(coupon.getCouponId()); |
| | | couponRelGoodsService.deleteCouponRelByCouponId(coupon.getCouponId()); |
| | | coupon.setCouponStatus(1); |
| | |
| | | Coupon coupon; |
| | | List<MemberCoupon> memberCouponList = new ArrayList<>(); |
| | | MemberCoupon memberCoupon; |
| | | String memberCouponId; |
| | | |
| | | // 遍历生日礼物发送DTO列表 |
| | | for(BirthdayGiftSendDto birthdayGiftSendDto : giftSendDtoList){ |
| | |
| | | // 根据优惠券数量生成会员优惠券列表 |
| | | for(int i=0;i<birthdayGiftSendDto.getCouponNumber();i++){ |
| | | memberCoupon = new MemberCoupon(); |
| | | //TODO |
| | | memberCouponId = IdUtils.simpleUUID(); |
| | | //memberCoupon.setId(memberCouponId); |
| | | memberCoupon.setDelFlag(0); |
| | | memberCoupon.setCouponId(couponId); |
| | | memberCoupon.setUserId(userId); |
| | |
| | | } |
| | | //生成用户优惠券 |
| | | MemberCoupon memberCoupon = new MemberCoupon(); |
| | | //String memberCouponId = IdUtils.simpleUUID(); |
| | | //memberCoupon.setId(memberCouponId); |
| | | memberCoupon.setDelFlag(0); |
| | | memberCoupon.setCouponId(couponId); |
| | | memberCoupon.setUserId(userId); |
| | |
| | | metAuditCouponTotalVo.setRefuseTotal(refuseTotal); |
| | | return metAuditCouponTotalVo; |
| | | } |
| | | |
| | | @Override |
| | | public R endImmediately(MgtBaseGetDto mgtBaseGetDto) { |
| | | // 将优惠券状态置为禁用 定时发放类型每小时会检查启用中的没发放的 发送了的、立即发送类型的优惠券不管 |
| | | Coupon coupon = couponMapper.selectById(mgtBaseGetDto.getId()); |
| | | if (coupon == null || coupon.getDelFlag() != 0) { |
| | | return R.fail("该优惠券不存在"); |
| | | } |
| | | if (coupon.getCouponStatus()!=1){ |
| | | return R.fail("状态错误,该优惠券未在启用中"); |
| | | } |
| | | coupon.setCouponStatus(0);//设置为禁用 |
| | | coupon.setUpdateUserId(mgtBaseGetDto.getUserId()); |
| | | coupon.setUpdateTime(new Date()); |
| | | this.updateById(coupon); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public List<LotteryEventCouponListVO> getLotteryEventCouponList() { |
| | | return this.getBaseMapper().getLotteryEventCouponList(); |
| | | } |
| | | |
| | | @Override |
| | | public List<LotteryEventCouponListVO> getLotteryEventCouponListByShopId(String shopId) { |
| | | return this.getBaseMapper().getLotteryEventCouponListByShopId(shopId); |
| | | } |
| | | } |