From bbe0a2fd03063316e50cf141986bda984599bbda Mon Sep 17 00:00:00 2001
From: 935090232@qq.com <ak473600000>
Date: Tue, 22 Feb 2022 23:41:42 +0800
Subject: [PATCH] Merge branch 'developer'

---
 zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShareProductAction.java |   61 +++++++++++++++---------------
 1 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShareProductAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShareProductAction.java
index ba10a99..5232255 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShareProductAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShareProductAction.java
@@ -1,25 +1,22 @@
 package com.matrix.system.shopXcx.api.action;
 
-import com.matrix.biz.bean.BizUser;
-import com.matrix.biz.dao.BizUserDao;
-import com.matrix.component.redis.RedisUserLoginUtils;
+import com.matrix.system.common.init.UserCacheManager;
+import com.matrix.component.tools.ImageUtil;
 import com.matrix.component.tools.WxacodeUtil;
 import com.matrix.core.pojo.AjaxResult;
-import com.matrix.core.tools.DateUtil;
-import com.matrix.core.tools.LogUtil;
-import com.matrix.core.tools.PropertiesUtil;
-import com.matrix.core.tools.UUIDUtil;
-import com.matrix.system.common.bean.BusParameterSettings;
+import com.matrix.core.tools.*;
 import com.matrix.system.common.constance.AppConstance;
 import com.matrix.system.common.dao.BusParameterSettingsDao;
+import com.matrix.system.hive.bean.SysVipInfo;
 import com.matrix.system.hive.dao.SysShopInfoDao;
+import com.matrix.system.hive.dao.SysVipInfoDao;
 import com.matrix.system.hive.plugin.util.CollectionUtils;
+import com.matrix.system.shopXcx.api.WeChatApiTools;
 import com.matrix.system.shopXcx.api.pojo.QrcodeImgParam;
 import com.matrix.system.shopXcx.api.vo.QrcodeVo;
 import com.matrix.system.shopXcx.api.vo.WxActivitiesGroupBuyVO;
 import com.matrix.system.shopXcx.bean.*;
 import com.matrix.system.shopXcx.dao.*;
-import org.jetbrains.annotations.NotNull;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Controller;
@@ -47,22 +44,21 @@
 @CrossOrigin(origins = "*", maxAge = 3600)
 public class WxShareProductAction {
 
-
+    @Autowired
+    WeChatApiTools weChatApiTools;
     @Autowired
     private ShopProductDao shopProductDao;
 
     @Autowired
-    private RedisUserLoginUtils redisUserLoginUtils;
+    private UserCacheManager userCacheManager;
 
     @Autowired
     private ShopShareQrcordDao shareQrcordDao;
     @Autowired
     private SysShopInfoDao shopInfoDao;
 
-
     @Value(value = "${qrcodeBackgroundImgPath}")
     private String qrcodeBackgroundImgPath;
-
 
     @Value(value = "${qrcodeFrontImgPath}")
     private String qrcodeFrontImgPath;
@@ -71,7 +67,7 @@
     ShopActivitiesGroupInfoDao shopActivitiesGroupInfoDao;
 
     @Autowired
-    BizUserDao bizUserDao;
+    SysVipInfoDao sysVipInfoDao;
 
 
     @Autowired
@@ -93,8 +89,8 @@
     @RequestMapping(value = "/getProductShareQrcode")
     public @ResponseBody
     AjaxResult getwxacode1(@RequestBody QrcodeVo qrcodeVo) throws Exception {
-        BizUser loginUser = redisUserLoginUtils.getLoginUser(BizUser.class);
-        loginUser = bizUserDao.selectById(loginUser.getUserId());
+        SysVipInfo loginUser = userCacheManager.getLoginUser();
+        loginUser = sysVipInfoDao.selectById(loginUser.getId());
         //活动类型
         ShopActivities activities=null;
         //是否为拼团分享
@@ -104,7 +100,7 @@
         }
         ShopShareQrcord queryOrcode = new ShopShareQrcord();
         queryOrcode.setProductId(qrcodeVo.getProductId());
-        queryOrcode.setUserId(loginUser.getOpenId());
+        queryOrcode.setUserId(loginUser.getId());
 
         if (isGroupProduct ) {
             queryOrcode.setProductId(Integer.parseInt(qrcodeVo.getActId() + ""));
@@ -119,7 +115,7 @@
             //如果未查询到就先插入数据再更新数据
             shareQrcord.setCreateBy(loginUser.getOpenId());
             shareQrcord.setUpdateBy(loginUser.getOpenId());
-            shareQrcord.setUserId(loginUser.getOpenId());
+            shareQrcord.setUserId(loginUser.getId());
             shareQrcord.setShopId(qrcodeVo.getShopId());
             //拼团活动
             if (isGroupProduct ) {
@@ -165,13 +161,14 @@
      * @param qrcodeVo
      * @return
      */
-    private QrcodeImgParam getSeckillQrcodeImgParam(BizUser loginUser, QrcodeVo qrcodeVo) throws Exception {
+    private QrcodeImgParam getSeckillQrcodeImgParam(SysVipInfo loginUser, QrcodeVo qrcodeVo) throws Exception {
 
         ShopActivitiesSeckillInfo seckillInfo = shopActivitiesSeckillInfoDao.selectById(qrcodeVo.getSkillId());
 
         ShopProduct shopProduct = shopProductDao.selectById(seckillInfo.getGoodsId().intValue());
 
-        String qrcodeSavePath = WxacodeUtil.getWxacode(qrcodeVo.getScene(), qrcodeVo.getPath(), UUIDUtil.getRandomID());
+        String qrcodeSavePath = WxacodeUtil.getWxacode(qrcodeVo.getScene(), qrcodeVo.getPath(), UUIDUtil.getRandomID()
+                ,weChatApiTools.getAppid(loginUser.getCompanyId()),weChatApiTools.getSecret(loginUser.getCompanyId()));
 
         LogUtil.debug("qrcodeSavePath={}", qrcodeSavePath);
         // 图片保存目录路径
@@ -203,13 +200,14 @@
      * @param qrcodeVo
      * @return
      */
-    private QrcodeImgParam getGroupQrcodeImgParam(BizUser loginUser, QrcodeVo qrcodeVo) throws Exception {
+    private QrcodeImgParam getGroupQrcodeImgParam(SysVipInfo loginUser, QrcodeVo qrcodeVo) throws Exception {
 
         WxActivitiesGroupBuyVO groupBuyVO = shopActivitiesGroupInfoDao.selectGroupInfoWithPriceByActId(qrcodeVo.getActId());
 
         ShopProduct shopProduct = shopProductDao.selectById(groupBuyVO.getGoodsId().intValue());
 
-        String qrcodeSavePath = WxacodeUtil.getWxacode(qrcodeVo.getScene(), qrcodeVo.getPath(), UUIDUtil.getRandomID());
+        String qrcodeSavePath = WxacodeUtil.getWxacode(qrcodeVo.getScene(), qrcodeVo.getPath(), UUIDUtil.getRandomID()
+                ,weChatApiTools.getAppid(loginUser.getCompanyId()),weChatApiTools.getSecret(loginUser.getCompanyId()));
 
         LogUtil.debug("qrcodeSavePath={}", qrcodeSavePath);
         // 图片保存目录路径
@@ -234,14 +232,14 @@
         return qrcodeImgParam;
     }
 
-    @NotNull
-    private QrcodeImgParam getQrcodeImgParam(BizUser loginUser, QrcodeVo qrcodeVo) throws Exception {
+    private QrcodeImgParam getQrcodeImgParam(SysVipInfo loginUser, QrcodeVo qrcodeVo) throws Exception {
 
         ShopProduct shopProduct = shopProductDao.selectById(qrcodeVo.getProductId());
 
 
 
-        String qrcodeSavePath = WxacodeUtil.getWxacode(qrcodeVo.getScene(), qrcodeVo.getPath(), UUIDUtil.getRandomID());
+        String qrcodeSavePath = WxacodeUtil.getWxacode(qrcodeVo.getScene(), qrcodeVo.getPath(), UUIDUtil.getRandomID()
+                ,weChatApiTools.getAppid(loginUser.getCompanyId()),weChatApiTools.getSecret(loginUser.getCompanyId()));
 
         LogUtil.debug("qrcodeSavePath={}", qrcodeSavePath);
         // 图片保存目录路径
@@ -249,7 +247,9 @@
         // 图片访问URL
         String baseSaveUrl = PropertiesUtil.getString(AppConstance.NGINX_URL);
         String productImg = shopProduct.getImgMobile();
-        productImg = productImg.replace(baseSaveUrl, baseSavePath);
+        String productPath = baseSavePath + "wxacode" + File.separatorChar + MD5Util.strToMD5(loginUser.getOpenId()) + "poster.png";
+        ImageUtil.downloadPicture(productImg, productPath);
+//        productImg = productImg.replace(baseSaveUrl, baseSavePath);
         String targetImg = UUIDUtil.getRandomID() + ".png";
 
         QrcodeImgParam qrcodeImgParam = new QrcodeImgParam();
@@ -257,7 +257,7 @@
         qrcodeImgParam.qrcodeSavePath = qrcodeSavePath;
         qrcodeImgParam.qrcodeBackgroundImgPath = qrcodeBackgroundImgPath;
         qrcodeImgParam.qrcodeFrontImgPath = qrcodeFrontImgPath;
-        qrcodeImgParam.productImgPath = productImg;
+        qrcodeImgParam.productImgPath = productPath;
         qrcodeImgParam.urlPath = baseSaveUrl + "/" + "wxacode" + "/" + targetImg;
         qrcodeImgParam.targetImg = baseSavePath + "/" + "wxacode" + "/" + targetImg;
         qrcodeImgParam.title = shopProduct.getTitle();
@@ -310,7 +310,7 @@
         g = b2Img.createGraphics();
         g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1));
         g.drawImage(qrcordImgBuf, 320, 550, 140, 140, null);
-        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
         //标题
         g.setColor(new Color(0xF10D0A0A, true));
         Font font = new Font("微软雅黑", Font.PLAIN, 24);
@@ -335,10 +335,11 @@
 
     public static void main(String[] args) throws Exception {
         QrcodeImgParam qrcodeImgParam = new QrcodeImgParam();
-        qrcodeImgParam.qrcodeSavePath = "C:\\Users\\Administrator\\Desktop\\dd\\ewm.png";
+        qrcodeImgParam.qrcodeSavePath = "C:\\Users\\Administrator\\Desktop\\ewm.png";
         qrcodeImgParam.qrcodeBackgroundImgPath = "C:\\Users\\Administrator\\Desktop\\dd\\bj1.png";
         qrcodeImgParam.qrcodeFrontImgPath = "C:\\Users\\Administrator\\Desktop\\dd\\qj2.png";
-        qrcodeImgParam.productImgPath = "C:\\Users\\Administrator\\Desktop\\dd\\banner.jpg";
+//        qrcodeImgParam.productImgPath = "C:\\Users\\Administrator\\Desktop\\dd\\banner.jpg";
+        qrcodeImgParam.productImgPath = "C:\\Users\\Administrator\\Desktop\\6cbfee5df0474fe0b864be142bc474ab.jpg";
         qrcodeImgParam.targetImg = "C:\\Users\\Administrator\\Desktop\\dd\\banner111.jpg";
         qrcodeImgParam.title = "盐酸米多君片";
         qrcodeImgParam.price = "¥30";

--
Gitblit v1.9.1