From 857eb5eaf379f7df6686bd838ee561d1ddfb8043 Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期五, 01 三月 2019 09:05:20 +0800
Subject: [PATCH] 抽奖记录表修改

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java |   39 ++++++++++++++++++++++++++-------------
 1 files changed, 26 insertions(+), 13 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 468af7c..9238670 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
@@ -619,9 +619,9 @@
 		// 娑堟伅鎺ㄩ��
 		try {
 			if (baseCoupon.getType() == CouponTypeEnum.welfareFreeCoupon) {
-//				userOtherMsgNotificationService.welfareCouponUsing(userSystemCoupon,order);
+				//userOtherMsgNotificationService.welfareCouponUsing(userSystemCoupon,order.get);
 			} else if (baseCoupon.getType() == CouponTypeEnum.freeCoupon) {
-//				userOtherMsgNotificationService.freeSheetCouponUsing(userSystemCoupon);
+				//userOtherMsgNotificationService.freeSheetCouponUsing(userSystemCoupon);
 			}
 			
 		} catch(Exception e) {
@@ -1082,7 +1082,7 @@
 		userSystemCouponRecordService.updateByPrimaryKeySelective(record);
 		
 		// 鍒搁��鍥�
-		sendBackCoupon(record.getUserSystemCoupon());
+		sendBackCoupon(record.getUserSystemCoupon(), record);
 	}
 	
 	@Transactional
@@ -1102,6 +1102,13 @@
 		record.setUpdateTime(new Date());
 		record.setState(UserSystemCouponRecord.STATE_SUCCESS);
 		userSystemCouponRecordService.updateByPrimaryKeySelective(record);
+		
+		// 娑堟伅鎺ㄩ��
+		if (CouponTypeEnum.welfareFreeCoupon.name().equals(record.getCouponType())) {
+			userOtherMsgNotificationService.welfareCouponUsed(record.getUserSystemCoupon(), orderNo);
+		} else if (CouponTypeEnum.freeCoupon.name().equals(record.getCouponType())) {
+			userOtherMsgNotificationService.freeSheetCouponUsed(record.getUserSystemCoupon(), orderNo);
+		} 
 	}
 
 	@Transactional
@@ -1238,7 +1245,7 @@
 				userSystemCouponRecordService.updateByPrimaryKeySelective(record);
 				
 				// 閫�鍥炲埜
-				sendBackCoupon(userSystemCoupon);
+				sendBackCoupon(userSystemCoupon, record);
 				
 			} else {
 				// 鍏嶅崟鍖归厤鎴愬姛
@@ -1253,16 +1260,15 @@
 				userSystemCoupon.setUpdateTime(new Date());
 				userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon);
 				
-				SystemCoupon systemCoupon = userSystemCoupon.getSystemCoupon();
+				String couponType = record.getCouponType();
+				if (couponType == null || couponType.trim().length() == 0) {
+					throw new Exception("鍒哥被鍨嬫湭琚褰�");
+				}
 				
-				SystemCoupon baseCoupon = systemCouponService.selectByPrimaryKey(systemCoupon.getId());
-				if (baseCoupon == null) {
-					// 鍒稿凡浣跨敤
-					userOtherMsgNotificationService.freeSheetCouponUsed(userSystemCoupon, orderNo);
-				} else 	if (baseCoupon.getType() == CouponTypeEnum.welfareFreeCoupon) {
+			 	if (CouponTypeEnum.welfareFreeCoupon.name().equals(couponType)) {
 					userOtherMsgNotificationService.welfareCouponUsing(userSystemCoupon,orderNo,payment);
-				} else if (baseCoupon.getType() == CouponTypeEnum.freeCoupon) {
-					userOtherMsgNotificationService.freeSheetCouponUsed(userSystemCoupon,orderNo);
+				} else if (CouponTypeEnum.freeCoupon.name().equals(couponType)) {
+					userOtherMsgNotificationService.freeSheetCouponUsing(userSystemCoupon, orderNo, payment);
 				} 
 			}
 		}
@@ -1274,7 +1280,7 @@
 	 * 閫�鍥炲埜 鍒濆鏁版嵁
 	 * @param userSystemCoupon
 	 */
-	public void sendBackCoupon(UserSystemCoupon userSystemCoupon) throws Exception{
+	public void sendBackCoupon(UserSystemCoupon userSystemCoupon, UserSystemCouponRecord record) throws Exception{
 
 		int expiryDay = 15;
 
@@ -1303,6 +1309,13 @@
 		userSystemCoupon.setUpdateTime(new Date());
 		
 		userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
+		
+		
+		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());
+		} 
 	}
 	
 	

--
Gitblit v1.8.0