From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 25 二月 2025 16:41:22 +0800
Subject: [PATCH] 淘宝转链接口更新

---
 fanli/src/main/java/com/yeshi/fanli/util/factory/UserMoneyDetailFactory.java | 1474 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 748 insertions(+), 726 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 50ee543..572cf90 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
@@ -1,726 +1,748 @@
-package com.yeshi.fanli.util.factory;
-
-import java.math.BigDecimal;
-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.UserInfo;
-import com.yeshi.fanli.entity.money.UserMoneyDetail;
-import com.yeshi.fanli.entity.money.UserMoneyDetail.UserMoneyDetailTypeEnum;
-import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanDrawBack;
-import com.yeshi.fanli.exception.money.UserMoneyDetailException;
-import com.yeshi.fanli.util.Constant;
-import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.TimeUtil;
-import com.yeshi.fanli.util.account.UserUtil;
-
-public class UserMoneyDetailFactory {
-
-	/**
-	 * 杩斿埄璧勯噾璁板綍
-	 * 
-	 * @param hongBaoList
-	 * @return
-	 */
-	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, "杩斿埄閲戦涓虹┖");
-
-		if (uid == null)
-			throw new UserMoneyDetailException(1, "UID涓虹┖");
-
-		UserMoneyDetail detail = new UserMoneyDetail();
-		detail.setCreateTime(new Date());
-		detail.setIdentifyCode(StringUtil
-				.Md5(UserMoneyDetailTypeEnum.fanli.name() + "-" + uid + "-" + orderType + "-" + orderId + "-" + hbIds));
-		detail.setMoney(money);
-		detail.setTitle(UserMoneyDetailTypeEnum.fanliNew.getDesc());
-		detail.setType(UserMoneyDetailTypeEnum.fanliNew);
-		detail.setDescInfo(Constant.getSourceName(orderType) + "锛�" + orderId);
-		detail.setUpdateTime(new Date());
-		detail.setUserInfo(new UserInfo(uid));
-		detail.setOrderType(orderType);
-		return detail;
-	}
-
-	/**
-	 * 楗夸簡涔堣繑鍒�
-	 * 
-	 * @param uid
-	 * @param orderId
-	 * @param hbId
-	 * @param money
-	 * @return
-	 * @throws UserMoneyDetailException
-	 */
-	public static UserMoneyDetail createElmeFanLi(Long uid, String orderId, Long hbId, BigDecimal money)
-			throws UserMoneyDetailException {
-
-		if (StringUtil.isNullOrEmpty(orderId))
-			throw new UserMoneyDetailException(1, "璁㈠崟鍙蜂负绌�");
-
-		if (money == null)
-			throw new UserMoneyDetailException(1, "杩斿埄閲戦涓虹┖");
-
-		if (uid == null)
-			throw new UserMoneyDetailException(1, "UID涓虹┖");
-
-		UserMoneyDetail detail = new UserMoneyDetail();
-		detail.setCreateTime(new Date());
-		detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.elmeFanli.name() + "-" + hbId));
-		detail.setMoney(money);
-		detail.setTitle(UserMoneyDetailTypeEnum.elmeFanli.getDesc());
-		detail.setType(UserMoneyDetailTypeEnum.elmeFanli);
-		detail.setDescInfo("璁㈠崟鍙凤細" + orderId);
-		detail.setUpdateTime(new Date());
-		detail.setUserInfo(new UserInfo(uid));
-		detail.setOrderType(Constant.SOURCE_TYPE_ELME);
-		return detail;
-	}
-
-	/**
-	 * 鍒嗕韩濂栭噾鍒拌处
-	 * 
-	 * @param uid
-	 * @param validCount
-	 * @param weiQuanCount
-	 * @param invalidCount
-	 * @param money
-	 * @param time
-	 * @return
-	 * @throws UserMoneyDetailException
-	 */
-	public static UserMoneyDetail createShare(Long uid, int orderType, BigDecimal money, Date time)
-			throws UserMoneyDetailException {
-		if (money == null)
-			throw new UserMoneyDetailException(1, "杩斿埄閲戦涓虹┖");
-
-		if (uid == null)
-			throw new UserMoneyDetailException(1, "UID涓虹┖");
-
-		if (time == null)
-			throw new UserMoneyDetailException(1, "鍙戠敓鏃堕棿涓虹┖");
-
-		Calendar ca = Calendar.getInstance();
-		ca.setTime(time);
-		ca.add(Calendar.MONTH, -1);
-
-		String timeF = TimeUtil.getGernalTime(ca.getTimeInMillis(), "yyyy骞碝鏈�");
-
-		UserMoneyDetail detail = new UserMoneyDetail();
-		detail.setCreateTime(new Date());
-		detail.setIdentifyCode(
-				StringUtil.Md5(UserMoneyDetailTypeEnum.share.name() + "-" + orderType + "-" + uid + "-" + timeF));
-		detail.setMoney(money);
-		detail.setTitle(UserMoneyDetailTypeEnum.shareNew.getDesc());
-		detail.setType(UserMoneyDetailTypeEnum.shareNew);
-		detail.setDescInfo(Constant.getSourceName(orderType) + "锛�" + timeF);
-		detail.setUpdateTime(new Date());
-		detail.setUserInfo(new UserInfo(uid));
-		detail.setOrderType(orderType);
-		return detail;
-	}
-
-	/**
-	 * 閭�璇峰閲戝埌璐�
-	 * 
-	 * @param uid
-	 * @param validCount
-	 * @param weiQuanCount
-	 * @param invalidCount
-	 * @param money
-	 * @param time
-	 * @return
-	 * @throws UserMoneyDetailException
-	 */
-	public static UserMoneyDetail createInvite(Long uid, int orderType, int validCount, int weiQuanCount,
-			BigDecimal money, Date time) throws UserMoneyDetailException {
-		if (money == null)
-			throw new UserMoneyDetailException(1, "杩斿埄閲戦涓虹┖");
-
-		if (uid == null)
-			throw new UserMoneyDetailException(1, "UID涓虹┖");
-
-		if (time == null)
-			throw new UserMoneyDetailException(1, "鍙戠敓鏃堕棿涓虹┖");
-
-		Calendar ca = Calendar.getInstance();
-		ca.setTime(time);
-		ca.add(Calendar.MONTH, -1);
-
-		String timeF = TimeUtil.getGernalTime(ca.getTimeInMillis(), "yyyy.M");
-
-		UserMoneyDetail detail = new UserMoneyDetail();
-		detail.setCreateTime(new Date());
-		detail.setIdentifyCode(
-				StringUtil.Md5(UserMoneyDetailTypeEnum.invite.name() + "-" + orderType + "-" + uid + "-" + timeF));
-		detail.setMoney(money);
-		detail.setTitle(timeF + UserMoneyDetailTypeEnum.invite.getDesc());
-		detail.setType(UserMoneyDetailTypeEnum.invite);
-		if (validCount != 0 || weiQuanCount != 0)
-			detail.setDescInfo(String.format("鏈夋晥璁㈠崟:%s绗�   缁存潈璁㈠崟:%s绗�", validCount, weiQuanCount));
-		detail.setUpdateTime(new Date());
-		detail.setUserInfo(new UserInfo(uid));
-		detail.setOrderType(orderType);
-		return detail;
-	}
-
-	/**
-	 * 杩斿埄缁存潈
-	 * 
-	 * @param uid
-	 * @param drawBack
-	 * @param money
-	 * @return
-	 * @throws UserMoneyDetailException
-	 */
-	public static UserMoneyDetail createFanLiWeiQuan(Long uid, TaoBaoWeiQuanDrawBack drawBack, BigDecimal money)
-			throws UserMoneyDetailException {
-		if (drawBack == null)
-			throw new UserMoneyDetailException(1, "閫�娆句负绌�");
-		if (drawBack.getId() == null)
-			throw new UserMoneyDetailException(1, "閫�娆綢D涓虹┖");
-		if (StringUtil.isNullOrEmpty(drawBack.getOrderId()))
-			throw new UserMoneyDetailException(1, "璁㈠崟鍙蜂负绌�");
-		if (StringUtil.isNullOrEmpty(drawBack.getOrderItemId()))
-			throw new UserMoneyDetailException(1, "瀛愯鍗曞彿涓虹┖");
-		if (money == null)
-			throw new UserMoneyDetailException(1, "閫�娆鹃噾棰濅负绌�");
-		if (uid == null)
-			throw new UserMoneyDetailException(1, "UID涓虹┖");
-
-		UserMoneyDetail detail = new UserMoneyDetail();
-		detail.setCreateTime(new Date());
-		detail.setIdentifyCode(StringUtil
-				.Md5(UserMoneyDetailTypeEnum.fanliWeiQuan.name() + "-" + uid + "-" + drawBack.getOrderItemId()));
-		detail.setMoney(new BigDecimal("0").subtract(money));
-		detail.setTitle(UserMoneyDetailTypeEnum.fanliWeiQuanNew.getDesc());
-		detail.setType(UserMoneyDetailTypeEnum.fanliWeiQuanNew);
-		detail.setSourceIdentifyId(drawBack.getId());
-		detail.setDescInfo(
-				Constant.getSourceName(Constant.SOURCE_TYPE_TAOBAO) + "锛�" + drawBack.getOrderId() + "-閮ㄥ垎鍟嗗搧鍞悗");
-		detail.setUpdateTime(new Date());
-		detail.setUserInfo(new UserInfo(uid));
-		detail.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
-		return detail;
-	}
-
-	/**
-	 * 鍒嗕韩璧氱淮鏉�
-	 * 
-	 * @param uid
-	 * @param drawBack
-	 * @param money
-	 * @return
-	 * @throws UserMoneyDetailException
-	 */
-	public static UserMoneyDetail createShareWeiQuan(Long uid, TaoBaoWeiQuanDrawBack drawBack, BigDecimal money)
-			throws UserMoneyDetailException {
-		if (drawBack == null)
-			throw new UserMoneyDetailException(1, "閫�娆句负绌�");
-		if (drawBack.getId() == null)
-			throw new UserMoneyDetailException(1, "閫�娆綢D涓虹┖");
-		if (StringUtil.isNullOrEmpty(drawBack.getOrderId()))
-			throw new UserMoneyDetailException(1, "璁㈠崟鍙蜂负绌�");
-		if (StringUtil.isNullOrEmpty(drawBack.getOrderItemId()))
-			throw new UserMoneyDetailException(1, "瀛愯鍗曞彿涓虹┖");
-		if (money == null)
-			throw new UserMoneyDetailException(1, "閫�娆鹃噾棰濅负绌�");
-		if (uid == null)
-			throw new UserMoneyDetailException(1, "UID涓虹┖");
-
-		UserMoneyDetail detail = new UserMoneyDetail();
-		detail.setCreateTime(new Date());
-		detail.setIdentifyCode(StringUtil
-				.Md5(UserMoneyDetailTypeEnum.shareWeiQuan.name() + "-" + uid + "-" + drawBack.getOrderItemId()));
-		detail.setMoney(new BigDecimal("0").subtract(money));
-		detail.setTitle(UserMoneyDetailTypeEnum.shareWeiQuan.getDesc());
-		detail.setSubTitle("璁㈠崟鍞悗");
-		detail.setType(UserMoneyDetailTypeEnum.shareWeiQuan);
-		detail.setSourceIdentifyId(drawBack.getId());
-		detail.setDescInfo("璁㈠崟鍙凤細" + drawBack.getOrderId());
-		detail.setUpdateTime(new Date());
-		detail.setUserInfo(new UserInfo(uid));
-		detail.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
-		return detail;
-	}
-
-	/**
-	 * 閭�璇疯禋缁存潈
-	 * 
-	 * @param uid
-	 * @param drawBack
-	 * @param money
-	 * @return
-	 * @throws UserMoneyDetailException
-	 */
-	public static UserMoneyDetail createInviteWeiQuan(Long uid, TaoBaoWeiQuanDrawBack drawBack, BigDecimal money)
-			throws UserMoneyDetailException {
-		if (drawBack == null)
-			throw new UserMoneyDetailException(1, "閫�娆句负绌�");
-		if (drawBack.getId() == null)
-			throw new UserMoneyDetailException(1, "閫�娆綢D涓虹┖");
-		if (StringUtil.isNullOrEmpty(drawBack.getOrderId()))
-			throw new UserMoneyDetailException(1, "璁㈠崟鍙蜂负绌�");
-		if (StringUtil.isNullOrEmpty(drawBack.getOrderItemId()))
-			throw new UserMoneyDetailException(1, "瀛愯鍗曞彿涓虹┖");
-		if (money == null)
-			throw new UserMoneyDetailException(1, "閫�娆鹃噾棰濅负绌�");
-		if (uid == null)
-			throw new UserMoneyDetailException(1, "UID涓虹┖");
-
-		UserMoneyDetail detail = new UserMoneyDetail();
-		detail.setCreateTime(new Date());
-		detail.setIdentifyCode(StringUtil
-				.Md5(UserMoneyDetailTypeEnum.inviteWeiQuan.name() + "-" + uid + "-" + drawBack.getOrderItemId()));
-		detail.setMoney(new BigDecimal("0").subtract(money));
-		detail.setTitle(UserMoneyDetailTypeEnum.inviteWeiQuan.getDesc());
-		detail.setSubTitle("璁㈠崟鍞悗");
-		detail.setType(UserMoneyDetailTypeEnum.inviteWeiQuan);
-		detail.setSourceIdentifyId(drawBack.getId());
-		detail.setDescInfo("璁㈠崟鍙凤細" + UserUtil.filterOrderId(drawBack.getOrderId()));
-		detail.setUpdateTime(new Date());
-		detail.setUserInfo(new UserInfo(uid));
-		detail.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
-		return detail;
-	}
-
-	/**
-	 * 鎻愮幇璧勯噾璁板綍
-	 * 
-	 * @param extract
-	 * @return
-	 */
-	public static UserMoneyDetail createExtract(Extract extract, String alipayNo) throws UserMoneyDetailException {
-		if (extract == null)
-			throw new UserMoneyDetailException(1, "鎻愮幇璁板綍涓嶈兘涓虹┖");
-		if (extract.getId() == null)
-			throw new UserMoneyDetailException(1, "鎻愮幇璁板綍涓婚敭涓嶈兘涓虹┖");
-		if (extract.getMoney() == null)
-			throw new UserMoneyDetailException(1, "鎻愮幇閲戦涓嶈兘涓虹┖");
-		if (extract.getUserInfo() == null || extract.getUserInfo().getId() == null)
-			throw new UserMoneyDetailException(1, "鎻愮幇鐢ㄦ埛涓嶈兘涓虹┖");
-
-		if (alipayNo != null && alipayNo.length() > 10)
-			alipayNo = "*" + alipayNo.substring(alipayNo.length() - 10, alipayNo.length());
-
-		UserMoneyDetail detail = new UserMoneyDetail();
-		detail.setCreateTime(new Date());
-		detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.extract.name() + ":" + extract.getId()));
-		detail.setMoney(new BigDecimal("0").subtract(extract.getMoney()));
-		detail.setSourceIdentifyId(extract.getId());
-		detail.setTitle(UserMoneyDetailTypeEnum.extractNew.getDesc());
-		detail.setType(UserMoneyDetailTypeEnum.extractNew);
-		detail.setUpdateTime(new Date());
-		detail.setDescInfo("鏀粯瀹濊鍗曞彿锛�" + alipayNo);
-		detail.setUserInfo(extract.getUserInfo());
-		detail.setShow(false);
-		return detail;
-	}
-
-	/**
-	 * 鎻愮幇璐﹀彿楠岃瘉璁板綍
-	 * 
-	 * @param aa
-	 * @param money
-	 * @return
-	 * @throws UserMoneyDetailException
-	 */
-	public static UserMoneyDetail createExtractAccountValid(AlipayAccountValidNormalHistory aa, BigDecimal money)
-			throws UserMoneyDetailException {
-		if (aa == null)
-			throw new UserMoneyDetailException(1, "楠岃瘉璁板綍涓嶈兘涓虹┖");
-		if (aa.getUid() == 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.extractVerify.name() + ":" + aa.getId()));
-		detail.setMoney(new BigDecimal("0").subtract(money));
-		detail.setSourceIdentifyId(aa.getId());
-		detail.setTitle(UserMoneyDetailTypeEnum.extractVerifyNew.getDesc());
-		detail.setType(UserMoneyDetailTypeEnum.extractVerifyNew);
-		detail.setUpdateTime(new Date());
-		detail.setUserInfo(new UserInfo(aa.getUid()));
-		detail.setDescInfo(String.format("鏀粯瀹濓細%s -濮撳悕-%s", UserUtil.filterAlipayAccount(aa.getAccount()),
-				UserUtil.filterAlipayName(aa.getName())));
-		return detail;
-	}
-
-	/**
-	 * 绯荤粺鎵i櫎
-	 * @Title: createSystemTakeOff
-	 * @Description: 
-	 * @param uid
-	 * @param money
-	 * @param desc
-	 * @return
-	 * @throws UserMoneyDetailException 
-	 * UserMoneyDetail 杩斿洖绫诲瀷
-	 * @throws
-	 */
-	public static UserMoneyDetail createSystemTakeOff(Long uid, BigDecimal money, String desc)
-			throws UserMoneyDetailException {
-		if (uid == 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(uid + "-" + UserMoneyDetailTypeEnum.systemTakeOff.name() + System.currentTimeMillis()));
-		detail.setMoney(new BigDecimal("0").subtract(money));
-		detail.setTitle(UserMoneyDetailTypeEnum.systemTakeOff.getDesc());
-		detail.setType(UserMoneyDetailTypeEnum.systemTakeOff);
-		detail.setUpdateTime(new Date());
-		detail.setUserInfo(new UserInfo(uid));
-		detail.setDescInfo(desc);
-		return detail;
-	}
-
-	/**
-	 * 鎻愮幇鎷掔粷
-	 * 
-	 * @param extract
-	 * @return
-	 * @throws UserMoneyDetailException
-	 */
-	public static UserMoneyDetail createExtractReject(Extract extract) throws UserMoneyDetailException {
-		if (extract == null)
-			throw new UserMoneyDetailException(1, "鎻愮幇璁板綍涓嶈兘涓虹┖");
-		if (extract.getId() == null)
-			throw new UserMoneyDetailException(1, "鎻愮幇璁板綍涓婚敭涓嶈兘涓虹┖");
-		if (extract.getMoney() == null)
-			throw new UserMoneyDetailException(1, "鎻愮幇閲戦涓嶈兘涓虹┖");
-		if (extract.getUserInfo() == null || extract.getUserInfo().getId() == null)
-			throw new UserMoneyDetailException(1, "鎻愮幇鐢ㄦ埛涓嶈兘涓虹┖");
-
-		UserMoneyDetail detail = new UserMoneyDetail();
-		detail.setCreateTime(new Date());
-		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());
-		detail.setUserInfo(extract.getUserInfo());
-		detail.setShow(false);// 闅愯棌鎻愮幇澶辫触璁板綍
-		return detail;
-	}
-
-	/**
-	 * 绯荤粺绾㈠寘
-	 * 
-	 * @param hb
-	 * @return
-	 * @throws UserMoneyDetailException
-	 */
-
-	private static UserMoneyDetail createHongBao(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.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;
-	}
-
-	/**
-	 * 鏂颁汉绾㈠寘
-	 * 
-	 * @param hb
-	 * @return
-	 * @throws UserMoneyDetailException
-	 */
-	public static UserMoneyDetail createNewerHongBao(HongBao hb) throws UserMoneyDetailException {
-		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, int orderType, BigDecimal money,
-			BigDecimal originalMoney, 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.orderRewardNew.getDesc());
-		detail.setType(UserMoneyDetailTypeEnum.orderRewardNew);
-		detail.setUpdateTime(new Date());
-		detail.setUserInfo(user);
-		detail.setOrderType(orderType);
-		detail.setDescInfo(Constant.getSourceName(orderType) + ":" + orderId + "-鍘熻繑鍒╋細" + originalMoney);
-		return detail;
-	}
-
-	/**
-	 * 璁㈠崟閲嶅缁熻閫�娆�
-	 * 
-	 * @param orderId
-	 * @param money
-	 * @param user
-	 * @return
-	 * @throws UserMoneyDetailException
-	 */
-	public static UserMoneyDetail createRepeatStatistic(String orderId, int orderType, 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.repeatStatistic.name() + "-" + orderId + "-" + user.getId()));
-		detail.setMoney(money);
-		detail.setTitle(UserMoneyDetailTypeEnum.repeatStatistic.getDesc());
-		detail.setType(UserMoneyDetailTypeEnum.repeatStatistic);
-		detail.setUpdateTime(new Date());
-		detail.setUserInfo(user);
-		detail.setDescInfo("璁㈠崟鍙�:" + orderId);
-		detail.setOrderType(orderType);
-		return detail;
-	}
-
-	public static UserMoneyDetail createSystemEqualize(String desc, BigDecimal money, UserInfo user)
-			throws UserMoneyDetailException {
-		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.systemEqualize.name() + "-" + System.currentTimeMillis() + "-" + user.getId()));
-		detail.setMoney(money);
-		detail.setTitle(UserMoneyDetailTypeEnum.systemEqualizeNew.getDesc());
-		detail.setType(UserMoneyDetailTypeEnum.systemEqualizeNew);
-		detail.setUpdateTime(new Date());
-		detail.setUserInfo(user);
-		if (!StringUtil.isNullOrEmpty(desc)) {
-			detail.setDescInfo(desc);
-		}
-		return detail;
-	}
-
-	public static UserMoneyDetail createScoreConvert(BigDecimal money, UserInfo user) throws UserMoneyDetailException {
-		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.scoreConvert.name() + "-" + System.currentTimeMillis() + "-" + user.getId()));
-		detail.setMoney(money);
-		detail.setTitle(UserMoneyDetailTypeEnum.scoreConvert.getDesc());
-		detail.setType(UserMoneyDetailTypeEnum.scoreConvert);
-		detail.setUpdateTime(new Date());
-		detail.setUserInfo(user);
-
-		return detail;
-	}
-
-	/**
-	 * 閭�璇峰閲戝埌璐�
-	 * 
-	 * @param uid
-	 * @param validCount
-	 * @param weiQuanCount
-	 * @param invalidCount
-	 * @param money
-	 * @param time
-	 * @return
-	 * @throws UserMoneyDetailException
-	 */
-	public static UserMoneyDetail createInviteSubsidy(Long uid, int orderType, BigDecimal money, Date time)
-			throws UserMoneyDetailException {
-		if (money == null)
-			throw new UserMoneyDetailException(1, "杩斿埄閲戦涓虹┖");
-
-		if (uid == null)
-			throw new UserMoneyDetailException(1, "UID涓虹┖");
-
-		if (time == null)
-			throw new UserMoneyDetailException(1, "鍙戠敓鏃堕棿涓虹┖");
-
-		Calendar ca = Calendar.getInstance();
-		ca.setTime(time);
-		ca.add(Calendar.MONTH, -1);
-
-		String timeF = TimeUtil.getGernalTime(ca.getTimeInMillis(), "yyyy.M");
-
-		UserMoneyDetail detail = new UserMoneyDetail();
-		detail.setCreateTime(new Date());
-		detail.setIdentifyCode(
-				StringUtil.Md5(UserMoneyDetailTypeEnum.subsidy.name() + "-" + orderType + "-" + uid + "-" + timeF));
-		detail.setMoney(money);
-		detail.setTitle(
-				timeF + UserMoneyDetailTypeEnum.subsidy.getDesc() + "銆�" + Constant.getSourceName(orderType) + "銆�");
-		detail.setType(UserMoneyDetailTypeEnum.subsidy);
-		detail.setDescInfo("閭�璇疯鍗曡ˉ璐�");
-		detail.setUpdateTime(new Date());
-		detail.setUserInfo(new UserInfo(uid));
-		detail.setOrderType(orderType);
-		return detail;
-	}
-
-	/**
-	 * 鍥㈤槦鏀剁泭
-	 * @Title: createTeamReward
-	 * @Description: 
-	 * @param uid
-	 * @param money
-	 * @param time
-	 * @return
-	 * @throws UserMoneyDetailException 
-	 * UserMoneyDetail 杩斿洖绫诲瀷
-	 * @throws
-	 */
-
-	public static UserMoneyDetail createTeamReward(Long uid, BigDecimal money, Date time)
-			throws UserMoneyDetailException {
-		if (money == null)
-			throw new UserMoneyDetailException(1, "杩斿埄閲戦涓虹┖");
-
-		if (uid == null)
-			throw new UserMoneyDetailException(1, "UID涓虹┖");
-
-		if (time == null)
-			throw new UserMoneyDetailException(1, "鍙戠敓鏃堕棿涓虹┖");
-
-		Calendar ca = Calendar.getInstance();
-		ca.setTime(time);
-		ca.add(Calendar.MONTH, -1);
-
-		String timeF = TimeUtil.getGernalTime(ca.getTimeInMillis(), "yyyy骞碝鏈�");
-
-		UserMoneyDetail detail = new UserMoneyDetail();
-		detail.setCreateTime(new Date());
-		detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.teamReward.name() + "-" + uid + "-" + timeF));
-		detail.setMoney(money);
-		detail.setTitle(UserMoneyDetailTypeEnum.teamReward.getDesc());
-		detail.setType(UserMoneyDetailTypeEnum.teamReward);
-		detail.setDescInfo(timeF);
-		detail.setUpdateTime(new Date());
-		detail.setUserInfo(new UserInfo(uid));
-		return detail;
-	}
-	
-	
-	/**
-	 * 鍥㈤槦鍒嗙孩
-	 * @Title: createTeamDividents
-	 * @Description: 
-	 * @param uid
-	 * @param money
-	 * @param time
-	 * @return
-	 * @throws UserMoneyDetailException 
-	 * UserMoneyDetail 杩斿洖绫诲瀷
-	 * @throws
-	 */
-	public static UserMoneyDetail createTeamDividents(Long uid, BigDecimal money, Date time)
-			throws UserMoneyDetailException {
-		if (money == null)
-			throw new UserMoneyDetailException(1, "杩斿埄閲戦涓虹┖");
-
-		if (uid == null)
-			throw new UserMoneyDetailException(1, "UID涓虹┖");
-
-		if (time == null)
-			throw new UserMoneyDetailException(1, "鍙戠敓鏃堕棿涓虹┖");
-
-		Calendar ca = Calendar.getInstance();
-		ca.setTime(time);
-		ca.add(Calendar.MONTH, -1);
-
-		String timeF = TimeUtil.getGernalTime(ca.getTimeInMillis(), "yyyy骞碝鏈�");
-
-		UserMoneyDetail detail = new UserMoneyDetail();
-		detail.setCreateTime(new Date());
-		detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.teamDividents.name() + "-" + uid + "-" + timeF));
-		detail.setMoney(money);
-		detail.setTitle(UserMoneyDetailTypeEnum.teamDividents.getDesc());
-		detail.setType(UserMoneyDetailTypeEnum.teamDividents);
-		detail.setDescInfo(timeF);
-		detail.setUpdateTime(new Date());
-		detail.setUserInfo(new UserInfo(uid));
-		return detail;
-	}
-
-}
+package com.yeshi.fanli.util.factory;
+
+import java.math.BigDecimal;
+import java.util.*;
+
+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.UserInfo;
+import com.yeshi.fanli.entity.money.UserMoneyDetail;
+import com.yeshi.fanli.entity.money.UserMoneyDetail.UserMoneyDetailTypeEnum;
+import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanDrawBack;
+import com.yeshi.fanli.exception.money.UserMoneyDetailException;
+import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.StringUtil;
+import org.yeshi.utils.TimeUtil;
+import com.yeshi.fanli.util.account.UserUtil;
+
+public class UserMoneyDetailFactory {
+
+    /**
+     * 杩斿埄璧勯噾璁板綍
+     *
+     * @param hongBaoList
+     * @return
+     */
+    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, "杩斿埄閲戦涓虹┖");
+
+        if (uid == null)
+            throw new UserMoneyDetailException(1, "UID涓虹┖");
+
+        UserMoneyDetail detail = new UserMoneyDetail();
+        detail.setCreateTime(new Date());
+        detail.setIdentifyCode(StringUtil
+                .Md5(UserMoneyDetailTypeEnum.fanli.name() + "-" + uid + "-" + orderType + "-" + orderId + "-" + hbIds));
+        detail.setMoney(money);
+        detail.setTitle(UserMoneyDetailTypeEnum.fanliNew.getDesc());
+        detail.setType(UserMoneyDetailTypeEnum.fanliNew);
+        detail.setDescInfo(Constant.getSourceName(orderType) + "锛�" + orderId);
+        detail.setUpdateTime(new Date());
+        detail.setUserInfo(new UserInfo(uid));
+        detail.setOrderType(orderType);
+        return detail;
+    }
+
+    /**
+     * 楗夸簡涔堣繑鍒�
+     *
+     * @param uid
+     * @param orderId
+     * @param hbId
+     * @param money
+     * @return
+     * @throws UserMoneyDetailException
+     */
+    public static UserMoneyDetail createElmeFanLi(Long uid, String orderId, Long hbId, BigDecimal money)
+            throws UserMoneyDetailException {
+
+        if (StringUtil.isNullOrEmpty(orderId))
+            throw new UserMoneyDetailException(1, "璁㈠崟鍙蜂负绌�");
+
+        if (money == null)
+            throw new UserMoneyDetailException(1, "杩斿埄閲戦涓虹┖");
+
+        if (uid == null)
+            throw new UserMoneyDetailException(1, "UID涓虹┖");
+
+        UserMoneyDetail detail = new UserMoneyDetail();
+        detail.setCreateTime(new Date());
+        detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.elmeFanli.name() + "-" + hbId));
+        detail.setMoney(money);
+        detail.setTitle(UserMoneyDetailTypeEnum.elmeFanli.getDesc());
+        detail.setType(UserMoneyDetailTypeEnum.elmeFanli);
+        detail.setDescInfo("璁㈠崟鍙凤細" + orderId);
+        detail.setUpdateTime(new Date());
+        detail.setUserInfo(new UserInfo(uid));
+        detail.setOrderType(Constant.SOURCE_TYPE_ELME);
+        return detail;
+    }
+
+    /**
+     * 鍒嗕韩濂栭噾鍒拌处
+     *
+     * @param uid
+     * @param money
+     * @param month 鏈堜唤
+     * @return
+     * @throws UserMoneyDetailException
+     */
+    public static UserMoneyDetail createShare(Long uid, int orderType, BigDecimal money, Date recieveMonth)
+            throws UserMoneyDetailException {
+        if (money == null)
+            throw new UserMoneyDetailException(1, "杩斿埄閲戦涓虹┖");
+
+        if (uid == null)
+            throw new UserMoneyDetailException(1, "UID涓虹┖");
+
+        if (recieveMonth == null)
+            throw new UserMoneyDetailException(1, "鍙戠敓鏃堕棿涓虹┖");
+
+        Calendar ca = Calendar.getInstance();
+        ca.setTime(recieveMonth);
+        ca.add(Calendar.MONTH, -1);
+
+        String timeF = TimeUtil.getGernalTime(ca.getTimeInMillis(), "yyyy骞碝鏈�");
+
+        UserMoneyDetail detail = new UserMoneyDetail();
+        detail.setCreateTime(new Date());
+        //鏆傛椂澶勭悊
+//        detail.setIdentifyCode(
+//                StringUtil.Md5(UserMoneyDetailTypeEnum.share.name() + "-" + orderType + "-" + uid + "-" +  TimeUtil.getGernalTime(ca.getTimeInMillis(), "yyyy骞碝鏈坉鏃�")));
+
+        detail.setIdentifyCode(
+                StringUtil.Md5(UserMoneyDetailTypeEnum.share.name() + "-" + orderType + "-" + uid + "-" + timeF));
+        detail.setMoney(money);
+        detail.setTitle(UserMoneyDetailTypeEnum.shareNew.getDesc());
+        detail.setType(UserMoneyDetailTypeEnum.shareNew);
+        detail.setDescInfo(Constant.getSourceName(orderType) + "锛�" + timeF);
+        detail.setUpdateTime(new Date());
+        detail.setUserInfo(new UserInfo(uid));
+        detail.setOrderType(orderType);
+        return detail;
+    }
+
+    /**
+     * 閭�璇峰閲戝埌璐�
+     *
+     * @param uid
+     * @param validCount
+     * @param weiQuanCount
+     * @param invalidCount
+     * @param money
+     * @param time
+     * @return
+     * @throws UserMoneyDetailException
+     */
+    public static UserMoneyDetail createInvite(Long uid, int orderType, int validCount, int weiQuanCount,
+                                               BigDecimal money, Date time) throws UserMoneyDetailException {
+        if (money == null)
+            throw new UserMoneyDetailException(1, "杩斿埄閲戦涓虹┖");
+
+        if (uid == null)
+            throw new UserMoneyDetailException(1, "UID涓虹┖");
+
+        if (time == null)
+            throw new UserMoneyDetailException(1, "鍙戠敓鏃堕棿涓虹┖");
+
+        Calendar ca = Calendar.getInstance();
+        ca.setTime(time);
+        ca.add(Calendar.MONTH, -1);
+
+        String timeF = TimeUtil.getGernalTime(ca.getTimeInMillis(), "yyyy.M");
+
+        UserMoneyDetail detail = new UserMoneyDetail();
+        detail.setCreateTime(new Date());
+        detail.setIdentifyCode(
+                StringUtil.Md5(UserMoneyDetailTypeEnum.invite.name() + "-" + orderType + "-" + uid + "-" + timeF));
+        detail.setMoney(money);
+        detail.setTitle(timeF + UserMoneyDetailTypeEnum.invite.getDesc());
+        detail.setType(UserMoneyDetailTypeEnum.invite);
+        if (validCount != 0 || weiQuanCount != 0)
+            detail.setDescInfo(String.format("鏈夋晥璁㈠崟:%s绗�   缁存潈璁㈠崟:%s绗�", validCount, weiQuanCount));
+        detail.setUpdateTime(new Date());
+        detail.setUserInfo(new UserInfo(uid));
+        detail.setOrderType(orderType);
+        return detail;
+    }
+
+    /**
+     * 杩斿埄缁存潈
+     *
+     * @param uid
+     * @param drawBack
+     * @param money
+     * @return
+     * @throws UserMoneyDetailException
+     */
+    public static UserMoneyDetail createFanLiWeiQuan(Long uid, TaoBaoWeiQuanDrawBack drawBack, BigDecimal money)
+            throws UserMoneyDetailException {
+        return createFanLiWeiQuan(uid, drawBack.getOrderId(), Arrays.asList(new TaoBaoWeiQuanDrawBack[]{drawBack}), money);
+    }
+
+
+    public static UserMoneyDetail createFanLiWeiQuan(Long uid, String orderId, List<TaoBaoWeiQuanDrawBack> drawBackList, BigDecimal money)
+            throws UserMoneyDetailException {
+        if (drawBackList == null || drawBackList.size() == 0)
+            throw new UserMoneyDetailException(1, "閫�娆句负绌�");
+        for (TaoBaoWeiQuanDrawBack drawBack : drawBackList) {
+            if (drawBack.getId() == null)
+                throw new UserMoneyDetailException(1, "閫�娆綢D涓虹┖");
+            if (StringUtil.isNullOrEmpty(drawBack.getOrderId()))
+                throw new UserMoneyDetailException(1, "璁㈠崟鍙蜂负绌�");
+            if (StringUtil.isNullOrEmpty(drawBack.getOrderItemId()))
+                throw new UserMoneyDetailException(1, "瀛愯鍗曞彿涓虹┖");
+        }
+        if (money == null)
+            throw new UserMoneyDetailException(1, "閫�娆鹃噾棰濅负绌�");
+        if (uid == null)
+            throw new UserMoneyDetailException(1, "UID涓虹┖");
+
+        Comparator<TaoBaoWeiQuanDrawBack> cm = (o1, o2) ->
+                o1.getId() - o2.getId() > 0 ? 1 : -1;
+        List<TaoBaoWeiQuanDrawBack> tempList = new ArrayList<>();
+        tempList.addAll(drawBackList);
+
+        List<String> orderItemIdList = new ArrayList<>();
+        for (TaoBaoWeiQuanDrawBack drawBack : tempList) {
+            orderItemIdList.add(drawBack.getOrderItemId());
+        }
+
+
+        UserMoneyDetail detail = new UserMoneyDetail();
+        detail.setCreateTime(new Date());
+        detail.setIdentifyCode(StringUtil
+                .Md5(UserMoneyDetailTypeEnum.fanliWeiQuan.name() + "-" + uid + "-" + StringUtil.concat(orderItemIdList, "#")));
+        detail.setMoney(new BigDecimal("0").subtract(money));
+        detail.setTitle(UserMoneyDetailTypeEnum.fanliWeiQuanNew.getDesc());
+        detail.setType(UserMoneyDetailTypeEnum.fanliWeiQuanNew);
+        //鏆傛椂鍙兘鍐欏叆绗竴涓殑id
+        detail.setSourceIdentifyId(tempList.get(0).getId());
+        detail.setDescInfo(
+                Constant.getSourceName(Constant.SOURCE_TYPE_TAOBAO) + "锛�" + orderId + "-閮ㄥ垎鍟嗗搧鍞悗");
+        detail.setUpdateTime(new Date());
+        detail.setUserInfo(new UserInfo(uid));
+        detail.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
+        return detail;
+    }
+
+    /**
+     * 鍒嗕韩璧氱淮鏉�
+     *
+     * @param uid
+     * @param drawBack
+     * @param money
+     * @return
+     * @throws UserMoneyDetailException
+     */
+    public static UserMoneyDetail createShareWeiQuan(Long uid, TaoBaoWeiQuanDrawBack drawBack, BigDecimal money)
+            throws UserMoneyDetailException {
+        if (drawBack == null)
+            throw new UserMoneyDetailException(1, "閫�娆句负绌�");
+        if (drawBack.getId() == null)
+            throw new UserMoneyDetailException(1, "閫�娆綢D涓虹┖");
+        if (StringUtil.isNullOrEmpty(drawBack.getOrderId()))
+            throw new UserMoneyDetailException(1, "璁㈠崟鍙蜂负绌�");
+        if (StringUtil.isNullOrEmpty(drawBack.getOrderItemId()))
+            throw new UserMoneyDetailException(1, "瀛愯鍗曞彿涓虹┖");
+        if (money == null)
+            throw new UserMoneyDetailException(1, "閫�娆鹃噾棰濅负绌�");
+        if (uid == null)
+            throw new UserMoneyDetailException(1, "UID涓虹┖");
+
+        UserMoneyDetail detail = new UserMoneyDetail();
+        detail.setCreateTime(new Date());
+        detail.setIdentifyCode(StringUtil
+                .Md5(UserMoneyDetailTypeEnum.shareWeiQuan.name() + "-" + uid + "-" + drawBack.getOrderItemId()));
+        detail.setMoney(new BigDecimal("0").subtract(money));
+        detail.setTitle(UserMoneyDetailTypeEnum.shareWeiQuan.getDesc());
+        detail.setSubTitle("璁㈠崟鍞悗");
+        detail.setType(UserMoneyDetailTypeEnum.shareWeiQuan);
+        detail.setSourceIdentifyId(drawBack.getId());
+        detail.setDescInfo("璁㈠崟鍙凤細" + drawBack.getOrderId());
+        detail.setUpdateTime(new Date());
+        detail.setUserInfo(new UserInfo(uid));
+        detail.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
+        return detail;
+    }
+
+    /**
+     * 閭�璇疯禋缁存潈
+     *
+     * @param uid
+     * @param drawBack
+     * @param money
+     * @return
+     * @throws UserMoneyDetailException
+     */
+    public static UserMoneyDetail createInviteWeiQuan(Long uid, TaoBaoWeiQuanDrawBack drawBack, BigDecimal money)
+            throws UserMoneyDetailException {
+        if (drawBack == null)
+            throw new UserMoneyDetailException(1, "閫�娆句负绌�");
+        if (drawBack.getId() == null)
+            throw new UserMoneyDetailException(1, "閫�娆綢D涓虹┖");
+        if (StringUtil.isNullOrEmpty(drawBack.getOrderId()))
+            throw new UserMoneyDetailException(1, "璁㈠崟鍙蜂负绌�");
+        if (StringUtil.isNullOrEmpty(drawBack.getOrderItemId()))
+            throw new UserMoneyDetailException(1, "瀛愯鍗曞彿涓虹┖");
+        if (money == null)
+            throw new UserMoneyDetailException(1, "閫�娆鹃噾棰濅负绌�");
+        if (uid == null)
+            throw new UserMoneyDetailException(1, "UID涓虹┖");
+
+        UserMoneyDetail detail = new UserMoneyDetail();
+        detail.setCreateTime(new Date());
+        detail.setIdentifyCode(StringUtil
+                .Md5(UserMoneyDetailTypeEnum.inviteWeiQuan.name() + "-" + uid + "-" + drawBack.getOrderItemId()));
+        detail.setMoney(new BigDecimal("0").subtract(money));
+        detail.setTitle(UserMoneyDetailTypeEnum.inviteWeiQuan.getDesc());
+        detail.setSubTitle("璁㈠崟鍞悗");
+        detail.setType(UserMoneyDetailTypeEnum.inviteWeiQuan);
+        detail.setSourceIdentifyId(drawBack.getId());
+        detail.setDescInfo("璁㈠崟鍙凤細" + UserUtil.filterOrderId(drawBack.getOrderId()));
+        detail.setUpdateTime(new Date());
+        detail.setUserInfo(new UserInfo(uid));
+        detail.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
+        return detail;
+    }
+
+    /**
+     * 鎻愮幇璧勯噾璁板綍
+     *
+     * @param extract
+     * @return
+     */
+    public static UserMoneyDetail createExtract(Extract extract, String alipayNo) throws UserMoneyDetailException {
+        if (extract == null)
+            throw new UserMoneyDetailException(1, "鎻愮幇璁板綍涓嶈兘涓虹┖");
+        if (extract.getId() == null)
+            throw new UserMoneyDetailException(1, "鎻愮幇璁板綍涓婚敭涓嶈兘涓虹┖");
+        if (extract.getMoney() == null)
+            throw new UserMoneyDetailException(1, "鎻愮幇閲戦涓嶈兘涓虹┖");
+        if (extract.getUserInfo() == null || extract.getUserInfo().getId() == null)
+            throw new UserMoneyDetailException(1, "鎻愮幇鐢ㄦ埛涓嶈兘涓虹┖");
+
+        if (alipayNo != null && alipayNo.length() > 10)
+            alipayNo = "*" + alipayNo.substring(alipayNo.length() - 10, alipayNo.length());
+
+        UserMoneyDetail detail = new UserMoneyDetail();
+        detail.setCreateTime(new Date());
+        detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.extract.name() + ":" + extract.getId()));
+        detail.setMoney(new BigDecimal("0").subtract(extract.getMoney()));
+        detail.setSourceIdentifyId(extract.getId());
+        detail.setTitle(UserMoneyDetailTypeEnum.extractNew.getDesc());
+        detail.setType(UserMoneyDetailTypeEnum.extractNew);
+        detail.setUpdateTime(new Date());
+        detail.setDescInfo("鏀粯瀹濊鍗曞彿锛�" + alipayNo);
+        detail.setUserInfo(extract.getUserInfo());
+        detail.setShow(false);
+        return detail;
+    }
+
+    /**
+     * 鎻愮幇璐﹀彿楠岃瘉璁板綍
+     *
+     * @param aa
+     * @param money
+     * @return
+     * @throws UserMoneyDetailException
+     */
+    public static UserMoneyDetail createExtractAccountValid(AlipayAccountValidNormalHistory aa, BigDecimal money)
+            throws UserMoneyDetailException {
+        if (aa == null)
+            throw new UserMoneyDetailException(1, "楠岃瘉璁板綍涓嶈兘涓虹┖");
+        if (aa.getUid() == 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.extractVerify.name() + ":" + aa.getId()));
+        detail.setMoney(new BigDecimal("0").subtract(money));
+        detail.setSourceIdentifyId(aa.getId());
+        detail.setTitle(UserMoneyDetailTypeEnum.extractVerifyNew.getDesc());
+        detail.setType(UserMoneyDetailTypeEnum.extractVerifyNew);
+        detail.setUpdateTime(new Date());
+        detail.setUserInfo(new UserInfo(aa.getUid()));
+        detail.setDescInfo(String.format("鏀粯瀹濓細%s -濮撳悕-%s", UserUtil.filterAlipayAccount(aa.getAccount()),
+                UserUtil.filterAlipayName(aa.getName())));
+        return detail;
+    }
+
+    /**
+     * 绯荤粺鎵i櫎
+     *
+     * @param uid
+     * @param money
+     * @param desc
+     * @return
+     * @throws UserMoneyDetailException UserMoneyDetail 杩斿洖绫诲瀷
+     * @throws
+     * @Title: createSystemTakeOff
+     * @Description:
+     */
+    public static UserMoneyDetail createSystemTakeOff(Long uid, BigDecimal money, String desc)
+            throws UserMoneyDetailException {
+        if (uid == 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(uid + "-" + UserMoneyDetailTypeEnum.systemTakeOff.name() + System.currentTimeMillis()));
+        detail.setMoney(new BigDecimal("0").subtract(money));
+        detail.setTitle(UserMoneyDetailTypeEnum.systemTakeOff.getDesc());
+        detail.setType(UserMoneyDetailTypeEnum.systemTakeOff);
+        detail.setUpdateTime(new Date());
+        detail.setUserInfo(new UserInfo(uid));
+        detail.setDescInfo(desc);
+        return detail;
+    }
+
+    /**
+     * 鎻愮幇鎷掔粷
+     *
+     * @param extract
+     * @return
+     * @throws UserMoneyDetailException
+     */
+    public static UserMoneyDetail createExtractReject(Extract extract) throws UserMoneyDetailException {
+        if (extract == null)
+            throw new UserMoneyDetailException(1, "鎻愮幇璁板綍涓嶈兘涓虹┖");
+        if (extract.getId() == null)
+            throw new UserMoneyDetailException(1, "鎻愮幇璁板綍涓婚敭涓嶈兘涓虹┖");
+        if (extract.getMoney() == null)
+            throw new UserMoneyDetailException(1, "鎻愮幇閲戦涓嶈兘涓虹┖");
+        if (extract.getUserInfo() == null || extract.getUserInfo().getId() == null)
+            throw new UserMoneyDetailException(1, "鎻愮幇鐢ㄦ埛涓嶈兘涓虹┖");
+
+        UserMoneyDetail detail = new UserMoneyDetail();
+        detail.setCreateTime(new Date());
+        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());
+        detail.setUserInfo(extract.getUserInfo());
+        detail.setShow(false);// 闅愯棌鎻愮幇澶辫触璁板綍
+        return detail;
+    }
+
+    /**
+     * 绯荤粺绾㈠寘
+     *
+     * @param hb
+     * @return
+     * @throws UserMoneyDetailException
+     */
+
+    private static UserMoneyDetail createHongBao(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.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;
+    }
+
+    /**
+     * 鏂颁汉绾㈠寘
+     *
+     * @param hb
+     * @return
+     * @throws UserMoneyDetailException
+     */
+    public static UserMoneyDetail createNewerHongBao(HongBao hb) throws UserMoneyDetailException {
+        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, int orderType, BigDecimal money,
+                                                    BigDecimal originalMoney, 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.orderRewardNew.getDesc());
+        detail.setType(UserMoneyDetailTypeEnum.orderRewardNew);
+        detail.setUpdateTime(new Date());
+        detail.setUserInfo(user);
+        detail.setOrderType(orderType);
+        detail.setDescInfo(Constant.getSourceName(orderType) + ":" + orderId + "-鍘熻繑鍒╋細" + originalMoney);
+        return detail;
+    }
+
+    /**
+     * 璁㈠崟閲嶅缁熻閫�娆�
+     *
+     * @param orderId
+     * @param money
+     * @param user
+     * @return
+     * @throws UserMoneyDetailException
+     */
+    public static UserMoneyDetail createRepeatStatistic(String orderId, int orderType, 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.repeatStatistic.name() + "-" + orderId + "-" + user.getId()));
+        detail.setMoney(money);
+        detail.setTitle(UserMoneyDetailTypeEnum.repeatStatistic.getDesc());
+        detail.setType(UserMoneyDetailTypeEnum.repeatStatistic);
+        detail.setUpdateTime(new Date());
+        detail.setUserInfo(user);
+        detail.setDescInfo("璁㈠崟鍙�:" + orderId);
+        detail.setOrderType(orderType);
+        return detail;
+    }
+
+    public static UserMoneyDetail createSystemEqualize(String desc, BigDecimal money, UserInfo user)
+            throws UserMoneyDetailException {
+        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.systemEqualize.name() + "-" + System.currentTimeMillis() + "-" + user.getId()));
+        detail.setMoney(money);
+        detail.setTitle(UserMoneyDetailTypeEnum.systemEqualizeNew.getDesc());
+        detail.setType(UserMoneyDetailTypeEnum.systemEqualizeNew);
+        detail.setUpdateTime(new Date());
+        detail.setUserInfo(user);
+        if (!StringUtil.isNullOrEmpty(desc)) {
+            detail.setDescInfo(desc);
+        }
+        return detail;
+    }
+
+    public static UserMoneyDetail createScoreConvert(BigDecimal money, UserInfo user) throws UserMoneyDetailException {
+        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.scoreConvert.name() + "-" + System.currentTimeMillis() + "-" + user.getId()));
+        detail.setMoney(money);
+        detail.setTitle(UserMoneyDetailTypeEnum.scoreConvert.getDesc());
+        detail.setType(UserMoneyDetailTypeEnum.scoreConvert);
+        detail.setUpdateTime(new Date());
+        detail.setUserInfo(user);
+
+        return detail;
+    }
+
+    /**
+     * 閭�璇峰閲戝埌璐�
+     *
+     * @param uid
+     * @param money
+     * @param time
+     * @return
+     * @throws UserMoneyDetailException
+     */
+    public static UserMoneyDetail createInviteSubsidy(Long uid, int orderType, BigDecimal money, Date time)
+            throws UserMoneyDetailException {
+        if (money == null)
+            throw new UserMoneyDetailException(1, "杩斿埄閲戦涓虹┖");
+
+        if (uid == null)
+            throw new UserMoneyDetailException(1, "UID涓虹┖");
+
+        if (time == null)
+            throw new UserMoneyDetailException(1, "鍙戠敓鏃堕棿涓虹┖");
+
+        Calendar ca = Calendar.getInstance();
+        ca.setTime(time);
+        ca.add(Calendar.MONTH, -1);
+
+        String timeF = TimeUtil.getGernalTime(ca.getTimeInMillis(), "yyyy.M");
+
+        UserMoneyDetail detail = new UserMoneyDetail();
+        detail.setCreateTime(new Date());
+        detail.setIdentifyCode(
+                StringUtil.Md5(UserMoneyDetailTypeEnum.subsidy.name() + "-" + orderType + "-" + uid + "-" + timeF));
+        detail.setMoney(money);
+        detail.setTitle(
+                timeF + UserMoneyDetailTypeEnum.subsidy.getDesc() + "銆�" + Constant.getSourceName(orderType) + "銆�");
+        detail.setType(UserMoneyDetailTypeEnum.subsidy);
+        detail.setDescInfo("閭�璇疯鍗曡ˉ璐�");
+        detail.setUpdateTime(new Date());
+        detail.setUserInfo(new UserInfo(uid));
+        detail.setOrderType(orderType);
+        return detail;
+    }
+
+    /**
+     * 鍥㈤槦鏀剁泭
+     *
+     * @param uid
+     * @param money
+     * @param time
+     * @return
+     * @throws UserMoneyDetailException UserMoneyDetail 杩斿洖绫诲瀷
+     * @throws
+     * @Title: createTeamReward
+     * @Description:
+     */
+
+    public static UserMoneyDetail createTeamReward(Long uid, BigDecimal money, Date time)
+            throws UserMoneyDetailException {
+        if (money == null)
+            throw new UserMoneyDetailException(1, "杩斿埄閲戦涓虹┖");
+
+        if (uid == null)
+            throw new UserMoneyDetailException(1, "UID涓虹┖");
+
+        if (time == null)
+            throw new UserMoneyDetailException(1, "鍙戠敓鏃堕棿涓虹┖");
+
+        Calendar ca = Calendar.getInstance();
+        ca.setTime(time);
+        ca.add(Calendar.MONTH, -1);
+
+        String timeF = TimeUtil.getGernalTime(ca.getTimeInMillis(), "yyyy骞碝鏈�");
+
+        UserMoneyDetail detail = new UserMoneyDetail();
+        detail.setCreateTime(new Date());
+        detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.teamReward.name() + "-" + uid + "-" + timeF));
+        detail.setMoney(money);
+        detail.setTitle(UserMoneyDetailTypeEnum.teamReward.getDesc());
+        detail.setType(UserMoneyDetailTypeEnum.teamReward);
+        detail.setDescInfo(timeF);
+        detail.setUpdateTime(new Date());
+        detail.setUserInfo(new UserInfo(uid));
+        return detail;
+    }
+
+
+    /**
+     * 鍥㈤槦鍒嗙孩
+     *
+     * @param uid
+     * @param money
+     * @param time
+     * @return
+     * @throws UserMoneyDetailException UserMoneyDetail 杩斿洖绫诲瀷
+     * @throws
+     * @Title: createTeamDividents
+     * @Description:
+     */
+    public static UserMoneyDetail createTeamDividents(Long uid, BigDecimal money, Date time)
+            throws UserMoneyDetailException {
+        if (money == null)
+            throw new UserMoneyDetailException(1, "杩斿埄閲戦涓虹┖");
+
+        if (uid == null)
+            throw new UserMoneyDetailException(1, "UID涓虹┖");
+
+        if (time == null)
+            throw new UserMoneyDetailException(1, "鍙戠敓鏃堕棿涓虹┖");
+
+        Calendar ca = Calendar.getInstance();
+        ca.setTime(time);
+        ca.add(Calendar.MONTH, -1);
+
+        String timeF = TimeUtil.getGernalTime(ca.getTimeInMillis(), "yyyy骞碝鏈�");
+
+        UserMoneyDetail detail = new UserMoneyDetail();
+        detail.setCreateTime(new Date());
+        detail.setIdentifyCode(StringUtil.Md5(UserMoneyDetailTypeEnum.teamDividents.name() + "-" + uid + "-" + timeF));
+        detail.setMoney(money);
+        detail.setTitle(UserMoneyDetailTypeEnum.teamDividents.getDesc());
+        detail.setType(UserMoneyDetailTypeEnum.teamDividents);
+        detail.setDescInfo(timeF);
+        detail.setUpdateTime(new Date());
+        detail.setUserInfo(new UserInfo(uid));
+        return detail;
+    }
+
+    public static void main(String[] args) {
+
+
+    }
+
+}

--
Gitblit v1.8.0