From 28cf328a098334b51a3e9d2d56f983fb8c862211 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期六, 23 五月 2020 09:54:38 +0800
Subject: [PATCH] 足迹、收藏订单兼容新需求

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonGoodsServiceImpl.java |   90 +++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 86 insertions(+), 4 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonGoodsServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonGoodsServiceImpl.java
index 71eea30..bc95171 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonGoodsServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonGoodsServiceImpl.java
@@ -1,16 +1,18 @@
 package com.yeshi.fanli.service.impl.goods;
 
 import java.util.Date;
+import java.util.List;
 
 import javax.annotation.Resource;
 
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.yeshi.utils.StringUtil;
 
 import com.yeshi.fanli.dao.mybatis.goods.CommonGoodsMapper;
+import com.yeshi.fanli.entity.goods.CommonGoods;
 import com.yeshi.fanli.exception.goods.CommonGoodsException;
-import com.yeshi.fanli.goods.CommonGoods;
 import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
-import com.yeshi.fanli.util.StringUtil;
 
 @Service
 public class CommonGoodsServiceImpl implements CommonGoodsService {
@@ -18,6 +20,14 @@
 	@Resource
 	private CommonGoodsMapper commonGoodsMapper;
 
+	
+	@Override
+	public CommonGoods selectByPrimaryKey(Long id) {
+		return commonGoodsMapper.selectByPrimaryKey(id);
+	}
+	
+	
+	
 	/**
 	 * 楠岃瘉鏁版嵁姝g‘鎬�
 	 * 
@@ -52,7 +62,9 @@
 
 	@Override
 	public CommonGoods addOrUpdateCommonGoods(CommonGoods commonGoods) throws CommonGoodsException {
+		// 楠岃瘉鏁版嵁瀹屾暣鎬�
 		filterCommonGoods(commonGoods);
+		
 		CommonGoods goods = commonGoodsMapper.selectByGoodsIdAndGoodsType(commonGoods.getGoodsId(),
 				commonGoods.getGoodsType());
 		if (goods != null) {
@@ -65,11 +77,31 @@
 		commonGoodsMapper.insertSelective(commonGoods);
 		return commonGoods;
 	}
+	
+	
+	@Override
+	public CommonGoods addCommonGoods(CommonGoods commonGoods) throws CommonGoodsException {
+		// 楠岃瘉鏁版嵁瀹屾暣鎬�
+		filterCommonGoods(commonGoods);
+		
+		CommonGoods goods = commonGoodsMapper.selectByGoodsIdAndGoodsType(commonGoods.getGoodsId(),
+				commonGoods.getGoodsType());
+		if (goods != null) {
+			commonGoods.setId(goods.getId());
+			return commonGoods;
+		}
+		commonGoods.setCreateTime(new Date());
+		commonGoods.setUpdateTime(new Date());
+		commonGoodsMapper.insertSelective(commonGoods);
+		return commonGoods;
+	}
+
 
 	@Override
 	public void updateCommonGoods(CommonGoods commonGoods) throws CommonGoodsException {
 		// 鍒ゆ柇淇℃伅鏄惁瀹屾暣
 		filterCommonGoods(commonGoods);
+		
 		CommonGoods goods = commonGoodsMapper.selectByGoodsIdAndGoodsType(commonGoods.getGoodsId(),
 				commonGoods.getGoodsType());
 		if (goods == null) {
@@ -83,7 +115,7 @@
 	}
 
 	@Override
-	public void offlineCommonGoods(Long goodsId, int goodsType) {
+	public void offlineCommonGoods(Long goodsId, Integer goodsType) {
 		CommonGoods goods = commonGoodsMapper.selectByGoodsIdAndGoodsType(goodsId, goodsType);
 		if (goods == null)
 			return;
@@ -95,8 +127,58 @@
 	}
 
 	@Override
-	public CommonGoods getCommonGoodsByGoodsIdAndGoodsType(Long goodsId, int goodsType) {
+	public CommonGoods getCommonGoodsByGoodsIdAndGoodsType(Long goodsId, Integer goodsType) {
 		return commonGoodsMapper.selectByGoodsIdAndGoodsType(goodsId, goodsType);
 	}
 
+	@Override
+	@Transactional
+	public void updateBatchCommonGoods(List<CommonGoods> listCommonGoods) {
+		
+		if (listCommonGoods == null || listCommonGoods.size() == 0) {
+			return;
+		}
+		
+		for (CommonGoods commonGoods: listCommonGoods) {
+			try {
+				updateCommonGoods(commonGoods);
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+	}
+	
+	@Override
+	@Transactional
+	public void addBatchCommonGoods(List<CommonGoods> listCommonGoods) {
+		
+		if (listCommonGoods == null || listCommonGoods.size() == 0) {
+			return;
+		}
+		
+		for (CommonGoods commonGoods: listCommonGoods) {
+			try {
+				addCommonGoods(commonGoods);
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+	}
+	
+	
+	@Override
+	public List<CommonGoods> listBySellerId(Long sellerId, Integer goodsType) {
+		return commonGoodsMapper.listBySellerId(sellerId, goodsType);
+	} 
+	
+	@Override
+	public long countBySellerIdAndHasCoupon(Long sellerId, Integer goodsType) {
+		return commonGoodsMapper.countBySellerIdAndHasCoupon(sellerId, goodsType);
+	}
+	
+	@Override
+	public List<CommonGoods> getByListGoodsId(List<Long> list, Integer goodsType) {
+		return commonGoodsMapper.getByListGoodsId(list, goodsType);
+	}
+	
 }

--
Gitblit v1.8.0