|
@@ -11,6 +11,7 @@ import com.caimei365.commodity.model.po.ProductSecondPo;
|
|
|
import com.caimei365.commodity.model.vo.*;
|
|
|
import com.caimei365.commodity.service.SecondHandService;
|
|
|
import com.caimei365.commodity.utils.ImageUtils;
|
|
|
+import com.caimei365.commodity.utils.ValidateUtil;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
@@ -43,6 +44,8 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
private RedisService redisService;
|
|
|
@Resource
|
|
|
private PriceMapper priceMapper;
|
|
|
+ @Value("${spring.cloud.config.profile}")
|
|
|
+ private String profile;
|
|
|
|
|
|
/**
|
|
|
* 二手商品列表
|
|
@@ -64,7 +67,7 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
if (null != userIdentity && userIdentity == 2) {
|
|
|
// 会员机构类型:1医美,2生美
|
|
|
Integer clubType = priceMapper.getClubTypeById(userId);
|
|
|
- if (null != clubType && clubType == 1){
|
|
|
+ if (null != clubType && clubType == 1) {
|
|
|
userIdentity = 5;
|
|
|
}
|
|
|
}
|
|
@@ -201,11 +204,38 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
* ,"image" : 图片信息
|
|
|
* ,"productDetails" : 商品详细信息
|
|
|
* ,"source" : 信息来源 1网站 2CRM 3后台
|
|
|
+ * ,"publishIdentity" : 发布者身份 1个人身份,2公司身份
|
|
|
+ * ,"licenseImage" : 营业执照照片
|
|
|
+ * ,"fileType" : 商品包含的文件类型,1,仪器原始合同,2,仪器注册证,3,仪器发票,4,仪器报关单,5,无任何文件'
|
|
|
+ * (fileType字符串逗号拼接)
|
|
|
+ * ,"checkCode" : 验证码
|
|
|
+ * ,"authenticationBackImage" : 身份证背面照片
|
|
|
* }
|
|
|
* @param headers HttpHeaders
|
|
|
*/
|
|
|
@Override
|
|
|
public ResponseJson releaseSecondHand(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 = (String) redisService.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("参数异常:手机验证码错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
// 打印IP
|
|
|
String ip = headers.getFirst("X-CLIENT-IP");
|
|
|
log.info("发布二手商品 X-CLIENT-IP : " + ip);
|
|
@@ -236,14 +266,24 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
Integer stock = secondDto.getStock();
|
|
|
String productQuality = secondDto.getProductQuality();
|
|
|
String contactName = secondDto.getContactName();
|
|
|
- String contactMobile = secondDto.getContactMobile();
|
|
|
String source = secondDto.getSource();
|
|
|
Integer townId = secondDto.getTownId();
|
|
|
String address = secondDto.getAddress();
|
|
|
// 此图片为逗号隔开的多张数据
|
|
|
String image = secondDto.getImage();
|
|
|
String maturityYears = secondDto.getMaturityYears();
|
|
|
-
|
|
|
+ Integer publishIdentity = secondDto.getPublishIdentity();
|
|
|
+ String companyName = secondDto.getCompanyName();
|
|
|
+ String fileType = secondDto.getFileType();
|
|
|
+ if (2 == publishIdentity && StringUtils.isBlank(companyName)) {
|
|
|
+ return ResponseJson.error("参数异常:发布身份为公司身份时,公司名称不能为空");
|
|
|
+ }
|
|
|
+ if (null == publishIdentity || publishIdentity <= 0) {
|
|
|
+ return ResponseJson.error("参数异常:请选择发布者身份");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(fileType)) {
|
|
|
+ return ResponseJson.error("参数异常:请选择包含的文件类型");
|
|
|
+ }
|
|
|
if (StringUtils.isEmpty(secondHandType)) {
|
|
|
return ResponseJson.error("参数异常:请选择分类");
|
|
|
} else if (StringUtils.equals("1", secondHandType)) {
|
|
@@ -277,9 +317,6 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
if (StringUtils.isEmpty(contactName)) {
|
|
|
return ResponseJson.error("参数异常:请输入联系人姓名");
|
|
|
}
|
|
|
- if (StringUtils.isEmpty(contactMobile)) {
|
|
|
- return ResponseJson.error("参数异常:请输入联系方式");
|
|
|
- }
|
|
|
if (null == townId) {
|
|
|
return ResponseJson.error("参数异常:请完善联系地址");
|
|
|
}
|
|
@@ -458,8 +495,22 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
secondPo.setOssName(secondDto.getOssName());
|
|
|
secondPo.setAuthenticationImage(secondDto.getAuthenticationImage());
|
|
|
secondPo.setCommitmentImage(secondDto.getCommitmentImage());
|
|
|
+ //新增字段,用户身份,营业执照,身份证背面
|
|
|
+ secondPo.setPublishIdentity(secondDto.getPublishIdentity());
|
|
|
+ secondPo.setLicenseImage(secondDto.getLicenseImage());
|
|
|
+ secondPo.setAuthenticationBackImage(secondDto.getAuthenticationBackImage());
|
|
|
/* 保存商品二手附加详细信息 */
|
|
|
secondHandMapper.saveSencondHandProduct(secondPo);
|
|
|
+ //保存商品包含文件
|
|
|
+ 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());
|
|
|
}
|
|
|
|
|
@@ -490,6 +541,7 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
return "时间未知";
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 获取是否在固定天数以内
|
|
|
*
|