食品采购出入库
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -159,6 +159,9 @@ public class SysUser extends BaseEntity {
|
||||
private Integer eduId;
|
||||
private String deptName;
|
||||
|
||||
private List<Long> roleIdList;
|
||||
private List<Long> deptIdList;
|
||||
|
||||
public Integer getSchoolId() {
|
||||
return schoolId;
|
||||
}
|
||||
@@ -395,6 +398,22 @@ public class SysUser extends BaseEntity {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public List<Long> getRoleIdList() {
|
||||
return roleIdList;
|
||||
}
|
||||
|
||||
public void setRoleIdList(List<Long> roleIdList) {
|
||||
this.roleIdList = roleIdList;
|
||||
}
|
||||
|
||||
public List<Long> getDeptIdList() {
|
||||
return deptIdList;
|
||||
}
|
||||
|
||||
public void setDeptIdList(List<Long> deptIdList) {
|
||||
this.deptIdList = deptIdList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
||||
@@ -127,7 +127,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers("/wx/area/**").permitAll()
|
||||
// 微信体验功能,部分接口权限放开
|
||||
// 首页查询商品查询,轮播图查询,类别查询,按类别查询商品接口
|
||||
.antMatchers("/wx/products/indexProducts","/wx/dict/type/product_category","/wx/products/category","/wx/carousel/list").permitAll()
|
||||
.antMatchers("/wx/products/indexProducts","/wx/dict/type/product_category","/wx/products/category","/wx/carousel/list", "/common/upload").permitAll()
|
||||
// 临时放开权限校验,共开发测试使用
|
||||
// .antMatchers("/wx/**").permitAll()
|
||||
.antMatchers("/wx/payApi/**").permitAll()
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 购物车明细表
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-19
|
||||
*/
|
||||
@Data
|
||||
public class CartItem implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField("user_id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 购物车id
|
||||
*/
|
||||
@TableField("cart_id")
|
||||
@NotNull(message = "购物车id不能为空")
|
||||
private Integer cartId;
|
||||
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
@NotNull(message = "商品id不能为空")
|
||||
@TableField("product_id")
|
||||
private Integer productId;
|
||||
|
||||
@TableField("product_name")
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 商品规格id
|
||||
*/
|
||||
@TableField("product_spec_id")
|
||||
private Integer productSpecId;
|
||||
|
||||
/**
|
||||
* 商品规格字符串
|
||||
*/
|
||||
@TableField("spec_str")
|
||||
private String specStr;
|
||||
|
||||
/**
|
||||
* 商品规格信息
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private ProductsSpec productSpec;
|
||||
|
||||
/**
|
||||
* 基础商品还是多规格商品
|
||||
*/
|
||||
@NotNull(message = "是否为多规格商品不能为空")
|
||||
@Length(max = 1, min = 1, message = "是否为多规格字段长度只能为1")
|
||||
@TableField("is_specs")
|
||||
private String isSpecs;
|
||||
|
||||
/**
|
||||
* 商品基本信息以及规格信息
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Products products;
|
||||
|
||||
/**
|
||||
* 商品数量
|
||||
*/
|
||||
@TableField("quantity")
|
||||
@NotNull(message = "商品数量不能为空")
|
||||
@Min(value = 1, message = "商品数量不能小于1")
|
||||
private Integer quantity;
|
||||
|
||||
/**
|
||||
* 加入购物车时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
@TableField("merchant_id")
|
||||
private Long merchantId;
|
||||
|
||||
/**
|
||||
* 微信平台跟服务商绑定的商户id
|
||||
*/
|
||||
@TableField("mchid")
|
||||
private String mchid;
|
||||
|
||||
/**
|
||||
* 用户收货地址id
|
||||
*/
|
||||
@NotNull(message = "用户收货地址不能为空")
|
||||
@TableField("address_id")
|
||||
private Integer addressId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String image;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String address;
|
||||
}
|
||||
@@ -38,7 +38,11 @@ public class FoodProduct implements Serializable {
|
||||
* 食材id
|
||||
*/
|
||||
private Integer foodId;
|
||||
|
||||
private String num;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 单价
|
||||
*/
|
||||
@@ -54,6 +58,23 @@ public class FoodProduct implements Serializable {
|
||||
*/
|
||||
private Integer eduId;
|
||||
|
||||
/**
|
||||
* 食材分类信息
|
||||
*/
|
||||
private Integer typeId;
|
||||
@TableField(exist = false)
|
||||
private String typeLabel;
|
||||
|
||||
// 单位信息
|
||||
private Integer unitId;
|
||||
@TableField(exist = false)
|
||||
private String unitLabel;
|
||||
|
||||
// 单位信息
|
||||
private Integer specId;
|
||||
@TableField(exist = false)
|
||||
private String specLabel;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.zf.foodpurchase.fdsafe.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FoodRepo {
|
||||
|
||||
private Integer id;
|
||||
private Integer foodProductId;
|
||||
private Integer repoId;
|
||||
private String orderNo;
|
||||
private String orderItemNo;
|
||||
private Integer foodProductNum;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.zf.foodpurchase.fdsafe.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2025-04-17
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class FoodSpec implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 食材规格/单位id
|
||||
*/
|
||||
@TableId(value = "spec_id", type = IdType.AUTO)
|
||||
private Integer specId;
|
||||
|
||||
/**
|
||||
* 食材规格
|
||||
*/
|
||||
private String specLabel;
|
||||
|
||||
/**
|
||||
* 0 正常 1 停用
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 是否有效: 0 有效 1 无效
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.zf.foodpurchase.fdsafe.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
public class InRepoVO {
|
||||
/**
|
||||
* 子订单编号
|
||||
*/
|
||||
private String orderItemNo;
|
||||
|
||||
/**
|
||||
* 学校id
|
||||
*/
|
||||
private Integer schoolId;
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 教育局id
|
||||
*/
|
||||
private Integer eduId;
|
||||
|
||||
/**
|
||||
* 供货商id
|
||||
*/
|
||||
private Integer supplierId;
|
||||
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Integer foodProductId;
|
||||
|
||||
/**
|
||||
* 食材名称
|
||||
*/
|
||||
private String foodName;
|
||||
|
||||
/**
|
||||
* 单价
|
||||
*/
|
||||
private BigDecimal price;
|
||||
|
||||
/**
|
||||
* 购买量
|
||||
*/
|
||||
private Integer productNum;
|
||||
|
||||
/**
|
||||
* 食材类别id
|
||||
*/
|
||||
private Integer typeId;
|
||||
|
||||
/**
|
||||
* 规格类型id
|
||||
*/
|
||||
private Integer unitId;
|
||||
|
||||
/**
|
||||
* 子订单状态:0 待接单;1 已接单;2 配送中;3 已完成;4 已取消
|
||||
*/
|
||||
private Integer orderItemStatus;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 订单项备注,来源与购物车备注
|
||||
*/
|
||||
private String orderItemRemark;
|
||||
/**
|
||||
* 食材ID
|
||||
*/
|
||||
private Integer foodId;
|
||||
|
||||
private Integer refundNum;
|
||||
|
||||
private Integer repoId;
|
||||
}
|
||||
@@ -1,496 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.zf.foodpurchase.common.annotation.Excel;
|
||||
import com.zf.foodpurchase.common.core.domain.BaseEntity;
|
||||
import com.zf.foodpurchase.fdsafe.vo.ProductsSpecVO;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品对象 products
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-11-16
|
||||
*/
|
||||
public class Products extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Integer productId;
|
||||
|
||||
/**
|
||||
* 商户id
|
||||
*/
|
||||
@Excel(name = "商户id")
|
||||
private Long merchantId;
|
||||
|
||||
/**
|
||||
* 商户id
|
||||
*/
|
||||
@Excel(name = "商家名称")
|
||||
private String merchantName;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@Excel(name = "名称")
|
||||
@NotBlank(message = "商品名称不能为空")
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Excel(name = "描述")
|
||||
private String description;
|
||||
|
||||
public String getFirstImage() {
|
||||
return firstImage;
|
||||
}
|
||||
|
||||
public void setFirstImage(String firstImage) {
|
||||
this.firstImage = firstImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单价
|
||||
*/
|
||||
@Excel(name = "单价")
|
||||
@Min(value = 0, message = "价格不能小于0")
|
||||
private Integer basePrice;
|
||||
|
||||
/**
|
||||
* 库存
|
||||
*/
|
||||
@Excel(name = "库存")
|
||||
@Min(value = 0, message = "库存不能小于0")
|
||||
private Integer totalStock;
|
||||
|
||||
@Min(value = 1, message = "购买数量不能小于0")
|
||||
private Integer buyCount;
|
||||
|
||||
/**
|
||||
* 商品图片
|
||||
*/
|
||||
@Excel(name = "商品图片")
|
||||
private String images;
|
||||
|
||||
private String firstImage;
|
||||
|
||||
private String[] imagesArray;
|
||||
|
||||
/**
|
||||
* 所属类别
|
||||
*/
|
||||
@Excel(name = "所属类别")
|
||||
@NotBlank(message = "所属类别不能为空")
|
||||
private String categoryId;
|
||||
|
||||
/**
|
||||
* 上架状态
|
||||
*/
|
||||
@Excel(name = "上架状态")
|
||||
@NotNull(message = "上架状态不能为空")
|
||||
@Length(min = 1, max = 1, message = "上架状态最大长度为1")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 购买类型
|
||||
*/
|
||||
@Excel(name = "购买类型")
|
||||
@NotNull(message = "购买类型不能为空")
|
||||
@Length(min = 1, max = 1, message = "购买类型最大长度为1")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 所需积分
|
||||
*/
|
||||
@Excel(name = "所需积分")
|
||||
@Min(value = 0, message = "所需积分不能小于0")
|
||||
private Integer baseIntegral;
|
||||
|
||||
/**
|
||||
* 返还积分
|
||||
*/
|
||||
@Excel(name = "返还积分")
|
||||
@Min(value = 0, message = "返还积分不能小于0")
|
||||
private Integer baseReturnIntergral;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 操作人id
|
||||
*/
|
||||
@Excel(name = "操作人id")
|
||||
private Long operId;
|
||||
|
||||
/**
|
||||
* 是否
|
||||
*/
|
||||
@Excel(name = "是否")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 详情图片
|
||||
*/
|
||||
@Excel(name = "详情图片")
|
||||
private String detailImages;
|
||||
|
||||
private Long version;
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多规格级联结构
|
||||
*/
|
||||
private List<ProductsSpecVO> specs;
|
||||
|
||||
/**
|
||||
* 收获地址id,微信小程序生成订单时使用
|
||||
*/
|
||||
private Integer addressId;
|
||||
|
||||
public Integer getAddressId() {
|
||||
return addressId;
|
||||
}
|
||||
|
||||
public void setAddressId(Integer addressId) {
|
||||
this.addressId = addressId;
|
||||
}
|
||||
|
||||
public List<ProductsSpecVO> getSpecs() {
|
||||
return specs;
|
||||
}
|
||||
|
||||
public void setSpecs(List<ProductsSpecVO> specs) {
|
||||
this.specs = specs;
|
||||
}
|
||||
|
||||
private String firstDetailsImage;
|
||||
|
||||
public String getFirstDetailsImage() {
|
||||
return firstDetailsImage;
|
||||
}
|
||||
|
||||
public void setFirstDetailsImage(String firstDetailsImage) {
|
||||
this.firstDetailsImage = firstDetailsImage;
|
||||
}
|
||||
|
||||
public String[] getDetailImagesArray() {
|
||||
return detailImagesArray;
|
||||
}
|
||||
|
||||
public void setDetailImagesArray(String[] detailImagesArray) {
|
||||
this.detailImagesArray = detailImagesArray;
|
||||
}
|
||||
|
||||
public String[] getImagesArray() {
|
||||
return imagesArray;
|
||||
}
|
||||
|
||||
public void setImagesArray(String[] imagesArray) {
|
||||
this.imagesArray = imagesArray;
|
||||
}
|
||||
|
||||
private String[] detailImagesArray;
|
||||
|
||||
@Excel(name = "是否多规格商品")
|
||||
private String isSpecs;
|
||||
|
||||
private Integer sailCount;
|
||||
|
||||
private String hot;
|
||||
|
||||
private String recommend;
|
||||
|
||||
private ProductsSpec productsSpec;
|
||||
|
||||
public List<ProductsSpec> getProductsSpecList() {
|
||||
return productsSpecList;
|
||||
}
|
||||
|
||||
public void setProductsSpecList(List<ProductsSpec> productsSpecList) {
|
||||
this.productsSpecList = productsSpecList;
|
||||
}
|
||||
|
||||
private List<ProductsSpec> productsSpecList;
|
||||
|
||||
private Integer limitNum = 5;
|
||||
|
||||
private String isNew;
|
||||
|
||||
public String getIsNew() {
|
||||
return isNew;
|
||||
}
|
||||
|
||||
public void setIsNew(String isNew) {
|
||||
this.isNew = isNew;
|
||||
}
|
||||
|
||||
public Integer getLimitNum() {
|
||||
return limitNum;
|
||||
}
|
||||
|
||||
public void setLimitNum(Integer limitNum) {
|
||||
this.limitNum = limitNum;
|
||||
}
|
||||
|
||||
public ProductsSpec getProductsSpec() {
|
||||
return productsSpec;
|
||||
}
|
||||
|
||||
public void setProductsSpec(ProductsSpec productsSpec) {
|
||||
this.productsSpec = productsSpec;
|
||||
}
|
||||
|
||||
List<SpecValues> specValuesList;
|
||||
|
||||
public Integer getSailCount() {
|
||||
return sailCount;
|
||||
}
|
||||
|
||||
public void setSailCount(Integer sailCount) {
|
||||
this.sailCount = sailCount;
|
||||
}
|
||||
|
||||
public String getHot() {
|
||||
return hot;
|
||||
}
|
||||
|
||||
public void setHot(String hot) {
|
||||
this.hot = hot;
|
||||
}
|
||||
|
||||
public String getRecommend() {
|
||||
return recommend;
|
||||
}
|
||||
|
||||
public void setRecommend(String recommend) {
|
||||
this.recommend = recommend;
|
||||
}
|
||||
|
||||
|
||||
public List<SpecValues> getSpecValuesList() {
|
||||
return specValuesList;
|
||||
}
|
||||
|
||||
public void setSpecValuesList(List<SpecValues> specValuesList) {
|
||||
this.specValuesList = specValuesList;
|
||||
}
|
||||
|
||||
public String getMerchantName() {
|
||||
return merchantName;
|
||||
}
|
||||
|
||||
public void setMerchantName(String merchantName) {
|
||||
this.merchantName = merchantName;
|
||||
}
|
||||
|
||||
public String getIsSpecs() {
|
||||
return isSpecs;
|
||||
}
|
||||
|
||||
public void setIsSpecs(String isSpecs) {
|
||||
this.isSpecs = isSpecs;
|
||||
}
|
||||
|
||||
public void setProductId(Integer productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public Integer getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setMerchantId(Long merchantId) {
|
||||
this.merchantId = merchantId;
|
||||
}
|
||||
|
||||
public Long getMerchantId() {
|
||||
return merchantId;
|
||||
}
|
||||
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setBasePrice(Integer basePrice) {
|
||||
this.basePrice = basePrice;
|
||||
}
|
||||
|
||||
public Integer getBasePrice() {
|
||||
return basePrice;
|
||||
}
|
||||
|
||||
public void setTotalStock(Integer totalStock) {
|
||||
this.totalStock = totalStock;
|
||||
}
|
||||
|
||||
public Integer getTotalStock() {
|
||||
return totalStock;
|
||||
}
|
||||
|
||||
public void setImages(String images) {
|
||||
this.images = images;
|
||||
}
|
||||
|
||||
public String getImages() {
|
||||
return images;
|
||||
}
|
||||
|
||||
public void setCategoryId(String categoryId) {
|
||||
this.categoryId = categoryId;
|
||||
}
|
||||
|
||||
public String getCategoryId() {
|
||||
return categoryId;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setBaseIntegral(Integer baseIntegral) {
|
||||
this.baseIntegral = baseIntegral;
|
||||
}
|
||||
|
||||
public Integer getBaseIntegral() {
|
||||
return baseIntegral;
|
||||
}
|
||||
|
||||
public void setBaseReturnIntergral(Integer baseReturnIntergral) {
|
||||
this.baseReturnIntergral = baseReturnIntergral;
|
||||
}
|
||||
|
||||
public Integer getBaseReturnIntergral() {
|
||||
return baseReturnIntergral;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setOperId(Long operId) {
|
||||
this.operId = operId;
|
||||
}
|
||||
|
||||
public Long getOperId() {
|
||||
return operId;
|
||||
}
|
||||
|
||||
public void setDelFlag(String delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDetailImages(String detailImages) {
|
||||
this.detailImages = detailImages;
|
||||
}
|
||||
|
||||
public String getDetailImages() {
|
||||
return detailImages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("productId", getProductId())
|
||||
.append("merchantId", getMerchantId())
|
||||
.append("productName", getProductName())
|
||||
.append("description", getDescription())
|
||||
.append("basePrice", getBasePrice())
|
||||
.append("totalStock", getTotalStock())
|
||||
.append("images", getImages())
|
||||
.append("categoryId", getCategoryId())
|
||||
.append("status", getStatus())
|
||||
.append("type", getType())
|
||||
.append("baseIntegral", getBaseIntegral())
|
||||
.append("baseReturnIntergral", getBaseReturnIntergral())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("operId", getOperId())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("detailImages", getDetailImages())
|
||||
.toString();
|
||||
}
|
||||
|
||||
public Integer getBuyCount() {
|
||||
return buyCount;
|
||||
}
|
||||
|
||||
public void setBuyCount(Integer buyCount) {
|
||||
this.buyCount = buyCount;
|
||||
}
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品价格表
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-18
|
||||
*/
|
||||
@Data
|
||||
public class ProductsSpec implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 商品-规格id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
@TableField("product_id")
|
||||
@NotNull(message = "商品id不能为空")
|
||||
private Integer productId;
|
||||
|
||||
@TableField("merchant_id")
|
||||
private Long merchantId;
|
||||
|
||||
/**
|
||||
* 规格值ids
|
||||
*/
|
||||
@TableField("spec_values")
|
||||
// @NotNull(message = "规格值不能为空")
|
||||
private String specValues;
|
||||
|
||||
/**
|
||||
* specValueArray
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<List<Integer>> specValueArray;
|
||||
|
||||
/**
|
||||
* 规格值类型与规格类型id
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
List<SpecValues> specValuesList;
|
||||
|
||||
/**
|
||||
* 商品价格
|
||||
*/
|
||||
@TableField("price")
|
||||
@NotNull(message = "价格不能为空")
|
||||
@Min(value = 0, message = "价格不能小于0")
|
||||
private Integer price;
|
||||
|
||||
/**
|
||||
* 改规格商品数量
|
||||
*/
|
||||
@TableField("stock")
|
||||
@NotNull(message = "库存不能为空")
|
||||
@Min(value = 0, message = "库存不能小于0")
|
||||
private Integer stock;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer buyCount;
|
||||
/**
|
||||
* 0:人民币购买; 1:积分兑换
|
||||
*/
|
||||
@TableField("type")
|
||||
// @NotBlank(message = "购买类型不能为空")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 所需积分数
|
||||
*/
|
||||
@TableField("integral")
|
||||
private Integer integral;
|
||||
|
||||
/**
|
||||
* 向推荐人返还积分数
|
||||
*/
|
||||
@TableField("return_integral")
|
||||
@Min(value = 0, message = "返还积分不能小于0")
|
||||
private Integer returnIntegral;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 规格对应商品图片
|
||||
*/
|
||||
@TableField("spec_image")
|
||||
private String specImage;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private String firstSpecImage;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String[] specImagesArray;
|
||||
|
||||
/**
|
||||
* 操作人id
|
||||
*/
|
||||
@TableField("oper_id")
|
||||
private Long operId;
|
||||
|
||||
|
||||
public List<Integer> getSpecValuesIds(){
|
||||
List<Integer> specValuesIds = new ArrayList<>();
|
||||
if(specValues!=null){
|
||||
if(!specValues.contains(",")){
|
||||
specValuesIds.add(Integer.parseInt(specValues));
|
||||
}else{
|
||||
String[] split = specValues.split(",");
|
||||
for (String s : split) {
|
||||
specValuesIds.add(Integer.parseInt(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
return specValuesIds;
|
||||
}
|
||||
|
||||
@TableField(exist = false)
|
||||
private String specStr;
|
||||
|
||||
@TableField("ps_version")
|
||||
private Long psVersion;
|
||||
|
||||
@TableField(exist = false)
|
||||
private int addressId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.zf.foodpurchase.fdsafe.entity;
|
||||
|
||||
import com.zf.foodpurchase.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class RepoRecord extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 申请日期
|
||||
*/
|
||||
private Date applyDate;
|
||||
|
||||
/**
|
||||
* 商户id
|
||||
*/
|
||||
private Integer supplierId;
|
||||
|
||||
/**
|
||||
* 类型id
|
||||
*/
|
||||
private Integer categoryId;
|
||||
|
||||
/**
|
||||
* 仓库id
|
||||
*/
|
||||
private Integer repoId;
|
||||
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Integer productId;
|
||||
|
||||
/**
|
||||
* 商品数量
|
||||
*/
|
||||
private Integer productNum;
|
||||
|
||||
/**
|
||||
* 商品总价,单位:分
|
||||
*/
|
||||
private BigDecimal totalCost;
|
||||
|
||||
/**
|
||||
* 出入库状态 1:入库, 0:出库
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
private String productName;
|
||||
|
||||
private Date startTime;
|
||||
|
||||
private Date endTime;
|
||||
|
||||
private String orderNo;
|
||||
|
||||
private Long schoolId;
|
||||
|
||||
private List<Long> deptIds;
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import lombok.experimental.Accessors;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -63,7 +64,6 @@ public class Repository implements Serializable {
|
||||
/**
|
||||
* 是否是默认仓库:0 否 1 是
|
||||
*/
|
||||
@NotNull(message = "是否是默认仓库不能为空")
|
||||
@TableField("default_repo")
|
||||
private String defaultRepo;
|
||||
|
||||
@@ -85,5 +85,17 @@ public class Repository implements Serializable {
|
||||
@TableField("oper_id")
|
||||
private Long operId;
|
||||
|
||||
@TableField
|
||||
@NotNull(message = "仓库管理员不能为空")
|
||||
private Long manager;
|
||||
|
||||
@TableField
|
||||
@NotNull(message = "仓库编号不能为空")
|
||||
private String repoNum;
|
||||
|
||||
@TableField
|
||||
@NotNull(message = "排序号不能为空")
|
||||
private Integer orderNum;
|
||||
@TableField(exist = false)
|
||||
private List<Long> deptIds;
|
||||
}
|
||||
|
||||
@@ -110,4 +110,10 @@ public class SchoolOrder implements Serializable {
|
||||
* 订单是否可参与结算:0 不可结算;1 可结算
|
||||
*/
|
||||
private Integer orderSettleStatus;
|
||||
|
||||
private String signPerson;
|
||||
|
||||
private Date signTime;
|
||||
|
||||
private String signImage;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SchoolOrderItem implements Serializable {
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Long foodProductId;
|
||||
private Integer foodProductId;
|
||||
|
||||
/**
|
||||
* 食材名称
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品规格类型表
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-16
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("spec_types")
|
||||
public class SpecTypes implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 规格类型
|
||||
*/
|
||||
@TableId(value = "spec_type", type = IdType.AUTO)
|
||||
private Integer specType;
|
||||
|
||||
/**
|
||||
* 所属商户id
|
||||
*/
|
||||
@TableField("merchant_id")
|
||||
private Long merchantId;
|
||||
|
||||
/**
|
||||
* 规格名称
|
||||
*/
|
||||
@TableField("spec_name")
|
||||
@NotNull(message = "规格名称不能为空")
|
||||
private String specName;
|
||||
|
||||
@TableField(exist = false)
|
||||
List<SpecValues> specValuesList;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 操作人id
|
||||
*/
|
||||
@TableField("oper_id")
|
||||
private Long operId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private boolean hasChildren;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 规格值表
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-16
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class SpecValues implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 规格类型id
|
||||
*/
|
||||
@TableField("spec_type")
|
||||
@NotNull(message = "规格类型不能为空")
|
||||
private Integer specType;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String specName;
|
||||
|
||||
/**
|
||||
* 所属商户id
|
||||
*/
|
||||
@TableField("merchant_id")
|
||||
private Long merchantId;
|
||||
|
||||
/**
|
||||
* 规格值
|
||||
*/
|
||||
@TableField("spec_value")
|
||||
@NotBlank(message = "规格值不能为空")
|
||||
private String specValue;
|
||||
|
||||
/**
|
||||
* 规格单位
|
||||
*/
|
||||
@TableField("spec_unit")
|
||||
private String specUnit;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 操作人
|
||||
*/
|
||||
@TableField("oper_id")
|
||||
private Long operId;
|
||||
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.zf.foodpurchase.fdsafe.mapper;
|
||||
|
||||
import com.zf.foodpurchase.fdsafe.entity.FoodProduct;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zf.foodpurchase.fdsafe.vo.FoodProductCKVO;
|
||||
import com.zf.foodpurchase.fdsafe.vo.FoodProductVO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -17,4 +18,6 @@ import java.util.List;
|
||||
public interface FoodProductMapper extends BaseMapper<FoodProduct> {
|
||||
|
||||
List<FoodProductVO> queryFoodProductVO(FoodProductVO foodProductVO);
|
||||
List<FoodProductCKVO> pageCKList(Integer repoId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.zf.foodpurchase.fdsafe.mapper;
|
||||
|
||||
import com.zf.foodpurchase.fdsafe.entity.FoodRepo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface FoodRepoMapper {
|
||||
|
||||
int insert(FoodRepo foodRepo);
|
||||
int update(FoodRepo foodRepo);
|
||||
FoodRepo selectByProductIdAndRepoId(@Param("productId") Long productId, @Param("repoId") Long repoId);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zf.foodpurchase.fdsafe.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zf.foodpurchase.fdsafe.entity.FoodSpec;
|
||||
import com.zf.foodpurchase.fdsafe.vo.FoodSpecVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2025-04-17
|
||||
*/
|
||||
public interface FoodSpecMapper extends BaseMapper<FoodSpec> {
|
||||
|
||||
List<FoodSpecVO> queryFoodSpecVO(FoodSpecVO foodSpecVO);
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zf.foodpurchase.fdsafe.entity.Products;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-11-16
|
||||
*/
|
||||
public interface ProductsMapper extends BaseMapper<Products>
|
||||
{
|
||||
/**
|
||||
* 查询商品
|
||||
*
|
||||
* @param productId 商品主键
|
||||
* @return 商品
|
||||
*/
|
||||
public Products selectProductsByProductId(Integer productId);
|
||||
|
||||
/**
|
||||
* 查询商品列表
|
||||
*
|
||||
* @param products 商品
|
||||
* @return 商品集合
|
||||
*/
|
||||
public List<Products> selectProductsList(Products products);
|
||||
|
||||
/**
|
||||
* 热销商品查询
|
||||
*
|
||||
* @param products 商品
|
||||
* @return 商品集合
|
||||
*/
|
||||
public List<Products> selectHotProducts(Products products);
|
||||
|
||||
/**
|
||||
* 推荐商品
|
||||
*
|
||||
* @param products 商品
|
||||
* @return 商品集合
|
||||
*/
|
||||
public List<Products> selectRecommendProducts(Products products);
|
||||
|
||||
/**
|
||||
* 新品上架
|
||||
*
|
||||
* @param products 商品
|
||||
* @return 商品集合
|
||||
*/
|
||||
public List<Products> selectNewProductsList(Products products);
|
||||
|
||||
/**
|
||||
* 查询商品列表,按销量查询
|
||||
*
|
||||
* @param products 商品
|
||||
* @return 商品集合
|
||||
*/
|
||||
public List<Products> selectSailCountProducts(Products products);
|
||||
|
||||
/**
|
||||
* 新增商品
|
||||
*
|
||||
* @param products 商品
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertProducts(Products products);
|
||||
|
||||
/**
|
||||
* 修改商品
|
||||
*
|
||||
* @param products 商品
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateProducts(Products products);
|
||||
|
||||
/**
|
||||
* 删除商品
|
||||
*
|
||||
* @param productId 商品主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteProductsByProductId(Integer productId);
|
||||
|
||||
/**
|
||||
* 批量删除商品
|
||||
*
|
||||
* @param productIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteProductsByProductIds(Integer[] productIds);
|
||||
|
||||
int deleteProductsLogicByProductIds(Integer[] productIds);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zf.foodpurchase.fdsafe.entity.ProductsSpec;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品价格表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-18
|
||||
*/
|
||||
public interface ProductsSpecMapper extends BaseMapper<ProductsSpec> {
|
||||
|
||||
int updateProductsSpec(ProductsSpec productsSpec);
|
||||
|
||||
Map<String,Long> selectMinOne(Integer productId);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.zf.foodpurchase.fdsafe.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zf.foodpurchase.fdsafe.entity.RepoRecord;
|
||||
import com.zf.foodpurchase.fdsafe.vo.RepoRecordVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface RepoRecordMapper extends BaseMapper<RepoRecord> {
|
||||
|
||||
public int insertRepoRecord(RepoRecord repoRecord);
|
||||
|
||||
public RepoRecordVO selectRepoRecordByRepoRecordId(@Param("repoRecordId") Long repoRecordId);
|
||||
|
||||
public List<RepoRecordVO> selectRepoRecordList(@Param("productName") String productName, @Param("categoryId") Integer categoryId, @Param("repoId") Integer repoId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
}
|
||||
@@ -15,5 +15,5 @@ import java.util.List;
|
||||
*/
|
||||
public interface RepositoryMapper extends BaseMapper<Repository> {
|
||||
|
||||
List<Repository> joinQueryList(Repository quryRepository);
|
||||
List<Repository> queryRepoList(Repository queryRepository);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.zf.foodpurchase.fdsafe.mapper;
|
||||
|
||||
import com.zf.foodpurchase.fdsafe.entity.SchoolOrderItem;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zf.foodpurchase.fdsafe.vo.ProductCountVO;
|
||||
import com.zf.foodpurchase.fdsafe.vo.SchoolOrderItemVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,4 +19,5 @@ import java.util.List;
|
||||
public interface SchoolOrderItemMapper extends BaseMapper<SchoolOrderItem> {
|
||||
|
||||
List<SchoolOrderItemVO> querySchoolOrderItemVO(SchoolOrderItemVO schoolOrderItemVO);
|
||||
|
||||
}
|
||||
|
||||
@@ -16,5 +16,9 @@ import java.util.List;
|
||||
*/
|
||||
public interface SchoolOrderMapper extends BaseMapper<SchoolOrder> {
|
||||
|
||||
List<SchoolOrderVO> querySupplierOrderVO(SchoolOrderVO schoolOrderVO);
|
||||
|
||||
List<SchoolOrderVO> querySchoolOrderVO(SchoolOrderVO schoolOrderVO);
|
||||
|
||||
int signOrder(SchoolOrderVO schoolOrderVO);
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SpecTypes;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品规格类型表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-16
|
||||
*/
|
||||
public interface SpecTypesMapper extends BaseMapper<SpecTypes> {
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SpecValues;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 规格值表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-16
|
||||
*/
|
||||
public interface SpecValuesMapper extends BaseMapper<SpecValues> {
|
||||
|
||||
List<SpecValues> queryList(SpecValues specValues);
|
||||
|
||||
List<SpecValues> queryByIds(List<Integer> specValuesIds);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.zf.foodpurchase.fdsafe.service;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.fdsafe.entity.FoodProduct;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zf.foodpurchase.fdsafe.vo.FoodProductCKVO;
|
||||
import com.zf.foodpurchase.fdsafe.vo.FoodProductVO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -24,4 +25,6 @@ public interface IFoodProductService extends IService<FoodProduct> {
|
||||
AjaxResult supplierUpdate(FoodProductVO foodProductVO);
|
||||
|
||||
AjaxResult eduCheck(FoodProductVO foodProductVO);
|
||||
|
||||
List<FoodProductCKVO> pageCKList(Integer repoId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.zf.foodpurchase.fdsafe.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.fdsafe.entity.FoodSpec;
|
||||
import com.zf.foodpurchase.fdsafe.vo.FoodSpecVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2025-04-17
|
||||
*/
|
||||
public interface IFoodSpecService extends IService<FoodSpec> {
|
||||
|
||||
List<FoodSpecVO> queryFoodSpecVO(FoodSpecVO foodSpecVO);
|
||||
|
||||
AjaxResult saveVO(FoodSpecVO foodSpecVO);
|
||||
|
||||
AjaxResult updateVO(FoodSpecVO foodSpecVO);
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.fdsafe.entity.Products;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-11-16
|
||||
*/
|
||||
public interface IProductsService extends IService<Products>
|
||||
{
|
||||
/**
|
||||
* 查询商品
|
||||
*
|
||||
* @param productId 商品主键
|
||||
* @return 商品
|
||||
*/
|
||||
public Products selectProductsByProductId(Integer productId);
|
||||
|
||||
/**
|
||||
* 查询商品列表
|
||||
*
|
||||
* @param products 商品
|
||||
* @return 商品集合
|
||||
*/
|
||||
public List<Products> selectProductsList(Products products);
|
||||
|
||||
/**
|
||||
* 新增商品
|
||||
*
|
||||
* @param products 商品
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertProducts(Products products);
|
||||
|
||||
/**
|
||||
* 直接插入不做任何处理
|
||||
*
|
||||
* @param products 商品
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertProductsDirect(Products products);
|
||||
|
||||
/**
|
||||
* 新增商品带单品
|
||||
*
|
||||
* @param products 商品
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertProductsAndSpec(Products products);
|
||||
/**
|
||||
* 修改商品
|
||||
*
|
||||
* @param products 商品
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateProducts(Products products);
|
||||
|
||||
/**
|
||||
* 多规格变动更新商品
|
||||
* @param products
|
||||
* @return
|
||||
*/
|
||||
public int updateProductsAndSpec(Products products);
|
||||
|
||||
/**
|
||||
* 通用更新,多规格变单规格,单规格变多规格
|
||||
* @param products
|
||||
* @return
|
||||
*/
|
||||
public int commonUpdateProducts(Products products);
|
||||
|
||||
|
||||
/**
|
||||
* 系统内部调用,不校验商品直接修改
|
||||
* @param products
|
||||
* @return
|
||||
*/
|
||||
public int updateProductsDirect(Products products);
|
||||
|
||||
/**
|
||||
* 批量删除商品
|
||||
*
|
||||
* @param productIds 需要删除的商品主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteProductsByProductIds(Integer[] productIds ,boolean isAllowDeleteSpecs);
|
||||
|
||||
/**
|
||||
* 删除商品信息
|
||||
*
|
||||
* @param productId 商品主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteProductsByProductId(Integer productId,boolean isAllowDeleteSpecs);
|
||||
|
||||
int deleteProductsLogicByProductIds(Integer[] productIds);
|
||||
|
||||
List<Products> selectHotProducts(Products products);
|
||||
|
||||
List<Products> selectRecommendProducts(Products products);
|
||||
|
||||
List<Products> selectNewProductsList(Products products);
|
||||
|
||||
List<Products> selectSailCountProducts(Products products);
|
||||
|
||||
AjaxResult getDetails(Integer productId);
|
||||
|
||||
public Products preDealProducts(Products products);
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.common.core.page.TableDataInfo;
|
||||
import com.zf.foodpurchase.fdsafe.entity.Products;
|
||||
import com.zf.foodpurchase.fdsafe.entity.ProductsSpec;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品价格表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-18
|
||||
*/
|
||||
public interface IProductsSpecService extends IService<ProductsSpec> {
|
||||
|
||||
TableDataInfo queryList(ProductsSpec productsSpec);
|
||||
|
||||
|
||||
Integer queryExists(ProductsSpec productsSpec);
|
||||
|
||||
|
||||
AjaxResult removeProductsByIds(List<Integer> list);
|
||||
|
||||
List<ProductsSpec> listWithProductSpecValues(LambdaQueryWrapper<ProductsSpec> queryWrapper);
|
||||
|
||||
|
||||
ProductsSpec preDealSpecValues(ProductsSpec spec);
|
||||
|
||||
public ProductsSpec preDealProductsSpec(Products products, ProductsSpec productsSpec);
|
||||
|
||||
boolean addWithSpec(Products products);
|
||||
|
||||
public Products preDealMultisSpecProducts(Products products);
|
||||
|
||||
boolean modifyProductsSepcList(List<ProductsSpec> productsSpecList);
|
||||
|
||||
int commonUpdateProducts(Products products);
|
||||
|
||||
boolean updateSingleProducts(Products products);
|
||||
|
||||
boolean updateMulSpecProducts(Products products);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.zf.foodpurchase.fdsafe.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.fdsafe.entity.InRepoVO;
|
||||
import com.zf.foodpurchase.fdsafe.entity.RepoRecord;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SchoolOrderItem;
|
||||
import com.zf.foodpurchase.fdsafe.vo.FoodProductCKVO;
|
||||
import com.zf.foodpurchase.fdsafe.vo.RepoRecordVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IRepoRecordService extends IService<RepoRecord> {
|
||||
|
||||
AjaxResult inRepo(List<InRepoVO> inRepoVOs);
|
||||
|
||||
AjaxResult outRepo(List<FoodProductCKVO> foodProductCKVOs);
|
||||
|
||||
RepoRecordVO selectRepoRecordByRepoRecordId(Long repoRecordId);
|
||||
|
||||
List<RepoRecordVO> selectRepoRecordList(RepoRecord repoRecord);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.zf.foodpurchase.fdsafe.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.fdsafe.entity.Repository;
|
||||
import com.zf.foodpurchase.fdsafe.vo.ProductCountVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -16,7 +17,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface IRepositoryService extends IService<Repository> {
|
||||
|
||||
List<Repository> joinQueryList(Repository quryRepository);
|
||||
List<Repository> queryRepoList(Repository quryRepository);
|
||||
|
||||
AjaxResult saveRepo(Repository repository);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.zf.foodpurchase.fdsafe.service;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SchoolOrder;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SchoolOrderItem;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zf.foodpurchase.fdsafe.vo.ProductCountVO;
|
||||
import com.zf.foodpurchase.fdsafe.vo.SchoolOrderItemVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -18,6 +18,8 @@ import java.util.List;
|
||||
*/
|
||||
public interface ISchoolOrderService extends IService<SchoolOrder> {
|
||||
|
||||
List<SchoolOrderVO> querySupplierOrderVO(SchoolOrderVO schoolOrderVO);
|
||||
|
||||
List<SchoolOrderVO> querySchoolOrderVO(SchoolOrderVO schoolOrderVO);
|
||||
|
||||
AjaxResult submitOrder(@Valid SchoolSubmitOrderVO submitOrderVO);
|
||||
@@ -31,4 +33,6 @@ public interface ISchoolOrderService extends IService<SchoolOrder> {
|
||||
boolean updateOrderStatus(SchoolOrder schoolOrder);
|
||||
|
||||
public boolean updateOrderSettleStatus(List<String> orderNos, Integer orderSettleStatus);
|
||||
|
||||
AjaxResult signOrder(SchoolOrderVO schoolOrderVO);
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SpecTypes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品规格类型表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-16
|
||||
*/
|
||||
public interface ISpecTypesService extends IService<SpecTypes> {
|
||||
|
||||
|
||||
AjaxResult saveTypes(SpecTypes specTypes);
|
||||
|
||||
AjaxResult removeSpecTypes(List<Long> list,Long merchantId);
|
||||
|
||||
AjaxResult updateType(SpecTypes specTypes, boolean admin);
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SpecValues;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 规格值表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-16
|
||||
*/
|
||||
public interface ISpecValuesService extends IService<SpecValues> {
|
||||
|
||||
List<SpecValues> queryList(SpecValues specValues);
|
||||
|
||||
|
||||
List<SpecValues> queryByIds(List<Integer> specValuesIds);
|
||||
|
||||
AjaxResult updateSpecValues(SpecValues specValues,boolean isAdmin);
|
||||
|
||||
AjaxResult removeValues(List<Long> idList, Long merchantId);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.zf.foodpurchase.fdsafe.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zf.foodpurchase.common.constant.FoodStatusConstants;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.common.core.domain.entity.SysUser;
|
||||
import com.zf.foodpurchase.common.utils.bean.BeanUtils;
|
||||
import com.zf.foodpurchase.fdsafe.entity.Food;
|
||||
import com.zf.foodpurchase.fdsafe.entity.FoodProduct;
|
||||
@@ -10,7 +11,9 @@ import com.zf.foodpurchase.fdsafe.mapper.FoodMapper;
|
||||
import com.zf.foodpurchase.fdsafe.mapper.FoodProductMapper;
|
||||
import com.zf.foodpurchase.fdsafe.service.IFoodProductService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zf.foodpurchase.fdsafe.vo.FoodProductCKVO;
|
||||
import com.zf.foodpurchase.fdsafe.vo.FoodProductVO;
|
||||
import com.zf.foodpurchase.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
@@ -31,7 +34,8 @@ import java.util.List;
|
||||
public class FoodProductServiceImpl extends ServiceImpl<FoodProductMapper, FoodProduct> implements IFoodProductService {
|
||||
@Autowired
|
||||
private FoodMapper foodMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -50,7 +54,7 @@ public class FoodProductServiceImpl extends ServiceImpl<FoodProductMapper, FoodP
|
||||
public AjaxResult supplierAdd(FoodProductVO foodProductVO) {
|
||||
FoodProduct foodProduct = dealSupplierProductAdd(foodProductVO);
|
||||
boolean save = save(foodProduct);
|
||||
return save ? AjaxResult.success("商品发布成功,等待审核") : AjaxResult.error("商品发布失败");
|
||||
return save ? AjaxResult.success("商品发布成功") : AjaxResult.error("商品发布失败");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,9 +69,9 @@ public class FoodProductServiceImpl extends ServiceImpl<FoodProductMapper, FoodP
|
||||
if (old == null) {
|
||||
return AjaxResult.error("商品不存在,无法修改");
|
||||
}
|
||||
FoodProduct foodProduct = dealSupplierProductUpdate(foodProductVO);
|
||||
//FoodProduct foodProduct = dealSupplierProductUpdate(foodProductVO);
|
||||
// 判断商品审核状态:审核不通过,修改信息重新发起审核;审核通过修改价格重新发起审核
|
||||
boolean isCheck = false;
|
||||
/*boolean isCheck = false;
|
||||
// if (old.getCheckStatus() == 2) {
|
||||
if (FoodStatusConstants.PRODUCT_CHECK_NO_PASS.equals(old.getCheckStatus())) {
|
||||
// 待审核状态
|
||||
@@ -78,11 +82,12 @@ public class FoodProductServiceImpl extends ServiceImpl<FoodProductMapper, FoodP
|
||||
else if (FoodStatusConstants.PRODUCT_CHECK_NO_PASS.equals(old.getCheckStatus()) && old.getPrice().compareTo(foodProductVO.getPrice()) != 0) {
|
||||
foodProduct.setCheckStatus(FoodStatusConstants.PRODUCT_WAIT_CHECK);
|
||||
isCheck = true;
|
||||
}
|
||||
|
||||
}*/
|
||||
FoodProduct foodProduct = new FoodProduct();
|
||||
BeanUtils.copyProperties(foodProductVO, foodProduct);
|
||||
boolean update = updateById(foodProduct);
|
||||
String msg = "商品修改成功"+(isCheck?",并重新发起审核":"");
|
||||
return update ? AjaxResult.success(msg) : AjaxResult.error("商品修改失败");
|
||||
//String msg = "商品修改成功"+(isCheck?",并重新发起审核":"");
|
||||
return update ? AjaxResult.success("商品修改成功") : AjaxResult.error("商品修改失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,6 +97,12 @@ public class FoodProductServiceImpl extends ServiceImpl<FoodProductMapper, FoodP
|
||||
return update ? AjaxResult.success("商品审核成功") : AjaxResult.error("商品审核失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FoodProductCKVO> pageCKList(Integer repoId) {
|
||||
List<FoodProductCKVO> list = baseMapper.pageCKList(repoId);
|
||||
return list;
|
||||
}
|
||||
|
||||
private FoodProduct dealSupplierProductAdd(FoodProductVO foodProductVO) {
|
||||
if (foodProductVO == null) {
|
||||
return null;
|
||||
@@ -102,8 +113,12 @@ public class FoodProductServiceImpl extends ServiceImpl<FoodProductMapper, FoodP
|
||||
if(food == null){
|
||||
throw new RuntimeException("商品关联食材不存在,无法添加");
|
||||
}
|
||||
SysUser user = sysUserService.getUser();
|
||||
FoodProduct foodProduct = new FoodProduct();
|
||||
BeanUtils.copyProperties(foodProductVO, foodProduct);
|
||||
if(!user.isAdmin()){
|
||||
foodProduct.setSupplierId(user.getSchoolId());
|
||||
}
|
||||
foodProduct.setEduId(food.getEduId());
|
||||
// 审核项置空.
|
||||
foodProduct.setCheckStatus(FoodStatusConstants.PRODUCT_WAIT_CHECK);
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.zf.foodpurchase.fdsafe.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.common.utils.bean.BeanUtils;
|
||||
import com.zf.foodpurchase.fdsafe.entity.FoodSpec;
|
||||
import com.zf.foodpurchase.fdsafe.mapper.FoodSpecMapper;
|
||||
import com.zf.foodpurchase.fdsafe.service.IFoodSpecService;
|
||||
import com.zf.foodpurchase.fdsafe.vo.FoodSpecVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2025-04-17
|
||||
*/
|
||||
@Service
|
||||
public class FoodSpecServiceImpl extends ServiceImpl<FoodSpecMapper, FoodSpec> implements IFoodSpecService {
|
||||
|
||||
@Override
|
||||
public List<FoodSpecVO> queryFoodSpecVO(FoodSpecVO foodSpecVO) {
|
||||
List<FoodSpecVO> list = baseMapper.queryFoodSpecVO(foodSpecVO);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult saveVO(FoodSpecVO foodSpecVO) {
|
||||
FoodSpec foodSpec=new FoodSpec();
|
||||
BeanUtils.copyProperties(foodSpecVO, foodSpec);
|
||||
if(!uniqueSpecCheck(foodSpec)){
|
||||
return AjaxResult.error("规格/单位已存在,不可重复添加");
|
||||
}
|
||||
boolean result = save(foodSpec);
|
||||
return result ? AjaxResult.success("添加成功") : AjaxResult.error("添加失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult updateVO(FoodSpecVO foodSpecVO) {
|
||||
FoodSpec foodSpec=new FoodSpec();
|
||||
BeanUtils.copyProperties(foodSpecVO, foodSpec);
|
||||
if(!uniqueSpecCheck(foodSpec)){
|
||||
return AjaxResult.error("规格/单位已存在,不可修改为该规格/单位");
|
||||
}
|
||||
boolean result = updateById(foodSpec);
|
||||
return result ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败");
|
||||
}
|
||||
|
||||
private boolean uniqueSpecCheck(FoodSpec foodSpec){
|
||||
LambdaQueryWrapper<FoodSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(FoodSpec::getSpecLabel, foodSpec.getSpecLabel());
|
||||
if(foodSpec.getSpecId()!=null){
|
||||
queryWrapper.ne(FoodSpec::getSpecId, foodSpec.getSpecId());
|
||||
}
|
||||
long count = count(queryWrapper);
|
||||
return count == 0;
|
||||
}
|
||||
}
|
||||
@@ -1,580 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zf.foodpurchase.common.constant.Constants;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.common.exception.ServiceException;
|
||||
import com.zf.foodpurchase.common.utils.StringUtils;
|
||||
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.mapper.ProductsMapper;
|
||||
import com.zf.foodpurchase.fdsafe.mapper.ProductsSpecMapper;
|
||||
import com.zf.foodpurchase.fdsafe.service.IProductsService;
|
||||
import com.zf.foodpurchase.fdsafe.service.ISpecValuesService;
|
||||
import com.zf.foodpurchase.fdsafe.utils.ImagesPrefixUtil;
|
||||
import com.zf.foodpurchase.fdsafe.vo.ProductsSpecVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 商品Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-11-16
|
||||
*/
|
||||
@Service
|
||||
public class ProductsServiceImpl extends ServiceImpl<ProductsMapper, Products> implements IProductsService {
|
||||
@Autowired
|
||||
private ProductsMapper productsMapper;
|
||||
|
||||
@Autowired
|
||||
private ProductsSpecMapper productsSpecMapper;
|
||||
|
||||
@Autowired
|
||||
private ISpecValuesService specValuesService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询商品
|
||||
*
|
||||
* @param productId 商品主键
|
||||
* @return 商品
|
||||
*/
|
||||
@Override
|
||||
public Products selectProductsByProductId(Integer productId) {
|
||||
return productsMapper.selectProductsByProductId(productId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商品列表
|
||||
*
|
||||
* @param products 商品
|
||||
* @return 商品
|
||||
*/
|
||||
@Override
|
||||
public List<Products> selectProductsList(Products products) {
|
||||
return productsMapper.selectProductsList(products);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增商品
|
||||
*
|
||||
* @param products 商品
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertProducts(Products products) {
|
||||
products = preDealProducts(products);
|
||||
return productsMapper.insertProducts(products);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增商品-直接插入不做任何校验处理
|
||||
*
|
||||
* @param products 商品
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertProductsDirect(Products products) {
|
||||
return productsMapper.insertProducts(products);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增商品
|
||||
*
|
||||
* @param products 多规格带一个单规格
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertProductsAndSpec(Products products) {
|
||||
|
||||
products = preDealProductsAndSpec(products);
|
||||
return productsMapper.insertProducts(products);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商品:单品变规格商品库存清零,添加具体规格商品自动计算.
|
||||
* 多规格商品变单规格商品,自动清除规格信息
|
||||
*
|
||||
* @param products 商品
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int updateProducts(Products products) {
|
||||
String msg = null;
|
||||
// 需要校验是否修改商品的库存信息
|
||||
Products oldProducts = selectProductsByProductId(products.getProductId());
|
||||
|
||||
// 不允许单规格变多规格,规格类型不发生变动,其实都可以的。规格类型变动了呢?
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs()) && Constants.SINGLE_SPEC.equals(oldProducts.getIsSpecs())) {
|
||||
// products.setTotalStock(0);
|
||||
throw new ServiceException("单品无法修改为多规格");
|
||||
}
|
||||
// 商品为多规格商品,且修改了库存数目
|
||||
if (oldProducts.getIsSpecs().equals(Constants.MULTI_SPEC) && !oldProducts.getTotalStock().equals(products.getTotalStock())) {
|
||||
throw new ServiceException("多规格商品不允许直接修改商品库存,请修改具体规格下的商品库存");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 多规格商品变单规格商品,清除多规格商品
|
||||
if (Constants.SINGLE_SPEC.equals(products.getIsSpecs()) && Constants.MULTI_SPEC.equals(oldProducts.getIsSpecs())) {
|
||||
LambdaQueryWrapper<ProductsSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ProductsSpec::getProductId, products.getProductId());
|
||||
productsSpecMapper.delete(queryWrapper);
|
||||
}
|
||||
|
||||
// 商品的购买类型发生变动
|
||||
// 商品购买类型发生变动,多规格需要提示信息
|
||||
if (!oldProducts.getType().equals(products.getType())) {
|
||||
// 价格与积分不兼容
|
||||
|
||||
|
||||
// if(Constants.MULTI_SPEC.equals(products.getIsSpecs())){
|
||||
// // 规格变动默认进行下架处理,因为价格和积分不兼容
|
||||
// products.setStatus(Constants.GOODS_STATUS_DOWN);
|
||||
// msg = "多规格商品类型变更,默认下架,请检查商品的规格信息";
|
||||
// throw new ServiceException("多规格商品不允许修改购买类型");
|
||||
// }
|
||||
// LambdaQueryWrapper<ProductsSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// queryWrapper.eq(ProductsSpec::getProductId, products.getProductId());
|
||||
// List<ProductsSpec> productsSpecList = productsSpecMapper.selectList(queryWrapper);
|
||||
// for (ProductsSpec productsSpec : productsSpecList) {
|
||||
// productsSpec.setType(products.getType());
|
||||
// productsSpecMapper.updateProductsSpec(productsSpec);
|
||||
// }
|
||||
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs())) {
|
||||
throw new ServiceException("多规格商品不允许修改购买类型");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return productsMapper.updateProducts(products);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多规格信息变动更新信息
|
||||
* @param products
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int updateProductsAndSpec(Products products) {
|
||||
String msg = null;
|
||||
// 需要校验是否修改商品的库存信息
|
||||
Products oldProducts = selectProductsByProductId(products.getProductId());
|
||||
|
||||
|
||||
// 暂时不允许单规格变为多规格
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs()) && Constants.SINGLE_SPEC.equals(oldProducts.getIsSpecs())) {
|
||||
// products.setTotalStock(0);
|
||||
throw new ServiceException("单品无法修改为多规格");
|
||||
// 单变多:
|
||||
// 更新products内容。
|
||||
|
||||
// 插入productSpec数据
|
||||
}
|
||||
|
||||
// 后面是多规格商品的处理。
|
||||
// 商品为多规格商品,且修改了库存数目
|
||||
if (oldProducts.getIsSpecs().equals(Constants.MULTI_SPEC) && !oldProducts.getTotalStock().equals(products.getTotalStock())) {
|
||||
throw new ServiceException("多规格商品不允许直接修改商品库存,请修改具体规格下的商品库存");
|
||||
}
|
||||
|
||||
// 多规格商品变单规格商品,清除多规格商品
|
||||
if (Constants.SINGLE_SPEC.equals(products.getIsSpecs()) && Constants.MULTI_SPEC.equals(oldProducts.getIsSpecs())) {
|
||||
LambdaQueryWrapper<ProductsSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ProductsSpec::getProductId, products.getProductId());
|
||||
productsSpecMapper.delete(queryWrapper);
|
||||
}
|
||||
|
||||
// 商品的购买类型发生变动
|
||||
// 商品购买类型发生变动,多规格需要提示信息
|
||||
if (!oldProducts.getType().equals(products.getType())) {
|
||||
// 价格与积分不兼容
|
||||
|
||||
|
||||
// if(Constants.MULTI_SPEC.equals(products.getIsSpecs())){
|
||||
// // 规格变动默认进行下架处理,因为价格和积分不兼容
|
||||
// products.setStatus(Constants.GOODS_STATUS_DOWN);
|
||||
// msg = "多规格商品类型变更,默认下架,请检查商品的规格信息";
|
||||
// throw new ServiceException("多规格商品不允许修改购买类型");
|
||||
// }
|
||||
// LambdaQueryWrapper<ProductsSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// queryWrapper.eq(ProductsSpec::getProductId, products.getProductId());
|
||||
// List<ProductsSpec> productsSpecList = productsSpecMapper.selectList(queryWrapper);
|
||||
// for (ProductsSpec productsSpec : productsSpecList) {
|
||||
// productsSpec.setType(products.getType());
|
||||
// productsSpecMapper.updateProductsSpec(productsSpec);
|
||||
// }
|
||||
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs())) {
|
||||
throw new ServiceException("多规格商品不允许修改购买类型");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// 求出最小值,确保每次更新多规格商品都能都能取到正确值
|
||||
Map<String, Integer> stringIntegerMap = selectMinPriceAndIntegralByProductId(products.getProductId());
|
||||
products.setBasePrice(stringIntegerMap.get("price") == null ? 0 :stringIntegerMap.get("price"));
|
||||
products.setBaseIntegral(stringIntegerMap.get("integral") == null ? 0 : stringIntegerMap.get("integral"));
|
||||
|
||||
products = preDealProductsAndSpec(products);
|
||||
return productsMapper.updateProducts(products);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 来源于ProductsController商品更新
|
||||
* 更新商品信息,保存规格信息
|
||||
* @param products
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int commonUpdateProducts(Products products) {
|
||||
int count=0;
|
||||
int specSize =0;
|
||||
// 需要校验是否修改商品的库存信息
|
||||
Products oldProducts = selectProductsByProductId(products.getProductId());
|
||||
if(oldProducts==null){
|
||||
throw new ServiceException("商品不存在");
|
||||
}
|
||||
|
||||
// 暂时不允许单规格变为多规格
|
||||
// 单独规格变多规格
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs()) && Constants.SINGLE_SPEC.equals(oldProducts.getIsSpecs())) {
|
||||
// products.setTotalStock(0);
|
||||
// throw new ServiceException("单品无法修改为多规格");
|
||||
// 单变多
|
||||
// 更新products信息,products的价格,积分,返还积分都要重新计算
|
||||
int stock = 0;
|
||||
int minPrice = -1;
|
||||
int minIntegral = -1;
|
||||
// 多规格商品的库存添加对应规格商品时,自动累加
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs())) {
|
||||
List<ProductsSpec> productsSpecList = products.getProductsSpecList();
|
||||
if (productsSpecList == null || productsSpecList.size() == 0) {
|
||||
throw new ServiceException("多规格商品至少设置一种规格");
|
||||
}
|
||||
specSize = productsSpecList.size();
|
||||
for (ProductsSpec productsSpec : productsSpecList) {
|
||||
if (productsSpec.getStock() == null || productsSpec.getStock() < 0) {
|
||||
throw new ServiceException("商品库存不能为空且不能小于0");
|
||||
}
|
||||
minPrice = minPrice == -1 ? productsSpec.getPrice() : Math.min(minPrice, productsSpec.getPrice());
|
||||
minIntegral = minIntegral == -1 ? productsSpec.getIntegral() : Math.min(minIntegral, productsSpec.getIntegral());
|
||||
stock += productsSpec.getStock();
|
||||
}
|
||||
|
||||
// 校验数量是否一致
|
||||
// if(products.getTotalStock() != stock){
|
||||
// throw new ServiceException("商品库存与各规格库存之和不一致");
|
||||
// }
|
||||
products.setTotalStock(stock);
|
||||
products.setBasePrice(minPrice);
|
||||
products.setBaseIntegral(minIntegral);
|
||||
|
||||
}
|
||||
products = preDealProductsAndSpec(products);
|
||||
if (products != null) {
|
||||
List<ProductsSpec> productsSpecList = products.getProductsSpecList();
|
||||
|
||||
// 保存规格信息
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs()) && !CollectionUtils.isEmpty(productsSpecList)) {
|
||||
for(ProductsSpec productsSpec : productsSpecList){
|
||||
productsSpec.setProductId(products.getProductId());
|
||||
productsSpec.setType(products.getType());
|
||||
if(StringUtils.isBlank(productsSpec.getSpecImage())){
|
||||
productsSpec.setSpecImage(null);
|
||||
}
|
||||
count += productsSpecMapper.insert(productsSpec);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新products
|
||||
products = preDealProductsAndSpec(products);
|
||||
count += productsMapper.updateProducts(products);
|
||||
if(count!=specSize+1){
|
||||
throw new ServiceException("商品信息更新失败");
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
// 商品为多规格商品,且修改了库存数目
|
||||
if (oldProducts.getIsSpecs().equals(Constants.MULTI_SPEC) && !oldProducts.getTotalStock().equals(products.getTotalStock())) {
|
||||
throw new ServiceException("多规格商品不允许直接修改商品库存,请修改具体规格下的商品库存");
|
||||
}
|
||||
|
||||
|
||||
// 多规格商品变单规格商品,清除多规格商品
|
||||
if (Constants.SINGLE_SPEC.equals(products.getIsSpecs()) && Constants.MULTI_SPEC.equals(oldProducts.getIsSpecs())) {
|
||||
LambdaQueryWrapper<ProductsSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ProductsSpec::getProductId, products.getProductId());
|
||||
productsSpecMapper.delete(queryWrapper);
|
||||
}
|
||||
|
||||
// 商品的购买类型发生变动
|
||||
// 商品购买类型发生变动,多规格需要提示信息
|
||||
if (!oldProducts.getType().equals(products.getType())) {
|
||||
// 价格与积分不兼容
|
||||
|
||||
|
||||
// if(Constants.MULTI_SPEC.equals(products.getIsSpecs())){
|
||||
// // 规格变动默认进行下架处理,因为价格和积分不兼容
|
||||
// products.setStatus(Constants.GOODS_STATUS_DOWN);
|
||||
// msg = "多规格商品类型变更,默认下架,请检查商品的规格信息";
|
||||
// throw new ServiceException("多规格商品不允许修改购买类型");
|
||||
// }
|
||||
// LambdaQueryWrapper<ProductsSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// queryWrapper.eq(ProductsSpec::getProductId, products.getProductId());
|
||||
// List<ProductsSpec> productsSpecList = productsSpecMapper.selectList(queryWrapper);
|
||||
// for (ProductsSpec productsSpec : productsSpecList) {
|
||||
// productsSpec.setType(products.getType());
|
||||
// productsSpecMapper.updateProductsSpec(productsSpec);
|
||||
// }
|
||||
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs())) {
|
||||
throw new ServiceException("多规格商品不允许修改购买类型");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// 求出最小值
|
||||
Map<String, Integer> stringIntegerMap = selectMinPriceAndIntegralByProductId(products.getProductId());
|
||||
products.setBasePrice(stringIntegerMap.get("price") == null ? 0 :stringIntegerMap.get("price"));
|
||||
products.setBaseIntegral(stringIntegerMap.get("integral") == null ? 0 : stringIntegerMap.get("integral"));
|
||||
|
||||
products = preDealProductsAndSpec(products);
|
||||
return productsMapper.updateProducts(products);
|
||||
}
|
||||
|
||||
public Map<String, Integer> selectMinPriceAndIntegralByProductId(Integer productId) {
|
||||
LambdaQueryWrapper<ProductsSpec> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.eq(ProductsSpec::getProductId, productId);
|
||||
|
||||
// 查询 price 的最小值
|
||||
Map<String,Long> map=productsSpecMapper.selectMinOne(productId);
|
||||
Map<String,Integer> map1=new HashMap<>();
|
||||
map1.put("price",map.get("price")==null?0:map.get("price").intValue());
|
||||
map1.put("integral",map.get("integral")==null?0:map.get("integral").intValue());
|
||||
return map1;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public int updateProductsDirect(Products products) {
|
||||
return productsMapper.updateProducts(products);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除商品
|
||||
*
|
||||
* @param productIds 需要删除的商品主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int deleteProductsByProductIds(Integer[] productIds, boolean isAllowDeleteSpecs) {
|
||||
if (!isAllowDeleteSpecs) {
|
||||
// 不允许删除商品规格信息
|
||||
for (Integer productId : productIds) {
|
||||
Products products = selectProductsByProductId(productId);
|
||||
List<ProductsSpec> productsSpecList = productsSpecMapper.selectList(new LambdaQueryWrapper<ProductsSpec>().eq(ProductsSpec::getProductId, products.getProductId()));
|
||||
if (products.getIsSpecs().equals(Constants.MULTI_SPEC) && !productsSpecList.isEmpty()) {
|
||||
// throw new ServiceException("待删除商品中存在多规格商品,需要先删除所有商品的规格商品");
|
||||
LambdaQueryWrapper<ProductsSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ProductsSpec::getProductId, products.getProductId());
|
||||
productsSpecMapper.delete(queryWrapper);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LambdaQueryWrapper<ProductsSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
List<Integer> idList = Arrays.asList(productIds);
|
||||
queryWrapper.in(ProductsSpec::getProductId, idList);
|
||||
productsSpecMapper.delete(queryWrapper);
|
||||
}
|
||||
return productsMapper.deleteProductsByProductIds(productIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商品信息
|
||||
*
|
||||
* @param productId 商品主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int deleteProductsByProductId(Integer productId, boolean isAllowDeleteSpecs) {
|
||||
if (!isAllowDeleteSpecs) {
|
||||
Products products = selectProductsByProductId(productId);
|
||||
if (products.getIsSpecs().equals(Constants.MULTI_SPEC)) {
|
||||
throw new ServiceException("该商品为多规格商品,请先删除所有规格的商品,再删除当前商品");
|
||||
}
|
||||
} else {
|
||||
LambdaQueryWrapper<ProductsSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ProductsSpec::getProductId, productId);
|
||||
productsSpecMapper.delete(queryWrapper);
|
||||
}
|
||||
return productsMapper.deleteProductsByProductId(productId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteProductsLogicByProductIds(Integer[] productIds) {
|
||||
return productsMapper.deleteProductsLogicByProductIds(productIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Products> selectHotProducts(Products products) {
|
||||
return productsMapper.selectHotProducts(products);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Products> selectRecommendProducts(Products products) {
|
||||
return productsMapper.selectRecommendProducts(products);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Products> selectNewProductsList(Products products) {
|
||||
return productsMapper.selectNewProductsList(products);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Products> selectSailCountProducts(Products products) {
|
||||
return productsMapper.selectSailCountProducts(products);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getDetails(Integer productId) {
|
||||
Products products = this.selectProductsByProductId(productId);
|
||||
if (products == null || !Constants.GOODS_STATUS_SOLD.equals(products.getStatus())) {
|
||||
return AjaxResult.success("查询成功");
|
||||
}
|
||||
ImagesPrefixUtil.productImageDeals(products);
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs())) {
|
||||
// 获取商品规格关联信息
|
||||
LambdaQueryWrapper<ProductsSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ProductsSpec::getProductId, productId);
|
||||
List<ProductsSpec> list = productsSpecMapper.selectList(queryWrapper);
|
||||
Set<Integer> specValueIds = new HashSet<>();
|
||||
if (list != null && list.size() > 0) {
|
||||
products.setProductsSpecList(list);
|
||||
// 构建 规格级联信息.specType小的为父节点,大的为子节点
|
||||
List<List<ProductsSpecVO>> trees = new ArrayList<>();
|
||||
for (ProductsSpec productsSpec : list) {
|
||||
ImagesPrefixUtil.productSpecImageDeals(productsSpec);
|
||||
List<Integer> specValuesIds = productsSpec.getSpecValuesIds();
|
||||
specValueIds.addAll(specValuesIds);
|
||||
|
||||
// 设置specStr信息
|
||||
List<SpecValues> specValues = specValuesService.queryByIds(specValuesIds);
|
||||
// 对specValues排序
|
||||
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
// 级联末位节点是否可选
|
||||
boolean isDisabled = productsSpec.getStock() <= 0;
|
||||
List<ProductsSpecVO> productsSpecVOS = ProductsSpecVO.buildVOS(specValues, isDisabled);
|
||||
trees.add(productsSpecVOS);
|
||||
for (SpecValues specValue : specValues) {
|
||||
|
||||
sb.append(specValue.getSpecValue());
|
||||
if (specValue.getSpecUnit() != null) {
|
||||
sb.append(specValue.getSpecUnit());
|
||||
}
|
||||
sb.append(" ");
|
||||
}
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
productsSpec.setSpecStr(sb.toString());
|
||||
}
|
||||
|
||||
List<ProductsSpecVO> productsSpecVOS = ProductsSpecVO.mergeSpec(trees);
|
||||
products.setSpecs(productsSpecVOS);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return AjaxResult.success("查询成功", products);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 插入/修改商品,对商品对象进行预处理
|
||||
*
|
||||
* @param products
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Products preDealProducts(Products products) {
|
||||
if (products == null) {
|
||||
return null;
|
||||
}
|
||||
// 购买类型校验
|
||||
switch (products.getType()) {
|
||||
// 自动设置所需积分为0
|
||||
case Constants.GOODS_MONEY_BUY:
|
||||
if (products.getBasePrice() == null || products.getBasePrice() < 0) {
|
||||
throw new ServiceException("商品购买类型为金额购买时,商品基础价格不能为空且不能小于0");
|
||||
}
|
||||
products.setBaseIntegral(0);
|
||||
break;
|
||||
// 自动设置价格为0
|
||||
case Constants.GOODS_INTEGRAL_BUY:
|
||||
if (products.getBaseIntegral() == null || products.getBaseIntegral() < 0) {
|
||||
throw new ServiceException("商品购买类型为积分购买时,商品所需积分不能为空且不能小于0");
|
||||
}
|
||||
products.setBasePrice(0);
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("商品购买类型错误");
|
||||
}
|
||||
|
||||
// 目前只有单规格商品调用此方法,不考虑多规格情况
|
||||
// if (Constants.MULTI_SPEC.equals(products.getIsSpecs())) {
|
||||
// products.setBaseIntegral(0);
|
||||
// }
|
||||
|
||||
return products;
|
||||
}
|
||||
|
||||
|
||||
public Products preDealProductsAndSpec(Products products) {
|
||||
if (products == null) {
|
||||
return null;
|
||||
}
|
||||
// 购买类型校验
|
||||
switch (products.getType()) {
|
||||
// 自动设置所需积分为0
|
||||
case Constants.GOODS_MONEY_BUY:
|
||||
if (products.getBasePrice() == null || products.getBasePrice() < 0) {
|
||||
throw new ServiceException("商品购买类型为金额购买时,商品基础价格不能为空且不能小于0");
|
||||
}
|
||||
products.setBaseIntegral(0);
|
||||
break;
|
||||
// 自动设置价格为0
|
||||
case Constants.GOODS_INTEGRAL_BUY:
|
||||
if (products.getBaseIntegral() == null || products.getBaseIntegral() < 0) {
|
||||
throw new ServiceException("商品购买类型为积分购买时,商品所需积分不能为空且不能小于0");
|
||||
}
|
||||
products.setBasePrice(0);
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("商品购买类型错误");
|
||||
}
|
||||
|
||||
return products;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,753 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zf.foodpurchase.common.constant.Constants;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
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.fdsafe.entity.Products;
|
||||
import com.zf.foodpurchase.fdsafe.entity.ProductsSpec;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SpecValues;
|
||||
import com.zf.foodpurchase.fdsafe.mapper.ProductsSpecMapper;
|
||||
import com.zf.foodpurchase.fdsafe.service.IProductsService;
|
||||
import com.zf.foodpurchase.fdsafe.service.IProductsSpecService;
|
||||
import com.zf.foodpurchase.fdsafe.utils.SpecUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.zf.foodpurchase.common.utils.SecurityUtils.getLoginUser;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品价格表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-18
|
||||
*/
|
||||
@Service
|
||||
public class ProductsSpecServiceImpl extends ServiceImpl<ProductsSpecMapper, ProductsSpec> implements IProductsSpecService {
|
||||
@Autowired
|
||||
private IProductsService productsService;
|
||||
|
||||
@Autowired
|
||||
private ProductsSpecMapper productsSpecMapper;
|
||||
@Autowired
|
||||
private SpecValuesServiceImpl specValuesServiceImpl;
|
||||
|
||||
@Override
|
||||
public TableDataInfo queryList(ProductsSpec productsSpec) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Integer maxSpecTypeCount = 3;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Integer queryExists(ProductsSpec productsSpec) {
|
||||
LambdaQueryWrapper<ProductsSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ProductsSpec::getProductId, productsSpec.getProductId());
|
||||
queryWrapper.eq(ProductsSpec::getSpecValues, productsSpec.getSpecValues());
|
||||
queryWrapper.eq(ProductsSpec::getType, productsSpec.getType());
|
||||
return (int) count(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 本来就是多规格商品变导致库存可能变更
|
||||
* @param productsSpecList
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public boolean modifyProductsSepcList(List<ProductsSpec> productsSpecList) {
|
||||
ProductsSpec firstSpec = productsSpecList.get(0);
|
||||
Integer productId = firstSpec.getProductId();
|
||||
Products products = productsService.selectProductsByProductId(productId);
|
||||
if (products == null) {
|
||||
throw new ServiceException("商品不存在");
|
||||
}
|
||||
products.setProductsSpecList(productsSpecList);
|
||||
products.setUpdateTime(DateUtils.getNowDate());
|
||||
products.setOperId(firstSpec.getOperId());
|
||||
// 商品基础信息:总库存,基础价格,基础积分变动
|
||||
Integer minPrice = -1;
|
||||
Integer minIntegral = -1;
|
||||
Integer stock = 0;
|
||||
Set<String> specValuesSet = new HashSet<>();
|
||||
|
||||
List<ProductsSpec> updateList = new ArrayList<>();
|
||||
List<ProductsSpec> insertList = new ArrayList<>();
|
||||
|
||||
for (ProductsSpec productsSpec : productsSpecList) {
|
||||
// 修改时不会修改规格类型
|
||||
productsSpec.setType(products.getType());
|
||||
// 购买类型校验
|
||||
switch (productsSpec.getType()) {
|
||||
// 自动设置所需积分为0
|
||||
case Constants.GOODS_MONEY_BUY:
|
||||
if (productsSpec.getPrice() == null || productsSpec.getPrice() <= 0) {
|
||||
throw new ServiceException("商品购买类型为金额购买时,商品价格不能为空且必须大于0");
|
||||
}
|
||||
productsSpec.setIntegral(0);
|
||||
break;
|
||||
// 自动设置价格为0
|
||||
case Constants.GOODS_INTEGRAL_BUY:
|
||||
if (productsSpec.getIntegral() == null || productsSpec.getIntegral() <= 0) {
|
||||
throw new ServiceException("商品购买类型为积分购买时,商品所需积分不能为空且不能小于0");
|
||||
}
|
||||
productsSpec.setPrice(0);
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("商品购买类型错误");
|
||||
}
|
||||
|
||||
dealProductsSpecArrayToValues(productsSpec);
|
||||
preDealSpecValues(productsSpec);
|
||||
specValuesSet.add(productsSpec.getSpecValues());
|
||||
if(productsSpec.getStock()==null || productsSpec.getStock()<0){
|
||||
throw new ServiceException("商品库存不能为空且不能小于0");
|
||||
}
|
||||
stock+= productsSpec.getStock();
|
||||
|
||||
//
|
||||
minPrice = minPrice==-1 ? productsSpec.getPrice() : Math.min(minPrice, productsSpec.getPrice());
|
||||
minIntegral = minIntegral == -1 ? productsSpec.getIntegral() : Math.min(minIntegral, productsSpec.getIntegral());
|
||||
|
||||
if(productsSpec.getId()!=null){
|
||||
updateList.add(productsSpec);
|
||||
}else{
|
||||
insertList.add(productsSpec);
|
||||
}
|
||||
}
|
||||
|
||||
if(specValuesSet.size()!=productsSpecList.size()){
|
||||
throw new ServiceException("规格商品不能有重复的规格");
|
||||
}
|
||||
if(minPrice!=-1){
|
||||
products.setBasePrice(minPrice);
|
||||
}
|
||||
if(minIntegral!=-1){
|
||||
products.setBaseIntegral(minIntegral);
|
||||
|
||||
}
|
||||
products.setTotalStock(stock);
|
||||
|
||||
|
||||
|
||||
// 更新规格信息
|
||||
int count = 0;
|
||||
for (ProductsSpec productsSpec : updateList) {
|
||||
if (productsSpecMapper.updateProductsSpec(productsSpec) > 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
for(ProductsSpec productsSpec:insertList){
|
||||
LambdaQueryWrapper<ProductsSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ProductsSpec::getProductId, productsSpec.getProductId());
|
||||
queryWrapper.eq(ProductsSpec::getSpecValues, productsSpec.getSpecValues());
|
||||
if(this.count(queryWrapper)>0){
|
||||
throw new ServiceException("存在重复规格商品数据,保存失败");
|
||||
}
|
||||
if(this.save(productsSpec)){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if(count!=productsSpecList.size()){
|
||||
throw new ServiceException("保存失败");
|
||||
}
|
||||
// 更新商品信息
|
||||
// productsService.updateProducts(products);
|
||||
|
||||
// 商品就更新了个库存,直接更新不做校验
|
||||
return productsService.updateProductsDirect(products)>0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 来源于ProductsController商品更新
|
||||
* 更新商品信息,保存规格信息
|
||||
* @param products
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int commonUpdateProducts(Products products) {
|
||||
int count=0;
|
||||
int specSize =0;
|
||||
// 需要校验是否修改商品的库存信息
|
||||
Products oldProducts = productsService.selectProductsByProductId(products.getProductId());
|
||||
if(oldProducts==null){
|
||||
throw new ServiceException("商品不存在");
|
||||
}
|
||||
|
||||
// 暂时不允许单规格变为多规格
|
||||
// 单独规格变多规格
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs()) && Constants.SINGLE_SPEC.equals(oldProducts.getIsSpecs())) {
|
||||
// products.setTotalStock(0);
|
||||
// throw new ServiceException("单品无法修改为多规格");
|
||||
// 单变多
|
||||
// 更新products信息,products的价格,积分,返还积分都要重新计算
|
||||
int stock = 0;
|
||||
int minPrice = -1;
|
||||
int minIntegral = -1;
|
||||
// 多规格商品的库存添加对应规格商品时,自动累加
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs())) {
|
||||
List<ProductsSpec> productsSpecList = products.getProductsSpecList();
|
||||
if (productsSpecList == null || productsSpecList.size() == 0) {
|
||||
throw new ServiceException("多规格商品至少设置一种规格");
|
||||
}
|
||||
specSize = productsSpecList.size();
|
||||
for (ProductsSpec productsSpec : productsSpecList) {
|
||||
if (productsSpec.getStock() == null || productsSpec.getStock() < 0) {
|
||||
throw new ServiceException("商品库存不能为空且不能小于0");
|
||||
}
|
||||
minPrice = minPrice == -1 ? productsSpec.getPrice() : Math.min(minPrice, productsSpec.getPrice());
|
||||
minIntegral = minIntegral == -1 ? productsSpec.getIntegral() : Math.min(minIntegral, productsSpec.getIntegral());
|
||||
stock += productsSpec.getStock();
|
||||
}
|
||||
|
||||
// 校验数量是否一致
|
||||
// if(products.getTotalStock() != stock){
|
||||
// throw new ServiceException("商品库存与各规格库存之和不一致");
|
||||
// }
|
||||
products.setTotalStock(stock);
|
||||
products.setBasePrice(minPrice);
|
||||
products.setBaseIntegral(minIntegral);
|
||||
|
||||
}
|
||||
products = preDealProductsAndSpec(products);
|
||||
if (products != null) {
|
||||
List<ProductsSpec> productsSpecList = products.getProductsSpecList();
|
||||
this.preDealMultisSpecProducts(products);
|
||||
// 保存规格信息
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs()) && !CollectionUtils.isEmpty(productsSpecList)) {
|
||||
for(ProductsSpec productsSpec : productsSpecList){
|
||||
productsSpec.setProductId(products.getProductId());
|
||||
productsSpec.setType(products.getType());
|
||||
if(StringUtils.isBlank(productsSpec.getSpecImage())){
|
||||
productsSpec.setSpecImage(null);
|
||||
}
|
||||
count += productsSpecMapper.insert(productsSpec);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新products
|
||||
products = preDealProductsAndSpec(products);
|
||||
count += productsService.updateProductsDirect(products);
|
||||
if(count!=specSize+1){
|
||||
throw new ServiceException("商品信息更新失败");
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
// 商品为多规格商品,且修改了库存数目
|
||||
if (oldProducts.getIsSpecs().equals(Constants.MULTI_SPEC) && !oldProducts.getTotalStock().equals(products.getTotalStock())) {
|
||||
throw new ServiceException("多规格商品不允许直接修改商品库存,请修改具体规格下的商品库存");
|
||||
}
|
||||
|
||||
|
||||
// 多规格商品变单规格商品,清除多规格商品
|
||||
if (Constants.SINGLE_SPEC.equals(products.getIsSpecs()) && Constants.MULTI_SPEC.equals(oldProducts.getIsSpecs())) {
|
||||
LambdaQueryWrapper<ProductsSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ProductsSpec::getProductId, products.getProductId());
|
||||
productsSpecMapper.delete(queryWrapper);
|
||||
}
|
||||
|
||||
// 商品的购买类型发生变动
|
||||
// 商品购买类型发生变动,多规格需要提示信息
|
||||
if (!oldProducts.getType().equals(products.getType())) {
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs())) {
|
||||
throw new ServiceException("多规格商品不允许修改购买类型");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// 求出最小值
|
||||
Map<String,Long> map=productsSpecMapper.selectMinOne(products.getProductId());
|
||||
products.setBasePrice(map.get("price") == null ? 0 :map.get("price").intValue());
|
||||
products.setBaseIntegral(map.get("integral") == null ? 0 : map.get("integral").intValue());
|
||||
|
||||
products = preDealProductsAndSpec(products);
|
||||
return productsService.updateProductsDirect(products);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商品信息,前端传过来的是但规格商品
|
||||
* @param products
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public boolean updateSingleProducts(Products products) {
|
||||
// 校验products的基本信息
|
||||
Products oldProducts = productsService.selectProductsByProductId(products.getProductId());
|
||||
if(oldProducts==null){
|
||||
throw new ServiceException("商品不存在");
|
||||
}
|
||||
String type= products.getType();
|
||||
switch (type) {
|
||||
case Constants.GOODS_MONEY_BUY:
|
||||
if (products.getBasePrice() == null || products.getBasePrice() <= 0) {
|
||||
throw new ServiceException("商品购买类型为金额购买时,商品价格不能为空且必须大于0");
|
||||
}
|
||||
products.setBaseIntegral(0);
|
||||
break;
|
||||
case Constants.GOODS_INTEGRAL_BUY:
|
||||
if (products.getBaseIntegral() == null || products.getBaseIntegral() <= 0) {
|
||||
throw new ServiceException("商品购买类型为积分兑换时,商品所需积分不能为空且必须大于0");
|
||||
}
|
||||
products.setBasePrice(0);
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("商品购买类型错误");
|
||||
}
|
||||
|
||||
// 校验库存信息
|
||||
if(products.getTotalStock() == null || products.getTotalStock() < 0){
|
||||
throw new ServiceException("商品库存不能为空且不能小于0");
|
||||
}
|
||||
|
||||
//设置
|
||||
// 2.原来是单规格的直接更新;非但规格的清空规格商品信息在更新商品信息
|
||||
if(Constants.MULTI_SPEC.equals(oldProducts.getIsSpecs())){
|
||||
LambdaQueryWrapper<ProductsSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ProductsSpec::getProductId, products.getProductId());
|
||||
productsSpecMapper.delete(queryWrapper);
|
||||
}
|
||||
int count= productsService.updateProductsDirect(products);
|
||||
return count>0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 前端传入的商品节点信息是
|
||||
* @param products
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean updateMulSpecProducts(Products products) {
|
||||
|
||||
// 不允许单规格变多规格的实现
|
||||
// 需要校验是否修改商品的库存信息
|
||||
Products oldProducts = productsService.selectProductsByProductId(products.getProductId());
|
||||
if(oldProducts==null){
|
||||
throw new ServiceException("商品不存在");
|
||||
}
|
||||
if(Constants.MULTI_SPEC.equals(oldProducts.getIsSpecs()) ){
|
||||
// 多规格的限制,不更新basePrice,baseIntegral,totalStock,type(多规格的type没法变动)
|
||||
if(!products.getType().equals(oldProducts.getType())){
|
||||
throw new ServiceException("多规格商品不允许修改购买类型");
|
||||
}
|
||||
|
||||
// 库存不进行修改
|
||||
products.setBasePrice(oldProducts.getBasePrice());
|
||||
products.setBaseIntegral(oldProducts.getBaseIntegral());
|
||||
products.setTotalStock(oldProducts.getTotalStock());
|
||||
|
||||
int count=productsService.updateProductsDirect(products);
|
||||
return count>0;
|
||||
}
|
||||
|
||||
// 暂定但规格无法转变为多规格
|
||||
if(Constants.SINGLE_SPEC.equals(oldProducts.getIsSpecs())){
|
||||
throw new ServiceException("单规格商品不允许修改为多规格商品");
|
||||
|
||||
// 允许添加多规格逻辑
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public Products preDealProductsAndSpec(Products products) {
|
||||
if (products == null) {
|
||||
return null;
|
||||
}
|
||||
// 购买类型校验
|
||||
switch (products.getType()) {
|
||||
// 自动设置所需积分为0
|
||||
case Constants.GOODS_MONEY_BUY:
|
||||
if (products.getBasePrice() == null || products.getBasePrice() < 0) {
|
||||
throw new ServiceException("商品购买类型为金额购买时,商品基础价格不能为空且不能小于0");
|
||||
}
|
||||
products.setBaseIntegral(0);
|
||||
break;
|
||||
// 自动设置价格为0
|
||||
case Constants.GOODS_INTEGRAL_BUY:
|
||||
if (products.getBaseIntegral() == null || products.getBaseIntegral() < 0) {
|
||||
throw new ServiceException("商品购买类型为积分购买时,商品所需积分不能为空且不能小于0");
|
||||
}
|
||||
products.setBasePrice(0);
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("商品购买类型错误");
|
||||
}
|
||||
|
||||
return products;
|
||||
}
|
||||
|
||||
public void dealProductsSpecArrayToValues(ProductsSpec productsSpec) {
|
||||
List<List<Integer>> specValueArray = productsSpec.getSpecValueArray();
|
||||
if (specValueArray == null || specValueArray.size() == 0) {
|
||||
throw new RuntimeException("多规格商品必须指定具体规格");
|
||||
}
|
||||
if (specValueArray.size() > maxSpecTypeCount) {
|
||||
throw new RuntimeException("多规格商品最多只能设置" + maxSpecTypeCount + "个规格");
|
||||
}
|
||||
|
||||
StringBuilder valueItems = new StringBuilder();
|
||||
for (List<Integer> item : specValueArray) {
|
||||
if (CollectionUtils.isEmpty(item) || item.size() != 2) {
|
||||
throw new RuntimeException("多规格商品必须具体规格有误");
|
||||
}
|
||||
valueItems.append(item.get(1)).append(",");
|
||||
}
|
||||
valueItems.deleteCharAt(valueItems.length() - 1);
|
||||
|
||||
productsSpec.setSpecValues(valueItems.toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void dealProductsSpec(Products products, List<ProductsSpec> productsSpecs) {
|
||||
if (products == null) {
|
||||
return;
|
||||
}
|
||||
if (CollectionUtils.isEmpty(productsSpecs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs())) {
|
||||
Integer minPrice = -1;
|
||||
Integer minIntegral = -1;
|
||||
for (ProductsSpec ps : productsSpecs) {
|
||||
minPrice = minPrice == -1 ? ps.getPrice() : Math.min(minPrice, ps.getPrice());
|
||||
minIntegral = minIntegral == -1 ? ps.getIntegral() : Math.min(minIntegral, ps.getIntegral());
|
||||
}
|
||||
if (minPrice != -1) {
|
||||
products.setBasePrice(minPrice);
|
||||
}
|
||||
if (minIntegral != -1) {
|
||||
products.setBaseIntegral(minIntegral);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果该商品列表中存在商品只有一个商品规格信息,
|
||||
* 删除规格后会自动将该商品库存置0,设置为非多规格商品,并下架(因为库存为0);
|
||||
* 并将该商品加入列表中返回给前端
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public AjaxResult removeProductsByIds(List<Integer> list) {
|
||||
List<Products> lastProducts = new ArrayList<>();
|
||||
for (Integer id : list) {
|
||||
LambdaQueryWrapper<ProductsSpec> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ProductsSpec::getId, id);
|
||||
ProductsSpec productsSpec = getOne(queryWrapper);
|
||||
|
||||
Products products = productsService.selectProductsByProductId(productsSpec.getProductId());
|
||||
if (productsSpec == null || products == null) {
|
||||
continue;
|
||||
}
|
||||
// 判断是否为最后一个规格
|
||||
queryWrapper.clear();
|
||||
queryWrapper.eq(ProductsSpec::getProductId, productsSpec.getProductId());
|
||||
List<ProductsSpec> productsSpecs = list(queryWrapper);
|
||||
// 修改库存
|
||||
products.setTotalStock(products.getTotalStock() - productsSpec.getStock());
|
||||
products.setUpdateTime(DateUtils.getNowDate());
|
||||
products.setOperId(getLoginUser().getUser().getUserId());
|
||||
boolean isLast = productsSpecs.size() == 1;
|
||||
// 最后一个规格:
|
||||
if (isLast) {
|
||||
return AjaxResult.error("多规格商品至少要有一个规格商品,如果确实需要删除,请直接删除商品");
|
||||
}
|
||||
removeById(id);
|
||||
|
||||
// 设置products的最小值
|
||||
// 查询 price 的最小值
|
||||
Map<String,Long> map=productsSpecMapper.selectMinOne(products.getProductId());
|
||||
products.setBasePrice(map.get("price")==null?0:map.get("price").intValue());
|
||||
products.setBaseIntegral(map.get("integral")==null?0:map.get("integral").intValue());
|
||||
boolean isUpdate = productsService.updateProductsDirect(products)>0;
|
||||
if (!isUpdate) {
|
||||
throw new RuntimeException("删除失败");
|
||||
}
|
||||
lastProducts.add(products);
|
||||
}
|
||||
|
||||
return AjaxResult.success("删除成功").put("data", lastProducts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductsSpec> listWithProductSpecValues(LambdaQueryWrapper<ProductsSpec> queryWrapper) {
|
||||
List<ProductsSpec> productsSpecs = list(queryWrapper);
|
||||
if (productsSpecs == null || productsSpecs.size() == 0) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
for (ProductsSpec productsSpec : productsSpecs) {
|
||||
String specValues = productsSpec.getSpecValues();
|
||||
List<Integer> specValuesIds = new ArrayList<>();
|
||||
if (StringUtils.isBlank(specValues)) {
|
||||
continue;
|
||||
}
|
||||
if (!specValues.contains(",")) {
|
||||
specValuesIds.add(Integer.parseInt(specValues));
|
||||
} else {
|
||||
specValuesIds = Arrays.stream(specValues.split(",")).map(Integer::parseInt).collect(Collectors.toList());
|
||||
}
|
||||
List<SpecValues> list = specValuesServiceImpl.queryByIds(specValuesIds);
|
||||
productsSpec.setSpecValuesList(list);
|
||||
String specStr = SpecUtils.getSpecStr(list);
|
||||
productsSpec.setSpecStr(specStr);
|
||||
|
||||
}
|
||||
return productsSpecs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对productSpec预处理,
|
||||
* 按照对应value的id对应specType的id由低到高排序
|
||||
*
|
||||
* @param productsSpec
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ProductsSpec preDealSpecValues(ProductsSpec productsSpec) {
|
||||
if (productsSpec == null || StringUtils.isBlank(productsSpec.getSpecValues())) {
|
||||
return productsSpec;
|
||||
}
|
||||
// 规格值在系统中是否存在校验
|
||||
List<Integer> specValueIdList = productsSpec.getSpecValuesIds();
|
||||
if (specValueIdList.size() > 0) {
|
||||
// 逐个校验规格类型
|
||||
LambdaQueryWrapper<SpecValues> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(SpecValues::getId, specValueIdList);
|
||||
queryWrapper.eq(SpecValues::getMerchantId, productsSpec.getMerchantId());
|
||||
List<SpecValues> valuesList = specValuesServiceImpl.list(queryWrapper);
|
||||
int listSize = valuesList == null ? 0 : valuesList.size();
|
||||
if (listSize != specValueIdList.size()) {
|
||||
throw new ServiceException("部分规格在系统中不存在请检查");
|
||||
}
|
||||
|
||||
// 存在多个valueList需要重新排序
|
||||
if (valuesList.size() > 1) {
|
||||
// 获取specTypeList
|
||||
List<Integer> specTypeList = valuesList.stream()
|
||||
.map(SpecValues::getSpecType)
|
||||
.distinct()
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (specTypeList.size() != specValueIdList.size()) {
|
||||
throw new ServiceException("每种类型的规格值至多为一个");
|
||||
}
|
||||
|
||||
// 重新排序
|
||||
Collections.sort(valuesList, Comparator.comparingInt(SpecValues::getSpecType));
|
||||
|
||||
List<Integer> collect = valuesList.stream().map(SpecValues::getId).collect(Collectors.toList());
|
||||
productsSpec.setSpecValues(StringUtils.join(collect, ","));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return productsSpec;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入/修改商品规格,对商品规格对象进行预处理
|
||||
*
|
||||
* @param products
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ProductsSpec preDealProductsSpec(Products products, ProductsSpec productsSpec) {
|
||||
|
||||
if (products == null || productsSpec == null) {
|
||||
throw new ServiceException("商品或商品规格不能为空");
|
||||
}
|
||||
// 修改时不会修改规格类型
|
||||
productsSpec.setType(products.getType());
|
||||
// if (!products.getType().equals(productsSpec.getType())) {
|
||||
// throw new ServiceException("商品购买类型与商品规格购买类型必须要保持一致");
|
||||
// }
|
||||
// 购买类型校验
|
||||
switch (productsSpec.getType()) {
|
||||
// 自动设置所需积分为0
|
||||
case Constants.GOODS_MONEY_BUY:
|
||||
if (productsSpec.getPrice() == null || productsSpec.getPrice() <= 0) {
|
||||
throw new ServiceException("商品购买类型为金额购买时,商品价格不能为空且必须大于0");
|
||||
}
|
||||
productsSpec.setIntegral(0);
|
||||
break;
|
||||
// 自动设置价格为0
|
||||
case Constants.GOODS_INTEGRAL_BUY:
|
||||
if (productsSpec.getIntegral() == null || productsSpec.getIntegral() <= 0) {
|
||||
throw new ServiceException("商品购买类型为积分购买时,商品所需积分不能为空且不能小于0");
|
||||
}
|
||||
productsSpec.setPrice(0);
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("商品购买类型错误");
|
||||
}
|
||||
|
||||
return productsSpec;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public boolean addWithSpec(Products products) {
|
||||
|
||||
// 单规格商品处理
|
||||
if(Constants.SINGLE_SPEC.equals(products.getIsSpecs())){
|
||||
boolean flag = productsService.insertProducts(products) > 0;
|
||||
return flag;
|
||||
}
|
||||
|
||||
// 多规格处理
|
||||
int stock = 0;
|
||||
int minPrice = -1;
|
||||
int minIntegral = -1;
|
||||
// 多规格商品的库存添加对应规格商品时,自动累加
|
||||
// 计算商品基本信息: 库存,最小价格,最小积分
|
||||
//代替preDealProducts_addWithSpec方法
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs())) {
|
||||
List<ProductsSpec> productsSpecList = products.getProductsSpecList();
|
||||
if (productsSpecList == null || productsSpecList.size() == 0) {
|
||||
throw new ServiceException("多规格商品至少设置一种规格");
|
||||
}
|
||||
for (ProductsSpec productsSpec : productsSpecList) {
|
||||
if (productsSpec.getStock() == null || productsSpec.getStock() < 0) {
|
||||
throw new ServiceException("商品库存不能为空且不能小于0");
|
||||
}
|
||||
|
||||
// 处理商品规格信息填充
|
||||
// 插入商品商品才会有productId
|
||||
// productsSpec.setProductId(products.getProductId());
|
||||
productsSpec.setMerchantId(products.getMerchantId());
|
||||
productsSpec.setType(products.getType());
|
||||
dealProductsSpecArrayToValues(productsSpec);
|
||||
productsSpec = preDealSpecValues(productsSpec);
|
||||
productsSpec.setOperId(products.getOperId());
|
||||
productsSpec.setCreateTime(DateUtils.getNowDate());
|
||||
|
||||
// 规格商品校验--代替preDealProductsSpec()方法
|
||||
String type= productsSpec.getType();
|
||||
switch (type) {
|
||||
case Constants.GOODS_MONEY_BUY:
|
||||
if (productsSpec.getPrice() == null || productsSpec.getPrice() <= 0) {
|
||||
throw new ServiceException("商品购买类型为金额购买时,商品价格不能为空且必须大于0");
|
||||
}
|
||||
productsSpec.setIntegral(0);
|
||||
break;
|
||||
case Constants.GOODS_INTEGRAL_BUY:
|
||||
if (productsSpec.getIntegral() == null || productsSpec.getIntegral() <= 0) {
|
||||
throw new ServiceException("商品购买类型为积分兑换时,商品所需积分不能为空且必须大于0");
|
||||
}
|
||||
productsSpec.setPrice(0);
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("商品购买类型错误");
|
||||
}
|
||||
minPrice = minPrice == -1 ? productsSpec.getPrice() : Math.min(minPrice, productsSpec.getPrice());
|
||||
minIntegral = minIntegral == -1 ? productsSpec.getIntegral() : Math.min(minIntegral, productsSpec.getIntegral());
|
||||
stock += productsSpec.getStock();
|
||||
|
||||
if (productsSpec.getStock() < 0) {
|
||||
throw new ServiceException("规格商品的库存不能小于0");
|
||||
}
|
||||
}
|
||||
|
||||
products.setTotalStock(stock);
|
||||
products.setBasePrice(minPrice);
|
||||
products.setBaseIntegral(minIntegral);
|
||||
// 不需要额外校验products的类别
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 保存商品信息
|
||||
// boolean flag = productsService.insertProductsAndSpec(products) > 0;
|
||||
boolean flag = productsService.insertProductsDirect(products) > 0;
|
||||
|
||||
if (flag) {
|
||||
List<ProductsSpec> productsSpecList = products.getProductsSpecList();
|
||||
|
||||
// 保存规格信息
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs()) && !CollectionUtils.isEmpty(productsSpecList)) {
|
||||
for(ProductsSpec productsSpec : productsSpecList){
|
||||
// 设置product_id
|
||||
productsSpec.setProductId(products.getProductId());
|
||||
if(StringUtils.isBlank(productsSpec.getSpecImage())){
|
||||
productsSpec.setSpecImage(null);
|
||||
}
|
||||
}
|
||||
flag = this.saveBatch(productsSpecList);
|
||||
}
|
||||
}else{
|
||||
throw new ServiceException("商品保存失败");
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Products preDealMultisSpecProducts(Products products) {
|
||||
int stock = 0;
|
||||
if (products == null) {
|
||||
return null;
|
||||
}
|
||||
products.setCreateTime(DateUtils.getNowDate());
|
||||
// 是否对多规格处理
|
||||
List<ProductsSpec> productsSpecList = products.getProductsSpecList();
|
||||
if (Constants.MULTI_SPEC.equals(products.getIsSpecs()) && !CollectionUtils.isEmpty(productsSpecList)) {
|
||||
for (ProductsSpec productsSpec : productsSpecList) {
|
||||
if (productsSpec.getStock() < 0) {
|
||||
throw new ServiceException("规格商品的库存不能小于0");
|
||||
}
|
||||
|
||||
productsSpec.setProductId(products.getProductId());
|
||||
productsSpec.setMerchantId(products.getMerchantId());
|
||||
productsSpec.setType(products.getType());
|
||||
|
||||
|
||||
productsSpec = preDealProductsSpec(products, productsSpec);
|
||||
dealProductsSpecArrayToValues(productsSpec);
|
||||
productsSpec = preDealSpecValues(productsSpec);
|
||||
productsSpec.setOperId(products.getOperId());
|
||||
productsSpec.setCreateTime(DateUtils.getNowDate());
|
||||
|
||||
stock += productsSpec.getStock();
|
||||
}
|
||||
}
|
||||
products.setTotalStock(stock);
|
||||
return products;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.zf.foodpurchase.fdsafe.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.common.core.domain.entity.SysUser;
|
||||
import com.zf.foodpurchase.fdsafe.entity.*;
|
||||
import com.zf.foodpurchase.fdsafe.mapper.FoodProductMapper;
|
||||
import com.zf.foodpurchase.fdsafe.mapper.FoodRepoMapper;
|
||||
import com.zf.foodpurchase.fdsafe.mapper.RepoRecordMapper;
|
||||
import com.zf.foodpurchase.fdsafe.mapper.SchoolOrderItemMapper;
|
||||
import com.zf.foodpurchase.fdsafe.service.IRepoRecordService;
|
||||
import com.zf.foodpurchase.fdsafe.vo.FoodProductCKVO;
|
||||
import com.zf.foodpurchase.fdsafe.vo.RepoRecordVO;
|
||||
import com.zf.foodpurchase.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class RepoRecordServiceImpl extends ServiceImpl<RepoRecordMapper, RepoRecord> implements IRepoRecordService {
|
||||
|
||||
@Autowired
|
||||
private RepoRecordMapper repoRecordMapper;
|
||||
@Autowired
|
||||
private FoodProductMapper foodProductsMapper;
|
||||
@Autowired
|
||||
private SchoolOrderItemMapper schoolOrderItemMapper;
|
||||
@Autowired
|
||||
private SchoolOrderServiceImpl schoolOrderServiceImpl;
|
||||
@Autowired
|
||||
private SchoolOrderItemServiceImpl schoolOrderItemServiceImpl;
|
||||
|
||||
@Autowired
|
||||
private FoodRepoMapper foodRepoMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult inRepo(List<InRepoVO> inRepoVOs) {
|
||||
SysUser user = userService.getUser();
|
||||
inRepoVOs.forEach(inRepoVO -> {
|
||||
Integer productId = inRepoVO.getFoodProductId();
|
||||
Integer repoId = inRepoVO.getRepoId();
|
||||
Integer productNum = inRepoVO.getProductNum() == null ? 0 : inRepoVO.getProductNum();
|
||||
String orderNo = inRepoVO.getOrderNo();
|
||||
String orderItemNo = inRepoVO.getOrderItemNo();
|
||||
Integer supplierId = inRepoVO.getSupplierId();
|
||||
Integer categoryId = inRepoVO.getTypeId();
|
||||
Date date = new Date();
|
||||
RepoRecord repoRecord = new RepoRecord();
|
||||
repoRecord.setSupplierId(supplierId);
|
||||
repoRecord.setApplyDate( date);
|
||||
repoRecord.setProductId(productId);
|
||||
repoRecord.setRepoId(repoId);
|
||||
repoRecord.setProductNum(productNum);
|
||||
repoRecord.setCategoryId(categoryId);
|
||||
repoRecord.setStatus(1);
|
||||
BigDecimal price = inRepoVO.getPrice() == null ? BigDecimal.ZERO : inRepoVO.getPrice();
|
||||
BigDecimal totalCost = price.multiply(new BigDecimal(productNum));
|
||||
repoRecord.setTotalCost(totalCost);
|
||||
if(!user.isAdmin()){
|
||||
repoRecord.setSchoolId(user.getSchoolId().longValue());
|
||||
}
|
||||
repoRecordMapper.insertRepoRecord(repoRecord);
|
||||
|
||||
FoodRepo oldFoodRepo = foodRepoMapper.selectByProductIdAndRepoId(productId.longValue(),repoId.longValue());
|
||||
if(ObjectUtil.isNotNull(oldFoodRepo)){
|
||||
Integer foodProductNumNew = oldFoodRepo.getFoodProductNum() + productNum;
|
||||
oldFoodRepo.setFoodProductNum(foodProductNumNew);
|
||||
foodRepoMapper.update(oldFoodRepo);
|
||||
} else {
|
||||
FoodRepo foodRepo = new FoodRepo();
|
||||
foodRepo.setFoodProductId(productId);
|
||||
foodRepo.setRepoId(repoId);
|
||||
foodRepo.setOrderNo(orderNo);
|
||||
foodRepo.setOrderItemNo(orderItemNo);
|
||||
foodRepo.setFoodProductNum(productNum);
|
||||
foodRepoMapper.insert(foodRepo);
|
||||
}
|
||||
|
||||
LambdaUpdateWrapper<SchoolOrderItem> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(SchoolOrderItem::getOrderNo,orderNo);
|
||||
updateWrapper.set(SchoolOrderItem::getOrderItemStatus,5);
|
||||
updateWrapper.set(SchoolOrderItem::getUpdateTime,new Date());
|
||||
schoolOrderItemServiceImpl.update(updateWrapper);
|
||||
LambdaUpdateWrapper<SchoolOrder> updateWrapper2 = new LambdaUpdateWrapper<>();
|
||||
updateWrapper2.eq(SchoolOrder::getOrderNo,orderNo);
|
||||
updateWrapper2.set(SchoolOrder::getOrderStatus,5);
|
||||
updateWrapper2.set(SchoolOrder::getUpdateTime,new Date());
|
||||
schoolOrderServiceImpl.update(updateWrapper2);
|
||||
});
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult outRepo(List<FoodProductCKVO> foodProductCKVOs) {
|
||||
SysUser user = userService.getUser();
|
||||
for (FoodProductCKVO foodProductCKVO : foodProductCKVOs) {
|
||||
Integer productId = foodProductCKVO.getFoodProductId().intValue();
|
||||
Integer repoId = foodProductCKVO.getRepoId();
|
||||
Integer productNum = foodProductCKVO.getFoodProductNum() == null ? 0 : foodProductCKVO.getFoodProductNum();
|
||||
Integer supplierId = foodProductCKVO.getSupplierId();
|
||||
Integer categoryId = foodProductCKVO.getTypeId();
|
||||
Date date = new Date();
|
||||
RepoRecord repoRecord = new RepoRecord();
|
||||
repoRecord.setSupplierId(supplierId);
|
||||
repoRecord.setApplyDate( date);
|
||||
repoRecord.setProductId(productId);
|
||||
repoRecord.setRepoId(repoId);
|
||||
repoRecord.setProductNum(productNum);
|
||||
repoRecord.setCategoryId(categoryId);
|
||||
repoRecord.setStatus(1);
|
||||
BigDecimal price = foodProductCKVO.getPrice() == null ? BigDecimal.ZERO : foodProductCKVO.getPrice();
|
||||
BigDecimal totalCost = price.multiply(new BigDecimal(productNum));
|
||||
repoRecord.setTotalCost(totalCost);
|
||||
if(!user.isAdmin()){
|
||||
repoRecord.setSchoolId(user.getSchoolId().longValue());
|
||||
}
|
||||
repoRecordMapper.insertRepoRecord(repoRecord);
|
||||
FoodRepo oldFoodRepo = foodRepoMapper.selectByProductIdAndRepoId(productId.longValue(),repoId.longValue());
|
||||
Integer foodProductNumNew = oldFoodRepo.getFoodProductNum() - productNum;
|
||||
oldFoodRepo.setFoodProductNum(foodProductNumNew);
|
||||
foodRepoMapper.update(oldFoodRepo);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepoRecordVO selectRepoRecordByRepoRecordId(Long repoRecordId) {
|
||||
return repoRecordMapper.selectRepoRecordByRepoRecordId(repoRecordId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RepoRecordVO> selectRepoRecordList(RepoRecord repoRecord) {
|
||||
String productName = repoRecord.getProductName();
|
||||
Integer categoryId = repoRecord.getCategoryId();
|
||||
Integer repoId = repoRecord.getRepoId();
|
||||
Date startTime = repoRecord.getStartTime();
|
||||
Date endTime = repoRecord.getEndTime();
|
||||
return repoRecordMapper.selectRepoRecordList(productName, categoryId, repoId, startTime, endTime);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,8 +29,8 @@ public class RepositoryServiceImpl extends ServiceImpl<RepositoryMapper, Reposit
|
||||
private RepositoryMapper repositoryMapper;
|
||||
|
||||
@Override
|
||||
public List<Repository> joinQueryList(Repository quryRepository) {
|
||||
return repositoryMapper.joinQueryList(quryRepository);
|
||||
public List<Repository> queryRepoList(Repository quryRepository) {
|
||||
return repositoryMapper.queryRepoList(quryRepository);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,16 +47,7 @@ public class RepositoryServiceImpl extends ServiceImpl<RepositoryMapper, Reposit
|
||||
if (checkRepoNameUnique(repository)) {
|
||||
return AjaxResult.error("仓库名称已存在请更换仓库名称");
|
||||
}
|
||||
boolean update = updateById(repository);
|
||||
// 如果是默认仓库,需要修改其他仓库为非默认仓库
|
||||
if(Constants.REPO_DEFAULT.equals(repository.getDefaultRepo())){
|
||||
LambdaUpdateWrapper<Repository> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(Repository::getMerchantId, repository.getMerchantId());
|
||||
updateWrapper.ne(Repository::getId, repository.getId());
|
||||
updateWrapper.ne(Repository::getDefaultRepo, Constants.REPO_UN_DEFAULT);
|
||||
updateWrapper.set(Repository::getDefaultRepo, Constants.REPO_UN_DEFAULT);
|
||||
update(updateWrapper);
|
||||
}
|
||||
boolean update = updateById(repository);
|
||||
return update ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败");
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.zf.foodpurchase.fdsafe.entity.SchoolOrderItem;
|
||||
import com.zf.foodpurchase.fdsafe.mapper.SchoolOrderItemMapper;
|
||||
import com.zf.foodpurchase.fdsafe.service.ISchoolOrderItemService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zf.foodpurchase.fdsafe.vo.ProductCountVO;
|
||||
import com.zf.foodpurchase.fdsafe.vo.SchoolOrderItemVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -46,4 +47,5 @@ public class SchoolOrderItemServiceImpl extends ServiceImpl<SchoolOrderItemMappe
|
||||
throw new ServiceException("子订单项状态更新失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,11 +46,26 @@ public class SchoolOrderServiceImpl extends ServiceImpl<SchoolOrderMapper, Schoo
|
||||
|
||||
@Autowired
|
||||
private SchoolRefundMapper schoolRefundMapper;
|
||||
@Autowired
|
||||
private SchoolOrderMapper schoolOrderMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<SchoolOrderVO> querySupplierOrderVO(SchoolOrderVO schoolOrderVO) {
|
||||
List<SchoolOrderVO> list = baseMapper.querySupplierOrderVO(schoolOrderVO);
|
||||
return list;
|
||||
}
|
||||
@Override
|
||||
public List<SchoolOrderVO> querySchoolOrderVO(SchoolOrderVO schoolOrderVO) {
|
||||
List<SchoolOrderVO> list = baseMapper.querySchoolOrderVO(schoolOrderVO);
|
||||
list.forEach(f ->{
|
||||
SchoolOrderItemVO schoolOrderItemVO = new SchoolOrderItemVO();
|
||||
schoolOrderItemVO.setOrderNo(f.getOrderNo());
|
||||
List<SchoolOrderItemVO> schoolOrderItems = schoolOrderItemService.querySchoolOrderItemVO(schoolOrderItemVO);
|
||||
if(!CollectionUtils.isEmpty(schoolOrderItems)){
|
||||
f.setSchoolOrderItemVOList(schoolOrderItems);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -291,5 +306,15 @@ public class SchoolOrderServiceImpl extends ServiceImpl<SchoolOrderMapper, Schoo
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult signOrder(SchoolOrderVO schoolOrderVO) {
|
||||
schoolOrderVO.setOrderStatus(3);
|
||||
int b = schoolOrderMapper.signOrder(schoolOrderVO);
|
||||
if(b>0){
|
||||
return AjaxResult.success("订单签收成功");
|
||||
}
|
||||
return AjaxResult.error("订单签收失败");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SpecTypes;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SpecValues;
|
||||
import com.zf.foodpurchase.fdsafe.mapper.SpecTypesMapper;
|
||||
import com.zf.foodpurchase.fdsafe.service.ISpecTypesService;
|
||||
import com.zf.foodpurchase.fdsafe.service.ISpecValuesService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品规格类型表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-16
|
||||
*/
|
||||
@Service
|
||||
public class SpecTypesServiceImpl extends ServiceImpl<SpecTypesMapper, SpecTypes> implements ISpecTypesService {
|
||||
|
||||
@Autowired
|
||||
private ISpecValuesService specValuesService;
|
||||
|
||||
@Override
|
||||
public AjaxResult saveTypes(SpecTypes specTypes) {
|
||||
LambdaQueryWrapper<SpecTypes> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SpecTypes::getSpecName, specTypes.getSpecName());
|
||||
queryWrapper.eq(SpecTypes::getMerchantId, specTypes.getMerchantId());
|
||||
if (this.count(queryWrapper) > 0) {
|
||||
return AjaxResult.error("规格类型已存在,不能重复添加");
|
||||
}
|
||||
boolean result =this.save(specTypes);
|
||||
return result?AjaxResult.success("添加成功"):AjaxResult.error("添加失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult removeSpecTypes(List<Long> list,Long merchantId) {
|
||||
LambdaQueryWrapper<SpecValues> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(SpecValues::getSpecType, list);
|
||||
if (specValuesService.count(queryWrapper) > 0) {
|
||||
return AjaxResult.error("该规格类型下有规格值,请先删除规格值");
|
||||
}
|
||||
// 管理员删除所有,非管理员删除其所在部门下
|
||||
LambdaQueryWrapper<SpecTypes> deleteWrapper = new LambdaQueryWrapper<>();
|
||||
deleteWrapper.in(SpecTypes::getSpecType, list);
|
||||
if(merchantId!=null){
|
||||
deleteWrapper.eq(SpecTypes::getMerchantId,merchantId);
|
||||
}
|
||||
this.remove(deleteWrapper);
|
||||
return AjaxResult.success("删除成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult updateType(SpecTypes specTypes, boolean admin) {
|
||||
LambdaUpdateWrapper <SpecTypes> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(SpecTypes::getSpecType, specTypes.getSpecType());
|
||||
if (admin) {
|
||||
updateWrapper.eq(SpecTypes::getMerchantId, specTypes.getMerchantId());
|
||||
}
|
||||
boolean flag=this.update(specTypes, updateWrapper);
|
||||
return flag?AjaxResult.success("修改成功"):AjaxResult.error("修改失败");
|
||||
}
|
||||
|
||||
public void preValidateInsert(SpecTypes specTypes){
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.fdsafe.entity.ProductsSpec;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SpecValues;
|
||||
import com.zf.foodpurchase.fdsafe.mapper.ProductsSpecMapper;
|
||||
import com.zf.foodpurchase.fdsafe.mapper.SpecValuesMapper;
|
||||
import com.zf.foodpurchase.fdsafe.service.ISpecValuesService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 规格值表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-16
|
||||
*/
|
||||
@Service
|
||||
public class SpecValuesServiceImpl extends ServiceImpl<SpecValuesMapper, SpecValues> implements ISpecValuesService {
|
||||
|
||||
@Autowired
|
||||
private SpecValuesMapper specValuesMapper;
|
||||
|
||||
@Autowired
|
||||
private ProductsSpecMapper productsSpecMapper;
|
||||
|
||||
@Override
|
||||
public List<SpecValues> queryList(SpecValues specValues) {
|
||||
return specValuesMapper.queryList(specValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SpecValues> queryByIds(List<Integer> specValuesIds) {
|
||||
return specValuesMapper.queryByIds(specValuesIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult updateSpecValues(SpecValues specValues,boolean isAdmin) {
|
||||
LambdaUpdateWrapper<SpecValues> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(SpecValues::getId,specValues.getId());
|
||||
if(!isAdmin){
|
||||
updateWrapper.eq(SpecValues::getMerchantId,specValues.getMerchantId());
|
||||
}
|
||||
int count=specValuesMapper.update(specValues,updateWrapper);
|
||||
return count>0 ? AjaxResult.success("修改成功"):AjaxResult.error("修改失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult removeValues(List<Long> idList, Long merchantId) {
|
||||
// todo:判断商品规格表有无关联商品
|
||||
for (Long id : idList) {
|
||||
List<ProductsSpec> list = productsSpecMapper.selectList(new LambdaQueryWrapper<ProductsSpec>().like(ProductsSpec::getSpecValues, id));
|
||||
if (list != null && list.size() > 0) {
|
||||
return AjaxResult.error("该规格类型下有商品关联,请先解除关联");
|
||||
}
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<SpecValues> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(SpecValues::getId,idList);
|
||||
if(merchantId!=null){
|
||||
queryWrapper.eq(SpecValues::getMerchantId,merchantId);
|
||||
}
|
||||
if(specValuesMapper.delete(queryWrapper)>0){
|
||||
return AjaxResult.success("删除成功");
|
||||
}
|
||||
return AjaxResult.error("删除失败");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,286 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.utils;
|
||||
|
||||
import com.zf.foodpurchase.common.config.RuoYiConfig;
|
||||
import com.zf.foodpurchase.common.utils.StringUtils;
|
||||
import com.zf.foodpurchase.fdsafe.entity.CartItem;
|
||||
import com.zf.foodpurchase.fdsafe.entity.OrderItem;
|
||||
import com.zf.foodpurchase.fdsafe.entity.Products;
|
||||
import com.zf.foodpurchase.fdsafe.entity.ProductsSpec;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:lilj
|
||||
* @date:2024/11/27
|
||||
*/
|
||||
public class ImagesPrefixUtil {
|
||||
public static void productImageDeals(List<Products> productsList) {
|
||||
for (Products products : productsList) {
|
||||
String images = products.getImages();
|
||||
if(StringUtils.isNotBlank(images)){
|
||||
if (images.contains(",")) {
|
||||
String[] imageArray = images.split(",");
|
||||
for (int i = 0; i < imageArray.length; i++) {
|
||||
if(!imageArray[i].contains("http")){
|
||||
imageArray[i] = RuoYiConfig.getImagePrefix()+ imageArray[i];
|
||||
}
|
||||
}
|
||||
products.setImages(String.join(",", imageArray));
|
||||
products.setFirstImage(imageArray[0]);
|
||||
products.setImagesArray(imageArray);
|
||||
} else {
|
||||
if(!images.contains("http")){
|
||||
images = RuoYiConfig.getImagePrefix()+ images;
|
||||
}
|
||||
products.setFirstImage( images);
|
||||
products.setImages(images);
|
||||
products.setImagesArray(new String[]{images});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String detailImages = products.getDetailImages();
|
||||
if (StringUtils.isBlank(detailImages)) {
|
||||
continue;
|
||||
}
|
||||
if (detailImages.contains(",")) {
|
||||
String[] imageArray = detailImages.split(",");
|
||||
for (int i = 0; i < imageArray.length; i++) {
|
||||
if(!imageArray[i].contains("http")){
|
||||
imageArray[i] = RuoYiConfig.getImagePrefix()+ imageArray[i];
|
||||
}
|
||||
}
|
||||
products.setFirstDetailsImage(imageArray[0]);
|
||||
products.setDetailImages(String.join(",", imageArray));
|
||||
products.setDetailImagesArray(imageArray);
|
||||
} else {
|
||||
if(!detailImages.contains("http")){
|
||||
detailImages = RuoYiConfig.getImagePrefix()+ detailImages;
|
||||
}
|
||||
products.setFirstDetailsImage(detailImages);
|
||||
products.setDetailImages(detailImages);
|
||||
products.setDetailImagesArray(new String[]{detailImages});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void productImageDeals(Products products) {
|
||||
String images = products.getImages();
|
||||
if (StringUtils.isNotBlank(images)) {
|
||||
if (images.contains(",")) {
|
||||
String[] imageArray = images.split(",");
|
||||
products.setFirstImage(imageArray[0]);
|
||||
for (int i = 0; i < imageArray.length; i++) {
|
||||
if(!imageArray[i].contains("http")){
|
||||
imageArray[i] = RuoYiConfig.getImagePrefix()+ imageArray[i];
|
||||
}
|
||||
}
|
||||
products.setImages(String.join(",", imageArray));
|
||||
products.setImagesArray(imageArray);
|
||||
} else {
|
||||
if(!images.contains("http")){
|
||||
images = RuoYiConfig.getImagePrefix()+ images;
|
||||
}
|
||||
products.setFirstImage(images);
|
||||
products.setImages(images);
|
||||
products.setImagesArray(new String[]{images});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String detailImages = products.getDetailImages();
|
||||
if (StringUtils.isBlank(detailImages)) {
|
||||
return;
|
||||
}
|
||||
if (detailImages.contains(",")) {
|
||||
String[] imageArray = detailImages.split(",");
|
||||
for (int i = 0; i < imageArray.length; i++) {
|
||||
if(!imageArray[i].contains("http")){
|
||||
imageArray[i] = RuoYiConfig.getImagePrefix()+ imageArray[i];
|
||||
}
|
||||
}
|
||||
products.setFirstDetailsImage(imageArray[0]);
|
||||
products.setDetailImages(String.join(",", imageArray));
|
||||
products.setDetailImagesArray(imageArray);
|
||||
} else {
|
||||
if(!detailImages.contains("http")){
|
||||
detailImages = RuoYiConfig.getImagePrefix()+ detailImages;
|
||||
}
|
||||
products.setFirstDetailsImage(detailImages);
|
||||
products.setDetailImages(detailImages);
|
||||
products.setDetailImagesArray(new String[]{detailImages});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void productSpecImageDeals(List<ProductsSpec> productsSpecs) {
|
||||
for (ProductsSpec productsSpec : productsSpecs) {
|
||||
String images = productsSpec.getSpecImage();
|
||||
if (StringUtils.isBlank(images)) {
|
||||
continue;
|
||||
}
|
||||
if (images.contains(",")) {
|
||||
String[] imageArray = images.split(",");
|
||||
productsSpec.setFirstSpecImage(imageArray[0]);
|
||||
for (int i = 0; i < imageArray.length; i++) {
|
||||
if(!imageArray[i].contains("http")){
|
||||
imageArray[i] = RuoYiConfig.getImagePrefix()+ imageArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
productsSpec.setSpecImage(String.join(",", imageArray));
|
||||
productsSpec.setSpecImagesArray(imageArray);
|
||||
} else {
|
||||
if(!images.contains("http")){
|
||||
images = RuoYiConfig.getImagePrefix()+ images;
|
||||
}
|
||||
productsSpec.setFirstSpecImage(images);
|
||||
productsSpec.setSpecImage(images);
|
||||
productsSpec.setSpecImagesArray(new String[]{images});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void productSpecImageDeals(ProductsSpec productsSpec) {
|
||||
|
||||
String images = productsSpec.getSpecImage();
|
||||
if (StringUtils.isBlank(images)) {
|
||||
return;
|
||||
}
|
||||
if (images.contains(",")) {
|
||||
String[] imageArray = images.split(",");
|
||||
|
||||
for (int i = 0; i < imageArray.length; i++) {
|
||||
if(!imageArray[i].contains("http")){
|
||||
imageArray[i] = RuoYiConfig.getImagePrefix()+ imageArray[i];
|
||||
}
|
||||
}
|
||||
productsSpec.setFirstSpecImage(imageArray[0]);
|
||||
productsSpec.setSpecImage(String.join(",", imageArray));
|
||||
productsSpec.setSpecImagesArray(imageArray);
|
||||
} else {
|
||||
if(!images.contains("http")){
|
||||
images = RuoYiConfig.getImagePrefix()+ images;
|
||||
}
|
||||
productsSpec.setFirstSpecImage(images);
|
||||
productsSpec.setSpecImage(images);
|
||||
productsSpec.setSpecImagesArray(new String[]{images});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void cartItemImage(CartItem item, Products products) {
|
||||
String images = products.getImages();
|
||||
String firstImage = getFirstImage(images);
|
||||
item.setImage(firstImage);
|
||||
}
|
||||
|
||||
public static void cartItemImage(CartItem item, ProductsSpec spec) {
|
||||
String images = spec.getSpecImage();
|
||||
String firstImage = getFirstImage(images);
|
||||
item.setImage(firstImage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理查询的出的orderItem的图片参数信息
|
||||
*/
|
||||
public static void dealOrderItemPic(OrderItem item){
|
||||
if(item == null || StringUtils.isBlank(item.getProductPicUrl()) ){
|
||||
return;
|
||||
}
|
||||
String picUrl = item.getProductPicUrl();
|
||||
String firstImage= getFirstImage(picUrl);
|
||||
item.setProductPicUrl(firstImage);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量处理
|
||||
* @param list
|
||||
*/
|
||||
public static void dealOrderItemPics(List<OrderItem> list){
|
||||
for(OrderItem item:list){
|
||||
dealOrderItemPic(item);
|
||||
}
|
||||
}
|
||||
|
||||
public static String imagesDeal(String images){
|
||||
if (StringUtils.isBlank(images)) {
|
||||
return null;
|
||||
}
|
||||
if (images.contains(",")) {
|
||||
String[] imageArray = images.split(",");
|
||||
for (int i = 0; i < imageArray.length; i++) {
|
||||
if(!imageArray[i].contains("http")){
|
||||
imageArray[i] = RuoYiConfig.getImagePrefix()+ imageArray[i];
|
||||
}
|
||||
}
|
||||
images = String.join(",", imageArray);
|
||||
}else {
|
||||
if (!images.contains("http")) {
|
||||
images = RuoYiConfig.getImagePrefix() + images;
|
||||
}
|
||||
}
|
||||
return images;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 轮播图是商户上传的轮播图,对应的路径应该为商户的路径
|
||||
* @param sourceStr
|
||||
* @param firstImages
|
||||
* @param destStr
|
||||
*/
|
||||
public static void dealImagesPath(String sourceStr,StringBuilder firstImages,StringBuilder destStr){
|
||||
String images = sourceStr;
|
||||
if (images == null) {
|
||||
firstImages=null;
|
||||
destStr=null;
|
||||
return;
|
||||
}
|
||||
if (images.contains(",")) {
|
||||
String[] imageArray = images.split(",");
|
||||
for (int i = 0; i < imageArray.length; i++) {
|
||||
if(!imageArray[i].contains("http")){
|
||||
imageArray[i] = RuoYiConfig.getImagePrefix() + imageArray[i];
|
||||
}
|
||||
destStr.append(imageArray[i]).append(",");
|
||||
}
|
||||
if(destStr.length()>1){
|
||||
destStr.deleteCharAt(destStr.length()-1);
|
||||
}
|
||||
firstImages .append( imageArray[0]);
|
||||
} else {
|
||||
if(!images.contains("http")){
|
||||
images = RuoYiConfig.getImagePrefix()+ images;
|
||||
}
|
||||
firstImages.append(images);
|
||||
destStr.append(images);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String getFirstImage(String sourceStr){
|
||||
String firstImage=null;
|
||||
if (StringUtils.isBlank(sourceStr)) {
|
||||
return null;
|
||||
}
|
||||
if (sourceStr.contains(",")) {
|
||||
String[] imageArray = sourceStr.split(",");
|
||||
firstImage = imageArray[0];
|
||||
if(!firstImage.contains("http")){
|
||||
firstImage = RuoYiConfig.getImagePrefix() + firstImage;
|
||||
}
|
||||
} else {
|
||||
if(!sourceStr.contains("http")){
|
||||
sourceStr = RuoYiConfig.getImagePrefix()+ sourceStr;
|
||||
}
|
||||
firstImage= sourceStr;
|
||||
}
|
||||
return firstImage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.utils;
|
||||
|
||||
import com.zf.foodpurchase.fdsafe.entity.SpecValues;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:lilj
|
||||
* @date:2024/12/5
|
||||
*/
|
||||
public class SpecUtils {
|
||||
|
||||
public static String getSpecStr(List<SpecValues> specValuesList) {
|
||||
if(CollectionUtils.isEmpty(specValuesList)){
|
||||
return null;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (SpecValues specValue : specValuesList) {
|
||||
sb.append(specValue.getSpecValue());
|
||||
if (specValue.getSpecUnit() != null) {
|
||||
sb.append(specValue.getSpecUnit());
|
||||
}
|
||||
sb.append(" ");
|
||||
}
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.zf.foodpurchase.fdsafe.vo;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class FoodProductCKVO {
|
||||
|
||||
private Long foodProductId;
|
||||
private String num;
|
||||
private String name;
|
||||
private String repoName;
|
||||
private String specName;
|
||||
private Integer foodProductNum;
|
||||
private String unitName;
|
||||
private Integer supplierId;
|
||||
private Integer typeId;
|
||||
private Integer repoId;
|
||||
private Long deptId;
|
||||
private BigDecimal price;
|
||||
private String msg;
|
||||
|
||||
}
|
||||
@@ -1,20 +1,14 @@
|
||||
package com.zf.foodpurchase.fdsafe.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.zf.foodpurchase.common.valigroud.AddGroup;
|
||||
import com.zf.foodpurchase.common.valigroud.CheckGroup;
|
||||
import com.zf.foodpurchase.common.valigroud.UpdateGroup;
|
||||
import com.zf.foodpurchase.common.vo.CommonVO;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -38,10 +32,12 @@ public class FoodProductVO extends CommonVO implements Serializable {
|
||||
@NotNull(message = "食材id不能为空", groups = { AddGroup.class})
|
||||
private Integer foodId;
|
||||
|
||||
|
||||
private String num;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String foodName;
|
||||
private String name;
|
||||
|
||||
// 关联食材得到的信息
|
||||
/**
|
||||
@@ -57,14 +53,17 @@ public class FoodProductVO extends CommonVO implements Serializable {
|
||||
@NotNull(message = "单价不能为空", groups = { AddGroup.class})
|
||||
private BigDecimal price;
|
||||
|
||||
// 规格单位信息
|
||||
// 单位信息
|
||||
private Integer unitId;
|
||||
private String unitLabel;
|
||||
|
||||
// 单位信息
|
||||
private Integer specId;
|
||||
private String specLabel;
|
||||
|
||||
/**
|
||||
* 供货商id
|
||||
*/
|
||||
@NotNull(message = "供货商id不能为空", groups = {AddGroup.class})
|
||||
private Integer supplierId;
|
||||
|
||||
/**
|
||||
@@ -115,4 +114,8 @@ public class FoodProductVO extends CommonVO implements Serializable {
|
||||
* 有效标志
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
private Integer totalProductNum;
|
||||
|
||||
private Integer repoId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.zf.foodpurchase.fdsafe.vo;
|
||||
|
||||
import com.zf.foodpurchase.common.valigroud.AddGroup;
|
||||
import com.zf.foodpurchase.common.valigroud.UpdateGroup;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author:lilj
|
||||
* @date:2025/4/17
|
||||
*/
|
||||
@Data
|
||||
public class FoodSpecVO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 食材规格/单位id
|
||||
*/
|
||||
@NotNull(message = "食材规格/单位id不能为空", groups = {UpdateGroup.class})
|
||||
private Integer specId;
|
||||
|
||||
/**
|
||||
* 食材规格
|
||||
*/
|
||||
@NotBlank(message = "食材规格/单位不能为空", groups = {UpdateGroup.class, AddGroup.class})
|
||||
private String specLabel;
|
||||
|
||||
/**
|
||||
* 0 正常 1 停用
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 是否有效: 0 有效 1 无效
|
||||
*/
|
||||
@NotNull(message = "是否有效不能为空", groups = {UpdateGroup.class, AddGroup.class})
|
||||
private Integer status;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.zf.foodpurchase.fdsafe.vo;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ProductCountVO {
|
||||
|
||||
private Integer productId;
|
||||
private String productName;
|
||||
private Integer productNum;
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
package com.zf.foodpurchase.fdsafe.vo;
|
||||
|
||||
import com.zf.foodpurchase.common.utils.StringUtils;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SpecValues;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author:lilj
|
||||
* @date:2024/12/2
|
||||
*/
|
||||
@Data
|
||||
public class ProductsSpecVO {
|
||||
|
||||
/**
|
||||
* 规格名
|
||||
*/
|
||||
private String text;
|
||||
|
||||
/**
|
||||
* 规格值id.
|
||||
*/
|
||||
private Integer value;
|
||||
|
||||
/**
|
||||
* 规格单位
|
||||
*/
|
||||
private String unit;
|
||||
|
||||
/**
|
||||
* 是否可选
|
||||
*/
|
||||
private Boolean disabled;
|
||||
|
||||
/**
|
||||
* 需要该属性辅助构建树形结构
|
||||
*/
|
||||
private Integer parentId;
|
||||
|
||||
/**
|
||||
* 唯一标识
|
||||
*/
|
||||
private String uniqueKey;
|
||||
|
||||
private String parentKey;
|
||||
|
||||
List<ProductsSpecVO> children;
|
||||
|
||||
/**
|
||||
* 合并多个规格
|
||||
*
|
||||
* @param trees
|
||||
* @return
|
||||
*/
|
||||
|
||||
public static List<ProductsSpecVO> mergeSpec(List<List<ProductsSpecVO>> trees) {
|
||||
// Step 1: Create a map to store all nodes by their value
|
||||
Map<String, ProductsSpecVO> nodeMap = new HashMap<>();
|
||||
for (List<ProductsSpecVO> tree : trees) {
|
||||
for (ProductsSpecVO node : tree) {
|
||||
// nodeMap.put(node.getParentId() + ":" + node.getValue(), node);
|
||||
nodeMap.put(node.getUniqueKey(), node);
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2: Build the tree structure
|
||||
for (ProductsSpecVO node : nodeMap.values()) {
|
||||
String parentKey= node.getParentKey();
|
||||
if (parentKey != null && nodeMap.containsKey(parentKey)) {
|
||||
ProductsSpecVO parent = nodeMap.get(parentKey);
|
||||
if (parent.getChildren() == null) {
|
||||
parent.setChildren(new ArrayList<>());
|
||||
}
|
||||
parent.getChildren().add(node);
|
||||
// parent.getChildrenMap().put(node.getValue(), node);
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3: Collect root nodes (nodes with parentId == null)
|
||||
List<ProductsSpecVO> rootNodes = new ArrayList<>();
|
||||
for (ProductsSpecVO node : nodeMap.values()) {
|
||||
if (node.getParentId() == null) {
|
||||
rootNodes.add(node);
|
||||
}
|
||||
}
|
||||
|
||||
return rootNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建节点基本信息
|
||||
*
|
||||
* @param specValuesList
|
||||
* @param isDisabled
|
||||
* @return
|
||||
*/
|
||||
public static List<ProductsSpecVO> buildVOS(List<SpecValues> specValuesList, Boolean isDisabled) {
|
||||
|
||||
List<ProductsSpecVO> productsSpecVOList = new ArrayList<>();
|
||||
List<Integer> specTypeList = specValuesList.stream()
|
||||
.map(SpecValues::getSpecType)
|
||||
.distinct()
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
Map<Integer, SpecValues> specTypeToSpecValueMap = specValuesList.stream()
|
||||
.collect(Collectors.toMap(
|
||||
SpecValues::getSpecType, // Key: specType
|
||||
value -> value // Value: specValue
|
||||
));
|
||||
|
||||
|
||||
// 初始化根节点
|
||||
ProductsSpecVO preNod = null;
|
||||
for (int i = 0; i < specTypeList.size(); i++) {
|
||||
ProductsSpecVO node = new ProductsSpecVO();
|
||||
node = new ProductsSpecVO();
|
||||
|
||||
SpecValues specValues =specTypeToSpecValueMap.get(specTypeList.get(i));
|
||||
if(StringUtils.isNotBlank(specValues.getSpecUnit())){
|
||||
node.setText(specValues.getSpecValue()+specValues.getSpecUnit());
|
||||
|
||||
}else{
|
||||
node.setText(specValues.getSpecValue());
|
||||
}
|
||||
node.setValue(specValues.getId());
|
||||
node.setUnit(specValues.getSpecUnit());
|
||||
if (i == specValuesList.size() - 1) {
|
||||
node.setDisabled(isDisabled);
|
||||
} else {
|
||||
node.setDisabled(false);
|
||||
}
|
||||
if (i != 0) {
|
||||
node.setParentId(preNod.getValue());
|
||||
node.setUniqueKey(preNod.getUniqueKey()+":"+node.getValue());
|
||||
node.setParentKey(preNod.getUniqueKey());
|
||||
}else{
|
||||
node.setUniqueKey("0"+":"+node.getValue().toString());
|
||||
}
|
||||
productsSpecVOList.add(node);
|
||||
preNod = node;
|
||||
|
||||
}
|
||||
|
||||
return productsSpecVOList;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.zf.foodpurchase.fdsafe.vo;
|
||||
|
||||
import com.zf.foodpurchase.fdsafe.entity.FoodProduct;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class RepoRecordVO {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 申请日期
|
||||
*/
|
||||
private Date applyDate;
|
||||
|
||||
/**
|
||||
* 供应商id
|
||||
*/
|
||||
private Long merchantId;
|
||||
|
||||
private String merchantName;
|
||||
|
||||
/**
|
||||
* 类型id
|
||||
*/
|
||||
private String categoryId;
|
||||
|
||||
private String categoryName;
|
||||
|
||||
/**
|
||||
* 仓库id
|
||||
*/
|
||||
private Integer repoId;
|
||||
|
||||
private String repoName;
|
||||
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Integer productId;
|
||||
|
||||
private List<FoodProduct> foodProducts;
|
||||
|
||||
/**
|
||||
* 商品数量
|
||||
*/
|
||||
private Integer productNum;
|
||||
|
||||
/**
|
||||
* 商品总价,单位:分
|
||||
*/
|
||||
private BigDecimal totalCost;
|
||||
|
||||
/**
|
||||
* 出入库状态 1:入库, 0:出库
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
private String statusName;
|
||||
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
private String msg;
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:lilj
|
||||
@@ -153,4 +154,6 @@ public class SchoolCartItemVO extends CommonVO implements Serializable {
|
||||
*/
|
||||
private Integer foodDelFlag;
|
||||
|
||||
private List<Long> deptIds;
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class SchoolOrderItemVO extends CommonVO implements Serializable {
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Long foodProductId;
|
||||
private Integer foodProductId;
|
||||
|
||||
/**
|
||||
* 食材名称
|
||||
|
||||
@@ -5,12 +5,14 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.zf.foodpurchase.common.vo.CommonVO;
|
||||
import com.zf.foodpurchase.fdsafe.entity.SchoolOrderItem;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:lilj
|
||||
@@ -105,4 +107,14 @@ public class SchoolOrderVO extends CommonVO implements Serializable {
|
||||
* 订单是否可参与结算:0 不可参与结算; 1 可参与结算
|
||||
*/
|
||||
private Integer orderSettleStatus;
|
||||
|
||||
private List<SchoolOrderItemVO> schoolOrderItemVOList;
|
||||
|
||||
private String signPerson;
|
||||
|
||||
private Date signTime;
|
||||
|
||||
private String signImage;
|
||||
|
||||
private List<Long> deptIds;
|
||||
}
|
||||
|
||||
@@ -123,4 +123,6 @@ public interface SysDeptMapper
|
||||
public void updateTenantId(@Param("deptIds") List<Long> deptIds, @Param("tenantId") String tenantId);
|
||||
|
||||
public List<Long> selectAllZSByDeptId(Long deptId);
|
||||
|
||||
List<SysDept> selectIdByDeptIds(@Param("deptIds") List<Integer> deptIds);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.zf.foodpurchase.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.zf.foodpurchase.system.domain.SysRoleDept;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 角色与部门关联表 数据层
|
||||
@@ -41,4 +42,6 @@ public interface SysRoleDeptMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchRoleDept(List<SysRoleDept> roleDeptList);
|
||||
|
||||
public List<Long> selectDeptIdsByRoleIds(@Param("roleIds") List<Long> roleIds);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.zf.foodpurchase.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.zf.foodpurchase.common.core.domain.entity.SysRole;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 角色表 数据层
|
||||
@@ -106,4 +107,6 @@ public interface SysRoleMapper
|
||||
public int deleteRoleByIds(Long[] roleIds);
|
||||
|
||||
public List<SysRole> selectRolesByTenantId(String tenantId);
|
||||
|
||||
public List<SysRole> selectRolesByIds(@Param("roleIds") List<Long> roleIds);
|
||||
}
|
||||
|
||||
@@ -59,4 +59,6 @@ public interface SysUserRoleMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserRoleInfos(@Param("roleId") Long roleId, @Param("userIds") Long[] userIds);
|
||||
|
||||
public List<Long> selectRoleIdsByUserId(Long userId);
|
||||
}
|
||||
|
||||
@@ -203,4 +203,6 @@ public interface ISysUserService
|
||||
* @return 结果
|
||||
*/
|
||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||
|
||||
public SysUser getUser();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,14 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.validation.Validator;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.zf.foodpurchase.common.core.domain.entity.SysDept;
|
||||
import com.zf.foodpurchase.common.core.domain.model.LoginUser;
|
||||
import com.zf.foodpurchase.fdsafe.entity.School;
|
||||
import com.zf.foodpurchase.fdsafe.mapper.SchoolMapper;
|
||||
import com.zf.foodpurchase.system.mapper.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -22,11 +30,6 @@ import com.zf.foodpurchase.common.utils.spring.SpringUtils;
|
||||
import com.zf.foodpurchase.system.domain.SysPost;
|
||||
import com.zf.foodpurchase.system.domain.SysUserPost;
|
||||
import com.zf.foodpurchase.system.domain.SysUserRole;
|
||||
import com.zf.foodpurchase.system.mapper.SysPostMapper;
|
||||
import com.zf.foodpurchase.system.mapper.SysRoleMapper;
|
||||
import com.zf.foodpurchase.system.mapper.SysUserMapper;
|
||||
import com.zf.foodpurchase.system.mapper.SysUserPostMapper;
|
||||
import com.zf.foodpurchase.system.mapper.SysUserRoleMapper;
|
||||
import com.zf.foodpurchase.system.service.ISysConfigService;
|
||||
import com.zf.foodpurchase.system.service.ISysDeptService;
|
||||
import com.zf.foodpurchase.system.service.ISysUserService;
|
||||
@@ -53,18 +56,27 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
@Autowired
|
||||
private SysUserRoleMapper userRoleMapper;
|
||||
|
||||
@Autowired
|
||||
private SysRoleDeptMapper roleDeptMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserPostMapper userPostMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
@Autowired
|
||||
private SysDeptMapper deptMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
|
||||
@Autowired
|
||||
protected Validator validator;
|
||||
|
||||
@Autowired
|
||||
private SchoolMapper schoolMapper;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
@@ -547,4 +559,66 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
}
|
||||
return successMsg.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysUser getUser() {
|
||||
LoginUser loginUser;
|
||||
try {
|
||||
loginUser = (LoginUser) SecurityUtils.getLoginUser();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
if (ObjectUtil.isNull(loginUser) || ObjectUtil.isNull(loginUser.getUser())
|
||||
|| ObjectUtil.isNull(loginUser.getUser().getUserId())) {
|
||||
return null;
|
||||
}
|
||||
Long userId = loginUser.getUser().getUserId();
|
||||
SysUser sysUser = userMapper.selectUserById(userId);
|
||||
if (ObjectUtil.isNull(sysUser)) {
|
||||
return null;
|
||||
}
|
||||
if (ObjectUtil.isNotNull(sysUser.getAccountDeptId())){
|
||||
sysUser.setSupplierId(sysUser.getAccountDeptId());
|
||||
}
|
||||
if (ObjectUtil.isNotNull(sysUser.getOrganiId())){
|
||||
sysUser.setSchoolId(sysUser.getOrganiId());
|
||||
School school = schoolMapper.selectById(sysUser.getOrganiId());
|
||||
if(ObjectUtil.isNotNull( school)){
|
||||
sysUser.setEduId(school.getEduId());
|
||||
}
|
||||
}
|
||||
|
||||
List<Long> roleIds = userRoleMapper.selectRoleIdsByUserId(userId);
|
||||
if (CollectionUtil.isEmpty(roleIds)) {
|
||||
return sysUser;
|
||||
}
|
||||
List<SysRole> roles = roleMapper.selectRolesByIds(roleIds);
|
||||
if (CollectionUtil.isEmpty(roles)) {
|
||||
return sysUser;
|
||||
}
|
||||
List<Long> userRoleIds = roles.stream()
|
||||
.map(SysRole::getRoleId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
sysUser.setRoles(roles);
|
||||
sysUser.setRoleIdList(userRoleIds);
|
||||
List<Long> deptIds = roleDeptMapper.selectDeptIdsByRoleIds(userRoleIds);
|
||||
if (CollectionUtil.isEmpty(deptIds)) {
|
||||
return sysUser;
|
||||
}
|
||||
List<Integer> deptIdInts = deptIds.stream()
|
||||
.distinct()
|
||||
.map(Long::intValue)
|
||||
.collect(Collectors.toList());
|
||||
List<SysDept> sysDepts = deptMapper.selectIdByDeptIds(deptIdInts);
|
||||
if (CollectionUtil.isEmpty(sysDepts)) {
|
||||
return sysUser;
|
||||
}
|
||||
List<Long> deptIdList = sysDepts.stream()
|
||||
.map(dept -> Long.valueOf(dept.getDeptId()))
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
sysUser.setDeptIdList(deptIdList);
|
||||
return sysUser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,28 +4,47 @@
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
fp.food_product_id, fp.food_id, fp.price, fp.supplier_id, fp.edu_id, fp.remark, fp.check_remark, fp.check_status, fp.create_time, fp.update_time, fp.check_time
|
||||
fp.food_product_id, fp.food_id, fp.price, fp.supplier_id, fp.edu_id, fp.remark, fp.check_remark, fp.check_status, fp.create_time, fp.update_time, fp.check_time,
|
||||
fp.num, fp.name, fp.type_id,fp.unit_id,fp.spec_id
|
||||
</sql>
|
||||
<select id="queryFoodProductVO" resultType="com.zf.foodpurchase.fdsafe.vo.FoodProductVO">
|
||||
select
|
||||
<include refid="Base_Column_List"/>,
|
||||
f.food_name, f.type_id,ft.type_label,f.unit_id, fu.unit_label, ed.edu_name,sp.supplier_name,sp.del_flag
|
||||
from food_product fp
|
||||
left join edu ed on ed.edu_id = fp.edu_id
|
||||
left join food f on f.food_id = fp.food_id
|
||||
left join food_type ft on ft.type_id = f.type_id
|
||||
left join food_unit fu on fu.unit_id = f.unit_id
|
||||
left join supplier sp on sp.supplier_id = fp.supplier_id
|
||||
|
||||
|
||||
SELECT
|
||||
ft.type_label,fu.unit_label,fs.spec_label,
|
||||
ed.edu_name,sp.supplier_name,sp.del_flag,fp.food_product_id,
|
||||
fp.food_id,fp.price,fp.supplier_id,fp.edu_id,fp.remark,
|
||||
fp.check_remark,fp.check_status,fp.create_time,fp.update_time,
|
||||
fp.check_time,fp.num,fp.name,fp.type_id,fp.unit_id,fp.spec_id,
|
||||
IFNULL(r.totalProductNum, 0) AS totalProductNum
|
||||
FROM food_product fp
|
||||
LEFT JOIN edu ed ON ed.edu_id = fp.edu_id
|
||||
LEFT JOIN food_type ft ON ft.type_id = fp.type_id
|
||||
LEFT JOIN food_unit fu ON fu.unit_id = fp.unit_id
|
||||
LEFT JOIN food_spec fs ON fs.spec_id = fp.spec_id
|
||||
-- 供货商过滤条件移到ON,保留无供货商商品
|
||||
LEFT JOIN supplier sp
|
||||
ON sp.supplier_id = fp.supplier_id
|
||||
AND sp.status = 1
|
||||
AND sp.del_flag = 0
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
food_product_id,
|
||||
SUM(food_product_num) AS totalProductNum
|
||||
FROM food_repo
|
||||
<where>
|
||||
<if test="repoId != null">
|
||||
repo_id = #{repoId}
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY food_product_id
|
||||
) r ON r.food_product_id = fp.food_product_id
|
||||
<where>
|
||||
sp.status = 1 and sp.del_flag = 0 and f.del_flag = 0
|
||||
<if test="foodProductId != null">
|
||||
and fp.food_product_id = #{foodProductId}
|
||||
fp.food_product_id = #{foodProductId}
|
||||
</if>
|
||||
<if test="foodId != null">
|
||||
and fp.food_id = #{foodId}
|
||||
</if>
|
||||
<!-- typeId过滤如果需要保留无分类商品 -->
|
||||
<if test="typeId !=null">
|
||||
and ft.type_id = #{typeId}
|
||||
</if>
|
||||
@@ -38,8 +57,8 @@
|
||||
<if test="checkStatus != null">
|
||||
and fp.check_status = #{checkStatus}
|
||||
</if>
|
||||
<if test="foodName !=null and foodName !=''">
|
||||
and f.food_name like concat('%',#{foodName},'%')
|
||||
<if test="name !=null and name !=''">
|
||||
and fp.name like concat('%',#{name},'%')
|
||||
</if>
|
||||
<if test="delFlag != null">
|
||||
and fp.del_flag = #{delFlag}
|
||||
@@ -48,4 +67,17 @@
|
||||
order by fp.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="pageCKList" resultType="com.zf.foodpurchase.fdsafe.vo.FoodProductCKVO">
|
||||
select a.food_product_id,a.num,a.name,c.repo_name repoName,d.spec_label specName,
|
||||
b.food_product_num foodProductNum,e.unit_label unitName,a.supplier_id supplierId,
|
||||
a.type_id typeId,b.repo_id repoId,c.merchant_id deptId,a.price
|
||||
from food_product a
|
||||
left join food_repo b on a.food_product_id=b.food_product_id
|
||||
left join repository c on b.repo_id=c.id
|
||||
left join food_spec d on a.spec_id=d.spec_id
|
||||
left join food_unit e on a.unit_id=e.unit_id
|
||||
where b.repo_id=#{repoId}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
38
fp-system/src/main/resources/mapper/FoodRepoMapper.xml
Normal file
38
fp-system/src/main/resources/mapper/FoodRepoMapper.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zf.foodpurchase.fdsafe.mapper.FoodRepoMapper">
|
||||
|
||||
<insert id="insert" parameterType="FoodRepo" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into food_repo(
|
||||
<if test="foodProductId != null">food_product_id,</if>
|
||||
<if test="repoId != null">repo_id,</if>
|
||||
<if test="orderNo != null and orderNo != ''">order_no,</if>
|
||||
<if test="orderItemNo != null and orderItemNo != ''">order_item_no,</if>
|
||||
<if test="foodProductNum != null">food_product_num</if>
|
||||
)values(
|
||||
<if test="foodProductId != null">#{foodProductId},</if>
|
||||
<if test="repoId != null">#{repoId},</if>
|
||||
<if test="orderNo != null and orderNo != ''">#{orderNo},</if>
|
||||
<if test="orderItemNo != null and orderItemNo != ''">#{orderItemNo},</if>
|
||||
<if test="foodProductNum != null">#{foodProductNum}</if>)
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
update food_repo
|
||||
<set>
|
||||
<if test="foodProductId != null">food_product_id=#{foodProductId},</if>
|
||||
<if test="repoId != null">repo_id=#{repoId},</if>
|
||||
<if test="orderNo != null and orderNo != ''">order_no=#{orderNo},</if>
|
||||
<if test="orderItemNo != null and orderItemNo != ''">order_item_no=#{orderItemNo},</if>
|
||||
<if test="foodProductNum != null">food_product_num=#{foodProductNum}</if>
|
||||
</set>
|
||||
where id=#{id}
|
||||
</update>
|
||||
|
||||
|
||||
<select id="selectByProductIdAndRepoId" resultType="FoodRepo">
|
||||
select id, food_product_id foodProductId, repo_id repoId, order_no orderNo, order_item_no orderItemNo, food_product_num foodProductNum
|
||||
from food_repo where food_product_id=#{productId} and repo_id=#{repoId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
30
fp-system/src/main/resources/mapper/FoodSpecMapper.xml
Normal file
30
fp-system/src/main/resources/mapper/FoodSpecMapper.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zf.foodpurchase.fdsafe.mapper.FoodSpecMapper">
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
spec_id, spec_label, del_flag, create_time, update_time,status
|
||||
</sql>
|
||||
<select id="queryFoodSpecVO" resultType="com.zf.foodpurchase.fdsafe.vo.FoodSpecVO"
|
||||
parameterType="com.zf.foodpurchase.fdsafe.vo.FoodSpecVO">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from food_spec
|
||||
<where>
|
||||
<if test="specId != null and specId != ''">
|
||||
and spec_id = #{specId}
|
||||
</if>
|
||||
<if test="specLabel != null and specLabel != ''">
|
||||
and spec_label like concat('%',#{specLabel},'%')
|
||||
</if>
|
||||
<if test="delFlag != null">
|
||||
and del_flag = #{delFlag}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
and status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,211 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zf.foodpurchase.fdsafe.mapper.ProductsMapper">
|
||||
|
||||
<resultMap type="com.zf.foodpurchase.fdsafe.entity.Products" id="ProductsResult">
|
||||
<result property="productId" column="product_id" />
|
||||
<result property="merchantId" column="merchant_id" />
|
||||
<result property="merchantName" column="dept_name" />
|
||||
<result property="productName" column="product_name" />
|
||||
<result property="description" column="description" />
|
||||
<result property="basePrice" column="base_price" />
|
||||
<result property="totalStock" column="total_stock" />
|
||||
<result property="images" column="images" />
|
||||
<result property="categoryId" column="category_id" />
|
||||
<result property="status" column="status" />
|
||||
<result property="type" column="type" />
|
||||
<result property="baseIntegral" column="base_integral" />
|
||||
<result property="baseReturnIntergral" column="base_return_intergral" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="operId" column="oper_id" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="detailImages" column="detail_images" />
|
||||
<result property="isSpecs" column="is_specs" />
|
||||
<result property="sailCount" column="sail_count" />
|
||||
<result property="hot" column="hot" />
|
||||
<result property="recommend" column="recommend" />
|
||||
<result property="isNew" column="is_new" />
|
||||
<result property="version" column="version" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectProductsVo">
|
||||
select product_id, merchant_id,
|
||||
d.dept_name as dept_name, product_name,
|
||||
description, base_price, total_stock,
|
||||
images, category_id, p.status as status,
|
||||
type, base_integral, base_return_intergral,
|
||||
p.create_time, p.update_time, oper_id,
|
||||
p.del_flag as del_flag, detail_images ,
|
||||
is_specs,
|
||||
sail_count, hot, recommend,
|
||||
is_new,version
|
||||
from products p inner join sys_dept d on d.dept_id = p.merchant_id
|
||||
</sql>
|
||||
|
||||
<select id="selectProductsList" parameterType="com.zf.foodpurchase.fdsafe.entity.Products" resultMap="ProductsResult">
|
||||
<include refid="selectProductsVo"/>
|
||||
<where>
|
||||
<if test="merchantId != null "> and p.merchant_id = #{merchantId}</if>
|
||||
<if test="productName != null and productName != ''"> and p.product_name like concat('%', #{productName}, '%')</if>
|
||||
<if test="merchantName != null and merchantName != ''"> and d.dept_name like concat('%', #{merchantName}, '%')</if>
|
||||
<if test="params.beginBasePrice != null and params.beginBasePrice != '' and params.endBasePrice != null and params.endBasePrice != ''"> and p.base_price between #{params.beginBasePrice} and #{params.endBasePrice}</if>
|
||||
<if test="categoryId != null "> and p.category_id = #{categoryId}</if>
|
||||
<if test="status != null "> and p.status = #{status}</if>
|
||||
<if test="type != null "> and p.type = #{type}</if>
|
||||
<if test="basePrice != null "> and p.base_price <= #{basePrice}</if>
|
||||
<if test="sailCount != null">and p.sail_count= #{sailCount},</if>
|
||||
<if test="hot != null and hot!=''">and p.hot=#{hot},</if>
|
||||
<if test="recommend != null and recommend">and p.recommend=#{recommend},</if>
|
||||
<if test="isNew != null and isNew">and p.is_new=#{isNew},</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectHotProducts" parameterType="com.zf.foodpurchase.fdsafe.entity.Products" resultMap="ProductsResult">
|
||||
<include refid="selectProductsVo"/>
|
||||
<where>
|
||||
p.hot = '1'
|
||||
and p.status = '1'
|
||||
<if test="merchantId != null "> and p.merchant_id = #{merchantId}</if>
|
||||
order by p.create_time desc
|
||||
limit #{limitNum}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectRecommendProducts" parameterType="com.zf.foodpurchase.fdsafe.entity.Products" resultMap="ProductsResult">
|
||||
<include refid="selectProductsVo"/>
|
||||
<where>
|
||||
p.recommend = '1'
|
||||
and p.status = '1'
|
||||
<if test="merchantId != null "> and p.merchant_id = #{merchantId}</if>
|
||||
order by p.create_time desc
|
||||
limit #{limitNum}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectNewProductsList" parameterType="com.zf.foodpurchase.fdsafe.entity.Products" resultMap="ProductsResult">
|
||||
<include refid="selectProductsVo"/>
|
||||
<where>
|
||||
p.status = '1'
|
||||
and p.is_new = '1'
|
||||
<if test="merchantId != null "> and p.merchant_id = #{merchantId}</if>
|
||||
order by p.create_time desc
|
||||
limit #{limitNum}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSailCountProducts" parameterType="com.zf.foodpurchase.fdsafe.entity.Products" resultMap="ProductsResult">
|
||||
<include refid="selectProductsVo"/>
|
||||
<where>
|
||||
p.status = '1'
|
||||
<if test="merchantId != null "> and p.merchant_id = #{merchantId}</if>
|
||||
order by p.sail_count desc
|
||||
limit #{limitNum}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<select id="selectProductsByProductId" parameterType="Integer" resultMap="ProductsResult">
|
||||
<include refid="selectProductsVo"/>
|
||||
where product_id = #{productId} and p.del_flag = '0'
|
||||
</select>
|
||||
|
||||
<insert id="insertProducts" parameterType="com.zf.foodpurchase.fdsafe.entity.Products" useGeneratedKeys="true" keyProperty="productId">
|
||||
insert into products
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="merchantId != null">merchant_id,</if>
|
||||
<if test="productName != null and productName != ''">product_name,</if>
|
||||
<if test="description != null">description,</if>
|
||||
<if test="basePrice != null">base_price,</if>
|
||||
<if test="totalStock != null">total_stock,</if>
|
||||
<if test="images != null">images,</if>
|
||||
<if test="categoryId != null">category_id,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="type != null">type,</if>
|
||||
<if test="baseIntegral != null">base_integral,</if>
|
||||
<if test="baseReturnIntergral != null">base_return_intergral,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="operId != null">oper_id,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="detailImages != null">detail_images,</if>
|
||||
<if test="isSpecs != null">is_specs,</if>
|
||||
<if test="sailCount != null">sail_count,</if>
|
||||
<if test="hot != null and hot!=''">hot,</if>
|
||||
<if test="recommend != null and recommend!=''">recommend,</if>
|
||||
<if test="isNew != null and isNew!=''">is_new,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="merchantId != null">#{merchantId},</if>
|
||||
<if test="productName != null and productName != ''">#{productName},</if>
|
||||
<if test="description != null">#{description},</if>
|
||||
<if test="basePrice != null">#{basePrice},</if>
|
||||
<if test="totalStock != null">#{totalStock},</if>
|
||||
<if test="images != null">#{images},</if>
|
||||
<if test="categoryId != null">#{categoryId},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
<if test="baseIntegral != null">#{baseIntegral},</if>
|
||||
<if test="baseReturnIntergral != null">#{baseReturnIntergral},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="operId != null">#{operId},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="detailImages != null">#{detailImages},</if>
|
||||
<if test="isSpecs != null">#{isSpecs},</if>
|
||||
<if test="sailCount != null">#{sailCount},</if>
|
||||
<if test="hot != null and recommend!=''">#{hot},</if>
|
||||
<if test="recommend != null and recommend!=''">#{recommend},</if>
|
||||
<if test="isNew != null and isNew!=''">#{isNew},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateProducts" parameterType="com.zf.foodpurchase.fdsafe.entity.Products">
|
||||
update products
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="merchantId != null">merchant_id = #{merchantId},</if>
|
||||
<if test="productName != null and productName != ''">product_name = #{productName},</if>
|
||||
<if test="description != null">description = #{description},</if>
|
||||
<if test="basePrice != null">base_price = #{basePrice},</if>
|
||||
<if test="totalStock != null">total_stock = #{totalStock},</if>
|
||||
<if test="images != null">images = #{images},</if>
|
||||
<if test="categoryId != null">category_id = #{categoryId},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="baseIntegral != null">base_integral = #{baseIntegral},</if>
|
||||
<if test="baseReturnIntergral != null">base_return_intergral = #{baseReturnIntergral},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="operId != null">oper_id = #{operId},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="detailImages != null">detail_images = #{detailImages},</if>
|
||||
<if test="isSpecs != null">is_specs = #{isSpecs},</if>
|
||||
<if test="sailCount != null">sail_count= #{sailCount},</if>
|
||||
<if test="hot != null and hot!=''">hot=#{hot},</if>
|
||||
<if test="recommend != null and recommend!=''">recommend=#{recommend},</if>
|
||||
<if test="isNew != null and isNew!=''">is_new=#{isNew},</if>
|
||||
<if test="version != null">version=#{version}+1,</if>
|
||||
</trim>
|
||||
where product_id = #{productId} and version=#{version}
|
||||
</update>
|
||||
|
||||
<delete id="deleteProductsByProductId" parameterType="Long">
|
||||
delete from products where product_id = #{productId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteProductsByProductIds" parameterType="String">
|
||||
delete from products where product_id in
|
||||
<foreach item="productId" collection="array" open="(" separator="," close=")">
|
||||
#{productId}
|
||||
</foreach>
|
||||
</delete>
|
||||
<update id="deleteProductsLogicByProductIds">
|
||||
update products set del_flag = '1' where product_id in
|
||||
<foreach item="productId" collection="array" open="(" separator="," close=")">
|
||||
#{productId}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zf.foodpurchase.fdsafe.mapper.ProductsSpecMapper">
|
||||
|
||||
<update id="updateProductsSpec">
|
||||
update products_spec
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="productId != null">product_id = #{productId},</if>
|
||||
<if test="specValues != null">spec_values = #{specValues},</if>
|
||||
<if test="price != null">price = #{price},</if>
|
||||
<if test="stock != null">stock = #{stock},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
<if test="integral != null">integral = #{integral},</if>
|
||||
<if test="returnIntegral != null">return_integral = #{returnIntegral},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="operId != null">oper_id = #{operId},</if>
|
||||
<if test="specImage != null">spec_image = #{specImage},</if>
|
||||
<if test="psVersion != null">ps_version = #{psVersion}+1,</if>
|
||||
</trim>
|
||||
where id = #{id} and ps_version=#{psVersion}
|
||||
</update>
|
||||
|
||||
|
||||
<select id="selectMinOne" parameterType="Integer" resultType="java.util.Map">
|
||||
select min(integral) as integral, min(price) as price from products_spec where product_id=#{productId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
86
fp-system/src/main/resources/mapper/RepoRecordMapper.xml
Normal file
86
fp-system/src/main/resources/mapper/RepoRecordMapper.xml
Normal file
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zf.foodpurchase.fdsafe.mapper.RepoRecordMapper">
|
||||
|
||||
<resultMap id="RepoRecordResultMap" type="com.zf.foodpurchase.fdsafe.entity.RepoRecord">
|
||||
<id column="id" property="id"/>
|
||||
<result column="apply_date" property="applyDate"/>
|
||||
<result column="supplier_id" property="supplierId"/>
|
||||
<result column="category_id" property="categoryId"/>
|
||||
<result column="repo_id" property="repoId"/>
|
||||
<result column="product_id" property="productId"/>
|
||||
<result column="product_num" property="productNum"/>
|
||||
<result column="total_cost" property="totalCost"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="msg" property="msg"/>
|
||||
<result column="school_id" property="schoolId"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="selectRepoRecordByRepoRecordId" resultType="com.zf.foodpurchase.fdsafe.vo.RepoRecordVO">
|
||||
select re.id,re.apply_date,re.supplier_id,re.category_id,re.repo_id,re.product_id,
|
||||
re.product_num,p.name,re.total_cost,re.status,re.msg,fd.type_label categoryName,
|
||||
sd.dept_name merchantName, rep.repo_name repoName,re.total_cost totalCost from repo_record re
|
||||
left join food_type fd on re.category_id=fd.type_id
|
||||
left join sys_dept sd on re.supplier_id=sd.dept_id
|
||||
left join repository rep on re.repo_id = rep.id
|
||||
left join food_product p on re.product_id=p.food_product_id WHERE re.id = #{repoRecordId}
|
||||
</select>
|
||||
|
||||
<insert id="insertRepoRecord" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
|
||||
INSERT INTO repo_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="applyDate != null">apply_date,</if>
|
||||
<if test="supplierId != null">supplier_id,</if>
|
||||
<if test="categoryId != null">category_id,</if>
|
||||
<if test="repoId != null">repo_id,</if>
|
||||
<if test="productId != null">product_id,</if>
|
||||
<if test="productNum != null">product_num,</if>
|
||||
<if test="totalCost != null">total_cost,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="msg != null and msg != ''">msg,</if>
|
||||
<if test="schoolId != null">school_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="applyDate != null">#{applyDate},</if>
|
||||
<if test="supplierId != null">#{supplierId,jdbcType=INTEGER},</if>
|
||||
<if test="categoryId != null">#{categoryId,jdbcType=INTEGER},</if>
|
||||
<if test="repoId != null">#{repoId,jdbcType=INTEGER},</if>
|
||||
<if test="productId != null">#{productId,jdbcType=INTEGER},</if>
|
||||
<if test="productNum != null">#{productNum,jdbcType=INTEGER},</if>
|
||||
<if test="totalCost != null">#{totalCost},</if>
|
||||
<if test="status != null">#{status,jdbcType=INTEGER},</if>
|
||||
<if test="msg != null and msg != ''">#{msg,jdbcType=VARCHAR},</if>
|
||||
<if test="schoolId != null">#{schoolId,jdbcType=BIGINT},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<select id="selectRepoRecordList" resultType="com.zf.foodpurchase.fdsafe.vo.RepoRecordVO">
|
||||
select re.id,re.apply_date,re.supplier_id,re.category_id,re.repo_id,re.product_id,
|
||||
re.product_num,p.name,re.total_cost,re.status,re.msg,fd.type_label categoryName,
|
||||
sd.dept_name merchantName, rep.repo_name repoName,re.total_cost totalCost from repo_record re
|
||||
left join food_type fd on re.category_id=fd.type_id
|
||||
left join sys_dept sd on re.supplier_id=sd.dept_id
|
||||
left join repository rep on re.repo_id = rep.id
|
||||
left join food_product p on re.product_id=p.food_product_id
|
||||
<where>
|
||||
<if test="repoId != null">
|
||||
AND re.repo_id = #{repoId,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="productName != null and productName != ''">
|
||||
AND p.name LIKE CONCAT('%', #{productName,jdbcType=VARCHAR}, '%')
|
||||
</if>
|
||||
<if test="categoryId != null">
|
||||
AND fd.type_id = #{categoryId,jdbcType=INTEGER}
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
AND re.apply_date >= #{startTime,jdbcType=DATETIME}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND re.apply_date <= #{endTime,jdbcType=DATETIME}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -6,6 +6,7 @@
|
||||
<id column="id" property="id" />
|
||||
<result column="merchant_id" property="merchantId" />
|
||||
<result column="merchant_name" property="merchantName" />
|
||||
<result column="repo_num" property="repoNum" />
|
||||
<result column="repo_name" property="repoName" />
|
||||
<result column="area_code" property="areaCode" />
|
||||
<result column="detail_address" property="detailAddress" />
|
||||
@@ -13,13 +14,16 @@
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="oper_id" property="operId" />
|
||||
<result column="manager" property="manager" />
|
||||
<result column="order_num" property="orderNum" />
|
||||
</resultMap>
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="joinColumn">
|
||||
select r.id, r.merchant_id,r.repo_name, r.area_code, r.detail_address, r.default_repo, r.create_time, r.update_time, r.oper_id,d.dept_name as merchant_name
|
||||
select r.id, r.merchant_id,r.repo_num, r.repo_name, r.area_code, r.detail_address, r.default_repo, r.create_time, r.update_time, r.oper_id,
|
||||
r.manager, r.order_num, d.dept_name as merchant_name
|
||||
from repository r left join sys_dept d on r.merchant_id = d.dept_id
|
||||
</sql>
|
||||
<select id="joinQueryList" resultType="com.zf.foodpurchase.fdsafe.entity.Repository"
|
||||
<select id="queryRepoList" resultType="com.zf.foodpurchase.fdsafe.entity.Repository"
|
||||
parameterType="com.zf.foodpurchase.fdsafe.entity.Repository">
|
||||
<include refid="joinColumn"/>
|
||||
<where>
|
||||
@@ -32,6 +36,15 @@
|
||||
<if test="createTime != null ">and r.create_time = #{createTime}</if>
|
||||
<if test="updateTime != null ">and r.update_time = #{updateTime}</if>
|
||||
<if test="merchantName != null and merchantName !='' ">and d.dept_name like concat('%', #{merchantName}, '%') </if>
|
||||
<if test="repoNum != null and repoNum !='' ">and r.repo_num =#{repoNum} </if>
|
||||
<if test="manager != null ">and r.manager = #{manager}</if>
|
||||
<if test="orderNum != null ">and r.order_num = #{orderNum}</if>
|
||||
<if test="deptIds != null and deptIds.size() > 0">
|
||||
and d.dept_id in
|
||||
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
@@ -39,6 +39,12 @@
|
||||
<if test="supplierName != null and supplierName !=''">
|
||||
and su.supplier_name like concat('%',#{supplierName},'%')
|
||||
</if>
|
||||
<if test="deptIds != null and deptIds.size() > 0">
|
||||
and ci.school_id in
|
||||
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
order by ci.update_time desc
|
||||
</select>
|
||||
|
||||
@@ -53,5 +53,4 @@
|
||||
</where>
|
||||
order by soi.order_item_no desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
so.order_no, so.supplier_id, so.school_id, so.edu_id, so.operator_person, so.operator_phone, so.total_money, so.refund_money, so.order_status, so.delivery_date, so.create_time, so.update_time, so.cancel_time, so.cancel_reason,so.order_remark,so.order_settle_status
|
||||
so.order_no, so.supplier_id, so.school_id, so.edu_id, so.operator_person, so.operator_phone, so.total_money, so.refund_money, so.order_status, so.delivery_date, so.create_time, so.update_time, so.cancel_time, so.cancel_reason,so.order_remark,so.order_settle_status,
|
||||
so.sign_person,so.sign_time,so.sign_image
|
||||
</sql>
|
||||
|
||||
<select id="querySchoolOrderVO" resultType="com.zf.foodpurchase.fdsafe.vo.SchoolOrderVO"
|
||||
parameterType="com.zf.foodpurchase.fdsafe.vo.SchoolOrderVO">
|
||||
select<include refid="Base_Column_List"/>,
|
||||
@@ -39,8 +41,68 @@
|
||||
<if test = 'orderSettleStatus !=null'>
|
||||
and so.order_settle_status = #{orderSettleStatus}
|
||||
</if>
|
||||
<if test="deptIds != null and deptIds.size() > 0">
|
||||
and s.school_id in
|
||||
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
order by so.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="querySupplierOrderVO" resultType="com.zf.foodpurchase.fdsafe.vo.SchoolOrderVO"
|
||||
parameterType="com.zf.foodpurchase.fdsafe.vo.SchoolOrderVO">
|
||||
select<include refid="Base_Column_List"/>,
|
||||
e.edu_name, s.school_name, su.supplier_name
|
||||
from school_order so
|
||||
left join edu e on so.edu_id = e.edu_id
|
||||
left join school s on so.school_id = s.school_id
|
||||
left join supplier su on so.supplier_id = su.supplier_id
|
||||
<where>
|
||||
<if test="orderNo != null and orderNo != ''">
|
||||
and so.order_no = #{orderNo}
|
||||
</if>
|
||||
<if test="supplierId != null">
|
||||
and so.supplier_id = #{supplierId}
|
||||
</if>
|
||||
<if test="schoolId != null">
|
||||
and so.school_id = #{schoolId}
|
||||
</if>
|
||||
<if test="eduId != null">
|
||||
and so.edu_id = #{eduId}
|
||||
</if>
|
||||
<if test="orderStatus != null">
|
||||
and so.order_status = #{orderStatus}
|
||||
</if>
|
||||
<if test="beginTime != null">
|
||||
AND date_format(so.create_time,'%Y%m%d') >= date_format(#{beginTime},'%Y%m%d')
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
and date_format(so.create_time,'%Y%m%d') <=date_format(#{endTime},'%Y%m%d')
|
||||
</if>
|
||||
<if test = 'orderSettleStatus !=null'>
|
||||
and so.order_settle_status = #{orderSettleStatus}
|
||||
</if>
|
||||
<if test="deptIds != null and deptIds.size() > 0">
|
||||
and su.supplier_id in
|
||||
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
order by so.create_time desc
|
||||
</select>
|
||||
|
||||
<update id="signOrder" parameterType="com.zf.foodpurchase.fdsafe.vo.SchoolOrderVO">
|
||||
update school_order
|
||||
<set>
|
||||
<if test="orderStatus != null">order_status = #{orderStatus},</if>
|
||||
<if test="signPerson != null and signPerson != ''">sign_person = #{signPerson},</if>
|
||||
<if test="signTime != null">sign_time = #{signTime},</if>
|
||||
<if test="signImage != null and signImage != ''">sign_image = #{signImage},</if>
|
||||
</set>
|
||||
where order_no = #{orderNo}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zf.foodpurchase.fdsafe.mapper.SpecTypesMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zf.foodpurchase.fdsafe.mapper.SpecValuesMapper">
|
||||
<sql id="baseColumn">
|
||||
select
|
||||
id,
|
||||
spec_type as specType,
|
||||
spec_value as specValue,
|
||||
spec_unit as specUnit,
|
||||
create_time as createTime,
|
||||
update_time as updateTime,
|
||||
oper_id as operId
|
||||
from spec_values
|
||||
</sql>
|
||||
<sql id="joinColumn">
|
||||
SELECT
|
||||
v.id,
|
||||
v.spec_type AS specType,
|
||||
v.spec_value AS specValue,
|
||||
v.spec_unit AS specUnit,
|
||||
v.create_time AS createTime,
|
||||
v.update_time AS updateTime,
|
||||
v.oper_id AS operId,
|
||||
t.spec_name AS specName
|
||||
FROM
|
||||
spec_values v
|
||||
LEFT JOIN spec_types t ON v.spec_type = t.spec_type
|
||||
</sql>
|
||||
|
||||
<select id="queryList" resultType="com.zf.foodpurchase.fdsafe.entity.SpecValues" parameterType="com.zf.foodpurchase.fdsafe.entity.SpecValues">
|
||||
<include refid="joinColumn"/>
|
||||
<where>
|
||||
<if test="specType != null">
|
||||
and v.spec_type = #{specType}
|
||||
</if>
|
||||
<if test="specValue != null">
|
||||
and v.spec_value = #{specValue}
|
||||
</if>
|
||||
<if test="specUnit != null">
|
||||
and v.spec_unit =#{specUnit}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="queryByIds" resultType="com.zf.foodpurchase.fdsafe.entity.SpecValues">
|
||||
<include refid="joinColumn"/>
|
||||
<where>
|
||||
<if test="list != null">
|
||||
id in
|
||||
<foreach collection="list" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -30,5 +30,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
(#{item.roleId},#{item.deptId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
<select id="selectDeptIdsByRoleIds" resultType="Long">
|
||||
select distinct rd.dept_id from sys_role_dept rd left join sys_dept d on rd.dept_id=d.dept_id where d.del_flag='0' and d.status='0' and role_id in
|
||||
<foreach collection="roleIds" item="roleId" open="(" separator="," close=")">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -154,5 +154,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectRoleVo"/>
|
||||
where r.tenant_id = #{tenantId}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectRolesByIds" parameterType="Long" resultMap="SysRoleResult">
|
||||
<include refid="selectRoleVo"/>
|
||||
where r.del_flag='0' and r.status='0' and r.role_id in
|
||||
<foreach collection="roleIds" item="roleId" open="(" close=")" separator=",">
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -54,7 +54,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectUserVo">
|
||||
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, u.account_type ,u.account_dept_id,
|
||||
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password,
|
||||
u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
|
||||
u.account_type ,u.account_dept_id, u.organi_id, u.account_type,
|
||||
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
|
||||
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
|
||||
from sys_user u
|
||||
|
||||
@@ -41,4 +41,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{userId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectRoleIdsByUserId" resultType="Long">
|
||||
select role_id from sys_user_role where user_id=#{userId}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -219,5 +219,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</foreach>
|
||||
</if>
|
||||
</update>
|
||||
<select id="selectIdByDeptIds" resultType="SysDept">
|
||||
|
||||
SELECT distinct dept_id, dept_name label, parent_id, status
|
||||
FROM sys_dept
|
||||
where del_flag = 0 and status = '0'
|
||||
<if test="deptIds != null and deptIds.size() > 0">
|
||||
and dept_id in
|
||||
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user