From e7920b14a9baab97035a1a529da85d124a2bcacd Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期二, 16 六月 2020 10:54:29 +0800
Subject: [PATCH] 云发单对测试用户显示

---
 fanli/src/main/java/com/yeshi/fanli/controller/CallBackController.java |   84 +++++++++++++++++++++++++-----------------
 1 files changed, 50 insertions(+), 34 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/CallBackController.java b/fanli/src/main/java/com/yeshi/fanli/controller/CallBackController.java
index 225f845..6609362 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/CallBackController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/CallBackController.java
@@ -2,14 +2,13 @@
 
 import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.PrintWriter;
 import java.math.BigDecimal;
 import java.security.SignatureException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -21,8 +20,6 @@
 
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.multipart.MultipartFile;
-import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.yeshi.utils.taobao.TbImgUtil;
 import org.yeshi.utils.wx.WXUtil;
 
@@ -34,6 +31,7 @@
 import com.yeshi.fanli.entity.bus.activity.ActivityRuleUser;
 import com.yeshi.fanli.entity.bus.activity.ActivityUser;
 import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState;
+import com.yeshi.fanli.entity.bus.user.cloud.UserCloud;
 import com.yeshi.fanli.entity.dynamic.ImgInfo;
 import com.yeshi.fanli.entity.dynamic.ImgInfo.ImgEnum;
 import com.yeshi.fanli.entity.dynamic.SimpleGoods;
@@ -51,6 +49,7 @@
 import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
 import com.yeshi.fanli.service.inter.push.PushService;
 import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService;
+import com.yeshi.fanli.service.inter.user.cloud.UserCloudService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
@@ -94,12 +93,15 @@
 
 	@Resource
 	private HongBaoManageService hongBaoManageService;
-	
+
 	@Resource
 	private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
 
 	@Resource
 	private ActivityUserService activityUserService;
+
+	@Resource
+	private UserCloudService userCloudService;
 
 	/**
 	 * 瀹㈡湇娑堟伅鍥炶皟
@@ -194,8 +196,6 @@
 	public void VIP(PrintWriter out) {
 		out.print("success");
 	}
-	
-	
 
 	/**
 	 * 鏀粯瀹濇敮浠樺洖璋�
@@ -260,37 +260,19 @@
 		// return;
 		// }
 		String contentDecode = "";
-		if (request instanceof MultipartHttpServletRequest) {
-			MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
-			List<MultipartFile> files = multipartRequest.getFiles("file");
-			try {
-				InputStream input = files.get(0).getInputStream();
-				InputStreamReader reader = new InputStreamReader(input, "UTF-16LE");
-				int d = -1;
-				String st = "";
-				while ((d = reader.read()) != -1) {
-					st += ((char) d);
-				}
-				System.out.println(st);
-				contentDecode = st;
 
-				contentDecode = contentDecode.substring(contentDecode.indexOf("(") +1,
-						contentDecode.length()).trim();
-				if (contentDecode.endsWith(")"))
-					contentDecode = contentDecode.substring(0, contentDecode.length() - 1);
+		contentDecode = content.substring(content.indexOf("(") + 1, content.length()).trim();
+		if (contentDecode.endsWith(")"))
+			contentDecode = contentDecode.substring(0, contentDecode.length() - 1);
 
-				System.out.println(contentDecode);
-
-				reader.close();
-
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-		}
+		System.out.println(contentDecode);
 
 		JSONObject data = JSONObject.fromObject(contentDecode).optJSONObject("data");
 
 		JSONArray array = data.optJSONObject("recommend").optJSONArray("resultList");
+
+		long startTime = System.currentTimeMillis();
+
 		for (int i = array.size() - 1; i >= 0; i--) {
 			JSONObject item = array.optJSONObject(i);
 			String title = item.optString("itemName");
@@ -337,7 +319,7 @@
 				} else {
 					imgInfo.setType(ImgEnum.goods);
 					SimpleGoods simpleGoods = new SimpleGoods();
-					simpleGoods.setGoodsId(itemId+"");
+					simpleGoods.setGoodsId(itemId + "");
 					simpleGoods.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
 					simpleGoods.setState(CommonGoods.STATE_NORMAL);
 					CouponInfoVO couponInfo = goodsVO.getCouponInfo();
@@ -357,12 +339,46 @@
 
 			ActivityUser user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser();
 			try {
-				goodsEvaluateService.addGoodsEvaluate(itemId+"", imageList, user, doc, null, null);
+				goodsEvaluateService.addGoodsEvaluate(itemId + "", imageList, user, doc, null,
+						new Date(startTime - 1000 * 60 * 20L * i));
 			} catch (GoodsEvaluateException e) {
 				e.printStackTrace();
+			} catch (Exception e) {
+				e.printStackTrace();
 			}
 		}
 
 	}
 
+	@RequestMapping(value = "yhg/groupmsg")
+	public void groupMsg(HttpServletRequest request, PrintWriter out) {
+		StringBuilder stringBuilder = new StringBuilder();
+		try {
+			byte[] buffer = new byte[2048];
+			int readBytes = 0;
+			while ((readBytes = request.getInputStream().read(buffer)) > 0) {
+				stringBuilder.append(new String(buffer, 0, readBytes));
+			}
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+		try {
+			JSONObject root = JSONObject.fromObject(stringBuilder.toString());
+			if (root.optInt("messageType") == 9) {
+				String content = root.optJSONObject("data").optString("content");
+				LogHelper.test("浜戝彂鍗曠兢鍐呭:" + content);
+				if (content.trim().equalsIgnoreCase(Constant.YHG_CLOUD_GROUP_AWAKEN_KEY)) {
+					LogHelper.test("浜戝彂鍗曠兢鍖归厤:" + root.optString("wcId") + "-"
+							+ root.optJSONObject("data").optString("fromGroup"));
+					userCloudService.cacheMatchGroup(root.optString("wcId"),
+							root.optJSONObject("data").optString("fromGroup"));
+				}
+			}
+		} catch (Exception e) {
+
+		}
+
+	}
+
 }

--
Gitblit v1.8.0