食品采购出入库
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package com.zf.foodpurchase.fdsafe.web.admin;
|
||||
|
||||
|
||||
import com.zf.foodpurchase.common.core.controller.BaseController;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.common.core.page.TableDataInfo;
|
||||
import com.zf.foodpurchase.common.valigroud.AddGroup;
|
||||
import com.zf.foodpurchase.common.valigroud.UpdateGroup;
|
||||
import com.zf.foodpurchase.fdsafe.service.IFoodSpecService;
|
||||
import com.zf.foodpurchase.fdsafe.vo.FoodSpecVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2025-04-17
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/foodSpec")
|
||||
public class FoodSpecController extends BaseController {
|
||||
@Autowired
|
||||
private IFoodSpecService foodSpecService;
|
||||
|
||||
/**
|
||||
* 查询用
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(){
|
||||
FoodSpecVO foodSpecVO = new FoodSpecVO();
|
||||
foodSpecVO.setStatus(0);
|
||||
foodSpecVO.setDelFlag(0);
|
||||
List list = foodSpecService.queryFoodSpecVO(foodSpecVO);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/pageList")
|
||||
public TableDataInfo pageList(FoodSpecVO foodSpecVO){
|
||||
startPage();
|
||||
foodSpecVO.setDelFlag(0);
|
||||
List<FoodSpecVO> list = foodSpecService.queryFoodSpecVO(foodSpecVO);
|
||||
return getDataTable(list);
|
||||
}
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody @Validated(AddGroup.class) FoodSpecVO foodSpecVO){
|
||||
return foodSpecService.saveVO(foodSpecVO);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
public AjaxResult update(@RequestBody @Validated(UpdateGroup.class) FoodSpecVO foodSpecVO){
|
||||
return foodSpecService.updateVO(foodSpecVO);
|
||||
}
|
||||
|
||||
@GetMapping("/delete")
|
||||
public AjaxResult delete(Integer specId){
|
||||
if(specId == null){
|
||||
return error("未指定要删除的食材规格/单位");
|
||||
}
|
||||
boolean flag = foodSpecService.removeById(specId);
|
||||
return flag ? success("删除成功") : error("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.web.merchant;
|
||||
|
||||
import com.zf.foodpurchase.common.core.controller.BaseController;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.common.core.domain.entity.SysUser;
|
||||
import com.zf.foodpurchase.common.core.page.TableDataInfo;
|
||||
import com.zf.foodpurchase.common.utils.poi.ExcelUtil;
|
||||
import com.zf.foodpurchase.fdsafe.entity.Carousel;
|
||||
import com.zf.foodpurchase.fdsafe.service.ICarouselService;
|
||||
import com.zf.foodpurchase.fdsafe.utils.ImagesPrefixUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商户轮播图Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-11-29
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/merchant/carousel")
|
||||
public class CarouselController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ICarouselService carouselService;
|
||||
|
||||
/**
|
||||
* 查询商户轮播图列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(Carousel carousel)
|
||||
{
|
||||
startPage();
|
||||
SysUser loginUser = getLoginUser().getUser();
|
||||
if(!loginUser.isAdmin()){
|
||||
carousel.setMerchantId(loginUser.getDeptId());
|
||||
}
|
||||
List<Carousel> list = carouselService.selectCarouselList(carousel);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出商户轮播图列表
|
||||
*/
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Carousel carousel)
|
||||
{
|
||||
List<Carousel> list = carouselService.selectCarouselList(carousel);
|
||||
ExcelUtil<Carousel> util = new ExcelUtil<Carousel>(Carousel.class);
|
||||
util.exportExcel(response, list, "商户轮播图数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商户轮播图详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{carouselId}")
|
||||
public AjaxResult getInfo(@PathVariable("carouselId") Long carouselId)
|
||||
{
|
||||
return success(carouselService.selectCarouselByCarouselId(carouselId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增商户轮播图
|
||||
*/
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody Carousel carousel)
|
||||
{
|
||||
SysUser loginUser = getLoginUser().getUser();
|
||||
if(!loginUser.isAdmin()){
|
||||
carousel.setMerchantId(loginUser.getDeptId());
|
||||
}else if(carousel.getMerchantId() == null){
|
||||
return AjaxResult.error("请指定轮播图所属商户");
|
||||
}
|
||||
List<Carousel> carousels = carouselService.selectCarouselList(carousel);
|
||||
if(carousels!=null && carousels.size() > 0){
|
||||
return AjaxResult.error("该商户已存在该轮播图,无法新增");
|
||||
}
|
||||
StringBuilder firstImages=new StringBuilder();
|
||||
StringBuilder destImages=new StringBuilder();
|
||||
ImagesPrefixUtil.dealImagesPath(carousel.getCarouselIamges(), firstImages, destImages);
|
||||
carousel.setCarouselIamges(destImages.toString());
|
||||
|
||||
return toAjax(carouselService.insertCarousel(carousel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商户轮播图
|
||||
*/
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody Carousel carousel)
|
||||
{
|
||||
StringBuilder firstImages=new StringBuilder();
|
||||
StringBuilder destImages=new StringBuilder();
|
||||
ImagesPrefixUtil.dealImagesPath(carousel.getCarouselIamges(), firstImages, destImages);
|
||||
carousel.setCarouselIamges(destImages.toString());
|
||||
return toAjax(carouselService.updateCarousel(carousel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商户轮播图
|
||||
*/
|
||||
@DeleteMapping("/{carouselIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] carouselIds)
|
||||
{
|
||||
return toAjax(carouselService.deleteCarouselByCarouselIds(carouselIds));
|
||||
}
|
||||
}
|
||||
@@ -1,221 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.web.merchant;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zf.foodpurchase.common.constant.Constants;
|
||||
import com.zf.foodpurchase.common.core.controller.BaseController;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.common.core.domain.entity.SysUser;
|
||||
import com.zf.foodpurchase.common.core.page.TableDataInfo;
|
||||
import com.zf.foodpurchase.common.exception.ServiceException;
|
||||
import com.zf.foodpurchase.common.utils.DateUtils;
|
||||
import com.zf.foodpurchase.common.utils.StringUtils;
|
||||
import com.zf.foodpurchase.common.utils.poi.ExcelUtil;
|
||||
import com.zf.foodpurchase.fdsafe.entity.Products;
|
||||
import com.zf.foodpurchase.fdsafe.entity.ProductsSpec;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SpecValues;
|
||||
import com.zf.foodpurchase.fdsafe.service.IProductsService;
|
||||
import com.zf.foodpurchase.fdsafe.service.IProductsSpecService;
|
||||
import com.zf.foodpurchase.fdsafe.service.ISpecValuesService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-11-16
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/merchant/products")
|
||||
public class ProductsController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IProductsService productsService;
|
||||
|
||||
@Autowired
|
||||
private IProductsSpecService productsSpecService;
|
||||
|
||||
@Autowired
|
||||
private ISpecValuesService specValuesService;
|
||||
|
||||
private boolean isAllowDeleteSpecs = true;
|
||||
|
||||
/**
|
||||
* 查询商品列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(Products products)
|
||||
{
|
||||
startPage();
|
||||
SysUser sysUser = getLoginUser().getUser();
|
||||
if(!sysUser.isAdmin()){
|
||||
products.setMerchantId(sysUser.getDeptId());
|
||||
}
|
||||
List<Products> list = productsService.selectProductsList(products);
|
||||
|
||||
if(CollectionUtils.isNotEmpty(list)){
|
||||
|
||||
// 遍历products
|
||||
list.forEach(item->{
|
||||
LambdaQueryWrapper<ProductsSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ProductsSpec::getProductId,item.getProductId());
|
||||
List<ProductsSpec> productsSpecs = productsSpecService.listWithProductSpecValues(queryWrapper);
|
||||
if(CollectionUtils.isNotEmpty(productsSpecs)){
|
||||
item.setProductsSpecList(productsSpecs);
|
||||
|
||||
// 遍历productsSpecList
|
||||
for(ProductsSpec productsSpec:productsSpecs){
|
||||
List<Integer> specValuesIds = productsSpec.getSpecValuesIds();
|
||||
List<List<Integer>> specValueArray =new ArrayList<>();
|
||||
if(CollectionUtils.isNotEmpty(specValuesIds)){
|
||||
for(Integer integer : specValuesIds){
|
||||
if(integer!=null){
|
||||
SpecValues specValues = specValuesService.getById(integer);
|
||||
if(specValues!=null){
|
||||
List<Integer> arrayItem = new ArrayList<>();
|
||||
arrayItem.add(specValues.getSpecType());
|
||||
arrayItem.add(specValues.getId());
|
||||
specValueArray.add(arrayItem);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
productsSpec.setSpecValueArray(specValueArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
item.setProductsSpecList(new ArrayList<>());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出商品列表
|
||||
*/
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Products products)
|
||||
{
|
||||
List<Products> list = productsService.selectProductsList(products);
|
||||
ExcelUtil<Products> util = new ExcelUtil<Products>(Products.class);
|
||||
util.exportExcel(response, list, "商品数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{productId}")
|
||||
public AjaxResult getInfo(@PathVariable("productId") Integer productId)
|
||||
{
|
||||
return success(productsService.selectProductsByProductId(productId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增商品
|
||||
*/
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody Products products)
|
||||
{
|
||||
SysUser sysUser = getLoginUser().getUser();
|
||||
if(sysUser.isAdmin() ){
|
||||
if( products.getMerchantId() == null){
|
||||
return AjaxResult.warn("请选择所属商家");
|
||||
}
|
||||
} else{
|
||||
products.setMerchantId(sysUser.getDeptId());
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(products.getImages())){
|
||||
return AjaxResult.error("商品图片不能为空");
|
||||
}
|
||||
products.setProductId(null);
|
||||
products.setOperId(sysUser.getUserId());
|
||||
products.setCreateTime(DateUtils.getNowDate());
|
||||
// 多规格商品的库存添加对应规格商品时,自动累加
|
||||
if(Constants.MULTI_SPEC.equals(products.getIsSpecs())){
|
||||
products.setTotalStock(0);
|
||||
}else{
|
||||
if(Constants.GOODS_MONEY_BUY.equals(products.getType()) && products.getBasePrice()<=0){
|
||||
throw new ServiceException("人民币购买商品价格要大于0");
|
||||
}
|
||||
|
||||
if(Constants.GOODS_INTEGRAL_BUY.equals(products.getType()) && products.getBaseIntegral()<=0){
|
||||
throw new ServiceException("积分兑换商品积分要大于0");
|
||||
}
|
||||
}
|
||||
|
||||
return toAjax(productsService.insertProducts(products));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商品
|
||||
*/
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody Products products)
|
||||
{
|
||||
if(products.getUpdateTime()==null){
|
||||
products.setUpdateTime(DateUtils.getNowDate());
|
||||
}
|
||||
SysUser sysUser = getLoginUser().getUser();
|
||||
if(sysUser.isAdmin() ){
|
||||
if(products.getMerchantId() == null){
|
||||
return AjaxResult.warn("请选择所属商家");
|
||||
}
|
||||
} else{
|
||||
products.setMerchantId(sysUser.getDeptId());
|
||||
}
|
||||
products.setOperId(sysUser.getUserId());
|
||||
products.setUpdateTime(DateUtils.getNowDate());
|
||||
if(products.getIsSpecs()==null){
|
||||
return AjaxResult.error("请指定商品是否多规格");
|
||||
}
|
||||
if(Constants.SINGLE_SPEC.equals(products.getIsSpecs())){
|
||||
// return toAjax(productsService.updateProducts(products));
|
||||
// 商品类型为但规格处理
|
||||
boolean flag = productsSpecService.updateSingleProducts(products);
|
||||
return flag ? success("修改成功") : error("修改失败");
|
||||
}
|
||||
|
||||
else if(Constants.MULTI_SPEC.equals(products.getIsSpecs())){
|
||||
// 实现多规格商品信息变更的逻辑
|
||||
boolean flag = productsSpecService.updateMulSpecProducts(products);
|
||||
return flag ? success("修改成功") : error("修改失败");
|
||||
}
|
||||
|
||||
else{
|
||||
return AjaxResult.error("请指定商品是否多规格");
|
||||
}
|
||||
// return toAjax(productsSpecService.commonUpdateProducts(products));
|
||||
// return toAjax(productsService.updateProductsAndSpec(products));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
*/
|
||||
@DeleteMapping("/{productIds}")
|
||||
public AjaxResult remove(@PathVariable Integer[] productIds)
|
||||
{
|
||||
return toAjax(productsService.deleteProductsByProductIds(productIds,isAllowDeleteSpecs));
|
||||
}
|
||||
|
||||
/**
|
||||
* 逻辑删除商品
|
||||
*/
|
||||
@DeleteMapping("/logic/{productIds}")
|
||||
public AjaxResult logicDelete(@PathVariable Integer[] productIds)
|
||||
{
|
||||
return toAjax(productsService.deleteProductsLogicByProductIds(productIds));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.zf.foodpurchase.fdsafe.web.merchant;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.zf.foodpurchase.common.core.controller.BaseController;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.common.core.domain.entity.SysUser;
|
||||
import com.zf.foodpurchase.common.core.page.TableDataInfo;
|
||||
import com.zf.foodpurchase.fdsafe.entity.FoodProduct;
|
||||
import com.zf.foodpurchase.fdsafe.entity.InRepoVO;
|
||||
import com.zf.foodpurchase.fdsafe.entity.RepoRecord;
|
||||
import com.zf.foodpurchase.fdsafe.service.IFoodProductService;
|
||||
import com.zf.foodpurchase.fdsafe.service.IRepoRecordService;
|
||||
import com.zf.foodpurchase.fdsafe.vo.FoodProductCKVO;
|
||||
import com.zf.foodpurchase.fdsafe.vo.RepoRecordVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/merchant/repoRecord")
|
||||
public class RepoRecordController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IRepoRecordService repoRecordService;
|
||||
@Autowired
|
||||
private IFoodProductService foodProductsService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(RepoRecord repoRecord)
|
||||
{
|
||||
startPage();
|
||||
SysUser sysUser = getLoginUser().getUser();
|
||||
if(!sysUser.isAdmin()){
|
||||
repoRecord.setDeptIds(sysUser.getDeptIdList());
|
||||
}
|
||||
List<RepoRecordVO> list = repoRecordService.selectRepoRecordList(repoRecord);
|
||||
list.forEach(f -> {
|
||||
if(f.getStatus() != null){
|
||||
if(ObjectUtil.equal(f.getStatus(),1)){
|
||||
f.setStatusName("入库");
|
||||
} else{
|
||||
f.setStatusName("出库");
|
||||
}
|
||||
}
|
||||
if(f.getProductId() != null){
|
||||
FoodProduct products = foodProductsService.getById(f.getProductId());
|
||||
f.setFoodProducts(Arrays.asList(products));
|
||||
}
|
||||
});
|
||||
return getDataTable(list);
|
||||
}
|
||||
@GetMapping(value = "/{repoRecordId}")
|
||||
public AjaxResult getInfo(@PathVariable("repoRecordId") Long repoRecordId)
|
||||
{
|
||||
RepoRecordVO repoRecordVO = repoRecordService.selectRepoRecordByRepoRecordId(repoRecordId);
|
||||
if(repoRecordVO.getStatus() != null){
|
||||
if(ObjectUtil.equal(repoRecordVO.getStatus(),1)){
|
||||
repoRecordVO.setStatusName("入库");
|
||||
} else{
|
||||
repoRecordVO.setStatusName("出库");
|
||||
}
|
||||
}
|
||||
if(repoRecordVO.getProductId() != null){
|
||||
FoodProduct products = foodProductsService.getById(repoRecordVO.getProductId());
|
||||
repoRecordVO.setFoodProducts(Arrays.asList(products));
|
||||
}
|
||||
return success(repoRecordService.selectRepoRecordByRepoRecordId(repoRecordId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 入库
|
||||
*/
|
||||
@PostMapping("/in")
|
||||
public AjaxResult inRepo(@Validated @RequestBody List<InRepoVO> inRepoVOs)
|
||||
{
|
||||
return repoRecordService.inRepo(inRepoVOs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 出库
|
||||
*/
|
||||
@PostMapping("/out")
|
||||
public AjaxResult outRepo(@Validated @RequestBody List<FoodProductCKVO> foodProductCKVOs)
|
||||
{
|
||||
return repoRecordService.outRepo(foodProductCKVOs);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.zf.foodpurchase.fdsafe.web.merchant;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zf.foodpurchase.common.core.controller.BaseController;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
@@ -9,10 +11,12 @@ import com.zf.foodpurchase.common.core.page.TableDataInfo;
|
||||
import com.zf.foodpurchase.common.utils.DateUtils;
|
||||
import com.zf.foodpurchase.fdsafe.entity.Repository;
|
||||
import com.zf.foodpurchase.fdsafe.service.IRepositoryService;
|
||||
import com.zf.foodpurchase.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -30,25 +34,50 @@ public class RepositoryController extends BaseController {
|
||||
@Autowired
|
||||
private IRepositoryService repositoryService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(Repository repository) {
|
||||
List<Repository> list = repositoryService.joinQueryList(getQuryRepository(repository));
|
||||
SysUser sysUser = userService.getUser();
|
||||
if(ObjectUtil.isNotNull(sysUser)){
|
||||
if(!sysUser.isAdmin()){
|
||||
List<Long> deptIds = sysUser.getDeptIdList();
|
||||
if(CollectionUtil.isEmpty(deptIds)){
|
||||
return AjaxResult.success(new ArrayList<>());
|
||||
}
|
||||
repository.setDeptIds(deptIds);
|
||||
}else{
|
||||
repository.setMerchantId(null);
|
||||
}
|
||||
}
|
||||
List<Repository> list = repositoryService.queryRepoList(repository);
|
||||
return AjaxResult.success("查询成功", list);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/pageList")
|
||||
public TableDataInfo pageList(Repository repository) {
|
||||
List<Repository> list = repositoryService.joinQueryList(getQuryRepository(repository));
|
||||
SysUser sysUser = userService.getUser();
|
||||
if(ObjectUtil.isNotNull(sysUser)){
|
||||
if(!sysUser.isAdmin()){
|
||||
List<Long> deptIds = sysUser.getDeptIdList();
|
||||
if(CollectionUtil.isEmpty(deptIds)){
|
||||
return getDataTable(new ArrayList<>());
|
||||
}
|
||||
repository.setDeptIds(deptIds);
|
||||
}else{
|
||||
repository.setMerchantId(null);
|
||||
}
|
||||
}
|
||||
List<Repository> list = repositoryService.queryRepoList(repository);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PostMapping("/addRepo")
|
||||
public AjaxResult addRepo(@Validated @RequestBody Repository repository) {
|
||||
SysUser user = getLoginUser().getUser();
|
||||
if (!user.isAdmin()) {
|
||||
repository.setMerchantId(user.getDeptId());
|
||||
}else {
|
||||
SysUser sysUser = userService.getUser();
|
||||
if (sysUser.isAdmin()) {
|
||||
if(repository.getMerchantId() == null){
|
||||
return error("必须指定要添加的仓库所属商户");
|
||||
}
|
||||
@@ -66,65 +95,14 @@ public class RepositoryController extends BaseController {
|
||||
*/
|
||||
@PostMapping("/modifyRepo")
|
||||
public AjaxResult modifyRepo(@Validated @RequestBody Repository repository) {
|
||||
if (repository.getId() == null) {
|
||||
return error("必须指定要修改的仓库id");
|
||||
}
|
||||
if (!verifyUpdateAuth(repository)) {
|
||||
return error("传入的商店下没有该仓库");
|
||||
}
|
||||
return repositoryService.modifyRepo(repository);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
public AjaxResult delete(Long[] ids) {
|
||||
SysUser user = getLoginUser().getUser();
|
||||
boolean flag = false;
|
||||
List<Long> list = Arrays.asList(ids);
|
||||
if (!user.isAdmin()) {
|
||||
LambdaQueryWrapper<Repository> queryWrapper = new LambdaQueryWrapper<Repository>();
|
||||
queryWrapper.in(Repository::getId, list);
|
||||
queryWrapper.eq(Repository::getMerchantId, user.getDeptId());
|
||||
flag = repositoryService.remove(queryWrapper);
|
||||
}else{
|
||||
flag = repositoryService.removeByIds(list);
|
||||
}
|
||||
flag = repositoryService.removeByIds( list);
|
||||
return flag?AjaxResult.success("删除成功"):AjaxResult.error("删除失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询条件构建
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Repository getQuryRepository(Repository repository) {
|
||||
if (repository == null) {
|
||||
repository = new Repository();
|
||||
}
|
||||
SysUser user = getLoginUser().getUser();
|
||||
if (!user.isAdmin()) {
|
||||
repository.setMerchantId(user.getDeptId());
|
||||
} else {
|
||||
repository.setMerchantId(null);
|
||||
}
|
||||
return repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证是够具有修改记录的权限
|
||||
*
|
||||
* @param repository
|
||||
* @return
|
||||
*/
|
||||
public boolean verifyUpdateAuth(Repository repository) {
|
||||
|
||||
LambdaQueryWrapper<Repository> queryWrapper = new LambdaQueryWrapper<Repository>();
|
||||
queryWrapper.eq(Repository::getId, repository.getId());
|
||||
queryWrapper.eq(Repository::getMerchantId, getLoginUser().getUser().getDeptId());
|
||||
long count = repositoryService.count(queryWrapper);
|
||||
if (getLoginUser().getUser().isAdmin()) {
|
||||
return true;
|
||||
}
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,219 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.web.merchant;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zf.foodpurchase.common.core.controller.BaseController;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.common.core.domain.entity.SysUser;
|
||||
import com.zf.foodpurchase.common.core.page.TableDataInfo;
|
||||
import com.zf.foodpurchase.common.utils.DateUtils;
|
||||
import com.zf.foodpurchase.fdsafe.entity.Cascade;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SpecTypes;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SpecValues;
|
||||
import com.zf.foodpurchase.fdsafe.service.ISpecTypesService;
|
||||
import com.zf.foodpurchase.fdsafe.service.ISpecValuesService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品规格类型表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-16
|
||||
*/
|
||||
@Api(tags = "规格类型管理")
|
||||
@RestController
|
||||
@RequestMapping("/merchant/specTypes")
|
||||
public class SpecTypesController extends BaseController {
|
||||
@Autowired
|
||||
private ISpecTypesService specTypesService;
|
||||
|
||||
@Autowired
|
||||
private ISpecValuesService specValuesService;
|
||||
|
||||
@ApiOperation("查询规格类型列表")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(String specName) {
|
||||
startPage();
|
||||
List<SpecTypes> typeList = new ArrayList<>();
|
||||
SysUser user=getLoginUser().getUser();
|
||||
Long merchantId = user.isAdmin()? null:user.getDeptId();
|
||||
|
||||
// 管理员
|
||||
if(merchantId == null){
|
||||
if(StringUtils.isNotBlank(specName)){
|
||||
LambdaQueryWrapper<SpecTypes> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.like(SpecTypes::getSpecName, specName);
|
||||
typeList = specTypesService.list(queryWrapper);
|
||||
}else{
|
||||
typeList = specTypesService.list();
|
||||
}
|
||||
}
|
||||
// 非管理员
|
||||
else{
|
||||
LambdaQueryWrapper<SpecTypes> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SpecTypes::getMerchantId, merchantId);
|
||||
queryWrapper.like(StringUtils.isNotBlank(specName),SpecTypes::getSpecName, specName);
|
||||
typeList = specTypesService.list(queryWrapper);
|
||||
}
|
||||
|
||||
for (SpecTypes specTypes : typeList) {
|
||||
LambdaQueryWrapper<SpecValues> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SpecValues::getSpecType, specTypes.getSpecType());
|
||||
List<SpecValues> specValuesList = specValuesService.list(queryWrapper);
|
||||
specTypes.setSpecValuesList(specValuesList);
|
||||
// 是否有子节点
|
||||
boolean hasChildren = !CollectionUtils.isEmpty(specValuesList);
|
||||
specTypes.setHasChildren(hasChildren);
|
||||
|
||||
if(hasChildren){
|
||||
specTypes.getSpecValuesList().forEach(specValues -> specValues.setSpecName(specTypes.getSpecName()));
|
||||
}
|
||||
}
|
||||
return getDataTable(typeList);
|
||||
}
|
||||
|
||||
@ApiOperation("规格列表级联结构")
|
||||
@GetMapping("/cascade")
|
||||
public AjaxResult cascade(Long merchantId) {
|
||||
List<SpecTypes> typeList = new ArrayList<>();
|
||||
SysUser user=getLoginUser().getUser();
|
||||
if(user.isAdmin()){
|
||||
if(merchantId == null){
|
||||
return error("请传入商户id");
|
||||
}else{
|
||||
typeList = specTypesService.list(new LambdaQueryWrapper<SpecTypes>().eq(SpecTypes::getMerchantId, merchantId));
|
||||
}
|
||||
}else{
|
||||
merchantId = user.getDeptId();
|
||||
typeList = specTypesService.list(new LambdaQueryWrapper<SpecTypes>().eq(SpecTypes::getMerchantId, merchantId));
|
||||
}
|
||||
HashMap<String,List<Cascade>> map = new HashMap<>();
|
||||
List<Cascade> parentList = new ArrayList<>();
|
||||
// 逐层构建
|
||||
for (SpecTypes specTypes : typeList) {
|
||||
Cascade parentNode = new Cascade();
|
||||
parentNode.setLabel(specTypes.getSpecName());
|
||||
parentNode.setValue(specTypes.getSpecType());
|
||||
// 级联结构构件
|
||||
List<Cascade> childrenList = new ArrayList<>();
|
||||
LambdaQueryWrapper<SpecValues> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SpecValues::getSpecType, specTypes.getSpecType());
|
||||
List<SpecValues> specValuesList = specValuesService.list(queryWrapper);
|
||||
// 是否有子节点
|
||||
boolean hasChildren = !CollectionUtils.isEmpty(specValuesList);
|
||||
if(hasChildren){
|
||||
specValuesList.forEach(specValues -> {
|
||||
Cascade cascade = new Cascade();
|
||||
if(StringUtils.isNotBlank(specValues.getSpecUnit())){
|
||||
cascade.setLabel(specValues.getSpecValue()+specValues.getSpecUnit());
|
||||
}else {
|
||||
cascade.setLabel(specValues.getSpecValue());
|
||||
}
|
||||
cascade.setValue(specValues.getId());
|
||||
childrenList.add(cascade);
|
||||
|
||||
} );
|
||||
parentNode.setChildren(childrenList);
|
||||
parentList.add(parentNode);
|
||||
}
|
||||
}
|
||||
|
||||
return success(parentList);
|
||||
}
|
||||
|
||||
@ApiOperation("添加规格类型列表")
|
||||
@PostMapping("/addSpecTypes")
|
||||
public AjaxResult addSpecTypes(@Validated @RequestBody SpecTypes specTypes) {
|
||||
SysUser user=getLoginUser().getUser();
|
||||
if(user.isAdmin()){
|
||||
if(specTypes.getMerchantId() == null){
|
||||
return error("请指定商户");
|
||||
}
|
||||
}else{
|
||||
specTypes.setMerchantId(user.getDeptId());
|
||||
}
|
||||
specTypes.setOperId(getUserId());
|
||||
specTypes.setCreateTime(DateUtils.getNowDate());
|
||||
return specTypesService.saveTypes(specTypes);
|
||||
}
|
||||
|
||||
// @ApiOperation("修改规格类型列表")
|
||||
// @PostMapping("/modifySpecName")
|
||||
// public AjaxResult modifySpecName(@Validated @RequestBody SpecTypes specTypes) {
|
||||
// SysUser user=getLoginUser().getUser();
|
||||
// specTypes.setOperId(getUserId());
|
||||
// specTypes.setUpdateTime(DateUtils.getNowDate());
|
||||
// if(user.isAdmin()){
|
||||
// if(specTypes.getMerchantId() == null){
|
||||
// return error("请指定商户");
|
||||
// }
|
||||
// }else{
|
||||
// specTypes.setMerchantId(user.getDeptId());
|
||||
// }
|
||||
// return specTypesService.updateType(specTypes,user.isAdmin());
|
||||
// }
|
||||
|
||||
// @ApiOperation("删除规格类型列表-单个")
|
||||
// @DeleteMapping("/deleteById")
|
||||
// public AjaxResult deleteById(Long id) {
|
||||
// if (id == null) {
|
||||
// return warn("请选择要删除的数据");
|
||||
// }
|
||||
//
|
||||
// // todo:如果有类型值关联,需要先删除对应的类型值
|
||||
// LambdaQueryWrapper<SpecValues> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// queryWrapper.eq(SpecValues::getSpecType, id);
|
||||
// if (specValuesService.count(queryWrapper) > 0) {
|
||||
// return error("该规格类型下有规格值,请先删除规格值");
|
||||
// }
|
||||
//
|
||||
// return toAjax(specTypesService.removeById(id));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 注意: 需要确保改ids不存在关联的规格值,否则无法删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("删除规格类型列表-多个")
|
||||
@DeleteMapping("/deleteByIds")
|
||||
public AjaxResult deleteByIds(Long id) {
|
||||
if (id == null ) {
|
||||
return warn("请选择要删除的数据");
|
||||
}
|
||||
List<Long> list = new ArrayList<>();
|
||||
list.add(id);
|
||||
SysUser user=getLoginUser().getUser();
|
||||
Long merchantId = user.isAdmin()? null:user.getDeptId();
|
||||
return specTypesService.removeSpecTypes(list,merchantId);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("删除规格类型列表-多个")
|
||||
@DeleteMapping("/deleteMoreIds")
|
||||
public AjaxResult deleteMoreIds(Long[] ids) {
|
||||
if (ids == null || ids.length <= 0) {
|
||||
return warn("请选择要删除的数据");
|
||||
}
|
||||
List<Long> list = Arrays.asList(ids);
|
||||
SysUser user=getLoginUser().getUser();
|
||||
Long merchantId = user.isAdmin()? null:user.getDeptId();
|
||||
return specTypesService.removeSpecTypes(list,merchantId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.zf.foodpurchase.common.valigroud.AddGroup;
|
||||
import com.zf.foodpurchase.common.valigroud.UpdateGroup;
|
||||
import com.zf.foodpurchase.fdsafe.service.ISchoolCartItemService;
|
||||
import com.zf.foodpurchase.fdsafe.vo.SchoolCartItemVO;
|
||||
import com.zf.foodpurchase.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -32,15 +33,20 @@ public class SchoolCartItemController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ISchoolCartItemService schoolCartItemService;
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@GetMapping("/pageList")
|
||||
public TableDataInfo pageList(SchoolCartItemVO schoolCartItemVO) {
|
||||
startPage();
|
||||
// 填充学校id,教育局id等数据
|
||||
dealCommonVO(schoolCartItemVO);
|
||||
//
|
||||
SysUser user = getLoginUser().getUser();
|
||||
SysUser user = userService.getUser();
|
||||
if(!user.isAdmin()){
|
||||
Integer accountType =getLoginUser().getUser().getAccountType();
|
||||
Integer accountType =user.getAccountType();
|
||||
List<Long> deptIds = user.getDeptIdList();
|
||||
schoolCartItemVO.setDeptIds(deptIds);
|
||||
if(!WxAPPAccountConstants.SCHOOL.equals(accountType)){
|
||||
// throw new ServiceException("非学校账号无法查询购物车信息");
|
||||
// 返回空的数据
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zf.foodpurchase.fdsafe.web.school;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.zf.foodpurchase.common.constant.WxAPPAccountConstants;
|
||||
import com.zf.foodpurchase.common.core.controller.BaseController;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
@@ -10,11 +11,13 @@ import com.zf.foodpurchase.common.core.page.TableDataInfo;
|
||||
import com.zf.foodpurchase.fdsafe.service.ISchoolOrderItemService;
|
||||
import com.zf.foodpurchase.fdsafe.service.ISchoolOrderService;
|
||||
import com.zf.foodpurchase.fdsafe.vo.*;
|
||||
import com.zf.foodpurchase.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -35,16 +38,53 @@ public class SchoolOrderController extends BaseController {
|
||||
@Autowired
|
||||
private ISchoolOrderItemService schoolOrderItemService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@GetMapping("/pageList")
|
||||
public TableDataInfo pageList(SchoolOrderVO schoolOrderVO) {
|
||||
|
||||
@GetMapping("/supplierPageList")
|
||||
public TableDataInfo supplierPageList(SchoolOrderVO schoolOrderVO) {
|
||||
startPage();
|
||||
SysUser user = userService.getUser();
|
||||
if(!user.isAdmin()){
|
||||
List<Long> deptIds = user.getDeptIdList();
|
||||
schoolOrderVO.setDeptIds(deptIds);
|
||||
}
|
||||
// 填充学校id,教育局id等数据
|
||||
dealCommonVO(schoolOrderVO);
|
||||
List<SchoolOrderVO> list = schoolOrderService.querySupplierOrderVO(schoolOrderVO);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@GetMapping("/schoolPageList")
|
||||
public TableDataInfo schoolPageList(SchoolOrderVO schoolOrderVO) {
|
||||
startPage();
|
||||
SysUser user = userService.getUser();
|
||||
if(!user.isAdmin()){
|
||||
List<Long> deptIds = user.getDeptIdList();
|
||||
schoolOrderVO.setDeptIds(deptIds);
|
||||
}
|
||||
// 填充学校id,教育局id等数据
|
||||
dealCommonVO(schoolOrderVO);
|
||||
List<SchoolOrderVO> list = schoolOrderService.querySchoolOrderVO(schoolOrderVO);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@GetMapping("/schoolList")
|
||||
public AjaxResult schoolList() {
|
||||
SchoolOrderVO schoolOrderVO = new SchoolOrderVO();
|
||||
schoolOrderVO.setOrderStatus(3);
|
||||
SysUser user = userService.getUser();
|
||||
if(!user.isAdmin()){
|
||||
List<Long> deptIds = user.getDeptIdList();
|
||||
schoolOrderVO.setDeptIds(deptIds);
|
||||
}
|
||||
// 填充学校id,教育局id等数据
|
||||
dealCommonVO(schoolOrderVO);
|
||||
List<SchoolOrderVO> list = schoolOrderService.querySchoolOrderVO(schoolOrderVO);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交订单:
|
||||
* 1.校验:商品有效性校验,订单金额校验
|
||||
@@ -57,9 +97,9 @@ public class SchoolOrderController extends BaseController {
|
||||
*/
|
||||
@PostMapping("/submitOrder")
|
||||
public AjaxResult submitOrder(@RequestBody @Valid SchoolSubmitOrderVO submitOrderVO) {
|
||||
SysUser user = getLoginUser().getUser();
|
||||
SysUser user = userService.getUser();
|
||||
if(!user.isAdmin()){
|
||||
Integer accountType =getLoginUser().getUser().getAccountType();
|
||||
Integer accountType =user.getAccountType();
|
||||
if(!WxAPPAccountConstants.SCHOOL.equals(accountType)){
|
||||
return error("非学校账号无法提交订单");
|
||||
}
|
||||
@@ -73,9 +113,9 @@ public class SchoolOrderController extends BaseController {
|
||||
*/
|
||||
@PostMapping("/cancelOrder")
|
||||
public AjaxResult cancelOrder(@RequestBody @Valid SchoolCancelOrderVO cancelOrderVO) {
|
||||
SysUser user = getLoginUser().getUser();
|
||||
SysUser user = userService.getUser();
|
||||
if(!user.isAdmin()){
|
||||
Integer accountType =getLoginUser().getUser().getAccountType();
|
||||
Integer accountType =user.getAccountType();
|
||||
if(!WxAPPAccountConstants.SCHOOL.equals(accountType)){
|
||||
return error("非学校账号无法取消订单");
|
||||
}
|
||||
@@ -88,9 +128,9 @@ public class SchoolOrderController extends BaseController {
|
||||
*/
|
||||
@PostMapping("/updateOrderRemark")
|
||||
public AjaxResult updateOrderRemark(@RequestBody @Valid SchoolModifyOrderRemarkVO remarkVO) {
|
||||
SysUser user = getLoginUser().getUser();
|
||||
SysUser user = userService.getUser();
|
||||
if(!user.isAdmin()){
|
||||
Integer accountType =getLoginUser().getUser().getAccountType();
|
||||
Integer accountType =user.getAccountType();
|
||||
if(!WxAPPAccountConstants.SCHOOL.equals(accountType)){
|
||||
return error("非学校账号无法修改订单备注");
|
||||
}
|
||||
@@ -115,14 +155,41 @@ public class SchoolOrderController extends BaseController {
|
||||
@GetMapping("/supplierAcceptOrder")
|
||||
public AjaxResult supplierAcceptOrder(@Validated SupplierAcceptOrderVO supplierAcceptOrderVO) {
|
||||
// 填充学校id,教育局id等数据
|
||||
dealCommonVO(supplierAcceptOrderVO);
|
||||
SysUser user = getLoginUser().getUser();
|
||||
SysUser user = userService.getUser();
|
||||
if(!user.isAdmin()){
|
||||
Integer accountType =getLoginUser().getUser().getAccountType();
|
||||
Integer accountType =user.getAccountType();
|
||||
if(!WxAPPAccountConstants.SUPPLIER.equals(accountType)){
|
||||
return error("非供货商账号无法接单");
|
||||
}
|
||||
}
|
||||
return schoolOrderService.supplierAcceptOrder(supplierAcceptOrderVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单详情
|
||||
* @param orderNo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryOrderMsg")
|
||||
public AjaxResult queryOrderMsg(String orderNo) {
|
||||
SchoolOrderVO schoolOrderVO = new SchoolOrderVO();
|
||||
schoolOrderVO.setOrderNo(orderNo);
|
||||
List<SchoolOrderVO> list = schoolOrderService.querySchoolOrderVO(schoolOrderVO);
|
||||
if(CollectionUtil.isEmpty( list)){
|
||||
return error("订单不存在");
|
||||
}
|
||||
SchoolOrderVO schoolOrder = list.get(0);
|
||||
SchoolOrderItemVO schoolOrderItemVO = new SchoolOrderItemVO();
|
||||
schoolOrderItemVO.setOrderNo(orderNo);
|
||||
List<SchoolOrderItemVO> itemList = schoolOrderItemService.querySchoolOrderItemVO(schoolOrderItemVO);
|
||||
schoolOrder.setSchoolOrderItemVOList(itemList);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/signOrder")
|
||||
public AjaxResult signOrder(@RequestBody SchoolOrderVO schoolOrderVO) {
|
||||
|
||||
return schoolOrderService.signOrder(schoolOrderVO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.common.core.page.TableDataInfo;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SchoolOrderItem;
|
||||
import com.zf.foodpurchase.fdsafe.service.ISchoolOrderItemService;
|
||||
import com.zf.foodpurchase.fdsafe.vo.ProductCountVO;
|
||||
import com.zf.foodpurchase.fdsafe.vo.SchoolOrderItemVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zf.foodpurchase.fdsafe.web.supplier;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.zf.foodpurchase.common.constant.WxAPPAccountConstants;
|
||||
import com.zf.foodpurchase.common.core.controller.BaseController;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
@@ -12,8 +13,10 @@ import com.zf.foodpurchase.common.valigroud.UpdateGroup;
|
||||
import com.zf.foodpurchase.fdsafe.entity.FoodProduct;
|
||||
import com.zf.foodpurchase.fdsafe.service.IFoodProductService;
|
||||
import com.zf.foodpurchase.fdsafe.utils.RestTemplateUtils;
|
||||
import com.zf.foodpurchase.fdsafe.vo.FoodProductCKVO;
|
||||
import com.zf.foodpurchase.fdsafe.vo.FoodProductVO;
|
||||
import com.zf.foodpurchase.fdsafe.vo.ReferencePriceVO;
|
||||
import com.zf.foodpurchase.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -34,11 +37,16 @@ public class FoodProductController extends BaseController {
|
||||
@Autowired
|
||||
private IFoodProductService foodProductService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@GetMapping("/pageList")
|
||||
public TableDataInfo pageList(FoodProductVO foodProductVO) {
|
||||
startPage();
|
||||
// 填充学校id,教育局id等数据
|
||||
dealCommonVO(foodProductVO);
|
||||
SysUser user = userService.getUser();
|
||||
if(!user.isAdmin()){
|
||||
foodProductVO.setSchoolId(user.getSchoolId());
|
||||
}
|
||||
foodProductVO.setDelFlag(0);
|
||||
List<FoodProductVO> list = foodProductService.queryFoodProductVO(foodProductVO);
|
||||
return getDataTable(list);
|
||||
@@ -47,30 +55,16 @@ public class FoodProductController extends BaseController {
|
||||
/**
|
||||
* 供货商发布商品
|
||||
*/
|
||||
@PostMapping("/supplierAdd")
|
||||
public AjaxResult supplierAdd(@RequestBody @Validated(AddGroup.class) FoodProductVO foodProductVO) {
|
||||
SysUser user = getLoginUser().getUser();
|
||||
if(!user.isAdmin()){
|
||||
Integer accountType =getLoginUser().getUser().getAccountType();
|
||||
if(!WxAPPAccountConstants.SUPPLIER.equals(accountType)){
|
||||
return error("非供货商账号无法添加商品");
|
||||
}
|
||||
}
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody @Validated(AddGroup.class) FoodProductVO foodProductVO) {
|
||||
return foodProductService.supplierAdd(foodProductVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 供货商修改商品
|
||||
*/
|
||||
@PostMapping("/supplierUpdate")
|
||||
public AjaxResult supplierUpdate(@RequestBody @Validated(UpdateGroup.class) FoodProductVO foodProductVO) {
|
||||
SysUser user = getLoginUser().getUser();
|
||||
if(!user.isAdmin()){
|
||||
Integer accountType =getLoginUser().getUser().getAccountType();
|
||||
if(!WxAPPAccountConstants.SUPPLIER.equals(accountType)){
|
||||
return error("非供货商账号无法修改商品");
|
||||
}
|
||||
}
|
||||
@PostMapping("/update")
|
||||
public AjaxResult update(@RequestBody @Validated(UpdateGroup.class) FoodProductVO foodProductVO) {
|
||||
return foodProductService.supplierUpdate(foodProductVO);
|
||||
}
|
||||
|
||||
@@ -79,9 +73,9 @@ public class FoodProductController extends BaseController {
|
||||
*/
|
||||
@PostMapping("/eduCheck")
|
||||
public AjaxResult eduCheck(@RequestBody @Validated(CheckGroup.class) FoodProductVO foodProductVO) {
|
||||
SysUser user = getLoginUser().getUser();
|
||||
SysUser user = userService.getUser();
|
||||
if(!user.isAdmin()){
|
||||
Integer accountType =getLoginUser().getUser().getAccountType();
|
||||
Integer accountType =user.getAccountType();
|
||||
if(!WxAPPAccountConstants.EDU.equals(accountType)){
|
||||
return error("非教育局账号无法审核商品");
|
||||
}
|
||||
@@ -92,18 +86,11 @@ public class FoodProductController extends BaseController {
|
||||
/**
|
||||
* 删除商品信息
|
||||
*/
|
||||
@GetMapping("/supplierDelete")
|
||||
public AjaxResult supplierDelete(Long foodProductId) {
|
||||
@GetMapping("/delete")
|
||||
public AjaxResult delete(Long foodProductId) {
|
||||
if(foodProductId == null){
|
||||
return error("商品id不能为空");
|
||||
}
|
||||
SysUser user = getLoginUser().getUser();
|
||||
if(!user.isAdmin()){
|
||||
Integer accountType =getLoginUser().getUser().getAccountType();
|
||||
if(!WxAPPAccountConstants.SUPPLIER.equals(accountType)){
|
||||
return error("非供货商账号无法删除商品");
|
||||
}
|
||||
}
|
||||
return foodProductService.removeById(foodProductId) ? success("删除成功") : error("删除失败");
|
||||
}
|
||||
|
||||
@@ -116,4 +103,10 @@ public class FoodProductController extends BaseController {
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/pageCKList")
|
||||
public TableDataInfo pageCKList(Integer repoId) {
|
||||
List<FoodProductCKVO> list = foodProductService.pageCKList(repoId);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user