From c23f48c5ec15476299edadd91fa18f908d710a4f Mon Sep 17 00:00:00 2001 From: rentaiming <806181062@qq.com> Date: 星期四, 18 七月 2024 08:58:42 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/inner/GoodsGroupPurchaseController.java | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 101 insertions(+), 4 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 373ceb6..5def470 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 @@ -1,16 +1,18 @@ package com.ruoyi.goods.controller.inner; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.fasterxml.jackson.core.JsonProcessingException; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.security.annotation.InnerAuth; +import com.ruoyi.system.api.domain.GoodsGroupPurchaseInfo; +import com.ruoyi.goods.service.impl.GoodsGroupPurchaseInfoServiceImpl; +import com.ruoyi.system.api.domain.GoodsGroupPurchase; import com.ruoyi.goods.service.IGoodsGroupPurchaseService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** * <p> @@ -28,6 +30,70 @@ private final IGoodsGroupPurchaseService goodsGroupPurchaseService; + private final GoodsGroupPurchaseInfoServiceImpl goodsGroupPurchaseInfoServiceImpl; + + @InnerAuth + @PostMapping("/getGoodsSeckiGoodsGroupPurchaseOne") + public R<GoodsGroupPurchase> getGoodsSeckiGoodsGroupPurchaseOne(@RequestBody Long goodsSkuId) { + GoodsGroupPurchase GoodsSeckillOne = goodsGroupPurchaseService.getById(goodsSkuId); + return R.ok(GoodsSeckillOne); + } + + + @InnerAuth + @PostMapping("/getGoodsSeckiGoodsGroupPurchaseInfo") + public R<GoodsGroupPurchaseInfo> getGoodsSeckiGoodsGroupPurchaseInfo(@RequestBody Long goodsSkuId) { + LambdaQueryWrapper<GoodsGroupPurchaseInfo> wrapper6= Wrappers.lambdaQuery(); + wrapper6.eq(GoodsGroupPurchaseInfo::getDelFlag,0); + wrapper6.eq(GoodsGroupPurchaseInfo::getGroupStatus,0); + wrapper6.eq(GoodsGroupPurchaseInfo::getGroupPurchaseId,goodsSkuId); + GoodsGroupPurchaseInfo one1 = goodsGroupPurchaseInfoServiceImpl.getOne(wrapper6); + + return R.ok(one1); + } + + @InnerAuth + @PostMapping("/getGoodsSeckiGoodsGroupPurchaseInfo1") + public R<GoodsGroupPurchaseInfo> getGoodsSeckiGoodsGroupPurchaseInfo1(@RequestBody GoodsGroupPurchaseInfo goodsGroupPurchaseInfo) { + LambdaQueryWrapper<GoodsGroupPurchaseInfo> wrapper6= Wrappers.lambdaQuery(); + wrapper6.eq(GoodsGroupPurchaseInfo::getDelFlag,0); + wrapper6.eq(GoodsGroupPurchaseInfo::getMubre,goodsGroupPurchaseInfo.getMubre()); + GoodsGroupPurchaseInfo one1 = goodsGroupPurchaseInfoServiceImpl.getOne(wrapper6); + int i=one1.getCurrentNumber()-1; + if (i==0){ + one1.setCurrentNumber(0); + one1.setGroupStatus(0); + goodsGroupPurchaseInfoServiceImpl.updateById(one1); + goodsGroupPurchaseInfoServiceImpl.removeById(one1); + }else{ + one1.setCurrentNumber(i); + if (one1.getGroupSize()>one1.getCurrentNumber()){ + one1.setGroupStatus(0); + } + goodsGroupPurchaseInfoServiceImpl.updateById(one1); + } + + return R.ok(one1); + } + + @InnerAuth + @PostMapping("/updgoodsGroupPurchaseInfo") + public R getGoodsSeckiGoodsGroupPurchaseInfo(@RequestBody GoodsGroupPurchaseInfo goodsGroupPurchaseInfo) { + if (goodsGroupPurchaseInfo.getId()!=null){ + GoodsGroupPurchaseInfo byId = goodsGroupPurchaseInfoServiceImpl.getById(goodsGroupPurchaseInfo.getId()); + Integer num= byId.getCurrentNumber()+1; + byId.setCurrentNumber(num); + if (num==byId.getGroupSize()){ + byId.setGroupStatus(1); + } + goodsGroupPurchaseInfoServiceImpl.updateById(byId); + }else{ + goodsGroupPurchaseInfoServiceImpl.save(goodsGroupPurchaseInfo); + } + + return R.ok(); + } + /** * 团购商品开始团购 * @@ -45,6 +111,37 @@ return R.ok(); } + @InnerAuth + @GetMapping("/num/{groupPurchaseId}") + R<?> GroupPurchaseNum(@PathVariable("groupPurchaseId") Long groupPurchaseId) { + try { + GoodsGroupPurchase byId = goodsGroupPurchaseService.getById(groupPurchaseId); + Integer m= byId.getCurrentNumber()+1; + byId.setCurrentNumber(m); + goodsGroupPurchaseService.updateById(byId); + } catch (Exception e) { + log.error("团购商品开始团购失败", e); + return R.fail("团购商品开始团购失败"); + } + return R.ok(); + } + + @InnerAuth + @GetMapping("/num1/{groupPurchaseId}") + R<?> GroupPurchaseNum1(@PathVariable("groupPurchaseId") Long groupPurchaseId) { + try { + GoodsGroupPurchase byId = goodsGroupPurchaseService.getById(groupPurchaseId); + Integer m= byId.getCurrentNumber()-1; + byId.setCurrentNumber(m); + goodsGroupPurchaseService.updateById(byId); + } catch (Exception e) { + log.error("团购商品开始团购失败", e); + return R.fail("团购商品开始团购失败"); + } + return R.ok(); + } + + /** * 团购商品结束团购 * -- Gitblit v1.7.1