|
@@ -1,5 +1,7 @@
|
|
package com.caimei.service.impl;
|
|
package com.caimei.service.impl;
|
|
|
|
|
|
|
|
+import com.aliyun.oss.OSS;
|
|
|
|
+import com.aliyun.oss.OSSClientBuilder;
|
|
import com.caimei.config.FastDfsClient;
|
|
import com.caimei.config.FastDfsClient;
|
|
import com.caimei.mapper.AuthProductMapper;
|
|
import com.caimei.mapper.AuthProductMapper;
|
|
import com.caimei.model.ResponseJson;
|
|
import com.caimei.model.ResponseJson;
|
|
@@ -8,7 +10,10 @@ import com.caimei.model.po.ProductParamPo;
|
|
import com.caimei.model.po.ProductPo;
|
|
import com.caimei.model.po.ProductPo;
|
|
import com.caimei.model.vo.ProductFormVo;
|
|
import com.caimei.model.vo.ProductFormVo;
|
|
import com.caimei.model.vo.ProductListVo;
|
|
import com.caimei.model.vo.ProductListVo;
|
|
|
|
+import com.caimei.model.vo.WxDoctorListVo;
|
|
import com.caimei.model.vo.WxProductListVo;
|
|
import com.caimei.model.vo.WxProductListVo;
|
|
|
|
+import com.caimei.module.base.entity.vo.AuthProductVo;
|
|
|
|
+import com.caimei.module.base.entity.vo.StatementFileVo;
|
|
import com.caimei.service.AuthProductService;
|
|
import com.caimei.service.AuthProductService;
|
|
import com.caimei.service.UploadService;
|
|
import com.caimei.service.UploadService;
|
|
import com.caimei.utils.Base64Util;
|
|
import com.caimei.utils.Base64Util;
|
|
@@ -52,11 +57,22 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
|
|
|
private UploadService uploadService;
|
|
private UploadService uploadService;
|
|
|
|
|
|
|
|
+ @Value("${spring.profiles.active}")
|
|
|
|
+ private String active;
|
|
|
|
+
|
|
|
|
+ @Value("${caimei.oldapi}")
|
|
|
|
+ private String wwwServer;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
public void setUploadService(UploadService uploadService) {
|
|
public void setUploadService(UploadService uploadService) {
|
|
this.uploadService = uploadService;
|
|
this.uploadService = uploadService;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private String endpoint = "https://oss-cn-shenzhen.aliyuncs.com";
|
|
|
|
+ private String accessKeyId = "LTAI4GBL3o4YkWnbKYgf2Xia";
|
|
|
|
+ private String accessKeySecret = "dBjAXqbYiEPP6Ukuk2ZsXQeET7FVkK";
|
|
|
|
+ private String bucketName = "caimei-oss";
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public ResponseJson<PageInfo<ProductListVo>> getProductList(Integer listType, Integer authId, String productName, String snCode, Integer status, Integer auditStatus, Integer pageNum, Integer pageSize) {
|
|
public ResponseJson<PageInfo<ProductListVo>> getProductList(Integer listType, Integer authId, String productName, String snCode, Integer status, Integer auditStatus, Integer pageNum, Integer pageSize) {
|
|
if (null == authId) {
|
|
if (null == authId) {
|
|
@@ -108,6 +124,8 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
String snCode = productSaveDto.getSnCode();
|
|
String snCode = productSaveDto.getSnCode();
|
|
String productImage = productSaveDto.getProductImage();
|
|
String productImage = productSaveDto.getProductImage();
|
|
String certificateImage = productSaveDto.getCertificateImage();
|
|
String certificateImage = productSaveDto.getCertificateImage();
|
|
|
|
+ Integer addQrCodeFlag = productSaveDto.getAddQrCodeFlag();
|
|
|
|
+ Integer addTemplateType = productSaveDto.getAddTemplateType();
|
|
Integer createBy = productSaveDto.getCreateBy();
|
|
Integer createBy = productSaveDto.getCreateBy();
|
|
List<ProductParamPo> paramList = productSaveDto.getParamList();
|
|
List<ProductParamPo> paramList = productSaveDto.getParamList();
|
|
if (null == authId) {
|
|
if (null == authId) {
|
|
@@ -132,6 +150,12 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
if (StringUtils.isBlank(certificateImage)) {
|
|
if (StringUtils.isBlank(certificateImage)) {
|
|
return ResponseJson.error("参数异常,请上传授权牌照", null);
|
|
return ResponseJson.error("参数异常,请上传授权牌照", null);
|
|
}
|
|
}
|
|
|
|
+ if (null == addQrCodeFlag) {
|
|
|
|
+ return ResponseJson.error("参数异常,请选择是否生成二维码授权牌", null);
|
|
|
|
+ }
|
|
|
|
+ if (1 == addQrCodeFlag && null == addTemplateType) {
|
|
|
|
+ return ResponseJson.error("参数异常,请选择二维码授权牌模板", null);
|
|
|
|
+ }
|
|
if (null == paramList || paramList.size() <= 0) {
|
|
if (null == paramList || paramList.size() <= 0) {
|
|
return ResponseJson.error("参数异常,商品参数列表不能为空", null);
|
|
return ResponseJson.error("参数异常,商品参数列表不能为空", null);
|
|
}
|
|
}
|
|
@@ -153,39 +177,113 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
product.setProductImage(productImage);
|
|
product.setProductImage(productImage);
|
|
// 授权牌照
|
|
// 授权牌照
|
|
product.setCertificateImage(certificateImage);
|
|
product.setCertificateImage(certificateImage);
|
|
|
|
+ product.setAddQrCodeFlag(addQrCodeFlag);
|
|
|
|
+ product.setAddTemplateType(addTemplateType);
|
|
// 商品信息保存后,上线状态默认为“待上线”,审核状态为“待审核”
|
|
// 商品信息保存后,上线状态默认为“待上线”,审核状态为“待审核”
|
|
product.setStatus(2);
|
|
product.setStatus(2);
|
|
product.setAuditStatus(2);
|
|
product.setAuditStatus(2);
|
|
if (insertFlag) {
|
|
if (insertFlag) {
|
|
|
|
+ // 原授权牌照
|
|
|
|
+ product.setOriginalCertificateImage(product.getCertificateImage());
|
|
// 创建人id
|
|
// 创建人id
|
|
product.setCreateBy(createBy);
|
|
product.setCreateBy(createBy);
|
|
// 创建时间
|
|
// 创建时间
|
|
product.setCreateTime(new Date());
|
|
product.setCreateTime(new Date());
|
|
- // 商品图片和授权牌照添加水印
|
|
|
|
- if (StringUtils.isNotBlank(product.getProductImage())) {
|
|
|
|
- //商品图片添加水印
|
|
|
|
- product.setPcImage(addWaterMark(product.getProductImage(), 1));
|
|
|
|
- product.setAppletsImage(addWaterMark(product.getProductImage(), 2));
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotBlank(product.getCertificateImage())) {
|
|
|
|
|
|
+ //商品图片添加水印
|
|
|
|
+ product.setPcImage(addWaterMark(product.getProductImage(), 1));
|
|
|
|
+ product.setAppletsImage(addWaterMark(product.getProductImage(), 2));
|
|
|
|
+ if (0 == addQrCodeFlag) {
|
|
//授权牌照添加水印
|
|
//授权牌照添加水印
|
|
product.setPcCertificateImage(addWaterMark(product.getCertificateImage(), 1));
|
|
product.setPcCertificateImage(addWaterMark(product.getCertificateImage(), 1));
|
|
product.setAppletsCertificateImage(addWaterMark(product.getCertificateImage(), 2));
|
|
product.setAppletsCertificateImage(addWaterMark(product.getCertificateImage(), 2));
|
|
}
|
|
}
|
|
// 插入授权商品
|
|
// 插入授权商品
|
|
authProductMapper.insertProduct(product);
|
|
authProductMapper.insertProduct(product);
|
|
|
|
+ if (1 == addQrCodeFlag) {
|
|
|
|
+ // 生成二维码授权牌
|
|
|
|
+ String addQrCodeImg = addQrCode(product.getCertificateImage(), product.getProductId(), addTemplateType);
|
|
|
|
+ product.setCertificateImage(addQrCodeImg);
|
|
|
|
+ //授权牌照添加水印
|
|
|
|
+ product.setPcCertificateImage(addWaterMark(addQrCodeImg, 1));
|
|
|
|
+ product.setAppletsCertificateImage(addWaterMark(addQrCodeImg, 2));
|
|
|
|
+ //更新授权牌照
|
|
|
|
+ authProductMapper.updateCertificateImage(product);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
// 商品id
|
|
// 商品id
|
|
product.setProductId(productId);
|
|
product.setProductId(productId);
|
|
- ProductPo productImages = authProductMapper.getImageByProductId(productId);
|
|
|
|
- boolean updateImageFlag = (StringUtils.isNotBlank(product.getProductImage()) && !product.getProductImage().equals(productImages.getProductImage())) || (StringUtils.isEmpty(productImages.getPcImage()) || StringUtils.isEmpty(productImages.getAppletsImage()));
|
|
|
|
|
|
+ ProductPo dbProduct = authProductMapper.getImageByProductId(productId);
|
|
|
|
+ // 数据库该商品授权牌是否添加二维码
|
|
|
|
+ Integer dbAddQrCodeFlag = dbProduct.getAddQrCodeFlag();
|
|
|
|
+ // 数据库该商品授权牌添加二维码模板
|
|
|
|
+ Integer dbAddTemplateType = dbProduct.getAddTemplateType();
|
|
|
|
+ // 商品图片是否重新上传
|
|
|
|
+ boolean updateImageFlag = (StringUtils.isNotBlank(product.getProductImage()) && !product.getProductImage().equals(dbProduct.getProductImage())) || (StringUtils.isEmpty(dbProduct.getPcImage()) || StringUtils.isEmpty(dbProduct.getAppletsImage()));
|
|
if (updateImageFlag) {
|
|
if (updateImageFlag) {
|
|
//商品图片添加水印
|
|
//商品图片添加水印
|
|
product.setPcImage(addWaterMark(product.getProductImage(), 1));
|
|
product.setPcImage(addWaterMark(product.getProductImage(), 1));
|
|
product.setAppletsImage(addWaterMark(product.getProductImage(), 2));
|
|
product.setAppletsImage(addWaterMark(product.getProductImage(), 2));
|
|
}
|
|
}
|
|
- updateImageFlag = (StringUtils.isNotBlank(product.getCertificateImage()) && !product.getCertificateImage().equals(productImages.getCertificateImage())) || (StringUtils.isEmpty(productImages.getPcCertificateImage()) || StringUtils.isEmpty(productImages.getPcCertificateImage()));
|
|
|
|
- if (updateImageFlag) {
|
|
|
|
|
|
+ // 授权牌照是否重新上传
|
|
|
|
+ updateImageFlag = (StringUtils.isNotBlank(product.getCertificateImage()) && !product.getCertificateImage().equals(dbProduct.getCertificateImage())) || (StringUtils.isEmpty(dbProduct.getPcCertificateImage()) || StringUtils.isEmpty(dbProduct.getAppletsCertificateImage()));
|
|
|
|
+ boolean addQrCodeSign = false;
|
|
|
|
+ boolean addWaterMarkSign = false;
|
|
|
|
+ if (1 == dbAddQrCodeFlag) {
|
|
|
|
+ if (0 == addQrCodeFlag) {
|
|
|
|
+ // 原本是,现在否
|
|
|
|
+ if (updateImageFlag) {
|
|
|
|
+ // 新上传图片,将原图片替换为当前图片,生成水印图片
|
|
|
|
+ product.setOriginalCertificateImage(product.getCertificateImage());
|
|
|
|
+ addWaterMarkSign = true;
|
|
|
|
+ } else {
|
|
|
|
+ // 原图片,将当前授权牌替换为原图,生成水印图片
|
|
|
|
+ product.setCertificateImage(dbProduct.getOriginalCertificateImage());
|
|
|
|
+ addWaterMarkSign = true;
|
|
|
|
+ }
|
|
|
|
+ } else if (1 == addQrCodeFlag) {
|
|
|
|
+ // 原本是,现在是
|
|
|
|
+ if (updateImageFlag) {
|
|
|
|
+ // 新上传图片,将原图片替换为当前图片,生成二维码授权牌,生成水印图片
|
|
|
|
+ product.setOriginalCertificateImage(product.getCertificateImage());
|
|
|
|
+ addQrCodeSign = true;
|
|
|
|
+ addWaterMarkSign = true;
|
|
|
|
+ } else if (!addTemplateType.equals(dbAddTemplateType)) {
|
|
|
|
+ // 原图片,更改模板,将当前授权牌替换为原图,生成二维码授权牌,生成水印图片
|
|
|
|
+ product.setCertificateImage(product.getOriginalCertificateImage());
|
|
|
|
+ addQrCodeSign = true;
|
|
|
|
+ addWaterMarkSign = true;
|
|
|
|
+ }
|
|
|
|
+ // else 原图片,不更改模板,不做更改
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ if (1 == addQrCodeFlag) {
|
|
|
|
+ // 原本否,现在是
|
|
|
|
+ if (updateImageFlag) {
|
|
|
|
+ // 新上传图片,将原图片替换为当前图片,生成二维码授权牌,生成水印图片
|
|
|
|
+ product.setOriginalCertificateImage(product.getCertificateImage());
|
|
|
|
+ addQrCodeSign = true;
|
|
|
|
+ addWaterMarkSign = true;
|
|
|
|
+ } else {
|
|
|
|
+ // 原图片,生成二维码授权牌,生成水印图片
|
|
|
|
+ addQrCodeSign = true;
|
|
|
|
+ addWaterMarkSign = true;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 原本否,现在否
|
|
|
|
+ if (updateImageFlag) {
|
|
|
|
+ // 新上传图片,将原图片替换为当前图片,生成二维码授权牌,生成水印图片
|
|
|
|
+ product.setOriginalCertificateImage(product.getCertificateImage());
|
|
|
|
+ addWaterMarkSign = true;
|
|
|
|
+ }
|
|
|
|
+ // 原图片,不做更改
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (addQrCodeSign) {
|
|
|
|
+ // 生成二维码授权牌
|
|
|
|
+ String addQrCodeImg = addQrCode(product.getCertificateImage(), productId, addTemplateType);
|
|
|
|
+ product.setCertificateImage(addQrCodeImg);
|
|
|
|
+ }
|
|
|
|
+ if (addWaterMarkSign) {
|
|
//授权牌照添加水印
|
|
//授权牌照添加水印
|
|
product.setPcCertificateImage(addWaterMark(product.getCertificateImage(), 1));
|
|
product.setPcCertificateImage(addWaterMark(product.getCertificateImage(), 1));
|
|
product.setAppletsCertificateImage(addWaterMark(product.getCertificateImage(), 2));
|
|
product.setAppletsCertificateImage(addWaterMark(product.getCertificateImage(), 2));
|
|
@@ -226,6 +324,22 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
return imagePath;
|
|
return imagePath;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private String addQrCode(String certificateImage, Integer productId, Integer addTemplateType) throws IOException {
|
|
|
|
+ String qrCodeLink = wwwServer + "/product/auth/product-" + productId + ".html";
|
|
|
|
+ String qrCodeImage = ImageUtils.addQrCode(certificateImage, qrCodeLink, addTemplateType);
|
|
|
|
+ String imagePath = null;
|
|
|
|
+ if (StringUtils.isNotEmpty(qrCodeImage)) {
|
|
|
|
+ MultipartFile imgFile = Base64Util.base64ToMultipart(qrCodeImage);
|
|
|
|
+ if (null != imgFile) {
|
|
|
|
+ imagePath = uploadService.saveFile(imgFile);
|
|
|
|
+ }
|
|
|
|
+ log.info(">>>>>>>>>>>>>>>>水印图片上传成功:" + imagePath);
|
|
|
|
+ } else {
|
|
|
|
+ log.info(">>>>>>>>>>>>>>>>水印图片上传失败");
|
|
|
|
+ }
|
|
|
|
+ return imagePath;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public ResponseJson<ProductFormVo> getProductFormData(Integer productId) {
|
|
public ResponseJson<ProductFormVo> getProductFormData(Integer productId) {
|
|
if (null == productId) {
|
|
if (null == productId) {
|
|
@@ -295,13 +409,35 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ResponseJson<PageInfo<WxProductListVo>> getWxProductList(Integer authId, String productName, Integer pageNum, Integer pageSize) {
|
|
|
|
- if (null == authId) {
|
|
|
|
- return ResponseJson.error("参数异常,请输入授权id", null);
|
|
|
|
|
|
+ public ResponseJson<PageInfo<WxProductListVo>> getWxProductList(String appId, String productName, Integer pageNum, Integer pageSize) {
|
|
|
|
+ if (null == appId) {
|
|
|
|
+ return ResponseJson.error("参数异常,请输入供应商appId", null);
|
|
}
|
|
}
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
- List<WxProductListVo> productList = authProductMapper.getWxProductList(authId, productName);
|
|
|
|
|
|
+ List<WxProductListVo> productList = authProductMapper.getWxProductList(appId, productName);
|
|
PageInfo<WxProductListVo> pageData = new PageInfo<>(productList);
|
|
PageInfo<WxProductListVo> pageData = new PageInfo<>(productList);
|
|
return ResponseJson.success(pageData);
|
|
return ResponseJson.success(pageData);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<AuthProductVo> getAuthProductDetails(Integer productId) {
|
|
|
|
+ AuthProductVo authProduct = authProductMapper.getAuthProductByProductId(productId);
|
|
|
|
+ if (null == authProduct) {
|
|
|
|
+ return ResponseJson.error("商品不存在", null);
|
|
|
|
+ }
|
|
|
|
+ // 代理声明文件
|
|
|
|
+ if (null != authProduct.getStatementType() && authProduct.getStatementType() == 4) {
|
|
|
|
+ StatementFileVo statementFile = authProductMapper.getStatementFile(authProduct.getAuthUserId(), authProduct.getBrandId());
|
|
|
|
+ OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
|
|
|
+ // 设置URL过期时间为1个小时
|
|
|
|
+ Date expiration = new Date(System.currentTimeMillis() + 3600L * 1000);
|
|
|
|
+ String url = ossClient.generatePresignedUrl(bucketName, active + "/authFile/" + statementFile.getOssName(), expiration).toString();
|
|
|
|
+ statementFile.setUrl(url);
|
|
|
|
+ ossClient.shutdown();
|
|
|
|
+ authProduct.setStatementFile(statementFile);
|
|
|
|
+ }
|
|
|
|
+ // 商品参数
|
|
|
|
+ authProduct.setParamList(authProductMapper.getAuthProductParams(productId));
|
|
|
|
+ return ResponseJson.success(authProduct);
|
|
|
|
+ }
|
|
}
|
|
}
|