From f4a0f2acc63d7785eab108419a4e16f5f688cb95 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期六, 18 一月 2020 12:06:27 +0800
Subject: [PATCH] 用户注册信息

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetServiceImpl.java |   63 +++++++++++++++++++++++++++----
 1 files changed, 55 insertions(+), 8 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 634d06c..de3ff95 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,6 +98,44 @@
 		}
 
 	}
+	
+	
+	@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 updateSelectiveByPrimaryKey(BanLiShopGoodsSets set) {
@@ -126,16 +164,25 @@
 				banLiShopGoodsSetPayService.deleteByPrimaryKey(pay.getId());
 			}
 	}
-	
-	
+
 	@Override
-	public List<BanLiShopGoodsSets> listQuery(int page, int pageSize, String key) {
-		return banLiShopGoodsSetsMapper.listQuery((page - 1) * pageSize, pageSize, key);
+	public List<BanLiShopGoodsSets> listQuery(int page, int pageSize, String key, Long goodsId) {
+		return banLiShopGoodsSetsMapper.listQuery((page - 1) * pageSize, pageSize, key, goodsId);
 	}
-	
+
 	@Override
-	public long countQuery(String key) {
-		return banLiShopGoodsSetsMapper.countQuery(key);
+	public long countQuery(String key, Long goodsId) {
+		return banLiShopGoodsSetsMapper.countQuery(key, goodsId);
+	}
+
+	@Override
+	public void addSalesCount(Long id, int count) {
+		BanLiShopGoodsSets set = banLiShopGoodsSetsMapper.selectByPrimaryKey(id);
+		BanLiShopGoodsSets update = new BanLiShopGoodsSets();
+		update.setId(set.getId());
+		update.setSalesCount(set.getSalesCount() + count);
+		update.setStock(set.getStock() - count);
+		banLiShopGoodsSetsMapper.updateByPrimaryKeySelective(update);		
 	}
 
 }

--
Gitblit v1.8.0