jyy
2021-03-11 403acdaee34690cf0798ea83e8db33079d8a3720
新增申请成为分销员接口
5 files modified
142 ■■■■■ changed files
zq-erp/pom.xml 4 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/component/tools/ImageUtil.java 33 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/component/tools/WxacodeUtil.java 23 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java 79 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/config/system.properties 3 ●●●● patch | view | raw | blame | history
zq-erp/pom.xml
@@ -394,11 +394,11 @@
                    <exclude>config/test/*</exclude>
                    <exclude>config/xcx/*</exclude>
                    <!--
                    <!---->
                    <exclude>config/config.json</exclude>
                    <exclude>config/application.properties</exclude>
                    <exclude>config/system.properties</exclude>
                    -->
zq-erp/src/main/java/com/matrix/component/tools/ImageUtil.java
@@ -2,8 +2,9 @@
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
@@ -91,4 +92,32 @@
        System.out.println("系统字体数:" + fontCount);
    }
    public static void downloadPicture(String imgUrl,String savePath) {
        URL url = null;
        int imageNumber = 0;
        try {
            url = new URL(imgUrl);
            DataInputStream dataInputStream = new DataInputStream(url.openStream());
            FileOutputStream fileOutputStream = new FileOutputStream(new File(savePath));
            ByteArrayOutputStream output = new ByteArrayOutputStream();
            byte[] buffer = new byte[1024];
            int length;
            while ((length = dataInputStream.read(buffer)) > 0) {
                output.write(buffer, 0, length);
            }
            byte[] context=output.toByteArray();
            fileOutputStream.write(output.toByteArray());
            dataInputStream.close();
            fileOutputStream.close();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
zq-erp/src/main/java/com/matrix/component/tools/WxacodeUtil.java
@@ -61,12 +61,6 @@
            HttpResponse response;
            response = httpClient.execute(httpPost);
            InputStream inputStream = response.getEntity().getContent();
            /*Object inputObj= response.getEntity().getContent();
            if(inputObj instanceof InputStream){
                String strError = streamToString(inputStream,"GBK");
                LogUtil.info("-------------二维码生成------"+strError);
                return "error:" + strError;
            }*/
            // 图片保存目录路径
            String baseSavePath = PropertiesUtil.getString(AppConstance.FILES_TORAGE_PATH);
@@ -74,11 +68,6 @@
            if(!targetFile.exists()){
                targetFile.mkdirs();
            }
            /*String inputstreamtofile = inputstreamtofile(inputStream, targetFile);
            if(null != inputstreamtofile){
                return inputstreamtofile;
            }*/
            // 创建图片文件夹
            baseSavePath += "wxacode" + File.separatorChar;
@@ -89,23 +78,15 @@
            String qrcodePath = baseSavePath + fileName + ".png";
            FileOutputStream out = new FileOutputStream(qrcodePath);
            LogUtil.debug("qrcodePath:{}",qrcodePath);
            //本地调试创建(不用删)
            /*String filePath = "e:/test.png";
            File file = new File(filePath);
            if (!file.exists()) {
                file.mkdir();
            }
            FileOutputStream outs = new FileOutputStream(file);*/
            byte[] buffer = new byte[1024];
            int bytesRead = 0;
            while((bytesRead = inputStream.read(buffer, 0, 1024)) != -1) {
                out.write(buffer, 0, bytesRead);
                //outs.write(buffer, 0, bytesRead);
            }
            out.flush();
            out.close();
            //outs.flush();
            //outs.close();
            return qrcodePath;
        } else {
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java
@@ -4,12 +4,10 @@
import com.matrix.biz.bean.BizUser;
import com.matrix.biz.dao.BizUserDao;
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.component.tools.ImageUtil;
import com.matrix.component.tools.WxacodeUtil;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.MD5Util;
import com.matrix.core.tools.PropertiesUtil;
import com.matrix.core.tools.StringUtils;
import com.matrix.core.tools.*;
import com.matrix.system.common.bean.BusParameterSettings;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.common.dao.BusParameterSettingsDao;
@@ -63,7 +61,7 @@
    public AjaxResult getTgPlan() {
        BusParameterSettings busParameterSettings = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_TG_PLAN, HostInterceptor.getCompanyId());
        AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("");
        ajaxResult.putInMap("data",busParameterSettings.getParamValue3());
        ajaxResult.setData(busParameterSettings.getParamValue3());
        return ajaxResult;
    }
@@ -133,38 +131,61 @@
    AjaxResult getInvitationPoster() {
        try {
            BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class);
            String qrcodeSavePath = WxacodeUtil.getWxacode(loginUser.getOpenId() + "", "pages/index/index", MD5Util.strToMD5(loginUser.getOpenId() + ""));
            //获取海报
            BusParameterSettings posterSetting = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_TG_POSTER, HostInterceptor.getCompanyId());
            String posterSavePath = posterSetting.getParamValue1();
            BufferedImage productImgBuf = ImageIO.read(new File(qrcodeSavePath));
            BufferedImage qrcordImgBuf = ImageIO.read(new File(posterSavePath));
            BufferedImage backgroundImgBuf = new BufferedImage(750, 900, BufferedImage.TYPE_4BYTE_ABGR);
            //绘制背景+产品
            Graphics2D g = backgroundImgBuf.createGraphics();
            g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1));
            LogUtil.debug("qrcodeSavePath={}", qrcodeSavePath);
            // 图片保存目录路径
            String baseSavePath = PropertiesUtil.getString(AppConstance.FILES_TORAGE_PATH);
            // 图片访问URL
            String baseSaveUrl = PropertiesUtil.getString(AppConstance.NGINX_URL);
            String qrcodeImgUrl = qrcodeSavePath.replace(baseSavePath, baseSaveUrl);
            return AjaxResult.buildSuccessInstance(qrcodeImgUrl);
            //目标海报物理存储路径
            String targetImg=MD5Util.strToMD5(loginUser.getOpenId()) +"haibao.png";
            String targetImgPath=baseSavePath+"wxacode" + File.separatorChar+targetImg ;
            String urlPath = baseSaveUrl + "/" + "wxacode" + "/" + targetImg;
            String qrcodeSavePath = WxacodeUtil.getWxacode(loginUser.getOpenId() + "", "pages/distributorCenter/applyFor/applyFor", MD5Util.strToMD5(loginUser.getOpenId() + ""));
            BufferedImage qrcordImgBuf = ImageIO.read(new File(qrcodeSavePath));
            //获取海报
            BusParameterSettings posterSetting = busParameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_TG_POSTER, HostInterceptor.getCompanyId());
            String posterPath=baseSavePath+"wxacode" + File.separatorChar+MD5Util.strToMD5(loginUser.getOpenId())+"poster.png";
            ImageUtil.downloadPicture(posterSetting.getParamValue(),posterPath);
            BufferedImage posterImgBuf = ImageIO.read(new File(posterPath));
            //获取用户头像
            String userPhotoPath=baseSavePath+"wxacode" + File.separatorChar+MD5Util.strToMD5(loginUser.getOpenId())+"userPhoto.png";
            ImageUtil.downloadPicture(loginUser.getAvatarUrl(),userPhotoPath);
            BufferedImage userPhotoImgBuf = ImageIO.read(new File(userPhotoPath));
            BufferedImage backgroundImgBuf = new BufferedImage(700, 900, BufferedImage.TYPE_4BYTE_ABGR);
            //绘制背景+产品
            Graphics2D g = backgroundImgBuf.createGraphics();
            //g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1));
            g.setColor(Color.WHITE);
            g.fillRect(0,0,700,900);
            g.drawImage(posterImgBuf,0,0,700, 700,null);
            g.drawImage(userPhotoImgBuf,20,720,80,80,null);
            g.drawImage(qrcordImgBuf,500,720,150,150,null);
            g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
            g.setFont(new Font("黑体", Font.BOLD, 24));
            g.setColor(Color.BLACK);
            g.drawString(loginUser.getNickName()+"邀请你一起推广赚佣金",120,750);
            g.dispose();
            ImageIO.write(backgroundImgBuf, "png", new File(targetImgPath));
            return AjaxResult.buildSuccessInstance(urlPath);
        } catch (Exception e) {
            LogUtil.error("门店生成二维码错误:{}", e, "");
            LogUtil.error("推广二维码生成错误:{}", e, "");
            return  AjaxResult.buildFailInstance("二维码生成失败");
        }
        return  AjaxResult.buildFailInstance("二维码生成失败");
    }
zq-erp/src/main/resources/config/system.properties
@@ -17,7 +17,8 @@
#文件保存地址
#file_storage_path=/mnt/hive/static/uploadeFile/
file_storage_path=E:\\20210116
file_storage_path=D:\\test\\
#文件上传大小字节为单位  10MB
maxUploadSize=10485760