Authored by mali

Merge branch 'dev_secondlist_productcode' into test6.9.3

... ... @@ -7,6 +7,8 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
import java.util.List;
/**
* Created by caoyan.
*/
... ... @@ -34,4 +36,8 @@ public class SecondhandReq extends PageRequestBO{
private Integer sku;
private Integer sizeId;
private String productCode;
private List<Integer> productIdList;
}
... ...
... ... @@ -49,6 +49,8 @@ public class SecondhandRsp {
private String productName;
private String productImage;
private String productCode;
private String rejectReason;
... ...
... ... @@ -401,6 +401,12 @@
<if test="secondhandReq.sizeId != null">
and b.size_id=#{secondhandReq.sizeId}
</if>
<if test="secondhandReq.productIdList != null and secondhandReq.productIdList.size()>0">
and a.product_id in
<foreach item="productId" collection="secondhandReq.productIdList" open="(" separator="," close=")">
#{productId}
</foreach>
</if>
</sql>
<select id="selectSecondTotalByCondition" resultType="java.lang.Integer" parameterType="com.yoho.product.model.SecondhandReq">
... ...
... ... @@ -5,9 +5,12 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.yoho.ufo.util.CollectionUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.collect.Maps;
import org.slf4j.Logger;
... ... @@ -102,8 +105,14 @@ public class SecondhandProductService implements ISecondhandProductService{
@Override
public PageResponseBO<SecondhandRsp> querySecondhandSkupList(SecondhandReq req) {
int total = storagePriceMapper.selectSecondTotalByCondition(req);
if (StringUtils.isNotBlank(req.getProductCode())) {
List<Product> productList = productMapper.selectByProductCode(req.getProductCode());
if (productList.isEmpty()) {
return null;
}
req.setProductIdList(CollectionUtil.distinct(productList, Product::getId));
}
int total = storagePriceMapper.selectSecondTotalByCondition(req);
if(total == 0) {
return null;
}
... ... @@ -130,7 +139,7 @@ public class SecondhandProductService implements ISecondhandProductService{
//查询product
List<Integer> productIdList = storagePriceList.stream().map(StoragePrice::getProductId).collect(Collectors.toList());
List<Product> productList = productMapper.selectProductListByIds(productIdList);
Map<Integer, String> productIdNameMap = productList.stream().collect(Collectors.toMap(Product::getId, Product::getProductName));
Map<Integer, Product> productMap = productList.stream().collect(Collectors.toMap(Product::getId, Function.identity()));
//查询secondhand_flaw
List<String> flawIdStrList = infoList.stream().map(SecondhandInfo::getFlawId).collect(Collectors.toList());
... ... @@ -142,7 +151,7 @@ public class SecondhandProductService implements ISecondhandProductService{
Map<Integer, String> goodsIdImageMap = goodsImagesList.stream().collect(Collectors.toMap(GoodsImages::getProductId, GoodsImages::getImageUrl));
//组装
List<SecondhandRsp> respList = convertToResp(storagePriceList, skupImageMap, secondhandInfoMap, sellerGoodsMap, productIdNameMap, flawMap, goodsIdImageMap);
List<SecondhandRsp> respList = convertToResp(storagePriceList, skupImageMap, secondhandInfoMap, sellerGoodsMap, productMap, flawMap, goodsIdImageMap);
PageResponseBO<SecondhandRsp> result=new PageResponseBO<>();
result.setList(respList);
... ... @@ -234,8 +243,8 @@ public class SecondhandProductService implements ISecondhandProductService{
}
private List<SecondhandRsp> convertToResp(List<StoragePrice> storagePriceList, Map<Integer, List<SecondhandImages>> skupImageMap,
Map<Integer, SecondhandInfo> infoMap, Map<Integer, SellerOrderGoods> sellerGoodsMap,
Map<Integer, String> productIdNameMap, Map<Integer, String> flawMap, Map<Integer, String> goodsIdImageMap){
Map<Integer, SecondhandInfo> infoMap, Map<Integer, SellerOrderGoods> sellerGoodsMap,
Map<Integer, Product> productMap, Map<Integer, String> flawMap, Map<Integer, String> goodsIdImageMap){
List<SecondhandRsp> respList = Lists.newArrayList();
for(StoragePrice item : storagePriceList) {
SecondhandRsp rsp = new SecondhandRsp();
... ... @@ -251,7 +260,11 @@ public class SecondhandProductService implements ISecondhandProductService{
rsp.setPrice(String.valueOf(item.getPrice()));
rsp.setStatus(item.getStatus());
rsp.setSku(item.getStorageId());
rsp.setProductName(productIdNameMap.get(item.getProductId()));
Product p = productMap.get(item.getProductId());
if (p != null) {
rsp.setProductName(p.getProductName());
rsp.setProductCode(p.getProductCode());
}
SellerOrderGoods sellerGoods = sellerGoodsMap.get(skup);
if(null != sellerGoods) {
... ...
... ... @@ -16,6 +16,7 @@
<input id="sellerUid" type="text"/>
<input id="sku" type="text"/>
<input id="sizeId" type="text"/>
<input id="productCode" type="text"/>
<a id="searchBtn" class="btn-info">筛选</a>
<a id="allBtn" class="btn-info">全部</a>
</div>
... ... @@ -86,6 +87,9 @@ $(function() {
return defaultLoadFilter(data);
}
});
$("#productCode").textbox({
prompt: "货号"
});
$("#searchBtn").linkbutton({
iconCls : "icon-search",
... ... @@ -176,7 +180,8 @@ function getSkupList(status){
skupType: $('#skupType').combobox('getValue'),
sellerUid: $('#sellerUid').val(),
sku: $('#sku').val(),
sizeId: $('#sizeId').combobox('getValue')
sizeId: $('#sizeId').combobox('getValue'),
productCode: $('#productCode').val(),
},
loadFilter: function (data) {
var temp = defaultLoadFilter(data);
... ... @@ -316,6 +321,11 @@ function getTableColumn() {
return "<img height='100px;' width='80px;' src='"+value+"'/>";
}
}, {
title: "货号",
field: "productCode",
width: 50,
align: "center"
}, {
title: "商品信息",
field: "productInfo",
width: 30,
... ... @@ -464,6 +474,7 @@ function getCountByStatus(){
form.append("sellerUid", $("#sellerUid").textbox("getValue"));
form.append("sku", $("#sku").textbox("getValue"));
form.append("sizeId", $("#sizeId").combobox("getValue"));
form.append("productCode", $("#productCode").textbox("getValue"));
//发送请求
$.ajax({
type: "POST",
... ...