From e1a62ec62e7331d97af9302e90e1ce44af8235eb Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 27 一月 2021 15:26:55 +0800
Subject: [PATCH] 拼多多授权绑定

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v1/PushController.java |  118 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 106 insertions(+), 12 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/PushController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/PushController.java
index b327acf..12fb5a7 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/PushController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/PushController.java
@@ -7,6 +7,7 @@
 
 import javax.annotation.Resource;
 
+import org.apache.commons.beanutils.PropertyUtils;
 import org.springframework.core.task.TaskExecutor;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -14,10 +15,13 @@
 import org.yeshi.utils.JsonUtil;
 import org.yeshi.utils.taobao.TbImgUtil;
 
+import com.google.gson.GsonBuilder;
 import com.yeshi.fanli.entity.accept.AcceptData;
 import com.yeshi.fanli.entity.bus.activity.ActivityUser;
 import com.yeshi.fanli.entity.common.JumpDetailV2;
 import com.yeshi.fanli.entity.dynamic.GoodsEvaluate;
+import com.yeshi.fanli.entity.dynamic.ImgInfo;
+import com.yeshi.fanli.entity.dynamic.ImgInfo.ImgEnum;
 import com.yeshi.fanli.entity.goods.CommonGoods;
 import com.yeshi.fanli.entity.push.DeviceActive;
 import com.yeshi.fanli.entity.push.DeviceTokenOPPO;
@@ -46,9 +50,10 @@
 import com.yeshi.fanli.service.inter.push.PushService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.StringUtil;
+import org.yeshi.utils.TimeUtil;
 import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
 import com.yeshi.fanli.util.factory.JumpDetailParamsFactory;
-import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
+import com.yeshi.common.vo.ClientTextStyleVO;
 import com.yeshi.fanli.vo.push.PushRecommendVO;
 
 import net.sf.json.JSONArray;
@@ -109,7 +114,7 @@
 	@RequestMapping(value = "callback", method = RequestMethod.POST)
 	public void callback(AcceptData acceptData, String pushId, PrintWriter out) {
 		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
-				acceptData.getPackages());
+				acceptData.getPackages(),acceptData.getSystem());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("涓嶅瓨鍦ㄨ绯荤粺"));
 			return;
@@ -224,10 +229,10 @@
 
 		// 璁惧娉ㄥ唽鏃堕棿
 		Date createTime = deviceActive.getCreateTime();
-		count = pushGoodsService.countHistoryByPushTime(uid, createTime);
+		count = pushGoodsService.countHistoryByPushTime(uid, createTime,acceptData.getSystem());
 
 		int pageSize = Constant.PAGE_SIZE;
-		List<PushGoods> list = pushGoodsService.listHistoryByPushTime((page - 1) * pageSize, pageSize, uid, createTime);
+		List<PushGoods> list = pushGoodsService.listHistoryByPushTime((page - 1) * pageSize, pageSize, uid, createTime,acceptData.getSystem());
 		if (list == null)
 			list = new ArrayList<>();
 
@@ -283,7 +288,7 @@
 					jumpDetail = jumpDetailV2Service.getByTypeCache("goodsdetail",Constant.getPlatformCode(acceptData.getPlatform()),
 							Integer.parseInt(acceptData.getVersion()));
 				} else {
-					String url = configService.get(ConfigKeyEnum.pushGoodsDetails.getKey());
+					String url = configService.getValue(ConfigKeyEnum.pushGoodsDetails.getKey(),acceptData.getSystem());
 					if (url == null) {
 						url = "";
 					}
@@ -299,18 +304,28 @@
 				totalwords.add(new ClientTextStyleVO("涓晢鍝�", "#666666"));
 			} else if (type == PushGoods.TYPE_ACTIVITY) {
 				GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pushGoods.getOtherId());
-				if (goodsEvaluate != null) {
-					ActivityUser user = goodsEvaluate.getUser();
-					if (user != null) {
-						nickName = user.getNickName();
+				if (goodsEvaluate == null) {
+					continue;
+				}
+				ActivityUser user = goodsEvaluate.getUser();
+				if (user != null) {
+					nickName = user.getNickName();
+				}
+				
+				if (StringUtil.isNullOrEmpty(vo.getPicture()) && goodsEvaluate.getImgList() != null &&
+						goodsEvaluate.getImgList().size() > 0) {
+					for (ImgInfo tmgInfo: goodsEvaluate.getImgList()) {
+						if (tmgInfo.getType() == ImgEnum.img || tmgInfo.getType() == ImgEnum.activity) {
+							vo.setPicture(tmgInfo.getUrl());
+						}
 					}
 				}
-
-				String url = configService.get(ConfigKeyEnum.pushActivityLink.getKey());
+				
+				String url = configService.getValue(ConfigKeyEnum.pushActivityLink.getKey(),acceptData.getSystem());
 				if (url == null) {
 					url = "";
 				}
-				url = url + "?id=" + id + "&otherId=" + pushGoods.getOtherId();
+				url = url + "?id=" + id;
 				params = JumpDetailParamsFactory.createWEBParams(url);
 				jumpDetail = jumpDetailV2Service.getByTypeCache("web",
 						Constant.getPlatformCode(acceptData.getPlatform()), Integer.parseInt(acceptData.getVersion()));
@@ -399,4 +414,83 @@
 		out.print(JsonUtil.loadTrueResult(""));
 	}
 
+	/**
+	 * 鑾峰彇鎺ㄩ�佹椿鍔ㄨ鎯�
+	 * @param callback
+	 * @param acceptData
+	 * @param uid
+	 * @param id
+	 * @param out
+	 */
+	@RequestMapping("getPushDetail")
+	public void getPushDetail(String callback, AcceptData acceptData, Long uid, Long id, PrintWriter out) {
+		if (uid == null || id == null) {
+			JsonUtil.printMode(out, callback,JsonUtil.loadFalseResult("鍙傛暟涓嶅畬鏁�"));
+			return;
+		}
+		
+		PushGoods pushGoods = pushGoodsService.selectByPrimaryKey(id);
+		if (pushGoods == null || StringUtil.isNullOrEmpty(pushGoods.getOtherId())) {
+			JsonUtil.printMode(out, callback,JsonUtil.loadFalseResult("璇ユ椿鍔ㄥ凡涓嬫灦"));
+			return;
+		}
+		
+		GoodsEvaluate goodsEvaluate = goodsEvaluateService.getById(pushGoods.getOtherId());
+		if (goodsEvaluate == null) {
+			JsonUtil.printMode(out, callback,JsonUtil.loadFalseResult("璇ユ椿鍔ㄥ凡涓嬫灦"));
+			return;
+		}
+		
+		String scanResult = null;
+		Integer scanNum = pushGoods.getScanNum();
+		if (scanNum == null) {
+		} else if (scanNum >= 10000) {
+			double num = scanNum;
+			String numMidea = String.format("%.1f", num / 10000);
+			scanResult = numMidea + "涓�";
+		} else {
+			scanResult = scanNum +"";
+		}
+		
+		String jumpLink = configService.getValue(ConfigKeyEnum.activityDetailLink.getKey(),acceptData.getSystem()) + "?type=%s&id=%s";
+		jumpLink = String.format(jumpLink, "circle", goodsEvaluate.getId());
+		if (!StringUtil.isNullOrEmpty(goodsEvaluate.getJumpLink())) {
+			goodsEvaluate.setJumpLink(jumpLink);
+		}
+		
+		List<ImgInfo> imgListNew = new ArrayList<>();
+		List<ImgInfo> imgList = goodsEvaluate.getImgList();
+		if (imgList != null && imgList.size() > 0) {
+			for (ImgInfo imgInfo: imgList) {
+				if (imgInfo.getType() != ImgEnum.img || imgInfo.getType() == ImgEnum.activity) {
+					ImgInfo imgInfoNew = new ImgInfo();
+					try {
+						PropertyUtils.copyProperties(imgInfoNew, imgInfo);
+					} catch (Exception e) {
+						e.printStackTrace();
+						continue;
+					}
+					
+					if (!StringUtil.isNullOrEmpty(imgInfoNew.getActivityUrl())) {
+						imgInfoNew.setActivityUrl(jumpLink);
+					}
+					
+					imgListNew.add(imgInfoNew);
+					continue;
+				} 
+				imgListNew.add(imgInfo);
+			}
+		}
+		goodsEvaluate.setImgList(imgListNew);
+		
+		GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
+		
+		JSONObject json = new JSONObject();
+		json.put("title", pushGoods.getTitle());
+		json.put("content", pushGoods.getContent());
+		json.put("pushTime", TimeUtil.formatDate(pushGoods.getPushTime()));
+		json.put("scanNum", scanResult);
+		json.put("detailInfo", gsonBuilder.create().toJson(goodsEvaluate));
+		JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json));
+	}
 }

--
Gitblit v1.8.0