| | |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.common.collect.Lists; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.enums.*; |
| | | import com.ruoyi.common.core.enums.ClientTypeEnum; |
| | | import com.ruoyi.common.core.enums.GroupStatusEnum; |
| | | import com.ruoyi.common.core.enums.ListingStatusEnum; |
| | | import com.ruoyi.common.core.enums.OrderFromEnum; |
| | | import com.ruoyi.common.core.enums.OrderStatusEnum; |
| | | import com.ruoyi.common.core.enums.StartStatusEnum; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | |
| | | import com.ruoyi.goods.service.IGoodsSkuService; |
| | | import com.ruoyi.goods.service.IMemberGoodsCollectionService; |
| | | import com.ruoyi.goods.service.async.AsyncMethodService; |
| | | import com.ruoyi.system.api.constants.DelayTaskEnum; |
| | | import com.ruoyi.system.api.constants.NotificationTypeConstant; |
| | | import com.ruoyi.system.api.domain.GoodsGroupPurchase; |
| | | import com.ruoyi.system.api.domain.GoodsGroupPurchaseInfo; |
| | | import com.ruoyi.system.api.domain.GoodsSku; |
| | | import com.ruoyi.system.api.domain.Order; |
| | | import com.ruoyi.system.api.domain.WebsocketMessageDTO; |
| | | import com.ruoyi.system.api.domain.dto.*; |
| | | import com.ruoyi.system.api.domain.dto.HomeGoodsSkuDTO; |
| | | import com.ruoyi.system.api.domain.dto.ListStatusDTO; |
| | | import com.ruoyi.system.api.domain.dto.OrderDTO; |
| | | import com.ruoyi.system.api.domain.dto.OrderUpdDTO; |
| | | import com.ruoyi.system.api.domain.dto.RefundDTO; |
| | | import com.ruoyi.system.api.domain.vo.GoodsGroupPurchaseInfoVO; |
| | | import com.ruoyi.system.api.domain.vo.OrderVO; |
| | | import com.ruoyi.system.api.domain.vo.WdGoodsGroupPurchaseVO; |
| | |
| | | queryWrapper.eq(GoodsGroupPurchase::getListingStatus, |
| | | ListingStatusEnum.ON_SHELVES.getCode()); |
| | | queryWrapper.le(GoodsGroupPurchase::getStartTime, dto.getStartTime()); |
| | | queryWrapper.ge(GoodsGroupPurchase::getEndTime, dto.getEndTime()); |
| | | queryWrapper.ge(GoodsGroupPurchase::getEndTime, dto.getStartTime()); |
| | | long count = this.count(queryWrapper); |
| | | if (count > 0) { |
| | | throw new ServiceException("添加失败,当前商品在该时间段内有其他团购活动"); |
| | |
| | | throw new ServiceException(String.format("团购商品【%s】剩余库存不足,请修改团购库存", |
| | | goodsSku.getSkuName())); |
| | | } |
| | | GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); |
| | | goodsStockUpdDTO.setAuctionStock(groupPurchaseStock * -1); |
| | | goodsStockUpdDTO.setGoodsSkuId(goodsSku.getId()); |
| | | goodsSkuService.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO)); |
| | | } else { |
| | | GoodsGroupPurchase groupPurchase = this.getById(dto.getId()); |
| | | if (StringUtils.isNull(groupPurchase)) { |
| | |
| | | throw new ServiceException(String.format("团购商品%s剩余库存不足,请修改团购库存", |
| | | goodsSku.getSkuName())); |
| | | } |
| | | GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); |
| | | goodsStockUpdDTO.setAuctionStock(latestStock); |
| | | goodsStockUpdDTO.setGoodsSkuId(goodsSku.getId()); |
| | | goodsSkuService.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO)); |
| | | this.updateById(goodsGroupPurchase); |
| | | } |
| | | if (goodsGroupPurchase.getListingStatus().equals(ListingStatusEnum.ON_SHELVES)) { |
| | | asyncMethodService.groupPurchaseScheduleTask(Lists.newArrayList(goodsGroupPurchase)); |
| | | } |
| | | asyncMethodService.groupPurchaseScheduleTask(Lists.newArrayList(goodsGroupPurchase)); |
| | | } |
| | | |
| | | /** |
| | |
| | | Integer num = orderClient.getGroupPurchasesGoodsNum(groupPurchase.getId(), |
| | | SecurityConstants.INNER).getData(); |
| | | vo.setBuyNumber(num); |
| | | List<GoodsGroupPurchaseInfo> list = goodsGroupPurchaseInfoService.lambdaQuery() |
| | | .eq(GoodsGroupPurchaseInfo::getGroupPurchaseId, id).list(); |
| | | Integer count = list.stream().map(GoodsGroupPurchaseInfo::getCurrentNumber) |
| | | .reduce(Integer::sum) |
| | | .orElse(0); |
| | | vo.setGroupedMemberNumber(count); |
| | | return vo; |
| | | } |
| | | |
| | |
| | | if (groupPurchase.getStartStatus().equals(StartStatusEnum.STARTED)) { |
| | | throw new ServiceException("该商品已开始团购,不能下架"); |
| | | } |
| | | //移除该团购商品延时任务 |
| | | redisService.deleteObject(DelayTaskEnum.GROUP_PURCHASES_START_TASK.getCode() + "-" |
| | | + groupPurchase.getId()); |
| | | redisService.deleteObject( |
| | | DelayTaskEnum.GROUP_PURCHASES_END_TASK.getCode() + "-" + groupPurchase.getId()); |
| | | // 退回剩余库存 |
| | | GoodsStockUpdDTO goodsStockUpdDTO = new GoodsStockUpdDTO(); |
| | | goodsStockUpdDTO.setAuctionStock( |
| | | groupPurchase.getLimitNumber() * groupPurchase.getGroupSize()); |
| | | goodsStockUpdDTO.setGoodsSkuId(groupPurchase.getGoodsSkuId()); |
| | | goodsSkuService.updGoodsStock(Lists.newArrayList(goodsStockUpdDTO)); |
| | | } |
| | | //修改状态 |
| | | groupPurchase.setListingStatus(dto.getListingStatus()); |
| | | groupPurchase.setStartStatus(StartStatusEnum.ENDED); |
| | | if (!groupPurchase.getGroupStatus().equals(GroupStatusEnum.FORMED_INTO_A_GROUP)) { |
| | | List<GoodsGroupPurchaseInfo> groupPurchaseInfoList = goodsGroupPurchaseInfoService.lambdaQuery() |
| | | .eq(GoodsGroupPurchaseInfo::getGroupPurchaseId, dto.getId()).list(); |
| | | long count = groupPurchaseInfoList.stream().filter(info -> info.getGroupStatus() == 1) |
| | | .count(); |
| | | if (count > 0) { |
| | | groupPurchase.setGroupStatus(GroupStatusEnum.FORMED_INTO_A_GROUP); |
| | | } else { |
| | | groupPurchase.setGroupStatus(GroupStatusEnum.GROUP_FAILURE); |
| | | } |
| | | this.updateById(groupPurchase); |
| | | if (dto.getListingStatus().equals(ListingStatusEnum.ON_SHELVES)) { |
| | | asyncMethodService.groupPurchaseScheduleTask(Lists.newArrayList(groupPurchase)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | goodsGroupPurchaseInfoVO.setShareTitle(one.getShareTitle()); |
| | | goodsGroupPurchaseInfoVO.setGroupStatus(one.getGroupStatus()); |
| | | goodsGroupPurchaseInfoVO.setStartStatus(one.getStartStatus()); |
| | | goodsGroupPurchaseInfoVO.setStartTime(one.getStartTime()); |
| | | goodsGroupPurchaseInfoVO.setEndTime(one.getEndTime()); |
| | | goodsGroupPurchaseInfoVO.setSharePic(one.getSharePic()); |
| | | goodsGroupPurchaseInfoVO.setGroupPurchasePrice(one.getGroupPurchasePrice()); |
| | | goodsGroupPurchaseInfoVO.setGroupSize(one.getGroupSize()); |
| | | goodsGroupPurchaseInfoVO.setLimitNumber(one.getLimitNumber()); |
| | | |
| | | if (one.getGroupStatus().getCode()==2){ |
| | | if (one.getGroupStatus().getCode()==0){ |
| | | LambdaQueryWrapper<GoodsGroupPurchaseInfo> wrapper6= Wrappers.lambdaQuery(); |
| | | wrapper6.eq(GoodsGroupPurchaseInfo::getDelFlag,0); |
| | | wrapper6.eq(GoodsGroupPurchaseInfo::getGroupStatus,0); |
| | |
| | | goodsGroupPurchaseInfoVO.setGroupStatus(one.getGroupStatus()); |
| | | } |
| | | }else{ |
| | | goodsGroupPurchaseInfoVO.setCurrentNumber(one.getGroupSize()); |
| | | goodsGroupPurchaseInfoVO.setCurrentNumber(one.getCurrentNumber()); |
| | | goodsGroupPurchaseInfoVO.setGroupStatus(one.getGroupStatus()); |
| | | } |
| | | |
| | |
| | | HomeGoodsSkuDTO homeGoodsSkuDTO1=new HomeGoodsSkuDTO(); |
| | | homeGoodsSkuDTO1.setGoodsSkuId(one.getId()); |
| | | homeGoodsSkuDTO1.setMemberId(homeGoodsSkuDTO.getMemberId()); |
| | | Order data = orderClient.getOrderByGroupPurchaseMemberId1(homeGoodsSkuDTO1, SecurityConstants.INNER).getData(); |
| | | Order data = orderClient.getOrderByGroupPurchaseMemberId2(homeGoodsSkuDTO1, SecurityConstants.INNER).getData(); |
| | | if (data!=null){ |
| | | goodsGroupPurchaseInfoVO.setIsGoodsGroupPurchase(2); |
| | | goodsGroupPurchaseInfoVO.setOrder(data); |
| | |
| | | } |
| | | }else{ |
| | | if (one.getGroupStatus().getCode()==0){ |
| | | if (one.getGroupSize()-one.getCurrentNumber()<5){ |
| | | goodsGroupPurchaseInfoVO.setGroupStatus(GroupStatusEnum.MS_FAILURE); |
| | | if (one.getGroupSize()>5){ |
| | | if (one.getGroupSize()-one.getCurrentNumber()<5){ |
| | | goodsGroupPurchaseInfoVO.setGroupStatus(GroupStatusEnum.MS_FAILURE); |
| | | }else{ |
| | | goodsGroupPurchaseInfoVO.setGroupStatus(one.getGroupStatus()); |
| | | } |
| | | }else{ |
| | | goodsGroupPurchaseInfoVO.setGroupStatus(one.getGroupStatus()); |
| | | } |
| | | |
| | | }else { |
| | | goodsGroupPurchaseInfoVO.setGroupStatus(one.getGroupStatus()); |
| | | } |
| | |
| | | orderDTO.setOrderFrom(OrderFromEnum.GROUP_PURCHASE_ORDERS); |
| | | orderDTO.setGoodsSkuId(goodsGroupPurchaseeVO.getId()); |
| | | orderDTO.setMemberId(homeGoodsSkuDTO.getMemberId()); |
| | | Order orderOne = orderClient.getOrderOne(orderDTO, SecurityConstants.INNER).getData(); |
| | | Order orderOne = orderClient.getOrderOne2(orderDTO, SecurityConstants.INNER).getData(); |
| | | |
| | | LambdaQueryWrapper<GoodsGroupPurchaseInfo> wrapper6= Wrappers.lambdaQuery(); |
| | | wrapper6.eq(GoodsGroupPurchaseInfo::getDelFlag,0); |
| | | wrapper6.eq(GoodsGroupPurchaseInfo::getGroupStatus,0); |
| | | wrapper6.eq(GoodsGroupPurchaseInfo::getGroupPurchaseId,goodsGroupPurchaseeVO.getId()); |
| | | wrapper6.eq(GoodsGroupPurchaseInfo::getMubre,orderOne.getGroupNo()); |
| | | GoodsGroupPurchaseInfo one1 = goodsGroupPurchaseInfoService.getOne(wrapper6); |
| | | if (one1!=null){ |
| | | goodsGroupPurchaseeVO.setCurrentNumber(one1.getCurrentNumber()); |
| | | if (one1.getGroupStatus()==0){ |
| | | if (one1.getGroupSize()-one1.getCurrentNumber()<5){ |
| | | goodsGroupPurchaseeVO.setGroupStatus(GroupStatusEnum.MS_FAILURE); |
| | | if (orderOne!=null){ |
| | | LambdaQueryWrapper<GoodsGroupPurchaseInfo> wrapper6= Wrappers.lambdaQuery(); |
| | | wrapper6.eq(GoodsGroupPurchaseInfo::getDelFlag,0); |
| | | wrapper6.eq(GoodsGroupPurchaseInfo::getGroupPurchaseId,goodsGroupPurchaseeVO.getId()); |
| | | wrapper6.eq(GoodsGroupPurchaseInfo::getMubre,orderOne.getGroupNo()); |
| | | GoodsGroupPurchaseInfo one1 = goodsGroupPurchaseInfoService.getOne(wrapper6); |
| | | if (one1!=null){ |
| | | goodsGroupPurchaseeVO.setCurrentNumber(one1.getCurrentNumber()); |
| | | if (one1.getGroupStatus()==0){ |
| | | if (one1.getGroupSize()-one1.getCurrentNumber()<5){ |
| | | goodsGroupPurchaseeVO.setGroupStatus(GroupStatusEnum.MS_FAILURE); |
| | | }else{ |
| | | goodsGroupPurchaseeVO.setGroupStatus(GroupStatusEnum.TO_FORM_A_GROUP); |
| | | } |
| | | }if (one1.getGroupStatus()==1){ |
| | | goodsGroupPurchaseeVO.setGroupStatus(GroupStatusEnum.FORMED_INTO_A_GROUP); |
| | | }if (goodsGroupPurchaseeVO.getStartStatus().getCode()==1){ |
| | | if (one1.getGroupStatus()==2){ |
| | | goodsGroupPurchaseeVO.setGroupStatus(GroupStatusEnum.TO_FORM_A_GROUP); |
| | | } |
| | | }else{ |
| | | goodsGroupPurchaseeVO.setGroupStatus(GroupStatusEnum.TO_FORM_A_GROUP); |
| | | if (one1.getGroupStatus()==2){ |
| | | goodsGroupPurchaseeVO.setGroupStatus(GroupStatusEnum.GROUP_FAILURE); |
| | | } |
| | | } |
| | | }if (one1.getGroupStatus()==1){ |
| | | goodsGroupPurchaseeVO.setGroupStatus(GroupStatusEnum.FORMED_INTO_A_GROUP); |
| | | }if (one1.getGroupStatus()==2){ |
| | | goodsGroupPurchaseeVO.setGroupStatus(GroupStatusEnum.GROUP_FAILURE); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |