From 88b54772dbcf5ecab1e2316e4e4626ac901b8908 Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期二, 22 一月 2019 15:58:24 +0800
Subject: [PATCH] 邀请码添加返回状态

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java |  263 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 235 insertions(+), 28 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 0edf0fb..f6f6363 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
@@ -13,6 +13,7 @@
 import org.apache.commons.beanutils.PropertyUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.yeshi.utils.taobao.TbImgUtil;
 
 import com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper;
 import com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper;
@@ -29,6 +30,7 @@
 import com.yeshi.fanli.service.inter.order.CommonOrderService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.MoneyBigDecimalUtil;
+import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.factory.CommonOrderGoodsFactory;
 import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
@@ -81,15 +83,14 @@
 	public List<CommonOrderVO> listGroupOrderNoByUid(long start, int count, Long uid, Integer state, Integer type,
 			Integer orderState, String orderNo, String startTime, String endTime, Integer dateType)
 			throws CommonOrderException {
-		return commonOrderMapper.listGroupOrderNoByUid(start, count, uid, state, type, orderState, orderNo, startTime,
-				endTime, dateType);
+		return commonOrderMapper.listUserOrder(start, count, uid, state, type, orderState, orderNo, startTime, endTime,
+				dateType);
 	}
 
 	@Override
 	public long countGroupOrderNoByUid(Long uid, Integer state, Integer type, Integer orderState, String orderNo,
 			String startTime, String endTime, Integer dateType) throws CommonOrderException {
-		return commonOrderMapper.countGroupOrderNoByUid(uid, state, type, orderState, orderNo, startTime, endTime,
-				dateType);
+		return commonOrderMapper.countUserOrder(uid, state, type, orderState, orderNo, startTime, endTime, dateType);
 	}
 
 	@Override
@@ -108,31 +109,37 @@
 		}
 
 		// 鍟嗗搧淇℃伅
-		List<CommonOrderVO> listGoods = commonOrderMapper.listByOrderNoAndType(listOrder);
+		List<CommonOrderVO> listGoods = commonOrderMapper.listOrderGoodsInfo(listOrder);
 		// 璁㈠崟鍟嗗搧涓虹┖
 		if (listGoods == null || listGoods.size() == 0) {
 			return listOrder;
 		}
 
 		// 鏁版嵁鍔犲伐閲嶆柊缁勭粐
-		listDataFactory(listOrder, listGoods);
+		listDataFactory(listOrder, listGoods, uid);
 
 		return listOrder;
 	}
 
 	@Override
-	public Map<String, BigDecimal> countOrderByHongBaoType(Long uid, Integer day) {
-		return commonOrderMapper.countOrderByHongBaoType(uid, day);
+	public Map<String, BigDecimal> countHistoryOrder(Long uid, Integer day) {
+		return commonOrderMapper.countHistoryOrder(uid, day);
 	}
 
 	@Override
-	public long countOrder(Long uid, Integer type, Integer day) {
-		return commonOrderMapper.countBonusOrder(uid, type, day);
+	public long countBonusOrderNumber(Long uid, Integer type, Integer day, String startTime, String endTime) {
+		return commonOrderMapper.countBonusOrderNumber(uid, type, day, startTime, endTime);
 	}
 
 	@Override
-	public BigDecimal countOrderMoney(Long uid, Integer type, Integer day) {
-		return commonOrderMapper.countBonusOrderMoney(uid, type, day);
+	public BigDecimal countBonusOrderMoney(Long uid, Integer type, Integer day, String startTime, String endTime) {
+		return commonOrderMapper.countBonusOrderMoney(uid, type, day, startTime, endTime);
+	}
+	
+	@Override
+	public Map<String, Object> countBonusOrderMoneyAndNumber(Long uid, Integer type, Integer day, 
+			String startTime, String endTime) {
+		return commonOrderMapper.countBonusOrderMoneyAndNumber(uid, type, day, startTime, endTime);
 	}
 
 	@Override
@@ -141,7 +148,7 @@
 		return commonOrderMapper.countByUidAndOrderState(uid, type, startTime, endTime, day);
 	}
 
-	public void listDataFactory(List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods) {
+	public void listDataFactory(List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods, Long uid) {
 
 		/* 缁勫悎鍟嗗搧淇℃伅 */
 		for (CommonOrderVO commonOrder : listGoods) {
@@ -170,6 +177,11 @@
 						e.printStackTrace();
 					}
 
+					String picture = commonGoodsVO.getPicture();
+					if (!StringUtil.isNullOrEmpty(picture) && !picture.contains("320x320")) {
+						commonGoodsVO.setPicture(TbImgUtil.getTBSize320Img(picture));
+					}
+					
 					Integer hongBaoType = order.getHongBaoType();
 					// 閭�璇疯鍗曚俊鎭繚鎶�
 					if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
@@ -185,14 +197,14 @@
 
 					// 璐拱鏁伴噺
 					commonGoodsVO.setActualCount(commonOrder.getTotalCount() + "浠�");
-					
+
 					BigDecimal totalSettlement = commonOrder.getTotalSettlement();
 					if (totalSettlement == null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) {
 						totalSettlement = commonOrder.getTotalPayment();
 					}
 					// 瀹炰粯娆�
 					commonGoodsVO.setActualPay("瀹炰粯娆撅細楼" + totalSettlement);
-					
+
 					listOrderGoods.add(commonGoodsVO);
 
 					Integer orderType = commonOrder.getOrderType();
@@ -214,14 +226,11 @@
 		SimpleDateFormat formatday = new SimpleDateFormat("yyyy.MM.dd");
 
 		for (CommonOrderVO order : listOrder) {
-			Date createTime = order.getCreateTime();
-			if (createTime != null) {
-				order.setObtainTime(createTime.getTime());
-			}
 
 			Date thirdCreateTime = order.getThirdCreateTime();
 			if (thirdCreateTime != null) {
 				order.setDownTime("涓嬪崟鏃堕棿锛�" + format.format(thirdCreateTime));
+				order.setObtainTime(thirdCreateTime.getTime());
 			}
 
 			Date settleTime = order.getSettleTime();
@@ -232,10 +241,25 @@
 			/* 璁㈠崟鐘舵�� 杞崲澶勭悊 */
 			String orderStateContent = "";
 			Map<String, String> orderStateMap = new HashMap<String, String>();
-
-			Integer hongBaoState = order.getHongBaoState();
-
+			
+			// 璁㈠崟鐘舵��
 			Integer orderState = order.getState();
+			// 绾㈠寘鐘舵��
+			Integer hongBaoState = order.getHongBaoState();
+			
+			Integer stateWholeOrder = order.getStateWholeOrder();
+			if (CommonOrder.STATE_WHOLE_ORDER_BUFENYOUXIAO == stateWholeOrder) {
+				// 鏁翠釜璁㈠崟閮ㄥ垎澶辨晥锛氬垽鏂湡瀹炵姸鎬� 璁㈠崟銆佺孩鍖�
+				CommonOrderVO buFenOrder = commonOrderMapper.getBuFenOrderState(uid, order.getOrderNo());
+				if (buFenOrder != null) {
+					// 鏈夋晥鐨勮鍗曠姸鎬�
+					orderState = buFenOrder.getState();
+					// 鏈夋晥鐨勭孩鍖呯姸鎬�
+					hongBaoState = buFenOrder.getHongBaoState();
+				}
+			} 
+			
+			
 			if (CommonOrder.STATE_FK == orderState) {
 				orderStateContent = "宸蹭粯娆�";
 			} else if (CommonOrder.STATE_JS == orderState) {
@@ -369,6 +393,23 @@
 	@Override
 	public List<CommonOrder> addTaoBaoOrder(List<TaoBaoOrder> taoBaoOrders, Long uid) throws CommonOrderException {
 		List<CommonOrder> commonOrderList = new ArrayList<>();
+		// 鍒ゆ柇鎵�鏈夌殑璁㈠崟鐘舵��
+		int invalidCount = 0;
+		for (TaoBaoOrder tb : taoBaoOrders) {
+			if ("璁㈠崟澶辨晥".equalsIgnoreCase(tb.getOrderState())) {
+				invalidCount++;
+			}
+		}
+
+		// 鑾峰彇鏁翠綋璁㈠崟鐨勭姸鎬�
+		int wholeOrderState = 0;
+		if (taoBaoOrders.size() == invalidCount)
+			wholeOrderState = CommonOrder.STATE_WHOLE_ORDER_SHIXIAO;
+		else if (invalidCount == 0)
+			wholeOrderState = CommonOrder.STATE_WHOLE_ORDER_YOUXIAO;
+		else
+			wholeOrderState = CommonOrder.STATE_WHOLE_ORDER_BUFENYOUXIAO;
+
 		for (TaoBaoOrder taoBaoOrder : taoBaoOrders) {
 			CommonOrder commonOrder = commonOrderMapper.selectByOrderNoAndOrderTypeAndOrderBy(taoBaoOrder.getOrderId(),
 					Constant.SOURCE_TYPE_TAOBAO, taoBaoOrder.getOrderBy());
@@ -378,6 +419,7 @@
 				CommonOrderGoods goods = new CommonOrderGoods();
 				goods.setGoodsId(taoBaoOrder.getAuctionId() + "");
 				goods.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
+
 				// 鍟嗗搧鏄惁宸茬粡鎻掑叆
 				List<CommonOrderGoods> commonGoodsList = commonOrderGoodsMapper
 						.listByGoodsIdAndGoodsType(goods.getGoodsId(), goods.getGoodsType());
@@ -400,6 +442,7 @@
 				commonOrder.setCommonOrderGoods(goods);
 				commonOrder.setUserInfo(new UserInfo(uid));
 				commonOrder.setCreateTime(new Date());
+				commonOrder.setStateWholeOrder(wholeOrderState);
 				commonOrderMapper.insertSelective(commonOrder);
 
 				commonOrderList.add(commonOrder);
@@ -418,6 +461,7 @@
 				updateCommonOrder.setSettlement(newCommonOrder.getSettlement());
 				updateCommonOrder.setSettleTime(newCommonOrder.getSettleTime());
 				updateCommonOrder.setState(newCommonOrder.getState());
+				updateCommonOrder.setStateWholeOrder(wholeOrderState);
 				updateCommonOrder.setUpdateTime(new Date());
 				commonOrderMapper.updateByPrimaryKeySelective(updateCommonOrder);
 				commonOrderList.add(commonOrderMapper.selectByPrimaryKey(updateCommonOrder.getId()));
@@ -428,14 +472,177 @@
 	}
 
 	@Override
-	public Map<String, Object> countMoneyGroupOrderNoByUid(Long uid, Integer type, String orderNo, String startTime,
-			String endTime, Integer day) {
-		return commonOrderMapper.countMoneyGroupOrderNoByUid(uid, type, orderNo, startTime, endTime, day);
+	public long countByUidAndOrderStateWithOrderBalanceTime(Long uid, int state, Date minDate, Date maxDate) {
+		return commonOrderMapper.countByUidAndOrderStateWithOrderBalanceTime(uid, state, minDate, maxDate);
+	}
+	
+	
+	@Override
+	public List<CommonOrderVO> listQueryByUid(long start, int count, Long uid, Integer state, Integer type,
+			Integer orderState, String orderNo, String startTime, String endTime, Integer dateType)
+			throws CommonOrderException {
+		
+			
+		List<CommonOrderVO> list = commonOrderMapper.listQueryByUid(start, count, uid, state, type, 
+				orderState, orderNo, startTime, endTime, dateType);
+		
+		if (list == null) {
+			list = new ArrayList<CommonOrderVO>();
+		}
+		
+		if (list.size() == 0) {
+			return list;
+		}
+		
+		SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+		for (CommonOrderVO order : list) {
+			
+			// 涓嬪崟鏃堕棿
+			Date thirdCreateTime = order.getThirdCreateTime();
+			if (thirdCreateTime != null) {
+				order.setDownTime(format.format(thirdCreateTime));
+			}
+			// 鏀惰揣鏃堕棿
+			Date settleTime = order.getSettleTime();
+			if (settleTime != null) {
+				order.setReceiveTime(format.format(settleTime));
+			}
+			
+			// 鍒拌处鏃堕棿
+			Date accountTime = order.getAccountTime();
+			if (accountTime != null) {
+				order.setHongBaoDate(format.format(accountTime));
+			}
+			
+			BigDecimal settlement = order.getSettlement();
+			if (settlement != null && settlement.compareTo(new BigDecimal(0)) > 0) {
+				order.setPayment(settlement); // 瀹為檯浠樻閲戦
+			}
+
+			/* 璁㈠崟杩斿埄绫诲瀷 杞崲 */
+			Integer hongBaoType = order.getHongBaoType();
+			if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) {
+				// 鑷喘
+				order.setHongBaoType(1);
+			} else if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType) {
+				// 鍒嗕韩
+				order.setHongBaoType(2);
+			} else if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
+					|| HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType
+					|| HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
+				// 閭�璇�
+				order.setHongBaoType(3);
+			}
+
+			Integer hongBaoState = order.getHongBaoState();
+			if (HongBaoV2.STATE_KELINGQU == hongBaoState || HongBaoV2.STATE_BUKELINGQU == hongBaoState) {
+				// 鏈埌璐�
+				order.setHongBaoState(1);
+
+			} else if (HongBaoV2.STATE_YILINGQU == hongBaoState) {
+				// 宸插埌璐�
+				order.setHongBaoState(2);
+
+			} else if (HongBaoV2.STATE_SHIXIAO == hongBaoState) {
+				// 宸插け鏁�
+				order.setHongBaoState(3);
+			}
+			
+		}
+		
+		return list;
+			
 	}
 
 	@Override
-	public long countByUidAndOrderStateWithOrderBalanceTime(Long uid, int state, Date minDate, Date maxDate) {
-
-		return commonOrderMapper.countByUidAndOrderStateWithOrderBalanceTime(uid, state, minDate, maxDate);
+	public long countQueryByUid(Long uid, Integer state, Integer type, Integer orderState, String orderNo,
+			String startTime, String endTime, Integer dateType) throws CommonOrderException {
+		return commonOrderMapper.countQueryByUid(uid, state, type, orderState, orderNo, startTime, endTime, dateType);
 	}
+	
+	
+	
+	@Override
+	public List<CommonOrderVO> listQuery(long start, int count, Integer keyType, String key, Integer state, 
+			Integer type, Integer orderState, String startTime, String endTime) throws CommonOrderException {
+		
+			
+		List<CommonOrderVO> list = commonOrderMapper.listQuery(start, count,keyType, key, state, type, 
+				orderState, startTime, endTime);
+		
+		
+		if (list == null) {
+			list = new ArrayList<CommonOrderVO>();
+		}
+		
+		if (list.size() == 0) {
+			return list;
+		}
+		
+		SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+		for (CommonOrderVO order : list) {
+			
+			// 涓嬪崟鏃堕棿
+			Date thirdCreateTime = order.getThirdCreateTime();
+			if (thirdCreateTime != null) {
+				order.setDownTime(format.format(thirdCreateTime));
+			}
+			// 鏀惰揣鏃堕棿
+			Date settleTime = order.getSettleTime();
+			if (settleTime != null) {
+				order.setReceiveTime(format.format(settleTime));
+			}
+			
+			// 鍒拌处鏃堕棿
+			Date accountTime = order.getAccountTime();
+			if (accountTime != null) {
+				order.setHongBaoDate(format.format(accountTime));
+			}
+			
+			BigDecimal settlement = order.getSettlement();
+			if (settlement != null && settlement.compareTo(new BigDecimal(0)) > 0) {
+				order.setPayment(settlement); // 瀹為檯浠樻閲戦
+			}
+
+			/* 璁㈠崟杩斿埄绫诲瀷 杞崲 */
+			Integer hongBaoType = order.getHongBaoType();
+			if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) {
+				// 鑷喘
+				order.setHongBaoType(1);
+			} else if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType) {
+				// 鍒嗕韩
+				order.setHongBaoType(2);
+			} else if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
+					|| HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType
+					|| HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
+				// 閭�璇�
+				order.setHongBaoType(3);
+			}
+
+			Integer hongBaoState = order.getHongBaoState();
+			if (HongBaoV2.STATE_KELINGQU == hongBaoState || HongBaoV2.STATE_BUKELINGQU == hongBaoState) {
+				// 鏈埌璐�
+				order.setHongBaoState(1);
+
+			} else if (HongBaoV2.STATE_YILINGQU == hongBaoState) {
+				// 宸插埌璐�
+				order.setHongBaoState(2);
+
+			} else if (HongBaoV2.STATE_SHIXIAO == hongBaoState) {
+				// 宸插け鏁�
+				order.setHongBaoState(3);
+			}
+			
+		}
+		
+		return list;
+			
+	}
+
+	@Override
+	public long countQuery(Integer keyType, String key, Integer state, Integer type, Integer orderState,
+			String startTime, String endTime) throws CommonOrderException {
+		return commonOrderMapper.countQuery(keyType, key, state, type, orderState, startTime, endTime);
+	}
+	
 }

--
Gitblit v1.8.0