From 98b1a0affd69bbe63223c21fdd2c404e8bedfccb Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 20 五月 2020 17:25:08 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into 2.1.2

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetServiceImpl.java |   62 ++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 1 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetServiceImpl.java
index 4d8a42f..8d09e1c 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetServiceImpl.java
@@ -41,7 +41,7 @@
 		return banLiShopGoodsSetsMapper.selectByPrimaryKey(id);
 	}
 
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	@Override
 	public void addSet(BanLiShopGoodsSets set) throws BanLiShopGoodsSetException, BanLiShopGoodsSetPayException {
 		if (set.getId() == null)// 娣诲姞
@@ -98,7 +98,67 @@
 		}
 
 	}
+	
+	
+	@Override
+	public void saveObject(BanLiShopGoodsSets record) throws BanLiShopGoodsSetException {
+		if (record.getGoods() == null || record.getGoods().getId() == null)
+			throw new BanLiShopGoodsSetException(1, "璇锋寚瀹氬晢鍝�");
 
+		if (StringUtil.isNullOrEmpty(record.getName()))
+			throw new BanLiShopGoodsSetException(1, "缂哄皯濂楅鍚嶅瓧");
+
+		if (record.getOriginalPrice() == null || record.getZkPrice() == null)
+			throw new BanLiShopGoodsSetException(1, "浠锋牸淇℃伅涓嶅畬鏁�");
+
+		if (record.getStock() == null)
+			throw new BanLiShopGoodsSetException(1, "缂哄皯搴撳瓨淇℃伅");
+
+		record.setUpdateTime(new Date());
+		if (record.getId() == null) {
+			record.setCreateTime(new Date());
+			banLiShopGoodsSetsMapper.insertSelective(record);
+			
+			if (record.getWeight() == null) {// 鏉冮噸鏇存柊
+				BanLiShopGoodsSets update = new BanLiShopGoodsSets();
+				update.setId(record.getId());
+				update.setWeight((int) record.getId().longValue());
+				banLiShopGoodsSetsMapper.updateByPrimaryKeySelective(update);
+			}
+		} else {
+			BanLiShopGoodsSets resultObj = banLiShopGoodsSetsMapper.selectDetailByPrimaryKey(record.getId());
+			if (resultObj == null)
+				throw new BanLiShopGoodsSetException(1, "淇敼鍐呭宸蹭笉瀛樺湪");
+			
+			record.setCreateTime(resultObj.getCreateTime());
+			banLiShopGoodsSetsMapper.updateByPrimaryKey(record);
+		}
+	}
+	
+
+	@Override
+	public void switchState(Long id) throws BanLiShopGoodsSetException {
+		if (id == null) {
+			throw new BanLiShopGoodsSetException(1, "璇蜂紶閫掓纭弬鏁�");
+		}
+		BanLiShopGoodsSets resultObj = banLiShopGoodsSetsMapper.selectByPrimaryKey(id);
+		if (resultObj == null) {
+			throw new BanLiShopGoodsSetException(1, "姝ゅ唴瀹瑰凡涓嶅瓨鍦�");
+		}
+		
+		Integer state = resultObj.getState();
+		if (state == null || state == 0) {
+			state = 1;
+		} else {
+			state = 0;
+		}
+		
+		BanLiShopGoodsSets updateObj = new BanLiShopGoodsSets();
+		updateObj.setId(id);
+		updateObj.setState(state);
+		banLiShopGoodsSetsMapper.updateByPrimaryKeySelective(updateObj);
+	}
+	
 	@Override
 	public void updateSelectiveByPrimaryKey(BanLiShopGoodsSets set) {
 		if (set.getId() == null)

--
Gitblit v1.8.0