From b7b8f2a4fe9059ef7b5470a68bb1b34787bc92b2 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期二, 25 六月 2019 09:14:46 +0800
Subject: [PATCH] 淘礼金相关

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java |   79 +++++++++++++++++++++++++++------------
 1 files changed, 55 insertions(+), 24 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java
index 404f06c..90e1c1a 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialServiceImpl.java
@@ -68,7 +68,12 @@
 		if (name == null || name.trim().length() == 0) {
 			throw new SpecialException(1, "涓撻鍚嶇О涓嶈兘涓虹┖");
 		}
-
+		
+		Integer sex = record.getSex();
+		if (sex == null) {
+			throw new SpecialException(1, "鎬у埆涓嶈兘涓虹┖");
+		}
+		
 		String params = record.getParams();
 		if (params == null || params.trim().length() == 0 || "null".equalsIgnoreCase(params)) {
 			record.setParams(null);
@@ -76,6 +81,8 @@
 			throw new SpecialException(1, "璺宠浆鍙傛暟闈濲SON鏍煎紡");
 		}
 
+		
+		
 		if (!StringUtil.isNullOrEmpty(jumpType)) {
 			List<JumpDetailV2> listByType = jumpDetailV2Service.listByType(jumpType);
 			if (listByType != null && listByType.size() > 0) {
@@ -111,10 +118,12 @@
 			record.setIcon(icon);
 			record.setPicture(picture);
 			record.setSubPicture(subPicture);
-
-			int maxOrder = specialMapper.getMaxOrderByCard(cardId);
-			record.setOrderby(maxOrder + 1);
-
+			
+			// 鎺掑簭
+			record.setOrderby(specialMapper.getDefaultMaxOrder(cardId) + 1);
+			record.setOrderMan(specialMapper.getManMaxOrder(cardId) + 1);
+			record.setOrderWoman(specialMapper.getWomanMaxOrder(cardId) + 1);
+			
 			record.setCreatetime(new Date());
 			record.setUpdatetime(new Date());
 			specialMapper.insert(record);
@@ -168,9 +177,12 @@
 			} else {
 				record.setIcon(resultObj.getIcon());
 			}
-
+			
 			record.setOrderby(resultObj.getOrderby());
+			record.setOrderMan(resultObj.getOrderMan());
+			record.setOrderWoman(resultObj.getOrderWoman());
 			record.setCreatetime(resultObj.getCreatetime());
+			
 			record.setUpdatetime(new Date());
 			specialMapper.updateByPrimaryKey(record);
 		}
@@ -212,9 +224,9 @@
 
 	@Override
 	@Transactional
-	public void updateOrder(Long id, Integer moveType) throws SpecialException {
+	public void updateOrder(Long id, Integer moveType, Integer sex) throws SpecialException {
 
-		if (id == null || moveType == null || (!moveType.equals(1) && !moveType.equals(-1))) {
+		if (id == null || moveType == null || (!moveType.equals(1) && !moveType.equals(-1)) || sex == null) {
 			throw new SpecialException(1, "璇蜂紶閫掓纭弬鏁�");
 		}
 
@@ -223,22 +235,41 @@
 			throw new SpecialException(1, "姝ゅ唴瀹瑰凡涓嶅瓨鍦�");
 		}
 
-		Integer order = resultObj.getOrderby();
 		Long cardId = resultObj.getCardId();
-
 		// 鑾峰彇浜ゆ崲瀵硅薄
-		Special exchangeObject = specialMapper.getOrderByCardID(cardId, moveType, order);
-		if (exchangeObject == null) {
-			if (moveType == 1) {
-				throw new SpecialException(1, "鍦ㄧ浉鍚屼娇鐢ㄥ湴鏂逛腑浼樺厛绾у凡缁忔渶浣庝簡");
-			} else {
-				throw new SpecialException(1, "鍦ㄧ浉鍚屼娇鐢ㄥ湴鏂逛腑浼樺厛绾у凡缁忔渶楂樹簡");
+		Special exchangeObject = null;
+		if (Special.SEX_ALL == sex || Special.SEX_DEFAULT == sex) {
+			Integer orderby = resultObj.getOrderby();
+			exchangeObject = specialMapper.getOrderByCardID(cardId, moveType, orderby, sex);
+			if (exchangeObject == null) {
+				throw new SpecialException(1, "娌℃湁鎵惧埌鍙氦鎹㈢殑浣嶇疆");
 			}
+			
+			resultObj.setOrderby(exchangeObject.getOrderby());
+			exchangeObject.setOrderby(orderby);
+		} else if (Special.SEX_MAN == sex ) {
+			Integer orderMan = resultObj.getOrderMan();
+			exchangeObject = specialMapper.getOrderByCardID(cardId, moveType, orderMan, sex);
+			if (exchangeObject == null) {
+				throw new SpecialException(1, "娌℃湁鎵惧埌鍙氦鎹㈢殑浣嶇疆");
+			}
+			
+			resultObj.setOrderMan(exchangeObject.getOrderMan());
+			exchangeObject.setOrderMan(orderMan);
+		} else if (Special.SEX_WOMAN == sex ) {
+			Integer orderWoman = resultObj.getOrderWoman();
+			exchangeObject = specialMapper.getOrderByCardID(cardId, moveType, orderWoman, sex);
+			
+			if (exchangeObject == null) {
+				throw new SpecialException(1, "娌℃湁鎵惧埌鍙氦鎹㈢殑浣嶇疆");
+			}
+			
+			resultObj.setOrderWoman(exchangeObject.getOrderWoman());
+			exchangeObject.setOrderWoman(orderWoman);
+		} else {
+			throw new SpecialException(1, "sex鍙傛暟涓嶆纭�");
 		}
-
-		resultObj.setOrderby(exchangeObject.getOrderby());
-		exchangeObject.setOrderby(order);
-
+		
 		specialMapper.updateByPrimaryKey(resultObj);
 		specialMapper.updateByPrimaryKey(exchangeObject);
 	}
@@ -280,9 +311,9 @@
 	}
 
 	@Override
-	public List<Special> listQueryByCard(long start, int count, Long card, String key) {
+	public List<Special> listQueryByCard(long start, int count, Long card, String key, Integer sex) {
 
-		List<Special> list = specialMapper.listQueryByCard(start, count, card, key);
+		List<Special> list = specialMapper.listQueryByCard(start, count, card, key, sex);
 		if (list == null || list.size() == 0) {
 			return list;
 		}
@@ -312,8 +343,8 @@
 	}
 
 	@Override
-	public long countlistQueryByCard(Long card, String key) {
-		return specialMapper.countlistQueryByCard(card, key);
+	public long countlistQueryByCard(Long card, String key, Integer sex) {
+		return specialMapper.countlistQueryByCard(card, key, sex);
 	}
 
 	@Override

--
Gitblit v1.8.0