From 2cde53516c1689efab451aef72c1db5e13b825a3 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 15 四月 2020 16:42:03 +0800
Subject: [PATCH] 团队订单金额消息加入补贴

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java |   72 +++++++++++++++++------------------
 1 files changed, 35 insertions(+), 37 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
index 75b0088..1e03ab2 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -36,6 +36,7 @@
 import com.yeshi.fanli.entity.jd.JDGoods;
 import com.yeshi.fanli.entity.jd.JDOrder;
 import com.yeshi.fanli.entity.jd.JDOrderItem;
+import com.yeshi.fanli.entity.money.InviteOrderSubsidyDebt;
 import com.yeshi.fanli.entity.order.CommonOrder;
 import com.yeshi.fanli.entity.order.CommonOrderGoods;
 import com.yeshi.fanli.entity.order.CommonOrderTradeIdMap;
@@ -57,6 +58,7 @@
 import com.yeshi.fanli.service.inter.config.ConfigService;
 import com.yeshi.fanli.service.inter.config.SystemCouponService;
 import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
+import com.yeshi.fanli.service.inter.money.InviteOrderSubsidyDebtService;
 import com.yeshi.fanli.service.inter.order.CommonOrderService;
 import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
 import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
@@ -133,6 +135,9 @@
 
 	@Resource
 	private InviteOrderSubsidyService inviteOrderSubsidyService;
+	
+	@Resource
+	private InviteOrderSubsidyDebtService inviteOrderSubsidyDebtService;
 
 	@Resource
 	private UserVIPInfoService userVIPInfoService;
@@ -2041,11 +2046,11 @@
 				
 				// 鏄惁宸蹭娇鐢ㄥ鍔卞埜銆佸厤鍗曞埜鎯呭喌
 				 if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
-					couponUseFactory(order, signList, listRecordTB);
+					couponUseFactory(order, listRecordTB);
 				} else if (sourceType == Constant.SOURCE_TYPE_JD) {
-					couponUseFactory(order, signList, listRecordJD);
+					couponUseFactory(order, listRecordJD);
 				} else if (sourceType == Constant.SOURCE_TYPE_PDD) {
-					couponUseFactory(order, signList, listRecordPDD);
+					couponUseFactory(order, listRecordPDD);
 				}
 			} else if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType) {
 				// 鍒嗕韩
@@ -2062,6 +2067,21 @@
 				order.setOrderOrigin("3");
 				order.setHongBaoTypePic(CommonOrder.TYPE_INVITE);
 				signList.add(CommonOrder.TYPE_INVITE);
+				
+				// 绾㈠寘鍔犱笂琛ヨ创閲戦
+				InviteOrderSubsidy orderSubsidy = inviteOrderSubsidyService.getByOrderNoAndType(uid, orderNo, sourceType);
+				if (orderSubsidy != null && orderSubsidy.getMoney() != null) {
+					BigDecimal subsidyMoney = orderSubsidy.getMoney();
+					// 缁存潈閲戦
+					InviteOrderSubsidyDebt subsidyDebt = inviteOrderSubsidyDebtService.getBySourceId(orderSubsidy.getId());
+					if (subsidyDebt != null && subsidyDebt.getOriginMoney() != null) {
+						subsidyMoney = subsidyMoney.subtract(subsidyDebt.getOriginMoney());
+					} 
+					//  鏈�缁堣ˉ璐�
+					if (subsidyMoney.compareTo(new BigDecimal(0)) > 0) {
+						hongBao = hongBao.add(subsidyMoney);
+					}
+				}
 			} 
 			order.setSignList(signList);
 
@@ -2104,9 +2124,8 @@
 			stateMap.put("content", stateContent);
 			stateMap.put("fontColor", stateFontColor);
 			order.setAccountState(stateMap);
-
 			hongbaoInfo = hongBaoState_Str + hongbaoInfo;
-
+			
 			Map<String, String> hongBaoMap = new HashMap<String, String>();
 			hongBaoMap.put("content", hongbaoInfo + " 楼" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString());
 			hongBaoMap.put("fontColor", hongbaoInfoFontColor);
@@ -2124,18 +2143,14 @@
 	 * 璁㈠崟锛� 鍏嶅崟鏍囪瘑 濂栧姳鏍囪瘑
 	 * 
 	 * @param order
-	 * @param hasRewardCoupon
-	 * @param hongBaoState
 	 * @param list
-	 * @param signList
 	 */
-	private void couponUseFactory(CommonOrderVO order,List<String> signList, List<UserSystemCouponRecord> list) throws Exception {
+	private void couponUseFactory(CommonOrderVO order, List<UserSystemCouponRecord> list) throws Exception {
 		if (list == null || list.size() == 0) {
 			return;
 		}
 
-		// 鏄惁鍏嶅崟鍟嗗搧
-		boolean freeOrder = false;
+		String text = null;
 		for (UserSystemCouponRecord couponRecord : list) {
 			int goodSource = couponRecord.getGoodSource();
 			if (goodSource == 0)
@@ -2145,47 +2160,30 @@
 			if (order.getOrderNo().equals(orderNo) && goodSource == order.getSourceType()) {
 				Integer state = couponRecord.getState();
 				String systemCouponType = couponRecord.getCouponType();
-				if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
+				if (CouponTypeEnum.rebatePercentCoupon.name().equals(systemCouponType)
+						&& UserSystemCouponRecord.STATE_SUCCESS == state) {
+					text = "宸插鍔�";
+				} else if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
 						|| CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)
 						|| CouponTypeEnum.freeCouponBuy.name().equals(systemCouponType)) {
 					if (UserSystemCouponRecord.STATE_FREE_ON == state) {
-						// 鍏嶅崟涓�
-						freeOrder = true;
-						signList.add(PIC_FREE_ON);
+						text = "鍏嶅崟涓�";
 					} else if (UserSystemCouponRecord.STATE_SUCCESS == state) {
-						// 鍏嶅崟鎴愬姛
-						freeOrder = true;
-						signList.add(PIC_FREE_SUCCEED);
-					} else if (UserSystemCouponRecord.STATE_FAIL_RULE == state
-							|| UserSystemCouponRecord.STATE_FAIL_DRAWBACK == state) {
-						// 瑙勫垯涓嶅尮閰嶃�侀��娆�
-						freeOrder = true;
-						signList.add(PIC_FREE_FAIL);
-					}
+						text = "鍏嶅崟鎴愬姛";
+					} 
 				}
 				break;
 			}
 		}
 
-		// 鍏嶅崟璇︽儏
-		if (freeOrder) {
+		if (!StringUtil.isNullOrEmpty(text)) {
 			ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
-			rewardStyleVO.setContent("鍏嶅崟璇︽儏 >");
+			rewardStyleVO.setContent(text);
 			rewardStyleVO.setColor("#E5005C");
 			rewardStyleVO.setBottomColor("#FFDCEA");
 
-			Map<String, Object> jumpLink = new HashMap<String, Object>();
-			jumpLink.put("orderNo", order.getOrderNo());
-			jumpLink.put("goodsType", order.getSourceType() + "");
-
-			Map<String, Object> jump = new HashMap<String, Object>();
-			jump.put("type", 1); // 椤甸潰璺宠浆
-			jump.put("params", jumpLink);
-			jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("freeCouponDetail"));
-
 			Map<String, Object> rewardMap = new HashMap<String, Object>();
 			rewardMap.put("text", rewardStyleVO);
-			rewardMap.put("jump", jump);
 			order.setRewardDetail(rewardMap);
 		}
 	}

--
Gitblit v1.8.0