From b6c37e4bc38db88a360d0f2c6099183f9bb75bdc Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期一, 22 四月 2019 14:31:59 +0800
Subject: [PATCH] 券推送插入

---
 fanli/src/main/java/com/yeshi/fanli/util/factory/UserMoneyDetailFactory.java |   81 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 76 insertions(+), 5 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/factory/UserMoneyDetailFactory.java b/fanli/src/main/java/com/yeshi/fanli/util/factory/UserMoneyDetailFactory.java
index f55bda5..fa88b3b 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/factory/UserMoneyDetailFactory.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/factory/UserMoneyDetailFactory.java
@@ -4,9 +4,9 @@
 import java.util.Calendar;
 import java.util.Date;
 
+import com.yeshi.fanli.dto.HongBao;
 import com.yeshi.fanli.entity.bus.user.AlipayAccountValidNormalHistory;
 import com.yeshi.fanli.entity.bus.user.Extract;
-import com.yeshi.fanli.entity.bus.user.HongBao;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
 import com.yeshi.fanli.entity.money.UserMoneyDetail;
 import com.yeshi.fanli.entity.money.UserMoneyDetail.UserMoneyDetailTypeEnum;
@@ -23,10 +23,12 @@
 	 * @param hongBaoList
 	 * @return
 	 */
-	public static UserMoneyDetail createFanLi(Long uid, String orderId, BigDecimal money)
+	public static UserMoneyDetail createFanLi(Long uid, String orderId, int orderType, String hbIds, BigDecimal money)
 			throws UserMoneyDetailException {
+
 		if (StringUtil.isNullOrEmpty(orderId))
 			throw new UserMoneyDetailException(1, "璁㈠崟鍙蜂负绌�");
+
 		if (money == null)
 			throw new UserMoneyDetailException(1, "杩斿埄閲戦涓虹┖");
 
@@ -35,7 +37,8 @@
 
 		UserMoneyDetail detail = new UserMoneyDetail();
 		detail.setCreateTime(new Date());
-		detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.fanli.name() + ":" + orderId));
+		detail.setIdentifyCode(StringUtil
+				.Md5(UserMoneyDetailTypeEnum.fanli.name() + "-" + uid + "-" + orderType + "-" + orderId + "-" + hbIds));
 		detail.setMoney(money);
 		detail.setTitle(UserMoneyDetailTypeEnum.fanli.getDesc());
 		detail.setType(UserMoneyDetailTypeEnum.fanli);
@@ -121,11 +124,13 @@
 		detail.setMoney(money);
 		detail.setTitle(timeF + UserMoneyDetailTypeEnum.invite.getDesc());
 		detail.setType(UserMoneyDetailTypeEnum.invite);
-		detail.setDescInfo(String.format("鏈夋晥璁㈠崟:%s绗�  缁存潈璁㈠崟:%s绗�  澶辨晥璁㈠崟:%s绗�", validCount, weiQuanCount, invalidCount));
+		if (validCount != 0 || weiQuanCount != 0 || invalidCount != 0)
+			detail.setDescInfo(String.format("鏈夋晥璁㈠崟:%s绗�   缁存潈璁㈠崟:%s绗�   澶辨晥璁㈠崟:%s绗�", validCount, weiQuanCount, invalidCount));
 		detail.setUpdateTime(new Date());
 		detail.setUserInfo(new UserInfo(uid));
 		return detail;
 	}
+
 
 	/**
 	 * 杩斿埄缁存潈
@@ -323,6 +328,7 @@
 		detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.extractReject.name() + ":" + extract.getId()));
 		detail.setMoney(extract.getMoney());
 		detail.setSourceIdentifyId(extract.getId());
+		detail.setSubTitle("鍘熻矾閫�鍥�");
 		detail.setTitle(UserMoneyDetailTypeEnum.extractReject.getDesc());
 		detail.setType(UserMoneyDetailTypeEnum.extractReject);
 		detail.setUpdateTime(new Date());
@@ -346,12 +352,33 @@
 
 		UserMoneyDetail detail = new UserMoneyDetail();
 		detail.setCreateTime(new Date());
-		detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.hongbao.name() + ":" + hb.getId()));
+		detail.setIdentifyCode(
+				StringUtil.Md5(UserMoneyDetailTypeEnum.hongbao.name() + "-" + subTitle + "-" + hb.getId()));
 		detail.setMoney(hb.getMoney());
 		detail.setSourceIdentifyId(hb.getId());
 		detail.setTitle(UserMoneyDetailTypeEnum.hongbao.getDesc());
 		detail.setSubTitle(subTitle);
 		detail.setType(UserMoneyDetailTypeEnum.hongbao);
+		detail.setUpdateTime(new Date());
+		detail.setUserInfo(hb.getUserInfo());
+		return detail;
+	}
+
+	private static UserMoneyDetail createHongBaoDeduct(HongBao hb, String subTitle) throws UserMoneyDetailException {
+		if (hb == null)
+			throw new UserMoneyDetailException(1, "绾㈠寘涓嶈兘涓虹┖");
+		if (hb.getUserInfo() == null)
+			throw new UserMoneyDetailException(1, "鐢ㄦ埛涓嶈兘涓虹┖");
+
+		UserMoneyDetail detail = new UserMoneyDetail();
+		detail.setCreateTime(new Date());
+		detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.hongbaoDeduct.name() + "-" + subTitle + "-"
+				+ hb.getBeizhu() + "-" + hb.getId()));
+		detail.setMoney(hb.getMoney());
+		detail.setSourceIdentifyId(hb.getId());
+		detail.setTitle(UserMoneyDetailTypeEnum.hongbaoDeduct.getDesc());
+		detail.setSubTitle(subTitle);
+		detail.setType(UserMoneyDetailTypeEnum.hongbaoDeduct);
 		detail.setUpdateTime(new Date());
 		detail.setUserInfo(hb.getUserInfo());
 		return detail;
@@ -368,4 +395,48 @@
 		return createHongBao(hb, "鏂颁汉绾㈠寘");
 	}
 
+	/**
+	 * 鏂颁汉绾㈠寘鎵i櫎
+	 * 
+	 * @param hb
+	 * @return
+	 * @throws UserMoneyDetailException
+	 */
+
+	public static UserMoneyDetail createNewerHongBaoDeduct(HongBao hb) throws UserMoneyDetailException {
+		return createHongBaoDeduct(hb, "鏂颁汉绾㈠寘鎵i櫎");
+	}
+
+
+
+	/**
+	 * 杩斿埄濂栧姳
+	 * 
+	 * @param orderId
+	 * @param money
+	 * @param user
+	 * @return
+	 * @throws UserMoneyDetailException
+	 */
+	public static UserMoneyDetail createOrderReward(String orderId, BigDecimal money, UserInfo user)
+			throws UserMoneyDetailException {
+		if (StringUtil.isNullOrEmpty(orderId))
+			throw new UserMoneyDetailException(1, "璁㈠崟鍙蜂笉鑳戒负绌�");
+		if (user == null)
+			throw new UserMoneyDetailException(1, "UID涓嶈兘涓虹┖");
+		if (money == null)
+			throw new UserMoneyDetailException(1, "閲戦涓嶈兘涓虹┖");
+
+		UserMoneyDetail detail = new UserMoneyDetail();
+		detail.setCreateTime(new Date());
+		detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.hongbao.name() + "-" + "鑰佺増鏈�" + "-" + orderId));
+		detail.setMoney(money);
+		detail.setTitle(UserMoneyDetailTypeEnum.orderReward.getDesc());
+		detail.setType(UserMoneyDetailTypeEnum.orderReward);
+		detail.setUpdateTime(new Date());
+		detail.setUserInfo(user);
+//		detail.setDescInfo("璁㈠崟鍙�:" + orderId);
+		return detail;
+	}
+
 }

--
Gitblit v1.8.0