商品规格相关问题处理

This commit is contained in:
Chopper 2021-06-22 18:58:55 +08:00
parent a3085405fe
commit 911df97422
4 changed files with 15 additions and 13 deletions

View File

@ -15,8 +15,8 @@ import lombok.Data;
public class SpecificationSearchParams {
@ApiModelProperty(value = "规格")
private String specName;
@ApiModelProperty(value = "规格id")
private String specId;
@ApiModelProperty(value = "绑定分类")
private String categoryPath;
@ -26,7 +26,7 @@ public class SpecificationSearchParams {
public <T> QueryWrapper<T> queryWrapper() {
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
queryWrapper.like(StringUtils.isNotEmpty(specName), "spec_name", specName);
queryWrapper.eq(StringUtils.isNotEmpty(specId), "spec_id", specId);
queryWrapper.eq(deleteFlag != null, "delete_flag", deleteFlag);
return queryWrapper;
}

View File

@ -50,12 +50,11 @@ public class SpecificationServiceImpl extends ServiceImpl<SpecificationMapper, S
private SpecValuesService specValuesService;
@Override
public List<SpecificationVO> getSpecList(String specName) {
public List<SpecificationVO> getSpecList(String specId) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq(StringUtils.isNotEmpty(specName), "s.spec_name", specName);
queryWrapper.eq(StringUtils.isNotEmpty(specId), "s.spec_id", specId);
queryWrapper.orderByDesc("s.create_time");
queryWrapper.groupBy("s.id");
return this.baseMapper.findSpecList(queryWrapper);
}
@ -103,7 +102,7 @@ public class SpecificationServiceImpl extends ServiceImpl<SpecificationMapper, S
@Override
public IPage<SpecificationVO> getSpecificationPage(SpecificationSearchParams searchParams, PageVO pageVo) {
List<SpecificationVO> specList = this.getSpecList(searchParams.getSpecName());
List<SpecificationVO> specList = this.getSpecList(searchParams.getSpecId());
IPage<SpecificationVO> page = new Page<>(pageVo.getPageNumber(), pageVo.getPageSize(), specList.size());
page.setRecords(PageUtil.listToPage(pageVo, specList));
return page;

View File

@ -150,7 +150,7 @@ public class CartServiceImpl implements CartService {
tradeDTO.setPlatformCoupon(null);
this.resetTradeDTO(tradeDTO);
} catch (ServiceException se) {
throw se;
throw se;
} catch (Exception e) {
log.error("购物车渲染异常", e);
throw new ServiceException(errorMessage);
@ -511,7 +511,7 @@ public class CartServiceImpl implements CartService {
tradeDTO.setStoreRemark(tradeParams.getRemark());
tradeDTO.setParentOrderSn(tradeParams.getParentOrderSn());
//订单无收货地址校验
if(tradeDTO.getMemberAddress()==null){
if (tradeDTO.getMemberAddress() == null) {
throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST);
}
//将购物车信息写入缓存后续逻辑调用校验

View File

@ -1,6 +1,5 @@
package cn.lili.controller.goods;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.goods.entity.dos.CategorySpecification;
@ -16,6 +15,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
@ -68,9 +68,12 @@ public class CategorySpecificationManagerController {
//删除分类规格绑定信息
this.categorySpecificationService.remove(new QueryWrapper<CategorySpecification>().eq("category_id", categoryId));
//绑定规格信息
for (String specId : categorySpecs) {
CategorySpecification categoryBrand = new CategorySpecification(categoryId, specId);
categorySpecificationService.save(categoryBrand);
if (categorySpecs != null && categorySpecs.length > 0) {
List<CategorySpecification> categorySpecifications = new ArrayList<>();
for (String categorySpec : categorySpecs) {
categorySpecifications.add( new CategorySpecification(categoryId, categorySpec));
}
categorySpecificationService.saveBatch(categorySpecifications);
}
return ResultUtil.success();
}