From 01d6fa48a0de7a21988e89f71721b6b85e53b517 Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期四, 06 三月 2025 16:33:53 +0800 Subject: [PATCH] 去掉资讯图片必填限制 --- ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/inner/GoodsGroupPurchaseController.java | 95 +++++++++++++++++++++++++++++++++-------------- 1 files changed, 66 insertions(+), 29 deletions(-) diff --git a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/inner/GoodsGroupPurchaseController.java b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/inner/GoodsGroupPurchaseController.java index f849338..2fdfad9 100644 --- a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/inner/GoodsGroupPurchaseController.java +++ b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/inner/GoodsGroupPurchaseController.java @@ -8,19 +8,22 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.common.security.annotation.InnerAuth; import com.ruoyi.goods.mapper.GoodsSkuMapper; -import com.ruoyi.goods.service.IGoodsSkuService; -import com.ruoyi.system.api.domain.GoodsGroupPurchaseInfo; +import com.ruoyi.goods.service.IGoodsGroupPurchaseService; import com.ruoyi.goods.service.impl.GoodsGroupPurchaseInfoServiceImpl; import com.ruoyi.system.api.domain.GoodsGroupPurchase; -import com.ruoyi.goods.service.IGoodsGroupPurchaseService; +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.feignClient.OrderClient; +import java.util.List; +import java.util.Set; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.*; - -import java.util.List; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; /** * <p> @@ -83,34 +86,51 @@ wrapper6.eq(GoodsGroupPurchaseInfo::getMubre,goodsGroupPurchaseInfo.getMubre()); GoodsGroupPurchaseInfo one1 = goodsGroupPurchaseInfoServiceImpl.getOne(wrapper6); int i=one1.getCurrentNumber()-1; - if (i==0){ - GoodsGroupPurchase byId = goodsGroupPurchaseService.getById(one1.getGroupPurchaseId()); - - GoodsSku goodsSku = goodsSkuMapper.selectById(byId.getGoodsSkuId()); - int i2 = goodsGroupPurchaseInfo.getPurchaseNum() + goodsSku.getStock(); - goodsSku.setStock(i2); - goodsSkuMapper.updateById(goodsSku); - goodsGroupPurchaseInfoServiceImpl.removeById(one1); - }else{ - one1.setCurrentNumber(i); - if (one1.getGroupSize()>one1.getCurrentNumber()){ - one1.setGroupStatus(0); + if (one1.getIsPurchase()==0){ + if (i==0){ + GoodsGroupPurchase byId = goodsGroupPurchaseService.getById(one1.getGroupPurchaseId()); + // int i1 = byId.getLimitNumber() * goodsGroupPurchaseInfo.getGroupSize(); + int i1 = one1.getPurchaseNum(); + GoodsSku goodsSku = goodsSkuMapper.selectById(byId.getGoodsSkuId()); + int i2 = i1 + goodsSku.getStock(); + goodsSku.setStock(i2); + goodsSkuMapper.updateById(goodsSku); + /* goodsGroupPurchaseInfoServiceImpl.removeById(one1);*/ } - - Integer i3= one1.getPurchaseNum()-goodsGroupPurchaseInfo.getPurchaseNum(); - one1.setPurchaseNum(i3); + one1.setCurrentNumber(i); + one1.setPurchaseNum(0); goodsGroupPurchaseInfoServiceImpl.updateById(one1); + }else{ + if (i==0){ + GoodsGroupPurchase byId = goodsGroupPurchaseService.getById(one1.getGroupPurchaseId()); - GoodsGroupPurchase byId = goodsGroupPurchaseService.getById(one1.getGroupPurchaseId()); + GoodsSku goodsSku = goodsSkuMapper.selectById(byId.getGoodsSkuId()); + int i2 = goodsGroupPurchaseInfo.getPurchaseNum() + goodsSku.getStock(); + goodsSku.setStock(i2); + goodsSkuMapper.updateById(goodsSku); + /* goodsGroupPurchaseInfoServiceImpl.removeById(one1);*/ + }else{ + one1.setCurrentNumber(i); + if (one1.getGroupSize()>one1.getCurrentNumber()){ + one1.setGroupStatus(0); + } - GoodsSku goodsSku = goodsSkuMapper.selectById(byId.getGoodsSkuId()); - int i2 = goodsGroupPurchaseInfo.getPurchaseNum() + goodsSku.getStock(); - goodsSku.setStock(i2); - goodsSkuMapper.updateById(goodsSku); - goodsGroupPurchaseInfoServiceImpl.removeById(one1); + Integer i3= one1.getPurchaseNum()-goodsGroupPurchaseInfo.getPurchaseNum(); + one1.setPurchaseNum(i3); + goodsGroupPurchaseInfoServiceImpl.updateById(one1); - goodsGroupPurchaseInfoServiceImpl.updateById(one1); + GoodsGroupPurchase byId = goodsGroupPurchaseService.getById(one1.getGroupPurchaseId()); + + GoodsSku goodsSku = goodsSkuMapper.selectById(byId.getGoodsSkuId()); + int i2 = goodsGroupPurchaseInfo.getPurchaseNum() + goodsSku.getStock(); + goodsSku.setStock(i2); + goodsSkuMapper.updateById(goodsSku); + /* goodsGroupPurchaseInfoServiceImpl.removeById(one1);*/ + + // goodsGroupPurchaseInfoServiceImpl.updateById(one1); + } } + return R.ok(one1); } @@ -118,7 +138,9 @@ @InnerAuth @PostMapping("/updgoodsGroupPurchaseInfo") public R getGoodsSeckiGoodsGroupPurchaseInfo(@RequestBody GoodsGroupPurchaseInfo goodsGroupPurchaseInfo) { + log.info("getGoodsSeckiGoodsGroupPurchaseInfo==============》{}", goodsGroupPurchaseInfo); if (goodsGroupPurchaseInfo.getId()!=null){ + log.info("========================已有待成团========================"); GoodsGroupPurchaseInfo byId = goodsGroupPurchaseInfoServiceImpl.getById(goodsGroupPurchaseInfo.getId()); Integer num= byId.getCurrentNumber()+1; byId.setCurrentNumber(num); @@ -126,6 +148,7 @@ goodsGroupPurchaseInfoServiceImpl.updateById(byId); if (num==byId.getGroupSize()){ byId.setGroupStatus(1); + byId.setIsPurchase(1); goodsGroupPurchaseInfoServiceImpl.updateById(byId); orderClient.updateOrderStatusByMubres1(byId.getMubre(), SecurityConstants.INNER); @@ -143,8 +166,10 @@ } }else{ + log.info("===================没有待成团的团购==================="); if (goodsGroupPurchaseInfo.getCurrentNumber()==goodsGroupPurchaseInfo.getGroupSize()){ goodsGroupPurchaseInfo.setGroupStatus(1); + goodsGroupPurchaseInfo.setIsPurchase(1); orderClient.updateOrderStatusByMubres1(goodsGroupPurchaseInfo.getMubre(), SecurityConstants.INNER); } goodsGroupPurchaseInfoServiceImpl.save(goodsGroupPurchaseInfo); @@ -231,4 +256,16 @@ } return R.ok(); } + + /** + * 根据团购商品id集合查询商品sku信息 + * + * @param groupPurchaseIdSet + * @return + */ + @InnerAuth + @PostMapping("/getGoodsSkuByGroupPurchaseIdSet") + R<List<GoodsSku>> getGoodsSkuByGroupPurchaseIdSet(@RequestBody Set<Long> groupPurchaseIdSet) { + return R.ok(goodsGroupPurchaseService.getGoodsSkuByGroupPurchaseIdSet(groupPurchaseIdSet)); + } } -- Gitblit v1.7.1