添加项目前缀,报404接口补全
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
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.fdsafe.entity.Browse;
|
||||
import com.zf.foodpurchase.fdsafe.service.IBrowseService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品浏览记录表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-15
|
||||
*/
|
||||
@Api(tags = "商品浏览记录")
|
||||
@RestController
|
||||
@RequestMapping("/merchant/browse")
|
||||
public class MeBrowseController extends BaseController {
|
||||
@Autowired
|
||||
private IBrowseService browseService;
|
||||
|
||||
// 需要关联商品信息,关联查询.
|
||||
@ApiOperation("查询用户浏览记录")
|
||||
@GetMapping("list")
|
||||
public AjaxResult list() {
|
||||
SysUser user = getLoginUser().getUser();
|
||||
Browse browse = new Browse();
|
||||
if (!user.isAdmin()) {
|
||||
browse.setMerchantId(user.getDeptId());
|
||||
}
|
||||
List<Browse> list = browseService.joinQueryList(browse);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@ApiOperation("查询用户浏览记录")
|
||||
@GetMapping("pageList")
|
||||
public TableDataInfo pageList(Browse browse) {
|
||||
startPage();
|
||||
SysUser user = getLoginUser().getUser();
|
||||
if (!user.isAdmin()) {
|
||||
browse.setMerchantId(user.getDeptId());
|
||||
}else{
|
||||
browse.setMerchantId(null);
|
||||
}
|
||||
List<Browse> list = browseService.joinQueryList(browse);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.zf.foodpurchase.fdsafe.web.merchant;
|
||||
|
||||
import com.zf.foodpurchase.common.constant.Constants;
|
||||
import com.zf.foodpurchase.common.constant.UserConstants;
|
||||
import com.zf.foodpurchase.common.core.controller.BaseController;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.common.core.domain.entity.SysDept;
|
||||
import com.zf.foodpurchase.common.core.domain.entity.SysUser;
|
||||
import com.zf.foodpurchase.system.service.ISysDeptService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:lilj
|
||||
* @date:2024/12/17
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("admin/merchant")
|
||||
public class MerchantController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ISysDeptService sysDeptService;
|
||||
|
||||
@GetMapping("/merchantQuery")
|
||||
public AjaxResult merchantQuery(){
|
||||
SysUser user = getLoginUser().getUser();
|
||||
if(!user.isAdmin()){
|
||||
return error("非管理员账号无法调用此接口");
|
||||
}
|
||||
|
||||
SysDept queryDept = new SysDept();
|
||||
// 只查询商户部门
|
||||
queryDept.setMerchantFlag("1");
|
||||
queryDept.setDelFlag(Constants.DEL_FLAG_NORMAL);
|
||||
queryDept.setStatus(UserConstants.DEPT_NORMAL);
|
||||
List<SysDept> depts = sysDeptService.selectDeptList(queryDept);
|
||||
return success(depts);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
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,130 @@
|
||||
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.Repository;
|
||||
import com.zf.foodpurchase.fdsafe.service.IRepositoryService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 仓库列表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-20
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/merchant/repository")
|
||||
public class RepositoryController extends BaseController {
|
||||
@Autowired
|
||||
private IRepositoryService repositoryService;
|
||||
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(Repository repository) {
|
||||
List<Repository> list = repositoryService.joinQueryList(getQuryRepository(repository));
|
||||
return AjaxResult.success("查询成功", list);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/pageList")
|
||||
public TableDataInfo pageList(Repository repository) {
|
||||
List<Repository> list = repositoryService.joinQueryList(getQuryRepository(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 {
|
||||
if(repository.getMerchantId() == null){
|
||||
return error("必须指定要添加的仓库所属商户");
|
||||
}
|
||||
}
|
||||
repository.setCreateTime(DateUtils.getNowDate());
|
||||
repository.setOperId(getUserId());
|
||||
return repositoryService.saveRepo(repository);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改前增加一步校验
|
||||
*
|
||||
* @param repository
|
||||
* @return
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,13 +12,6 @@ spring:
|
||||
url: jdbc:mysql://39.165.209.170:3307/zf_school_food?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: zheng_wXn_fan*QFs_6aNvFq@keji_qDr.gPYsfBL
|
||||
# 从库数据源
|
||||
slave:
|
||||
# 从数据源开关/默认关闭
|
||||
#enabled: false
|
||||
url: jdbc:mysql://39.165.209.170:3307/zf_shopping_mall?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: zheng_wXn_fan*QFs_6aNvFq@keji_qDr.gPYsfBL
|
||||
# 初始连接数
|
||||
initialSize: 5
|
||||
# 最小连接池数量
|
||||
|
||||
@@ -26,7 +26,7 @@ server:
|
||||
port: 8090
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
context-path: /schoolfood
|
||||
tomcat:
|
||||
# tomcat的URI编码
|
||||
uri-encoding: UTF-8
|
||||
@@ -79,9 +79,15 @@ spring:
|
||||
redis:
|
||||
# host: localhost
|
||||
# port: 6379
|
||||
host: 125.46.39.9
|
||||
database: 11
|
||||
password: zhengfan999
|
||||
# 地址
|
||||
host: 39.165.209.170
|
||||
# 端口,默认为6379 服务器密码:zhengfan999
|
||||
port: 6379
|
||||
# 数据库索引
|
||||
database: 0
|
||||
# 密码
|
||||
password: zheng_wXn_fan*QFs_6aNvFq@keji_qDr.gPYsfBL
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
lettuce:
|
||||
pool:
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品浏览记录表
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-15
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@TableName("browse")
|
||||
public class Browse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField("user_id")
|
||||
private Long userId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String nickName;
|
||||
|
||||
@NotNull(message="商家id不能为空")
|
||||
@TableField("merchant_id")
|
||||
private Long merchantId;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private String merchantName;
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
@NotNull(message="商品id不能为空")
|
||||
@TableField("product_id")
|
||||
private Long productId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 浏览开始时间
|
||||
*/
|
||||
@NotNull(message="浏览开始时间不能为空")
|
||||
@TableField("start_time")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 浏览结束时间
|
||||
*/
|
||||
@NotNull(message="浏览结束时间不能为空")
|
||||
@TableField("end_time")
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 浏览时间,单位:秒
|
||||
*/
|
||||
@TableField("remain_time")
|
||||
private Long remainTime;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
// @JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
// @JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date queryBeginTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
// @JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date queryEndTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.zf.foodpurchase.fdsafe.entity;
|
||||
|
||||
import com.zf.foodpurchase.common.annotation.Excel;
|
||||
import com.zf.foodpurchase.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 商户轮播图对象 carousel
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-11-29
|
||||
*/
|
||||
public class Carousel extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 一组轮播图id */
|
||||
@Excel(name = "一组轮播图id ")
|
||||
private Long carouselId;
|
||||
|
||||
/** 商户id */
|
||||
private Long merchantId;
|
||||
|
||||
|
||||
/** 商户名称 */
|
||||
private String merchantName;
|
||||
|
||||
/** 轮播图片url */
|
||||
@Excel(name = "轮播图片url")
|
||||
@NotBlank(message = "图片不能为空")
|
||||
private String carouselIamges;
|
||||
|
||||
public String getMerchantName() {
|
||||
return merchantName;
|
||||
}
|
||||
|
||||
public void setMerchantName(String merchantName) {
|
||||
this.merchantName = merchantName;
|
||||
}
|
||||
|
||||
public void setCarouselId(Long carouselId)
|
||||
{
|
||||
this.carouselId = carouselId;
|
||||
}
|
||||
|
||||
public Long getCarouselId()
|
||||
{
|
||||
return carouselId;
|
||||
}
|
||||
public void setMerchantId(Long merchantId)
|
||||
{
|
||||
this.merchantId = merchantId;
|
||||
}
|
||||
|
||||
public Long getMerchantId()
|
||||
{
|
||||
return merchantId;
|
||||
}
|
||||
public void setCarouselIamges(String carouselIamges)
|
||||
{
|
||||
this.carouselIamges = carouselIamges;
|
||||
}
|
||||
|
||||
public String getCarouselIamges()
|
||||
{
|
||||
return carouselIamges;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("carouselId", getCarouselId())
|
||||
.append("merchantId", getMerchantId())
|
||||
.append("carouselIamges", getCarouselIamges())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.zf.foodpurchase.fdsafe.entity;
|
||||
|
||||
/**
|
||||
* @author:lilj
|
||||
* @date:2024/12/24
|
||||
*/
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 级联数据结构
|
||||
*/
|
||||
@Data
|
||||
public class Cascade {
|
||||
|
||||
private String label;
|
||||
private Integer value;
|
||||
|
||||
private List<Cascade> children;
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
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 javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 物流订单信息
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-20
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class LogisticsInfo implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 订单项id
|
||||
*/
|
||||
@TableField("out_trade_no")
|
||||
@NotBlank(message = "订单号不能为空")
|
||||
private String outTradeNo;
|
||||
|
||||
/**
|
||||
* 物流公司名称
|
||||
*/
|
||||
@TableField("logistics_company")
|
||||
@NotBlank(message = "物流公司名称不能为空")
|
||||
private String logisticsCompany;
|
||||
|
||||
/**
|
||||
* 快递单号
|
||||
*/
|
||||
@TableField("tracking_no")
|
||||
@NotBlank(message = "快递单号不能为空")
|
||||
private String trackingNo;
|
||||
|
||||
/**
|
||||
* 快递状态
|
||||
*/
|
||||
@TableField("status")
|
||||
@NotNull(message = "快递状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 快递当前位置
|
||||
*/
|
||||
@TableField("current_location")
|
||||
@NotBlank(message = "快递当前位置不能为空")
|
||||
private String currentLocation;
|
||||
|
||||
/**
|
||||
* 发货位置
|
||||
*/
|
||||
@TableField("start_location")
|
||||
@NotBlank(message = "发货位置不能为空")
|
||||
private String startLocation;
|
||||
|
||||
/**
|
||||
* 收货位置
|
||||
*/
|
||||
@TableField("end_location")
|
||||
private String endLocation;
|
||||
|
||||
/**
|
||||
* 预计抵达时间
|
||||
*/
|
||||
@TableField("expected_delivery_date")
|
||||
private Date expectedDeliveryDate;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 商家id
|
||||
*/
|
||||
@TableField("merchant_id")
|
||||
private Long merchantId;
|
||||
|
||||
@TableField(exist = false )
|
||||
private String merchantName;
|
||||
|
||||
/**
|
||||
* 小程序用户id
|
||||
*/
|
||||
@TableField("user_id")
|
||||
private Long userId;
|
||||
|
||||
|
||||
@TableField(exist = false )
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 创建/更改物流信息人员id(商家/管理员)
|
||||
*/
|
||||
@TableField("oper_id")
|
||||
private Long operId;
|
||||
|
||||
@TableField("del_flag")
|
||||
private String delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String operName;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Date beginTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Date endTime;
|
||||
|
||||
/**
|
||||
* 发货时间
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private Date sendTime;
|
||||
|
||||
/**
|
||||
* 签收时间:
|
||||
* 根据orderItem是否增加签收时间来判断是否放开注释
|
||||
*/
|
||||
// @TableField(exist = false)
|
||||
// private Date signTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
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 2024-11-26
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class OrderItem implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 订单项
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 微信用户标识
|
||||
*/
|
||||
@TableField("openid")
|
||||
private String openid;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField("user_id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 微信支付订单号
|
||||
*/
|
||||
@TableField("transaction_id")
|
||||
private String transactionId;
|
||||
|
||||
/**
|
||||
* 微信合单商户订单号
|
||||
*/
|
||||
@TableField("combine_out_trade_no")
|
||||
private String combineOutTradeNo;
|
||||
|
||||
/**
|
||||
* 子单商户订单号
|
||||
*/
|
||||
@TableField("out_trade_no")
|
||||
private String outTradeNo;
|
||||
|
||||
/**
|
||||
* 父订单号
|
||||
*/
|
||||
@TableField("order_id")
|
||||
private Integer orderId;
|
||||
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
@TableField("product_id")
|
||||
private Integer productId;
|
||||
|
||||
/**
|
||||
* 商户id
|
||||
*/
|
||||
@TableField("merchant_id")
|
||||
private Long merchantId;
|
||||
|
||||
@TableField("merchant_name")
|
||||
private String merchantName;
|
||||
|
||||
/**
|
||||
* 规格JSON,[{规格类型:规格值},{规格类型:规格值}]
|
||||
*/
|
||||
@TableField("spec_str")
|
||||
private String specStr;
|
||||
|
||||
@TableField("spec_values")
|
||||
private String specValueIds;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@TableField("product_name")
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 商品价格
|
||||
*/
|
||||
@TableField("price")
|
||||
private Integer price;
|
||||
|
||||
/**
|
||||
* 购买类型:0 人民币购买;1 积分兑换
|
||||
*/
|
||||
@TableField("buy_type")
|
||||
private String buyType;
|
||||
|
||||
/**
|
||||
* 兑换所需积分
|
||||
*/
|
||||
@TableField("integral")
|
||||
private Integer integral;
|
||||
|
||||
/**
|
||||
* 购买数量
|
||||
*/
|
||||
@TableField("quantity")
|
||||
private Integer quantity;
|
||||
|
||||
/**
|
||||
* 商品url,用来订单中展示商品的缩略图
|
||||
*/
|
||||
@TableField("product_pic_url")
|
||||
private String productPicUrl;
|
||||
|
||||
/**
|
||||
* 支付时间
|
||||
*/
|
||||
@TableField("pay_time")
|
||||
private Date payTime;
|
||||
|
||||
/**
|
||||
* 发货时间
|
||||
*/
|
||||
@TableField("send_time")
|
||||
private Date sendTime;
|
||||
|
||||
/**
|
||||
* 交易成交时间
|
||||
*/
|
||||
@TableField("finish_time")
|
||||
private Date finishTime;
|
||||
|
||||
|
||||
/**
|
||||
* 订单创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 订单更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 订单状态:0 未支付;1 支付成功; 2 超时关闭; 3 用户取消; 4 已发货; 5 运输中; 6 已签收; 7 交易结束; 8 退款中;9 已退款; 10 退款异常; 11 物流异常
|
||||
*/
|
||||
@TableField("order_status")
|
||||
private Integer orderStatus;
|
||||
|
||||
/**
|
||||
* 是否逻辑删除
|
||||
逻辑删除:0 正常;1 已删除
|
||||
*/
|
||||
@TableField("del_flag")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 商品规格id
|
||||
*/
|
||||
@TableField("product_spec_id")
|
||||
private Integer productSpecId;
|
||||
|
||||
@TableField("product_description")
|
||||
private String productDescription;
|
||||
|
||||
@TableField("return_integral")
|
||||
private Integer returnIntegral;
|
||||
|
||||
@TableField("mchid")
|
||||
private String mchid;
|
||||
|
||||
@TableField("user_address_id")
|
||||
private Integer userAddressId;
|
||||
|
||||
@TableField("area_code")
|
||||
private String areaCode;
|
||||
|
||||
@TableField("detail_address")
|
||||
private String detailAddress;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String showAddress;
|
||||
|
||||
@TableField("phone_number")
|
||||
private String phoneNumber;
|
||||
|
||||
@TableField("logistics_id")
|
||||
private Integer logisticsId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private LogisticsInfo logisticsInfo;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String nickName;
|
||||
|
||||
@TableField("recp_name")
|
||||
private String recpName;
|
||||
}
|
||||
@@ -0,0 +1,496 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
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,89 @@
|
||||
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 javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 仓库列表
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-20
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
public class Repository implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@NotNull(message = "仓库名称不能为空")
|
||||
@TableField("repo_name")
|
||||
private String repoName;
|
||||
/**
|
||||
* 所属商户id
|
||||
*/
|
||||
@TableField("merchant_id")
|
||||
private Long merchantId;
|
||||
|
||||
|
||||
/**
|
||||
* 所属商户名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String merchantName;
|
||||
|
||||
/**
|
||||
* 区划编码
|
||||
*/
|
||||
// @NotNull(message = "所属区划不能为空")
|
||||
@TableField("area_code")
|
||||
private String areaCode;
|
||||
|
||||
/**
|
||||
* 详细地址
|
||||
*/
|
||||
@NotNull(message = "详细地址不能为空")
|
||||
@TableField("detail_address")
|
||||
private String detailAddress;
|
||||
|
||||
/**
|
||||
* 是否是默认仓库:0 否 1 是
|
||||
*/
|
||||
@NotNull(message = "是否是默认仓库不能为空")
|
||||
@TableField("default_repo")
|
||||
private String defaultRepo;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 操作人
|
||||
*/
|
||||
@TableField("oper_id")
|
||||
private Long operId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.zf.foodpurchase.fdsafe.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zf.foodpurchase.fdsafe.entity.Browse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品浏览记录表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-15
|
||||
*/
|
||||
public interface BrowseMapper extends BaseMapper<Browse> {
|
||||
|
||||
List<Browse> joinQueryList(Browse browse);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.zf.foodpurchase.fdsafe.mapper;
|
||||
|
||||
|
||||
import com.zf.foodpurchase.fdsafe.entity.Carousel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商户轮播图Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-11-29
|
||||
*/
|
||||
public interface CarouselMapper
|
||||
{
|
||||
/**
|
||||
* 查询商户轮播图
|
||||
*
|
||||
* @param carouselId 商户轮播图主键
|
||||
* @return 商户轮播图
|
||||
*/
|
||||
public Carousel selectCarouselByCarouselId(Long carouselId);
|
||||
|
||||
/**
|
||||
* 查询商户轮播图列表
|
||||
*
|
||||
* @param carousel 商户轮播图
|
||||
* @return 商户轮播图集合
|
||||
*/
|
||||
public List<Carousel> selectCarouselList(Carousel carousel);
|
||||
|
||||
/**
|
||||
* 新增商户轮播图
|
||||
*
|
||||
* @param carousel 商户轮播图
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCarousel(Carousel carousel);
|
||||
|
||||
/**
|
||||
* 修改商户轮播图
|
||||
*
|
||||
* @param carousel 商户轮播图
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCarousel(Carousel carousel);
|
||||
|
||||
/**
|
||||
* 删除商户轮播图
|
||||
*
|
||||
* @param carouselId 商户轮播图主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCarouselByCarouselId(Long carouselId);
|
||||
|
||||
/**
|
||||
* 批量删除商户轮播图
|
||||
*
|
||||
* @param carouselIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCarouselByCarouselIds(Long[] carouselIds);
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
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,19 @@
|
||||
package com.zf.foodpurchase.fdsafe.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zf.foodpurchase.fdsafe.entity.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 仓库列表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-20
|
||||
*/
|
||||
public interface RepositoryMapper extends BaseMapper<Repository> {
|
||||
|
||||
List<Repository> joinQueryList(Repository quryRepository);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
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> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.zf.foodpurchase.fdsafe.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zf.foodpurchase.fdsafe.entity.Browse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品浏览记录表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-15
|
||||
*/
|
||||
public interface IBrowseService extends IService<Browse> {
|
||||
|
||||
List<Browse> joinQueryList(Browse browse);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.zf.foodpurchase.fdsafe.service;
|
||||
|
||||
|
||||
import com.zf.foodpurchase.fdsafe.entity.Carousel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商户轮播图Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-11-29
|
||||
*/
|
||||
public interface ICarouselService
|
||||
{
|
||||
/**
|
||||
* 查询商户轮播图
|
||||
*
|
||||
* @param carouselId 商户轮播图主键
|
||||
* @return 商户轮播图
|
||||
*/
|
||||
public Carousel selectCarouselByCarouselId(Long carouselId);
|
||||
|
||||
/**
|
||||
* 查询商户轮播图列表
|
||||
*
|
||||
* @param carousel 商户轮播图
|
||||
* @return 商户轮播图集合
|
||||
*/
|
||||
public List<Carousel> selectCarouselList(Carousel carousel);
|
||||
|
||||
/**
|
||||
* 新增商户轮播图
|
||||
*
|
||||
* @param carousel 商户轮播图
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCarousel(Carousel carousel);
|
||||
|
||||
/**
|
||||
* 修改商户轮播图
|
||||
*
|
||||
* @param carousel 商户轮播图
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCarousel(Carousel carousel);
|
||||
|
||||
/**
|
||||
* 批量删除商户轮播图
|
||||
*
|
||||
* @param carouselIds 需要删除的商户轮播图主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCarouselByCarouselIds(Long[] carouselIds);
|
||||
|
||||
/**
|
||||
* 删除商户轮播图信息
|
||||
*
|
||||
* @param carouselId 商户轮播图主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCarouselByCarouselId(Long carouselId);
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
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);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
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,24 @@
|
||||
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 java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 仓库列表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-20
|
||||
*/
|
||||
public interface IRepositoryService extends IService<Repository> {
|
||||
|
||||
List<Repository> joinQueryList(Repository quryRepository);
|
||||
|
||||
AjaxResult saveRepo(Repository repository);
|
||||
|
||||
AjaxResult modifyRepo(Repository repository);
|
||||
}
|
||||
@@ -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.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);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.zf.foodpurchase.fdsafe.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zf.foodpurchase.fdsafe.entity.Browse;
|
||||
import com.zf.foodpurchase.fdsafe.service.IBrowseService;
|
||||
import com.zf.foodpurchase.fdsafe.mapper.BrowseMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品浏览记录表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-15
|
||||
*/
|
||||
@Service
|
||||
public class BrowseServiceImpl extends ServiceImpl<BrowseMapper, Browse> implements IBrowseService {
|
||||
@Autowired
|
||||
private BrowseMapper browseMapper;
|
||||
|
||||
@Override
|
||||
public List<Browse> joinQueryList(Browse browse) {
|
||||
return browseMapper.joinQueryList(browse);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.zf.foodpurchase.fdsafe.service.impl;
|
||||
|
||||
import com.zf.foodpurchase.common.utils.DateUtils;
|
||||
import com.zf.foodpurchase.fdsafe.entity.Carousel;
|
||||
import com.zf.foodpurchase.fdsafe.mapper.CarouselMapper;
|
||||
import com.zf.foodpurchase.fdsafe.service.ICarouselService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商户轮播图Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-11-29
|
||||
*/
|
||||
@Service
|
||||
public class CarouselServiceImpl implements ICarouselService
|
||||
{
|
||||
@Autowired
|
||||
private CarouselMapper carouselMapper;
|
||||
|
||||
/**
|
||||
* 查询商户轮播图
|
||||
*
|
||||
* @param carouselId 商户轮播图主键
|
||||
* @return 商户轮播图
|
||||
*/
|
||||
@Override
|
||||
public Carousel selectCarouselByCarouselId(Long carouselId)
|
||||
{
|
||||
return carouselMapper.selectCarouselByCarouselId(carouselId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商户轮播图列表
|
||||
*
|
||||
* @param carousel 商户轮播图
|
||||
* @return 商户轮播图
|
||||
*/
|
||||
@Override
|
||||
public List<Carousel> selectCarouselList(Carousel carousel)
|
||||
{
|
||||
return carouselMapper.selectCarouselList(carousel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增商户轮播图
|
||||
*
|
||||
* @param carousel 商户轮播图
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertCarousel(Carousel carousel)
|
||||
{
|
||||
carousel.setCreateTime(DateUtils.getNowDate());
|
||||
return carouselMapper.insertCarousel(carousel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商户轮播图
|
||||
*
|
||||
* @param carousel 商户轮播图
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateCarousel(Carousel carousel)
|
||||
{
|
||||
carousel.setUpdateTime(DateUtils.getNowDate());
|
||||
return carouselMapper.updateCarousel(carousel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除商户轮播图
|
||||
*
|
||||
* @param carouselIds 需要删除的商户轮播图主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCarouselByCarouselIds(Long[] carouselIds)
|
||||
{
|
||||
return carouselMapper.deleteCarouselByCarouselIds(carouselIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除商户轮播图信息
|
||||
*
|
||||
* @param carouselId 商户轮播图主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCarouselByCarouselId(Long carouselId)
|
||||
{
|
||||
return carouselMapper.deleteCarouselByCarouselId(carouselId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,580 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,753 @@
|
||||
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,74 @@
|
||||
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.constant.Constants;
|
||||
import com.zf.foodpurchase.common.core.domain.AjaxResult;
|
||||
import com.zf.foodpurchase.fdsafe.entity.Repository;
|
||||
import com.zf.foodpurchase.fdsafe.mapper.RepositoryMapper;
|
||||
import com.zf.foodpurchase.fdsafe.service.IRepositoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 轮播图
|
||||
* <p>
|
||||
* 仓库列表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author lilj
|
||||
* @since 2024-11-20
|
||||
*/
|
||||
@Service
|
||||
public class RepositoryServiceImpl extends ServiceImpl<RepositoryMapper, Repository> implements IRepositoryService {
|
||||
@Autowired
|
||||
private RepositoryMapper repositoryMapper;
|
||||
|
||||
@Override
|
||||
public List<Repository> joinQueryList(Repository quryRepository) {
|
||||
return repositoryMapper.joinQueryList(quryRepository);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult saveRepo(Repository repository) {
|
||||
if (checkRepoNameUnique(repository)) {
|
||||
return AjaxResult.error("仓库名称已存在请更换仓库名称");
|
||||
}
|
||||
return save(repository) ? AjaxResult.success("新增成功") : AjaxResult.error("新增失败");
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public AjaxResult modifyRepo(Repository repository) {
|
||||
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);
|
||||
}
|
||||
return update ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败");
|
||||
}
|
||||
|
||||
public boolean checkRepoNameUnique(Repository repository) {
|
||||
LambdaQueryWrapper<Repository> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(Repository::getRepoName, repository.getRepoName());
|
||||
queryWrapper.eq(Repository::getMerchantId, repository.getMerchantId());
|
||||
// 不为空说明是修改,同一商户下仓库名不能重复
|
||||
if (repository.getId() != null) {
|
||||
queryWrapper.ne(Repository::getId, repository.getId());
|
||||
}
|
||||
return repositoryMapper.selectCount(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
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){
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
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("删除失败");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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,154 @@
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
56
fp-system/src/main/resources/mapper/BrowseMapper.xml
Normal file
56
fp-system/src/main/resources/mapper/BrowseMapper.xml
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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.BrowseMapper">
|
||||
<resultMap id="BaseResultMap" type="com.zf.foodpurchase.fdsafe.entity.Browse">
|
||||
<id column="id" jdbcType="BIGINT" property="id"/>
|
||||
<result column="user_id" jdbcType="BIGINT" property="userId"/>
|
||||
<result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
|
||||
<result column="product_id" jdbcType="BIGINT" property="productId"/>
|
||||
<result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
|
||||
<result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
|
||||
<result column="remain_time" jdbcType="BIGINT" property="remainTime"/>
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
||||
<result column="nickname" jdbcType="VARCHAR" property="nickName"/>
|
||||
<result column="dept_name" jdbcType="VARCHAR" property="merchantName"/>
|
||||
<result column="product_name" jdbcType="VARCHAR" property="productName"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="joinQuery">
|
||||
select b.id,
|
||||
b.user_id,
|
||||
b.merchant_id,
|
||||
b.product_id,
|
||||
b.start_time,
|
||||
b.end_time,
|
||||
b.remain_time,
|
||||
b.create_time,
|
||||
IFNULL(u.nickname,'未设置昵称') as nickname,
|
||||
m.dept_name,
|
||||
p.product_name
|
||||
from browse b inner join user u on b.user_id=u.id inner join sys_dept m on b.merchant_id=m.dept_id inner join products p on b.product_id=p.product_id
|
||||
</sql>
|
||||
<select id="joinQueryList" resultMap="BaseResultMap" parameterType="com.zf.foodpurchase.fdsafe.entity.Browse">
|
||||
<include refid="joinQuery"/>
|
||||
<where>
|
||||
<if test="userId != null and userId != ''">
|
||||
and b.user_id = #{userId}
|
||||
</if>
|
||||
<if test="merchantId != null and merchantId != ''">
|
||||
and b.merchant_id = #{merchantId}
|
||||
</if>
|
||||
<if test="productId != null and productId != ''">
|
||||
and b.product_id = #{productId}
|
||||
</if>
|
||||
<if test="queryBeginTime != null ">
|
||||
and date_format(b.start_time, '%Y-%m-%d %H:%i:%s') >= date_format(#{queryBeginTime}, '%Y-%m-%d %H:%i:%s')
|
||||
</if>
|
||||
<if test="queryEndTime != null ">
|
||||
and date_format(b.start_time, '%Y-%m-%d %H:%i:%s') <= date_format(#{queryEndTime}, '%Y-%m-%d %H:%i:%s')
|
||||
</if>
|
||||
<if test="productName !=null and productName != ''">
|
||||
and p.product_name like concat('%',#{productName},'%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
70
fp-system/src/main/resources/mapper/CarouselMapper.xml
Normal file
70
fp-system/src/main/resources/mapper/CarouselMapper.xml
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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.CarouselMapper">
|
||||
|
||||
<resultMap type="Carousel" id="CarouselResult">
|
||||
<result property="carouselId" column="carousel_id" />
|
||||
<result property="merchantId" column="merchant_id" />
|
||||
<result property="merchantName" column="dept_name" />
|
||||
<result property="carouselIamges" column="carousel_iamges" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCarouselVo">
|
||||
select carousel_id, c.merchant_id, carousel_iamges, c.create_time,c.update_time,dept_name from carousel c inner join sys_dept d on
|
||||
c.merchant_id = d.dept_id
|
||||
</sql>
|
||||
|
||||
<select id="selectCarouselList" parameterType="Carousel" resultMap="CarouselResult">
|
||||
<include refid="selectCarouselVo"/>
|
||||
<where>
|
||||
<if test="merchantId != null "> and merchant_id = #{merchantId}</if>
|
||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''"> and c.create_time between #{params.beginCreateTime} and #{params.endCreateTime}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectCarouselByCarouselId" parameterType="Long" resultMap="CarouselResult">
|
||||
<include refid="selectCarouselVo"/>
|
||||
where carousel_id = #{carouselId}
|
||||
</select>
|
||||
|
||||
<insert id="insertCarousel" parameterType="Carousel" useGeneratedKeys="true" keyProperty="carouselId">
|
||||
insert into carousel
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="merchantId != null">merchant_id,</if>
|
||||
<if test="carouselIamges != null and carouselIamges != ''">carousel_iamges,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="merchantId != null">#{merchantId},</if>
|
||||
<if test="carouselIamges != null and carouselIamges != ''">#{carouselIamges},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateCarousel" parameterType="Carousel">
|
||||
update carousel
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="merchantId != null">merchant_id = #{merchantId},</if>
|
||||
<if test="carouselIamges != null and carouselIamges != ''">carousel_iamges = #{carouselIamges},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where carousel_id = #{carouselId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteCarouselByCarouselId" parameterType="Long">
|
||||
delete from carousel where carousel_id = #{carouselId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteCarouselByCarouselIds" parameterType="String">
|
||||
delete from carousel where carousel_id in
|
||||
<foreach item="carouselId" collection="array" open="(" separator="," close=")">
|
||||
#{carouselId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
211
fp-system/src/main/resources/mapper/ProductsMapper.xml
Normal file
211
fp-system/src/main/resources/mapper/ProductsMapper.xml
Normal file
@@ -0,0 +1,211 @@
|
||||
<?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>
|
||||
29
fp-system/src/main/resources/mapper/ProductsSpecMapper.xml
Normal file
29
fp-system/src/main/resources/mapper/ProductsSpecMapper.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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>
|
||||
38
fp-system/src/main/resources/mapper/RepositoryMapper.xml
Normal file
38
fp-system/src/main/resources/mapper/RepositoryMapper.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.RepositoryMapper">
|
||||
|
||||
<resultMap id="joinMap" type="com.zf.foodpurchase.fdsafe.entity.Repository">
|
||||
<id column="id" property="id" />
|
||||
<result column="merchant_id" property="merchantId" />
|
||||
<result column="merchant_name" property="merchantName" />
|
||||
<result column="repo_name" property="repoName" />
|
||||
<result column="area_code" property="areaCode" />
|
||||
<result column="detail_address" property="detailAddress" />
|
||||
<result column="default_repo" property="defaultRepo" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="oper_id" property="operId" />
|
||||
</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
|
||||
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"
|
||||
parameterType="com.zf.foodpurchase.fdsafe.entity.Repository">
|
||||
<include refid="joinColumn"/>
|
||||
<where>
|
||||
<if test="id != null ">and r.id = #{id}</if>
|
||||
<if test="merchantId != null ">and r.merchant_id = #{merchantId}</if>
|
||||
<if test="areaCode != null ">and r.area_code = #{areaCode}</if>
|
||||
<if test="detailAddress != null ">and r.detail_address = #{detailAddress}</if>
|
||||
<if test="defaultRepo != null ">and r.default_repo = #{defaultRepo}</if>
|
||||
<if test="operId != null ">and r.oper_id = #{operId}</if>
|
||||
<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>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
6
fp-system/src/main/resources/mapper/SpecTypesMapper.xml
Normal file
6
fp-system/src/main/resources/mapper/SpecTypesMapper.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?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>
|
||||
57
fp-system/src/main/resources/mapper/SpecValuesMapper.xml
Normal file
57
fp-system/src/main/resources/mapper/SpecValuesMapper.xml
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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>
|
||||
Reference in New Issue
Block a user