|
@@ -437,13 +437,30 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String current = dateFormat.format(date);
|
|
|
// 图片
|
|
|
- String[] images = secondDto.getImage().split(",");
|
|
|
+
|
|
|
// 组装数据
|
|
|
ProductPo product = new ProductPo();
|
|
|
+ if (null != secondDto.getImage()) {
|
|
|
+ String[] images = secondDto.getImage().split(",");
|
|
|
+ product.setMainImage(images[0]);
|
|
|
+ /* 保存商品图片信息*/
|
|
|
+ for (int i = 0; i < images.length; i++) {
|
|
|
+ ProductImagePo imagePo = new ProductImagePo();
|
|
|
+ imagePo.setProductId(product.getProductId());
|
|
|
+ imagePo.setShopId(1252);
|
|
|
+ imagePo.setAddTime(current);
|
|
|
+ imagePo.setImage(images[i]);
|
|
|
+ if (i == 0) {
|
|
|
+ imagePo.setMainFlag(1);
|
|
|
+ } else {
|
|
|
+ imagePo.setMainFlag(0);
|
|
|
+ }
|
|
|
+ secondHandMapper.insertProductImage(imagePo);
|
|
|
+ }
|
|
|
+ }
|
|
|
product.setBrandId(secondDto.getBrandId());
|
|
|
product.setName(secondDto.getName());
|
|
|
product.setAliasName(secondDto.getName());
|
|
|
- product.setMainImage(images[0]);
|
|
|
// 二手商品类型
|
|
|
product.setProductCategory(2);
|
|
|
product.setPreferredFlag(0);
|
|
@@ -485,20 +502,6 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
sku.setCostProportional(95d);
|
|
|
sku.setProductId(product.getProductId());
|
|
|
shopMapper.insertSku(sku);
|
|
|
- /* 保存商品图片信息*/
|
|
|
- for (int i = 0; i < images.length; i++) {
|
|
|
- ProductImagePo imagePo = new ProductImagePo();
|
|
|
- imagePo.setProductId(product.getProductId());
|
|
|
- imagePo.setShopId(1252);
|
|
|
- imagePo.setAddTime(current);
|
|
|
- imagePo.setImage(images[i]);
|
|
|
- if (i == 0) {
|
|
|
- imagePo.setMainFlag(1);
|
|
|
- } else {
|
|
|
- imagePo.setMainFlag(0);
|
|
|
- }
|
|
|
- secondHandMapper.insertProductImage(imagePo);
|
|
|
- }
|
|
|
ProductSecondPo secondPo = new ProductSecondPo();
|
|
|
// 保存附赠详细信息关系
|
|
|
secondPo.setProductId(product.getProductId());
|