| | |
| | | import com.ruoyi.system.api.constant.AppErrorConstant; |
| | | import com.ruoyi.system.api.constant.DelayTaskEnum; |
| | | import com.ruoyi.system.api.domain.dto.*; |
| | | import com.ruoyi.system.api.domain.poji.activity.Activity; |
| | | 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.service.RemoteShopService; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | |
| | | List<MgtCouponMemberListVo> relUserList = couponRelUserService.listCouponMemberVo(coupon.getCouponId()); |
| | | mgtCouponGetVo.setRelUserList(relUserList); |
| | | } |
| | | //获取活动名称 |
| | | if(coupon.getSendTarget()==5&&coupon.getRelationType()==2){ |
| | | Activity activity = remoteActivityService.getActivity(coupon.getRelationActivityId()).getData(); |
| | | mgtCouponGetVo.setRelationActivityName(activity.getActivityName()); |
| | | } |
| | | if(mgtCouponGetVo.getSendLimitFlag()==0){ |
| | | mgtCouponGetVo.setSendLimitNumber(null); |
| | | } |
| | | return mgtCouponGetVo; |
| | | } |
| | | |
| | |
| | | //获取优惠券发放用户 |
| | | List<MgtCouponMemberListVo> relUserList = couponRelUserService.listCouponMemberVo(coupon.getCouponId()); |
| | | merCouponGetVo.setRelUserList(relUserList); |
| | | } |
| | | if(merCouponGetVo.getSendLimitFlag()==0){ |
| | | merCouponGetVo.setSendLimitNumber(null); |
| | | } |
| | | return merCouponGetVo; |
| | | } |
| | |
| | | coupon.setRelationActivityType(mgtCouponEditDto.getRelationActivityType()); |
| | | coupon.setRelationActivityId(mgtCouponEditDto.getRelationActivityId()); |
| | | coupon.setPropagandaPoster(mgtCouponEditDto.getPropagandaPoster()); |
| | | coupon.setSendLimitNumber(mgtCouponEditDto.getSendLimitNumber()); |
| | | //指定发放优惠券不做发放数限制 |
| | | if(coupon.getSendType()==2){ |
| | | mgtCouponEditDto.setSendLimitFlag(0); |
| | | } |
| | | coupon.setSendLimitFlag(mgtCouponEditDto.getSendLimitFlag()); |
| | | if(mgtCouponEditDto.getSendLimitFlag()==1){ |
| | | coupon.setSendLimitNumber(mgtCouponEditDto.getSendLimitNumber()); |
| | | }else{ |
| | | coupon.setSendLimitNumber(0); |
| | | } |
| | | coupon.setLimitNumber(mgtCouponEditDto.getLimitNumber()); |
| | | //判断是否指定商品 |
| | | if(coupon.getUseScope()==2&&!mgtCouponEditDto.getRelGoodsIdList().isEmpty()){ |
| | | List<String> relGoodsIdList = mgtCouponEditDto.getRelGoodsIdList(); |
| | |
| | | coupon.setUpdateUserId(merCouponEditDto.getUserId()); |
| | | coupon.setRelationType(1); |
| | | coupon.setPropagandaPoster(merCouponEditDto.getPropagandaPoster()); |
| | | coupon.setSendLimitNumber(merCouponEditDto.getSendLimitNumber()); |
| | | //指定发放优惠券不做发放数限制 |
| | | if(coupon.getSendType()==2){ |
| | | merCouponEditDto.setSendLimitFlag(0); |
| | | } |
| | | coupon.setSendLimitFlag(merCouponEditDto.getSendLimitFlag()); |
| | | if(merCouponEditDto.getSendLimitFlag()==1){ |
| | | coupon.setSendLimitNumber(merCouponEditDto.getSendLimitNumber()); |
| | | }else{ |
| | | coupon.setSendLimitNumber(0); |
| | | } |
| | | //判断是否指定商品 |
| | | if(coupon.getUseScope()==2&&!merCouponEditDto.getRelGoodsIdList().isEmpty()){ |
| | | List<String> relGoodsIdList = merCouponEditDto.getRelGoodsIdList(); |
| | |
| | | if(!getAbleCouponPageVoList.isEmpty()){ |
| | | String relGoodsIds; |
| | | HashSet<Long> shopIdSet = new HashSet<>(); |
| | | HashSet<Long> goodsIdSet = new HashSet<>(); |
| | | HashSet<String> goodsIdSet = new HashSet<>(); |
| | | String[] goodsIdArr; |
| | | for(AppGetAbleCouponPageVo getAbleCouponPageVo : getAbleCouponPageVoList){ |
| | | if(getAbleCouponPageVo.getShopId()!=null){ |
| | | shopIdSet.add(getAbleCouponPageVo.getShopId()); |
| | | } |
| | | if(StringUtils.isNotBlank(getAbleCouponPageVo.getRelGoodsIds())&&!getAbleCouponPageVo.getRelGoodsIds().contains(",")){ |
| | | goodsIdSet.add(Long.valueOf(getAbleCouponPageVo.getRelGoodsIds())); |
| | | if(StringUtils.isNotBlank(getAbleCouponPageVo.getRelGoodsIds())){ |
| | | relGoodsIds = getAbleCouponPageVo.getRelGoodsIds(); |
| | | goodsIdArr = relGoodsIds.split(","); |
| | | for(String str : goodsIdArr){ |
| | | goodsIdSet.add(str); |
| | | } |
| | | } |
| | | } |
| | | //获取关联商户和商品信息并转换为Map |
| | | String shopJoinedString = String.join(",", shopIdSet.stream().map(Object::toString).collect(Collectors.toList())); |
| | | String shopJoinedString; |
| | | Map<Long, MgtSimpleShopVo> shopMap = null; |
| | | if(shopIdSet!=null&&!shopIdSet.isEmpty()) { |
| | | 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(); |
| | | shopMap = simpleShopVoList.stream() |
| | | .collect(Collectors.toMap(MgtSimpleShopVo::getShopId, Function.identity())); |
| | | } |
| | | String goodsJoinedString = null; |
| | | if(goodsIdSet!=null&&!goodsIdSet.isEmpty()){ |
| | | goodsJoinedString = String.join(",", goodsIdSet.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())); |
| | | Map<String, Goods> goodsMap = null; |
| | | if(goodsJoinedString!=null){ |
| | | List<Goods> goodsList = remoteGoodsService.listGoodsByGoodsId(goodsJoinedString).getData(); |
| | |
| | | .collect(Collectors.toMap(Goods::getGoodsId, Function.identity())); |
| | | } |
| | | //处理返回信息 |
| | | String shopLimit = "全场通用"; |
| | | String goodsLimit = null; |
| | | String shopLimit = "全门店通用"; |
| | | String goodsLimit; |
| | | StringJoiner goodsNameSj; |
| | | for(AppGetAbleCouponPageVo getAbleCouponPageVo : getAbleCouponPageVoList){ |
| | | goodsLimit = null; |
| | | goodsNameSj = new StringJoiner(","); |
| | | //商户限制 |
| | | if(getAbleCouponPageVo.getShopId()!=null){ |
| | | if(!member.getRelationShopId().equals(getAbleCouponPageVo.getShopId())){ |
| | | shopLimit = shopMap.get(getAbleCouponPageVo.getShopId()).getShopName()+"可用"; |
| | | } |
| | | shopLimit = shopMap.get(getAbleCouponPageVo.getShopId()).getShopName()+"可用"; |
| | | } |
| | | getAbleCouponPageVo.setShopLimit(shopLimit); |
| | | //商品限制 |
| | | relGoodsIds = getAbleCouponPageVo.getRelGoodsIds(); |
| | | if(StringUtils.isNotBlank(relGoodsIds)&&!relGoodsIds.contains(",")){ |
| | | goodsLimit = goodsMap.get(relGoodsIds).getGoodsName(); |
| | | if(StringUtils.isNotBlank(getAbleCouponPageVo.getRelGoodsIds())){ |
| | | relGoodsIds = getAbleCouponPageVo.getRelGoodsIds(); |
| | | goodsIdArr = relGoodsIds.split(","); |
| | | for(String goodsIs : goodsIdArr){ |
| | | if(goodsMap.get(goodsIs)!=null){ |
| | | goodsNameSj.add(goodsMap.get(goodsIs).getGoodsName()); |
| | | }else{ |
| | | log.debug("用户优惠券未找到关联商品"+getAbleCouponPageVo.getCouponId()+"-"+getAbleCouponPageVo.getRelGoodsIds()); |
| | | } |
| | | } |
| | | goodsLimit = goodsNameSj.toString(); |
| | | } |
| | | getAbleCouponPageVo.setGoodsLimit(goodsLimit); |
| | | } |
| | |
| | | * @return void |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void appGetCoupon(String couponId,Long userId,Long shopId){ |
| | | Coupon coupon = this.getById(couponId); |
| | | //判断优惠券状态 |