| | |
| | | import com.ruoyi.system.api.domain.dto.*; |
| | | import com.ruoyi.system.api.domain.poji.config.DelayTask; |
| | | import com.ruoyi.system.api.domain.poji.goods.Goods; |
| | | import com.ruoyi.system.api.domain.poji.member.Member; |
| | | import com.ruoyi.system.api.domain.poji.member.MemberCoupon; |
| | | import com.ruoyi.system.api.domain.poji.shop.Shop; |
| | | import com.ruoyi.system.api.domain.vo.MerGoodsPriceListVo; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.StringJoiner; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | } |
| | | } |
| | | //判断优惠券是否指定发放用户 |
| | | if(coupon.getSendType()==5&&coupon.getRelationType()==1){ |
| | | if(coupon.getSendTarget()==5&&coupon.getRelationType()==1){ |
| | | //获取优惠券发放用户 |
| | | List<MgtCouponMemberListVo> relUserList = couponRelUserService.listCouponMemberVo(coupon.getCouponId()); |
| | | mgtCouponGetVo.setRelUserList(relUserList); |
| | |
| | | MerCouponGetVo merCouponGetVo = new MerCouponGetVo(); |
| | | Coupon coupon = this.getById(couponId); |
| | | BeanUtils.copyProperties(coupon, merCouponGetVo); |
| | | if(merCouponGetVo.getSendType()>1){ |
| | | merCouponGetVo.setSendType(2); |
| | | merCouponGetVo.setSendTarget(merCouponGetVo.getSendType()); |
| | | } |
| | | //判断优惠券是否为指定商品 |
| | | if(coupon.getUseScope()==2){ |
| | | String relGoodsIds = coupon.getRelGoodsIds(); |
| | |
| | | } |
| | | } |
| | | //判断优惠券是否指定发放用户 |
| | | if(coupon.getSendType()==5&&coupon.getRelationType()==1){ |
| | | if(coupon.getSendTarget()==5&&coupon.getRelationType()==1){ |
| | | //获取优惠券发放用户 |
| | | List<MgtCouponMemberListVo> relUserList = couponRelUserService.listCouponMemberVo(coupon.getCouponId()); |
| | | merCouponGetVo.setRelUserList(relUserList); |
| | |
| | | coupon.setCouponType(mgtCouponEditDto.getCouponType()); |
| | | coupon.setCouponName(mgtCouponEditDto.getCouponName()); |
| | | coupon.setSendType(mgtCouponEditDto.getSendType()); |
| | | coupon.setSendTarget(mgtCouponEditDto.getSendTarget()); |
| | | coupon.setSendTimeType(mgtCouponEditDto.getSendTimeType()); |
| | | coupon.setSendTime(mgtCouponEditDto.getSendTime()); |
| | | coupon.setMoneyThreshold(mgtCouponEditDto.getMoneyThreshold()); |
| | |
| | | } |
| | | //判断是否指定用户 |
| | | List<Long> relUserIdList = null; |
| | | if(coupon.getSendType()==5&&coupon.getRelationType()==1&&!mgtCouponEditDto.getRelUserIdList().isEmpty()){ |
| | | if(coupon.getSendTarget()==2&&coupon.getSendTarget()==5&&coupon.getRelationType()==1&&!mgtCouponEditDto.getRelUserIdList().isEmpty()){ |
| | | relUserIdList = mgtCouponEditDto.getRelUserIdList(); |
| | | List<CouponRelUser> couponRelUserList = relUserIdList.stream() |
| | | .map(str -> { |
| | | CouponRelUser couponRelUser = new CouponRelUser(); |
| | | couponRelUser.setDelFlag(0); |
| | | couponRelUser.setCouponId(coupon.getCouponId()); |
| | | couponRelUser.setUserId(str); |
| | | return couponRelUser; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | List<CouponRelUser> couponRelUserList = new ArrayList<>(); |
| | | CouponRelUser couponRelUser; |
| | | StringJoiner userIdSj = new StringJoiner(","); |
| | | for(Long userId : relUserIdList){ |
| | | couponRelUser = new CouponRelUser(); |
| | | couponRelUser.setDelFlag(0); |
| | | couponRelUser.setCouponId(coupon.getCouponId()); |
| | | couponRelUser.setUserId(userId); |
| | | couponRelUserList.add(couponRelUser); |
| | | userIdSj.add(userId.toString()); |
| | | } |
| | | couponRelUserService.saveBatch(couponRelUserList); |
| | | coupon.setRelUserIds(userIdSj.toString()); |
| | | } |
| | | //处理优惠券发放 |
| | | if(coupon.getSendTimeType()==1){ |
| | |
| | | protected void sendCoupon(Coupon coupon, List<Long> relUserIdList){ |
| | | //1.手动领取2.全部用户3.会员用户4非会员用户5自定义 |
| | | Date nowTime = new Date(); |
| | | Integer sendType = coupon.getSendType(); |
| | | Integer sendTarget = coupon.getSendTarget(); |
| | | List<Long> userIdList = new ArrayList<>(); |
| | | Long shopId = null; |
| | | if(coupon.getCouponFrom()==2 && sendType==3){ |
| | | if(coupon.getCouponFrom()==2 && sendTarget==3){ |
| | | shopId = coupon.getShopId(); |
| | | } |
| | | if(sendType >= 2 && sendType <= 4){ |
| | | userIdList = memberService.listIdBySendType(sendType,shopId); |
| | | }else if(sendType == 5){ |
| | | if(sendTarget >= 2 && sendTarget <= 4){ |
| | | userIdList = memberService.listIdBySendType(sendTarget,shopId); |
| | | }else if(sendTarget == 5){ |
| | | //关联类型1.用户管理筛选2.活动管理筛选 |
| | | if(coupon.getRelationType()==2){ |
| | | Integer relationActivityType = coupon.getRelationActivityType(); |
| | |
| | | memberCoupon.setCouponStatus(coupon.getCouponStatus()); |
| | | memberCoupon.setCouponName(coupon.getCouponName()); |
| | | memberCoupon.setSendType(coupon.getSendType()); |
| | | memberCoupon.setSendTarget(coupon.getSendTarget()); |
| | | memberCoupon.setSendTimeType(coupon.getSendTimeType()); |
| | | memberCoupon.setSendTime(coupon.getSendTime()); |
| | | memberCoupon.setMoneyThreshold(coupon.getMoneyThreshold()); |
| | |
| | | private void sendCouponNow(Coupon coupon, List<Long> relUserIdList){ |
| | | //1.手动领取2.全部用户3.会员用户4非会员用户5自定义 |
| | | Date nowTime = new Date(); |
| | | Integer sendType = coupon.getSendType(); |
| | | Integer sendTarget = coupon.getSendTarget(); |
| | | List<Long> userIdList = new ArrayList<>(); |
| | | Long shopId = null; |
| | | if(coupon.getCouponFrom()==2 && sendType==3){ |
| | | if(coupon.getCouponFrom()==2 && sendTarget==3){ |
| | | shopId = coupon.getShopId(); |
| | | } |
| | | if(sendType >= 2 && sendType <= 4){ |
| | | userIdList = memberService.listIdBySendType(sendType,shopId); |
| | | }else if(sendType == 5){ |
| | | if(sendTarget >= 2 && sendTarget <= 4){ |
| | | userIdList = memberService.listIdBySendType(sendTarget,shopId); |
| | | }else if(sendTarget == 5){ |
| | | //关联类型1.用户管理筛选2.活动管理筛选 |
| | | if(coupon.getRelationType()==2){ |
| | | Integer relationActivityType = coupon.getRelationActivityType(); |
| | |
| | | memberCoupon.setCouponStatus(coupon.getCouponStatus()); |
| | | memberCoupon.setCouponName(coupon.getCouponName()); |
| | | memberCoupon.setSendType(coupon.getSendType()); |
| | | memberCoupon.setSendTarget(coupon.getSendTarget()); |
| | | memberCoupon.setSendTimeType(coupon.getSendTimeType()); |
| | | memberCoupon.setSendTime(coupon.getSendTime()); |
| | | memberCoupon.setMoneyThreshold(coupon.getMoneyThreshold()); |
| | |
| | | List<CouponRelUser> couponRelUserList; |
| | | List<Long> userIdList = new ArrayList<>(); |
| | | Coupon coupon = this.getById(couponId); |
| | | if(coupon.getSendType()==5&&coupon.getRelationType()==1){ |
| | | if(coupon.getSendTarget()==5&&coupon.getRelationType()==1){ |
| | | couponRelUserList = couponRelUserService.list(new LambdaQueryWrapper<CouponRelUser>().eq(CouponRelUser::getDelFlag,0).eq(CouponRelUser::getCouponId,coupon.getCouponId())); |
| | | if(couponRelUserList!=null&&!couponRelUserList.isEmpty()){ |
| | | userIdList = couponRelUserList.stream() |
| | |
| | | } |
| | | } |
| | | //判断优惠券是否指定发放用户 |
| | | if(coupon.getSendType()==5&&coupon.getRelationType()==1){ |
| | | if(coupon.getSendTarget()==5&&coupon.getRelationType()==1){ |
| | | //获取优惠券发放用户 |
| | | List<MgtCouponMemberListVo> relUserList = couponRelUserService.listCouponMemberVo(coupon.getCouponId()); |
| | | mgtCouponAuditGetVo.setRelUserList(relUserList); |
| | |
| | | coupon.setCouponType(merCouponEditDto.getCouponType()); |
| | | coupon.setCouponName(merCouponEditDto.getCouponName()); |
| | | coupon.setSendType(merCouponEditDto.getSendType()); |
| | | if(merCouponEditDto.getSendType()!=1){ |
| | | coupon.setSendType(merCouponEditDto.getSendTarget()); |
| | | } |
| | | coupon.setSendTarget(merCouponEditDto.getSendTarget()); |
| | | coupon.setSendTimeType(merCouponEditDto.getSendTimeType()); |
| | | coupon.setSendTime(merCouponEditDto.getSendTime()); |
| | | coupon.setMoneyThreshold(merCouponEditDto.getMoneyThreshold()); |
| | |
| | | } |
| | | //判断是否指定用户 |
| | | List<Long> relUserIdList = null; |
| | | if(coupon.getSendType()==5&&coupon.getRelationType()==1&&!merCouponEditDto.getRelUserIdList().isEmpty()){ |
| | | if(coupon.getSendTarget()==5&&coupon.getRelationType()==1&&!merCouponEditDto.getRelUserIdList().isEmpty()){ |
| | | relUserIdList = merCouponEditDto.getRelUserIdList(); |
| | | List<CouponRelUser> couponRelUserList = relUserIdList.stream() |
| | | .map(str -> { |
| | | CouponRelUser couponRelUser = new CouponRelUser(); |
| | | couponRelUser.setDelFlag(0); |
| | | couponRelUser.setCouponId(coupon.getCouponId()); |
| | | couponRelUser.setUserId(str); |
| | | return couponRelUser; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | List<CouponRelUser> couponRelUserList = new ArrayList<>(); |
| | | CouponRelUser couponRelUser; |
| | | StringJoiner userIdSj = new StringJoiner(","); |
| | | for(Long userId : relUserIdList){ |
| | | couponRelUser = new CouponRelUser(); |
| | | couponRelUser.setDelFlag(0); |
| | | couponRelUser.setCouponId(coupon.getCouponId()); |
| | | couponRelUser.setUserId(userId); |
| | | couponRelUserList.add(couponRelUser); |
| | | userIdSj.add(userId.toString()); |
| | | } |
| | | couponRelUserService.saveBatch(couponRelUserList); |
| | | coupon.setRelUserIds(userIdSj.toString()); |
| | | } |
| | | this.saveOrUpdate(coupon); |
| | | } |
| | |
| | | memberCoupon.setCouponStatus(coupon.getCouponStatus()); |
| | | memberCoupon.setCouponName(coupon.getCouponName()); |
| | | memberCoupon.setSendType(coupon.getSendType()); |
| | | memberCoupon.setSendTarget(coupon.getSendTarget()); |
| | | memberCoupon.setSendTimeType(coupon.getSendTimeType()); |
| | | memberCoupon.setSendTime(coupon.getSendTime()); |
| | | memberCoupon.setMoneyThreshold(coupon.getMoneyThreshold()); |
| | |
| | | * @return List<AppUnGetCouponPageVo> |
| | | */ |
| | | @Override |
| | | public List<AppGetAbleCouponPageVo> pageAppUserGetAbleCoupon(Page page, AppPageDto appPageDto, Long shopId){ |
| | | public List<AppGetAbleCouponPageVo> pageAppUserGetAbleCoupon(Page page, AppPageDto appPageDto, Member member){ |
| | | //获取当前已领取完优惠券 |
| | | List<String> unGetList = couponMapper.listUserUnGetCoupon(appPageDto.getUserId()); |
| | | List<AppGetAbleCouponPageVo> getAbleCouponPageVoList = couponMapper.getAbleCouponPageVoList(page, shopId, unGetList); |
| | | List<AppGetAbleCouponPageVo> getAbleCouponPageVoList = couponMapper.getAbleCouponPageVoList(page, member.getRelationShopId(),member.getUserId(),member.getBindingFlag(), unGetList); |
| | | //处理商品限制 |
| | | if(!getAbleCouponPageVoList.isEmpty()){ |
| | | String relGoodsIds; |
| | |
| | | memberCoupon.setCouponStatus(coupon.getCouponStatus()); |
| | | memberCoupon.setCouponName(coupon.getCouponName()); |
| | | memberCoupon.setSendType(coupon.getSendType()); |
| | | memberCoupon.setSendTarget(coupon.getSendTarget()); |
| | | memberCoupon.setSendTimeType(coupon.getSendTimeType()); |
| | | memberCoupon.setSendTime(coupon.getSendTime()); |
| | | memberCoupon.setMoneyThreshold(coupon.getMoneyThreshold()); |