Authored by Lixiaodi

修改bug

@@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
45 select id, product_id, color_id, color_name, goods_name, color_image, is_default 45 select id, product_id, color_id, color_name, goods_name, color_image, is_default
46 from goods 46 from goods
47 where product_id in 47 where product_id in
48 - <foreach item="item" index="index" collection="productIds" open="(" separator="," close=")"> 48 + <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
49 #{item} 49 #{item}
50 </foreach> 50 </foreach>
51 </select> 51 </select>
@@ -54,14 +54,9 @@ @@ -54,14 +54,9 @@
54 sale_time = #{saleTime,jdbcType=INTEGER}, 54 sale_time = #{saleTime,jdbcType=INTEGER},
55 min_price = #{minPrice,jdbcType=DECIMAL}, 55 min_price = #{minPrice,jdbcType=DECIMAL},
56 max_price = #{maxPrice,jdbcType=DECIMAL}, 56 max_price = #{maxPrice,jdbcType=DECIMAL},
57 - create_time = #{createTime,jdbcType=INTEGER},  
58 - update_time = #{updateTime,jdbcType=INTEGER},  
59 - shelve_time = #{shelveTime,jdbcType=INTEGER},  
60 - edit_time = #{editTime,jdbcType=INTEGER},  
61 - shelve_status = #{shelveStatus,jdbcType=INTEGER},  
62 - storage = #{storage,jdbcType=INTEGER},  
63 - key_words = #{keyWords,jdbcType=VARCHAR},  
64 - del_status = #{delStatus,jdbcType=INTEGER} 57 + update_time = unix_timestamp(),
  58 + edit_time = unix_timestamp(),
  59 + key_words = #{keyWords,jdbcType=VARCHAR}
65 where id = #{id,jdbcType=INTEGER} 60 where id = #{id,jdbcType=INTEGER}
66 </update> 61 </update>
67 <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> 62 <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
@@ -82,10 +77,10 @@ @@ -82,10 +77,10 @@
82 select id, product_name, product_code, max_sort_id, mid_sort_id, brand_id, series_id, 77 select id, product_name, product_code, max_sort_id, mid_sort_id, brand_id, series_id,
83 gender, sale_time, min_price, max_price, create_time, update_time, shelve_time, edit_time, 78 gender, sale_time, min_price, max_price, create_time, update_time, shelve_time, edit_time,
84 shelve_status, storage, key_words, del_status 79 shelve_status, storage, key_words, del_status
85 - from product where 1=1 and <include refid="pageCondition" /> order by product.id desc limit #{start},#{rows} 80 + from product where 1=1 <include refid="pageCondition" /> order by product.id desc limit #{start},#{rows}
86 </select> 81 </select>
87 - <select id="selectCount" resultMap="java.lang.Integer">  
88 - select count(*) from product where 1=1 and <include refid="pageCondition" /> 82 + <select id="selectCount" resultType="java.lang.Integer">
  83 + select count(*) from product where 1=1 <include refid="pageCondition" />
89 </select> 84 </select>
90 85
91 <sql id="pageCondition" > 86 <sql id="pageCondition" >
@@ -112,7 +107,7 @@ @@ -112,7 +107,7 @@
112 <select id="selectSkuPage" resultMap="BaseResultMap"> 107 <select id="selectSkuPage" resultMap="BaseResultMap">
113 select distinct p.id from product p <include refid="skuPageCondition" /> order by p.id desc limit #{start},#{rows} 108 select distinct p.id from product p <include refid="skuPageCondition" /> order by p.id desc limit #{start},#{rows}
114 </select> 109 </select>
115 - <select id="selectSkuCount" resultMap="java.lang.Integer"> 110 + <select id="selectSkuCount" resultType="java.lang.Integer">
116 select count(*) from (select distinct p.id from product p <include refid="skuPageCondition" /> ) sub 111 select count(*) from (select distinct p.id from product p <include refid="skuPageCondition" /> ) sub
117 </select> 112 </select>
118 113
@@ -55,7 +55,7 @@ @@ -55,7 +55,7 @@
55 </select> 55 </select>
56 56
57 <select id="selectMinPriceByProductIdList" resultMap="BaseResultMap"> 57 <select id="selectMinPriceByProductIdList" resultMap="BaseResultMap">
58 - select product_id, min(price) as price, 58 + select product_id, min(price) as price
59 from storage_price where product_id in 59 from storage_price where product_id in
60 <foreach item="item" index="index" collection="list" open="(" separator="," close=")"> 60 <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
61 #{item} 61 #{item}
@@ -78,7 +78,7 @@ @@ -78,7 +78,7 @@
78 <include refid="skupPageCondition" /> order by id desc limit #{start},#{rows} 78 <include refid="skupPageCondition" /> order by id desc limit #{start},#{rows}
79 </select> 79 </select>
80 80
81 - <select id="selectCount" resultMap="BaseResultMap"> 81 + <select id="selectCount" resultType="java.lang.Integer">
82 select count(*) 82 select count(*)
83 from storage_price where storage_id = #{storageId} 83 from storage_price where storage_id = #{storageId}
84 <include refid="skupPageCondition" /> 84 <include refid="skupPageCondition" />
@@ -73,14 +73,17 @@ public class ProductServiceImpl implements IProductService { @@ -73,14 +73,17 @@ public class ProductServiceImpl implements IProductService {
73 List<GoodsImages> goodsImagesList = getGoodsImagesFromBo(bo); 73 List<GoodsImages> goodsImagesList = getGoodsImagesFromBo(bo);
74 Integer productId; 74 Integer productId;
75 Integer goodsId; 75 Integer goodsId;
  76 + int now = (int) (System.currentTimeMillis() / 1000);
76 // 新增 77 // 新增
77 if (bo.getId() == null || bo.getId() < 1) { 78 if (bo.getId() == null || bo.getId() < 1) {
  79 + product.setShelveTime(0);
  80 + product.setEditTime(0);
  81 + product.setStorage(0);
78 if (productMapper.insert(product) == 0) { 82 if (productMapper.insert(product) == 0) {
79 return new ApiResponse<Void>(500, "创建商品失败"); 83 return new ApiResponse<Void>(500, "创建商品失败");
80 } 84 }
81 productId = product.getId(); 85 productId = product.getId();
82 goods.setProductId(productId); 86 goods.setProductId(productId);
83 - goodsMapper.insert(goods);  
84 if (goodsMapper.insert(goods) == 0) { 87 if (goodsMapper.insert(goods) == 0) {
85 return new ApiResponse<Void>(500, "创建商品颜色失败"); 88 return new ApiResponse<Void>(500, "创建商品颜色失败");
86 } 89 }
@@ -98,6 +101,8 @@ public class ProductServiceImpl implements IProductService { @@ -98,6 +101,8 @@ public class ProductServiceImpl implements IProductService {
98 for (Storage s : storageList) { 101 for (Storage s : storageList) {
99 s.setProductId(productId); 102 s.setProductId(productId);
100 s.setGoodsId(goodsId); 103 s.setGoodsId(goodsId);
  104 + s.setCreateTime(now);
  105 + s.setUpdateTime(0);
101 storageMapper.insert(s); 106 storageMapper.insert(s);
102 } 107 }
103 if (bo.getEditImage() != null && bo.getEditImage() == 1) { 108 if (bo.getEditImage() != null && bo.getEditImage() == 1) {
@@ -142,6 +147,7 @@ public class ProductServiceImpl implements IProductService { @@ -142,6 +147,7 @@ public class ProductServiceImpl implements IProductService {
142 private Goods getGoodsFromBo(ProductRequestBo bo) { 147 private Goods getGoodsFromBo(ProductRequestBo bo) {
143 Goods g = new Goods(); 148 Goods g = new Goods();
144 BeanUtils.copyProperties(bo, g); 149 BeanUtils.copyProperties(bo, g);
  150 + g.setId(bo.getGoodsId());
145 g.setIsDefault("Y"); 151 g.setIsDefault("Y");
146 if (CollectionUtils.isNotEmpty(bo.getImageUrlList())) { 152 if (CollectionUtils.isNotEmpty(bo.getImageUrlList())) {
147 g.setColorImage(bo.getImageUrlList().get(0)); 153 g.setColorImage(bo.getImageUrlList().get(0));
@@ -247,7 +253,8 @@ public class ProductServiceImpl implements IProductService { @@ -247,7 +253,8 @@ public class ProductServiceImpl implements IProductService {
247 ProductEditResponceBo bo = new ProductEditResponceBo(); 253 ProductEditResponceBo bo = new ProductEditResponceBo();
248 BeanUtils.copyProperties(product, bo); 254 BeanUtils.copyProperties(product, bo);
249 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 255 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
250 - bo.setSaleTime(sdf.format(product.getSaleTime() * 1000L)); 256 + bo.setSaleTime(sdf.format((product.getSaleTime() == null || product.getSaleTime() == 0) ? ""
  257 + : sdf.format(product.getSaleTime() * 1000L)));
251 bo.setGender(new Integer(product.getGender())); 258 bo.setGender(new Integer(product.getGender()));
252 bo.setMinPrice(product.getMinPrice().toString()); 259 bo.setMinPrice(product.getMinPrice().toString());
253 bo.setMaxPrice(product.getMaxPrice().toString()); 260 bo.setMaxPrice(product.getMaxPrice().toString());
@@ -413,25 +420,27 @@ public static void main(String[] args) { @@ -413,25 +420,27 @@ public static void main(String[] args) {
413 } 420 }
414 List<Storage> aStorageList = storageMap.get(goods.getId()); 421 List<Storage> aStorageList = storageMap.get(goods.getId());
415 int countStock = 0; 422 int countStock = 0;
416 - for(Storage s : aStorageList) {  
417 - countStock += s.getStorageNum();  
418 - }  
419 - respBo.setStorage(countStock);  
420 - List<ProductResponceBo> skuList = new ArrayList<>();  
421 - respBo.setSkuList(skuList);  
422 - //respBo  
423 - for(Storage s : aStorageList) {  
424 - ProductResponceBo skuBo = new ProductResponceBo();  
425 - skuBo.setId(s.getId());  
426 - skuBo.setGoodsName(goods.getGoodsName());  
427 - // 尺码  
428 - Size size = sizeMap.get(s.getSizeId());  
429 - if (size != null) {  
430 - skuBo.setSizeName(size.getSizeName()); 423 + if(CollectionUtils.isNotEmpty(aStorageList)) {
  424 + for(Storage s : aStorageList) {
  425 + countStock += s.getStorageNum();
  426 + }
  427 + List<ProductResponceBo> skuList = new ArrayList<>();
  428 + respBo.setSkuList(skuList);
  429 + //respBo
  430 + for(Storage s : aStorageList) {
  431 + ProductResponceBo skuBo = new ProductResponceBo();
  432 + skuBo.setId(s.getId());
  433 + skuBo.setGoodsName(goods.getGoodsName());
  434 + // 尺码
  435 + Size size = sizeMap.get(s.getSizeId());
  436 + if (size != null) {
  437 + skuBo.setSizeName(size.getSizeName());
  438 + }
  439 + skuBo.setStorage(s.getStorageNum());
  440 + skuList.add(skuBo);
431 } 441 }
432 - skuBo.setStorage(s.getStorageNum());  
433 - skuList.add(skuBo);  
434 } 442 }
  443 + respBo.setStorage(countStock);
435 } 444 }
436 } 445 }
437 PageResponseBO<ProductResponceBo> pageBo = new PageResponseBO<>(count, boList, bo.getPage(), bo.getRows()); 446 PageResponseBO<ProductResponceBo> pageBo = new PageResponseBO<>(count, boList, bo.getPage(), bo.getRows());
@@ -461,7 +470,8 @@ public static void main(String[] args) { @@ -461,7 +470,8 @@ public static void main(String[] args) {
461 b.setSellerUid(sp.getSellerUid()); 470 b.setSellerUid(sp.getSellerUid());
462 b.setCurrentPrice(sp.getPrice().toString()); 471 b.setCurrentPrice(sp.getPrice().toString());
463 b.setStatus(sp.getStatus()); 472 b.setStatus(sp.getStatus());
464 - b.setSkupCreateTime(sdf.format(sp.getCreateTime() * 1000L)); 473 + b.setSkupCreateTime((sp.getCreateTime() == null || sp.getCreateTime() == 0) ? ""
  474 + : sdf.format(sp.getCreateTime() * 1000L));
465 boList.add(b); 475 boList.add(b);
466 }); 476 });
467 } 477 }