| | |
| | | import com.ruoyi.member.domain.pojo.coupon.CouponRelGoods; |
| | | import com.ruoyi.member.domain.pojo.coupon.CouponRelUser; |
| | | import com.ruoyi.member.domain.pojo.coupon.CouponTotal; |
| | | import com.ruoyi.system.api.domain.dto.MerBaseGetDto; |
| | | import com.ruoyi.system.api.domain.dto.MerPageDto; |
| | | import com.ruoyi.system.api.domain.poji.member.MemberCoupon; |
| | | import com.ruoyi.member.domain.vo.*; |
| | |
| | | import com.ruoyi.system.api.constant.AppErrorConstant; |
| | | import com.ruoyi.system.api.domain.dto.MgtBaseGetDto; |
| | | import com.ruoyi.system.api.domain.poji.goods.Goods; |
| | | import com.ruoyi.system.api.domain.vo.MerGoodsPriceListVo; |
| | | import com.ruoyi.system.api.service.RemoteActivityService; |
| | | import com.ruoyi.system.api.service.RemoteGoodsService; |
| | | import org.springframework.scheduling.annotation.Async; |
| | |
| | | String relGoodsIds = coupon.getRelGoodsIds(); |
| | | if(StringUtils.isNotBlank(relGoodsIds)){ |
| | | //获取指定商品列表 |
| | | List<Goods> goodsList = remoteGoodsService.listGoodsByGoodsId(relGoodsIds).getData(); |
| | | List<MerGoodsPriceListVo> goodsList = remoteGoodsService.listGoodsPriceByGoodsId(relGoodsIds).getData(); |
| | | if(!goodsList.isEmpty()){ |
| | | //转换为返回对象 |
| | | List<MgtCouponGoodsListVo> relGoodsList = new ArrayList<>(); |
| | | MgtCouponGoodsListVo mgtCouponGoodsListVo; |
| | | for(Goods goods : goodsList){ |
| | | mgtCouponGoodsListVo = new MgtCouponGoodsListVo(); |
| | | mgtCouponGoodsListVo.setGoodsId(goods.getGoodsId()); |
| | | mgtCouponGoodsListVo.setGoodsName(goods.getGoodsName()); |
| | | mgtCouponGoodsListVo.setGoodsNo(goods.getGoodsNo()); |
| | | //商品类型1周期2服务3体验4单品 |
| | | switch (goods.getGoodsType()){ |
| | | case 1: |
| | | mgtCouponGoodsListVo.setGoodsType("周期"); |
| | | break; |
| | | case 2: |
| | | mgtCouponGoodsListVo.setGoodsType("服务"); |
| | | break; |
| | | case 3: |
| | | mgtCouponGoodsListVo.setGoodsType("体验"); |
| | | break; |
| | | case 4: |
| | | mgtCouponGoodsListVo.setGoodsType("单品"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | mgtCouponGoodsListVo.setSalesPrice(goods.getSalesPrice()); |
| | | relGoodsList.add(mgtCouponGoodsListVo); |
| | | } |
| | | merCouponGetVo.setRelGoodsList(relGoodsList); |
| | | merCouponGetVo.setRelGoodsList(goodsList); |
| | | } |
| | | } |
| | | } |
| | |
| | | Date nowTime = new Date(); |
| | | Integer sendType = coupon.getSendType(); |
| | | List<Long> userIdList = new ArrayList<>(); |
| | | Long shopId = null; |
| | | if(coupon.getCouponFrom()==2 && sendType==3){ |
| | | shopId = coupon.getShopId(); |
| | | } |
| | | if(sendType >= 2 && sendType <= 4){ |
| | | userIdList = memberService.listIdBySendType(sendType); |
| | | userIdList = memberService.listIdBySendType(sendType,shopId); |
| | | }else if(sendType == 5){ |
| | | //关联类型1.用户管理筛选2.活动管理筛选 |
| | | if(coupon.getRelationType()==2){ |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 平台获取优惠券列表 |
| | | * @description 获取商户优惠券列表 |
| | | * @author jqs |
| | | * @date 2023/6/30 16:53 |
| | | * @param page |
| | |
| | | * @return List<MerCouponPageVo> |
| | | */ |
| | | @Override |
| | | public List<MerCouponPageVo> pageShopMerCoupon(Page page, MerPageDto merPageDto){ |
| | | public List<MerCouponPageVo> pageShopMerCoupon(Page page, MerCouponPageDto merPageDto){ |
| | | List<MerCouponPageVo> couponPageVoList = couponMapper.pageShopMerCoupon(page, merPageDto); |
| | | //处理使用限制和有效期 |
| | | if(couponPageVoList!=null&&!couponPageVoList.isEmpty()){ |
| | |
| | | } |
| | | return couponPageVoList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @description 商户编辑优惠券 |
| | | * @author jqs |
| | | * @date 2023/7/3 9:21 |
| | | * @param merCouponEditDto |
| | | * @return void |
| | | */ |
| | | @Override |
| | | public void editMerCoupon(MerCouponEditDto merCouponEditDto){ |
| | | //编辑优惠券 |
| | | Coupon coupon; |
| | | CouponTotal couponTotal; |
| | | if(StringUtils.isNotBlank(merCouponEditDto.getCouponId())){ |
| | | coupon = this.getById(merCouponEditDto.getCouponId()); |
| | | if(coupon.getAuditStatus()!=3){ |
| | | throw new ServiceException(AppErrorConstant.COUPON_AUDIT_EDIT); |
| | | } |
| | | couponRelUserService.deleteCouponRelByCouponId(coupon.getCouponId()); |
| | | couponRelGoodsService.deleteCouponRelByCouponId(coupon.getCouponId()); |
| | | coupon.setCouponStatus(1); |
| | | }else{ |
| | | coupon = new Coupon(); |
| | | String couponId = IdUtils.simpleUUID(); |
| | | coupon.setCouponId(couponId); |
| | | coupon.setDelFlag(0); |
| | | coupon.setShopId(merCouponEditDto.getShopId()); |
| | | coupon.setCouponStatus(1); |
| | | coupon.setCreateTime(new Date()); |
| | | coupon.setCreateUserId(merCouponEditDto.getUserId()); |
| | | coupon.setCouponFrom(2); |
| | | //创建优惠券统计 |
| | | couponTotal = new CouponTotal(); |
| | | couponTotal.setCouponId(couponId); |
| | | couponTotal.setSendCount(0); |
| | | couponTotal.setSendUserCount(0); |
| | | couponTotalService.save(couponTotal); |
| | | } |
| | | //优惠券赋值 |
| | | coupon.setAuditStatus(1); |
| | | coupon.setCouponType(merCouponEditDto.getCouponType()); |
| | | coupon.setCouponName(merCouponEditDto.getCouponName()); |
| | | coupon.setSendType(merCouponEditDto.getSendType()); |
| | | coupon.setSendTimeType(merCouponEditDto.getSendTimeType()); |
| | | coupon.setSendTime(merCouponEditDto.getSendTime()); |
| | | coupon.setMoneyThreshold(merCouponEditDto.getMoneyThreshold()); |
| | | coupon.setDiscountMoney(merCouponEditDto.getDiscountMoney()); |
| | | coupon.setDiscountPercent(merCouponEditDto.getDiscountPercent()); |
| | | coupon.setUseScope(merCouponEditDto.getUseScope()); |
| | | coupon.setValidTimeType(merCouponEditDto.getValidTimeType()); |
| | | coupon.setValidStartTime(merCouponEditDto.getValidStartTime()); |
| | | coupon.setValidEndTime(merCouponEditDto.getValidEndTime()); |
| | | coupon.setValidDay(merCouponEditDto.getValidDay()); |
| | | coupon.setUpdateTime(new Date()); |
| | | coupon.setUpdateUserId(merCouponEditDto.getUserId()); |
| | | coupon.setRelationType(1); |
| | | //判断是否指定商品 |
| | | if(coupon.getUseScope()==2&&!merCouponEditDto.getRelGoodsIdList().isEmpty()){ |
| | | List<String> relGoodsIdList = merCouponEditDto.getRelGoodsIdList(); |
| | | List<CouponRelGoods> couponRelGoodsList = relGoodsIdList.stream() |
| | | .map(str -> { |
| | | CouponRelGoods couponRelGoods = new CouponRelGoods(); |
| | | couponRelGoods.setDelFlag(0); |
| | | couponRelGoods.setCouponId(coupon.getCouponId()); |
| | | couponRelGoods.setGoodsId(str); |
| | | return couponRelGoods; |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | couponRelGoodsService.saveBatch(couponRelGoodsList); |
| | | String relGoodsIds = relGoodsIdList.stream().collect(Collectors.joining(",")); |
| | | coupon.setRelGoodsIds(relGoodsIds); |
| | | } |
| | | //判断是否指定用户 |
| | | List<Long> relUserIdList = null; |
| | | if(coupon.getSendType()==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()); |
| | | couponRelUserService.saveBatch(couponRelUserList); |
| | | } |
| | | this.saveOrUpdate(coupon); |
| | | } |
| | | |
| | | /** |
| | | * @description 商户删除优惠券 |
| | | * @author jqs |
| | | * @date 2023/7/3 15:04 |
| | | * @param merBaseGetDto |
| | | * @return void |
| | | */ |
| | | @Override |
| | | public void deleteMerCoupon(MerBaseGetDto merBaseGetDto){ |
| | | Coupon coupon = this.getById(merBaseGetDto.getId()); |
| | | coupon.setCouponStatus(-1); |
| | | coupon.setDelFlag(1); |
| | | coupon.setUpdateUserId(merBaseGetDto.getUserId()); |
| | | coupon.setUpdateTime(new Date()); |
| | | this.saveOrUpdate(coupon); |
| | | } |
| | | } |