From 6ad00f636a0c1e798800f5bea31bcb1d6583c07a Mon Sep 17 00:00:00 2001 From: phpcjl <phpcjl@gmail.com> Date: 星期三, 11 十二月 2024 17:20:00 +0800 Subject: [PATCH] 1.后台管理-商品管理 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsBargainPriceController.java | 71 +++++++++++++++++++++++++++++++++++ 1 files changed, 71 insertions(+), 0 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsBargainPriceController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsBargainPriceController.java index 316d668..8c6e644 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsBargainPriceController.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/GoodsBargainPriceController.java @@ -1,8 +1,22 @@ package com.ruoyi.other.controller; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.other.api.domain.GoodsBargainPrice; +import com.ruoyi.other.api.domain.GoodsBargainPriceDetail; +import com.ruoyi.other.api.vo.GetGoodsBargainPrice; +import com.ruoyi.other.service.GoodsBargainPriceDetailService; +import com.ruoyi.other.service.GoodsBargainPriceService; +import com.ruoyi.system.api.model.LoginUser; +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; + +import javax.annotation.Resource; +import java.util.List; /** * <p> @@ -15,6 +29,63 @@ @RestController @RequestMapping("/goods-bargain-price") public class GoodsBargainPriceController { + + @Resource + private GoodsBargainPriceService goodsBargainPriceService; + + @Resource + private GoodsBargainPriceDetailService goodsBargainPriceDetailService; + + @Resource + private TokenService tokenService; + + + /** + * 根据商品id和会员等级获取门店特价 + * @param goodsBargainPrice + * @return + */ + @PostMapping("/getGoodsBargainPrice") + public R<GoodsBargainPriceDetail> getGoodsBargainPrice(@RequestBody GetGoodsBargainPrice goodsBargainPrice){ + GoodsBargainPrice one = goodsBargainPriceService.getOne(new LambdaQueryWrapper<GoodsBargainPrice>() + .eq(GoodsBargainPrice::getGoodsId, goodsBargainPrice.getGoodsId()) + .eq(GoodsBargainPrice::getShopId, goodsBargainPrice.getShopId()) + .eq(GoodsBargainPrice::getAuditStatus, 1) + .eq(GoodsBargainPrice::getDelFlag, 0) + .orderByDesc(GoodsBargainPrice::getCreateTime) + .last(" limit 0,1")); + if(null == one){ + return R.ok(); + } + GoodsBargainPriceDetail detailServiceOne = goodsBargainPriceDetailService.getOne(new LambdaQueryWrapper<GoodsBargainPriceDetail>() + .eq(GoodsBargainPriceDetail::getGoodsBargainPriceId, one.getId()).eq(GoodsBargainPriceDetail::getVip, goodsBargainPrice.getVip())); + return R.ok(detailServiceOne); + } + + /** + * 新增 + */ + @PostMapping("/add") + public R<Void> add(@RequestBody GoodsBargainPrice goodsBargainPrice) { + LoginUser loginUserApplet = tokenService.getLoginUserApplet(); + goodsBargainPrice.setAuditStatus(0); + goodsBargainPrice.setCreateUserId(loginUserApplet.getUserid()); + goodsBargainPriceService.save(goodsBargainPrice); + + List<GoodsBargainPriceDetail> goodsBargainPriceDetailList = goodsBargainPrice.getGoodsBargainPriceDetailList(); + if (goodsBargainPriceDetailList == null || goodsBargainPriceDetailList.isEmpty()){ + return R.fail("添加失败"); + } + for (GoodsBargainPriceDetail goodsBargainPriceDetail : goodsBargainPriceDetailList) { + goodsBargainPriceDetail.setGoodsBargainPriceId(goodsBargainPrice.getId()); + } + goodsBargainPriceDetailService.saveBatch(goodsBargainPriceDetailList); + return R.ok(); + } + + + + } -- Gitblit v1.7.1