From 8bd4482694b5bc615036e333b23ceafea9c41e9a Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期一, 01 九月 2025 10:45:23 +0800 Subject: [PATCH] 供应商商品 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java | 89 +++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 87 insertions(+), 2 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java index 216af76..a009823 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java @@ -1,8 +1,27 @@ package com.ruoyi.web.controller.api; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.basic.PageInfo; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.framework.web.service.TokenService; +import com.ruoyi.system.dto.TErpGoodsAddDto; +import com.ruoyi.system.dto.TErpGoodsUpdateStatus; +import com.ruoyi.system.dto.TErpGoodsUpdateStatusDto; +import com.ruoyi.system.model.TErpGoods; +import com.ruoyi.system.query.TErpGoodsQuery; +import com.ruoyi.system.query.TErpIssueReportingQuery; +import com.ruoyi.system.service.TCrmClinicService; +import com.ruoyi.system.service.TCrmSupplierService; +import com.ruoyi.system.service.TErpGoodsService; +import com.ruoyi.system.service.TErpIssueReportingService; +import com.ruoyi.system.vo.TErpGoodsVO; +import com.ruoyi.system.vo.TErpIssueReportingVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; /** * <p> @@ -14,7 +33,73 @@ */ @RestController @RequestMapping("/t-erp-goods") +@Api(tags = "供应商商品管理") public class TErpGoodsController { + + private final TErpGoodsService erpGoodsService; + private final TokenService tokenService; + + @Autowired + public TErpGoodsController(TErpGoodsService erpGoodsService, TokenService tokenService) { + this.erpGoodsService = erpGoodsService; + this.tokenService = tokenService; + } + + + + /** + * 获取erp问题上报管理列表 + */ + @ApiOperation(value = "供应商获取商品分页列表") + @PostMapping(value = "/pageList") + public R<PageInfo<TErpGoodsVO>> pageList(@RequestBody TErpGoodsQuery query) { + SysUser user = tokenService.getLoginUser().getUser(); + return R.ok(erpGoodsService.pageList(query,user)); + } + + + + @ApiOperation(value = "供应商添加商品") + @PostMapping(value = "/add") + public R<Boolean> add(@Validated @RequestBody TErpGoodsAddDto dto) { + if (erpGoodsService.isExit(dto.getGoodsIdCode())) { + return R.fail("erp商品已存在"); + } + TErpGoods goods = new TErpGoods(); + goods.setSupplierId(user.getClinicId()); + goods.setGoodsIdCode(dto.getGoodsIdCode()); + goods.setQuasiNumber(dto.getQuasiNumber()); + goods.setManufacturer(dto.getManufacturer()); + goods.setFormulationSpec(dto.getFormulationSpec()); + goods.setPackingSpec(dto.getPackingSpec()); + goods.setGoodsName(dto.getGoodsName()); + return R.ok(erpGoodsService.save(goods)); + } + + @ApiOperation(value = "供应商删除商品") + @DeleteMapping(value = "/delete/{id}") + public R<Boolean> delete(@PathVariable String id) { + return R.ok(erpGoodsService.removeById(id)); + } + + + /** + * 启用 停用 + */ + @ApiOperation(value = "供应商启用 停用商品") + @PostMapping(value = "/updateStatus") + public R<Boolean> updateStatus(@RequestBody TErpGoodsUpdateStatusDto dto) { + TErpGoods goods = erpGoodsService.getById(dto.getId()); + if(dto.getState()==1 && goods.getTypeId()==null){ + return R.fail("操作失败,请先完善商品信息"); + } + if(dto.getState()==1 && goods.getClinicPurchasePrice()==null){ + return R.fail("操作失败,请设置供应商分佣比例后再启用"); + } + goods.setState(dto.getState()); + boolean b = erpGoodsService.updateById(goods); + return R.ok(b); + } } -- Gitblit v1.7.1