master:档口销售出库,查货号获取商品数据调优;
parent
cd0ae25ec1
commit
b9f117069e
|
|
@ -88,8 +88,8 @@ public class StoreProductStockController extends XktBaseController {
|
|||
@ApiOperation(value = "销售出库,输入货号,查询客户优惠信息及当前货号颜色的库存", httpMethod = "POST", response = R.class)
|
||||
@PostMapping(value = "/stock-cus-discount")
|
||||
public R<StoreProdStockAndDiscountResVO> getStockAndCusDiscount(@Validated @RequestBody StoreProdStockAndDiscountVO stockAndDiscountVO) {
|
||||
return R.ok(BeanUtil.toBean(storeProdStockService.getStockAndCusDiscount(BeanUtil
|
||||
.toBean(stockAndDiscountVO, StoreProdStockAndDiscountDTO.class)), StoreProdStockAndDiscountResVO.class));
|
||||
return R.ok(BeanUtil.toBean(storeProdStockService.getStockAndCusDiscount(BeanUtil.toBean(stockAndDiscountVO,
|
||||
StoreProdStockAndDiscountDTO.class)), StoreProdStockAndDiscountResVO.class));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')||@ss.hasSupplierSubRole()")
|
||||
|
|
|
|||
|
|
@ -18,9 +18,8 @@ import java.util.List;
|
|||
@Accessors(chain = true)
|
||||
public class StoreProdStockAndDiscountResVO {
|
||||
|
||||
@ApiModelProperty(value = "sns条码")
|
||||
private String sns;
|
||||
|
||||
@ApiModelProperty(value = "档口ID")
|
||||
private Long storeId;
|
||||
@ApiModelProperty(value = "档口客户ID")
|
||||
private Long storeCusId;
|
||||
@ApiModelProperty(value = "档口客户名称")
|
||||
|
|
@ -31,50 +30,25 @@ public class StoreProdStockAndDiscountResVO {
|
|||
private Integer discount;
|
||||
@ApiModelProperty(value = "大小码加价")
|
||||
private Integer overPrice;
|
||||
@ApiModelProperty(value = "标准尺码")
|
||||
private List<Integer> standardSizeList;
|
||||
|
||||
@ApiModelProperty(value = "档口商品库存ID")
|
||||
private Long storeProdStockId;
|
||||
@ApiModelProperty(value = "档口商品ID")
|
||||
private Long storeProdId;
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@ApiModelProperty(value = "档口商品ID")
|
||||
private Long storeProdId;
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeProdColorId;
|
||||
@ApiModelProperty(value = "档口颜色ID")
|
||||
private Long storeColorId;
|
||||
@ApiModelProperty(value = "颜色名称")
|
||||
private String colorName;
|
||||
@ApiModelProperty(value = "尺码30")
|
||||
private Integer size30;
|
||||
@ApiModelProperty(value = "尺码31")
|
||||
private Integer size31;
|
||||
@ApiModelProperty(value = "尺码32")
|
||||
private Integer size32;
|
||||
@ApiModelProperty(value = "尺码33")
|
||||
private Integer size33;
|
||||
@ApiModelProperty(value = "尺码34")
|
||||
private Integer size34;
|
||||
@ApiModelProperty(value = "尺码35")
|
||||
private Integer size35;
|
||||
@ApiModelProperty(value = "尺码36")
|
||||
private Integer size36;
|
||||
@ApiModelProperty(value = "尺码37")
|
||||
private Integer size37;
|
||||
@ApiModelProperty(value = "尺码38")
|
||||
private Integer size38;
|
||||
@ApiModelProperty(value = "尺码39")
|
||||
private Integer size39;
|
||||
@ApiModelProperty(value = "尺码40")
|
||||
private Integer size40;
|
||||
@ApiModelProperty(value = "尺码41")
|
||||
private Integer size41;
|
||||
@ApiModelProperty(value = "尺码42")
|
||||
private Integer size42;
|
||||
@ApiModelProperty(value = "尺码43")
|
||||
private Integer size43;
|
||||
@ApiModelProperty(value = "总数量")
|
||||
private Integer totalStock;
|
||||
@ApiModelProperty(value = "尺码库存列表")
|
||||
private List<SPSADSizeVO> sizeStockList;
|
||||
|
||||
@Data
|
||||
public static class SPSADSizeVO {
|
||||
@ApiModelProperty(value = "尺码")
|
||||
private Integer size;
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,9 +18,8 @@ import java.util.List;
|
|||
@Accessors(chain = true)
|
||||
public class StoreProdStockAndDiscountResDTO {
|
||||
|
||||
@ApiModelProperty(value = "sns条码")
|
||||
private String sns;
|
||||
|
||||
@ApiModelProperty(value = "档口ID")
|
||||
private Long storeId;
|
||||
@ApiModelProperty(value = "档口客户ID")
|
||||
private Long storeCusId;
|
||||
@ApiModelProperty(value = "档口客户名称")
|
||||
|
|
@ -31,50 +30,25 @@ public class StoreProdStockAndDiscountResDTO {
|
|||
private Integer discount;
|
||||
@ApiModelProperty(value = "大小码加价")
|
||||
private Integer overPrice;
|
||||
@ApiModelProperty(value = "标准尺码")
|
||||
private List<Integer> standardSizeList;
|
||||
|
||||
@ApiModelProperty(value = "档口商品库存ID")
|
||||
private Long storeProdStockId;
|
||||
@ApiModelProperty(value = "档口商品ID")
|
||||
private Long storeProdId;
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@ApiModelProperty(value = "档口商品ID")
|
||||
private Long storeProdId;
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeProdColorId;
|
||||
@ApiModelProperty(value = "档口颜色ID")
|
||||
private Long storeColorId;
|
||||
@ApiModelProperty(value = "颜色名称")
|
||||
private String colorName;
|
||||
@ApiModelProperty(value = "尺码30")
|
||||
private Integer size30;
|
||||
@ApiModelProperty(value = "尺码31")
|
||||
private Integer size31;
|
||||
@ApiModelProperty(value = "尺码32")
|
||||
private Integer size32;
|
||||
@ApiModelProperty(value = "尺码33")
|
||||
private Integer size33;
|
||||
@ApiModelProperty(value = "尺码34")
|
||||
private Integer size34;
|
||||
@ApiModelProperty(value = "尺码35")
|
||||
private Integer size35;
|
||||
@ApiModelProperty(value = "尺码36")
|
||||
private Integer size36;
|
||||
@ApiModelProperty(value = "尺码37")
|
||||
private Integer size37;
|
||||
@ApiModelProperty(value = "尺码38")
|
||||
private Integer size38;
|
||||
@ApiModelProperty(value = "尺码39")
|
||||
private Integer size39;
|
||||
@ApiModelProperty(value = "尺码40")
|
||||
private Integer size40;
|
||||
@ApiModelProperty(value = "尺码41")
|
||||
private Integer size41;
|
||||
@ApiModelProperty(value = "尺码42")
|
||||
private Integer size42;
|
||||
@ApiModelProperty(value = "尺码43")
|
||||
private Integer size43;
|
||||
@ApiModelProperty(value = "总数量")
|
||||
private Integer totalStock;
|
||||
@ApiModelProperty(value = "尺码库存列表")
|
||||
private List<SPSADSizeDTO> sizeStockList;
|
||||
|
||||
@Data
|
||||
public static class SPSADSizeDTO {
|
||||
@ApiModelProperty(value = "尺码")
|
||||
private Integer size;
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer stock;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import com.ruoyi.xkt.dto.storeProdColorPrice.StoreProdColorPricePageDTO;
|
|||
import com.ruoyi.xkt.dto.storeProdColorPrice.StoreProdColorPriceResDTO;
|
||||
import com.ruoyi.xkt.dto.storeProdColorPrice.StoreProdColorPriceSimpleDTO;
|
||||
import com.ruoyi.xkt.dto.storeProdColorPrice.StoreProdMinPriceDTO;
|
||||
import com.ruoyi.xkt.dto.storeProductStock.StoreProdStockAndDiscountDTO;
|
||||
import com.ruoyi.xkt.dto.storeProductStock.StoreProdStockAndDiscountResDTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
|
@ -46,4 +48,11 @@ public interface StoreProductColorPriceMapper extends BaseMapper<StoreProductCol
|
|||
* @return List<StoreProdColorPriceResDTO>
|
||||
*/
|
||||
List<StoreProdColorPriceResDTO> selectPricePage(StoreProdColorPricePageDTO pageDTO);
|
||||
|
||||
/**
|
||||
* 销售出库,输入货号,查询颜色价格等信息
|
||||
* @param dto 入参
|
||||
* @return StoreProdStockAndDiscountResDTO
|
||||
*/
|
||||
StoreProdStockAndDiscountResDTO selectStockAndCusDiscount(StoreProdStockAndDiscountDTO dto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,13 @@ import com.ruoyi.common.constant.HttpStatus;
|
|||
import com.ruoyi.common.core.page.Page;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.xkt.domain.*;
|
||||
import com.ruoyi.xkt.domain.StoreProductColorSize;
|
||||
import com.ruoyi.xkt.domain.StoreProductFile;
|
||||
import com.ruoyi.xkt.domain.StoreProductStock;
|
||||
import com.ruoyi.xkt.domain.SysFile;
|
||||
import com.ruoyi.xkt.dto.storeProductFile.StoreProdMainPicDTO;
|
||||
import com.ruoyi.xkt.dto.storeProductStock.*;
|
||||
import com.ruoyi.xkt.enums.FileType;
|
||||
import com.ruoyi.xkt.enums.ProductSizeStatus;
|
||||
import com.ruoyi.xkt.mapper.*;
|
||||
import com.ruoyi.xkt.service.IStoreProductStockService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
|
@ -101,38 +103,23 @@ public class StoreProductStockServiceImpl implements IStoreProductStockService {
|
|||
if (!SecurityUtils.isAdmin() && !SecurityUtils.isStoreManagerOrSub(dto.getStoreId())) {
|
||||
throw new ServiceException("当前用户非档口管理者或子账号,无权限操作!", HttpStatus.ERROR);
|
||||
}
|
||||
// 商品颜色等基本信息
|
||||
StoreProdStockAndDiscountResDTO basicInfoDTO = ObjectUtils.defaultIfNull(this.prodColorPriceMapper.selectStockAndCusDiscount(dto),
|
||||
new StoreProdStockAndDiscountResDTO());
|
||||
// 档口商品颜色 的 库存
|
||||
StoreProductStock stock = this.storeProdStockMapper.selectOne(new LambdaQueryWrapper<StoreProductStock>()
|
||||
.eq(StoreProductStock::getStoreId, dto.getStoreId()).eq(StoreProductStock::getStoreProdColorId, dto.getStoreProdColorId())
|
||||
.eq(StoreProductStock::getDelFlag, Constants.UNDELETED));
|
||||
if (ObjectUtils.isEmpty(stock)) {
|
||||
return new StoreProdStockAndDiscountResDTO();
|
||||
}
|
||||
// 商品
|
||||
StoreProduct storeProd = Optional.ofNullable(this.storeProdMapper.selectOne(new LambdaQueryWrapper<StoreProduct>()
|
||||
.eq(StoreProduct::getId, stock.getStoreProdId()).eq(StoreProduct::getDelFlag, Constants.UNDELETED)))
|
||||
.orElseThrow(() -> new ServiceException("商品不存在或无效!", HttpStatus.ERROR));
|
||||
// 查询当前商品的售价
|
||||
StoreProductColorPrice prodColorPrice = this.prodColorPriceMapper.selectOne(new LambdaQueryWrapper<StoreProductColorPrice>()
|
||||
.eq(StoreProductColorPrice::getStoreProdId, stock.getStoreProdId()).eq(StoreProductColorPrice::getStoreColorId, stock.getStoreColorId())
|
||||
.eq(StoreProductColorPrice::getDelFlag, Constants.UNDELETED));
|
||||
// 查询当前客户在该商品的优惠信息
|
||||
StoreCustomerProductDiscount storeCusProdDiscount = this.storeCusProdDiscMapper.selectOne(new LambdaQueryWrapper<StoreCustomerProductDiscount>()
|
||||
.eq(StoreCustomerProductDiscount::getStoreCusId, dto.getStoreCusId()).eq(StoreCustomerProductDiscount::getStoreProdColorId, dto.getStoreProdColorId())
|
||||
.eq(StoreCustomerProductDiscount::getStoreId, dto.getStoreId()).eq(StoreCustomerProductDiscount::getDelFlag, Constants.UNDELETED));
|
||||
// 标准尺码
|
||||
List<StoreProductColorSize> prodColorSizeList = this.prodColorSizeMapper.selectList(new LambdaQueryWrapper<StoreProductColorSize>()
|
||||
.eq(StoreProductColorSize::getStoreProdId, stock.getStoreProdId()).eq(StoreProductColorSize::getStoreColorId, stock.getStoreColorId())
|
||||
.eq(StoreProductColorSize::getDelFlag, Constants.UNDELETED).eq(StoreProductColorSize::getStandard, ProductSizeStatus.STANDARD.getValue()));
|
||||
|
||||
// TODO 还要返回sns条码数据
|
||||
// TODO 还要返回sns条码数据
|
||||
|
||||
return BeanUtil.toBean(stock, StoreProdStockAndDiscountResDTO.class).setStoreProdStockId(stock.getId()).setStoreCusId(dto.getStoreCusId())
|
||||
.setStoreCusName(storeCusProdDiscount.getStoreCusName()).setPrice(prodColorPrice.getPrice()).setOverPrice(storeProd.getOverPrice())
|
||||
.setDiscount(ObjectUtils.defaultIfNull(storeCusProdDiscount.getDiscount(), 0))
|
||||
.setStandardSizeList(prodColorSizeList.stream().map(StoreProductColorSize::getSize).sorted(Comparator.comparing(Function.identity())).collect(Collectors.toList()));
|
||||
.eq(StoreProductColorSize::getStoreProdId, basicInfoDTO.getStoreProdId()).eq(StoreProductColorSize::getStoreColorId, basicInfoDTO.getStoreColorId())
|
||||
.eq(StoreProductColorSize::getDelFlag, Constants.UNDELETED));
|
||||
List<StoreProdStockAndDiscountResDTO.SPSADSizeDTO> sizeStockList = prodColorSizeList.stream().map(size -> new StoreProdStockAndDiscountResDTO.SPSADSizeDTO()
|
||||
.setSize(size.getSize()).setStock(this.getSizeStock(size.getSize(), stock))).collect(Collectors.toList());
|
||||
return basicInfoDTO.setStoreCusId(dto.getStoreCusId()).setStoreId(dto.getStoreId()).setSizeStockList(sizeStockList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 库存盘点
|
||||
*
|
||||
|
|
@ -468,5 +455,59 @@ public class StoreProductStockServiceImpl implements IStoreProductStockService {
|
|||
return stock;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品某尺寸的库存
|
||||
* @param size 尺寸
|
||||
* @param stock 库存
|
||||
* @return 库存
|
||||
*/
|
||||
private Integer getSizeStock(Integer size, StoreProductStock stock) {
|
||||
if (ObjectUtils.isEmpty(stock)) {
|
||||
return null;
|
||||
}
|
||||
if (size == 30) {
|
||||
return stock.getSize30();
|
||||
} else if (size == 31) {
|
||||
return stock.getSize31();
|
||||
}
|
||||
else if (size == 32) {
|
||||
return stock.getSize32();
|
||||
}
|
||||
else if (size == 33) {
|
||||
return stock.getSize33();
|
||||
}
|
||||
else if (size == 34) {
|
||||
return stock.getSize34();
|
||||
}
|
||||
else if (size == 35) {
|
||||
return stock.getSize35();
|
||||
}
|
||||
else if (size == 36) {
|
||||
return stock.getSize36();
|
||||
}
|
||||
else if (size == 37) {
|
||||
return stock.getSize37();
|
||||
}
|
||||
else if (size == 38) {
|
||||
return stock.getSize38();
|
||||
}
|
||||
else if (size == 39) {
|
||||
return stock.getSize39();
|
||||
}
|
||||
else if (size == 40) {
|
||||
return stock.getSize40();
|
||||
}
|
||||
else if (size == 41) {
|
||||
return stock.getSize41();
|
||||
}
|
||||
else if (size == 42) {
|
||||
return stock.getSize42();
|
||||
}
|
||||
else if (size == 43) {
|
||||
return stock.getSize43();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,4 +83,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
spcp.store_color_id
|
||||
</select>
|
||||
|
||||
<select id="selectStockAndCusDiscount" resultType="com.ruoyi.xkt.dto.storeProductStock.StoreProdStockAndDiscountResDTO">
|
||||
SELECT DISTINCT
|
||||
spcp.store_color_id,
|
||||
spcp.price,
|
||||
spc.color_name,
|
||||
spc.id AS storeProdColorId,
|
||||
spcp.store_prod_id,
|
||||
sp.prod_art_num,
|
||||
sp.over_price,
|
||||
scpd.discount,
|
||||
( SELECT sc.cus_name FROM store_customer sc WHERE sc.id = #{storeCusId} ) AS storeCusName
|
||||
FROM
|
||||
store_product_color_price spcp
|
||||
LEFT JOIN store_product sp ON spcp.store_prod_id = sp.id
|
||||
LEFT JOIN store_product_color spc ON spcp.store_prod_id = spc.store_prod_id
|
||||
AND spc.store_color_id = spcp.store_color_id AND spc.del_flag = 0
|
||||
LEFT JOIN store_customer_product_discount scpd ON scpd.store_prod_color_id = spc.id
|
||||
AND scpd.del_flag = 0
|
||||
WHERE
|
||||
spcp.del_flag = 0
|
||||
AND spc.id = #{storeProdColorId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue