| | |
| | | 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 com.ruoyi.system.api.domain.vo.MgtSimpleShopVo; |
| | | import com.ruoyi.system.api.service.RemoteActivityService; |
| | | import com.ruoyi.system.api.service.RemoteConfigService; |
| | | import com.ruoyi.system.api.service.RemoteGoodsService; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | BigDecimal discountPercent; |
| | | String useLimit = ""; |
| | | for(MgtCouponPageVo mgtCouponPageVo : mgtCouponPageVoList){ |
| | | useLimit = null; |
| | | //处理使用限制 |
| | | couponType = mgtCouponPageVo.getCouponType(); |
| | | if(couponType.equals("满减")){ |
| | |
| | | discountMoney = mgtCouponPageVo.getDiscountMoney(); |
| | | useLimit = "满" + moneyThreshold.toString() + "减" + discountMoney.toString() + "元"; |
| | | } |
| | | if(couponType.equals("折扣")){ |
| | | moneyThreshold = mgtCouponPageVo.getMoneyThreshold(); |
| | | discountPercent = mgtCouponPageVo.getDiscountPercent(); |
| | | useLimit = discountPercent.toString() + "折"; |
| | | } |
| | | if(couponType.equals("代金")){ |
| | | discountMoney = mgtCouponPageVo.getDiscountMoney(); |
| | | useLimit = discountMoney.toString(); |
| | | } |
| | | mgtCouponPageVo.setUseLimit(useLimit); |
| | | //处理有效期 |
| | | validTimeType = mgtCouponPageVo.getValidTimeType(); |
| | | if(validTimeType==1){ |
| | | validStartTime = mgtCouponPageVo.getValidStartTime(); |
| | | validEndTime = mgtCouponPageVo.getValidEndTime(); |
| | | validTime = DateUtils.dateTime(validStartTime) + '-' + DateUtils.dateTime(validEndTime); |
| | | validTime = DateUtils.parseDateToStr("yyyy-MM-dd",validStartTime) + '-' + DateUtils.parseDateToStr("yyyy-MM-dd",validEndTime); |
| | | }else if(validTimeType==2){ |
| | | validDay = mgtCouponPageVo.getValidDay(); |
| | | validTime = "领取之日起" + validDay.toString() + "天"; |
| | |
| | | } |
| | | } |
| | | //判断优惠券是否指定发放用户 |
| | | if(coupon.getSendType()==5&&coupon.getRelationType()==1){ |
| | | if(coupon.getSendTarget()==5&&coupon.getRelationType()==1){ |
| | | //获取优惠券发放用户 |
| | | List<MgtCouponMemberListVo> relUserList = couponRelUserService.listCouponMemberVo(coupon.getCouponId()); |
| | | mgtCouponGetVo.setRelUserList(relUserList); |
| | |
| | | * @description 平台获取优惠券编辑信息 |
| | | * @author jqs |
| | | * @date 2023/6/13 14:29 |
| | | * @param couponId |
| | | * @param merBaseGetDto |
| | | * @return MgtCouponGetVo |
| | | */ |
| | | @Override |
| | | public MerCouponGetVo getMerCouponVo(String couponId){ |
| | | public MerCouponGetVo getMerCouponVo(MerBaseGetDto merBaseGetDto){ |
| | | MerCouponGetVo merCouponGetVo = new MerCouponGetVo(); |
| | | Coupon coupon = this.getById(couponId); |
| | | Coupon coupon = this.getById(merBaseGetDto.getId()); |
| | | BeanUtils.copyProperties(coupon, merCouponGetVo); |
| | | if(merCouponGetVo.getSendType()>1){ |
| | | merCouponGetVo.setSendType(2); |
| | | merCouponGetVo.setSendTarget(merCouponGetVo.getSendType()); |
| | | } |
| | | //判断优惠券是否为指定商品 |
| | | if(coupon.getUseScope()==2){ |
| | | String relGoodsIds = coupon.getRelGoodsIds(); |
| | | if(StringUtils.isNotBlank(relGoodsIds)){ |
| | | //获取指定商品列表 |
| | | List<MerGoodsPriceListVo> goodsList = remoteGoodsService.listGoodsPriceByGoodsId(relGoodsIds).getData(); |
| | | if(!goodsList.isEmpty()){ |
| | | MerGoodsPriceListDto merGoodsPriceListDto = new MerGoodsPriceListDto(); |
| | | merGoodsPriceListDto.setGoodsIds(relGoodsIds); |
| | | merGoodsPriceListDto.setShopId(merBaseGetDto.getShopId()); |
| | | List<MerGoodsPriceListVo> goodsList = remoteGoodsService.listGoodsPriceByGoodsId(merGoodsPriceListDto).getData(); |
| | | if(goodsList!=null&&!goodsList.isEmpty()){ |
| | | merCouponGetVo.setRelGoodsList(goodsList); |
| | | } |
| | | } |
| | | } |
| | | //判断优惠券是否指定发放用户 |
| | | 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()); |
| | |
| | | coupon.setRelationType(mgtCouponEditDto.getRelationType()); |
| | | coupon.setRelationActivityType(mgtCouponEditDto.getRelationActivityType()); |
| | | coupon.setRelationActivityId(mgtCouponEditDto.getRelationActivityId()); |
| | | coupon.setPropagandaPoster(mgtCouponEditDto.getPropagandaPoster()); |
| | | //判断是否指定商品 |
| | | if(coupon.getUseScope()==2&&!mgtCouponEditDto.getRelGoodsIdList().isEmpty()){ |
| | | List<String> relGoodsIdList = mgtCouponEditDto.getRelGoodsIdList(); |
| | |
| | | } |
| | | //判断是否指定用户 |
| | | List<Long> relUserIdList = null; |
| | | if(coupon.getSendType()==5&&coupon.getRelationType()==1&&!mgtCouponEditDto.getRelUserIdList().isEmpty()){ |
| | | if(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){ |
| | | if(coupon.getSendType()==2&&coupon.getSendTimeType()==1){ |
| | | sendCoupon(coupon,relUserIdList); |
| | | coupon.setSendFlag(1); |
| | | this.saveOrUpdate(coupon); |
| | |
| | | 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(); |
| | |
| | | userIdList = relUserIdList; |
| | | } |
| | | } |
| | | if(relUserIdList!=null&&!relUserIdList.isEmpty()){ |
| | | if(userIdList!=null&&!userIdList.isEmpty()){ |
| | | List<MemberCoupon> memberCouponList = new ArrayList<>(); |
| | | MemberCoupon memberCoupon; |
| | | Integer sendTotal = 0; |
| | |
| | | String memberCouponId; |
| | | Integer sendUserTotal; |
| | | for(Long userId : userIdList){ |
| | | memberCouponId = IdUtils.simpleUUID(); |
| | | memberCoupon = new MemberCoupon(); |
| | | memberCoupon.setId(memberCouponId); |
| | | memberCoupon.setDelFlag(0); |
| | | memberCoupon.setCouponId(coupon.getCouponId()); |
| | | memberCoupon.setUserId(userId); |
| | | memberCoupon.setShopId(coupon.getShopId()); |
| | | memberCoupon.setCouponType(coupon.getCouponType()); |
| | | memberCoupon.setCouponStatus(coupon.getCouponStatus()); |
| | | memberCoupon.setCouponName(coupon.getCouponName()); |
| | | memberCoupon.setSendType(coupon.getSendType()); |
| | | memberCoupon.setSendTimeType(coupon.getSendTimeType()); |
| | | memberCoupon.setSendTime(coupon.getSendTime()); |
| | | memberCoupon.setMoneyThreshold(coupon.getMoneyThreshold()); |
| | | memberCoupon.setDiscountMoney(coupon.getDiscountMoney()); |
| | | memberCoupon.setDiscountPercent(coupon.getDiscountPercent()); |
| | | memberCoupon.setUseScope(coupon.getUseScope()); |
| | | memberCoupon.setValidTimeType(coupon.getValidTimeType()); |
| | | memberCoupon.setValidStartTime(coupon.getValidStartTime()); |
| | | memberCoupon.setValidEndTime(coupon.getValidEndTime()); |
| | | memberCoupon.setValidDay(coupon.getValidDay()); |
| | | memberCoupon.setReceiveTime(nowTime); |
| | | memberCoupon.setRelGoodsIds(coupon.getRelGoodsIds()); |
| | | //有效期处理1.时间段2.领取之日起 |
| | | if(coupon.getValidTimeType()==1){ |
| | | memberCoupon.setDeadlineTime(coupon.getValidEndTime()); |
| | | }else if(coupon.getValidTimeType()==2){ |
| | | memberCoupon.setDeadlineTime(DateUtils.addDays(nowTime,coupon.getValidDay())); |
| | | if(coupon.getCouponFrom()==2){ |
| | | for(int i=0;i<coupon.getLimitNumber();i++){ |
| | | memberCouponId = IdUtils.simpleUUID(); |
| | | memberCoupon = new MemberCoupon(); |
| | | memberCoupon.setId(memberCouponId); |
| | | memberCoupon.setDelFlag(0); |
| | | memberCoupon.setCouponId(coupon.getCouponId()); |
| | | memberCoupon.setUserId(userId); |
| | | memberCoupon.setShopId(coupon.getShopId()); |
| | | memberCoupon.setCouponType(coupon.getCouponType()); |
| | | 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()); |
| | | memberCoupon.setDiscountMoney(coupon.getDiscountMoney()); |
| | | memberCoupon.setDiscountPercent(coupon.getDiscountPercent()); |
| | | memberCoupon.setUseScope(coupon.getUseScope()); |
| | | memberCoupon.setValidTimeType(coupon.getValidTimeType()); |
| | | memberCoupon.setValidStartTime(coupon.getValidStartTime()); |
| | | memberCoupon.setValidEndTime(coupon.getValidEndTime()); |
| | | memberCoupon.setValidDay(coupon.getValidDay()); |
| | | memberCoupon.setCouponFrom(coupon.getCouponFrom()); |
| | | memberCoupon.setReceiveTime(nowTime); |
| | | memberCoupon.setRelGoodsIds(coupon.getRelGoodsIds()); |
| | | //有效期处理1.时间段2.领取之日起 |
| | | if(coupon.getValidTimeType()==1){ |
| | | memberCoupon.setDeadlineTime(coupon.getValidEndTime()); |
| | | }else if(coupon.getValidTimeType()==2){ |
| | | memberCoupon.setDeadlineTime(DateUtils.addDays(nowTime,coupon.getValidDay())); |
| | | } |
| | | memberCouponList.add(memberCoupon); |
| | | sendTotal = sendTotal + 1; |
| | | if(coupon.getSendType()==1){ |
| | | sendUserTotal = memberCouponService.totalMemberCouponByUserAndCoupon(userId,coupon.getCouponId()); |
| | | if(sendUserTotal!=null&&sendUserTotal>0){ |
| | | }else{ |
| | | sendPerson = sendPerson + 1; |
| | | } |
| | | } |
| | | memberCouponRecordService.updateMemberCouponRecord(coupon,userId,1); |
| | | } |
| | | }else{ |
| | | memberCouponId = IdUtils.simpleUUID(); |
| | | memberCoupon = new MemberCoupon(); |
| | | memberCoupon.setId(memberCouponId); |
| | | memberCoupon.setDelFlag(0); |
| | | memberCoupon.setCouponId(coupon.getCouponId()); |
| | | memberCoupon.setUserId(userId); |
| | | //memberCoupon.setShopId(coupon.getShopId()); |
| | | memberCoupon.setCouponType(coupon.getCouponType()); |
| | | 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()); |
| | | memberCoupon.setDiscountMoney(coupon.getDiscountMoney()); |
| | | memberCoupon.setDiscountPercent(coupon.getDiscountPercent()); |
| | | memberCoupon.setUseScope(coupon.getUseScope()); |
| | | memberCoupon.setValidTimeType(coupon.getValidTimeType()); |
| | | memberCoupon.setValidStartTime(coupon.getValidStartTime()); |
| | | memberCoupon.setValidEndTime(coupon.getValidEndTime()); |
| | | memberCoupon.setValidDay(coupon.getValidDay()); |
| | | memberCoupon.setCouponFrom(coupon.getCouponFrom()); |
| | | memberCoupon.setReceiveTime(nowTime); |
| | | memberCoupon.setRelGoodsIds(coupon.getRelGoodsIds()); |
| | | //有效期处理1.时间段2.领取之日起 |
| | | if(coupon.getValidTimeType()==1){ |
| | | memberCoupon.setDeadlineTime(coupon.getValidEndTime()); |
| | | }else if(coupon.getValidTimeType()==2){ |
| | | memberCoupon.setDeadlineTime(DateUtils.addDays(nowTime,coupon.getValidDay())); |
| | | } |
| | | memberCouponList.add(memberCoupon); |
| | | sendTotal = sendTotal + 1; |
| | | if(coupon.getSendType()==1){ |
| | | sendUserTotal = memberCouponService.totalMemberCouponByUserAndCoupon(userId,coupon.getCouponId()); |
| | | if(sendUserTotal!=null&&sendUserTotal>0){ |
| | | }else{ |
| | | sendPerson = sendPerson + 1; |
| | | } |
| | | } |
| | | memberCouponRecordService.updateMemberCouponRecord(coupon,userId,1); |
| | | } |
| | | memberCouponList.add(memberCoupon); |
| | | sendTotal = sendTotal + 1; |
| | | if(coupon.getSendType()==1){ |
| | | sendUserTotal = memberCouponService.totalMemberCouponByUserAndCoupon(userId,coupon.getCouponId()); |
| | | if(sendUserTotal!=null&&sendUserTotal>0){ |
| | | }else{ |
| | | sendPerson = sendPerson + 1; |
| | | } |
| | | } |
| | | memberCouponRecordService.updateMemberCouponRecord(coupon,userId,1); |
| | | } |
| | | memberCouponService.saveBatch(memberCouponList); |
| | | //处理优惠券统计 |
| | |
| | | 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.setDelFlag(0); |
| | | memberCoupon.setCouponId(coupon.getCouponId()); |
| | | memberCoupon.setUserId(userId); |
| | | memberCoupon.setShopId(coupon.getShopId()); |
| | | if(coupon.getCouponFrom()==2){ |
| | | memberCoupon.setShopId(coupon.getShopId()); |
| | | } |
| | | memberCoupon.setCouponType(coupon.getCouponType()); |
| | | 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()); |
| | |
| | | memberCoupon.setValidStartTime(coupon.getValidStartTime()); |
| | | memberCoupon.setValidEndTime(coupon.getValidEndTime()); |
| | | memberCoupon.setValidDay(coupon.getValidDay()); |
| | | memberCoupon.setCouponFrom(coupon.getCouponFrom()); |
| | | memberCoupon.setReceiveTime(nowTime); |
| | | memberCoupon.setRelGoodsIds(coupon.getRelGoodsIds()); |
| | | //有效期处理1.时间段2.领取之日起 |
| | |
| | | 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() |
| | |
| | | Date validEndTime; |
| | | Integer validDay; |
| | | String validTime = ""; |
| | | HashSet<Long> shopIdSet = new HashSet<>(); |
| | | for(MgtCouponAuditPageVo mgtCouponAuditPageVo : mgtCouponAuditPageVoList){ |
| | | //处理有效期 |
| | | validTimeType = mgtCouponAuditPageVo.getValidTimeType(); |
| | | if(validTimeType==1){ |
| | | validStartTime = mgtCouponAuditPageVo.getValidStartTime(); |
| | | validEndTime = mgtCouponAuditPageVo.getValidEndTime(); |
| | | validTime = DateUtils.dateTime(validStartTime) + '-' + DateUtils.dateTime(validEndTime); |
| | | validTime = DateUtils.parseDateToStr("yyyy-MM-dd",validStartTime) + '-' + DateUtils.parseDateToStr("yyyy-MM-dd",validEndTime); |
| | | }else if(validTimeType==2){ |
| | | validDay = mgtCouponAuditPageVo.getValidDay(); |
| | | validTime = "领取之日起" + validDay.toString() + "天"; |
| | | } |
| | | mgtCouponAuditPageVo.setValidTime(validTime); |
| | | if(mgtCouponAuditPageVo.getShopId()!=null){ |
| | | shopIdSet.add(mgtCouponAuditPageVo.getShopId()); |
| | | } |
| | | } |
| | | String shopJoinedString = String.join(",", shopIdSet.stream().map(Object::toString).collect(Collectors.toList())); |
| | | MgtBaseBathDto mgtBaseBathDto = new MgtBaseBathDto(); |
| | | mgtBaseBathDto.setIds(shopJoinedString); |
| | | List<MgtSimpleShopVo> simpleShopVoList = remoteShopService.listShopSimpleVoByIds(mgtBaseBathDto).getData(); |
| | | Map<Long, MgtSimpleShopVo> shopMap = simpleShopVoList.stream() |
| | | .collect(Collectors.toMap(MgtSimpleShopVo::getShopId, Function.identity())); |
| | | for(MgtCouponAuditPageVo mgtCouponAuditPageVo : mgtCouponAuditPageVoList){ |
| | | if(mgtCouponAuditPageVo.getShopId()!=null){ |
| | | mgtCouponAuditPageVo.setShopName(shopMap.get(mgtCouponAuditPageVo.getShopId()).getShopName()); |
| | | } |
| | | } |
| | | } |
| | | return mgtCouponAuditPageVoList; |
| | |
| | | } |
| | | } |
| | | //判断优惠券是否指定发放用户 |
| | | if(coupon.getSendType()==5&&coupon.getRelationType()==1){ |
| | | if(coupon.getSendTarget()==5&&coupon.getRelationType()==1){ |
| | | //获取优惠券发放用户 |
| | | List<MgtCouponMemberListVo> relUserList = couponRelUserService.listCouponMemberVo(coupon.getCouponId()); |
| | | mgtCouponAuditGetVo.setRelUserList(relUserList); |
| | |
| | | public void auditMgtCoupon(MgtCouponAuditDto mgtCouponAuditDto){ |
| | | Coupon coupon = this.getById(mgtCouponAuditDto.getCouponId()); |
| | | //判断优惠券是否审核 |
| | | if(coupon.getCouponStatus()!=1){ |
| | | if(coupon.getAuditStatus()!=1){ |
| | | throw new ServiceException(AppErrorConstant.COUPON_AUDIT_DOUBLE); |
| | | } |
| | | coupon.setAuditStatus(mgtCouponAuditDto.getAuditStatus()); |
| | |
| | | coupon.setUpdateTime(new Date()); |
| | | coupon.setUpdateUserId(mgtCouponAuditDto.getUserId()); |
| | | //审核通过后判断是否立即发放 |
| | | if(coupon.getCouponStatus()==2&&coupon.getSendTimeType()==1){ |
| | | if(coupon.getAuditStatus()==2&&coupon.getSendType()==2&&coupon.getSendTimeType()==1){ |
| | | List<CouponRelUser> couponRelUserList = couponRelUserService.list(new LambdaQueryWrapper<CouponRelUser>().eq(CouponRelUser::getDelFlag,0).eq(CouponRelUser::getCouponId,coupon.getCouponId())); |
| | | List<Long> userIdList = new ArrayList<>(); |
| | | if(couponRelUserList!=null&&!couponRelUserList.isEmpty()){ |
| | |
| | | if(validTimeType==1){ |
| | | validStartTime = merCouponPageVo.getValidStartTime(); |
| | | validEndTime = merCouponPageVo.getValidEndTime(); |
| | | validTime = DateUtils.dateTime(validStartTime) + '-' + DateUtils.dateTime(validEndTime); |
| | | validTime = DateUtils.parseDateToStr("yyyy.MM.dd",validStartTime) + '-' + DateUtils.parseDateToStr("yyyy.MM.dd",validEndTime); |
| | | }else if(validTimeType==2){ |
| | | validDay = merCouponPageVo.getValidDay(); |
| | | validTime = "领取之日起" + validDay.toString() + "天"; |
| | | } |
| | | merCouponPageVo.setValidTime(validTime); |
| | | merCouponPageVo.setCouponCode("https://hongruitang.oss-cn-beijing.aliyuncs.com/2023/8/3/couponCode.jpg"); |
| | | } |
| | | } |
| | | return couponPageVoList; |
| | |
| | | if(validTimeType==1){ |
| | | validStartTime = merCouponPageVo.getValidStartTime(); |
| | | validEndTime = merCouponPageVo.getValidEndTime(); |
| | | validTime = DateUtils.dateTime(validStartTime) + '-' + DateUtils.dateTime(validEndTime); |
| | | validTime = DateUtils.parseDateToStr("yyyy.MM.dd",validStartTime) + '-' + DateUtils.parseDateToStr("yyyy.MM.dd",validEndTime); |
| | | }else if(validTimeType==2){ |
| | | validDay = merCouponPageVo.getValidDay(); |
| | | validTime = "领取之日起" + validDay.toString() + "天"; |
| | |
| | | coupon.setCouponType(merCouponEditDto.getCouponType()); |
| | | coupon.setCouponName(merCouponEditDto.getCouponName()); |
| | | coupon.setSendType(merCouponEditDto.getSendType()); |
| | | if(merCouponEditDto.getSendType()!=1){ |
| | | coupon.setSendType(merCouponEditDto.getSendTarget()); |
| | | } |
| | | coupon.setSendTimeType(merCouponEditDto.getSendTimeType()); |
| | | coupon.setSendTarget(merCouponEditDto.getSendTarget()); |
| | | //商户端默认立即发放 |
| | | coupon.setSendTimeType(1); |
| | | coupon.setSendTime(merCouponEditDto.getSendTime()); |
| | | coupon.setMoneyThreshold(merCouponEditDto.getMoneyThreshold()); |
| | | coupon.setDiscountMoney(merCouponEditDto.getDiscountMoney()); |
| | |
| | | coupon.setValidTimeType(merCouponEditDto.getValidTimeType()); |
| | | coupon.setValidStartTime(merCouponEditDto.getValidStartTime()); |
| | | coupon.setValidEndTime(merCouponEditDto.getValidEndTime()); |
| | | coupon.setLimitNumber(merCouponEditDto.getLimitNumber()); |
| | | coupon.setValidDay(merCouponEditDto.getValidDay()); |
| | | coupon.setUpdateTime(new Date()); |
| | | coupon.setUpdateUserId(merCouponEditDto.getUserId()); |
| | | coupon.setRelationType(1); |
| | | coupon.setPropagandaPoster(merCouponEditDto.getPropagandaPoster()); |
| | | //判断是否指定商品 |
| | | if(coupon.getUseScope()==2&&!merCouponEditDto.getRelGoodsIdList().isEmpty()){ |
| | | List<String> relGoodsIdList = merCouponEditDto.getRelGoodsIdList(); |
| | |
| | | } |
| | | //判断是否指定用户 |
| | | 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); |
| | | } |
| | |
| | | for(BirthdayGiftSendDto birthdayGiftSendDto : giftSendDtoList){ |
| | | couponId = birthdayGiftSendDto.getCouponId(); |
| | | coupon = this.getById(couponId); |
| | | if(coupon==null||coupon.getCouponStatus()!=1){ |
| | | throw new ServiceException(AppErrorConstant.COUPON_GET_ERROR); |
| | | } |
| | | for(int i=0;i<birthdayGiftSendDto.getCouponNumber();i++){ |
| | | memberCoupon = new MemberCoupon(); |
| | | memberCouponId = IdUtils.simpleUUID(); |
| | |
| | | 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()); |
| | |
| | | memberCoupon.setValidStartTime(coupon.getValidStartTime()); |
| | | memberCoupon.setValidEndTime(coupon.getValidEndTime()); |
| | | memberCoupon.setValidDay(coupon.getValidDay()); |
| | | memberCoupon.setCouponFrom(coupon.getCouponFrom()); |
| | | memberCoupon.setReceiveTime(new Date()); |
| | | //有效期处理1.时间段2.领取之日起 |
| | | if(coupon.getValidTimeType()==1){ |
| | |
| | | * @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; |
| | |
| | | relGoodsIds = appGetAbleCouponPageVo.getRelGoodsIds(); |
| | | if(StringUtils.isNotBlank(relGoodsIds)){ |
| | | goodsList = remoteGoodsService.listGoodsByGoodsId(relGoodsIds).getData(); |
| | | if(!goodsList.isEmpty()){ |
| | | if(goodsList!=null&&!goodsList.isEmpty()){ |
| | | goodsLimitList = goodsList.stream().map(goods -> { |
| | | String goodsName = goods.getGoodsName(); |
| | | goodsName = "限制" + goodsName + "适用"; |
| | |
| | | memberCoupon.setDelFlag(0); |
| | | memberCoupon.setCouponId(couponId); |
| | | memberCoupon.setUserId(userId); |
| | | memberCoupon.setShopId(shopId); |
| | | if(coupon.getCouponFrom()==2){ |
| | | memberCoupon.setShopId(shopId); |
| | | } |
| | | memberCoupon.setCouponType(coupon.getCouponType()); |
| | | 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()); |
| | |
| | | memberCoupon.setValidStartTime(coupon.getValidStartTime()); |
| | | memberCoupon.setValidEndTime(coupon.getValidEndTime()); |
| | | memberCoupon.setValidDay(coupon.getValidDay()); |
| | | memberCoupon.setCouponFrom(coupon.getCouponFrom()); |
| | | memberCoupon.setReceiveTime(new Date()); |
| | | //有效期处理1.时间段2.领取之日起 |
| | | if(coupon.getValidTimeType()==1){ |
| | |
| | | memberCouponRecordService.updateMemberCouponRecord(coupon,userId,1); |
| | | } |
| | | |
| | | /** |
| | | * @description 获取商户优惠券审核统计 |
| | | * @author jqs |
| | | * @date 2023/7/28 11:30 |
| | | * @param shopId |
| | | * @return MetAuditCouponTotalVo |
| | | */ |
| | | @Override |
| | | public MetAuditCouponTotalVo getMetAuditCouponTotal(Long shopId){ |
| | | MetAuditCouponTotalVo metAuditCouponTotalVo = new MetAuditCouponTotalVo(); |
| | | LambdaQueryWrapper<Coupon> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Coupon::getDelFlag,0); |
| | | queryWrapper.eq(Coupon::getCouponFrom,2); |
| | | queryWrapper.eq(Coupon::getShopId,shopId); |
| | | queryWrapper.eq(Coupon::getCouponStatus,1); |
| | | queryWrapper.eq(Coupon::getAuditStatus,1); |
| | | Integer unAuditTotal = this.count(queryWrapper); |
| | | queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(Coupon::getDelFlag,0); |
| | | queryWrapper.eq(Coupon::getCouponFrom,2); |
| | | queryWrapper.eq(Coupon::getShopId,shopId); |
| | | queryWrapper.eq(Coupon::getCouponStatus,1); |
| | | queryWrapper.eq(Coupon::getAuditStatus,3); |
| | | Integer refuseTotal = this.count(queryWrapper); |
| | | metAuditCouponTotalVo.setUnAuditTotal(unAuditTotal); |
| | | metAuditCouponTotalVo.setRefuseTotal(refuseTotal); |
| | | return metAuditCouponTotalVo; |
| | | } |
| | | } |