From bb58e108a9da48d84b84d30b73c01106dd642550 Mon Sep 17 00:00:00 2001 From: jiangqs <jiangqs> Date: 星期三, 02 八月 2023 19:58:49 +0800 Subject: [PATCH] bug --- ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberCouponServiceImpl.java | 113 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 91 insertions(+), 22 deletions(-) diff --git a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberCouponServiceImpl.java b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberCouponServiceImpl.java index 7621352..32acc73 100644 --- a/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberCouponServiceImpl.java +++ b/ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberCouponServiceImpl.java @@ -4,24 +4,28 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.exception.ServiceException; +import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.member.domain.dto.AppMemberCouponPageDto; +import com.ruoyi.member.domain.dto.MerGoodsCouponListDto; import com.ruoyi.member.domain.vo.AppMemberCouponPageVo; import com.ruoyi.member.mapper.member.MemberCouponMapper; import com.ruoyi.member.service.member.MemberCouponService; import com.ruoyi.system.api.constant.AppErrorConstant; +import com.ruoyi.system.api.domain.dto.MerBaseDto; +import com.ruoyi.system.api.domain.dto.MgtBaseBathDto; import com.ruoyi.system.api.domain.poji.goods.Goods; 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.AppMemberCouponVo; +import com.ruoyi.system.api.domain.vo.MerMemberCouponVo; import com.ruoyi.system.api.domain.vo.MerVerifyCouponGetVo; +import com.ruoyi.system.api.domain.vo.MgtSimpleShopVo; import com.ruoyi.system.api.service.RemoteGoodsService; import com.ruoyi.system.api.service.RemoteShopService; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -44,6 +48,7 @@ @Resource private RemoteShopService remoteShopService; + /** * @description: TODO * @author jqs34 @@ -51,8 +56,8 @@ * @version 1.0 */ @Override - public List<AppMemberCouponVo> listVoMemberCouponByUserId(Long userId){ - List<AppMemberCouponVo> appMemberCouponVoList = memberCouponMapper.listVoMemberCouponByUserId(userId); + public List<AppMemberCouponVo> listVoMemberCouponByUserId(MerBaseDto merBaseDto){ + List<AppMemberCouponVo> appMemberCouponVoList = memberCouponMapper.listVoMemberCouponByUserId(merBaseDto); return appMemberCouponVoList; } @@ -76,7 +81,7 @@ throw new ServiceException(AppErrorConstant.COUPON_EXPIRED); } else if (couponStatus == 2) { throw new ServiceException(AppErrorConstant.COUPON_USED); - } else if (couponStatus != 0) { + } else if (couponStatus != 1) { throw new ServiceException(AppErrorConstant.COUPON_NO_FIND); } // 检查优惠券类型 @@ -118,7 +123,7 @@ throw new ServiceException(AppErrorConstant.COUPON_EXPIRED); }else if(memberCoupon.getCouponStatus()==2){ throw new ServiceException(AppErrorConstant.COUPON_USED); - }else if(memberCoupon.getCouponStatus()==-1){ + }else if(memberCoupon.getCouponStatus()!=1){ throw new ServiceException(AppErrorConstant.COUPON_NO_FIND); } if(memberCoupon.getCouponType()!=4){ @@ -138,6 +143,7 @@ merVerifyCouponGetVo.setCouponFrom("平台"); } memberCoupon.setCouponStatus(2); + memberCoupon.setUseTime(new Date()); this.saveOrUpdate(memberCoupon); merVerifyCouponGetVo.setMemberCoupon(memberCoupon); @@ -175,32 +181,95 @@ if(!memberCouponPageVoList.isEmpty()){ String relGoodsIds; List<Goods> goodsList; - List<String> goodsLimitList; - Shop shop = null; + List<String> goodsLimitList = null; + HashSet<Long> shopIdSet = new HashSet<>(); + for(AppMemberCouponPageVo appGetAbleCouponPageVo : memberCouponPageVoList){ + if(appGetAbleCouponPageVo.getShopId()!=null){ + shopIdSet.add(appGetAbleCouponPageVo.getShopId()); + } + if(appGetAbleCouponPageVo.getCouponType()==4){ + appGetAbleCouponPageVo.setVerifyCode("2-"+appGetAbleCouponPageVo.getMemberCouponId()); + } + } + 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(AppMemberCouponPageVo appGetAbleCouponPageVo : memberCouponPageVoList){ relGoodsIds = appGetAbleCouponPageVo.getRelGoodsIds(); - goodsList = remoteGoodsService.listGoodsByGoodsId(relGoodsIds).getData(); - if(!goodsList.isEmpty()){ - goodsLimitList = goodsList.stream().map(goods -> { - String goodsName = goods.getGoodsName(); - goodsName = "限制" + goodsName + "适用"; - return goodsName; - }).collect(Collectors.toList()); + if(StringUtils.isNotBlank(relGoodsIds)){ + goodsList = remoteGoodsService.listGoodsByGoodsId(relGoodsIds).getData(); + if(goodsList!=null&&!goodsList.isEmpty()){ + goodsLimitList = goodsList.stream().map(goods -> { + String goodsName = goods.getGoodsName(); + goodsName = "限制" + goodsName + "适用"; + return goodsName; + }).collect(Collectors.toList()); + } }else{ goodsLimitList = new ArrayList<>(); if(appGetAbleCouponPageVo.getShopId()!=null){ - if(shop!=null&&shop.getShopId().equals(appGetAbleCouponPageVo.getShopId())){ - }else{ - shop = remoteShopService.getShop(appGetAbleCouponPageVo.getShopId()).getData(); - } - goodsLimitList.add(shop.getShopName()+"通用"); + goodsLimitList.add(shopMap.get(appGetAbleCouponPageVo.getShopId()).getShopName()+"通用"); }else{ goodsLimitList.add("全场通用"); } } appGetAbleCouponPageVo.setGoodsLimitList(goodsLimitList); + if(appGetAbleCouponPageVo.getShopId()!=null){ + appGetAbleCouponPageVo.setVerifyShopName(shopMap.get(appGetAbleCouponPageVo.getShopId()).getShopName()); + } } } return memberCouponPageVoList; } + + /** + * @description 定时检查优惠券过期 + * @author jqs + * @date 2023/7/12 19:19 + * @param + * @return void + */ + @Override + public void timingCheckMemberCoupon(){ + memberCouponMapper.timingCheckMemberCoupon(); + } + + /** + * @description 使用优惠券 + * @author jqs + * @date 2023/7/13 19:38 + * @param memberCouponIds + * @return void + */ + @Override + public void useMemberCoupon(String memberCouponIds){ + memberCouponMapper.useMemberCoupon(memberCouponIds); + } + + /** + * @description 使用优惠券 + * @author jqs + * @date 2023/7/13 19:38 + * @param memberCouponIds + * @return void + */ + @Override + public void backMemberCoupon(String memberCouponIds){ + memberCouponMapper.backMemberCoupon(memberCouponIds); + } + + /** + * @description + * @author jqs + * @date 2023/7/19 17:35 + * @param + * @return List<MerMemberCouponVo> + */ + @Override + public List<MerMemberCouponVo> listMerShopGoodsMemberCoupon(MerGoodsCouponListDto merGoodsCouponListDto){ + return memberCouponMapper.listMerShopGoodsMemberCoupon(merGoodsCouponListDto); + } } -- Gitblit v1.7.1