Authored by unknown

二手商品属性

... ... @@ -9,4 +9,6 @@ import com.yohoufo.dal.product.model.SecondhandFlaw;
public interface SecondhandFlawMapper {
List<SecondhandFlaw> selectByType(@Param("type") Integer type);
List<SecondhandFlaw> selectByIds(@Param("type") String ids);
}
\ No newline at end of file
... ...
... ... @@ -12,4 +12,6 @@ public interface SecondhandImagesMapper {
List<SecondhandImages> selectBySkup(Integer skup);
List<SecondhandImages> selectDefaultBySkupList(@Param("skupList") List<Integer> skupList);
}
\ No newline at end of file
... ...
... ... @@ -8,4 +8,6 @@ public interface SecondhandInfoMapper {
int insert(@Param("record")SecondhandInfo record);
SecondhandInfo selectBySkup(Integer skup);
}
\ No newline at end of file
... ...
... ... @@ -38,6 +38,7 @@ public interface StoragePriceMapper {
List<StoragePrice> selectByStorageIds(List<Integer> storageIds);
List<StoragePrice> selectBySkupList(@Param("skupList") List<Integer> skupList);
List<StoragePrice> selectSecondByProductId(@Param("productId") Integer productId, @Param("start") Integer start, @Param("limit") Integer limit);
/**
* 批量修改skup价格
... ...
... ... @@ -15,4 +15,9 @@
where type=#{type}
order by order_by
</select>
<select id="selectByIds" resultMap="BaseResultMap">
select * from secondhand_flaw where id in(${ids})
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -18,8 +18,16 @@
</foreach>
</insert>
<select id="selectBySkup" resultMap="BaseResultMap">
<select id="selectBySkup" resultMap="BaseResultMap">
select id, skup, type, is_default, image_url
from secondhand_images where skup = #{skup,jdbcType=INTEGER};
</select>
from secondhand_images where skup = #{skup,jdbcType=INTEGER}
</select>
<select id="selectDefaultBySkupList" resultMap="BaseResultMap">
select * from secondhand_images where is_default = 'Y' and skup in
<foreach item="item" index="index" collection="skupList" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -18,4 +18,9 @@
values (#{record.skup,jdbcType=INTEGER}, #{record.flawId,jdbcType=VARCHAR},
#{record.flawAttr,jdbcType=VARCHAR}, #{record.describeInfo,jdbcType=VARCHAR}, unix_timestamp())
</insert>
<select id="selectBySkup" resultMap="BaseResultMap">
select * from secondhand_info where skup = #{skup}
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -191,4 +191,12 @@
</foreach>
</select>
<select id="selectSecondByProductId" resultMap="BaseResultMap">
select *
from storage_price
where status = 1
and product_id =#{productId} and pre_sale_flag in(5,6) and is_hide = 0
limit #{start},#{limit}
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -87,6 +87,35 @@ public class ProductController {
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("product data").build();
}
@ApiOperation(name = "ufo.product.secondHand.list", desc = "二手商品列表")
@IgnoreSession
@RequestMapping(params = "method=ufo.product.secondHand.list")
@Cachable(expire = 180)
public ApiResponse querySecondHandProductInfo(
@RequestParam(value = "product_id") Integer productId
, @RequestParam(value = "isJump") boolean isJump
, @RequestParam(value = "limit", required = false)Integer limit
, @RequestParam(value = "page", required = false)Integer page
) {
LOG.info("in method=ufo.product.secondHand.list product_id={}, isJump={}, limit={}, page ={}", productId, isJump, limit, page);
List<SecondHandProductResp> resp = productService.querySecondHandProductInfo(productId, isJump, limit, page);
if(isJump && resp.size()==1) {
return new ApiResponse.ApiResponseBuilder().data(resp.get(0)).code(200).message("second hand product data").build();
} else {
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("second hand product data").build();
}
}
@ApiOperation(name = "ufo.product.secondHand.data", desc = "二手商品详情")
@IgnoreSession
@RequestMapping(params = "method=ufo.product.secondHand.data")
@Cachable(expire = 180)
public ApiResponse querySecondHandProductInfo( @RequestParam(value = "skup") Integer skup) {
LOG.info("in method=ufo.product.secondHand.data skup={}", skup);
SecondHandProductResp resp = productService.querySecondHandProductInfo(skup);
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("second hand product data").build();
}
@ApiOperation(name = "ufo.product.sort.template", desc = "商品列表")
@IgnoreSignature
@IgnoreSession
... ...
package com.yohoufo.product.response;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public class SecondHandProductResp {
private Integer productId;
private String productName;
private String productCode;
private Integer skup;
private String image;
private List<String> imageList;
private String price;
private String newProductPrice;
private String savePrice;
private String sizeName;
private String colorName;
private String describeInfo;
private List<String> flawInfo;
private String flawAttr;
/** 全新瑕疵,二手. */
private String sechondHandTypeName;
}
... ...
... ... @@ -95,4 +95,8 @@ public interface ProductService {
void addSales(Integer skup);
void changeOneSkupHideStatus(Integer skup, int status);
List<SecondHandProductResp> querySecondHandProductInfo(Integer productId, boolean isJump, Integer limit, Integer page);
SecondHandProductResp querySecondHandProductInfo(Integer skup);
}
... ...
... ... @@ -19,6 +19,7 @@ import com.yohoufo.dal.product.*;
import com.yohoufo.dal.product.model.*;
import com.yohoufo.product.model.*;
import com.yohoufo.product.response.*;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;
... ... @@ -90,6 +91,15 @@ public class ProductServiceImpl implements ProductService {
private ProductSalesMapper productSalesMapper;
@Autowired
private SecondhandImagesMapper secondhandImagesMapper;
@Autowired
private SecondhandInfoMapper secondhandInfoMapper;
@Autowired
private SecondhandFlawMapper secondhandFlawMapper;
@Autowired
private SellerStoreMapUtil sellerStoreMapUtil;
@Override
... ... @@ -124,6 +134,12 @@ public class ProductServiceImpl implements ProductService {
BigDecimal preSaleLeastPrice = preSaleLeastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
productInfo.setPreSaleLeastPrice(preSaleLeastPrice);
}
List<BigDecimal> secondHandLeastPriceList = goodsSizes.stream().map(GoodsSize::getSecondHandLeastPrice).filter(Objects::nonNull).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(secondHandLeastPriceList)) {
BigDecimal secondHandLeastPrice = secondHandLeastPriceList.stream().min((p1, p2) -> (p1.compareTo(p2))).get();
productInfo.setSecondHandLeastPrice(secondHandLeastPrice);
}
goodsSizes.sort(Comparator.comparing(GoodsSize::getOrderBy));
}
}
... ... @@ -355,7 +371,7 @@ public class ProductServiceImpl implements ProductService {
@Override
public void sellerUpdateStatus(StoragePriceBo skupBo) {
// 卖家修改状态:*1:可售(支付保证金),2:取消支付保证金,3:超时未支付保证金,4:支付保证金后取消售卖
// 卖家修改状态:*1:可售(支付保证金),2:取消支付保证金,3:超时未支付保证金,4:支付保证金后取消售卖,10:待审核
if (skupBo == null) {
throw new ServiceException(400, "skupBo为空!");
}
... ... @@ -365,8 +381,9 @@ public class ProductServiceImpl implements ProductService {
throw new ServiceException(400, "skup错误:" + skup);
}
int status;
if (skupBo.getStatus() == null || (status = skupBo.getStatus()) < 1 || status > 4) {
Integer status = skupBo.getStatus();
int[] validStatus = {1, 2, 3, 4, 10};
if (status == null || !ArrayUtils.contains(validStatus, status)) {
throw new ServiceException(400, "商品(status)错误:" + skupBo.getStatus());
}
... ... @@ -386,7 +403,7 @@ public class ProductServiceImpl implements ProductService {
throw new ServiceException(400, "商品(skup)状态已变更");
}
addStorageNum(skup, sp.getStorageId(), 1);
} else if (status == 2 || status == 3) {
} else if (status == 2 || status == 3 || status == 10) {
if (storagePriceMapper.updateStatus(skup, status, 0) == 0) {
throw new ServiceException(400, "商品(skup)状态已变更");
}
... ... @@ -689,6 +706,13 @@ public class ProductServiceImpl implements ProductService {
StoragePrice storagePrice = storagePriceMap.get(storage.getId() + "_0");
StoragePrice storagePricePre = storagePriceMap.get(storage.getId() + "_1");
StoragePrice storagePriceSecondNew = storagePriceMap.get(storage.getId() + "_5");
StoragePrice storagePriceSecondOld = storagePriceMap.get(storage.getId() + "_6");
StoragePrice storagePriceSecond = storagePriceSecondNew == null ? storagePriceSecondOld : storagePriceSecondNew;
if (storagePriceSecondOld != null && storagePriceSecondNew != null && storagePriceSecondOld.getPrice().compareTo(storagePriceSecondNew.getPrice()) < 0) {
storagePriceSecond = storagePriceSecondOld;
}
GoodsSize goodsSize = new GoodsSize();
goodsSize.setId(storage.getId());
goodsSize.setSizeId(storage.getSizeId());
... ... @@ -718,6 +742,11 @@ public class ProductServiceImpl implements ProductService {
goodsSize.setPreSaleStatus(storagePricePre == null ? null : storagePricePre.getStatus());
goodsSize.setPreSaleSkup(storagePricePre == null ? 0 : storagePricePre.getSkup());
goodsSize.setPreSaleStorageNum(goodsSize.getPreSaleSkup() == null || goodsSize.getPreSaleSkup() == 0 ? 0 : 1);
goodsSize.setSecondHandLeastPrice(storagePriceSecond == null ? null : storagePriceSecond.getPrice());
goodsSize.setSecondHandStatus(storagePriceSecond == null ? null : storagePriceSecond.getStatus());
goodsSize.setSecondHandSkup(storagePriceSecond == null ? 0 : storagePriceSecond.getSkup());
goodsSize.setSecondHandStorageNum(goodsSize.getSecondHandSkup() == null || goodsSize.getSecondHandSkup() == 0 ? 0 : 1);
}
}
}
... ... @@ -1151,4 +1180,89 @@ public class ProductServiceImpl implements ProductService {
}
}
@Override
public List<SecondHandProductResp> querySecondHandProductInfo(Integer productId, boolean isJump, Integer limit, Integer page) {
List<StoragePrice> spList = storagePriceMapper.selectSecondByProductId(productId, limit, page);
if (spList.isEmpty()) {
return new ArrayList<>();
}
if (spList.size() == 1 && isJump) {
return Arrays.asList(querySecondHandProductInfo(spList.get(0).getSkup()));
}
List<Storage> storageList = storageMapper.selectByIds(spList.stream().map(StoragePrice::getStorageId).collect(Collectors.toList()));
List<Size> sizeList = sizeMapper.selectByIds(storageList.stream().map(Storage::getSizeId).collect(Collectors.toList()));
List<SecondhandImages> secondhandImagesList = secondhandImagesMapper.selectDefaultBySkupList(spList.stream().map(StoragePrice::getSkup).collect(Collectors.toList()));
Map<Integer, Storage> storageMap = storageList.stream().collect(Collectors.toMap(Storage::getId, Function.identity()));
Map<Integer, Size> sizeMap = sizeList.stream().collect(Collectors.toMap(Size::getId, Function.identity()));
Map<Integer, SecondhandImages> secondhandImagesMap = secondhandImagesList.stream().collect(Collectors.toMap(SecondhandImages::getSkup, Function.identity()));
List<SecondHandProductResp> resp = new ArrayList<>();
for (StoragePrice sp : spList) {
SecondHandProductResp bean = new SecondHandProductResp();
bean.setSkup(sp.getSkup());
bean.setPrice(sp.getPrice().toString());
bean.setSechondHandTypeName(sp.getPreSaleFlag() == 5 ? "全新瑕疵" : "二手");
Storage storage = storageMap.get(sp.getStorageId());
if (storage != null) {
Size size = sizeMap.get(storage.getSizeId());
if (size != null) {
bean.setSizeName(size.getSizeName() + "码");
}
}
if (StringUtils.isBlank(bean.getSizeName())) {
bean.setSizeName("");
}
SecondhandImages images = secondhandImagesMap.get(sp.getSkup());
if (images != null) {
bean.setImage(images.getImageUrl());
}
if (StringUtils.isBlank(bean.getImage())) {
bean.setImage("");
}
resp.add(bean);
}
return resp;
}
public SecondHandProductResp querySecondHandProductInfo(Integer skup) {
StoragePrice sp = storagePriceMapper.selectBySkup(skup);
if (sp == null) {
return null;
}
SecondHandProductResp resp = new SecondHandProductResp();
Integer storageId = sp.getStorageId();
Integer productId = sp.getProductId();
Storage storage = storageMapper.selectByPrimaryKey(storageId);
Goods goods = goodsMapper.selectByPrimaryKey(storage.getGoodsId());
Product product = productMapper.selectByPrimaryKey(productId);
Size size = sizeMapper.selectByPrimaryKey(storage.getSizeId());
List<SecondhandImages> secondhandImagesList = secondhandImagesMapper.selectBySkup(skup);
SecondhandInfo secondhandInfo = secondhandInfoMapper.selectBySkup(skup);
resp.setProductId(productId);
List<String> imageList = new ArrayList<>();
for (SecondhandImages image : secondhandImagesList) {
if (StringUtils.equals(image.getIsDefault(), "Y")) {
resp.setImage(image.getImageUrl());
} else {
imageList.add(image.getImageUrl());
}
}
resp.setImageList(imageList);
resp.setPrice(sp.getPrice().toString());
resp.setSizeName(size.getSizeName() + "码");
resp.setProductName(product.getProductName());
resp.setProductCode(product.getProductCode());
resp.setColorName(goods.getGoodsName());
resp.setFlawAttr(secondhandInfo.getFlawAttr());
resp.setDescribeInfo(secondhandInfo.getDescribeInfo());
resp.setSechondHandTypeName(sp.getPreSaleFlag() == 5 ? "全新瑕疵" : "二手");
if (secondhandInfo != null && StringUtils.isNotBlank(secondhandInfo.getFlawId())) {
List<SecondhandFlaw> flaws = secondhandFlawMapper.selectByIds(secondhandInfo.getFlawId());
resp.setFlawInfo(flaws.stream().map(SecondhandFlaw::getName).collect(Collectors.toList()));
}
return resp;
}
}
... ...