From 651a15c78f668bef3859d9ed1bb7ad0b669d3600 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 03 七月 2020 17:52:07 +0800
Subject: [PATCH] 多APP优化

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java |   78 +++++++++++++++++++++------------------
 1 files changed, 42 insertions(+), 36 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java
index 0ce3f20..0128ca1 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ShareController.java
@@ -10,6 +10,9 @@
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 
+import com.yeshi.fanli.entity.SystemEnum;
+import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException;
+import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager;
 import org.springframework.core.task.TaskExecutor;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -90,6 +93,9 @@
 
 	@Resource
 	private ShareGoodsService shareGoodsService;
+
+	@Resource
+	private TaoBaoLinkManager taoBaoLinkManager;
 
 	@Resource
 	private ConfigService configService;
@@ -193,15 +199,15 @@
 		}
 
 		if (source != null && "taolijin".equals(source)) {
-			createTaoLijin(uid, auctionId, totalNum, relationId, request, out);
+			createTaoLijin(uid, auctionId, totalNum, relationId,acceptData.getSystem(), request, out);
 			return;
 		}
 
 		try {
-			TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId);
+			TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(uid, auctionId, relationId,null);
 
 			JSONObject data = new JSONObject();
-			String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
+			String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()),
 					Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
 					auctionId + "");
 
@@ -212,7 +218,7 @@
 
 			data.put("clickUrl", url);
 			data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
-			data.put("rule", configService.get(ConfigKeyEnum.shareSingleGoodsRule.getKey()));
+			data.put("rule", configService.getValue(ConfigKeyEnum.shareSingleGoodsRule.getKey(),acceptData.getSystem()));
 			data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
 
 			String shareText = "";
@@ -223,14 +229,14 @@
 			if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
 				String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
 				if (StringUtil.isNullOrEmpty(text))
-					text = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
+					text = configService.getValue(ConfigKeyEnum.goodsShareTextNoCoupon.getKey(),acceptData.getSystem());
 				shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle()).replace("{鍟嗗搧鍘熶环}",
 						MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "");
 			} else// 鏈夊埜
 			{
 				String text = shareGoodsTextTemplateService.geteCouponTemplate(uid);
 				if (StringUtil.isNullOrEmpty(text))
-					text = configService.get(ConfigKeyEnum.goodsShareTextCoupon.getKey());
+					text = configService.getValue(ConfigKeyEnum.goodsShareTextCoupon.getKey(),acceptData.getSystem());
 
 				shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle())
 						.replace("{鍟嗗搧鍘熶环}", MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "")
@@ -248,12 +254,12 @@
 				descText = descText.substring(0);
 			data.put("descText", descText);
 			//
-			String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
+			String imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs.getKey(),acceptData.getSystem());
 			JSONArray array = JSONArray.fromObject(imgs);
 			int p = (int) (array.size() * Math.random());
 			if (p < array.size())
 				data.put("notifyPicture", array.optString(p));
-			data.put("notifyDesc", configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
+			data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(),acceptData.getSystem()));
 
 			// 娣诲姞鍒嗕韩璁板綍
 			BigDecimal rate = hongBaoManageService.getShareRate();
@@ -299,7 +305,7 @@
 				}
 			});
 			return;
-		} catch (ShareGoodsException e) {
+		} catch (TaoBaoConvertLinkException e) {
 			LogHelper.errorDetailInfo(e, "鍒嗕韩鍑洪敊:uid:" + uid + "auctionId:" + auctionId, "");
 			// 鍒嗕韩鍑洪敊鎶ヨ
 			try {
@@ -307,7 +313,7 @@
 			} catch (Exception e1) {
 			}
 			out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
-			businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""));
+			businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""),acceptData.getSystem());
 		}
 	}
 
@@ -321,10 +327,10 @@
 	 * @param request
 	 * @param out
 	 */
-	public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, HttpServletRequest request,
-			PrintWriter out) {
+	public void createTaoLijin(Long uid, Long auctionId, int totalNum, String relationId, SystemEnum system, HttpServletRequest request,
+							   PrintWriter out) {
 		try {
-			TaoBaoLink taoBaoLink = shareGoodsService.getTaoLiJinLinkForShare(uid, auctionId, relationId);
+			TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoLiJinLinkForShare(uid, auctionId, relationId,null);
 
 			TaoBaoGoodsBrief goods = taoBaoLink.getGoods();
 
@@ -354,7 +360,7 @@
 				return;
 			}
 
-			String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&tid=%s", configService.getH5Host(),
+			String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq&tid=%s", configService.getH5Host(system),
 					Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
 					auctionId + "", AESUtil.encrypt(tljId + "", Constant.UIDAESKEY));
 			String shortLink = HttpUtil.getShortLink(url);
@@ -390,7 +396,7 @@
 			if (StringUtil.isNullOrEmpty(taoBaoLink.getGoods().getCouponInfo())) {
 				String text = shareGoodsTextTemplateService.getCommonTemplate(uid);
 				if (StringUtil.isNullOrEmpty(text))
-					text = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
+					text = configService.getValue(ConfigKeyEnum.goodsShareTextNoCoupon.getKey(),system);
 				shareText = text.replace("{鏍囬}", taoBaoLink.getGoods().getTitle()).replace("{鍟嗗搧鍘熶环}",
 						MoneyBigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getZkPrice()) + "");
 			} else// 鏈夊埜
@@ -416,12 +422,12 @@
 				descText = descText.substring(0);
 			data.put("descText", descText);
 
-			String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
+			String imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs.getKey(),system);
 			JSONArray array = JSONArray.fromObject(imgs);
 			int p = (int) (array.size() * Math.random());
 			if (p < array.size())
 				data.put("notifyPicture", array.optString(p));
-			data.put("notifyDesc", configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
+			data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(),system));
 
 			// 娣诲姞鍒嗕韩璁板綍
 			BigDecimal rate = hongBaoManageService.getShareRate();
@@ -467,7 +473,7 @@
 				}
 			});
 			return;
-		} catch (ShareGoodsException e) {
+		} catch (TaoBaoConvertLinkException e) {
 			LogHelper.errorDetailInfo(e, "鍒嗕韩鍑洪敊:uid:" + uid + "auctionId:" + auctionId, "");
 			// 鍒嗕韩鍑洪敊鎶ヨ
 			try {
@@ -475,7 +481,7 @@
 			} catch (Exception e1) {
 			}
 			out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
-			businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""));
+			businessEmergent110Service.shareTaoBaoGoodsError(StringUtil.Md5(auctionId + ""),system);
 		}
 	}
 
@@ -691,7 +697,7 @@
 		}
 
 		if (StringUtil.isNullOrEmpty(template))
-			template = getShareTemplate(uid, hasCoupon, tljId);
+			template = getShareTemplate(uid, hasCoupon, tljId,acceptData.getSystem());
 
 		// 鏍¢獙鍒告ā鏉挎槸鍚︽纭�
 		if (hasCoupon) {
@@ -730,7 +736,7 @@
 			}
 			url = userTaoLiJinRecord.getSendUrl();
 		} else {
-			url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
+			url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()),
 					Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
 					goods.getAuctionId() + "");
 		}
@@ -850,7 +856,7 @@
 		out.print(JsonUtil.loadTrueResult(""));
 	}
 
-	private String getShareTemplate(Long uid, boolean hasCoupon, Long tljId) {
+	private String getShareTemplate(Long uid, boolean hasCoupon, Long tljId,SystemEnum system) {
 		if (hasCoupon) {
 			if (tljId != null) {
 				String template = shareGoodsTextTemplateService.getTaoLiJinTemplate(uid);
@@ -860,14 +866,14 @@
 			} else {
 				String template = shareGoodsTextTemplateService.geteCouponTemplate(uid);
 				if (StringUtil.isNullOrEmpty(template))
-					template = configService.get(ConfigKeyEnum.goodsShareTextCoupon.getKey());
+					template = configService.getValue(ConfigKeyEnum.goodsShareTextCoupon.getKey(),system);
 				return template;
 			}
 
 		} else {
 			String template = shareGoodsTextTemplateService.getCommonTemplate(uid);
 			if (StringUtil.isNullOrEmpty(template))
-				template = configService.get(ConfigKeyEnum.goodsShareTextNoCoupon.getKey());
+				template = configService.getValue(ConfigKeyEnum.goodsShareTextNoCoupon.getKey(),system);
 			return template;
 		}
 	}
@@ -893,7 +899,7 @@
 		}
 
 		JSONObject data = new JSONObject();
-		data.put("template", getShareTemplate(uid, hasCoupon, tljId));
+		data.put("template", getShareTemplate(uid, hasCoupon, tljId,acceptData.getSystem()));
 		out.print(JsonUtil.loadTrueResult(data));
 	}
 
@@ -908,7 +914,7 @@
 		if (tljId != null) {
 			out.print(JsonUtil.loadTrueResult(configTaoLiJinService.getValueByKey("share_goods_rules", new Date())));
 		} else {
-			out.print(JsonUtil.loadTrueResult(configService.get(ConfigKeyEnum.shareGoodsTemplateRules.getKey())));
+			out.print(JsonUtil.loadTrueResult(configService.getValue(ConfigKeyEnum.shareGoodsTemplateRules.getKey(),acceptData.getSystem())));
 		}
 	}
 
@@ -916,8 +922,8 @@
 	 * 鏌ヨ椤堕儴鍒嗙被
 	 * 
 	 * @param acceptData
-	 * @param page
-	 * @param cid
+	 * @param id
+	 * @param uid
 	 * @param out
 	 */
 	@RequestMapping(value = "shareDynamic", method = RequestMethod.POST)
@@ -1042,10 +1048,10 @@
 				data.put("shareMoney", new BigDecimal(content.substring(index + 1, content.length())).toString());
 
 				// 鍒嗕韩鎻愰啋
-				data.put("notifyDesc", configService.get(ConfigKeyEnum.goodsShareNotify.getKey()));
+				data.put("notifyDesc", configService.getValue(ConfigKeyEnum.goodsShareNotify.getKey(),acceptData.getSystem()));
 
 				// 鍒嗕韩鎻愮ず璇�
-				String imgs = configService.get(ConfigKeyEnum.goodsShareNotifyImgs.getKey());
+				String imgs = configService.getValue(ConfigKeyEnum.goodsShareNotifyImgs.getKey(),acceptData.getSystem());
 				JSONArray array = JSONArray.fromObject(imgs);
 				int p = (int) (array.size() * Math.random());
 				if (p < array.size()) {
@@ -1073,7 +1079,7 @@
 
 					Long auctionId = dynamicInfo.getImgs().get(0).getGoods().getAuctionId();
 					// 鍟嗗搧鍒嗕韩閾炬帴
-					String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
+					String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()),
 							Constant.systemCommonConfig.getShareGoodsPagePath(),
 							AESUtil.encrypt(uid + "", Constant.UIDAESKEY), auctionId + "");
 					String shortLink = HttpUtil.getShortLink(url);
@@ -1090,13 +1096,13 @@
 							&& extraInfo.getRelationValid() == true) {
 						relationId = extraInfo.getRelationId();
 					}
-					TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId);
+					TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(uid, auctionId, relationId,null);
 					TaoBaoGoodsBrief goods = taoBaoLink.getGoods();
 					if (!com.yeshi.fanli.util.VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(),
 							acceptData.getVersion()))
 						data.put("clickUrl",
 								ShareControllerV2.getERCodeContentNew(
-										configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), goods,
+										configService.getValue(ConfigKeyEnum.taobaoShareQrcodeText.getKey(),acceptData.getSystem()), goods,
 										taoBaoLink.getTaoToken()));
 
 					data.put("token", TaoBaoUtil.filterTaoToken(taoBaoLink.getTaoToken()));
@@ -1104,7 +1110,7 @@
 					String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
 					// 娴嬭瘯
 					List<String> commentTexts = new ArrayList<>();
-					String commentTextStr = configService.get(ConfigKeyEnum.shareSingleGoodsCommentText.getKey());
+					String commentTextStr = configService.getValue(ConfigKeyEnum.shareSingleGoodsCommentText.getKey(),acceptData.getSystem());
 					if (!StringUtil.isNullOrEmpty(commentTextStr)) {
 						JSONArray arr = JSONArray.fromObject(commentTextStr);
 						for (int i = 0; i < arr.size(); i++) {
@@ -1124,7 +1130,7 @@
 					data.put("commentTexts", commentTexts);
 					data.put("wxErCode",
 							ShareControllerV2.getERCodeContentNew(
-									configService.get(ConfigKeyEnum.taobaoShareQrcodeText.getKey()), goods,
+									configService.getValue(ConfigKeyEnum.taobaoShareQrcodeText.getKey(),acceptData.getSystem()), goods,
 									taoBaoLink.getTaoToken()));
 				}
 
@@ -1199,7 +1205,7 @@
 
 					data.put("inviteLink", Constant.YINGYONGBAO_LINK);
 					data.put("inviteCode", inviteCode);
-					data.put("helpLink", configService.get(ConfigKeyEnum.inviteHelpLink.getKey()));
+					data.put("helpLink", configService.getValue(ConfigKeyEnum.inviteHelpLink.getKey(),acceptData.getSystem()));
 				}
 			}
 			out.print(JsonUtil.loadTrueResult(data));

--
Gitblit v1.8.0