From 744594ef1a2f530fc3e86ea9dc48b62247f79420 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 19 五月 2020 17:13:23 +0800
Subject: [PATCH] 饿了么绘图,添加口碑

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/QrCodeServiceImpl.java |  676 ++++++++++++++++++++++++++++++++------------------------
 1 files changed, 387 insertions(+), 289 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/QrCodeServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/QrCodeServiceImpl.java
index e895c86..bbde1c8 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/QrCodeServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/QrCodeServiceImpl.java
@@ -1,289 +1,387 @@
-package com.yeshi.fanli.service.impl.user;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Date;
-import java.util.UUID;
-
-import javax.annotation.Resource;
-
-import org.springframework.stereotype.Service;
-import org.yeshi.utils.HttpUtil;
-import org.yeshi.utils.QRCodeUtil;
-import org.yeshi.utils.tencentcloud.COSManager;
-
-import com.yeshi.fanli.dao.mybatis.share.ShareMapper;
-import com.yeshi.fanli.service.inter.user.QrCodeService;
-import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
-import com.yeshi.fanli.util.Constant;
-import com.yeshi.fanli.util.FileUtil;
-import com.yeshi.fanli.util.ImageUtil;
-import com.yeshi.fanli.util.StringUtil;
-
-@Service
-public class QrCodeServiceImpl implements QrCodeService {
-
-	@Resource
-	private ShareMapper shareMapper;
-
-	@Resource
-	private SpreadUserImgService spreadUserImgService;
-
-	@Override
-	public String getPortrait(Long uid) {
-		return shareMapper.getPortrait(uid);
-	}
-
-	@Override
-	public String drawInviteQrCode(String url, Long uid, String portrait, String inviteCode) throws IOException {
-		if (url != null && !url.equals("")) {
-			String targetPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + System.currentTimeMillis() + ".jpg";
-			String erCodeTempPath = FileUtil.getCacheDir() + "/" + uid + "_" + System.currentTimeMillis() + ".jpg";
-
-			String erCode = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/"
-					+ Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
-			// 鐢熸垚
-			try {
-				QRCodeUtil.getInstance(250).encode(erCode, erCodeTempPath);
-			} catch (Exception e) {
-				e.printStackTrace();
-			}
-
-			InputStream urlInputStream = HttpUtil.getAsInputStream(url); // 鑳屾櫙
-			InputStream portraitInputStream = HttpUtil.getAsInputStream(portrait); // 澶村儚
-			InputStream erCodeInputStream = new FileInputStream(new File(erCodeTempPath)); // 浜岀淮鐮�
-
-			// 寮�濮嬫牴鎹� url(鑳屾櫙鍥�), qrCode(浜岀淮鐮�), portrait(澶村儚) 鐢熸垚鍥剧墖
-			ImageUtil.inviteFriendImg(urlInputStream, portraitInputStream, erCodeInputStream, targetPath, inviteCode);
-
-			if (new File(targetPath).exists() && new File(targetPath).length() > 0) {
-				// 涓婁紶鏂囦欢
-
-				// 灏唘rl 杞负 md5 璁╁埌涓嬮潰涓坊鍔� 鍦ㄦ瘮杈僲d5鐨勫��
-
-				int index = url.lastIndexOf("/");
-				String newUrl = url.substring(index + 1);
-				String urlMd5 = newUrl.substring(0, newUrl.lastIndexOf("."));
-
-				String imgUrl = COSManager.getInstance()
-						.uploadFile(new File(targetPath),
-								"ercode/" + "ercode_" + uid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg")
-						.getUrl();
-
-				if (new File(erCodeTempPath).exists())
-					new File(erCodeTempPath).delete();
-
-				if (new File(targetPath).exists())
-					new File(targetPath).delete();
-
-				return imgUrl;
-			}
-		}
-		return null;
-	}
-
-	@Override
-	public String drawInviteQrCode(String url, Long uid, String portrait, int erCodePostionX, int erCodePostionY,
-			int erCodeSize, String inviteCode) throws IOException {
-		if (!StringUtil.isNullOrEmpty(url)) {
-			String targetPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + System.currentTimeMillis() + ".jpg";
-			String erCodeTempPath = FileUtil.getCacheDir() + "/" + uid + "_" + System.currentTimeMillis() + ".jpg";
-
-			String erCode = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/"
-					+ Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
-			// 鐢熸垚
-			try {
-				QRCodeUtil.getInstance(250).encode(erCode, erCodeTempPath);
-			} catch (Exception e) {
-				e.printStackTrace();
-			}
-
-			InputStream urlInputStream = HttpUtil.getAsInputStream(url); // 鑳屾櫙
-			InputStream portraitInputStream = HttpUtil.getAsInputStream(portrait); // 澶村儚
-			InputStream erCodeInputStream = new FileInputStream(new File(erCodeTempPath)); // 浜岀淮鐮�
-
-			// 寮�濮嬫牴鎹� url(鑳屾櫙鍥�), qrCode(浜岀淮鐮�), portrait(澶村儚) 鐢熸垚鍥剧墖
-			ImageUtil.inviteFriendImg(urlInputStream, portraitInputStream, erCodeInputStream, targetPath,
-					erCodePostionX, erCodePostionY, erCodeSize, inviteCode);
-
-			if (new File(targetPath).exists() && new File(targetPath).length() > 0) {
-				// 涓婁紶鏂囦欢
-
-				// 灏唘rl 杞负 md5 璁╁埌涓嬮潰涓坊鍔� 鍦ㄦ瘮杈僲d5鐨勫��
-
-				int index = url.lastIndexOf("/");
-				String newUrl = url.substring(index + 1);
-				String urlMd5 = newUrl.substring(0, newUrl.lastIndexOf("."));
-
-				String imgUrl = COSManager.getInstance()
-						.uploadFile(new File(targetPath), "ercode/" + "ercode_" + uid + "_" + urlMd5 + ".jpg").getUrl();
-
-				if (new File(erCodeTempPath).exists())
-					new File(erCodeTempPath).delete();
-
-				if (new File(targetPath).exists())
-					new File(targetPath).delete();
-
-				return imgUrl;
-			}
-		}
-		return null;
-	}
-	
-	
-	@Override
-	public String drawInviteQrCodeNew(String url, Long uid, String portrait, Integer pX, Integer pY, Integer size, String inviteCode) throws IOException {
-		
-		if (StringUtil.isNullOrEmpty(url)) {
-			return null;
-		}
-		
-		String targetPath = null;
-		String erCodeTempPath = null;
-		InputStream erCodeInputStream  = null; // 浜岀淮鐮�
-		InputStream portraitInputStream = null; // 澶村儚
-		InputStream urlInputStream = HttpUtil.getAsInputStream(url); // 鑳屾櫙
-		
-		String uuid = UUID.randomUUID().toString().replace("-", "");
-		if (uid == null) {
-			targetPath = FileUtil.getCacheDir() + "/share_" + uuid + "_" + System.currentTimeMillis() + ".jpg";
-			// 瀹樻柟 閭�璇风爜锛堟棤鏁堢殑锛�
-			inviteCode = "FLQAPP";
-			// 瀹樻柟浜岀淮鐮�
-			erCodeInputStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official.png");
-			// 瀹樻柟榛樿澶村儚
-			portraitInputStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official_icon.png");
-		
-		} else {
-		
-			targetPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + System.currentTimeMillis() + ".jpg";
-			erCodeTempPath = FileUtil.getCacheDir() + "/" + uid + "_" + System.currentTimeMillis() + ".jpg";
-	
-			String erCode = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/"
-					+ Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
-			// 鐢熸垚
-			try {
-				QRCodeUtil.getInstance(250).encode(erCode, erCodeTempPath);
-			} catch (Exception e) {
-				e.printStackTrace();
-			}
-	
-			urlInputStream = HttpUtil.getAsInputStream(url); // 鑳屾櫙
-			portraitInputStream = HttpUtil.getAsInputStream(portrait); // 澶村儚
-			erCodeInputStream = new FileInputStream(new File(erCodeTempPath)); // 浜岀淮鐮�
-		}
-		
-		// 寮�濮嬫牴鎹� url(鑳屾櫙鍥�), qrCode(浜岀淮鐮�), portrait(澶村儚) 鐢熸垚鍥剧墖
-		ImageUtil.inviteFriendImgWhitecustom(urlInputStream, portraitInputStream, erCodeInputStream, targetPath,
-			 pX, pY, size, inviteCode);
-		
-		// 鍒犻櫎浜岀淮鐮佹枃浠�
-		if(erCodeInputStream != null) {
-			erCodeInputStream.close();
-		}
-		if (erCodeTempPath != null && new File(erCodeTempPath).exists()) {
-			new File(erCodeTempPath).delete();
-		}
-		
-		// 涓婁紶鏂囦欢鐩稿浣嶇疆
-		if (new File(targetPath).exists() && new File(targetPath).length() > 0) {
-			int index = url.lastIndexOf("/");
-			String newUrl = url.substring(index + 1);
-			String urlMd5 = newUrl.substring(0, newUrl.lastIndexOf("."));
-			String fileUrl= null;
-			if (uid == null) {
-				fileUrl = "ercode/" + "ercode_" + uuid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
-			} else {
-				fileUrl = "ercode/" + "ercode_" + uid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
-			}
-
-			// 涓婁紶鏂囦欢
-			String imgUrl = COSManager.getInstance().uploadFile(new File(targetPath), fileUrl).getUrl();
-			
-			// 鍒犻櫎鏈湴缂撳瓨鏂囦欢
-			new File(targetPath).delete();
-
-			return imgUrl;
-		}
-		return null;
-	}
-	
-	@Override
-	public String drawInviteToGreet(String url, Long uid, String portrait, String inviteCode, String content, 
-			Date date) throws IOException {
-		
-		if (StringUtil.isNullOrEmpty(url)) {
-			return null;
-		}
-
-		String targetPath = null;
-		String erCodeTempPath = null;
-		InputStream erCodeInputStream  = null; // 浜岀淮鐮�
-		InputStream portraitInputStream = null; // 澶村儚
-		InputStream urlInputStream = HttpUtil.getAsInputStream(url); // 鑳屾櫙
-		
-		String uuid = UUID.randomUUID().toString().replace("-", "");
-		if (uid == null) {
-			targetPath = FileUtil.getCacheDir() + "/share_" + uuid + "_" + System.currentTimeMillis() + ".jpg";
-			// 瀹樻柟 閭�璇风爜锛堟棤鏁堢殑锛�
-			inviteCode = "FLQAPP";
-			// 瀹樻柟浜岀淮鐮�
-			erCodeInputStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official.png");
-			// 瀹樻柟榛樿澶村儚
-			portraitInputStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official_icon.png");
-		
-		} else {
-			targetPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + System.currentTimeMillis() + ".jpg";
-			erCodeTempPath = FileUtil.getCacheDir() + "/" + uid + "_" + System.currentTimeMillis() + ".jpg";
-			String erCode = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/"
-					+ Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
-			// 鐢熸垚
-			try {
-				QRCodeUtil.getInstance(250).encode(erCode, erCodeTempPath);
-			} catch (Exception e) {
-				e.printStackTrace();
-			}
-			erCodeInputStream = new FileInputStream(new File(erCodeTempPath)); 
-			portraitInputStream = HttpUtil.getAsInputStream(portrait); // 澶村儚
-		}
-		
-		
-		// 寮�濮嬫牴鎹� url(鑳屾櫙鍥�), qrCode(浜岀淮鐮�), portrait(澶村儚) 鐢熸垚鍥剧墖
-		ImageUtil.drawInviteToGreet(urlInputStream, portraitInputStream, erCodeInputStream, targetPath, inviteCode, content, date);
-
-		
-		// 鍒犻櫎浜岀淮鐮佹枃浠�
-		if(erCodeInputStream != null) {
-			erCodeInputStream.close();
-		}
-		if (erCodeTempPath != null && new File(erCodeTempPath).exists()) {
-			new File(erCodeTempPath).delete();
-		}
-		
-		// 涓婁紶鏂囦欢
-		if (new File(targetPath).exists() && new File(targetPath).length() > 0) {
-			int index = url.lastIndexOf("/");
-			String newUrl = url.substring(index + 1);
-			String urlMd5 = newUrl.substring(0, newUrl.lastIndexOf("."));
-
-			// 涓婁紶鏂囦欢鐩稿浣嶇疆
-			String fileUrl= null;
-			if (uid == null) {
-				fileUrl = "ercode/" + "ercode_" + uuid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
-			} else {
-				fileUrl = "ercode/" + "ercode_" + uid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
-			}
-
-			// 涓婁紶
-			String imgUrl = COSManager.getInstance().uploadFile(new File(targetPath), fileUrl).getUrl();
-			// 鍒犻櫎缂撳瓨鏂囦欢
-			new File(targetPath).delete();
-
-			return imgUrl;
-		} 
-		return null;
-	}
-
-}
+package com.yeshi.fanli.service.impl.user;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.UUID;
+
+import javax.annotation.Resource;
+
+import org.springframework.stereotype.Service;
+import org.yeshi.utils.HttpUtil;
+import org.yeshi.utils.QRCodeUtil;
+import org.yeshi.utils.entity.FileUploadResult;
+import org.yeshi.utils.tencentcloud.COSManager;
+
+import com.yeshi.fanli.dao.mybatis.share.ShareMapper;
+import com.yeshi.fanli.entity.bus.user.UserInfo;
+import com.yeshi.fanli.service.inter.user.QrCodeService;
+import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
+import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.FilePathEnum;
+import com.yeshi.fanli.util.FileUtil;
+import com.yeshi.fanli.util.ImageUtil;
+import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.UserInviteUtil;
+import com.yeshi.fanli.vo.goods.GoodsDetailVO;
+
+@Service
+public class QrCodeServiceImpl implements QrCodeService {
+
+	@Resource
+	private ShareMapper shareMapper;
+
+	@Resource
+	private SpreadUserImgService spreadUserImgService;
+
+	@Override
+	public String getPortrait(Long uid) {
+		return shareMapper.getPortrait(uid);
+	}
+
+	@Override
+	public String drawInviteQrCode(String url, Long uid, String portrait, String inviteCode) throws IOException {
+		if (url != null && !url.equals("")) {
+			String targetPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + System.currentTimeMillis() + ".jpg";
+			String erCodeTempPath = FileUtil.getCacheDir() + "/" + uid + "_" + System.currentTimeMillis() + ".jpg";
+
+			String erCode = ("http://" + Constant.wxGZConfig.getLoginHost() + "/"
+					+ Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
+			// 鐢熸垚
+			try {
+				QRCodeUtil.getInstance(250).encode(erCode, erCodeTempPath);
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+
+			InputStream urlInputStream = HttpUtil.getAsInputStream(url); // 鑳屾櫙
+			InputStream portraitInputStream = HttpUtil.getAsInputStream(portrait); // 澶村儚
+			InputStream erCodeInputStream = new FileInputStream(new File(erCodeTempPath)); // 浜岀淮鐮�
+
+			// 瀹樻柟榛樿澶村儚
+			if (portraitInputStream == null) {
+				portraitInputStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official_icon.png");
+			}
+			
+			
+			// 寮�濮嬫牴鎹� url(鑳屾櫙鍥�), qrCode(浜岀淮鐮�), portrait(澶村儚) 鐢熸垚鍥剧墖
+			ImageUtil.inviteFriendImg(urlInputStream, portraitInputStream, erCodeInputStream, targetPath, inviteCode);
+
+			if (new File(targetPath).exists() && new File(targetPath).length() > 0) {
+				// 涓婁紶鏂囦欢
+
+				// 灏唘rl 杞负 md5 璁╁埌涓嬮潰涓坊鍔� 鍦ㄦ瘮杈僲d5鐨勫��
+
+				int index = url.lastIndexOf("/");
+				String newUrl = url.substring(index + 1);
+				String urlMd5 = newUrl.substring(0, newUrl.lastIndexOf("."));
+
+				String imgUrl = COSManager.getInstance()
+						.uploadFile(new File(targetPath),
+								FilePathEnum.ercode.getPath() + "ercode_" + uid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg")
+						.getUrl();
+
+				if (new File(erCodeTempPath).exists())
+					new File(erCodeTempPath).delete();
+
+				if (new File(targetPath).exists())
+					new File(targetPath).delete();
+
+				return imgUrl;
+			}
+		}
+		return null;
+	}
+
+	@Override
+	public String drawInviteQrCode(String url, Long uid, String portrait, int erCodePostionX, int erCodePostionY,
+			int erCodeSize, String inviteCode) throws IOException {
+		if (!StringUtil.isNullOrEmpty(url)) {
+			String targetPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + System.currentTimeMillis() + ".jpg";
+			String erCodeTempPath = FileUtil.getCacheDir() + "/" + uid + "_" + System.currentTimeMillis() + ".jpg";
+
+			String erCode = ("http://" + Constant.wxGZConfig.getLoginHost() + "/"
+					+ Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
+			// 鐢熸垚
+			try {
+				QRCodeUtil.getInstance(250).encode(erCode, erCodeTempPath);
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+
+			InputStream urlInputStream = HttpUtil.getAsInputStream(url); // 鑳屾櫙
+			InputStream portraitInputStream = HttpUtil.getAsInputStream(portrait); // 澶村儚
+			InputStream erCodeInputStream = new FileInputStream(new File(erCodeTempPath)); // 浜岀淮鐮�
+
+			// 瀹樻柟榛樿澶村儚
+			if (portraitInputStream == null) {
+				portraitInputStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official_icon.png");
+			}
+			
+			// 寮�濮嬫牴鎹� url(鑳屾櫙鍥�), qrCode(浜岀淮鐮�), portrait(澶村儚) 鐢熸垚鍥剧墖
+			ImageUtil.inviteFriendImg(urlInputStream, portraitInputStream, erCodeInputStream, targetPath,
+					erCodePostionX, erCodePostionY, erCodeSize, inviteCode);
+
+			if (new File(targetPath).exists() && new File(targetPath).length() > 0) {
+				// 涓婁紶鏂囦欢
+
+				// 灏唘rl 杞负 md5 璁╁埌涓嬮潰涓坊鍔� 鍦ㄦ瘮杈僲d5鐨勫��
+
+				int index = url.lastIndexOf("/");
+				String newUrl = url.substring(index + 1);
+				String urlMd5 = newUrl.substring(0, newUrl.lastIndexOf("."));
+
+				String imgUrl = COSManager.getInstance().uploadFile(new File(targetPath), 
+						FilePathEnum.ercode.getPath() + "ercode_" + uid + "_" + urlMd5 + ".jpg").getUrl();
+
+				if (new File(erCodeTempPath).exists())
+					new File(erCodeTempPath).delete();
+
+				if (new File(targetPath).exists())
+					new File(targetPath).delete();
+
+				return imgUrl;
+			}
+		}
+		return null;
+	}
+
+	@Override
+	public String drawInviteQrCodeNew(InputStream urlInputStream, String urlMd5, Long uid, String portrait, Integer pX, Integer pY, Integer size,
+			String inviteCode) throws IOException {
+		if (urlInputStream == null) {
+			return null;
+		}
+
+		String targetPath = null;
+		String erCodeTempPath = null;
+		InputStream erCodeInputStream = null; // 浜岀淮鐮�
+		InputStream portraitInputStream = null; // 澶村儚
+//		InputStream urlInputStream = HttpUtil.getAsInputStream(url); // 鑳屾櫙
+
+		String uuid = UUID.randomUUID().toString().replace("-", "");
+		if (uid == null) {
+			targetPath = FileUtil.getCacheDir() + "/share_" + uuid + "_" + System.currentTimeMillis() + ".jpg";
+			// 瀹樻柟 閭�璇风爜锛堟棤鏁堢殑锛�
+			inviteCode = "FLQAPP";
+			// 瀹樻柟浜岀淮鐮�
+			erCodeInputStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official.png");
+			// 瀹樻柟榛樿澶村儚
+			portraitInputStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official_icon.png");
+
+		} else {
+			targetPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + System.currentTimeMillis() + ".jpg";
+			erCodeTempPath = FileUtil.getCacheDir() + "/" + uid + "_" + System.currentTimeMillis() + ".jpg";
+
+			String erCode = UserInviteUtil.getShareUrl(uid);
+			// 鐢熸垚
+			try {
+				QRCodeUtil.getInstance(250).encode(erCode, erCodeTempPath);
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+			portraitInputStream = HttpUtil.getAsInputStream(portrait); // 澶村儚
+			erCodeInputStream = new FileInputStream(new File(erCodeTempPath)); // 浜岀淮鐮�
+		}
+		
+		// 瀹樻柟榛樿澶村儚
+		if (portraitInputStream == null) {
+			portraitInputStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official_icon.png");
+		}
+		
+		
+		// 寮�濮嬫牴鎹� url(鑳屾櫙鍥�), qrCode(浜岀淮鐮�), portrait(澶村儚) 鐢熸垚鍥剧墖
+		ImageUtil.inviteFriendImgWhitecustom(urlInputStream, portraitInputStream, erCodeInputStream, targetPath, pX, pY,
+				size, inviteCode);
+
+		// 鍒犻櫎浜岀淮鐮佹枃浠�
+		if (erCodeInputStream != null) {
+			erCodeInputStream.close();
+		}
+		if (erCodeTempPath != null && new File(erCodeTempPath).exists()) {
+			new File(erCodeTempPath).delete();
+		}
+
+		// 涓婁紶鏂囦欢鐩稿浣嶇疆
+		if (new File(targetPath).exists() && new File(targetPath).length() > 0) {
+			String fileUrl = null;
+			if (uid == null) {
+				fileUrl = FilePathEnum.invitePictureDemo.getPath() + "ercode_" + uuid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
+			} else {
+				fileUrl = FilePathEnum.ercode.getPath() + "ercode_" + uid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
+			}
+
+			// 涓婁紶鏂囦欢
+			String imgUrl = COSManager.getInstance().uploadFile(new File(targetPath), fileUrl).getUrl();
+
+			// 鍒犻櫎鏈湴缂撳瓨鏂囦欢
+			new File(targetPath).delete();
+
+			return imgUrl;
+		}
+		return null;
+	}
+
+	@Override
+	public String drawInviteToGreet(String url, Long uid, String portrait, String inviteCode, String content, Date date)
+			throws IOException {
+
+		if (StringUtil.isNullOrEmpty(url)) {
+			return null;
+		}
+
+		String targetPath = null;
+		String erCodeTempPath = null;
+		InputStream erCodeInputStream = null; // 浜岀淮鐮�
+		InputStream portraitInputStream = null; // 澶村儚
+		InputStream urlInputStream = HttpUtil.getAsInputStream(url); // 鑳屾櫙
+
+		String uuid = UUID.randomUUID().toString().replace("-", "");
+		if (uid == null) {
+			targetPath = FileUtil.getCacheDir() + "/share_" + uuid + "_" + System.currentTimeMillis() + ".jpg";
+			// 瀹樻柟 閭�璇风爜锛堟棤鏁堢殑锛�
+			inviteCode = "FLQAPP";
+			// 瀹樻柟浜岀淮鐮�
+			erCodeInputStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official.png");
+			// 瀹樻柟榛樿澶村儚
+			portraitInputStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official_icon.png");
+
+		} else {
+			targetPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + System.currentTimeMillis() + ".jpg";
+			erCodeTempPath = FileUtil.getCacheDir() + "/" + uid + "_" + System.currentTimeMillis() + ".jpg";
+			String erCode = ("http://" + Constant.wxGZConfig.getLoginHost() + "/"
+					+ Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
+			// 鐢熸垚
+			try {
+				QRCodeUtil.getInstance(250).encode(erCode, erCodeTempPath);
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+			erCodeInputStream = new FileInputStream(new File(erCodeTempPath));
+			portraitInputStream = HttpUtil.getAsInputStream(portrait); // 澶村儚
+		}
+
+		// 瀹樻柟榛樿澶村儚
+		if (portraitInputStream == null) {
+			portraitInputStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official_icon.png");
+		}
+				
+		// 寮�濮嬫牴鎹� url(鑳屾櫙鍥�), qrCode(浜岀淮鐮�), portrait(澶村儚) 鐢熸垚鍥剧墖
+		ImageUtil.drawInviteToGreet(urlInputStream, portraitInputStream, erCodeInputStream, targetPath, inviteCode,
+				content, date);
+
+		// 鍒犻櫎浜岀淮鐮佹枃浠�
+		if (erCodeInputStream != null) {
+			erCodeInputStream.close();
+		}
+		if (erCodeTempPath != null && new File(erCodeTempPath).exists()) {
+			new File(erCodeTempPath).delete();
+		}
+
+		// 涓婁紶鏂囦欢
+		if (new File(targetPath).exists() && new File(targetPath).length() > 0) {
+			int index = url.lastIndexOf("/");
+			String newUrl = url.substring(index + 1);
+			String urlMd5 = newUrl.substring(0, newUrl.lastIndexOf("."));
+
+			// 涓婁紶鏂囦欢鐩稿浣嶇疆
+			String fileUrl = null;
+			if (uid == null) {
+				fileUrl = FilePathEnum.invitePictureDemo.getPath() + "ercode_" + uuid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
+			} else {
+				fileUrl = FilePathEnum.ercode.getPath() + "ercode_" + uid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
+			}
+
+			// 涓婁紶
+			String imgUrl = COSManager.getInstance().uploadFile(new File(targetPath), fileUrl).getUrl();
+			// 鍒犻櫎缂撳瓨鏂囦欢
+			new File(targetPath).delete();
+
+			return imgUrl;
+		}
+		return null;
+	}
+	
+	
+	
+	@Override
+	public FileUploadResult drawDynamicGoodsPoster(String erCodeUrl, String portrait, String inviteCode,
+			String mainPic, GoodsDetailVO goods) {
+		// 浜岀淮鐮佹祦
+		InputStream erCodeStream = null;
+		try {
+			erCodeStream = QRCodeUtil.getInstance(250).encodeDeleteWhite(erCodeUrl);
+		} catch (Exception e1) {
+			e1.printStackTrace();
+		}
+		
+		// 澶村儚
+		InputStream portraitStream = null; 
+		if (!StringUtil.isNullOrEmpty(portrait)) {
+			try {
+				portraitStream = HttpUtil.getAsInputStream(portrait);
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+		if (portraitStream == null) {
+			portraitStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official_default_head.jpg");
+		}
+		
+		// 鐢诲浘
+		InputStream drawStream = ImageUtil.drawGoodsPoster(erCodeStream, portraitStream,inviteCode,mainPic, goods);
+		// 涓婁紶浣嶇疆
+		String uuid = UUID.randomUUID().toString().replace("-", "");
+		String upPath = FilePathEnum.shareGoods.getPath() + uuid + "_" + goods.getGoodsId() + "_" + System.currentTimeMillis() + ".png";
+		// 涓婁紶鏂囦欢
+		return COSManager.getInstance().uploadInputStream(drawStream, upPath);
+	}
+	
+	
+	@Override
+	public FileUploadResult drawGoodsPoster(String erCodeUrl, String portrait, GoodsDetailVO goods) {
+		// 浜岀淮鐮佹祦
+		InputStream erCodeStream = null;
+		try {
+			erCodeStream = QRCodeUtil.getInstance(250).encode(erCodeUrl);
+		} catch (Exception e1) {
+			e1.printStackTrace();
+		}
+		
+		// 澶村儚
+		InputStream portraitStream = null; 
+		if (!StringUtil.isNullOrEmpty(portrait)) {
+			try {
+				portraitStream = HttpUtil.getAsInputStream(portrait);
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+		if (portraitStream == null) {
+			portraitStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official_default_head.jpg");
+		}
+		
+		// 鐢诲浘
+		InputStream drawStream = ImageUtil.drawGoodsShareSingle(erCodeStream, portraitStream, goods);
+		// 涓婁紶浣嶇疆
+		String uuid = UUID.randomUUID().toString().replace("-", "");
+		String upPath = FilePathEnum.shareXCX.getPath() + uuid + "_" + goods.getGoodsId() + "_" + System.currentTimeMillis() + ".png";
+		// 涓婁紶鏂囦欢
+		return COSManager.getInstance().uploadInputStream(drawStream, upPath);
+	}
+
+	
+	@Override
+	public FileUploadResult drawGoodsPosterXCX(InputStream erCodeStream,UserInfo user, GoodsDetailVO goods) {
+		// 鐢诲浘
+		InputStream drawStream = ImageUtil.drawGoodsShareXCX(erCodeStream, user, goods);
+		// 涓婁紶浣嶇疆
+		String uuid = UUID.randomUUID().toString().replace("-", "");
+		String upPath = FilePathEnum.shareXCX.getPath() + uuid + "_" + goods.getGoodsId() + "_" + System.currentTimeMillis() + ".png";
+		// 涓婁紶鏂囦欢
+		return COSManager.getInstance().uploadInputStream(drawStream, upPath);
+	}
+
+}

--
Gitblit v1.8.0