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/controller/client/v2/RedPackControllerV2.java |  218 +++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 159 insertions(+), 59 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RedPackControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RedPackControllerV2.java
index 3c46f78..d57ec05 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RedPackControllerV2.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RedPackControllerV2.java
@@ -2,8 +2,10 @@
 
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Type;
 import java.math.BigDecimal;
+import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
@@ -26,16 +28,20 @@
 import com.google.gson.stream.JsonReader;
 import com.google.gson.stream.JsonWriter;
 import com.yeshi.fanli.entity.accept.AcceptData;
-import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
+import com.yeshi.fanli.entity.bus.user.ThreeSale;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
-import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
+import com.yeshi.fanli.entity.common.AdminUser;
+import com.yeshi.fanli.entity.common.Config;
 import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
 import com.yeshi.fanli.entity.redpack.RedPackExchange;
 import com.yeshi.fanli.entity.redpack.RedPackWinInvite;
 import com.yeshi.fanli.entity.redpack.RedPackWinInvite.RedPackWinInviteTypeEnum;
+import com.yeshi.fanli.entity.system.ConfigKeyEnum;
 import com.yeshi.fanli.exception.redpack.RedPackExchangeException;
 import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException;
+import com.yeshi.fanli.service.AdminUserService;
 import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
+import com.yeshi.fanli.service.inter.config.ConfigService;
 import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
 import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
 import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
@@ -44,17 +50,21 @@
 import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
 import com.yeshi.fanli.service.inter.redpack.RedPackGiveRecordService;
 import com.yeshi.fanli.service.inter.redpack.RedPackWinInviteService;
-import com.yeshi.fanli.service.inter.redpack.RedPackWinNewUserService;
 import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
 import com.yeshi.fanli.service.inter.user.UserInfoService;
 import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
+import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
+import com.yeshi.fanli.util.AESUtil;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.ThreadUtil;
 import com.yeshi.fanli.util.TimeUtil;
 import com.yeshi.fanli.util.UserInviteUtil;
+import com.yeshi.fanli.util.email.MailSenderUtil;
 import com.yeshi.fanli.vo.redpack.RedPackDetailVO;
-import com.yeshi.fanli.vo.redpack.RedPackWinDetailVO;
+import com.yeshi.fanli.vo.redpack.RedPackGiveVO;
 import com.yeshi.fanli.vo.redpack.RedPackWinInviteVO;
+import com.yeshi.fanli.vo.redpack.RedPackWinProgressVO;
 
 import net.sf.json.JSONObject;
 
@@ -81,9 +91,6 @@
 	private RedPackWinInviteService redPackWinInviteService;
 
 	@Resource
-	private RedPackWinNewUserService redPackWinNewUserService;
-
-	@Resource
 	private UserInfoService userInfoService;
 
 	@Resource
@@ -94,12 +101,21 @@
 
 	@Resource
 	private SwiperPictureService swiperPictureService;
-	
+
 	@Resource
 	private UserSystemCouponService userSystemCouponService;
-	
+
 	@Resource
 	private RedPackForbidService redPackForbidService;
+
+	@Resource
+	private ThreeSaleSerivce threeSaleSerivce;
+	
+	@Resource
+	private ConfigService configService;
+	
+	@Resource
+	private AdminUserService adminUserService;
 
 	/**
 	 * 缁熻
@@ -124,7 +140,8 @@
 		BigDecimal yesterdayUse = zero;
 		BigDecimal thisMonthUse = zero;
 		BigDecimal lastMonthUse = zero;
-		BigDecimal balance = redPackBalanceService.getBalance(uid);;
+		BigDecimal balance = redPackBalanceService.getBalance(uid);
+		;
 		if (balance == null) {
 			balance = zero;
 		} else {
@@ -178,8 +195,9 @@
 		data.put("extractMax", redPackConfigService.getValueByKey("extract_money_max"));
 		data.put("extractBanlenMin", redPackConfigService.getValueByKey("extract_banlen_min"));
 		data.put("extractDesc", "娉細3涓伐浣滄棩鍐呭畬鎴愬鏍革紝绾㈠寘鎻愮幇鎴愬姛鍚庡皢浼氳繘鍏ュ埌浣欓銆�");
-
+		data.put("giveTotal", redPackGiveRecordService.countGiveList(uid));
 		data.put("useLink", redPackConfigService.getValueByKey("use_link"));
+		data.put("winLink", redPackConfigService.getValueByKey("invite_win_redpack_link"));
 
 		data.put("todayWin", todayWin.setScale(2).toString());
 		data.put("yesterdayWin", yesterdayWin.setScale(2).toString());
@@ -197,12 +215,9 @@
 	 * 
 	 * @param acceptData
 	 * @param uid
-	 * @param index
-	 *            List鏈�鏈殑涓婚敭ID
-	 * @param year
-	 *            骞翠唤
-	 * @param month
-	 *            鏈堜唤
+	 * @param index      List鏈�鏈殑涓婚敭ID
+	 * @param year       骞翠唤
+	 * @param month      鏈堜唤
 	 * @param out
 	 */
 	@RequestMapping(value = "getMoneyDetails")
@@ -299,6 +314,32 @@
 		}
 	}
 
+	@RequestMapping(value = "getGiveList", method = RequestMethod.POST)
+	public void getGiveList(AcceptData acceptData, Integer page, Long uid, PrintWriter out) {
+		if (uid == null || uid <= 0) {
+			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
+			return;
+		}
+
+		if (page == null || page <= 0)
+			page = 1;
+
+		try {
+			List<RedPackGiveVO> list = redPackGiveRecordService.getGiveList(page, Constant.PAGE_SIZE, uid);
+
+			GsonBuilder gsonBuilder = new GsonBuilder();
+			Gson gson = gsonBuilder.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy.MM.dd HH:mm").create();
+
+			JSONObject data = new JSONObject();
+			data.put("list", gson.toJson(list));
+			data.put("count", redPackGiveRecordService.countGiveList(uid));
+			out.print(JsonUtil.loadTrueResult(data));
+		} catch (Exception e) {
+			e.printStackTrace();
+			out.print(JsonUtil.loadFalseResult(1, "鏌ヨ澶辫触"));
+		}
+	}
+
 	/**
 	 * 杞崲绾㈠寘涓虹湡瀹為噾閽�
 	 * 
@@ -317,6 +358,35 @@
 		try {
 			redPackExchangeService.exchangeCash(uid, amount);
 			out.print(JsonUtil.loadTrueResult("鎻愮幇鐢宠鎴愬姛"));
+
+			ThreadUtil.run(new Runnable() {
+				@Override
+				public void run() {
+					JSONObject json = new JSONObject();
+					json.put("timeStamp", java.lang.System.currentTimeMillis());
+					json.put("adminId", 4L);
+					String sign = AESUtil.encrypt(json.toString(), Constant.ADMINH5_AESKEY);
+					String url = "";
+					try {
+						url = String.format("%s?from=emailh5&sign=%s",
+								Constant.systemCommonConfig.getExtractNotifyUrl(), URLEncoder.encode(sign, "UTF-8"));
+					} catch (UnsupportedEncodingException e) {
+						e.printStackTrace();
+					}
+
+					long[] targetUids = new long[] { 3L, 4L };
+					Config config = configService.getConfig(ConfigKeyEnum.extractCodeEmailFrom.getKey());
+					String[] sts = config.getValue().split(",");
+					String account = sts[0];
+					String pwd = sts[1];
+					for (long adminId : targetUids) {
+						AdminUser adminUser = adminUserService.selectByPrimaryKey(adminId);
+						String msg = "鏈夌敤鎴烽噰鐢ㄧ孩鍖呭厬鎹㈢幇閲�";
+						boolean isS = MailSenderUtil.sendEmail(adminUser.getEmail(), account, pwd, "绾㈠寘鍏戞崲鐜伴噾鎻愰啋", msg);
+					}
+				}
+			});
+
 		} catch (RedPackExchangeException e) {
 			out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
 		}
@@ -385,7 +455,7 @@
 	@RequestMapping(value = "getBasicInfo")
 	public void getBasicInfo(AcceptData acceptData, Long uid, String callback, PrintWriter out) {
 		if (uid == null || uid <= 0) {
-			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
 			return;
 		}
 
@@ -395,68 +465,98 @@
 		data.put("shareLink", UserInviteUtil.getShareUrl(uid));
 		data.put("redPackLock", redPackForbidService.verifyForbid(uid));
 
-		UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
-		if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
-			data.put("inviteCode", userInfoExtra.getInviteCode());
+		String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
+		if (!StringUtil.isNullOrEmpty(inviteCode)) {
+			data.put("inviteCode", inviteCode);
 		} else {
 			data.put("inviteCode", "");
 		}
-		
-		//
-	  long freeCouponCount=	userSystemCouponService.countUsableFreeCouponForBuy(uid);
-	  long 	rewardCouponCount=  userSystemCouponService.countUsableRewardCoupon(uid);
-	  
-	  data.put("freeCouponCount", freeCouponCount);
-	  data.put("rewardCouponCount", rewardCouponCount);
+
+		// 璧犻�佸厤鍗曞埜
+		long freeCouponCount = userSystemCouponService.countGiveFreeCoupon(uid);
+		// 濂栧姳鍒�
+		long rewardCouponCount = userSystemCouponService.countUsableRewardCoupon(uid);
+
+		data.put("freeCouponCount", freeCouponCount);
+		data.put("rewardCouponCount", rewardCouponCount);
 
 		if (!StringUtil.isNullOrEmpty(callback)) {
 			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
-		} else
+		} else {
 			out.print(JsonUtil.loadTrueResult(data));
+		}
 	}
 
 	/**
-	 * 鏂颁汉绾㈠寘璇︽儏
+	 *  璇ョ敤鎴烽個璇峰閲戞
 	 * 
 	 * @param acceptData
-	 * @param uid
+	 * @param uid  涓嬬嚎UID
 	 * @param out
 	 */
-	@RequestMapping(value = "getWinDetail", method = RequestMethod.POST)
-	public void getWinDetail(AcceptData acceptData, Long uid, PrintWriter out) {
+	@RequestMapping(value = "getInviteReward")
+	public void getInviteReward(AcceptData acceptData, Integer page, Long uid, String callback, PrintWriter out) {
 		if (uid == null || uid <= 0) {
-			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
 			return;
 		}
 
-		try {
-			RedPackWinDetailVO winDetail = redPackWinNewUserService.receiveReward(uid);
-			if (winDetail == null) {
-				out.print(JsonUtil.loadFalseResult(1, "绾㈠寘宸茶鎶㈠厜"));
-				return;
+		if (page == null || page < 1)
+			page = 1;
+
+		List<RedPackWinProgressVO> listVO = new ArrayList<RedPackWinProgressVO>();
+		List<RedPackWinInvite> list = redPackWinInviteService.getWinTopListByBossId(page, Constant.PAGE_SIZE, uid);
+		if (list != null) {
+			for (RedPackWinInvite win : list) {
+				ThreeSale threeSale = threeSaleSerivce.getNearRelationByBossIdAndWorkerId(uid, win.getTeamUid());
+				if (threeSale == null)
+					continue;
+
+				UserInfo userInfo = userInfoService.selectByPKey(win.getTeamUid());
+				if (userInfo == null)
+					continue;
+
+				RedPackWinProgressVO progressVO = new RedPackWinProgressVO();
+				progressVO.setUid(userInfo.getId());
+				progressVO.setName(userInfo.getNickName());
+				progressVO.setPortrait(userInfo.getPortrait());
+				progressVO.setMoney(win.getMoney().setScale(2).toString());
+				progressVO.setTime("閭�璇凤細" + TimeUtil.formatDate(threeSale.getSucceedTime()));
+				listVO.add(progressVO);
 			}
-			winDetail.setLogo(Constant.systemCommonConfig.getDefaultPortrait());
-			winDetail.setLogoLight(Constant.systemCommonConfig.getDefaultPortrait());
+		}
 
-			JSONObject params = new JSONObject();
-			params.put("url", redPackConfigService.getValueByKey("goods_shop_link_h5"));
-			winDetail.setParams(params.toString());
-			winDetail.setJumpDetail(jumpDetailV2Service.getByTypeCache("web",
-					Constant.getPlatformCode(acceptData.getPlatform()), Integer.parseInt(acceptData.getVersion())));
-			winDetail.setTips(redPackConfigService.getValueByKey("new_user_win_tips"));
-
-			// 2銆侀《閮ㄨ疆鎾浘
-			List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("redpack_win_detail_banner");
-			List<SwiperPicture> topPicList = new ArrayList<>();
-			if (oldtopPicList != null && oldtopPicList.size() > 0)
-				topPicList.addAll(oldtopPicList);
-
-			JSONObject data = new JSONObject();
-			data.put("detail", JsonUtil.getApiCommonGson().toJson(winDetail));
-			data.put("banner", JsonUtil.getApiCommonGson().toJson(topPicList));
+		JSONObject data = new JSONObject();
+		data.put("list", listVO);
+		data.put("count", redPackWinInviteService.countWinTopListByBossId(uid));
+		if (!StringUtil.isNullOrEmpty(callback)) {
+			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
+		} else {
 			out.print(JsonUtil.loadTrueResult(data));
-		} catch (Exception e) {
-			out.print(JsonUtil.loadFalseResult(1, "绾㈠寘宸茶鎶㈠厜鍟�"));
+		}
+	}
+
+	/**
+	 *  璇ョ敤鎴烽個璇疯繘搴�
+	 * 
+	 * @param acceptData
+	 * @param tid  涓嬬嚎UID
+	 * @param out
+	 */
+	@RequestMapping(value = "getInviteProgress")
+	public void getInviteProgress(AcceptData acceptData, Long uid, Long tid, String callback, PrintWriter out) {
+		if (uid == null || uid <= 0 || tid == null || tid <= 0) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "浼犻�掑弬鏁扮己澶�"));
+			return;
+		}
+
+		JSONObject data = new JSONObject();
+		data.put("list", redPackWinInviteService.getInviteProgressByWorkerId(uid, tid));
+		data.put("num", redPackWinInviteService.countTeamNumByTid(uid, tid));
+		if (!StringUtil.isNullOrEmpty(callback)) {
+			out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
+		} else {
+			out.print(JsonUtil.loadTrueResult(data));
 		}
 	}
 }

--
Gitblit v1.8.0