From 3ce9e928e082ff8abf697dba560cbfbb412e89f8 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期一, 11 十一月 2019 15:45:02 +0800
Subject: [PATCH] 商城后台编辑

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetPayServiceImpl.java |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetPayServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetPayServiceImpl.java
index 5ec9351..c18a993 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetPayServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetPayServiceImpl.java
@@ -73,6 +73,50 @@
 			updateSelectiveByPrimaryKey(pay);
 		}
 	}
+	
+	@Override
+	public void saveObject(BanLiShopGoodsSetsPay record) throws BanLiShopGoodsSetPayException {
+		// 鍒ゆ柇鍙傛暟鏄惁榻愬叏
+		if (record.getGoodsSet() == null || record.getGoodsSet().getId() == null)
+			throw new BanLiShopGoodsSetPayException(1, "濂楅涓嶅瓨鍦�");
+
+		if (record.getPayType() == null)
+			throw new BanLiShopGoodsSetPayException(1, "璇锋寚瀹氭敮浠樻柟寮�");
+
+		if (record.getPayType() == BanLiShopGoodsSetsPay.PAY_TYPE_HONGBAO) {
+			if (record.getHongBaoPrice() == null)
+				throw new BanLiShopGoodsSetPayException(1, "璇锋寚瀹氱孩鍖呮敮浠樹环鏍�");
+		} else if (record.getPayType() == BanLiShopGoodsSetsPay.PAY_TYPE_BALANCE) {
+			if (record.getBalancePrice() == null)
+				throw new BanLiShopGoodsSetPayException(1, "璇锋寚瀹氫綑棰濇敮浠樹环鏍�");
+		} else if (record.getPayType() == BanLiShopGoodsSetsPay.PAY_TYPE_HONGBAO_MONEY) {
+			if (record.getHongBaoPrice() == null || record.getMoneyPrice() == null)
+				throw new BanLiShopGoodsSetPayException(1, "璇锋寚瀹氱孩鍖呫�佺幇閲戞敮浠樹环鏍�");
+		} else if (record.getPayType() == BanLiShopGoodsSetsPay.PAY_TYPE_MONEY) {
+			if (record.getMoneyPrice() == null)
+				throw new BanLiShopGoodsSetPayException(1, "璇锋寚瀹氱幇閲戞敮浠樹环鏍�");
+		}
+
+		record.setUpdateTime(new Date());
+		if (record.getId() == null) {
+			record.setCreateTime(new Date());
+			banLiShopGoodsSetsPayMapper.insertSelective(record);
+
+			if (record.getWeight() == null) {// 鏉冮噸鏇存柊
+				BanLiShopGoodsSetsPay update = new BanLiShopGoodsSetsPay();
+				update.setId(record.getId());
+				update.setWeight((int) record.getId().longValue());
+				banLiShopGoodsSetsPayMapper.updateByPrimaryKeySelective(update);
+			}
+		} else {
+			BanLiShopGoodsSetsPay resultObj = banLiShopGoodsSetsPayMapper.selectByPrimaryKey(record.getId());
+			if (resultObj == null)
+				throw new BanLiShopGoodsSetPayException(1, "淇敼鍐呭宸蹭笉瀛樺湪");
+			
+			record.setCreateTime(resultObj.getCreateTime());
+			banLiShopGoodsSetsPayMapper.updateByPrimaryKey(record);
+		}
+	}
 
 	@Override
 	public void updateSelectiveByPrimaryKey(BanLiShopGoodsSetsPay pay) {

--
Gitblit v1.8.0