...
|
...
|
@@ -892,15 +892,7 @@ public class ProductServiceImpl implements ProductService { |
|
|
final Integer sellerUid = storagePrice.getSellerUid();
|
|
|
final Integer productId = storagePrice.getProductId();
|
|
|
// 根据 skn 获取商品信息
|
|
|
Product product = productMapper.selectByPrimaryKey(productId);
|
|
|
if (product != null) {
|
|
|
// 设置商品名称
|
|
|
innerResult.setProductName(product.getProductName());
|
|
|
}
|
|
|
// 设置 id sku-p 和 sku-p 价格
|
|
|
innerResult.setId(storagePrice.getId());
|
|
|
innerResult.setSkup(storagePrice.getSkup());
|
|
|
innerResult.setSkupPrice(storagePrice.getPrice());
|
|
|
getProductInfoBySkn(innerResult, storagePrice, productId);
|
|
|
// 获取 sku-p 尺码
|
|
|
Storage storage = storageMapper.selectByPrimaryKey(storagePrice.getStorageId());
|
|
|
final Integer skuSizeId = ((storage == null) ? null : storage.getSizeId());
|
...
|
...
|
@@ -917,6 +909,61 @@ public class ProductServiceImpl implements ProductService { |
|
|
innerResult.setColorImage(ImageUrlAssist.getUrl(goodsList.get(0).getColorImage(), GOODS_IMAGE_BUCKET, null, null));
|
|
|
}
|
|
|
// 获取该 sku-p 对应 skn 下其他的 sku
|
|
|
getOtherSkuUnderSameSkn(innerResult, storagePrice, sellerUid, productId);
|
|
|
// 获取二维码
|
|
|
String origin = "https://o.yohobuy.com/ufo?p={skuP_storeId}&productId={skn}&skn={skn}&openby:yohobuy={\"action\":\"go.ufo\",\"params\":{\"pagename\":\"productDetail\",\"productId\":\"{skn}\"}}";
|
|
|
String qrCode = origin.replace("{skuP_storeId}", StringUtils.join(skuP, ",", storeId))
|
|
|
.replace("{skn}", Integer.toString(productId));
|
|
|
|
|
|
innerResult.setQrCode(qrCode);
|
|
|
// 获取价格走势
|
|
|
getPriceTrend(innerResult, productId, skuSizeId);
|
|
|
// 构建结果集并返回
|
|
|
result.setSkupDetail(innerResult);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取价格走势
|
|
|
*
|
|
|
* @param innerResult
|
|
|
* @param productId
|
|
|
* @param skuSizeId
|
|
|
*/
|
|
|
private void getPriceTrend(SkupDetailForScreenInfo innerResult, final Integer productId, final Integer skuSizeId) {
|
|
|
if (productId != null && skuSizeId != null) {
|
|
|
List<PriceTrendModel> priceTrendMonthList = priceTrendMonthMapper.selectByProductIdAndSizeId(productId, skuSizeId, PRICE_TREND_MONTH_DEFAULT_LIMIT);
|
|
|
List<PriceTrendModel> priceTrendDayList = priceTrendDayMapper.selectByProductIdAndSizeId(productId, skuSizeId, PRICE_TREND_DAY_DEFAULT_LIMIT);
|
|
|
// PriceTrendBO
|
|
|
List<PriceTrendBO> priceResultList = new ArrayList<>();
|
|
|
priceTrendMonthList.stream().forEach(ele -> {
|
|
|
PriceTrendBO bo = new PriceTrendBO();
|
|
|
bo.setDate(DateUtil.getDateString(ele.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
|
|
|
bo.setPrice(String.valueOf(ele.getSkuPrice()));
|
|
|
priceResultList.add(bo);
|
|
|
});
|
|
|
// 59个0点或12点的数据 + 1个当天最近时间整点的数据
|
|
|
if (!priceTrendDayList.isEmpty()) {
|
|
|
PriceTrendBO b = new PriceTrendBO();
|
|
|
b.setDate(DateUtil.getDateString(priceTrendDayList.get(0).getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
|
|
|
b.setPrice(String.valueOf(priceTrendDayList.get(0).getSkuPrice()));
|
|
|
priceResultList.add(0, b);
|
|
|
}
|
|
|
// 重排一下
|
|
|
Collections.reverse(priceResultList);
|
|
|
innerResult.setPriceTrend(priceResultList);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取该 sku-p 对应 skn 下其他的 sku
|
|
|
*
|
|
|
* @param innerResult
|
|
|
* @param storagePrice
|
|
|
* @param sellerUid
|
|
|
* @param productId
|
|
|
*/
|
|
|
private void getOtherSkuUnderSameSkn(SkupDetailForScreenInfo innerResult, final StoragePrice storagePrice, final Integer sellerUid, final Integer productId) {
|
|
|
List<Storage> storageList = storageMapper.selectByProductId(productId);
|
|
|
if (!CollectionUtils.isEmpty(storageList)) {
|
|
|
// 过滤出所有 sku (distinct)
|
...
|
...
|
@@ -964,68 +1011,26 @@ public class ProductServiceImpl implements ProductService { |
|
|
});
|
|
|
innerResult.setOtherSize(innerList);
|
|
|
}
|
|
|
|
|
|
/*for (Storage data : storageList) {
|
|
|
List<StoragePrice> storagePricesList = storagePriceMapper.selectByStorageIdsPlus(Arrays.asList(data.getId()), storagePrice.getStorageId());
|
|
|
if (storagePricesList != null) {
|
|
|
SkusBO sku = new SkusBO();
|
|
|
Size size = sizeMapper.selectByPrimaryKey(data.getSizeId());
|
|
|
if (size != null) {
|
|
|
if (storagePricesList.size() > 0) {
|
|
|
// 设置其他 sku 的 ID
|
|
|
sku.setId(data.getId());
|
|
|
// 设置其他 sku 尺码
|
|
|
sku.setSkuSize(size.getSizeName());
|
|
|
// 初始化
|
|
|
sku.setSkuPrice(storagePricesList.get(0).getPrice());
|
|
|
for (StoragePrice price : storagePricesList) {
|
|
|
if (sku.getSkuPrice().compareTo(price.getPrice()) > 0) {
|
|
|
// 设置最小的 sku-p 价格为当前 sku 的价格
|
|
|
sku.setSkuPrice(price.getPrice());
|
|
|
}
|
|
|
}
|
|
|
innerList.add(sku);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
innerResult.setOtherSize(innerList);*/
|
|
|
}
|
|
|
// 获取二维码
|
|
|
String origin = "https://o.yohobuy.com/ufo?p={skuP_storeId}&productId={skn}&skn={skn}&openby:yohobuy={\"action\":\"go.ufo\",\"params\":{\"pagename\":\"productDetail\",\"productId\":\"{skn}\"}}";
|
|
|
String qrCode = origin.replace("{skuP_storeId}", StringUtils.join(skuP, ",", storeId))
|
|
|
.replace("{skn}", Integer.toString(productId));
|
|
|
}
|
|
|
|
|
|
innerResult.setQrCode(qrCode);
|
|
|
/**
|
|
|
* 获取价格走势
|
|
|
*/
|
|
|
if (productId != null && skuSizeId != null) {
|
|
|
// List<PriceTrendModel> priceTrendList = priceTrendSixtyDayMapper.selectByProductIdAndSizeId(productId, skuSizeId);
|
|
|
List<PriceTrendModel> priceTrendMonthList = priceTrendMonthMapper.selectByProductIdAndSizeId(productId, skuSizeId, PRICE_TREND_MONTH_DEFAULT_LIMIT);
|
|
|
List<PriceTrendModel> priceTrendDayList = priceTrendDayMapper.selectByProductIdAndSizeId(productId, skuSizeId, PRICE_TREND_DAY_DEFAULT_LIMIT);
|
|
|
// PriceTrendBO
|
|
|
List<PriceTrendBO> priceResultList = new ArrayList<>();
|
|
|
priceTrendMonthList.stream().forEach(ele -> {
|
|
|
PriceTrendBO bo = new PriceTrendBO();
|
|
|
bo.setDate(DateUtil.getDateString(ele.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
|
|
|
bo.setPrice(String.valueOf(ele.getSkuPrice()));
|
|
|
priceResultList.add(bo);
|
|
|
});
|
|
|
// 59个0点或12点的数据 + 1个当天最近时间整点的数据
|
|
|
if (!priceTrendDayList.isEmpty()) {
|
|
|
PriceTrendBO b = new PriceTrendBO();
|
|
|
b.setDate(DateUtil.getDateString(priceTrendDayList.get(0).getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
|
|
|
b.setPrice(String.valueOf(priceTrendDayList.get(0).getSkuPrice()));
|
|
|
priceResultList.add(0, b);
|
|
|
}
|
|
|
// 重排一下
|
|
|
Collections.reverse(priceResultList);
|
|
|
innerResult.setPriceTrend(priceResultList);
|
|
|
/**
|
|
|
* 根据 skn 获取商品信息
|
|
|
*
|
|
|
* @param innerResult
|
|
|
* @param storagePrice
|
|
|
* @param productId
|
|
|
*/
|
|
|
private void getProductInfoBySkn(SkupDetailForScreenInfo innerResult, final StoragePrice storagePrice, final Integer productId) {
|
|
|
final Product product = productMapper.selectByPrimaryKey(productId);
|
|
|
if (product != null) {
|
|
|
// 设置商品名称
|
|
|
innerResult.setProductName(product.getProductName());
|
|
|
}
|
|
|
// 构建结果集并返回
|
|
|
result.setSkupDetail(innerResult);
|
|
|
return result;
|
|
|
// 设置 id sku-p 和 sku-p 价格
|
|
|
innerResult.setId(storagePrice.getId());
|
|
|
innerResult.setSkup(storagePrice.getSkup());
|
|
|
innerResult.setSkupPrice(storagePrice.getPrice());
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|