From 0cc3b905e5945d1b4b02ee5f91a615bcfd8f08d6 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期四, 25 七月 2019 11:44:10 +0800
Subject: [PATCH] 京东兼容

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 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 300ac5c..5b8f48c 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
@@ -609,7 +609,7 @@
 
 	@Transactional
 	@Override
-	public void useGoodsCoupon(Long uid, Long id, Long goodId) throws UserSystemCouponException, Exception {
+	public void useGoodsCoupon(Long uid, Long id, Long goodId, Integer sourceType) throws UserSystemCouponException, Exception {
 		if (uid == null) {
 			throw new UserSystemCouponException(1, "鐢ㄦ埛鏈櫥褰�");
 		}
@@ -660,7 +660,7 @@
 		// 鎻掑叆浣跨敤鍒歌褰�
 		UserSystemCouponRecord couponRecord = new UserSystemCouponRecord();
 		couponRecord.setGoodId(goodId);
-		couponRecord.setGoodSource(Constant.SOURCE_TYPE_TAOBAO); // 榛樿娣樺疂
+		couponRecord.setGoodSource(sourceType); // 榛樿娣樺疂
 		couponRecord.setState(UserSystemCouponRecord.STATE_WAIT); // 姝e湪鍖归厤
 		couponRecord.setUserSystemCoupon(userSystemCoupon);
 		couponRecord.setCouponType(baseCoupon.getType().name());
@@ -684,12 +684,16 @@
 
 	@Transactional
 	@Override
-	public void useOrderCoupon(Long uid, Long id, String orderNo, Integer goodsType) throws UserSystemCouponException, Exception {
+	public void useOrderCoupon(Long uid, Long id, String orderNo, Integer sourceType) throws UserSystemCouponException, Exception {
 
 		if (id == null) {
 			throw new UserSystemCouponException(1, "鍒竔d涓嶅瓨鍦�");
 		}
-
+		
+		if (sourceType == null) {
+			sourceType = Constant.SOURCE_TYPE_TAOBAO;
+		}
+				
 		// 鐢ㄦ埛鍒�
 		UserSystemCoupon userSystemCoupon = selectByPrimaryKey(id);
 		if (userSystemCoupon == null) {
@@ -724,7 +728,7 @@
 		}
 
 		// 璁㈠崟
-		CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(uid, orderNo, CommonOrder.STATE_JS);
+		CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(uid, orderNo, CommonOrder.STATE_JS, sourceType);
 		if (orderVO == null) {
 			throw new UserSystemCouponException(1, "璁㈠崟淇℃伅鑾峰彇澶辫触");
 		}
@@ -738,7 +742,7 @@
 		// 鏉′欢: A:蹇呴』鏄繑鍒╄鍗� 銆丅:蹇呴』宸茬粡澶勪簬宸插埌璐︾姸鎬�
 		if (HongBaoV2.TYPE_ZIGOU == hongBaoType && HongBaoV2.STATE_YILINGQU == hongBaoState || hongBao != null) {
 
-			Order order = orderService.findOrderByOrderIdAndType(orderNo, goodsType);
+			Order order = orderService.findOrderByOrderIdAndType(orderNo, sourceType);
 			if (order == null)
 				return;
 
@@ -766,14 +770,14 @@
 			// 2.鎻掑叆鍏宠仈
 			orderHongBaoMapService.addOrderHongBaoMap(hongBaoV2, order);
 
-			// 3.鎻掑叆璧勯噾鏄庣粏,鐢ㄦ埛浣欓 // TODO
-			UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createOrderReward(orderNo,goodsType, money,
+			// 3.鎻掑叆璧勯噾鏄庣粏,鐢ㄦ埛浣欓
+			UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createOrderReward(orderNo, sourceType, money,
 					new UserInfo(uid));
 			userMoneyDetailService.addUserMoneyDetail(userMoneyDetail);
 			userInfoService.addMoney(new UserInfo(uid), money);
 
 			// 鎻掑叆璧勯噾閫氱煡
-			userMoneyMsgNotificationService.orderReward(uid, orderNo,goodsType, money,
+			userMoneyMsgNotificationService.orderReward(uid, orderNo, sourceType, money,
 					userInfoService.selectByPKey(uid).getMyHongBao());
 
 			/* 鐢ㄦ埛鍒镐俊鎭姸鎬佸強璁板綍澶勭悊 */
@@ -788,7 +792,7 @@
 			// 鎻掑叆浣跨敤鍒歌褰�
 			UserSystemCouponRecord couponRecord = new UserSystemCouponRecord();
 			couponRecord.setState(UserSystemCouponRecord.STATE_SUCCESS);
-			couponRecord.setGoodSource(goodsType);
+			couponRecord.setGoodSource(sourceType);
 			couponRecord.setOrderNo(orderNo);
 			couponRecord.setUserSystemCoupon(userSystemCoupon);
 			couponRecord.setCouponType(systemCoupon.getType().name());
@@ -807,7 +811,7 @@
 	}
 
 	@Override
-	public UserSystemCouponRecordVO getRewardCouponRecord(String orderNo) throws UserSystemCouponException, Exception {
+	public UserSystemCouponRecordVO getRewardCouponRecord(String orderNo, Integer sourceType) throws UserSystemCouponException, Exception {
 
 		if (orderNo == null || orderNo.trim().length() == 0) {
 			throw new UserSystemCouponException(1, "璁㈠崟鍙蜂笉瀛樺湪");
@@ -843,7 +847,7 @@
 		Long uid = userSystemCoupon.getUid();
 
 		CommonOrderVO commonOrderVO = commonOrderService.getCommonOrderByOrderNo(userSystemCoupon.getUid(), orderNo,
-				CommonOrder.STATE_JS);
+				CommonOrder.STATE_JS, sourceType);
 
 		if (commonOrderVO == null) {
 			throw new UserSystemCouponException(1, "璁㈠崟淇℃伅鑾峰彇澶辫触");
@@ -885,7 +889,7 @@
 	}
 
 	@Override
-	public UserSystemCouponRecordVO getFreeCouponRecord(String orderNo) throws UserSystemCouponException, Exception {
+	public UserSystemCouponRecordVO getFreeCouponRecord(String orderNo, Integer sourceType) throws UserSystemCouponException, Exception {
 
 		if (orderNo == null || orderNo.trim().length() == 0) {
 			throw new UserSystemCouponException(1, "璁㈠崟鍙蜂笉瀛樺湪");
@@ -913,7 +917,7 @@
 		}
 
 		// 璁㈠崟
-		CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(userSystemCoupon.getUid(), orderNo, null);
+		CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(userSystemCoupon.getUid(), orderNo, null, sourceType);
 		if (orderVO == null) {
 			throw new UserSystemCouponException(1, "璁㈠崟淇℃伅鑾峰彇澶辫触");
 		}

--
Gitblit v1.8.0