From feee16c2fe842ef452823d3f8ed95a39ad191ee6 Mon Sep 17 00:00:00 2001
From: 喻健 <喻健@Admin>
Date: 星期一, 10 十二月 2018 16:11:20 +0800
Subject: [PATCH] 分享记录来源查询

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java |  149 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 140 insertions(+), 9 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java
index 4d4b506..18fc9c4 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java
@@ -7,27 +7,36 @@
 import java.util.List;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
 
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.yeshi.utils.HttpUtil;
 import org.yeshi.utils.JsonUtil;
 import org.yeshi.utils.taobao.TbImgUtil;
 
 import com.yeshi.fanli.entity.accept.AcceptData;
+import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
 import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
+import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
 import com.yeshi.fanli.entity.taobao.TaoBaoLink;
 import com.yeshi.fanli.exception.ShareGoodsException;
 import com.yeshi.fanli.service.inter.config.ConfigService;
 import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
 import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
+import com.yeshi.fanli.service.inter.monitor.MonitorService;
+import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
+import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
 import com.yeshi.fanli.util.AESUtil;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.factory.MonitorFactory;
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
-
-import net.sf.json.JSONObject;
 
 @Controller(value = "ShareController1")
 @RequestMapping("api/v1/share")
@@ -41,6 +50,15 @@
 
 	@Resource
 	private HongBaoManageService hongBaoManageService;
+
+	@Resource
+	private MonitorService monitorService;
+	
+	@Resource
+	private UserShareGoodsRecordService userShareGoodsRecordService;
+	
+	@Resource
+	private UserShareGoodsGroupService userShareGoodsGroupService;
 
 	// 鑾峰彇鍟嗗搧鍒嗕韩閾炬帴
 	@RequestMapping(value = "getGoodsShareUrl")
@@ -59,7 +77,8 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "gettaobaosharelink")
-	public void getTaobaoShareLink(AcceptData acceptData, Long uid, Long auctionId, PrintWriter out) {
+	public void getTaobaoShareLink(AcceptData acceptData, Long uid, Long auctionId, HttpServletRequest request,
+			PrintWriter out) {
 		if (uid == null || uid <= 0) {
 			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛ID涓嶈兘涓虹┖"));
 			return;
@@ -85,7 +104,8 @@
 
 			data.put("clickUrl", url);
 			data.put("token", taoBaoLink.getTaoToken());
-			data.put("rule", "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
+			data.put("rule",
+					"http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
 			data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
 
 			String shareText = "";
@@ -105,13 +125,20 @@
 			}
 			shareText = shareText.replace("[浠锋牸绫诲瀷]", shopType);
 			data.put("shareText", shareText);
-			String descText=shareText.replace(taoBaoLink.getGoods().getTitle()+"\r\n", "");
-			if(descText.startsWith("\\r\\n"))
-				descText=descText.substring(0);
-			data.put("descText",descText );
+			String descText = shareText.replace(taoBaoLink.getGoods().getTitle() + "\r\n", "");
+			if (descText.startsWith("\\r\\n"))
+				descText = descText.substring(0);
+			data.put("descText", descText);
+			//
+			String imgs = configService.get("goods_share_notify_imgs");
+			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("goods_share_notify"));
 
 			// 娣诲姞鍒嗕韩璁板綍
-			BigDecimal rate = new BigDecimal(hongBaoManageService.get("hongbao_goods_proportion"));
+			BigDecimal rate =hongBaoManageService.getFanLiRate();
 			UserShareGoodsHistory history = new UserShareGoodsHistory();
 			history.setTkCode(taoBaoLink.getTaoToken());
 			history.setLink(taoBaoLink.getClickUrl());
@@ -141,9 +168,113 @@
 			});
 			return;
 		} catch (ShareGoodsException e) {
+			try {
+				monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "鍒嗕韩鍑洪敊"));
+			} catch (Exception e1) {
+			}
 			out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
 		}
 
 	}
+	
+	/**
+	 * 鍒嗕韩璁板綍缁熻鍒楄〃
+	 * @param acceptData
+	 * @param page 鍒濆1
+	 * @param uid
+	 * @param source
+	 * @param out
+	 */
+	@RequestMapping(value = "getlistrecord", method = RequestMethod.POST)
+	public void getListRecord(AcceptData acceptData, Integer page, Long uid, String source, PrintWriter out) {
+
+		if (page == null || page < 1) {
+			out.print(JsonUtil.loadFalseResult("椤电爜涓嶆纭�"));
+		}
+
+		if (uid == null) {
+			out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"));
+		}
+		
+		if ("all".equals(source)) {
+			source = null;// 鏌ヨ鍏ㄩ儴
+		}
+
+		try {
+			int pageSize = Constant.PAGE_SIZE;
+
+			JSONObject data = new JSONObject();
+			List<UserShareGoodsRecord> list = new ArrayList<UserShareGoodsRecord>();
+
+			long count = userShareGoodsRecordService.countQueryByUid(uid, source);
+			
+			if (count > 0) {
+				list = userShareGoodsRecordService.getMyShareGoodsRecords((page - 1) * pageSize, pageSize, uid, source);
+			}
+
+			data.put("count", count);
+			data.put("result_list", list);
+			out.print(JsonUtil.loadTrueResult(data));
+
+		} catch (Exception e) {
+			out.print(JsonUtil.loadFalseResult("鍔犺浇澶辫触"));
+			e.printStackTrace();
+		}
+	}
+
+	
+	/**
+	 * 鑾峰彇鍒嗕韩鍟嗗搧
+	 * @param acceptData
+	 * @param recordId
+	 * @param out
+	 */
+	@RequestMapping(value = "getrecordgoods", method = RequestMethod.POST)
+	public void getRecordGoods(AcceptData acceptData, Long recordId, PrintWriter out) {
+
+		if (recordId == null) {
+			out.print(JsonUtil.loadFalseResult("鍙傛暟涓嶆纭�"));
+		}
+
+		try {
+			JSONObject data = userShareGoodsGroupService.getGoodsGroup(recordId);
+			out.print(JsonUtil.loadTrueResult(data));
+		} catch (Exception e) {
+			out.print(JsonUtil.loadFalseResult("鍔犺浇澶辫触"));
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * 鑾峰彇鍒嗕韩鍟嗗搧鍗曚釜缁熻淇℃伅
+	 * @param acceptData
+	 * @param groupId
+	 * @param out
+	 */
+	@RequestMapping(value = "getgoodsdata", method = RequestMethod.POST)
+	public void getGoodsData(AcceptData acceptData, Long groupId, PrintWriter out) {
+
+		if (groupId == null) {
+			out.print(JsonUtil.loadFalseResult("鍙傛暟涓嶆纭�"));
+		}
+
+		try {
+			UserShareGoodsGroup userShareGoodsGroup = userShareGoodsGroupService.selectByPrimaryKey(groupId);
+			if (userShareGoodsGroup != null) {
+				userShareGoodsGroup.setBrowseTime(null);
+				userShareGoodsGroup.setCreateTime(null);
+				userShareGoodsGroup.setUpdateTime(null);
+				userShareGoodsGroup.setRecordId(null);
+			}
+			
+			JSONObject data = new JSONObject();
+			data.put("goodsData", userShareGoodsGroup);
+			out.print(JsonUtil.loadTrueResult(data));
+		} catch (Exception e) {
+			out.print(JsonUtil.loadFalseResult("鍔犺浇澶辫触"));
+			e.printStackTrace();
+		}
+	}
+	
 
 }

--
Gitblit v1.8.0