|
@@ -12,7 +12,9 @@ import com.caimei.service.auth.AuthProductService;
|
|
import com.caimei.service.auth.AuthService;
|
|
import com.caimei.service.auth.AuthService;
|
|
import com.caimei.service.auth.ShopService;
|
|
import com.caimei.service.auth.ShopService;
|
|
import com.caimei.service.auth.UploadService;
|
|
import com.caimei.service.auth.UploadService;
|
|
|
|
+import com.caimei.utils.Base64Util;
|
|
import com.caimei.utils.ExcelOperateUtil;
|
|
import com.caimei.utils.ExcelOperateUtil;
|
|
|
|
+import com.caimei.utils.ImageUtils;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
|
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
|
@@ -24,12 +26,16 @@ import org.apache.poi.xssf.usermodel.*;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.imageio.ImageIO;
|
|
import javax.imageio.ImageIO;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import javax.swing.*;
|
|
|
|
+import java.awt.*;
|
|
|
|
+import java.awt.Font;
|
|
import java.awt.image.BufferedImage;
|
|
import java.awt.image.BufferedImage;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
@@ -37,6 +43,7 @@ import java.net.HttpURLConnection;
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.List;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -55,6 +62,9 @@ public class AuthServiceImpl implements AuthService {
|
|
@Resource
|
|
@Resource
|
|
private LdmMapper ldmMapper;
|
|
private LdmMapper ldmMapper;
|
|
|
|
|
|
|
|
+ @Value("${caimei.zpapi}")
|
|
|
|
+ private String zpServer;
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
private AuthProductMapper authProductMapper;
|
|
private AuthProductMapper authProductMapper;
|
|
|
|
|
|
@@ -88,9 +98,6 @@ public class AuthServiceImpl implements AuthService {
|
|
@Value("${caimei.imageDomain}")
|
|
@Value("${caimei.imageDomain}")
|
|
private String imageDomain;
|
|
private String imageDomain;
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private FastFileStorageClient storageClient;
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public ResponseJson<PageInfo<AuthVo>> getAuthList(Integer listType, Integer authUserId, String authParty,
|
|
public ResponseJson<PageInfo<AuthVo>> getAuthList(Integer listType, Integer authUserId, String authParty,
|
|
String mobile, Integer status, Integer auditStatus, Integer lowerAuditStatus,
|
|
String mobile, Integer status, Integer auditStatus, Integer lowerAuditStatus,
|
|
@@ -239,8 +246,19 @@ public class AuthServiceImpl implements AuthService {
|
|
if (null == auth.getEmpNum()) {
|
|
if (null == auth.getEmpNum()) {
|
|
return ResponseJson.error("请输入员工人数");
|
|
return ResponseJson.error("请输入员工人数");
|
|
}
|
|
}
|
|
- if (1 == source && null == auth.getCreateBy()) {
|
|
|
|
- return ResponseJson.error("参数异常,请输入创建人id");
|
|
|
|
|
|
+ if (1 == source) {
|
|
|
|
+ if (null == auth.getCreateBy()) {
|
|
|
|
+ return ResponseJson.error("参数异常,请输入创建人id");
|
|
|
|
+ }
|
|
|
|
+ /*if (1 == auth.getAuthImageType() && StringUtils.isEmpty(auth.getAuthImageLogo())) {
|
|
|
|
+ return ResponseJson.error("授权牌logo不能为空");
|
|
|
|
+ }*/
|
|
|
|
+ if (2 == auth.getAuthImageType() && StringUtils.isEmpty(auth.getAuthImage())) {
|
|
|
|
+ return ResponseJson.error("授权牌不能为空");
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ // 机构添加默认模板库生成
|
|
|
|
+ auth.setAuthImageType(1);
|
|
}
|
|
}
|
|
if (!importFlag) {
|
|
if (!importFlag) {
|
|
if (null == auth.getProvinceId() || null == auth.getCityId() || null == auth.getTownId() || StringUtils.isEmpty(auth.getAddress()) || null == auth.getLng() || null == auth.getLat()) {
|
|
if (null == auth.getProvinceId() || null == auth.getCityId() || null == auth.getTownId() || StringUtils.isEmpty(auth.getAddress()) || null == auth.getLng() || null == auth.getLat()) {
|
|
@@ -278,6 +296,21 @@ public class AuthServiceImpl implements AuthService {
|
|
// 删除原有的轮播图
|
|
// 删除原有的轮播图
|
|
authMapper.deleteBanner(auth.getId());
|
|
authMapper.deleteBanner(auth.getId());
|
|
}
|
|
}
|
|
|
|
+ // 保存之后生成授权牌和水印授权牌
|
|
|
|
+ String authImage = null;
|
|
|
|
+ if (1 == auth.getAuthImageType()) {
|
|
|
|
+ // 模板库生成
|
|
|
|
+ // 获取对应模板
|
|
|
|
+ TemplateVo authTemplate = authMapper.getAuthTemplate(auth.getId(), null, 1);
|
|
|
|
+ authImage = generateAuthImage(authTemplate, auth);
|
|
|
|
+ auth.setAuthImage(authImage);
|
|
|
|
+ // 添加水印
|
|
|
|
+ if (StringUtils.isNotEmpty(authImage)) {
|
|
|
|
+ auth.setPcAuthImage(addWaterMark(authImage, 1));
|
|
|
|
+ auth.setAppletsAuthImage(addWaterMark(authImage, 2));
|
|
|
|
+ authMapper.updateAuthImage(auth);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
// 保存轮播图
|
|
// 保存轮播图
|
|
if (null != bannerList) {
|
|
if (null != bannerList) {
|
|
bannerList.forEach(banner -> authMapper.insertBanner(auth.getId(), banner));
|
|
bannerList.forEach(banner -> authMapper.insertBanner(auth.getId(), banner));
|
|
@@ -285,6 +318,122 @@ public class AuthServiceImpl implements AuthService {
|
|
return ResponseJson.success("保存品牌授权成功", auth);
|
|
return ResponseJson.success("保存品牌授权成功", auth);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public String addWaterMark(String image,Integer type){
|
|
|
|
+ try {
|
|
|
|
+ //type:1pc,2applets
|
|
|
|
+ ClassPathResource classPathResource = new ClassPathResource("/images/newPcWaterMark.png");
|
|
|
|
+ InputStream inputStreamImg = classPathResource.getInputStream();
|
|
|
|
+ Image pcWaterMarkImg = ImageIO.read(inputStreamImg);
|
|
|
|
+ classPathResource = new ClassPathResource("/images/newAppletsWaterMark.png");
|
|
|
|
+ inputStreamImg = classPathResource.getInputStream();
|
|
|
|
+ Image appletsWaterMarkImg = ImageIO.read(inputStreamImg);
|
|
|
|
+ String img = ImageUtils.markImageByIcon(type == 1 ? pcWaterMarkImg : appletsWaterMarkImg, image, null);
|
|
|
|
+ String imagePath = null;
|
|
|
|
+ if (StringUtils.isNotEmpty(img)) {
|
|
|
|
+ MultipartFile imgFile = Base64Util.base64ToMultipart(img);
|
|
|
|
+ if (null != imgFile) {
|
|
|
|
+ imagePath = uploadService.saveFile(imgFile);
|
|
|
|
+ }
|
|
|
|
+ log.info(">>>>>>>>>>>>>>>>水印图片上传成功:" + imagePath);
|
|
|
|
+ } else {
|
|
|
|
+ log.info(">>>>>>>>>>>>>>>>水印图片上传失败");
|
|
|
|
+ }
|
|
|
|
+ return imagePath;
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String generateAuthImage(TemplateVo authTemplate, CmBrandAuthPo auth) {
|
|
|
|
+ if (null != authTemplate) {
|
|
|
|
+ // 根据模板id设置相关数据
|
|
|
|
+ Map<String, Object> templateInfo = getTemplateInfo(authTemplate, auth);
|
|
|
|
+ Object templateImage = templateInfo.get("templateImage");
|
|
|
|
+ if (null != templateImage) {
|
|
|
|
+ String authImage = ImageUtils.generateAuthImage(templateInfo);
|
|
|
|
+ log.info("【图片上传】>>>>>>>>>>>>>>>>图片临时路径:" + authImage);
|
|
|
|
+ // 临时图片
|
|
|
|
+ File tempFile = new File(authImage);
|
|
|
|
+ String imageUrl = null;
|
|
|
|
+ try {
|
|
|
|
+ imageUrl = imageDomain + "/" + client.uploadFile(authImage);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ // 删除临时图片
|
|
|
|
+ boolean delete = tempFile.delete();
|
|
|
|
+ log.info("【图片上传】>>>>>>>>>>>>>>>>删除临时图片:" + delete);
|
|
|
|
+ return imageUrl;
|
|
|
|
+ } else {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Map<String,Object> getTemplateInfo(TemplateVo template, CmBrandAuthPo auth) {
|
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
|
+ Integer templateId = template.getTemplateId();
|
|
|
|
+ if (1 == templateId) {
|
|
|
|
+ map.put("templateImage", template.getTemplateImage());
|
|
|
|
+ double rate = 0.15;
|
|
|
|
+ if (StringUtils.isNotEmpty(auth.getAuthImageLogo())) {
|
|
|
|
+ // 获取授权牌logo位置
|
|
|
|
+ try {
|
|
|
|
+ ImageIcon imageIcon = new ImageIcon(new URL(template.getTemplateImage()));
|
|
|
|
+ Image srcImg = imageIcon.getImage();
|
|
|
|
+ int srcWidth = srcImg.getWidth(null);
|
|
|
|
+ ImageIcon authImageLogo = new ImageIcon(new URL(auth.getAuthImageLogo()));
|
|
|
|
+ Image authLogo = authImageLogo.getImage();
|
|
|
|
+ int authLogoWidth = authLogo.getWidth(null);
|
|
|
|
+ int x = (srcWidth - (int) Math.round(238 * rate) - authLogoWidth) / 2 + (int) Math.round(238 * rate);
|
|
|
|
+ int y = (int) Math.round(1230 * rate);
|
|
|
|
+ map.put("addImage1_x", x);
|
|
|
|
+ map.put("addImage1_y", y);
|
|
|
|
+ map.put("addImage1_image", auth.getAuthImageLogo());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 添加认证编号信息
|
|
|
|
+ if (StringUtils.isNotEmpty(auth.getAuthCode())) {
|
|
|
|
+ map.put("addWord1_content", auth.getAuthCode());
|
|
|
|
+ map.put("addWord1_color", "218,185,107");
|
|
|
|
+ map.put("addWord1_type", "思源宋体");
|
|
|
|
+ map.put("addWord1_style", Font.BOLD);
|
|
|
|
+ map.put("addWord1_size", (int) Math.round(90 * rate));
|
|
|
|
+ map.put("addWord1_x", (int) Math.round(2168 * rate));
|
|
|
|
+ map.put("addWord1_y", (int) Math.round(3150 * rate));
|
|
|
|
+ }
|
|
|
|
+ // 添加认证日期信息
|
|
|
|
+ if (null != auth.getAuthDate()) {
|
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
|
|
|
|
+ map.put("addWord2_content", format.format(auth.getAuthDate()));
|
|
|
|
+ map.put("addWord2_color", "218,185,107");
|
|
|
|
+ map.put("addWord2_type", "思源宋体");
|
|
|
|
+ map.put("addWord2_style", Font.PLAIN);
|
|
|
|
+ map.put("addWord2_size", (int) Math.round(90 * rate));
|
|
|
|
+ map.put("addWord2_x", (int) Math.round(2085 * rate));
|
|
|
|
+ map.put("addWord2_y", (int) Math.round(3277 * rate));
|
|
|
|
+ }
|
|
|
|
+ // 添加二维码信息
|
|
|
|
+ if (StringUtils.isNotEmpty(template.getQrPosition())) {
|
|
|
|
+ String qrCodeLink = zpServer + "/" + auth.getAuthUserId() + "/app/approve/club/detail?id=" + auth.getId();
|
|
|
|
+ map.put("addQr1_link", qrCodeLink);
|
|
|
|
+ map.put("addQr1_size", template.getQrSize());
|
|
|
|
+ String[] split = template.getQrPosition().split(",");
|
|
|
|
+ if (split.length == 2) {
|
|
|
|
+ map.put("addQr1_x", Integer.parseInt(split[0]));
|
|
|
|
+ map.put("addQr1_y", Integer.parseInt(split[1]));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return map;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public ResponseJson auditAuth(Integer authId, Integer auditStatus, String invalidReason, Integer auditBy, Integer source) {
|
|
public ResponseJson auditAuth(Integer authId, Integer auditStatus, String invalidReason, Integer auditBy, Integer source) {
|
|
if (authId == null) {
|
|
if (authId == null) {
|
|
@@ -347,75 +496,6 @@ public class AuthServiceImpl implements AuthService {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public ResponseJson importLdmData(Integer authUserId) {
|
|
|
|
- List<LdmDataPo> ldmDataList = authMapper.getLdmData();
|
|
|
|
- ldmDataList.forEach(ldmData->{
|
|
|
|
- String lngAndLat = ldmData.getLngAndLat();
|
|
|
|
- if (StringUtils.isNotEmpty(lngAndLat)) {
|
|
|
|
- String[] split = lngAndLat.split(",");
|
|
|
|
- BigDecimal lng = new BigDecimal(split[0]);
|
|
|
|
- BigDecimal lat = new BigDecimal(split[1]);
|
|
|
|
- ldmData.setLng(lng);
|
|
|
|
- ldmData.setLat(lat);
|
|
|
|
- }
|
|
|
|
- String regId1 = ldmData.getRegId1();
|
|
|
|
- if (StringUtils.isNotEmpty(regId1)) {
|
|
|
|
- Integer provinceId = authMapper.getProvinceId(regId1);
|
|
|
|
- ldmData.setProvinceId(provinceId);
|
|
|
|
- }
|
|
|
|
- String regId2 = ldmData.getRegId2();
|
|
|
|
- if (StringUtils.isNotEmpty(regId2)) {
|
|
|
|
- Integer cityId = authMapper.getCityId(regId2);
|
|
|
|
- ldmData.setCityId(cityId);
|
|
|
|
- }
|
|
|
|
- String regId3 = ldmData.getRegId3();
|
|
|
|
- if (StringUtils.isNotEmpty(regId3)) {
|
|
|
|
- Integer townId = authMapper.getTownId(regId3);
|
|
|
|
- ldmData.setTownId(townId);
|
|
|
|
- }
|
|
|
|
- String pic1 = ldmData.getPic1();
|
|
|
|
- String pic2 = ldmData.getPic2();
|
|
|
|
- String pic3 = ldmData.getPic3();
|
|
|
|
- String pic4 = ldmData.getPic4();
|
|
|
|
- String pic5 = ldmData.getPic5();
|
|
|
|
- List<String> picList = new ArrayList<>();
|
|
|
|
- picList.add(pic1);
|
|
|
|
- picList.add(pic2);
|
|
|
|
- picList.add(pic3);
|
|
|
|
- picList.add(pic4);
|
|
|
|
- picList.add(pic5);
|
|
|
|
- String logo = null;
|
|
|
|
- List<String> addPicList = new ArrayList<>();
|
|
|
|
- for (String pic : picList) {
|
|
|
|
- if (StringUtils.isNotEmpty(pic)) {
|
|
|
|
- try {
|
|
|
|
- String imagePath = "https://wangdian.skinovachina.com" + pic;
|
|
|
|
- String fileName = imagePath.substring(imagePath.lastIndexOf("/") + 1);
|
|
|
|
- String imageUrl = uploadService.saveFileByUrl(imagePath, fileName);
|
|
|
|
- addPicList.add(imageUrl);
|
|
|
|
- if (null == logo) {
|
|
|
|
- logo = imageUrl;
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- CmBrandAuthPo authPo = new CmBrandAuthPo();
|
|
|
|
- BeanUtils.copyProperties(ldmData, authPo);
|
|
|
|
- authPo.setAuthUserId(authUserId);
|
|
|
|
- authPo.setCreateBy(authUserId);
|
|
|
|
- authPo.setLogo(logo);
|
|
|
|
- authMapper.insertAuth(authPo);
|
|
|
|
- // 保存轮播图
|
|
|
|
- if (addPicList.size() > 0) {
|
|
|
|
- addPicList.forEach(banner -> authMapper.insertBanner(authPo.getId(), banner));
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- return ResponseJson.success();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public ResponseJson exportDataByExcel(Integer authUserId, HttpServletResponse response) {
|
|
public ResponseJson exportDataByExcel(Integer authUserId, HttpServletResponse response) {
|
|
try {
|
|
try {
|