Authored by caoyan

自助尺码

... ... @@ -10,6 +10,6 @@ public interface SelfSizeMapper {
int insertBatch(@Param("list") List<SelfSize> list);
List<SelfSize> selectByProductIdAndSizeId(@Param("productId") Integer productId, @Param("sizeIds") String sizeIds);
List<SelfSize> selectByProductIdAndSizeId(@Param("productId") Integer productId, @Param("sizeIdList") List<Integer> sizeIdList);
}
\ No newline at end of file
... ...
... ... @@ -10,6 +10,6 @@ public interface SelfSizeUidMapper {
int insertBatch(@Param("list") List<SelfSizeUid> list);
List<SelfSizeUid> selectByProductIdAndSizeId(@Param("productId") Integer productId, @Param("sizeIds") String sizeIds);
List<SelfSizeUid> selectByProductIdAndSizeId(@Param("productId") Integer productId, @Param("sizeIdList") List<Integer> sizeIdList);
}
\ No newline at end of file
... ...
... ... @@ -24,7 +24,10 @@
<select id="selectByProductIdAndSizeId" resultMap="BaseResultMap">
select id, product_id, goods_id, size_id
from self_size
where product_id=#{productId} and size_id in (#{sizeIds}) and status=0
where status=0 and product_id=#{productId} and size_id in
<foreach item="sizeId" index="index" collection="sizeIdList" open="(" separator="," close=")">
#{sizeId}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -25,7 +25,10 @@
<select id="selectByProductIdAndSizeId" resultMap="BaseResultMap">
select product_id, goods_id, size_id, uid, create_time
from self_size_uid
where product_id=#{productId} and size_id in (#{sizeIds})
where product_id=#{productId} and size_id in
<foreach item="sizeId" index="index" collection="sizeIdList" open="(" separator="," close=")">
#{sizeId}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -1701,6 +1701,7 @@ public class ProductServiceImpl implements ProductService {
//校验sizeId
String[] sizeIdArr = sizeIds.split(",");
List<Integer> sizeIdList = buildSizeIdList(sizeIdArr);
List<SelfSize> needAddRecordList = Lists.newArrayList();
List<SelfSizeUid> needRelateUidList = Lists.newArrayList();
... ... @@ -1709,14 +1710,14 @@ public class ProductServiceImpl implements ProductService {
List<Integer> existSizeIdList = storageList.stream().map(Storage::getSizeId).collect(Collectors.toList());
List<Size> sizeList = sizeMapper.selectByIds(existSizeIdList);
Map<Integer, String> sizeIdNameMap = sizeList.stream().collect(Collectors.toMap(Size::getId, Size::getSizeName));
List<SelfSize> existRecordList = selfSizeMapper.selectByProductIdAndSizeId(productId, sizeIds);
List<SelfSize> existRecordList = selfSizeMapper.selectByProductIdAndSizeId(productId, sizeIdList);
Map<Integer, SelfSize> selfSizeMap = existRecordList.stream().collect(Collectors.toMap(SelfSize::getSizeId, s->s));
if(MapUtils.isEmpty(selfSizeMap)) {
selfSizeMap = Maps.newHashMap();
}
//自助尺码uid关联表
List<SelfSizeUid> selfSizeUidList = selfSizeUidMapper.selectByProductIdAndSizeId(productId, sizeIds);
List<SelfSizeUid> selfSizeUidList = selfSizeUidMapper.selectByProductIdAndSizeId(productId, sizeIdList);
Map<Integer, List<SelfSizeUid>> sizeIdUidMap = selfSizeUidList.stream().collect(Collectors.groupingBy(SelfSizeUid::getSizeId));
List<String> warnSizeNameList = Lists.newArrayList();
... ... @@ -1772,6 +1773,15 @@ public class ProductServiceImpl implements ProductService {
}
private List<Integer> buildSizeIdList(String[] sizeIdArr){
List<Integer> sizeIdList = Lists.newArrayList();
for(int i=0; i<sizeIdArr.length; i++) {
sizeIdList.add(Integer.parseInt(sizeIdArr[i]));
}
return sizeIdList;
}
private String getGoodsDeafultImage(Integer goodsId) {
List<GoodsImages> goodsImages = goodsImagesMapper.selectByGoodsId(goodsId);
String defaultYImage = null;
... ...