From 8c04d27e5cebb7e654c208533e9567c4df2c8acc Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期四, 12 十二月 2019 14:21:44 +0800
Subject: [PATCH] 券时间限制

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java |   47 ++++++++++++++++++++++++-----------------------
 1 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java
index 5843a70..2b816ec 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackExchangeServiceImpl.java
@@ -21,7 +21,6 @@
 import com.yeshi.fanli.entity.redpack.RedPackDetail;
 import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
 import com.yeshi.fanli.entity.redpack.RedPackExchange;
-import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
 import com.yeshi.fanli.exception.redpack.RedPackExchangeException;
 import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.money.UserMoneyService;
@@ -30,6 +29,7 @@
 import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
 import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
 import com.yeshi.fanli.service.inter.redpack.RedPackExchangeService;
+import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.TimeUtil;
 import com.yeshi.fanli.util.factory.RedPackDetailFactory;
@@ -54,6 +54,9 @@
 	
 	@Resource
 	private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
+	
+	@Resource
+	private RedPackForbidService redPackForbidService;
 	
 	
 	@Override
@@ -87,16 +90,13 @@
 	public void exchangeCash(Long uid, BigDecimal amount) throws RedPackExchangeException {
 		if (uid == null || amount == null)
 			throw new RedPackExchangeException(1, "鍙傛暟涓嶆纭�");
-
+		
+		if(redPackForbidService.verifyForbid(uid))
+			throw new RedPackExchangeException(1, "绾㈠寘鍔熻兘宸茶灏佺");
+		
 		String extractBanlenMin = redPackConfigService.getValueByKey("extract_banlen_min");
 	
-		BigDecimal balance = null;
-		try {
-			balance = redPackBalanceService.getBalance(uid);
-		} catch (RedPackBalanceException e1) {
-			throw new RedPackExchangeException(1, e1.getMsg());
-		}
-		
+		BigDecimal balance =  redPackBalanceService.getBalance(uid);
 		if (balance == null || balance.compareTo(new BigDecimal(extractBanlenMin)) < 0)
 			throw new RedPackExchangeException(1, "浣欓涓嶈冻" + extractBanlenMin + "鍏�");
 		
@@ -143,6 +143,9 @@
 		if (RedPackExchange.STATE_INIT != record.getState())
 			throw new RedPackExchangeException(1,"璇ョ敵璇峰凡琚鐞嗭紝璇峰埛鏂�");
 
+		if(redPackForbidService.verifyForbid(record.getUid()))
+			throw new RedPackExchangeException(1, "绾㈠寘鍔熻兘宸茶灏佺");
+		
 		Date nowDate = new Date();
 		record.setAuditId(admin.getId());
 		record.setAuditTime(nowDate);
@@ -175,20 +178,18 @@
 			throw new RedPackExchangeException(1,"鏇存柊鎻愮幇鏄庣粏鍑洪敊");
 		}
 		
-		try {
-			//娑堟伅
-			SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
-			String beizu = "绾㈠寘鎻愮幇鎴愬姛鍚庤鍒扳�滄垜鐨�-璐︽埛浣欓鈥濅腑鏌ョ湅";
-			MsgRedPackExchangeContentDTO dto = new MsgRedPackExchangeContentDTO();
-			dto.setTitle("绾㈠寘鎻愮幇");
-			dto.setTime(sd.format(record.getCreateTime()));
-			dto.setHandle("浜哄伐瀹℃牳" + sd.format(new Date())); 
-			dto.setMoney("楼" + record.getMoney().setScale(2));		
-			dto.setBalance("楼" + redPackBalanceService.getBalance(record.getUid()));
-			userMoneyMsgNotificationService.redPackMsg(record.getUid(), MsgTypeMoneyTypeEnum.redPackExchangePass, new Gson().toJson(dto), beizu);
-		} catch (RedPackBalanceException e) {
-			throw new RedPackExchangeException(1, e.getMsg());
-		}
+	
+		//娑堟伅
+		SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
+		String beizu = "绾㈠寘鎻愮幇鎴愬姛鍚庤鍒扳�滄垜鐨�-璐︽埛浣欓鈥濅腑鏌ョ湅";
+		MsgRedPackExchangeContentDTO dto = new MsgRedPackExchangeContentDTO();
+		dto.setTitle("绾㈠寘鎻愮幇");
+		dto.setTime(sd.format(record.getCreateTime()));
+		dto.setHandle("浜哄伐瀹℃牳" + sd.format(new Date())); 
+		dto.setMoney("楼" + record.getMoney().setScale(2));		
+		dto.setBalance("楼" + redPackBalanceService.getBalance(record.getUid()));
+		userMoneyMsgNotificationService.redPackMsg(record.getUid(), MsgTypeMoneyTypeEnum.redPackExchangePass, new Gson().toJson(dto), beizu);
+		
 	}
 	
 

--
Gitblit v1.8.0