From ab5b1fe9c886011cf16805a18d4cd50812508cee Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期三, 28 八月 2019 16:00:47 +0800
Subject: [PATCH] 券

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java |  240 ++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 123 insertions(+), 117 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 73e276d..80019c7 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
@@ -1225,74 +1225,8 @@
 	}
 	
 
-	@Override
-	public void updateCounponInvalid(List<UserSystemCoupon> list) {
-		if (list == null || list.size() == 0) {
-			return;
-		}
+	
 
-		for (UserSystemCoupon userSystemCoupon : list) {
-			UserSystemCoupon userCoupon = new UserSystemCoupon();
-			userCoupon.setUpdateTime(new Date());
-			userSystemCoupon.setState(UserSystemCoupon.STATE_OVERDUE);
-			userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon);
-
-			SystemCoupon baseCoupon = userSystemCoupon.getSystemCoupon();
-			if (baseCoupon == null) {
-				continue;
-			}
-			
-			baseCoupon = systemCouponService.selectByPrimaryKey(baseCoupon.getId());
-			if (baseCoupon == null || baseCoupon.getId() == null) {
-				continue;
-			}
-
-			// 娑堟伅鎺ㄩ��
-			try {
-				if (baseCoupon.getType() == CouponTypeEnum.welfareFreeCoupon) {
-					userOtherMsgNotificationService.welfareCouponAlreadyOutOfDate(userSystemCoupon);
-				} else if (baseCoupon.getType() == CouponTypeEnum.freeCoupon) {
-					userOtherMsgNotificationService.freeSheetCouponAlreadyOutOfDate(userSystemCoupon);
-				} else if (baseCoupon.getType() == CouponTypeEnum.rebatePercentCoupon) {
-					userOtherMsgNotificationService.rewardCouponAlreadyOutOfDate(userSystemCoupon);
-				}else if (baseCoupon.getType() == CouponTypeEnum.freeCouponBuy) {
-					userOtherMsgNotificationService.outOfDate(userSystemCoupon, MsgTypeOtherTypeEnum.freeCouponBuy);
-				} else if (baseCoupon.getType() == CouponTypeEnum.freeCouponGive) {
-					userOtherMsgNotificationService.outOfDate(userSystemCoupon, MsgTypeOtherTypeEnum.freeCouponGive);
-				}
-			} catch (Exception e) {
-				try {
-					LogHelper.errorDetailInfo(e);
-				} catch (Exception e1) {
-					e1.printStackTrace();
-				}
-			}
-		}
-	}
-
-	@Transactional
-	@Override
-	public void sendBackTimeOutCoupon(Long uid) {
-		// 瓒呰繃10鍒嗛挓   鏈鍖归厤鐨勫埜
-		List<UserSystemCouponRecord> list = userSystemCouponRecordService.getCouponByUsingTimeOut(uid, 600L);
-		if (list == null || list.size() == 0) {
-			return;
-		}
-
-		for (UserSystemCouponRecord couponRecord : list) {
-			// 鏇存柊鐘舵�侊細鍖归厤瓒呮椂
-			couponRecord.setState(UserSystemCouponRecord.STATE_WAIT_TIME_OUT);
-			couponRecord.setUpdateTime(new Date());
-			userSystemCouponRecordService.updateByPrimaryKeySelective(couponRecord);
-
-			UserSystemCoupon userSystemCoupon = couponRecord.getUserSystemCoupon();
-			// 鐘舵�佸垵濮嬪寲
-			userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
-			userSystemCoupon.setUseTime(null);
-			userSystemCoupon.setUpdateTime(new Date());
-			userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
-		}
-	}
 
 	@Transactional
 	@Override
@@ -1372,56 +1306,7 @@
 		return isfree;
 	}
 
-	/**
-	 * 閫�鍥炲埜 鍒濆鏁版嵁
-	 * 
-	 * @param userSystemCoupon
-	 */
-	public void sendBackCoupon(UserSystemCoupon userCoupon, UserSystemCouponRecord record) throws Exception {
-		if (userCoupon == null)
-			return;
-			
-		Integer state = userCoupon.getState();
-		if (state != UserSystemCoupon.STATE_IN_USE) 
-			return;
-		
-		Date now = new Date();
-		Date endTime = userCoupon.getEndTime();
-		if (endTime != null && endTime.getTime() < now.getTime()) {
-			// 杩囨湡
-			List<UserSystemCoupon> list = new ArrayList<UserSystemCoupon>();
-			list.add(userCoupon);
-			updateCounponInvalid(list);
-			return;
-		}
-		
-		// 閫�鍥炲埜
-		UserSystemCoupon userSystemCoupon = new UserSystemCoupon();
-		userSystemCoupon.setId(userCoupon.getId());
-		userSystemCoupon.setGive(false);
-		userSystemCoupon.setUseTime(null);
-		userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
-		userSystemCoupon.setUpdateTime(new Date());
-		userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
-		
-		// 浣跨敤璁板綍
-		if  (record != null) {
-			UserSystemCouponRecord useRecordUpdate = new UserSystemCouponRecord();
-			useRecordUpdate.setId(record.getId());
-			useRecordUpdate.setState(UserSystemCouponRecord.STATE_WAIT_TIME_OUT);
-			useRecordUpdate.setUpdateTime(new Date());
-			userSystemCouponRecordService.updateByPrimaryKeySelective(useRecordUpdate);
-			
-			if (CouponTypeEnum.welfareFreeCoupon.name().equals(record.getCouponType())) {
-				userOtherMsgNotificationService.welfareCouponDrawBack(userSystemCoupon, record.getOrderNo());
-			} else if (CouponTypeEnum.freeCoupon.name().equals(record.getCouponType())) {
-				userOtherMsgNotificationService.freeSheetCouponDrawBack(userSystemCoupon, record.getOrderNo());
-			} else if (CouponTypeEnum.freeCouponBuy.name().equals(record.getCouponType())) {
-				userOtherMsgNotificationService.couponDrawBack(userSystemCoupon, record.getOrderNo(), MsgTypeOtherTypeEnum.freeCouponBuy);
-			}
-		}
-		
-	}
+	
 
 	@Override
 	@Transactional
@@ -2070,6 +1955,127 @@
 
 	
 	@Override
+	public void updateCounponInvalid(List<UserSystemCoupon> list) {
+		if (list == null || list.size() == 0) {
+			return;
+		}
+
+		for (UserSystemCoupon userSystemCoupon : list) {
+			UserSystemCoupon userCoupon = new UserSystemCoupon();
+			userCoupon.setUpdateTime(new Date());
+			userSystemCoupon.setState(UserSystemCoupon.STATE_OVERDUE);
+			userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon);
+
+			SystemCoupon baseCoupon = userSystemCoupon.getSystemCoupon();
+			if (baseCoupon == null) {
+				continue;
+			}
+			
+			baseCoupon = systemCouponService.selectByPrimaryKey(baseCoupon.getId());
+			if (baseCoupon == null || baseCoupon.getId() == null) {
+				continue;
+			}
+
+			// 娑堟伅鎺ㄩ��
+			try {
+				if (baseCoupon.getType() == CouponTypeEnum.welfareFreeCoupon) {
+					userOtherMsgNotificationService.welfareCouponAlreadyOutOfDate(userSystemCoupon);
+				} else if (baseCoupon.getType() == CouponTypeEnum.freeCoupon) {
+					userOtherMsgNotificationService.freeSheetCouponAlreadyOutOfDate(userSystemCoupon);
+				} else if (baseCoupon.getType() == CouponTypeEnum.rebatePercentCoupon) {
+					userOtherMsgNotificationService.rewardCouponAlreadyOutOfDate(userSystemCoupon);
+				}else if (baseCoupon.getType() == CouponTypeEnum.freeCouponBuy) {
+					userOtherMsgNotificationService.outOfDate(userSystemCoupon, MsgTypeOtherTypeEnum.freeCouponBuy);
+				} else if (baseCoupon.getType() == CouponTypeEnum.freeCouponGive) {
+					userOtherMsgNotificationService.outOfDate(userSystemCoupon, MsgTypeOtherTypeEnum.freeCouponGive);
+				}
+			} catch (Exception e) {
+				try {
+					LogHelper.errorDetailInfo(e);
+				} catch (Exception e1) {
+					e1.printStackTrace();
+				}
+			}
+		}
+	}
+	
+	/**
+	 * 閫�鍥炲埜 鍒濆鏁版嵁
+	 * 
+	 * @param userSystemCoupon
+	 */
+	public void sendBackCoupon(UserSystemCoupon userCoupon, UserSystemCouponRecord record) throws Exception {
+		if (userCoupon == null)
+			return;
+			
+		Integer state = userCoupon.getState();
+		if (state != UserSystemCoupon.STATE_IN_USE) 
+			return;
+		
+		Date now = new Date();
+		Date endTime = userCoupon.getEndTime();
+		if (endTime != null && endTime.getTime() < now.getTime()) {
+			// 杩囨湡
+			List<UserSystemCoupon> list = new ArrayList<UserSystemCoupon>();
+			list.add(userCoupon);
+			updateCounponInvalid(list);
+			return;
+		}
+		
+		// 閫�鍥炲埜
+		UserSystemCoupon userSystemCoupon = new UserSystemCoupon();
+		userSystemCoupon.setId(userCoupon.getId());
+		userSystemCoupon.setGive(false);
+		userSystemCoupon.setUseTime(null);
+		userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
+		userSystemCoupon.setUpdateTime(new Date());
+		userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
+		
+		// 浣跨敤璁板綍
+		if  (record != null) {
+			UserSystemCouponRecord useRecordUpdate = new UserSystemCouponRecord();
+			useRecordUpdate.setId(record.getId());
+			useRecordUpdate.setState(UserSystemCouponRecord.STATE_WAIT_TIME_OUT);
+			useRecordUpdate.setUpdateTime(new Date());
+			userSystemCouponRecordService.updateByPrimaryKeySelective(useRecordUpdate);
+			
+			if (CouponTypeEnum.welfareFreeCoupon.name().equals(record.getCouponType())) {
+				userOtherMsgNotificationService.welfareCouponDrawBack(userSystemCoupon, record.getOrderNo());
+			} else if (CouponTypeEnum.freeCoupon.name().equals(record.getCouponType())) {
+				userOtherMsgNotificationService.freeSheetCouponDrawBack(userSystemCoupon, record.getOrderNo());
+			} else if (CouponTypeEnum.freeCouponBuy.name().equals(record.getCouponType())) {
+				userOtherMsgNotificationService.couponDrawBack(userSystemCoupon, record.getOrderNo(), MsgTypeOtherTypeEnum.freeCouponBuy);
+			}
+		}
+	}
+	
+	
+	@Transactional
+	@Override
+	public void sendBackTimeOutCoupon(Long uid) {
+		// 瓒呰繃10鍒嗛挓   鏈鍖归厤鐨勫埜
+		List<UserSystemCouponRecord> list = userSystemCouponRecordService.getCouponByUsingTimeOut(uid, 600L);
+		if (list == null || list.size() == 0) {
+			return;
+		}
+
+		for (UserSystemCouponRecord couponRecord : list) {
+			// 鏇存柊鐘舵�侊細鍖归厤瓒呮椂
+			couponRecord.setState(UserSystemCouponRecord.STATE_WAIT_TIME_OUT);
+			couponRecord.setUpdateTime(new Date());
+			userSystemCouponRecordService.updateByPrimaryKeySelective(couponRecord);
+
+			UserSystemCoupon userSystemCoupon = couponRecord.getUserSystemCoupon();
+			// 鐘舵�佸垵濮嬪寲
+			userSystemCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
+			userSystemCoupon.setUseTime(null);
+			userSystemCoupon.setUpdateTime(new Date());
+			userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
+		}
+	}
+
+	
+	@Override
 	public void sendBackGiveCoupon(List<UserSystemCouponGiveRecord> overdueList) {
 		for (UserSystemCouponGiveRecord record: overdueList) {
 			// 鏇存柊璧犻�佽褰�

--
Gitblit v1.8.0