Authored by mali

库存管理

... ... @@ -44,4 +44,7 @@ public interface StoragePriceMapper {
// 查询状态可售的skup集合
List<StoragePrice> selectByProductIds(@Param("list")List<Integer> productIdList);
// 根据SKup等信息查询其所属productId列表 最多查询出最新的300 productId
List<Integer> selectProductIdsBySkupInfo(@Param("storagePrice")StoragePrice storagePrice);
}
\ No newline at end of file
... ...
package com.yoho.ufo.dal.model;
import java.math.BigDecimal;
import java.util.List;
public class Product {
private Integer id;
... ... @@ -42,46 +43,18 @@ public class Product {
// 0未删除 1已删除
private Integer delStatus;
public Integer getStorageId() {
return storageId;
}
public void setStorageId(Integer storageId) {
this.storageId = storageId;
}
public Integer getSellerUid() {
return sellerUid;
}
public void setSellerUid(Integer sellerUid) {
this.sellerUid = sellerUid;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getSkup() {
return skup;
}
public void setSkup(Integer skup) {
this.skup = skup;
}
private Integer storageId;
private Integer sellerUid;
private Integer status;
private Integer storageNum;
private Integer skup;
private List<Integer> productIdList;
public Integer getId() {
return id;
}
... ... @@ -233,4 +206,52 @@ public class Product {
public void setDelStatus(Integer delStatus) {
this.delStatus = delStatus;
}
public Integer getStorageId() {
return storageId;
}
public void setStorageId(Integer storageId) {
this.storageId = storageId;
}
public Integer getSellerUid() {
return sellerUid;
}
public void setSellerUid(Integer sellerUid) {
this.sellerUid = sellerUid;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getSkup() {
return skup;
}
public void setSkup(Integer skup) {
this.skup = skup;
}
public Integer getStorageNum() {
return storageNum;
}
public void setStorageNum(Integer storageNum) {
this.storageNum = storageNum;
}
public List<Integer> getProductIdList() {
return productIdList;
}
public void setProductIdList(List<Integer> productIdList) {
this.productIdList = productIdList;
}
}
\ No newline at end of file
... ...
package com.yoho.ufo.dal.model;
import com.alibaba.fastjson.JSONObject;
import java.math.BigDecimal;
public class StoragePrice {
... ... @@ -122,4 +124,9 @@ public class StoragePrice {
public void setSizeId(Integer sizeId) {
this.sizeId = sizeId;
}
@Override
public String toString() {
return JSONObject.toJSONString(this);
}
}
\ No newline at end of file
... ...
... ... @@ -201,5 +201,11 @@
<if test="product.brandId != null and product.brandId > 0">
and p.brand_id = #{product.brandId}
</if>
<if test="product.productIdList != null and product.productIdList.size()>0">
And b.id in
<foreach collection="product.productIdList" item="productID" open="(" close=")" separator=",">
#{productID}
</foreach>
</if>
</sql>
</mapper>
\ No newline at end of file
... ...
... ... @@ -148,4 +148,17 @@
#{item}
</foreach> limit 5000 <!-- 防止太多的数据,导致内存扛不住 -->
</select>
<select id="selectProductIdsBySkupInfo" resultType="java.lang.Integer">
select DISTINCT product_id from storage_price where 1 = 1
<if test="storagePrice.sellerUid != null and storagePrice.sellerUid > 0">
and seller_uid = #{storagePrice.sellerUid}
</if>
<if test="storagePrice.storageId != null and storagePrice.storageId > 0">
and storage_id = #{storagePrice.storageId}
</if>
<if test="storagePrice.skup != null and storagePrice.skup > 0">
and skup = #{storagePrice.skup}
</if>
order by create_time desc limit 300
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -59,4 +59,15 @@ public class ProductConvertService {
bo.setProductName(productItem.getProductName());
return bo;
}
public StoragePrice convertProduct2Skup(Product product) {
StoragePrice storagePrice = new StoragePrice();
if (null == product) {
return storagePrice;
}
storagePrice.setSkup(product.getSkup());
storagePrice.setStorageId(product.getStorageId());
storagePrice.setSellerUid(product.getSellerUid());
return storagePrice;
}
}
... ...
package com.yoho.ufo.service.impl;
import com.google.common.collect.Lists;
import com.yoho.ufo.convert.ProductConvertService;
import com.yoho.ufo.dal.StoragePriceMapper;
import com.yoho.ufo.dal.model.Product;
import com.yoho.ufo.dal.model.StoragePrice;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by li.ma on 2018/9/20.
*/
@Service
public class StoragePriceService {
private static final Logger LOGGER = LoggerFactory.getLogger(StoragePriceService.class);
@Autowired
private StoragePriceMapper storagePriceMapper;
@Autowired
private ProductConvertService productConvertService;
public List<Integer> selectProductIdBySkupInfo(Product product) {
if (null == product || (null == product.getStorageId() && null == product.getSkup() && null == product.getSellerUid())) {
return Lists.newArrayList();
}
StoragePrice storagePrice = productConvertService.convertProduct2Skup(product);
List<Integer> productIds = storagePriceMapper.selectProductIdsBySkupInfo(storagePrice);
LOGGER.info("result selectProductIdBySkupInfo is {}, storagePrice is {}", productIds, storagePrice);
return CollectionUtils.isEmpty(productIds) ? Lists.newArrayList() : productIds;
}
}
... ...
... ... @@ -36,6 +36,9 @@ public class StorageService {
private StoragePriceMapper storagePriceMapper;
@Autowired
private StoragePriceService storagePriceService;
@Autowired
private ProductMapper productMapper;
@Autowired
... ... @@ -46,6 +49,10 @@ public class StorageService {
LOGGER.info("StorageService storageList param = {}", bo);
Product product = OrikaUtils.map(bo, Product.class);
// 如果查询条件含storage_price,先根据条件查询出productId列表 ,再到product表中联合查询
product.setProductIdList(storagePriceService.selectProductIdBySkupInfo(product));
int count = productMapper.selectProductStorageCount(product);
if (count == 0) {
LOGGER.warn("StorageService storageList count is 0.param = {}", bo);
... ...
... ... @@ -7,7 +7,7 @@
<script src="/ufoPlatform/js/ajaxfileupload.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="height: 190px">
<div region="north" style="height: 220px">
<script>
document.write(addHead('商品库存信息', ''));
</script>
... ... @@ -204,10 +204,10 @@
var skup = $('#skup').textbox('getValue');
var param = {};
if (undefined !== brandName && null !== brandName && "" !== brandName) {
param.brandName = brandName;
param.brandId = brandName;
}
if (undefined !== storageNum && null !== storageNum && "" !== storageNum) {
param.storage = storageNum;
param.storageNum = storageNum;
}
if (undefined !== id && null !== id && "" !== id) {
param.id = id;
... ...