From f4d4486e55b91ab2d6313c48dbe8500c3928e8fa Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期二, 14 四月 2020 09:19:31 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/order/InviteOrderSubsidyServiceImplV2.java |   30 ++++++++++++++++--------------
 1 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/InviteOrderSubsidyServiceImplV2.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/InviteOrderSubsidyServiceImplV2.java
index dcadc32..3eaccbb 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/InviteOrderSubsidyServiceImplV2.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/InviteOrderSubsidyServiceImplV2.java
@@ -22,7 +22,6 @@
 import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
 import com.yeshi.fanli.exception.order.CommonOrderException;
 import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
-import com.yeshi.fanli.exception.order.OrderTeamRewardException;
 import com.yeshi.fanli.service.inter.order.CommonOrderService;
 import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
 import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
@@ -84,9 +83,8 @@
 		return inviteOrderSubsidyMapper.listByOrderNoAndType(orderNo, type);
 	}
 
-	@Transactional(rollbackFor = Exception.class)
 	private void addOrderSubsidy(InviteOrderSubsidy orderSubsidy)
-			throws InviteOrderSubsidyException, OrderTeamRewardException, CommonOrderException {
+			throws InviteOrderSubsidyException, CommonOrderException {
 		if (orderSubsidy.getMoney() == null || StringUtil.isNullOrEmpty(orderSubsidy.getOrderNo())
 				|| orderSubsidy.getSourceType() == null || orderSubsidy.getUid() == null)
 			throw new InviteOrderSubsidyException(1, "鏁版嵁涓嶅畬鏁�");
@@ -121,7 +119,7 @@
 			// 蹇呴』鏄嚜璐鍗曟墠杩斿埄
 			HongBaoV2 parent = hongBaoV2Service.selectByPrimaryKey(list.get(0).getHongBaoV2().getId());
 			if (parent != null
-					&& (parent.getType() == HongBaoV2.TYPE_SHARE_GOODS || parent.getType() == HongBaoV2.TYPE_ZIGOU)) {// 涓嶆槸瓒呯骇浼氬憳鐨勮嚜璐�/鍒嗕韩鎵嶈ˉ璐�
+					&& (parent.getType() == HongBaoV2.TYPE_SHARE_GOODS || parent.getType() == HongBaoV2.TYPE_ZIGOU)) {//
 
 				List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(sourceType, orderId);
 				if (orderList == null || orderList.size() == 0)
@@ -154,7 +152,7 @@
 					}
 
 					List<HongBaoV2> hbList = hongBaoV2Service.listByIds(idList);
-					Integer state = null;
+					Integer state = InviteOrderSubsidy.STATE_UNKNOWN;
 
 					// 浜х敓鏀硅鍗曠殑杩斿埄鎬婚噾棰�
 					BigDecimal totalBuyFanLiMoney = new BigDecimal(0);
@@ -163,15 +161,8 @@
 						if (v2.getState() == HongBaoV2.STATE_BUKELINGQU || v2.getState() == HongBaoV2.STATE_KELINGQU
 								|| v2.getState() == HongBaoV2.STATE_YILINGQU)
 							totalBuyFanLiMoney = totalBuyFanLiMoney.add(v2.getMoney());
-
-						if (state == null && (v2.getState() == HongBaoV2.STATE_KELINGQU
-								|| v2.getState() == HongBaoV2.STATE_YILINGQU)) {// 绾㈠寘鐘舵�佷负宸查鍙栨垨鑰呮槸寰呴鍙栵紝鍒欒缃负琛ヨ创鏈夋晥
-							state = InviteOrderSubsidy.STATE_VALID;
-						}
 					}
 
-					if (state == null)
-						state = InviteOrderSubsidy.STATE_UNKNOWN;
 					// 璁$畻濂栧姳閲�
 					for (Iterator<Long> its = uidHongBaoMap.keySet().iterator(); its.hasNext();) {
 						Long uid = its.next();
@@ -205,13 +196,24 @@
 
 							try {
 								addOrderSubsidy(orderSubsidy);
-							} catch (OrderTeamRewardException e) {
-								throw new InviteOrderSubsidyException(e.getCode(), e.getMsg());
 							} catch (CommonOrderException e) {
 								throw new InviteOrderSubsidyException(e.getCode(), e.getMsg());
 							}
 						}
 					}
+
+					boolean isSettle = false;
+					if (orderList != null)
+						for (CommonOrder commonOrder : orderList) {
+							if (commonOrder.getState() == CommonOrder.STATE_JS
+									|| commonOrder.getState() == CommonOrder.STATE_WQ) {
+								isSettle = true;
+								break;
+							}
+						}
+					if (isSettle) {
+						validByOrderIdAndSourceType(orderId, sourceType);
+					}
 				}
 			}
 		}

--
Gitblit v1.8.0