Authored by chenjian

Merge branch 'dev-offline-buy' into test6.8.5

... ... @@ -6,6 +6,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
import com.yohoufo.product.model.SkupInfo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -456,4 +457,17 @@ public class ProductController {
}
return null;
}
@IgnoreSession
@RequestMapping(params = "method=ufo.product.skup.detail")
public ApiResponse querySkupDetailBySkup(@RequestParam(value = "skup") Integer skup) {
if (null == skup) {
LOG.info("in method=ufo.product.skup.detail skup Is Null");
return new ApiResponse(400, "skup Is Null", null);
}
LOG.info("in method=ufo.product.skup.detail skup={}", skup);
SkupInfo skupInfo = productService.querySkupDetailBySkup(skup);
return new ApiResponse.ApiResponseBuilder().data(skupInfo).code(200).build();
}
}
\ No newline at end of file
... ...
package com.yohoufo.product.model;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.experimental.Builder;
import java.math.BigDecimal;
import java.util.List;
@Data
@Builder
public class SkupInfo {
@JSONField(name = "product_id")
private Integer productId;
@JSONField(name = "product_name")
private String productName;
@JSONField(name = "brand_name")
private String brandName;
@JSONField(name = "series_name")
private String seriesName;
@JSONField(name = "color_name")
private String colorName;
@JSONField(name = "image_list")
private List<String> imageList;
@JSONField(name = "sale_time")
private String saleTime;
@JSONField(name = "product_code")
private String productCode;
@JSONField(name = "skup")
private Integer skup;
@JSONField(name = "price")
private BigDecimal price;
@JSONField(name = "status")
private Integer status;
@JSONField(name = "status_str")
private String statusStr;
@JSONField(name = "store_name")
private String storeName;
}
... ...
... ... @@ -5,6 +5,7 @@ import java.util.List;
import com.yoho.core.dal.datasource.annotation.Database;
import com.yohoufo.dal.product.model.StoragePrice;
import com.yohoufo.product.model.SkupInfo;
import com.yohoufo.product.request.StoragePriceBo;
import com.yohoufo.product.response.ProductDetailResp;
import com.yohoufo.product.response.ProductSeriesTemplateResp;
... ... @@ -76,4 +77,6 @@ public interface ProductService {
List<SaleCategoryBo> querySaleCategoryDetail(Integer id);
List<StorageInfoResp> queryStorageInfoBySkuList(Collection<Integer> skuList);
SkupInfo querySkupDetailBySkup(int skup);
}
... ...
... ... @@ -14,7 +14,9 @@ import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.yohoufo.product.model.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -45,12 +47,6 @@ import com.yohoufo.dal.product.model.SaleCategory;
import com.yohoufo.dal.product.model.Size;
import com.yohoufo.dal.product.model.Storage;
import com.yohoufo.dal.product.model.StoragePrice;
import com.yohoufo.product.model.GoodsBO;
import com.yohoufo.product.model.GoodsImageBO;
import com.yohoufo.product.model.GoodsSize;
import com.yohoufo.product.model.ProductInfo;
import com.yohoufo.product.model.ProductSeriesTemplate;
import com.yohoufo.product.model.ProductSortTemplate;
import com.yohoufo.product.request.StoragePriceBo;
import com.yohoufo.product.response.ProductDetailResp;
import com.yohoufo.product.response.ProductSeriesTemplateResp;
... ... @@ -777,4 +773,66 @@ public class ProductServiceImpl implements ProductService{
sc.setSub(new ArrayList<>());
return sc;
}
@Override
public SkupInfo querySkupDetailBySkup(int skup) {
StoragePrice skupDo = storagePriceMapper.selectBySkup(skup);
Product product = productMapper.selectByPrimaryKey(skupDo.getProductId());
Goods goods = goodsMapper.selectByPrimaryKey(skupDo.getGoodsId());
List<GoodsImages> goodsImages = goodsImagesMapper.selectByGoodsId(skupDo.getGoodsId());
List<String> imageList = CollectionUtils.isEmpty(goodsImages) ? Lists.newArrayList()
: goodsImages.stream().map(GoodsImages::getImageUrl).filter(StringUtils::isNotBlank).collect(Collectors.toList());
Brand brand = product.getBrandId() == null ? null : brandMapper.selectByPrimaryKey(product.getBrandId());
BrandSeries brandSeries = product.getSeriesId() == null ? null : brandSeriesMapper.selectByPrimaryKey(product.getSeriesId());
Pair<Integer, String> skupStatusPair = product.getShelveStatus() == 1 ? getSkupStatus(skupDo.getStatus()) : getSkupStatus(0);
return SkupInfo.builder()
.productId(product.getId())
.productName(product.getProductName())
.productCode(product.getProductCode())
.brandName(brand == null ? "" : brand.getBrandName())
.seriesName(brandSeries == null ? "" : brandSeries.getSeriesName())
.saleTime((product.getSaleTime() == null || product.getSaleTime().equals(0)) ? "0" : DateUtil.getDateString(product.getSaleTime(), DateUtil.YYYY_MM_DD_DOT))
.colorName(goods.getColorName())
.imageList(imageList)
.skup(skup)
.price(skupDo.getPrice())
.status(skupStatusPair.getLeft())
.statusStr(skupStatusPair.getRight())
.storeName("YOHO!STORE艾尚店")
.build();
}
/**
* skup状态:0:已下架;1:可售;2:已售出
* @param status
* @return
*/
private Pair<Integer, String> getSkupStatus(int status) {
int skupStatus = 0;
String skupStatusStr = "已下架";
switch(status) {
case 1:
skupStatus = 1;
skupStatusStr = "可售";
break;
case 100:
skupStatus = 2;
skupStatusStr = "已售出";
break;
}
return Pair.of(skupStatus, skupStatusStr);
}
}
... ...