Authored by chenchao

Merge branch 'test6.9.7' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.7

... ... @@ -38,6 +38,8 @@ public class StoragePrice {
private Integer createTime;
private Integer preSaleFlag;
private Integer region;//0:大陆 1:香港
public Integer getId() {
return id;
... ... @@ -135,12 +137,20 @@ public class StoragePrice {
this.preSaleFlag = preSaleFlag;
}
public Integer getRegion() {
return region;
}
public void setRegion(Integer region) {
this.region = region;
}
@Override
public String toString() {
return "StoragePrice [id=" + id + ", skup=" + skup + ", productId=" + productId + ", goodsId=" + goodsId
+ ", storageId=" + storageId + ", depotNum=" + depotNum + ", sellerUid=" + sellerUid + ", price="
+ price + ", status=" + status + ", updateTime=" + updateTime + ", createTime=" + createTime
+ ", preSaleFlag=" + preSaleFlag + "]";
+ ", preSaleFlag=" + preSaleFlag + ", region=" + region + "]";
}
... ...
... ... @@ -14,6 +14,7 @@
<result column="update_time" jdbcType="INTEGER" property="updateTime" />
<result column="create_time" jdbcType="INTEGER" property="createTime" />
<result column="pre_sale_flag" jdbcType="INTEGER" property="preSaleFlag" />
<result column="region" jdbcType="INTEGER" property="region" />
</resultMap>
<insert id="insert" parameterType="com.yohoufo.dal.product.model.StoragePrice">
... ... @@ -101,11 +102,11 @@
<select id="selectLeastPricesByProductId" resultMap="BaseResultMap">
select * from (
select id, skup, storage_id, price, status, pre_sale_flag
select id, skup, storage_id, price, status, pre_sale_flag, region
from storage_price
where status = 1 and product_id = #{productId} and is_hide = 0
order by storage_id,price asc limit 1000000
) a group by storage_id, pre_sale_flag
) a group by storage_id, pre_sale_flag, region
</select>
<select id="selectInStockLeastPriceByProductId" resultType="java.math.BigDecimal">
... ...
... ... @@ -219,6 +219,13 @@ public class ProductServiceImpl implements ProductService {
BigDecimal secondHandLeastPrice = secondHandLeastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
productInfo.setSecondHandLeastPrice(secondHandLeastPrice);
}
List<BigDecimal> hkLeastPriceList = goodsSizes.stream().map(GoodsSize::getHkLeastPrice).filter(Objects::nonNull).collect(Collectors.toList());
if(!CollectionUtils.isEmpty(hkLeastPriceList)) {
BigDecimal hkLeastPrice = hkLeastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
productInfo.setHkLeastPrice(hkLeastPrice);
}
goodsSizes.sort(Comparator.comparing(GoodsSize::getOrderBy));
List<JSONObject> otherAddSizeList = getOtherSizeList(product.getMaxSortId(), product.getMidSortId(), goodsSizes);
if(!CollectionUtils.isEmpty(otherAddSizeList)) {
... ... @@ -920,7 +927,7 @@ public class ProductServiceImpl implements ProductService {
private Map<String, StoragePrice> getStorageLeastPriceInfo(Integer productId) {
List<StoragePrice> storagePrices = storagePriceMapper.selectLeastPricesByProductId(productId);
return storagePrices.stream()
.collect(Collectors.toMap(s -> s.getStorageId() + "_" + s.getPreSaleFlag(), Function.identity()));
.collect(Collectors.toMap(s -> s.getStorageId() + "_" + s.getPreSaleFlag() + "_" + s.getRegion(), Function.identity()));
}
private List<GoodsBO> getGoodsList(Integer productId, BigDecimal sellMinPrice, BigDecimal maxPrice) {
... ... @@ -946,11 +953,17 @@ public class ProductServiceImpl implements ProductService {
Map<String, StoragePrice> storagePriceMap = getStorageLeastPriceInfo(productId);
for (Storage storage : storageList) {
StoragePrice storagePrice = storagePriceMap.get(storage.getId() + "_0");
StoragePrice storagePricePre = storagePriceMap.get(storage.getId() + "_1");
StoragePrice storagePriceDl = storagePriceMap.get(storage.getId() + "_0_0");//大陆现货
StoragePrice storagePriceHk = storagePriceMap.get(storage.getId() + "_0_1");//香港现货
StoragePrice storagePrice = storagePriceDl == null ? storagePriceHk : storagePriceDl;
if(storagePriceDl != null && storagePriceHk != null && storagePriceHk.getPrice().compareTo(storagePriceDl.getPrice()) < 0) {
storagePrice = storagePriceHk;
}
StoragePrice storagePricePre = storagePriceMap.get(storage.getId() + "_1_0");//大陆预售
StoragePrice storagePriceSecondNew = storagePriceMap.get(storage.getId() + "_5");
StoragePrice storagePriceSecondOld = storagePriceMap.get(storage.getId() + "_6");
StoragePrice storagePriceSecondNew = storagePriceMap.get(storage.getId() + "_5_0");//大陆全新瑕疵
StoragePrice storagePriceSecondOld = storagePriceMap.get(storage.getId() + "_6_0");//大陆二手
StoragePrice storagePriceSecond = storagePriceSecondNew == null ? storagePriceSecondOld : storagePriceSecondNew;
if (storagePriceSecondOld != null && storagePriceSecondNew != null && storagePriceSecondOld.getPrice().compareTo(storagePriceSecondNew.getPrice()) < 0) {
storagePriceSecond = storagePriceSecondOld;
... ... @@ -990,6 +1003,11 @@ public class ProductServiceImpl implements ProductService {
goodsSize.setSecondHandStatus(storagePriceSecond == null ? null : storagePriceSecond.getStatus());
goodsSize.setSecondHandSkup(storagePriceSecond == null ? 0 : storagePriceSecond.getSkup());
goodsSize.setSecondHandStorageNum(goodsSize.getSecondHandSkup() == null || goodsSize.getSecondHandSkup() == 0 ? 0 : 1);
goodsSize.setHkLeastPrice(storagePriceHk == null ? null : storagePriceHk.getPrice());
goodsSize.setHkStatus(storagePriceHk == null ? null : storagePriceHk.getStatus());
goodsSize.setHkSkup(storagePriceHk == null ? null : storagePriceHk.getSkup());
goodsSize.setHkStorageNum(goodsSize.getHkSkup() == null || goodsSize.getHkSkup() == 0 ? 0: 1);
}
}
}
... ...