From c8112d757b901efc582633e49423c81482555ea9 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期四, 27 六月 2019 15:38:35 +0800
Subject: [PATCH] 动态删除3天之前数据

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java |   56 +++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 41 insertions(+), 15 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java
index 07b8e9f..a2aa6ef 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java
@@ -224,12 +224,24 @@
 
 		// 杩囨湡
 		userTaoLiJinOriginService.overdueHongBao(uid);
-
-		BigDecimal tlj = userMoneyExtra.getTlj();
+		
+		// 鎬绘帹骞跨孩鍖�
 		BigDecimal totalMoney = MoneyBigDecimalUtil.mul(perface, new BigDecimal(totalNum));
-		if (totalMoney.compareTo(tlj) > 0) {
+		
+		// 鑷喘鏃剁殑绾㈠寘浣欓
+		if (origin == 1) {
+			BigDecimal tljSelf = userMoneyExtra.getTljSelf();
+			if (tljSelf == null || tljSelf.compareTo(totalMoney) < 0) {
+				throw new UserTaoLiJinRecordException(101, "绾㈠寘浣欓涓嶈冻");
+			}
+		} 
+		
+		// 鍒嗕韩鏃剁殑绾㈠寘浣欓
+		BigDecimal tlj = userMoneyExtra.getTlj();
+		if (tlj == null || tlj.compareTo(totalMoney) < 0) {
 			throw new UserTaoLiJinRecordException(101, "绾㈠寘浣欓涓嶈冻");
 		}
+		
 
 		// 鍒涘缓娣樼ぜ閲戠孩鍖�
 		TaoLiJinDTO taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, name, perface, totalNum, sendStartTime,
@@ -252,12 +264,21 @@
 		record.setRightsId(taoLiJinDTO.getRightsId());
 		record.setSendUrl(taoLiJinDTO.getSendUrl());
 		record.setCreateTime(new Date());
+		if (origin == 1) { //  鑷喘
+			record.setUseType(1);
+		} else { //  鍒嗕韩
+			record.setUseType(2);
+		}
+		
 		userTaoLiJinRecordMapper.insertSelective(record);
 
-		// 鍓╀綑娣樼ぜ閲�
-		BigDecimal surplusTlj = MoneyBigDecimalUtil.sub(tlj, totalMoney);
+		BigDecimal surplusTlj = MoneyBigDecimalUtil.sub(tlj, totalMoney); 
+		
 		UserMoneyExtra updateExtra = new UserMoneyExtra();
 		updateExtra.setUid(uid);
+		if (origin == 1) { // 鍓╀綑娣樼ぜ閲�-- 鑷喘
+			updateExtra.setTljSelf(MoneyBigDecimalUtil.sub(userMoneyExtra.getTljSelf(), totalMoney));
+		} 
 		updateExtra.setTlj(surplusTlj);
 		updateExtra.setUpdateTime(new Date());
 		userMoneyExtraService.updateByPrimaryKeySelective(updateExtra);
@@ -315,6 +336,19 @@
 					LogHelper.errorDetailInfo(e);
 				}
 
+				// 鍒涘缓鎶ュ憡
+				try {
+					userTaoLiJinReportService.insertDefault(rightsId);
+				} catch (Exception e) {
+					LogHelper.errorDetailInfo(e);
+				}
+				
+				
+				if (origin == 1) { 
+					return; //  鑷喘涓嶆帹閫佹秷鎭�
+				}
+				
+				
 				// 浣跨敤鎴愬姛娑堟伅
 				try {
 					String beizhu = "鏈棰嗗彇/浣跨敤鐨勯儴鍒嗗皢浼氶��鍥�";
@@ -327,13 +361,6 @@
 					content.setMoney(totalMoney);
 
 					userOtherMsgNotificationService.taoLiJinMsg(uid, beizhu, content);
-				} catch (Exception e) {
-					LogHelper.errorDetailInfo(e);
-				}
-
-				// 鍒涘缓鎶ュ憡
-				try {
-					userTaoLiJinReportService.insertDefault(rightsId);
 				} catch (Exception e) {
 					LogHelper.errorDetailInfo(e);
 				}
@@ -406,10 +433,9 @@
 			// 璁$畻鍒嗕韩濂栭噾
 			BigDecimal shareMoney = new BigDecimal(0);
 			BigDecimal commission = userTaoLiJinRecordVO.getCommission();
-			if (commission != null && commission.compareTo(shareMoney) > 1) {
+			if (commission != null && commission.compareTo(shareMoney) > 0) {
 				BigDecimal shareRate = hongBaoManageService.getShareRate();
-				shareMoney = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(commission, new BigDecimal("0.01")),
-						MoneyBigDecimalUtil.div(shareRate, new BigDecimal(100)));
+				shareMoney = MoneyBigDecimalUtil.mul(commission, MoneyBigDecimalUtil.div(shareRate, new BigDecimal(100)));
 				shareMoney = BigDecimalUtil.getWithNoZera(shareMoney);
 			}
 

--
Gitblit v1.8.0