From fb202bc7bd1bb88966473036241c4eef2ea76699 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期三, 11 十二月 2019 14:03:39 +0800
Subject: [PATCH] 队员脱离

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java |   33 ++++++++++++++++++---------------
 1 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
index 2e388ee..1483a50 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -739,7 +739,7 @@
 		return userSystemCouponMapper.countUsableByUid(uid, listCouponId);
 	}
 
-	@Transactional
+	@Transactional(rollbackFor = Exception.class)
 	@Override
 	public void useGoodsCoupon(Long uid, Long id, Long goodId, Integer sourceType)
 			throws UserSystemCouponException, Exception {
@@ -816,7 +816,7 @@
 
 	}
 
-	@Transactional
+	@Transactional(rollbackFor = Exception.class)
 	@Override
 	public void useOrderCoupon(Long uid, Long id, String orderNo, Integer sourceType, AcceptData acceptData)
 			throws UserSystemCouponException, Exception {
@@ -869,23 +869,26 @@
 			throw new UserSystemCouponException(1, "浜诧紝寰堥仐鎲撅紝鍞悗缁存潈璁㈠崟涓嶈兘浣跨敤杩斿埄濂栧姳鍒竳");
 		}
 
+		
 		// 璁㈠崟
-		CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(uid, orderNo, CommonOrder.STATE_JS,
-				sourceType);
-		if (orderVO == null)
-			throw new UserSystemCouponException(1, "璁㈠崟淇℃伅鑾峰彇澶辫触");
-
+		List<CommonOrderVO> listVo = commonOrderService.listGroupOrderNoByUid(0, 1, uid, 2, 1,1, orderNo, null, 
+				null, null, sourceType);
+		if (listVo == null || listVo.size() == 0) 
+			throw new UserSystemCouponException(1, "浜诧紝寰堥仐鎲撅紝璇ヨ鍗曞凡涓嶈兘浣跨敤杩斿埄濂栧姳鍒竳");
+		
+		CommonOrderVO orderVO = listVo.get(0);
 		// 鐗堟湰鍖哄垎锛�2.1
 		if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
+			boolean valid = false;
 			Date thirdCreateTime = orderVO.getThirdCreateTime();
-			if (thirdCreateTime != null) {
+			Date accountTime = orderVO.getAccountTime();
+			if (thirdCreateTime != null && accountTime != null) {
 				long downOrderTime = thirdCreateTime.getTime();
 				long limitDate = TimeUtil.parse(Constant.COUPON_REWARD_TIME).getTime();
 				if (downOrderTime > limitDate) {
-					Date endDay = DateUtil.plusDayDate(4, thirdCreateTime);
+					Date endDay = DateUtil.plusDayDate(Constant.COUPON_REWARD_LIMIT_DAY, accountTime);
 					long currentTime = java.lang.System.currentTimeMillis();
 					if (endDay.getTime() > currentTime) {
-						boolean valid = false;
 						DateInfo dateInfo = DateUtil.dateDiff3(currentTime, endDay.getTime());
 						if (dateInfo != null) {
 							if (dateInfo.getDay() > 0)
@@ -900,12 +903,12 @@
 							if (!valid && dateInfo.getSecond() > 0)
 								valid = true;
 						}
-
-						if (!valid)
-							throw new UserSystemCouponException(1, "璇ヨ鍗曞凡瓒呰繃鏈夋晥浣跨敤濂栧姳鍒告椂闂�");
 					}
 				}
-			}
+			} 
+			
+			if (!valid)
+				throw new UserSystemCouponException(1, "璇ヨ鍗曚笉鑳戒娇鐢ㄥ鍔卞埜");
 		}
 
 		BigDecimal hongBao = orderVO.getHongBao();
@@ -2017,7 +2020,7 @@
 		return listVO;
 	}
 
-	@Transactional
+	@Transactional(rollbackFor = Exception.class)
 	@Override
 	public UserSystemCouponVO giveCoupon(Long uid, Long id) throws UserSystemCouponException {
 		UserSystemCoupon userSystemCoupon = userSystemCouponMapper.selectByPrimaryKey(id);

--
Gitblit v1.8.0