|
@@ -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;
|
|
|
}
|
|
|
}
|
|
@@ -159,17 +162,17 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
second.setImageList(images);
|
|
|
// 初始商品分类
|
|
|
String typeStr = "";
|
|
|
- String secondHandType = second.getSecondHandType();
|
|
|
- if ("1".equals(secondHandType)) {
|
|
|
+ Integer secondHandType = second.getSecondHandType();
|
|
|
+ if (1 == secondHandType) {
|
|
|
typeStr += "二手仪器";
|
|
|
- } else if ("2".equals(secondHandType)) {
|
|
|
+ } else if (2 == secondHandType) {
|
|
|
typeStr += "临期产品";
|
|
|
} else {
|
|
|
typeStr += "其他";
|
|
|
}
|
|
|
// 二手仪器分类
|
|
|
- String instrumentType = second.getInstrumentType();
|
|
|
- if ("1".equals(instrumentType)) {
|
|
|
+ Integer instrumentType = second.getInstrumentType();
|
|
|
+ if (1 == instrumentType) {
|
|
|
typeStr += "-美容仪器";
|
|
|
}
|
|
|
second.setTypeStr(typeStr);
|
|
@@ -201,11 +204,39 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
* ,"image" : 图片信息
|
|
|
* ,"productDetails" : 商品详细信息
|
|
|
* ,"source" : 信息来源 1网站 2CRM 3后台
|
|
|
+ * ,"publishIdentity" : 发布者身份 1个人身份,2公司身份
|
|
|
+ * ,"licenseImage" : 营业执照照片
|
|
|
+ * ,"fileType" : 商品包含的文件类型,1,仪器原始合同,2,仪器注册证,3,仪器发票,4,仪器报关单,5,无任何文件'
|
|
|
+ * (fileType字符串逗号拼接)
|
|
|
+ * ,"checkCode" : 验证码
|
|
|
+ * ,"authenticationBackImage" : 身份证背面照片
|
|
|
+ * ,"cardNumber" : 收款卡号
|
|
|
* }
|
|
|
* @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);
|
|
@@ -227,7 +258,7 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
}
|
|
|
// 验证传入参数
|
|
|
String secondHandType = secondDto.getSecondHandType();
|
|
|
- String instrumentType = secondDto.getInstrumentType();
|
|
|
+ Integer instrumentType = secondDto.getInstrumentType();
|
|
|
Integer brandId = secondDto.getBrandId();
|
|
|
String name = secondDto.getName();
|
|
|
Double price = secondDto.getPrice();
|
|
@@ -236,18 +267,29 @@ 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 cardNumber = secondDto.getCardNumber();
|
|
|
// 此图片为逗号隔开的多张数据
|
|
|
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)) {
|
|
|
- if (StringUtils.isEmpty(instrumentType)) {
|
|
|
+ if (null == instrumentType) {
|
|
|
return ResponseJson.error("参数异常:请完善仪器分类");
|
|
|
}
|
|
|
} else if (StringUtils.equals("2", secondHandType)) {
|
|
@@ -277,9 +319,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("参数异常:请完善联系地址");
|
|
|
}
|
|
@@ -295,6 +334,9 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
if (StringUtils.isEmpty(source)) {
|
|
|
return ResponseJson.error("参数异常:请输入发布来源");
|
|
|
}
|
|
|
+ if (StringUtils.isBlank(cardNumber)) {
|
|
|
+ return ResponseJson.error("参数异常:请输入收款卡号");
|
|
|
+ }
|
|
|
// 保存二手商品
|
|
|
return saveSecondHandProduct(secondDto);
|
|
|
}
|
|
@@ -349,6 +391,20 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
}
|
|
|
|
|
|
private ResponseJson saveSecondHandProduct(SecondDto secondDto) {
|
|
|
+ //根据银行卡判断是否注册过特殊二手供应商,有则挂在之前的供应商名下,否则注册新供应商
|
|
|
+ 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());
|
|
|
+ secondHandMapper.insertShop(shopVo);
|
|
|
+ shopId=shopVo.getShopId();
|
|
|
+ }
|
|
|
// 设置日期时间格式
|
|
|
Date date = new Date();
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
@@ -368,7 +424,7 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
product.setProductCategory(2);
|
|
|
product.setPreferredFlag(0);
|
|
|
// 默认发布到二手供应商
|
|
|
- product.setShopId(1252);
|
|
|
+ product.setShopId(shopId);
|
|
|
product.setSellNumber(secondDto.getStock());
|
|
|
product.setCostPrice(0d);
|
|
|
product.setCostCheckFlag(2);
|
|
@@ -458,8 +514,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 +560,7 @@ public class SecondHandServiceImpl implements SecondHandService {
|
|
|
return "时间未知";
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 获取是否在固定天数以内
|
|
|
*
|