|
@@ -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,10 +420,10 @@ public static void main(String[] args) { |
|
@@ -413,10 +420,10 @@ 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;
|
|
|
423
|
+ if(CollectionUtils.isNotEmpty(aStorageList)) {
|
416
|
for(Storage s : aStorageList) {
|
424
|
for(Storage s : aStorageList) {
|
417
|
countStock += s.getStorageNum();
|
425
|
countStock += s.getStorageNum();
|
418
|
}
|
426
|
}
|
419
|
- respBo.setStorage(countStock);
|
|
|
420
|
List<ProductResponceBo> skuList = new ArrayList<>();
|
427
|
List<ProductResponceBo> skuList = new ArrayList<>();
|
421
|
respBo.setSkuList(skuList);
|
428
|
respBo.setSkuList(skuList);
|
422
|
//respBo
|
429
|
//respBo
|
|
@@ -433,6 +440,8 @@ public static void main(String[] args) { |
|
@@ -433,6 +440,8 @@ public static void main(String[] args) { |
433
|
skuList.add(skuBo);
|
440
|
skuList.add(skuBo);
|
434
|
}
|
441
|
}
|
435
|
}
|
442
|
}
|
|
|
443
|
+ respBo.setStorage(countStock);
|
|
|
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());
|
438
|
return new ApiResponse<>(pageBo);
|
447
|
return new ApiResponse<>(pageBo);
|
|
@@ -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
|
}
|