|
@@ -21,6 +21,7 @@ import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
@@ -111,7 +112,7 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public ResponseJson<SecondDetailVo> getSecondHandDetail(Integer userId, Integer productId) {
|
|
public ResponseJson<SecondDetailVo> getSecondHandDetail(Integer userId, Integer productId) {
|
|
- SecondDetailVo second = secondHandMapper.getSecondHandDetail(productId);
|
|
|
|
|
|
+ SecondDetailVo second = secondHandMapper.getSecondHandDetail(userId, productId);
|
|
Integer type = null == second.getSecondProductType() ? 0 : second.getSecondProductType();
|
|
Integer type = null == second.getSecondProductType() ? 0 : second.getSecondProductType();
|
|
List<Integer> ids = secondHandMapper.getNewAddProductIds(type);
|
|
List<Integer> ids = secondHandMapper.getNewAddProductIds(type);
|
|
Integer newFlag = ids.contains(second.getProductId()) ? 1 : 0;
|
|
Integer newFlag = ids.contains(second.getProductId()) ? 1 : 0;
|
|
@@ -451,15 +452,17 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
sku.setProductId(product.getProductId());
|
|
sku.setProductId(product.getProductId());
|
|
shopMapper.insertSku(sku);
|
|
shopMapper.insertSku(sku);
|
|
} else {
|
|
} else {
|
|
|
|
+ product.setProductId(secondDto.getProductId());
|
|
shopMapper.updateProduct(product);
|
|
shopMapper.updateProduct(product);
|
|
shopMapper.deleteProductImageById(product.getProductId());
|
|
shopMapper.deleteProductImageById(product.getProductId());
|
|
}
|
|
}
|
|
if (null != secondDto.getProductImages()) {
|
|
if (null != secondDto.getProductImages()) {
|
|
List<String> productImages = secondDto.getProductImages();
|
|
List<String> productImages = secondDto.getProductImages();
|
|
|
|
+ Integer shopId = newFlag ? 1252 : null;
|
|
productImages.forEach(image -> {
|
|
productImages.forEach(image -> {
|
|
ProductImagePo imagePo = new ProductImagePo();
|
|
ProductImagePo imagePo = new ProductImagePo();
|
|
imagePo.setProductId(product.getProductId());
|
|
imagePo.setProductId(product.getProductId());
|
|
- imagePo.setShopId(1252);
|
|
|
|
|
|
+ imagePo.setShopId(shopId);
|
|
imagePo.setAddTime(current);
|
|
imagePo.setAddTime(current);
|
|
imagePo.setImage(image);
|
|
imagePo.setImage(image);
|
|
imagePo.setMainFlag(3);
|
|
imagePo.setMainFlag(3);
|
|
@@ -468,11 +471,12 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
}
|
|
}
|
|
if (null != secondDto.getImage()) {
|
|
if (null != secondDto.getImage()) {
|
|
String[] images = secondDto.getImage().split(",");
|
|
String[] images = secondDto.getImage().split(",");
|
|
|
|
+ Integer shopId = newFlag ? 1252 : null;
|
|
/* 保存商品图片信息*/
|
|
/* 保存商品图片信息*/
|
|
for (int i = 0; i < images.length; i++) {
|
|
for (int i = 0; i < images.length; i++) {
|
|
ProductImagePo imagePo = new ProductImagePo();
|
|
ProductImagePo imagePo = new ProductImagePo();
|
|
imagePo.setProductId(product.getProductId());
|
|
imagePo.setProductId(product.getProductId());
|
|
- imagePo.setShopId(1252);
|
|
|
|
|
|
+ imagePo.setShopId(shopId);
|
|
imagePo.setAddTime(current);
|
|
imagePo.setAddTime(current);
|
|
imagePo.setImage(images[i]);
|
|
imagePo.setImage(images[i]);
|
|
if (i == 0) {
|
|
if (i == 0) {
|
|
@@ -527,7 +531,11 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
secondPo.setCommitmentImage(secondDto.getCommitmentImage());
|
|
secondPo.setCommitmentImage(secondDto.getCommitmentImage());
|
|
secondPo.setPublishMethod(secondDto.getPublishMethod());
|
|
secondPo.setPublishMethod(secondDto.getPublishMethod());
|
|
secondPo.setPublishIdentity(secondDto.getPublishIdentity());
|
|
secondPo.setPublishIdentity(secondDto.getPublishIdentity());
|
|
- if(newFlag){
|
|
|
|
|
|
+ secondPo.setBrandId(secondDto.getBrandId());
|
|
|
|
+ if (null != secondDto.getBrandName()) {
|
|
|
|
+ secondPo.setBrandName(secondDto.getBrandName());
|
|
|
|
+ }
|
|
|
|
+ if (newFlag) {
|
|
// 默认设置未出售
|
|
// 默认设置未出售
|
|
secondPo.setSold(0);
|
|
secondPo.setSold(0);
|
|
// 付款状态1:待支付、2已付款
|
|
// 付款状态1:待支付、2已付款
|
|
@@ -538,9 +546,9 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
secondPo.setViewingNum(0);
|
|
secondPo.setViewingNum(0);
|
|
/* 保存商品二手附加详细信息 */
|
|
/* 保存商品二手附加详细信息 */
|
|
secondHandMapper.saveSencondHandProduct(secondPo);
|
|
secondHandMapper.saveSencondHandProduct(secondPo);
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
secondHandMapper.updateSecondHandProduct(secondPo);
|
|
secondHandMapper.updateSecondHandProduct(secondPo);
|
|
- secondHandMapper.deleteFileTypes(product.getProductId());
|
|
|
|
|
|
+ secondHandMapper.deleteFileTypes(secondDto.getProductId());
|
|
}
|
|
}
|
|
//保存商品包含文件
|
|
//保存商品包含文件
|
|
if (StringUtils.isNotBlank(secondDto.getFileType())) {
|
|
if (StringUtils.isNotBlank(secondDto.getFileType())) {
|
|
@@ -612,7 +620,7 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public ResponseJson<Integer> updateSecondHandViews(Integer productId) {
|
|
public ResponseJson<Integer> updateSecondHandViews(Integer productId) {
|
|
- SecondDetailVo second = secondHandMapper.getSecondHandDetail(productId);
|
|
|
|
|
|
+ SecondDetailVo second = secondHandMapper.getSecondHandDetail(null, productId);
|
|
Integer viewingNum = 0;
|
|
Integer viewingNum = 0;
|
|
if (null != second) {
|
|
if (null != second) {
|
|
viewingNum = second.getViewingNum();
|
|
viewingNum = second.getViewingNum();
|
|
@@ -672,7 +680,7 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
if (result != null) {
|
|
if (result != null) {
|
|
return ResponseJson.error("参数异常:联系方式不正确");
|
|
return ResponseJson.error("参数异常:联系方式不正确");
|
|
}
|
|
}
|
|
- if(null == secondDto.getProductId()){
|
|
|
|
|
|
+ if (null == secondDto.getProductId()) {
|
|
//校验验证码
|
|
//校验验证码
|
|
String checkCode = secondDto.getCheckCode();
|
|
String checkCode = secondDto.getCheckCode();
|
|
if (StringUtils.isBlank(checkCode)) {
|
|
if (StringUtils.isBlank(checkCode)) {
|
|
@@ -752,7 +760,7 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ResponseJson<SecondDetailVo> getSecondProductDetail(Integer userId, Integer productId) {
|
|
public ResponseJson<SecondDetailVo> getSecondProductDetail(Integer userId, Integer productId) {
|
|
- SecondDetailVo second = secondHandMapper.getSecondHandDetail(productId);
|
|
|
|
|
|
+ SecondDetailVo second = secondHandMapper.getSecondHandDetail(userId, productId);
|
|
Integer type = null == second.getSecondProductType() ? 0 : second.getSecondProductType();
|
|
Integer type = null == second.getSecondProductType() ? 0 : second.getSecondProductType();
|
|
List<Integer> ids = secondHandMapper.getNewAddProductIds(type);
|
|
List<Integer> ids = secondHandMapper.getNewAddProductIds(type);
|
|
Integer newFlag = ids.contains(second.getProductId()) ? 1 : 0;
|
|
Integer newFlag = ids.contains(second.getProductId()) ? 1 : 0;
|
|
@@ -836,4 +844,11 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
PaginationVo<SecondListVo> pageData = new PaginationVo<SecondListVo>(secondList);
|
|
PaginationVo<SecondListVo> pageData = new PaginationVo<SecondListVo>(secondList);
|
|
return ResponseJson.success(pageData);
|
|
return ResponseJson.success(pageData);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson updateSecondHandStatus(Integer productId) {
|
|
|
|
+ secondHandMapper.updateSecondHandStatus(productId);
|
|
|
|
+ return ResponseJson.success();
|
|
|
|
+ }
|
|
}
|
|
}
|