|
@@ -19,13 +19,11 @@ import com.github.pagehelper.PageHelper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
-import org.springframework.data.redis.serializer.StringRedisSerializer;
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.io.Serializable;
|
|
|
|
import java.text.DecimalFormat;
|
|
import java.text.DecimalFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Calendar;
|
|
import java.util.Calendar;
|
|
@@ -106,7 +104,7 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
// 获取二手商品图片
|
|
// 获取二手商品图片
|
|
List<String> images = secondHandMapper.getImageByProductId(second.getProductId());
|
|
List<String> images = secondHandMapper.getImageByProductId(second.getProductId());
|
|
images.forEach(img -> {
|
|
images.forEach(img -> {
|
|
- img = ImageUtils.getImageURL("product", img, 0, domain);
|
|
|
|
|
|
+ ImageUtils.getImageURL("product", img, 0, domain);
|
|
});
|
|
});
|
|
second.setImageList(images);
|
|
second.setImageList(images);
|
|
}
|
|
}
|
|
@@ -406,38 +404,10 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
}
|
|
}
|
|
|
|
|
|
private ResponseJson saveSecondHandProduct(SecondDto secondDto) {
|
|
private ResponseJson saveSecondHandProduct(SecondDto secondDto) {
|
|
- /**
|
|
|
|
- * 当前版本二手商品作为黄页性质,不参与交易,shopId不需要
|
|
|
|
- //根据银行卡判断是否注册过特殊二手供应商,有则挂在之前的供应商名下,否则注册新供应商
|
|
|
|
- Integer shopId = secondHandMapper.findSecondShop(secondDto.getCardNumber());
|
|
|
|
- if (null == shopId || shopId <= 0) {
|
|
|
|
- //保存为特殊二手供应商
|
|
|
|
- ShopVo shopVo = new ShopVo();
|
|
|
|
- //1个人,2公司
|
|
|
|
- String name = 1 == secondDto.getPublishIdentity() ? secondDto.getContactName() : secondDto.getCompanyName();
|
|
|
|
- shopVo.setName(name);
|
|
|
|
- shopVo.setLinkMan(secondDto.getContactName());
|
|
|
|
- shopVo.setContractMobile(secondDto.getContactMobile());
|
|
|
|
- shopVo.setCardNumber(secondDto.getCardNumber());
|
|
|
|
- if (secondDto.getBanOfDeposit() != null) {
|
|
|
|
- shopVo.setBanOfDeposit(secondDto.getBanOfDeposit());
|
|
|
|
- }
|
|
|
|
- if (secondDto.getAccountName() != null) {
|
|
|
|
- shopVo.setAccountName(secondDto.getAccountName());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (secondDto.getAccountType() != null) {
|
|
|
|
- shopVo.setAccountType(secondDto.getAccountType());
|
|
|
|
- }
|
|
|
|
- secondHandMapper.insertShop(shopVo);
|
|
|
|
- shopId = shopVo.getShopId();
|
|
|
|
- }*/
|
|
|
|
// 设置日期时间格式
|
|
// 设置日期时间格式
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
String current = dateFormat.format(date);
|
|
String current = dateFormat.format(date);
|
|
- // 图片
|
|
|
|
-
|
|
|
|
// 组装数据
|
|
// 组装数据
|
|
ProductPo product = new ProductPo();
|
|
ProductPo product = new ProductPo();
|
|
if (null != secondDto.getImage()) {
|
|
if (null != secondDto.getImage()) {
|
|
@@ -458,6 +428,18 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
secondHandMapper.insertProductImage(imagePo);
|
|
secondHandMapper.insertProductImage(imagePo);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (null != secondDto.getProductImages()) {
|
|
|
|
+ List<String> productImages = secondDto.getProductImages();
|
|
|
|
+ productImages.forEach(image -> {
|
|
|
|
+ ProductImagePo imagePo = new ProductImagePo();
|
|
|
|
+ imagePo.setProductId(product.getProductId());
|
|
|
|
+ imagePo.setShopId(1252);
|
|
|
|
+ imagePo.setAddTime(current);
|
|
|
|
+ imagePo.setImage(image);
|
|
|
|
+ secondHandMapper.insertProductImage(imagePo);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ product.setPublishMethod(secondDto.getPublishMethod());
|
|
product.setBrandId(secondDto.getBrandId());
|
|
product.setBrandId(secondDto.getBrandId());
|
|
product.setName(secondDto.getName());
|
|
product.setName(secondDto.getName());
|
|
product.setAliasName(secondDto.getName());
|
|
product.setAliasName(secondDto.getName());
|
|
@@ -493,6 +475,7 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
secondHandMapper.insertProductValidFlag(product.getProductId(), product.getValidFlag());
|
|
secondHandMapper.insertProductValidFlag(product.getProductId(), product.getValidFlag());
|
|
/*保存sku数据*/
|
|
/*保存sku数据*/
|
|
Sku sku = new Sku();
|
|
Sku sku = new Sku();
|
|
|
|
+ sku.setOrganizeId(5);
|
|
sku.setPrice(secondDto.getPrice());
|
|
sku.setPrice(secondDto.getPrice());
|
|
sku.setStock(secondDto.getStock());
|
|
sku.setStock(secondDto.getStock());
|
|
sku.setNormalPrice(secondDto.getNormalPrice());
|
|
sku.setNormalPrice(secondDto.getNormalPrice());
|
|
@@ -532,7 +515,7 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
}
|
|
}
|
|
secondPo.setBuyFlag(secondDto.getBuyFlag());
|
|
secondPo.setBuyFlag(secondDto.getBuyFlag());
|
|
secondPo.setUserId(secondDto.getUserId());
|
|
secondPo.setUserId(secondDto.getUserId());
|
|
- secondPo.setSecondHandType(secondDto.getSecondHandType());
|
|
|
|
|
|
+ secondPo.setSecondHandType("1");
|
|
secondPo.setInstrumentType(secondDto.getInstrumentType());
|
|
secondPo.setInstrumentType(secondDto.getInstrumentType());
|
|
secondPo.setFixedYears(secondDto.getFixedYears());
|
|
secondPo.setFixedYears(secondDto.getFixedYears());
|
|
secondPo.setMaturityYears(secondDto.getMaturityYears());
|
|
secondPo.setMaturityYears(secondDto.getMaturityYears());
|
|
@@ -552,24 +535,8 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
secondPo.setOssName(secondDto.getOssName());
|
|
secondPo.setOssName(secondDto.getOssName());
|
|
secondPo.setAuthenticationImage(secondDto.getAuthenticationImage());
|
|
secondPo.setAuthenticationImage(secondDto.getAuthenticationImage());
|
|
secondPo.setCommitmentImage(secondDto.getCommitmentImage());
|
|
secondPo.setCommitmentImage(secondDto.getCommitmentImage());
|
|
- //新增字段,用户身份,营业执照,身份证背面
|
|
|
|
- secondPo.setPublishIdentity(secondDto.getPublishIdentity());
|
|
|
|
- secondPo.setLicenseImage(secondDto.getLicenseImage());
|
|
|
|
- secondPo.setAuthenticationBackImage(secondDto.getAuthenticationBackImage());
|
|
|
|
/* 保存商品二手附加详细信息 */
|
|
/* 保存商品二手附加详细信息 */
|
|
secondHandMapper.saveSencondHandProduct(secondPo);
|
|
secondHandMapper.saveSencondHandProduct(secondPo);
|
|
- //保存商品包含文件
|
|
|
|
- if (!"".equals(secondDto.getFileType()) || secondDto.getFileType() != null) {
|
|
|
|
- String fileTypes = secondDto.getFileType();
|
|
|
|
- if (fileTypes.contains(",")) {
|
|
|
|
- String[] split = fileTypes.split(",");
|
|
|
|
- for (String fileType : split) {
|
|
|
|
- secondHandMapper.insertSecondFileType(fileType, secondPo.getId(), product.getProductId());
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- secondHandMapper.insertSecondFileType(fileTypes, secondPo.getId(), product.getProductId());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
return ResponseJson.success(product.getProductId());
|
|
return ResponseJson.success(product.getProductId());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -679,4 +646,131 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
}
|
|
}
|
|
return ResponseJson.success(recommendList);
|
|
return ResponseJson.success(recommendList);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson releaseSecondHands(SecondDto secondDto, HttpHeaders headers) {
|
|
|
|
+ //校验手机号
|
|
|
|
+ String contactMobile = secondDto.getContactMobile();
|
|
|
|
+ String result = ValidateUtil.validateMobile(contactMobile);
|
|
|
|
+ if (result != null) {
|
|
|
|
+ return ResponseJson.error("参数异常:联系方式不正确");
|
|
|
|
+ }
|
|
|
|
+ //校验验证码
|
|
|
|
+ String checkCode = secondDto.getCheckCode();
|
|
|
|
+ if (StringUtils.isBlank(checkCode)) {
|
|
|
|
+ return ResponseJson.error("参数异常:请输入验证码");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(checkCode)) {
|
|
|
|
+ String redisSmsCode = stringRedisService.get("code:" + contactMobile);
|
|
|
|
+ // 开发 和 测试环境 固定短信验证码 666666
|
|
|
|
+ if ("dev".equals(profile) || "beta".equals(profile)) {
|
|
|
|
+ redisSmsCode = (null != redisSmsCode && !"null".equals(redisSmsCode) ? redisSmsCode : "666666");
|
|
|
|
+ }
|
|
|
|
+ if (!checkCode.equals(redisSmsCode)) {
|
|
|
|
+ return ResponseJson.error("参数异常:手机验证码错误");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 验证传入参数
|
|
|
|
+ Integer brandId = secondDto.getBrandId();
|
|
|
|
+ String name = secondDto.getName();
|
|
|
|
+ String source = secondDto.getSource();
|
|
|
|
+ Integer townId = secondDto.getTownId();
|
|
|
|
+ String address = secondDto.getAddress();
|
|
|
|
+ if (null == brandId) {
|
|
|
|
+ return ResponseJson.error("参数异常:请选择商品品牌");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(name)) {
|
|
|
|
+ return ResponseJson.error("参数异常:请输入商品名称");
|
|
|
|
+ }
|
|
|
|
+ if (null == townId) {
|
|
|
|
+ return ResponseJson.error("参数异常:请完善联系地址");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(address)) {
|
|
|
|
+ return ResponseJson.error("参数异常:请填写详细地址");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isEmpty(source)) {
|
|
|
|
+ return ResponseJson.error("参数异常:请输入发布来源");
|
|
|
|
+ }
|
|
|
|
+ // 保存二手商品
|
|
|
|
+ return saveSecondHandProduct(secondDto);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<PaginationVo<SecondListVo>> getSecondHandProducts(Integer buyFlag, Integer userId, String name, int pageNum, int pageSize) {
|
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
|
+ List<SecondListVo> secondList = secondHandMapper.getSecondHandProducts(buyFlag,userId, name);
|
|
|
|
+ if (!CollectionUtils.isEmpty(secondList)) {
|
|
|
|
+ // 初始化商品产品标签
|
|
|
|
+ int initNewNum = 0;
|
|
|
|
+ for (SecondListVo second : secondList) {
|
|
|
|
+ initNewNum++;
|
|
|
|
+ if (initNewNum > 10) {
|
|
|
|
+ second.setNewAdded(0);
|
|
|
|
+ } else {
|
|
|
|
+ second.setNewAdded(1);
|
|
|
|
+ }
|
|
|
|
+ // 优化地址信息
|
|
|
|
+ String provinceCityDistrict = second.getProvinceCityDistrict();
|
|
|
|
+ if (StringUtils.isNotBlank(provinceCityDistrict)) {
|
|
|
|
+ provinceCityDistrict = provinceCityDistrict.replace("/", "").replace("市辖区", "");
|
|
|
|
+ }
|
|
|
|
+ second.setProvinceCityDistrict(provinceCityDistrict);
|
|
|
|
+ //价格千分位处理
|
|
|
|
+ second.setPriceStr(priceFormatStr(second.getPrice()));
|
|
|
|
+ // 处理时间格式化
|
|
|
|
+ second.setOnLineDateStr(dateFormatStr(second.getOnLineDate()));
|
|
|
|
+ // 获取二手商品图片
|
|
|
|
+ List<String> images = secondHandMapper.getImageByProductId(second.getProductId());
|
|
|
|
+ images.forEach(img -> {
|
|
|
|
+ ImageUtils.getImageURL("product", img, 0, domain);
|
|
|
|
+ });
|
|
|
|
+ second.setImageList(images);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ PaginationVo<SecondListVo> pageData = new PaginationVo<SecondListVo>(secondList);
|
|
|
|
+ return ResponseJson.success(pageData);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<SecondDetailVo> getSecondProductDetail(Integer userId, Integer productId) {
|
|
|
|
+ SecondDetailVo second = secondHandMapper.getSecondHandDetail(productId);
|
|
|
|
+ Integer type = null == second.getSecondHandType() ? 0 : second.getSecondHandType();
|
|
|
|
+ List<Integer> ids = secondHandMapper.getNewAddProductIds(type);
|
|
|
|
+ Integer newFlag = ids.contains(second.getProductId()) ? 1 : 0;
|
|
|
|
+ second.setNewAdded(newFlag.toString());
|
|
|
|
+ // 优化地址信息
|
|
|
|
+ String provinceCityDistrict = second.getProvinceCityDistrict();
|
|
|
|
+ provinceCityDistrict = provinceCityDistrict.replace("/", "").replace("市辖区", "");
|
|
|
|
+ second.setProvinceCityDistrict(provinceCityDistrict);
|
|
|
|
+ //价格千分位处理
|
|
|
|
+ second.setPriceStr(priceFormatStr(second.getPrice()));
|
|
|
|
+ second.setNormalPriceStr(priceFormatStr(second.getNormalPrice()));
|
|
|
|
+ second.setOriginalPriceStr(priceFormatStr(second.getOriginalPrice()));
|
|
|
|
+ // 处理时间格式化
|
|
|
|
+ second.setOnLineDateStr(dateFormatStr(second.getOnLineDate()));
|
|
|
|
+ // 获取二手商品图片
|
|
|
|
+ List<String> images = secondHandMapper.getImageByProductId(second.getProductId());
|
|
|
|
+ // 获取二手商品图片(处理老的非全路径图片)
|
|
|
|
+ images.forEach(img -> {
|
|
|
|
+ img = ImageUtils.getImageURL("product", img, 0, domain);
|
|
|
|
+ });
|
|
|
|
+ second.setImageList(images);
|
|
|
|
+ // 初始商品分类
|
|
|
|
+ String typeStr = "";
|
|
|
|
+ Integer secondHandType = second.getSecondHandType();
|
|
|
|
+ if (1 == secondHandType) {
|
|
|
|
+ typeStr += "二手仪器";
|
|
|
|
+ } else if (2 == secondHandType) {
|
|
|
|
+ typeStr += "临期产品";
|
|
|
|
+ } else {
|
|
|
|
+ typeStr += "其他";
|
|
|
|
+ }
|
|
|
|
+ // 二手仪器分类
|
|
|
|
+ Integer instrumentType = second.getInstrumentType();
|
|
|
|
+ if (1 == instrumentType) {
|
|
|
|
+ typeStr += "-美容仪器";
|
|
|
|
+ }
|
|
|
|
+ second.setTypeStr(typeStr);
|
|
|
|
+ return ResponseJson.success(second);
|
|
|
|
+ }
|
|
}
|
|
}
|