From 0b57cfd62e842b309d03467b96a331c673ecad7c Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 21 四月 2020 14:08:18 +0800
Subject: [PATCH] 删除普通会员等级

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java |   92 +++++++++++++++++++++++++++++++---------------
 1 files changed, 62 insertions(+), 30 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 b5801de..f17f18d 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
@@ -22,6 +22,7 @@
 import com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper;
 import com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper;
 import com.yeshi.fanli.dao.mybatis.order.CommonOrderTradeIdMapMapper;
+import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoOrderGoodsMapper;
 import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
 import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
 import com.yeshi.fanli.dto.mq.order.body.OrderConfirmMQMsg;
@@ -36,6 +37,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;
@@ -47,6 +49,7 @@
 import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
+import com.yeshi.fanli.entity.taobao.TaoBaoOrderGoods;
 import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
 import com.yeshi.fanli.exception.order.CommonOrderException;
 import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
@@ -57,6 +60,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;
@@ -135,6 +139,9 @@
 	private InviteOrderSubsidyService inviteOrderSubsidyService;
 
 	@Resource
+	private InviteOrderSubsidyDebtService inviteOrderSubsidyDebtService;
+
+	@Resource
 	private UserVIPInfoService userVIPInfoService;
 
 	@Resource
@@ -145,6 +152,9 @@
 
 	@Resource
 	private UserLevelManager userLevelManager;
+
+	@Resource
+	private TaoBaoOrderGoodsMapper taoBaoOrderGoodsMapper;
 
 	@Resource(name = "producer")
 	private Producer orderProducer;
@@ -315,7 +325,7 @@
 
 		// 褰撳墠鐢ㄦ埛鏄惁VIP
 		boolean vip = userInviteService.verifyVIP(uid);
-		
+
 		// 鏄惁瀛樺湪濂栧姳鍒�
 		boolean hasRewardCoupon = userSystemCouponService.getValidRebateCoupon(uid);
 		for (CommonOrderVO order : listOrder) {
@@ -585,16 +595,16 @@
 			if (HongBaoV2.TYPE_ZIGOU == hongBaoType) {
 				// 濂栧姳璁㈠崟銆佸厤鍗� 浣跨敤璁板綍
 				if (sourceType == null) {
-					couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, null, uid, vip, acceptData);
+					couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, null, uid, vip, acceptData, hongBao);
 				} else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
 					couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, uid, vip,
-							acceptData);
+							acceptData, hongBao);
 				} else if (sourceType == Constant.SOURCE_TYPE_JD) {
 					couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, uid, vip,
-							acceptData);
+							acceptData, hongBao);
 				} else if (sourceType == Constant.SOURCE_TYPE_PDD) {
 					couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, uid, vip,
-							acceptData);
+							acceptData, hongBao);
 				}
 			}
 
@@ -617,7 +627,7 @@
 	 * @param signList
 	 */
 	private void couponFactory(CommonOrderVO order, boolean hasRewardCoupon, Integer hongBaoState, Integer hongBaoType,
-			List<UserSystemCouponRecord> list, Long uid, boolean vip, AcceptData acceptData) throws Exception {
+			List<UserSystemCouponRecord> list, Long uid, boolean vip, AcceptData acceptData, BigDecimal hongBao) throws Exception {
 
 		// 鏄惁鍏嶅崟鍟嗗搧
 		boolean freeOrder = false;
@@ -715,6 +725,11 @@
 			order.setRewardDetail(rewardMap);
 		}
 
+		// 浣跨敤濂栧姳鍒� 閲戦棰濋檺鍒�
+		if (hongBao.compareTo(Constant.REWARD_COUPON_LIMIT_MONEY) > 0){
+			return;
+		}
+		
 		// 鏄惁鍙娇鐢ㄥ鍔卞埜
 		if (!rewardSuccess && !freeOrder && HongBaoV2.TYPE_ZIGOU == hongBaoType
 				&& HongBaoV2.STATE_YILINGQU == hongBaoState && !vip && CommonOrder.STATE_WQ != order.getState()) {
@@ -869,7 +884,6 @@
 		return commonOrderMapper.countUserOrderToApp(uid, type, startTime, endTime, day, source, state, stateOrder);
 	}
 
-	
 	@Override
 	public BigDecimal getWeiQuanMoney(List<TaoBaoWeiQuanOrder> listWQ, int sourceType, Long uid) {
 		BigDecimal weiQuanMoney = new BigDecimal(0);
@@ -931,8 +945,14 @@
 			if ("楗夸簡涔�".equalsIgnoreCase(taoBaoOrder.getOrderType())) {
 				cog.setGoodsId(taoBaoOrder.getTradeId() + "");
 				cog.setGoodsType(Constant.SOURCE_TYPE_ELME);
-				cog.setPicture("http://img.flqapp.com/resource/goods/elme_picture_demo.png");
-				cog.setTitle(taoBaoOrder.getTitle());
+				TaoBaoOrderGoods goods = taoBaoOrderGoodsMapper.selectByTradeId(taoBaoOrder.getTradeId());
+				if (goods == null) {
+					cog.setPicture("http://img.flqapp.com/resource/goods/elme_picture_demo.png");
+					cog.setTitle(taoBaoOrder.getTitle());
+				} else {
+					cog.setPicture(goods.getImg());
+					cog.setTitle(goods.getTitle());
+				}
 				newCommonOrder.setCommonOrderGoods(cog);
 			} else {
 				cog.setGoodsId(taoBaoOrder.getAuctionId() + "");
@@ -1789,7 +1809,6 @@
 		return listVO;
 	}
 
-
 	@Override
 	public Date getThirdCreateTime(String orderId, int sourceType) {
 		List<CommonOrder> list = listBySourceTypeAndOrderId(sourceType, orderId);
@@ -1798,7 +1817,6 @@
 		return list.get(0).getThirdCreateTime();
 	}
 
-	
 	@Override
 	public List<CommonOrderVO> getOrderList(AcceptData acceptData, Integer page, Long uid, Integer state, Integer type,
 			Integer orderState, String orderNo, String startTime, String endTime, Integer dateType,
@@ -1832,9 +1850,7 @@
 		return commonOrderMapper.countOrderList(uid, state, type, orderState, orderNo, startTime, endTime, dateType,
 				listSource);
 	}
-	
-	
-	
+
 	/**
 	 * 璁㈠崟淇℃伅鍔犲伐
 	 * 
@@ -1860,7 +1876,7 @@
 					}
 				}
 			}
-			
+
 			Integer sourceType = order.getSourceType();
 			if (sourceType == null) {
 				continue;
@@ -1887,7 +1903,6 @@
 		if (listPDD.size() > 0) {
 			listRecordPDD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_PDD, listPDD);
 		}
-
 
 		SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
 		SimpleDateFormat formatday = new SimpleDateFormat("yyyy.MM.dd");
@@ -1979,7 +1994,6 @@
 				order.setReceiveTime("鏀惰揣鏃堕棿锛�" + format.format(settleTime));
 			}
 
-				
 			Map<String, String> orderStateMap = new HashMap<String, String>();
 			// 璁㈠崟鐘舵��
 			Integer orderState = order.getState();
@@ -1992,21 +2006,21 @@
 					orderState = buFenOrder.getState();
 				}
 			}
-			
+
 			// 鏄剧ず杩斿埄璇存槑杩炴帴> 鏈け鏁�
 			if (CommonOrder.STATE_SX != orderState
 					&& thirdCreateTime.getTime() > TimeUtil.convertDateToTemp(Constant.ORDER_SHOW_BRACE_TIME)) {
 				String rebateLink = configService.get(ConfigKeyEnum.orderRebateDescLink.getKey());
 				order.setRebateLink(rebateLink + "?orderNo=" + orderNo + "&sourceType=" + sourceType);
 			}
-						
+
 			// 绾㈠寘淇℃伅
-			List<HongBaoOrder> hongBaoOrderList = hongBaoOrderService.listDetailByOrderIdAndSourceTypeAndUid(orderNo, sourceType, uid);
+			List<HongBaoOrder> hongBaoOrderList = hongBaoOrderService.listDetailByOrderIdAndSourceTypeAndUid(orderNo,
+					sourceType, uid);
 			HongBaoCountVO hongBaoCountVO = hongBaoOrderService.getHongBaoCountVO(hongBaoOrderList);
 			BigDecimal hongBao = hongBaoCountVO.getValidMoney();
 			Integer hongBaoState = hongBaoCountVO.getCurrentState();
-						
-			
+
 			/* 璁㈠崟鐘舵�� 杞崲澶勭悊 */
 			String orderStateContent = "";
 			if (CommonOrder.STATE_FK == orderState) {
@@ -2019,7 +2033,8 @@
 				orderStateContent = "宸插敭鍚�";
 				if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
 					/* 璁㈠崟缁存潈 鍒ゆ柇鏄惁鍏ㄩ儴缁存潈 */
-					List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper.selectListByOrderIdAndState(order.getOrderNo(), "缁存潈鎴愬姛");
+					List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper
+							.selectListByOrderIdAndState(order.getOrderNo(), "缁存潈鎴愬姛");
 					BigDecimal weiQuanMoney = getWeiQuanMoney(listWQ, sourceType, uid);
 					hongBao = MoneyBigDecimalUtil.sub(hongBao, weiQuanMoney);
 				}
@@ -2038,9 +2053,9 @@
 				order.setOrderOrigin("1");
 				order.setHongBaoTypePic(CommonOrder.TYPE_FANLI);
 				signList.add(CommonOrder.TYPE_FANLI);
-				
+
 				// 鏄惁宸蹭娇鐢ㄥ鍔卞埜銆佸厤鍗曞埜鎯呭喌
-				 if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
+				if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
 					couponUseFactory(order, listRecordTB);
 				} else if (sourceType == Constant.SOURCE_TYPE_JD) {
 					couponUseFactory(order, listRecordJD);
@@ -2062,7 +2077,24 @@
 				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);
 
 			String hongBaoDate = null;
@@ -2104,7 +2136,6 @@
 			stateMap.put("content", stateContent);
 			stateMap.put("fontColor", stateFontColor);
 			order.setAccountState(stateMap);
-
 			hongbaoInfo = hongBaoState_Str + hongbaoInfo;
 
 			Map<String, String> hongBaoMap = new HashMap<String, String>();
@@ -2113,8 +2144,9 @@
 			order.setHongBaoInfo(hongBaoMap);
 
 			// 鍒嗕韩銆侀個璇� 闅愯棌璁㈠崟鍙�
-			if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType || HongBaoV2.TYPE_ERJI == hongBaoType
-					|| HongBaoV2.TYPE_SHARE_YIJI == hongBaoType || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
+			if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
+					|| HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType
+					|| HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
 				order.setOrderNo(UserUtil.filterOrderId(order.getOrderNo()));
 			}
 		}
@@ -2150,7 +2182,7 @@
 					if (UserSystemCouponRecord.STATE_FREE_ON == state) {
 						text = "鍏嶅崟涓�";
 					} else if (UserSystemCouponRecord.STATE_SUCCESS == state) {
-						text = "鍏嶅崟鎴愬姛";
+						text = "宸插厤鍗�";
 					} 
 				}
 				break;

--
Gitblit v1.8.0