Authored by caoyan

自助尺码

@@ -10,6 +10,6 @@ public interface SelfSizeMapper { @@ -10,6 +10,6 @@ public interface SelfSizeMapper {
10 10
11 int insertBatch(@Param("list") List<SelfSize> list); 11 int insertBatch(@Param("list") List<SelfSize> list);
12 12
13 - List<SelfSize> selectByProductIdAndSizeId(@Param("productId") Integer productId, @Param("sizeIds") String sizeIds); 13 + List<SelfSize> selectByProductIdAndSizeId(@Param("productId") Integer productId, @Param("sizeIdList") List<Integer> sizeIdList);
14 14
15 } 15 }
@@ -10,6 +10,6 @@ public interface SelfSizeUidMapper { @@ -10,6 +10,6 @@ public interface SelfSizeUidMapper {
10 10
11 int insertBatch(@Param("list") List<SelfSizeUid> list); 11 int insertBatch(@Param("list") List<SelfSizeUid> list);
12 12
13 - List<SelfSizeUid> selectByProductIdAndSizeId(@Param("productId") Integer productId, @Param("sizeIds") String sizeIds); 13 + List<SelfSizeUid> selectByProductIdAndSizeId(@Param("productId") Integer productId, @Param("sizeIdList") List<Integer> sizeIdList);
14 14
15 } 15 }
@@ -24,7 +24,10 @@ @@ -24,7 +24,10 @@
24 <select id="selectByProductIdAndSizeId" resultMap="BaseResultMap"> 24 <select id="selectByProductIdAndSizeId" resultMap="BaseResultMap">
25 select id, product_id, goods_id, size_id 25 select id, product_id, goods_id, size_id
26 from self_size 26 from self_size
27 - where product_id=#{productId} and size_id in (#{sizeIds}) and status=0 27 + where status=0 and product_id=#{productId} and size_id in
  28 + <foreach item="sizeId" index="index" collection="sizeIdList" open="(" separator="," close=")">
  29 + #{sizeId}
  30 + </foreach>
28 </select> 31 </select>
29 32
30 </mapper> 33 </mapper>
@@ -25,7 +25,10 @@ @@ -25,7 +25,10 @@
25 <select id="selectByProductIdAndSizeId" resultMap="BaseResultMap"> 25 <select id="selectByProductIdAndSizeId" resultMap="BaseResultMap">
26 select product_id, goods_id, size_id, uid, create_time 26 select product_id, goods_id, size_id, uid, create_time
27 from self_size_uid 27 from self_size_uid
28 - where product_id=#{productId} and size_id in (#{sizeIds}) 28 + where product_id=#{productId} and size_id in
  29 + <foreach item="sizeId" index="index" collection="sizeIdList" open="(" separator="," close=")">
  30 + #{sizeId}
  31 + </foreach>
29 </select> 32 </select>
30 33
31 </mapper> 34 </mapper>
@@ -1701,6 +1701,7 @@ public class ProductServiceImpl implements ProductService { @@ -1701,6 +1701,7 @@ public class ProductServiceImpl implements ProductService {
1701 1701
1702 //校验sizeId 1702 //校验sizeId
1703 String[] sizeIdArr = sizeIds.split(","); 1703 String[] sizeIdArr = sizeIds.split(",");
  1704 + List<Integer> sizeIdList = buildSizeIdList(sizeIdArr);
1704 List<SelfSize> needAddRecordList = Lists.newArrayList(); 1705 List<SelfSize> needAddRecordList = Lists.newArrayList();
1705 List<SelfSizeUid> needRelateUidList = Lists.newArrayList(); 1706 List<SelfSizeUid> needRelateUidList = Lists.newArrayList();
1706 1707
@@ -1709,14 +1710,14 @@ public class ProductServiceImpl implements ProductService { @@ -1709,14 +1710,14 @@ public class ProductServiceImpl implements ProductService {
1709 List<Integer> existSizeIdList = storageList.stream().map(Storage::getSizeId).collect(Collectors.toList()); 1710 List<Integer> existSizeIdList = storageList.stream().map(Storage::getSizeId).collect(Collectors.toList());
1710 List<Size> sizeList = sizeMapper.selectByIds(existSizeIdList); 1711 List<Size> sizeList = sizeMapper.selectByIds(existSizeIdList);
1711 Map<Integer, String> sizeIdNameMap = sizeList.stream().collect(Collectors.toMap(Size::getId, Size::getSizeName)); 1712 Map<Integer, String> sizeIdNameMap = sizeList.stream().collect(Collectors.toMap(Size::getId, Size::getSizeName));
1712 - List<SelfSize> existRecordList = selfSizeMapper.selectByProductIdAndSizeId(productId, sizeIds); 1713 + List<SelfSize> existRecordList = selfSizeMapper.selectByProductIdAndSizeId(productId, sizeIdList);
1713 Map<Integer, SelfSize> selfSizeMap = existRecordList.stream().collect(Collectors.toMap(SelfSize::getSizeId, s->s)); 1714 Map<Integer, SelfSize> selfSizeMap = existRecordList.stream().collect(Collectors.toMap(SelfSize::getSizeId, s->s));
1714 if(MapUtils.isEmpty(selfSizeMap)) { 1715 if(MapUtils.isEmpty(selfSizeMap)) {
1715 selfSizeMap = Maps.newHashMap(); 1716 selfSizeMap = Maps.newHashMap();
1716 } 1717 }
1717 1718
1718 //自助尺码uid关联表 1719 //自助尺码uid关联表
1719 - List<SelfSizeUid> selfSizeUidList = selfSizeUidMapper.selectByProductIdAndSizeId(productId, sizeIds); 1720 + List<SelfSizeUid> selfSizeUidList = selfSizeUidMapper.selectByProductIdAndSizeId(productId, sizeIdList);
1720 Map<Integer, List<SelfSizeUid>> sizeIdUidMap = selfSizeUidList.stream().collect(Collectors.groupingBy(SelfSizeUid::getSizeId)); 1721 Map<Integer, List<SelfSizeUid>> sizeIdUidMap = selfSizeUidList.stream().collect(Collectors.groupingBy(SelfSizeUid::getSizeId));
1721 1722
1722 List<String> warnSizeNameList = Lists.newArrayList(); 1723 List<String> warnSizeNameList = Lists.newArrayList();
@@ -1772,6 +1773,15 @@ public class ProductServiceImpl implements ProductService { @@ -1772,6 +1773,15 @@ public class ProductServiceImpl implements ProductService {
1772 1773
1773 } 1774 }
1774 1775
  1776 + private List<Integer> buildSizeIdList(String[] sizeIdArr){
  1777 + List<Integer> sizeIdList = Lists.newArrayList();
  1778 + for(int i=0; i<sizeIdArr.length; i++) {
  1779 + sizeIdList.add(Integer.parseInt(sizeIdArr[i]));
  1780 + }
  1781 + return sizeIdList;
  1782 + }
  1783 +
  1784 +
1775 private String getGoodsDeafultImage(Integer goodsId) { 1785 private String getGoodsDeafultImage(Integer goodsId) {
1776 List<GoodsImages> goodsImages = goodsImagesMapper.selectByGoodsId(goodsId); 1786 List<GoodsImages> goodsImages = goodsImagesMapper.selectByGoodsId(goodsId);
1777 String defaultYImage = null; 1787 String defaultYImage = null;