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/lable/QualityFactoryServiceImpl.java | 1488 +++++++++++++++-------------------------------------------
 1 files changed, 399 insertions(+), 1,089 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/lable/QualityFactoryServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/lable/QualityFactoryServiceImpl.java
index 266345e..27267b7 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/lable/QualityFactoryServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/lable/QualityFactoryServiceImpl.java
@@ -3,22 +3,19 @@
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import javax.annotation.Resource;
-import javax.transaction.Transactional;
 
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import com.yeshi.fanli.dao.mybatis.TaoBaoClassRelationMapper;
 import com.yeshi.fanli.dao.mybatis.lable.LabelGoodsMapper;
 import com.yeshi.fanli.dao.mybatis.lable.QualityFactoryMapper;
 import com.yeshi.fanli.dao.mybatis.lable.QualityFlashSaleMapper;
 import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoGoodsBriefMapper;
-import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoGoodsBriefRecordMapper;
-import com.yeshi.fanli.entity.bus.clazz.TaoBaoClassRelation;
 import com.yeshi.fanli.entity.bus.lable.BoutiqueAutoRule;
 import com.yeshi.fanli.entity.bus.lable.Label;
 import com.yeshi.fanli.entity.bus.lable.LabelGoods;
@@ -26,20 +23,20 @@
 import com.yeshi.fanli.entity.bus.lable.QualityFlashSale;
 import com.yeshi.fanli.entity.common.AdminUser;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
-import com.yeshi.fanli.exception.QualityFactoryException;
+import com.yeshi.fanli.exception.goods.quality.QualityFactoryException;
 import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
-import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException;
 import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
 import com.yeshi.fanli.service.inter.lable.LabelService;
 import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
 import com.yeshi.fanli.service.inter.lable.QualityFlashSaleService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
-import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.RedisKeyEnum;
 import com.yeshi.fanli.util.RedisManager;
 import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.taobao.TaoBaoUtil;
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
+import com.yeshi.fanli.vo.quality.QualityFactoryVO;
 
 @Service
 public class QualityFactoryServiceImpl implements QualityFactoryService {
@@ -59,8 +56,6 @@
 	@Resource
 	private TaoBaoUnionConfigService taoBaoUnionConfigService;
 	@Resource
-	private TaoBaoGoodsBriefRecordMapper taoBaoGoodsBriefRecordMapper;
-	@Resource
 	private TaoBaoClassRelationMapper taoBaoClassRelationMapper;
 	@Resource
 	private QualityFlashSaleService qualityFlashSaleService;
@@ -71,108 +66,42 @@
 	private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
 
 	@Override
-	public int insert(QualityFactory record) throws QualityFactoryException {
-		return qualityFactoryMapper.insert(record);
-	}
-
-	@Override
-	public int updateByPrimaryKey(QualityFactory record) throws QualityFactoryException {
-		return qualityFactoryMapper.updateByPrimaryKey(record);
-	}
-
-	@Override
 	public int updateByPrimaryKeySelective(QualityFactory record) throws QualityFactoryException {
 		return qualityFactoryMapper.updateByPrimaryKeySelective(record);
 	}
+	
 
 	@Override
-	public int deleteByPrimaryKey(Long id) throws QualityFactoryException {
-		return qualityFactoryMapper.deleteByPrimaryKey(id);
-	}
-
-	@Override
-	public void deleteByTbAuctionId(Long auctionId) {
-
+	public void deleteByTaoBaoGoodsId(Long auctionId) {
 		if (auctionId == null) {
 			return;
 		}
-
-		List<TaoBaoGoodsBrief> tbgoods = taoBaoGoodsBriefMapper.queryByAuctionId(auctionId);
-		if (tbgoods != null && tbgoods.size() > 0) {
-			TaoBaoGoodsBrief taoBaoGoodsBrief = tbgoods.get(0);
-			try {
-				deleteByTaoBaoGoodsId(taoBaoGoodsBrief.getId());
-			} catch (QualityFactoryException e) {
-				e.printStackTrace();
-			}
-		}
-
-	}
-
-	@Override
-	public void deleteByTaoBaoGoodsId(Long gid) throws QualityFactoryException {
-
-		if (gid == null) {
-			return;
-		}
-
-		List<QualityFactory> list = qualityFactoryMapper.queryByGoodsId(gid);
-		if (list != null && list.size() > 0) {
-
-			// 鍒犻櫎闄愭椂鎶㈣喘
-			for (QualityFactory qualityFactory : list) {
-				qualityFlashSaleMapper.deleteByQualityID(qualityFactory.getId());
-			}
-
-			// 绉婚櫎绮鹃�夊簱
-			qualityFactoryMapper.deleteByGoodsId(gid);
-		}
-
+		// 绉婚櫎绮鹃�夊簱
+		qualityFactoryMapper.deleteByGoodsId(auctionId);
+		// 鍒犻櫎闄愭椂鎶㈣喘
+		qualityFlashSaleMapper.deleteByGoodsId(auctionId);
 		// 鍒犻櫎瀵瑰簲鏍囩
-		labelGoodsMapper.deleteByGoodsId(gid);
+		labelGoodsMapper.deleteByGoodsId(auctionId);
 	}
 
+
 	@Override
-	public void deleteBatchByTaoBaoGoodsId(List<Long> listGid) throws QualityFactoryException {
+	public void deleteBatchByTaoBaoGoodsId(List<Long> listGid) {
 
 		if (listGid == null || listGid.size() == 0) {
 			return;
 		}
-
-		List<QualityFactory> list = qualityFactoryMapper.listQueryGoodsByGoodsId(listGid);
-
-		if (list != null && list.size() > 0) {
-
-			List<Long> listFid = new ArrayList<Long>();
-			for (QualityFactory qualityFactory : list) {
-				listFid.add(qualityFactory.getId());
-			}
-
-			if (listFid.size() > 0) {
-				// 鎵归噺鍒犻櫎绮鹃�夊簱
-				qualityFactoryMapper.deleteBatchByPrimaryKey(listFid);
-				// 鎵归噺鍒犻櫎闄愭椂鎶㈣喘
-				qualityFlashSaleMapper.deleteBatchByQualityID(listFid);
-			}
-		}
-
+		// 鎵归噺鍒犻櫎绮鹃�夊簱
+		qualityFactoryMapper.deleteBatchByGoodsId(listGid);
+		// 鎵归噺鍒犻櫎闄愭椂鎶㈣喘
+		qualityFlashSaleMapper.deleteBatchByQualityID(listGid);
 		// 鍒犻櫎瀵瑰簲鏍囩
 		labelGoodsMapper.deleteBatchByGoodsId(listGid);
 	}
 
+	
 	@Override
-	@Transactional
-	public void deleteBatchByPrimaryKey(List<String> ids) throws QualityFactoryException {
-
-		if (ids != null) {
-			for (String id : ids) {
-				qualityFactoryMapper.deleteByPrimaryKey(Long.parseLong(id));
-			}
-		}
-	}
-
-	@Override
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	public void deleteByGoodsId(List<String> ids) throws QualityFactoryException {
 
 		if (ids != null && ids.size() > 0) {
@@ -183,18 +112,12 @@
 	}
 
 	@Override
-	public int removeStorageGoods(String doTime, Long gcids) throws QualityFactoryException {
-		return qualityFactoryMapper.removeStorageGoods(doTime, gcids);
-	}
-
-	@Override
 	public QualityFactory selectByPrimaryKey(Long id) throws QualityFactoryException {
 		return qualityFactoryMapper.selectByPrimaryKey(id);
 	}
 
 	@Override
-	public List<Long> getAuctionIdbyClassId(Long systemCid, Integer goodsSource, String dateTime)
-			throws QualityFactoryException {
+	public List<Long> getAuctionIdbyClassId(Long systemCid, Integer goodsSource, String dateTime){
 		return qualityFactoryMapper.getAuctionIdbyClassId(systemCid, goodsSource, dateTime);
 	}
 
@@ -204,29 +127,13 @@
 	}
 
 	@Override
-	public List<QualityFactory> query(long start, int count, String key, Integer totalSales, Integer price,
-			Integer tkRate, Integer propor, Integer goodsSource, Integer days, Integer startZkPrice, Integer endZkPrice,
-			Integer startBiz30day, Integer endBiz30day, Integer startWeight, Integer endWeight, Integer startTkRate,
-			Integer endTkRate, Integer startAmount, Integer endAmount, Integer hasCoupon, Integer freeShipment,
-			Integer isPrepay, Integer payRate30, Integer goodRate, Integer rfdRate, Integer startPropor,
-			Integer endPropor, Long gcid, Integer keyType) throws QualityFactoryException {
-
-		return qualityFactoryMapper.query(start, count, key, totalSales, price, tkRate, propor, goodsSource, days,
-				startZkPrice, endZkPrice, startBiz30day, endBiz30day, startWeight, endWeight, startTkRate, endTkRate,
-				startAmount, endAmount, hasCoupon, freeShipment, isPrepay, payRate30, goodRate, rfdRate, startPropor,
-				endPropor, gcid, keyType);
+	public List<QualityFactory> query(QualityFactoryVO qualityFactoryVO) throws QualityFactoryException {
+		return qualityFactoryMapper.query(qualityFactoryVO);
 	}
 
 	@Override
-	public long queryCount(String key, Integer goodsSource, Integer days, Integer startZkPrice, Integer endZkPrice,
-			Integer startBiz30day, Integer endBiz30day, Integer startWeight, Integer endWeight, Integer startTkRate,
-			Integer endTkRate, Integer startAmount, Integer endAmount, Integer hasCoupon, Integer freeShipment,
-			Integer isPrepay, Integer payRate30, Integer goodRate, Integer rfdRate, Integer startPropor,
-			Integer endPropor, Long gcid, Integer keyType) throws QualityFactoryException {
-
-		return qualityFactoryMapper.queryCount(key, goodsSource, days, startZkPrice, endZkPrice, startBiz30day,
-				endBiz30day, startWeight, endWeight, startTkRate, endTkRate, startAmount, endAmount, hasCoupon,
-				freeShipment, isPrepay, payRate30, goodRate, rfdRate, startPropor, endPropor, gcid, keyType);
+	public long queryCount(QualityFactoryVO qualityFactoryVO) throws QualityFactoryException {
+		return qualityFactoryMapper.queryCount(qualityFactoryVO);
 	}
 
 	@Override
@@ -245,157 +152,133 @@
 	}
 
 	@Override
-	@Transactional
-	public void addBatch(List<Long> auctionIdList, String lableNames, AdminUser admin) throws Exception {
+	@Transactional(rollbackFor=Exception.class)
+	public void addBatchTaoBaoGoods(List<TaoBaoGoodsBrief> listTaoBaoGoods, String lableNames, AdminUser admin)
+			throws Exception {
 
-		List<Label> listLabs = new ArrayList<Label>();
-
-		if (!StringUtil.isNullOrEmpty(lableNames)) {
-			// 绌烘牸闅斿紑
-			String[] arrtitles = lableNames.split("\\s+");
-			for (String title : arrtitles) {
-				/* 閬嶅巻鏍囩鍚嶇О锛氭煡璇㈡暟鎹簱涓槸鍚﹀凡瀛樺湪 */
-				List<Label> labels = labelService.selectByTitle(title.trim());
-
-				if (labels != null && labels.size() > 0) {
-					Label label = labels.get(0);
-
-					listLabs.add(label);
-				} else {
-					// 鏂板
-					Label label = new Label();
-					label.setTitle(title);// 鍚嶇О
-					label.setEntrymode(Label.MODE_SYSTEM); // 鎵归噺褰曞叆
-					label.setCreatetime(new Date());
-					label.setUpdatetime(new Date());
-					label.setCreateUser(admin);
-					label.setIosClick(0l);
-					label.setAndroidClick(0l);
-					labelService.insertSelective(label);
-
-					listLabs.add(label);
-				}
-
-			}
+		if (listTaoBaoGoods == null || listTaoBaoGoods.size() == 0) {
+			throw new Exception("鏈壘鍒板尮閰嶇殑鍟嗗搧");
 		}
 
-		List<String> strList = new ArrayList<String>();
-		for (Long id : auctionIdList) {
-			strList.add(id + "");
+		// 鍒涘缓鏍囩
+		List<Label> listLabs = labelService.addBatchByNames(lableNames, admin);
+		
+	
+		// 娣诲姞鍟嗗搧鏍囩鍒楄〃
+		List<LabelGoods> listLabelAdd = new ArrayList<LabelGoods>();
+		// 鎻掑叆鍟嗗搧闆嗗悎
+		List<TaoBaoGoodsBrief> listGoodsInsert = new ArrayList<TaoBaoGoodsBrief>();
+		// 鏇存柊鍟嗗搧闆嗗悎
+		List<TaoBaoGoodsBrief> listGoodsUpdate = new ArrayList<TaoBaoGoodsBrief>();
+		// 杩涘叆绮鹃�夊晢鍝佸垪琛�
+		List<QualityFactory> listInsertQuality = new ArrayList<QualityFactory>();
+		
+
+		// 鎻掑叆鍟嗗搧娣樺疂ID闆嗗悎
+		List<Long> listAuctionId = new ArrayList<Long>();
+		for (TaoBaoGoodsBrief goodsBrief : listTaoBaoGoods) {
+			listAuctionId.add(goodsBrief.getAuctionId());
 		}
-		List<TaoBaoGoodsBrief> existList = taoBaoGoodsBriefRecordMapper.queryGoodsByAuctionId(strList);
+		List<Long> listHas = taoBaoGoodsBriefService.listExistById(listAuctionId);
 
-		List<QualityFactory> addList = new ArrayList<QualityFactory>();
-		List<LabelGoods> addLabelList = new ArrayList<LabelGoods>();
-
-		for (Long auctionId : auctionIdList) {
-
-			boolean process = false;
-			TaoBaoGoodsBrief goodsBrief = null;
-
-			if (existList != null && existList.size() > 0) {
-				for (TaoBaoGoodsBrief taoBaoGoodsBrief : existList) {
-					Long aId = taoBaoGoodsBrief.getAuctionId();
-					if (auctionId.equals(aId)) {
-						goodsBrief = taoBaoGoodsBrief;
-						goodsBrief.setId(null);
-						process = true;
+		// 閬嶅巻鍟嗗搧
+		for (TaoBaoGoodsBrief newGoodsBrief : listTaoBaoGoods) {
+			Long auctionId = newGoodsBrief.getAuctionId();
+			// 璁剧疆鎴愪富閿�
+			newGoodsBrief.setId(auctionId);
+			newGoodsBrief.setState(0); // 鐘舵�佸惎鐢�
+			newGoodsBrief.setCreatetime(new Date());
+			newGoodsBrief.setUpdatetime(new Date());
+			
+			/* 鍒ゆ柇鍟嗗搧 鏄惁宸茬粡瀛樺湪鏁版嵁搴� */
+			if (listHas != null && listHas.size() > 0 && listHas.contains(auctionId)) {
+				// 鏇存柊鍟嗗搧
+				
+				listGoodsUpdate.add(newGoodsBrief);	
+				// 鍟嗗搧鏍囩
+				if (listLabs != null && listLabs.size() > 0) {
+					for (Label lab: listLabs) {
+						long existence = labelGoodsMapper.isExistence(auctionId, lab.getId());
+						if (existence <= 0) {
+							// 璐翠笂鏂版爣绛�
+							LabelGoods lg = new LabelGoods();
+							lg.setLabel(lab);
+							lg.setCreateUser(admin);
+							lg.setCreatetime(new Date());
+							lg.setTaoBaoGoodsBrief(newGoodsBrief);
+							listLabelAdd.add(lg);
+						}
 					}
 				}
-			}
-
-			if (!process) {
-				/* 鏍规嵁auctionId 鑾峰彇娣樺疂鍟嗗搧 */
-				goodsBrief = redisManager.getTaoBaoGoodsBrief(auctionId);
-			}
-
-			if (goodsBrief == null)
-				continue;
-
-			/* 鍒ゆ柇鍟嗗搧 鏄惁宸茬粡瀛樺湪鏁版嵁搴� */
-			List<TaoBaoGoodsBrief> taoBaoGoodsBriefList = taoBaoGoodsBriefService.queryByAuctionId(auctionId);
-
-			if (taoBaoGoodsBriefList != null && taoBaoGoodsBriefList.size() > 0) {
-
-				TaoBaoGoodsBrief currentGoodsBrief = taoBaoGoodsBriefList.get(0);
-
-				goodsBrief.setId(currentGoodsBrief.getId());
-				// 闈炵┖椤� 澶勭悊
-				setTaoBaoGoodsBriefDefault(goodsBrief);
-				// 鏇存柊鍟嗗搧鏈�鏂颁俊鎭�
-				taoBaoGoodsBriefService.updateByPrimaryKey(goodsBrief);
+				
+				// 鏇存柊鐨勫晢鍝佷俊鎭� 鏄惁瀛樺湪绮鹃�夊簱涓�
+				QualityFactory quality = qualityFactoryMapper.getByAuctionId(auctionId);
+				if (quality == null) {
+					QualityFactory selectionGoods = new QualityFactory();
+					selectionGoods.setTaoBaoGoodsBrief(newGoodsBrief);
+					selectionGoods.setCreateUser(admin);
+					selectionGoods.setCreatetime(new Date());
+					selectionGoods.setUpdateUser(admin);
+					selectionGoods.setUpdatetime(new Date());
+					selectionGoods.setEntryMode(QualityFactory.MODE_MANUAL);// 浜哄伐绛涢��
+					selectionGoods.setGoodsSource(QualityFactory.SOURCE_TAOBAO);// 鏉ユ簮
+					selectionGoods.setWeight((int) (Math.random() * (4000)));
+					listInsertQuality.add(selectionGoods);
+				} 
 			} else {
-
-				// 鎻掑叆鏈湴鏁版嵁搴�
-				goodsBrief.setId(null);
-				goodsBrief.setState(0);
-				goodsBrief.setCreatetime(new Date());
-				goodsBrief.setUpdatetime(new Date());
-				// 闈炵┖椤� 澶勭悊
-				setTaoBaoGoodsBriefDefault(goodsBrief);
-
-				taoBaoGoodsBriefService.insertSelective(goodsBrief);
-			}
-
-			// 鏄惁宸插叆搴�
-			Long id = goodsBrief.getId();
-			List<QualityFactory> selectionList = qualityFactoryMapper.queryByGoodsId(id);
-
-			/* 杩涘叆绮鹃�夊晢鍝佸簱 */
-			if (selectionList == null || selectionList.size() == 0) {
-				// 娣诲姞鑷崇簿閫夊晢鍝佸簱
+				// 璁剧疆鍟嗗搧榛樿鍊�
+				taoBaoGoodsBriefService.setGoodsBriefDefault(newGoodsBrief);
+				listGoodsInsert.add(newGoodsBrief);
+				
+				// 绮鹃�夊簱淇℃伅
 				QualityFactory selectionGoods = new QualityFactory();
-
+				selectionGoods.setTaoBaoGoodsBrief(newGoodsBrief);
 				selectionGoods.setCreateUser(admin);
 				selectionGoods.setCreatetime(new Date());
 				selectionGoods.setUpdateUser(admin);
 				selectionGoods.setUpdatetime(new Date());
-
-				selectionGoods.setWeight(50);// 榛樿50
-				selectionGoods.setTaoBaoGoodsBrief(goodsBrief);
 				selectionGoods.setEntryMode(QualityFactory.MODE_MANUAL);// 浜哄伐绛涢��
-				selectionGoods.setGoodsSource(QualityFactory.SOURCE_TAOBAO);// 鏉ユ簮娣樺疂
+				selectionGoods.setGoodsSource(QualityFactory.SOURCE_TAOBAO);// 鏉ユ簮
+				selectionGoods.setWeight((int) (Math.random() * (4000)));
+				listInsertQuality.add(selectionGoods);
 
-				addList.add(selectionGoods);
-			} else {
-				// 鏇存柊鍟嗗搧
-				QualityFactory selectionGoods = selectionList.get(0);
-				selectionGoods.setUpdatetime(new Date());
-				qualityFactoryMapper.updateByPrimaryKey(selectionGoods);
-			}
-
-			if (listLabs.size() > 0) {
-				for (Label label : listLabs) {
-					/* 璐翠笂鏍囩 锛� 宸茶创涓嶅鐞嗗垯 */
-					Long existence = labelGoodsMapper.isExistence(id, label.getId());
-
-					// 璇ュ晢鍝佷笉瀛樺湪姝ゆ爣绛惧垯娣诲姞锛� 鍙嶄箣涓嶅仛澶勭悊
-					if (existence == null || existence == 0l) {
-						// 璐翠笂鏂版爣绛�
+				// 鍟嗗搧鏍囩
+				if (listLabs != null && listLabs.size() > 0) {
+					for (Label lab: listLabs) {
 						LabelGoods lg = new LabelGoods();
-						lg.setLabel(label);
+						lg.setLabel(lab);
 						lg.setCreateUser(admin);
 						lg.setCreatetime(new Date());
-						lg.setTaoBaoGoodsBrief(goodsBrief);
-
-						addLabelList.add(lg);
+						lg.setTaoBaoGoodsBrief(newGoodsBrief);
+						listLabelAdd.add(lg);
 					}
 				}
 			}
 		}
-
-		if (addList.size() > 0) {
-			qualityFactoryMapper.insertBatch(addList);
+		// 鎻掑叆娣樺疂鍟嗗搧
+		if (listGoodsInsert.size() > 0) {
+			taoBaoGoodsBriefService.insertBatch(listGoodsInsert);
+		}
+				
+		// 鏇存柊娣樺疂鍟嗗搧
+		if (listGoodsUpdate.size() > 0) {
+			taoBaoGoodsUpdateService.updateTaoBaoGoods(listGoodsUpdate);
+		}
+		
+		// 鍔犲叆绮鹃�夊簱
+		if (listInsertQuality.size() > 0) {
+			qualityFactoryMapper.insertBatch(listInsertQuality);
 		}
 
-		if (addLabelList.size() > 0) {
-			labelGoodsMapper.insertBatch(addLabelList);
+		// 娣诲姞鏍囩
+		if (listLabelAdd.size() > 0) {
+			labelGoodsMapper.insertBatch(listLabelAdd);
 		}
-
+	
 	}
 
 	@Override
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	public void setWeightBatch(List<Long> idList, AdminUser admin, Integer weight, Integer weightSmall,
 			Integer weightLarge) throws Exception {
 
@@ -419,7 +302,7 @@
 			}
 
 			// 淇敼鏉冮噸
-			// selectionGoods.setUpdateUser(admin);
+			selectionGoods.setUpdateUser(admin);
 			selectionGoods.setWeight(resultWeight);
 			qualityFactoryMapper.updateByPrimaryKeySelective(selectionGoods);
 		}
@@ -436,32 +319,25 @@
 		qualityFactoryMapper.updateWeight(weight, time);
 	}
 
-	@Override
-	public long queryNeedUpdateCount() {
-		return qualityFactoryMapper.countQueryNeedUpdate();
-	}
 
-	@Override
-	public List<Long> queryNeedUpdate(long start, int count, int hour) {
-		return qualityFactoryMapper.queryNeedUpdate(0, count, hour);
-	}
-
-	
 	/**
 	 * 鑾峰彇缂撳瓨
-	 * @param key 閿�
-	 * @param title 鏍囩鍚嶇О
+	 * 
+	 * @param key
+	 *            閿�
+	 * @param title
+	 *            鏍囩鍚嶇О
 	 * @return
 	 */
-	public String getLabelIdByRedis (String key, String title) throws Exception {
-		
+	public String getLabelIdByRedis(String key, String title) throws Exception {
+		key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, key);
 		String value = redisManager.getCommonString(key);
-		
+
 		if (StringUtil.isNullOrEmpty(value)) {
-			
+
 			// id涓虹┖鏃剁郴缁熻繘琛屾煡璇�
 			List<Label> list9K9 = labelService.selectByTitle(title);
-			
+
 			if (list9K9 != null && list9K9.size() > 0) {
 				Long id = list9K9.get(0).getId();
 				if (id != null) {
@@ -471,292 +347,204 @@
 				}
 			}
 		}
-		
+
 		return value;
 	}
-	
+
 	@Override
-	@Transactional
-	public void updateGoodsFactory(List<Long> listId) {
-
-		if (listId == null || listId.size() == 0) {
+	public void updateQualityGoods(Long goodsId) {
+		if (goodsId == null) {
 			return;
 		}
 
-		List<QualityFactory> listQuality = qualityFactoryMapper.listQueryGoodsByGoodsId(listId);
-		if (listQuality == null || listQuality.size() == 0) {
-			return;
-		}
-
-		
-		List<Long> listDeleteQuality = new ArrayList<Long>();
-		
-		List<QualityFactory> listUpdateQuality = new ArrayList<QualityFactory>();
-
-		List<TaoBaoGoodsBrief> listUpdateGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
-
-		List<Long> list9ClassDelete = new ArrayList<Long>();
-		// 娣诲姞鍟嗗搧鏍囩鍒楄〃
-		List<LabelGoods> listLabelAdd = new ArrayList<LabelGoods>();
-
+		TaoBaoGoodsBrief goods = null;
+		boolean isDelete = false;
 		try {
-			
-			List<Long> list9Class = new ArrayList<Long>();
-			Map<String, Label> map = new HashMap<String, Label>();
-			
-			if (Constant.IS_OUTNET) {
-				
-				String value9K9 = getLabelIdByRedis("lab-9K9", "9.9");
-				String value19K9 = getLabelIdByRedis("lab-19K9", "19.9");
-				String value29K9 = getLabelIdByRedis("lab-29K9", "29.9");
-				String value49K9 = getLabelIdByRedis("lab-49K9", "49.9");
-				
-				if (!StringUtil.isNullOrEmpty(value9K9)) {
-					map.put("9.9", new Label(Long.parseLong(value9K9)));
-					list9Class.add(Long.parseLong(value9K9));	
-				}
-				
-				if (!StringUtil.isNullOrEmpty(value19K9)) {
-					map.put("19.9", new Label(Long.parseLong(value19K9)));
-					list9Class.add(Long.parseLong(value19K9));	
-				}
-				
-				if (!StringUtil.isNullOrEmpty(value29K9)) {
-					map.put("29.9", new Label(Long.parseLong(value29K9)));
-					list9Class.add(Long.parseLong(value29K9));	
-				}
-				
-				if (!StringUtil.isNullOrEmpty(value49K9)) {
-					map.put("49.9", new Label(Long.parseLong(value49K9)));
-					list9Class.add(Long.parseLong(value49K9));	
-				}
-				
+			// 鑾峰彇璇︽儏
+			goods = TaoKeApiUtil.searchGoodsDetail(goodsId);
+			if(goods == null) {
+				isDelete = true;
+			} else if (goods.getCouponAmount().compareTo(BigDecimal.valueOf(0)) > 0) {
+				isDelete = true;
 			}
-
-			listQuality.parallelStream().forEach(quality -> {
-
-				TaoBaoGoodsBrief goods = quality.getTaoBaoGoodsBrief();
-
-				if (goods == null) {
-					// 绉婚櫎绮鹃�夊簱
-					listDeleteQuality.add(quality.getId());
-
-				} else {
-
-					Long id = goods.getId();
-
-					TaoBaoGoodsBrief newGoodsBrief = null;
-
-					Long auctionId = goods.getAuctionId();
-					try {
-						// 鑾峰彇璇︽儏
-						newGoodsBrief = TaoKeApiUtil.searchGoodsDetail(auctionId);
-					} catch (TaobaoGoodsDownException e1) {
-						// 鍟嗗搧涓嬫灦 绉婚櫎鏁版嵁搴�
-						taoBaoGoodsUpdateService.deleteTaoBaoGoods(auctionId);
-
-					} catch (Exception e) {
-						try {
-							LogHelper.errorDetailInfo(e);
-						} catch (Exception e1) {
-							e1.printStackTrace();
-						}
-					}
-
-					if (newGoodsBrief == null) {
-
-						/* 鏃犲埜淇℃伅 绉婚櫎绮鹃�夊簱 */
-						listDeleteQuality.add(quality.getId());
-
-					} else {
-						/* 鏃犲埜淇℃伅 绉婚櫎绮鹃�夊簱 */
-						if (StringUtil.isNullOrEmpty(newGoodsBrief.getCouponInfo())
-								&& StringUtil.isNullOrEmpty(newGoodsBrief.getCouponActivityId())) { // 鏃犲埜淇℃伅
-
-							// 绉婚櫎绮鹃�夊簱
-							listDeleteQuality.add(quality.getId());
-
-						} else {
-							/* 鏇存柊鍟嗗搧淇℃伅 */
-							TaoBaoGoodsBrief updateGoods = taoBaoGoodsUpdateService
-									.getUpdateTaoBaoGoodsBrief(newGoodsBrief);
-							updateGoods.setId(id);
-							taoBaoGoodsBriefService.setGoodsBriefDefault(updateGoods);
-							listUpdateGoodsBrief.add(updateGoods);
-
-							/* 鏇存柊绮鹃�夊簱 淇℃伅鏃堕棿 */
-							Integer biz30day = updateGoods.getBiz30day();
-							if (biz30day < 1000) {
-								// 閿�閲忓皬浜�1000 閲嶆柊璁剧疆鏉冮噸
-								int weight = 10 + (int) (Math.random() * 2000);
-								quality.setWeight(weight);
-							}
-							quality.setUpdatetime(new Date());
-							listUpdateQuality.add(quality);
-
-							/* 鍒ゆ柇鏄惁宸茬粡璐翠笂鏍囩 9k9鏍囩 瀵瑰簲浠锋牸鍙樺寲 */
-							if (list9Class.size() > 0) {
-								List<LabelGoods> listGlid = labelGoodsMapper.listQuery9k9Class(id, list9Class);
-								if (listGlid != null && listGlid.size() > 0) {
-									/* 鍒犻櫎鍘熸爣绛� 9k9 */
-									for (LabelGoods labelGoods : listGlid) {
-										list9ClassDelete.add(labelGoods.getId());
-									}
-
-									/* 璐翠笂鏂版爣绛� 9k9 */
-									LabelGoods labelGds = screen9K9(updateGoods, map);
-									if (labelGds != null) {
-										listLabelAdd.add(labelGds);
-									}
-								}
-							}
-
-						}
-					}
-				}
-
-			});
-
-			// 鏇存柊鍟嗗搧淇℃伅
-			if (listUpdateGoodsBrief.size() > 0) {
-				taoBaoGoodsBriefService.updateBatchSelective(listUpdateGoodsBrief);
-			}
-
-			// 鏇存柊绮鹃�夊簱
-			if (listUpdateQuality.size() > 0) {
-				qualityFactoryMapper.updateBatchSelective(listUpdateQuality);
-			}
-
-			// 鎵归噺鍒犻櫎绮鹃�夊簱
-			if (listDeleteQuality.size() > 0) {
-				qualityFactoryMapper.deleteBatchByPrimaryKey(listDeleteQuality);
-			}
-
-			// 娣诲姞鏍囩
-			if (listLabelAdd.size() > 0) {
-				labelGoodsMapper.insertBatch(listLabelAdd);
-			}
-
-			// 鍒犻櫎鏍囩
-			if (list9ClassDelete.size() > 0) {
-				labelGoodsMapper.deleteBatchByPK(list9ClassDelete);
-			}
-
-		} catch (Exception e) {
-			try {
-				LogHelper.errorDetailInfo(e);
-			} catch (Exception e1) {
-				e1.printStackTrace();
-			}
+		} catch (TaobaoGoodsDownException e) {
+			isDelete = true;
 		}
+		
+		// 绉婚櫎绮鹃�夊簱
+		if (isDelete) {
+			deleteByTaoBaoGoodsId(goodsId);
+			taoBaoGoodsBriefService.deleteByPrimaryKey(goodsId);
+			return;
+		}
+		
+		goods.setId(goodsId);
+		goods.setCreatetime(new Date());
+		goods.setUpdatetime(new Date());
+		try {
+			taoBaoGoodsUpdateService.updateTaoBaoGoods(goods);
+		} catch (TaobaoGoodsUpdateException e) {
+			e.printStackTrace();
+		}
+		
 	}
 
 	@Override
 	@Transactional
-	public void updateBatchQualityFactory(List<QualityFactory> listQuality, List<Long> list9Class,
-			Map<String, Label> map) throws Exception {
+	public void autoInsertOrUpadateStorage(BoutiqueAutoRule autoRule, List<TaoBaoGoodsBrief> goodsList,	List<Label> listLabs) {
 
-		if (listQuality == null || listQuality.size() == 0) {
+		if (goodsList == null || goodsList.size() == 0) {
 			return;
 		}
+		
+		/* 鏉ユ簮鎺ㄨ崘鍟嗗搧 闇�瑕佽幏鍙栬鎯� */
+		if (QualityFactory.SOURCE_TAOBAO_MATERIAL == autoRule.getGoodsSource()) {
+			List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
+			
+			goodsList.parallelStream().forEach(goods -> {
+				try {
+					TaoBaoGoodsBrief taoBaoGoodsBrief = TaoKeApiUtil.searchGoodsDetail(goods.getAuctionId());
+					if (taoBaoGoodsBrief != null) {
+						listGoodsBrief.add(taoBaoGoodsBrief);
+					}
+				} catch (TaobaoGoodsDownException e) {
+					e.printStackTrace();
+				}
+			});
+			
+			goodsList.clear();
+			goodsList = listGoodsBrief;
 
-		List<Long> listDeleteQuality = new ArrayList<Long>();
-		List<QualityFactory> listUpdateQuality = new ArrayList<QualityFactory>();
+			if (goodsList == null || goodsList.size() == 0) {
+				return;
+			}
+		}
+		
+		
+//		for (int i = 0; i < goodsList.size(); i++) {
+//			if (goodsList.get(i).getMaterialLibType() != null && goodsList.get(i).getMaterialLibType() == 0) {
+//				goodsList.remove(i);
+//				i--;
+//			}
+//		}
+		
 
-		List<Long> listGid = new ArrayList<Long>();
-		List<TaoBaoGoodsBrief> listUpdateGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
-
-		List<Long> list9ClassDelete = new ArrayList<Long>();
 		// 娣诲姞鍟嗗搧鏍囩鍒楄〃
 		List<LabelGoods> listLabelAdd = new ArrayList<LabelGoods>();
+		
+		// 鎻掑叆鍟嗗搧闆嗗悎
+		List<TaoBaoGoodsBrief> listGoodsInsert = new ArrayList<TaoBaoGoodsBrief>();
+		// 鏇存柊鍟嗗搧闆嗗悎
+		List<TaoBaoGoodsBrief> listGoodsUpdate = new ArrayList<TaoBaoGoodsBrief>();
 
-		listQuality.parallelStream().forEach(quality -> {
-
-			TaoBaoGoodsBrief goods = quality.getTaoBaoGoodsBrief();
-			if (goods == null) {
-				// 绉婚櫎绮鹃�夊簱
-				listDeleteQuality.add(quality.getId());
-			} else {
-				Long id = goods.getId();
-				Long auctionId = goods.getAuctionId();
-
-				try {
-					// 鑾峰彇璇︽儏
-					TaoBaoGoodsBrief taoBaoGoodsBrief = TaoKeApiUtil.searchGoodsDetail(auctionId);
-
-					if (taoBaoGoodsBrief == null) {
-						/* 鏃犲埜淇℃伅 绉婚櫎绮鹃�夊簱 */
-						listGid.add(id);
-					} else {
-						/* 鏃犲埜淇℃伅 绉婚櫎绮鹃�夊簱 */
-						if (StringUtil.isNullOrEmpty(taoBaoGoodsBrief.getCouponInfo())
-								&& StringUtil.isNullOrEmpty(taoBaoGoodsBrief.getCouponActivityId())) { // 鏃犲埜淇℃伅
-							// 绉婚櫎绮鹃�夊簱
-							listGid.add(id);
-
-							/* 鏇存柊鍟嗗搧淇℃伅 */
-							TaoBaoGoodsBrief updateGoods = taoBaoGoodsUpdateService
-									.getUpdateTaoBaoGoodsBrief(taoBaoGoodsBrief);
-							updateGoods.setId(id);
-							taoBaoGoodsBriefService.setGoodsBriefDefault(updateGoods);
-							listUpdateGoodsBrief.add(updateGoods);
-						} else {
-							/* 鏇存柊鍟嗗搧淇℃伅 */
-
-							TaoBaoGoodsBrief updateGoods = taoBaoGoodsUpdateService
-									.getUpdateTaoBaoGoodsBrief(taoBaoGoodsBrief);
-							updateGoods.setId(id);
-							taoBaoGoodsBriefService.setGoodsBriefDefault(updateGoods);
-							listUpdateGoodsBrief.add(updateGoods);
-
-							/* 鏇存柊绮鹃�夊簱 淇℃伅鏃堕棿 */
-							Integer biz30day = updateGoods.getBiz30day();
-							if (biz30day < 1000) {
-								// 閿�閲忓皬浜�1000 閲嶆柊璁剧疆鏉冮噸
-								int weight = 10 + (int) (Math.random() * 2000);
-								quality.setWeight(weight);
-							}
-							quality.setUpdatetime(new Date());
-
-							listUpdateQuality.add(quality);
-
-							/* 鍒ゆ柇鏄惁宸茬粡璐翠笂鏍囩 9k9鏍囩 瀵瑰簲浠锋牸鍙樺寲 */
-							if (list9Class.size() > 0) {
-								List<LabelGoods> listGlid = labelGoodsMapper.listQuery9k9Class(id, list9Class);
-								if (listGlid != null && listGlid.size() > 0) {
-									/* 鍒犻櫎鍘熸爣绛� 9k9 */
-									for (LabelGoods labelGoods : listGlid) {
-										list9ClassDelete.add(labelGoods.getId());
-									}
-
-									/* 璐翠笂鏂版爣绛� 9k9 */
-									LabelGoods labelGds = screen9K9(updateGoods, map);
-									if (labelGds != null) {
-										listLabelAdd.add(labelGds);
-									}
-								}
-							}
+		// 杩涘叆绮鹃�夊晢鍝佸垪琛�
+		List<QualityFactory> listInsertQuality = new ArrayList<QualityFactory>();
+		// 杩涘叆绮鹃�夊晢鍝佸垪琛�
+		List<QualityFactory> listUpdateQuality = new ArrayList<QualityFactory>();
+		
+		// 鎻掑叆鍟嗗搧娣樺疂ID闆嗗悎
+		List<Long> listAuctionId = new ArrayList<Long>();
+		for (TaoBaoGoodsBrief goodsBrief : goodsList) {
+			listAuctionId.add(goodsBrief.getAuctionId());
+		}
+		
+		List<Long> listHas =  new ArrayList<Long>();
+		if (listAuctionId.size() > 0) {
+			listHas = taoBaoGoodsBriefService.listExistById(listAuctionId);
+		}
+		
+		
+		// 閬嶅巻鍟嗗搧
+		for (TaoBaoGoodsBrief newGoodsBrief : goodsList) {
+			Long auctionId = newGoodsBrief.getAuctionId();
+			// 璁剧疆鎴愪富閿�
+			newGoodsBrief.setId(auctionId);
+			newGoodsBrief.setState(0); // 鐘舵�佸惎鐢�
+			newGoodsBrief.setCreatetime(new Date());
+			newGoodsBrief.setUpdatetime(new Date());
+			
+			/* 鍒ゆ柇鍟嗗搧 鏄惁宸茬粡瀛樺湪鏁版嵁搴� */
+			if (listHas != null && listHas.size() > 0 && listHas.contains(auctionId)) {
+				// 鏇存柊鍟嗗搧
+				
+				listGoodsUpdate.add(newGoodsBrief);	
+				
+				// 鍟嗗搧鏍囩
+				if (listLabs != null && listLabs.size() > 0) {
+					for (Label lab: listLabs) {
+						long existence = labelGoodsMapper.isExistence(auctionId, lab.getId());
+						if (existence <= 0) {
+							// 璐翠笂鏂版爣绛�
+							LabelGoods lg = new LabelGoods();
+							lg.setLabel(lab);
+							lg.setCreateUser(autoRule.getAdminUser());
+							lg.setCreatetime(new Date());
+							lg.setTaoBaoGoodsBrief(newGoodsBrief);
+							listLabelAdd.add(lg);
 						}
 					}
+				}
+				
+				// 鏇存柊鐨勫晢鍝佷俊鎭� 鏄惁瀛樺湪绮鹃�夊簱涓�
+				QualityFactory quality = qualityFactoryMapper.getByAuctionId(auctionId);
+				if (quality == null) {
+					listInsertQuality.add(getNewQualityFactory(newGoodsBrief, autoRule));
+				} else {
+					// 闅忔満鏉冮噸
+					int weight = autoRule.getStartWeight()
+							+ (int) (Math.random() * ((autoRule.getEndWeight() - autoRule.getStartWeight()) + 1));
+					quality.setWeight(weight);
+					// 鏇存柊鏃堕棿
+					quality.setUpdatetime(new Date());
+					// 鏇存柊鏉ユ簮瑙勫垯
+					quality.setBoutiqueAutoRule(autoRule);
+					// 鏇存柊鏉ユ簮绫诲埆
+					quality.setSourceCalss(autoRule.getSourceCalss());
+					// 鏉ユ簮
+					quality.setGoodsSource(autoRule.getGoodsSource());
+					listUpdateQuality.add(quality);
+				}
+				
+			} else {
+				// 璁剧疆鍟嗗搧榛樿鍊�
+				taoBaoGoodsBriefService.setGoodsBriefDefault(newGoodsBrief);
+				listGoodsInsert.add(newGoodsBrief);
+				
+				// 绮鹃�夊簱淇℃伅
+				listInsertQuality.add(getNewQualityFactory(newGoodsBrief, autoRule));
 
-				} catch (TaobaoGoodsDownException e1) {
-					// 鍟嗗搧涓嬫灦 绉婚櫎鏁版嵁搴�
-					taoBaoGoodsUpdateService.deleteTaoBaoGoods(auctionId);
-
-				} catch (Exception e) {
-					try {
-						LogHelper.errorDetailInfo(e);
-					} catch (Exception e1) {
-						e1.printStackTrace();
+				// 鍟嗗搧鏍囩
+				if (listLabs != null && listLabs.size() > 0) {
+					for (Label lab: listLabs) {
+						LabelGoods lg = new LabelGoods();
+						lg.setLabel(lab);
+						lg.setCreateUser(autoRule.getAdminUser());
+						lg.setCreatetime(new Date());
+						lg.setTaoBaoGoodsBrief(newGoodsBrief);
+						listLabelAdd.add(lg);
 					}
 				}
 			}
+		}
 
-		});
+		// 鎻掑叆娣樺疂鍟嗗搧
+		if (listGoodsInsert.size() > 0) {
+			taoBaoGoodsBriefService.insertBatch(listGoodsInsert);
+		}
+				
+		// 鏇存柊娣樺疂鍟嗗搧
+		if (listGoodsUpdate.size() > 0) {
+			try {
+				taoBaoGoodsUpdateService.updateTaoBaoGoods(listGoodsUpdate);
+			} catch (TaobaoGoodsUpdateException e) {
+				e.printStackTrace();
+			}
+		}
 
-		// 鏇存柊鍟嗗搧淇℃伅
-		if (listUpdateGoodsBrief.size() > 0) {
-			taoBaoGoodsBriefService.updateBatchSelective(listUpdateGoodsBrief);
+		
+		// 鍔犲叆绮鹃�夊簱
+		if (listInsertQuality.size() > 0) {
+			qualityFactoryMapper.insertBatch(listInsertQuality);
 		}
 
 		// 鏇存柊绮鹃�夊簱
@@ -764,401 +552,30 @@
 			qualityFactoryMapper.updateBatchSelective(listUpdateQuality);
 		}
 
-		// 鎵归噺绉婚櫎绮鹃�夊簱
-		if (listGid.size() > 0) {
-			deleteBatchByTaoBaoGoodsId(listGid);
-		}
-
-		// 鎵归噺鍒犻櫎绮鹃�夊簱
-		if (listDeleteQuality.size() > 0) {
-			qualityFactoryMapper.deleteBatchByPrimaryKey(listDeleteQuality);
-		}
-
 		// 娣诲姞鏍囩
 		if (listLabelAdd.size() > 0) {
 			labelGoodsMapper.insertBatch(listLabelAdd);
-		}
-
-		// 鍒犻櫎鏍囩
-		if (list9ClassDelete.size() > 0) {
-			labelGoodsMapper.deleteBatchByPK(list9ClassDelete);
-		}
-	}
-
-	@Override
-	public void autoInsertOrUpadateStorage(List<TaoBaoGoodsBrief> goodsList, List<Label> listLabs,
-			BoutiqueAutoRule autoRule) throws Exception {
-
-		if (goodsList == null || goodsList.size() == 0) {
-			return;
-		}
-
-		/* 鏉ユ簮鎺ㄨ崘鍟嗗搧闇�瑕佽幏鍙栬鎯� */
-		if (QualityFactory.SOURCE_TAOBAO_MATERIAL == autoRule.getGoodsSource()) {
-			// 鎻掑叆鍟嗗搧闆嗗悎
-			List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
-
-			goodsList.parallelStream().forEach(goods -> {
-				// 鑾峰彇璇︽儏
-				try {
-					TaoBaoGoodsBrief taoBaoGoodsBrief = TaoKeApiUtil.searchGoodsDetail(goods.getAuctionId());
-					if (taoBaoGoodsBrief != null) {
-						listGoodsBrief.add(taoBaoGoodsBrief);
-					}
-
-				} catch (Exception e) {
-					e.printStackTrace();
-				}
-			});
-
-			goodsList.clear();
-
-			goodsList = listGoodsBrief;
-
-			if (goodsList == null || goodsList.size() == 0) {
-				return;
-			}
-		}
-
-		
-		
-		// 鍟嗗搧id闆嗗悎
-		List<Long> listSystemTBid = new ArrayList<Long>();
-
-		// 娣诲姞鍟嗗搧鏍囩鍒楄〃
-		List<LabelGoods> listLabelAdd = new ArrayList<LabelGoods>();
-
-		// 鎻掑叆鍟嗗搧闆嗗悎
-		List<TaoBaoGoodsBrief> listGoodsInsert = new ArrayList<TaoBaoGoodsBrief>();
-		// 鏇存柊鍟嗗搧闆嗗悎
-		List<TaoBaoGoodsBrief> listGoodsUpdate = new ArrayList<TaoBaoGoodsBrief>();
-
-		// 杩涘叆绮鹃�夊晢鍝佸垪琛�
-		List<QualityFactory> listAddInsert = new ArrayList<QualityFactory>();
-		// 杩涘叆绮鹃�夊晢鍝佸垪琛�
-		List<QualityFactory> listAddUpdate = new ArrayList<QualityFactory>();
-		
-
-		// 鎻掑叆鍟嗗搧娣樺疂ID闆嗗悎
-		List<Long> listAuctionId = new ArrayList<Long>();
-		for (TaoBaoGoodsBrief goodsBrief : goodsList) {
-			listAuctionId.add(goodsBrief.getAuctionId());
-		}
-
-		List<TaoBaoGoodsBrief> listHas = taoBaoGoodsBriefService.listQueryByAuctionId(listAuctionId);
-
-		List<Long> list9Class = null;
-		List<Long> list9ClassDelete = new ArrayList<Long>();
-		Map<String, Label> map = new HashMap<String, Label>();
-
-		list9Class = new ArrayList<Long>();
-
-		List<Label> list9K9 = labelService.selectByTitleCache("labKey", "9.9");
-		if (list9K9 != null && list9K9.size() > 0) {
-			map.put("9.9", list9K9.get(0));
-			list9Class.add(list9K9.get(0).getId());
-		}
-
-		List<Label> list19k9 = labelService.selectByTitleCache("labKey", "19.9");
-		if (list19k9 != null && list19k9.size() > 0) {
-			map.put("19.9", list19k9.get(0));
-			list9Class.add(list19k9.get(0).getId());
-		}
-
-		List<Label> list29k9 = labelService.selectByTitleCache("labKey", "29.9");
-		if (list29k9 != null && list29k9.size() > 0) {
-			map.put("29.9", list29k9.get(0));
-			list9Class.add(list29k9.get(0).getId());
-		}
-
-		List<Label> list49k9 = labelService.selectByTitleCache("labKey", "49.9");
-		if (list49k9 != null && list49k9.size() > 0) {
-			map.put("49.9", list49k9.get(0));
-			list9Class.add(list49k9.get(0).getId());
-		}
-
-		for (TaoBaoGoodsBrief newGoodsBrief : goodsList) {
-
-			Long systemId = null;
-			boolean isExist = false;
-			Long auctionId = newGoodsBrief.getAuctionId();
-
-			/* 鍒ゆ柇鍟嗗搧 鏄惁宸茬粡瀛樺湪鏁版嵁搴� */
-			if (listHas != null && listHas.size() > 0) {
-				for (TaoBaoGoodsBrief hasgoodsBrief : listHas) {
-					Long hasId = hasgoodsBrief.getAuctionId();
-					if (auctionId.equals(hasId)) {
-						systemId = hasgoodsBrief.getId();
-						// 瀛樺湪鏁版嵁搴�
-						isExist = true;
-						break;// 缁撴潫鍐呴儴寰幆
-					}
-				}
-			}
-
-			/* 鍟嗗搧宸插瓨鍦ㄦ暟鎹簱 */
-			if (isExist && systemId != null) {
-				
-				// 鐢ㄤ簬纭畾鏄惁瀛樺湪绮鹃�夊簱
-				listSystemTBid.add(systemId);
-				
-				// 鏇存柊鍟嗗搧淇℃伅
-				TaoBaoGoodsBrief updateGoods = taoBaoGoodsUpdateService.getUpdateTaoBaoGoodsBrief(newGoodsBrief);
-				// 璁剧疆涓婚敭id
-				updateGoods.setId(systemId);
-				// 淇敼鍒涘缓鏃堕棿 - 鎹箟鏂板垱寤�
-				Date date = new Date();
-				updateGoods.setCreatetime(date);
-				updateGoods.setUpdatetime(date);
-				taoBaoGoodsBriefService.setGoodsBriefDefault(updateGoods);
-				
-				listGoodsUpdate.add(updateGoods);
-
-				
-				Long has9k9ID = null;
-
-				/* 璐翠笂鏍囩   */
-				if (listLabs != null && listLabs.size() > 0) {
-
-					for (Label label : listLabs) {
-						
-						//  鍖呭惈 9.9/19.9/29.9/49.9 銆佸悓鏃舵潵婧愭窐瀹濇帹鑽�: 鐢变簬鑾峰彇璇︽儏涓庢帹鑽愭帴鍙g殑鍒镐俊鎭瓨鍦ㄥ嚭鍏�  浠ユ渶鍚庤鎯呬负鍑�
-						if (list9Class.contains(label.getId()) && autoRule.isCalss9k9() && QualityFactory.SOURCE_TAOBAO_MATERIAL == autoRule.getGoodsSource()) {
-							
-							/* 鑾峰彇鍟嗗搧璇︽儏鍚庤绠楁槸鍚﹀睘浜� 9k9绯诲垪  鍔犲叆瀵瑰簲鐨勬爣绛�*/
-							LabelGoods labelGds = screen9K9(updateGoods, map);
-						
-							if (labelGds != null) {
-								
-								Label label9k = labelGds.getLabel();
-								Long id = label9k.getId();
-								
-								long existence = labelGoodsMapper.isExistence(systemId, id);
-								if (existence <= 0) {
-									// 涓嶅瓨鍦ㄥ搴旀爣绛�
-									listLabelAdd.add(labelGds);
-								} else {
-									// 宸插瓨鍦�
-									has9k9ID = id; 
-								}
-								
-							}
-							
-						} else {
-							
-							long existence = labelGoodsMapper.isExistence(systemId, label.getId());
-							if (existence <= 0) {
-								// 璐翠笂鏂版爣绛�
-								LabelGoods lg = new LabelGoods();
-								lg.setLabel(label);
-								lg.setCreateUser(autoRule.getAdminUser());
-								lg.setCreatetime(new Date());
-								lg.setTaoBaoGoodsBrief(updateGoods);
-
-								listLabelAdd.add(lg);
-							} else {
-								if(list9Class.contains(label.getId())){
-									// 宸插瓨鍦�
-									has9k9ID = label.getId(); 
-								}
-							}
-						}
-					}
-				}
-
-				
-				/* 鍒ゆ柇鏄惁宸茬粡璐翠笂鏍囩 9k9鏍囩 */
-				if (list9Class.size() > 0) {
-					
-					List<LabelGoods> listGlid = labelGoodsMapper.listQuery9k9Class(systemId, list9Class);
-					
-					if (listGlid != null && listGlid.size() > 0) {
-						
-						if (has9k9ID == null && !autoRule.isCalss9k9()) {
-							// 闈�9k9鍏ュ簱瑙勫垯  鑻ュ晢鍝佷俊鎭彉鍖� 瀵瑰簲鐨勬爣绛炬牴鎹环鏍� 淇敼
-							LabelGoods labelGds = screen9K9(updateGoods, map);
-							if (labelGds != null) {
-								Label label9k = labelGds.getLabel();
-								Long id = label9k.getId();
-								
-								long existence = labelGoodsMapper.isExistence(systemId, id);
-								if (existence <= 0) {
-									// 涓嶅瓨鍦ㄥ搴旀爣绛�
-									listLabelAdd.add(labelGds);
-								} else {
-									// 宸插瓨鍦�
-									has9k9ID = id; 
-								}
-							}
-						}
-						
-						
-						// 娓呯┖ 9K9绯诲垪鏍囩
-						for (LabelGoods labelGoods : listGlid) {
-							Label label = labelGoods.getLabel();
-							if (has9k9ID != null && has9k9ID.equals(label.getId())) {
-								continue;
-							}
-							
-							list9ClassDelete.add(labelGoods.getId());
-						}
-					}
-				}
-				
-			} else {
-				newGoodsBrief.setId(null);
-				newGoodsBrief.setState(0); // 鐘舵�佸惎鐢�
-				newGoodsBrief.setCreatetime(new Date());
-				newGoodsBrief.setUpdatetime(new Date());
-				// 璁剧疆榛樿鍊�
-				taoBaoGoodsBriefService.setGoodsBriefDefault(newGoodsBrief);
-				// 鎻掑叆鏁版嵁搴�
-				listGoodsInsert.add(newGoodsBrief);
-
-				// 鍔犲叆绮鹃�夊簱
-				listAddInsert.add(getNewQualityFactory(newGoodsBrief, autoRule));
-
-				// 璐翠笂鏍囩
-				if (listLabs != null && listLabs.size() > 0) {
-					
-					for (Label label : listLabs) {
-						
-						// 鍖呭惈 9.9/19.9/29.9/49.9 銆佸悓鏃舵潵婧愭窐瀹濇帹鑽�: 鐢变簬鑾峰彇璇︽儏涓庢帹鑽愭帴鍙g殑鍒镐俊鎭瓨鍦ㄥ嚭鍏�  浠ユ渶鍚庤鎯呬负鍑�
-						if (list9Class.contains(label.getId()) && autoRule.isCalss9k9() && 
-								QualityFactory.SOURCE_TAOBAO_MATERIAL == autoRule.getGoodsSource()) {
-							/*  鍔犲叆瀵瑰簲鐨�9.9/19.9/29.9/49.9 鏍囩*/
-							LabelGoods labelGds = screen9K9(newGoodsBrief, map);
-							
-							if (labelGds != null) {
-								listLabelAdd.add(labelGds);
-							}
-							
-						} else {
-							// 璐翠笂鏂版爣绛�
-							LabelGoods lg = new LabelGoods();
-							lg.setLabel(label);
-							lg.setCreateUser(autoRule.getAdminUser());
-							lg.setCreatetime(new Date());
-							lg.setTaoBaoGoodsBrief(newGoodsBrief);
-							listLabelAdd.add(lg);
-						}
-						
-					}
-					
-				}
-			}
-		}
-
-		// 鏇存柊鐨勫晢鍝佷俊鎭� 鏄惁瀛樺湪绮鹃�夊簱涓�
-		List<QualityFactory> listExist = null;
-		if (listSystemTBid.size() > 0) {
-			listExist = qualityFactoryMapper.listQueryGoodsByGoodsId(listSystemTBid);
-		}
-
-		/* 鏇存柊娣樺疂鍟嗗搧淇℃伅 */
-		if (listGoodsUpdate.size() > 0) {
-
-			for (TaoBaoGoodsBrief goodsBrief : listGoodsUpdate) {
-				boolean isExist = false;
-
-				if (listExist == null || listExist.size() == 0) {
-					// 鍔犲叆鍒扮簿閫夊簱
-					listAddInsert.add(getNewQualityFactory(goodsBrief, autoRule));
-					continue;
-				}
-
-				QualityFactory selection = null;
-				Long id = goodsBrief.getId();
-				for (QualityFactory selectionGoods : listExist) {
-					TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
-					if (taoBaoGoodsBrief != null) {
-						Long sid = taoBaoGoodsBrief.getId();
-						if (id.equals(sid)) {
-							isExist = true;
-							selection = selectionGoods;
-						}
-					}
-				}
-
-				if (isExist) {
-					/* 鏇存柊绮鹃�夊簱淇℃伅 */
-
-					// 闅忔満鏉冮噸
-					int weight = autoRule.getStartWeight()
-							+ (int) (Math.random() * ((autoRule.getEndWeight() - autoRule.getStartWeight()) + 1));
-					selection.setWeight(weight);
-					// 鏇存柊鏃堕棿
-					selection.setUpdatetime(new Date());
-					// 鏇存柊鏉ユ簮瑙勫垯
-					selection.setBoutiqueAutoRule(autoRule);
-					// 鏇存柊鏉ユ簮绫诲埆
-					selection.setSourceCalss(autoRule.getSourceCalss());
-					// 鏉ユ簮
-					selection.setGoodsSource(autoRule.getGoodsSource());
-
-					listAddUpdate.add(selection);
-
-				} else {
-					// 鏂板鑷崇簿閫夊簱
-					listAddInsert.add(getNewQualityFactory(goodsBrief, autoRule));
-				}
-
-			}
-
-			taoBaoGoodsBriefService.updateBatchSelective(listGoodsUpdate);
-		}
-
-		// 娣樺疂鍟嗗搧鎻掑叆鏁版嵁搴�
-		if (listGoodsInsert.size() > 0) {
-			taoBaoGoodsBriefService.insertBatch(listGoodsInsert);
-		}
-
-		// 鏇存柊绮鹃�夊簱
-		if (listAddUpdate.size() > 0) {
-			qualityFactoryMapper.updateBatchSelective(listAddUpdate);
-		}
-
-		// 鍔犲叆绮鹃�夊簱
-		if (listAddInsert.size() > 0) {
-			qualityFactoryMapper.insertBatch(listAddInsert);
-		}
-
-		// 娣诲姞鏍囩
-		if (listLabelAdd.size() > 0) {
-			labelGoodsMapper.insertBatch(listLabelAdd);
-		}
-
-		// 鍒犻櫎鏍囩
-		if (list9ClassDelete.size() > 0) {
-			labelGoodsMapper.deleteBatchByPK(list9ClassDelete);
 		}
 
 		// 鍔犲叆闄愭椂鎶㈣喘
 		if (autoRule.isFlashSale()) {
-			updateQualityFlashSale(listAddInsert, listAddUpdate, autoRule);
+			updateQualityFlashSale(goodsList, autoRule);
 		}
-
 	}
 
-	public void updateQualityFlashSale(List<QualityFactory> listinsert, List<QualityFactory> listUpdate,
-			BoutiqueAutoRule autoRule) {
-		// 绮鹃�塱d闆嗗悎
+	
+	
+	/**
+	 *  闄愭椂绉掓潃
+	 * @param listinsert
+	 * @param listUpdate
+	 * @param autoRule
+	 */
+	public void updateQualityFlashSale(List<TaoBaoGoodsBrief> listGoods, BoutiqueAutoRule autoRule) {
+		
 		List<Long> listQFId = new ArrayList<Long>();
-
-		if (listinsert.size() > 0) {
-			for (QualityFactory qualityFactory : listinsert) {
-				listQFId.add(qualityFactory.getId());
-			}
-		}
-
-		if (listUpdate.size() > 0) {
-			for (QualityFactory qualityFactory : listUpdate) {
-				listQFId.add(qualityFactory.getId());
-			}
-		}
-
-		if (listQFId.size() == 0) {
-			return;
+		for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoods) {
+			listQFId.add(taoBaoGoodsBrief.getId());
 		}
 
 		int startWeight = autoRule.getStartWeight();
@@ -1167,49 +584,40 @@
 
 		// 鍔犲叆鍏ラ檺鏃舵姠璐�
 		List<QualityFlashSale> listFlashSale = new ArrayList<QualityFlashSale>();
-		// 闄愭椂鎶㈣喘鏇存柊锛� 鏃堕棿銆佹潈閲�
+		// 闄愭椂鎶㈣喘鏇存柊锛�
 		List<QualityFlashSale> listFlashSaleUpdate = new ArrayList<QualityFlashSale>();
+		
 
 		// 鏌ヨ宸插瓨鍦ㄦ樉绀洪檺鏃舵姠璐殑鍟嗗搧
 		List<QualityFlashSale> listQuery = qualityFlashSaleService.listQueryByQualityID(listQFId);
 		
 		if (listQuery == null || listQuery.size() == 0) {
-			// 鍏ㄩ儴鏂板鍏ュ簱
-			int i = 0;
-			for (Long qfId : listQFId) {
-				listFlashSale.add(getNewQualityFlashSale(qfId, i, startWeight, endWeight, goodsSource));
+			for (TaoBaoGoodsBrief taoBaoGoodsBrief: listGoods) {
+				listFlashSale.add(getNewQualityFlashSale(taoBaoGoodsBrief, startWeight, endWeight, goodsSource));
 			}
-			
 		} else {
-			int i = 0;
-			boolean exist = false;
 			
-			for (Long qfId : listQFId) {
+			for (TaoBaoGoodsBrief taoBaoGoodsBrief: listGoods) {
+				boolean exist = false;
+				Long id = taoBaoGoodsBrief.getId();
 				
 				for (QualityFlashSale flashSale : listQuery) {
-					QualityFactory qualityFactory = flashSale.getQualityFactory();
-					
-					if (qfId.equals(qualityFactory.getId())) {
+					TaoBaoGoodsBrief goodsBrief = flashSale.getTaoBaoGoodsBrief();
+					if (id.equals(goodsBrief.getId())) {
 						exist = true;
-
-						//鍗冲皢鍑嗗鏃堕棿娈垫椂闂�
-						//int nowType = qualityFlashSaleService.getQueryType();
-						//flashSale.setType(nowType);
-
 						double weight = startWeight + (Math.random() * ((endWeight - startWeight) + 1));
 						flashSale.setWeight(weight);
 						flashSale.setUpdatetime(new Date());
 						listFlashSaleUpdate.add(flashSale);
-
+						listQuery.remove(flashSale);
 						break;
 					}
 				}
 
 				if (!exist) {
-					listFlashSale.add(getNewQualityFlashSale(qfId, i, startWeight, endWeight, goodsSource));
+					listFlashSale.add(getNewQualityFlashSale(taoBaoGoodsBrief, startWeight, endWeight, goodsSource));
 				}
 			}
-			
 		}
 
 		// 鎻掑叆闄愭椂鎶㈣喘
@@ -1221,7 +629,6 @@
 		if (listFlashSaleUpdate.size() > 0) {
 			qualityFlashSaleService.updateBatchSelective(listFlashSaleUpdate);
 		}
-
 	}
 
 	/**
@@ -1231,31 +638,27 @@
 	 * @param i
 	 * @return
 	 */
-	public QualityFlashSale getNewQualityFlashSale(Long qfId, int i, int startWeight, int endWeight, int goodsSource) {
+	public QualityFlashSale getNewQualityFlashSale(TaoBaoGoodsBrief taoBaoGoodsBrief, int startWeight, 
+			int endWeight, int goodsSource) {
 
 		QualityFlashSale flashSale = new QualityFlashSale();
-		QualityFactory qualityFactory = new QualityFactory();
-		qualityFactory.setId(qfId);
-		flashSale.setQualityFactory(qualityFactory);
-
-		if (QualityFactory.SOURCE_TAOBAO_DATAOKE == goodsSource) {
-			// 澶ф窐瀹紭鍏堝睍绀�
-			double weight = 20000 + (Math.random() * 2001);
-			flashSale.setWeight(weight);
-		} else {
-			double weight = startWeight + (Math.random() * ((endWeight - startWeight) + 1));
-			flashSale.setWeight(weight);
-		}
-
-		//int nowType = qualityFlashSaleService.getNowType();
-		//flashSale.setType(nowType);
-
+		flashSale.setTaoBaoGoodsBrief(taoBaoGoodsBrief);
 		flashSale.setCreatetime(new Date());
 		flashSale.setUpdatetime(new Date());
-
+		
+		// 鏉冮噸璁剧疆锛氬ぇ娣樺浼樺厛灞曠ず
+		double weight = 0;
+		if (QualityFactory.SOURCE_TAOBAO_DATAOKE == goodsSource) {
+			weight = 10000 + (Math.random() * 2001);
+		} else {
+			weight = startWeight + (Math.random() * ((endWeight - startWeight) + 1));
+		}
+		flashSale.setWeight(weight);
+				
 		return flashSale;
 	}
 
+	
 	/**
 	 * 鍟嗗搧鍔犲叆绮鹃�夊簱-new QualityFactory()
 	 * 
@@ -1270,11 +673,7 @@
 
 		Integer rootCatId = goodsBrief.getRootCatId();
 		if (rootCatId != null) {
-			List<TaoBaoClassRelation> listRelation = taoBaoClassRelationMapper.listByTaoBaoCid(rootCatId.longValue());
-			if (listRelation != null && listRelation.size() > 0) {
-				TaoBaoClassRelation taoBaoClassRelation = listRelation.get(0);
-				classID = taoBaoClassRelation.getCid();
-			}
+			classID = taoBaoClassRelationMapper.getClassIdByTaoBaoCid(rootCatId.longValue());
 		}
 
 		// 娣诲姞鑷崇簿閫夊晢鍝佸簱
@@ -1301,163 +700,74 @@
 		return selectionGoods;
 
 	}
-
-	public void setTaoBaoGoodsBriefDefault(TaoBaoGoodsBrief goodsBrief) {
-		BigDecimal defaultZero = new BigDecimal("0");
-
-		if (goodsBrief.getBiz30day() == null)
-			goodsBrief.setBiz30day(0);
-
-		if (goodsBrief.getCouponAmount() == null)
-			goodsBrief.setCouponAmount(defaultZero);
-
-		if (goodsBrief.getCouponLeftCount() == null)
-			goodsBrief.setCouponLeftCount(0);
-
-		if (goodsBrief.getCouponStartFee() == null)
-			goodsBrief.setCouponStartFee(defaultZero);
-
-		if (goodsBrief.getCouponTotalCount() == null)
-			goodsBrief.setCouponTotalCount(0);
-
-		if (goodsBrief.getDayLeft() == null)
-			goodsBrief.setDayLeft(0);
-
-		if (goodsBrief.getEventCreatorId() == null)
-			goodsBrief.setEventCreatorId(0);
-
-		if (goodsBrief.getHasRecommended() == null)
-			goodsBrief.setHasRecommended(0);
-
-		if (goodsBrief.getHasSame() == null)
-			goodsBrief.setHasSame(0);
-
-		if (goodsBrief.getIncludeDxjh() == null)
-			goodsBrief.setIncludeDxjh(0);
-
-		if (goodsBrief.getLeafCatId() == null)
-			goodsBrief.setIncludeDxjh(0);
-
-		if (goodsBrief.getReservePrice() == null)
-			goodsBrief.setReservePrice(defaultZero);
-
-		if (goodsBrief.getRfdRate() == null)
-			goodsBrief.setRfdRate(0);
-
-		if (goodsBrief.getRootCatId() == null)
-			goodsBrief.setRootCatId(0);
-
-		if (goodsBrief.getRootCatScore() == null)
-			goodsBrief.setRootCatScore(0);
-
-		if (goodsBrief.getSameItemPid() == null)
-			goodsBrief.setSameItemPid(0L);
-
-		if (goodsBrief.getSellerId() == null)
-			goodsBrief.setSellerId(0L);
-
-		if (goodsBrief.getTkCommFee() == null)
-			goodsBrief.setTkCommFee(defaultZero);
-
-		if (goodsBrief.getTkRate() == null)
-			goodsBrief.setTkRate(defaultZero);
-
-		if (goodsBrief.getTotalFee() == null)
-			goodsBrief.setTotalFee(defaultZero);
-
-		if (goodsBrief.getTotalNum() == null)
-			goodsBrief.setTotalNum(0);
-
-		if (goodsBrief.getUserType() == null)
-			goodsBrief.setUserType(0);
-
-		if (goodsBrief.getZkPrice() == null)
-			goodsBrief.setZkPrice(defaultZero);
-
-	}
-
+	
+	
+	
 	/**
-	 * 鏌ヨ绮鹃�夊晢鍝佹暟鎹簲鐢ㄥ墠绔�
+	 * 鍒犻櫎鏈洿鏂扮殑鍟嗗搧
 	 * 
-	 * @param start
-	 * @param count
-	 * @param key
-	 * @param classId
-	 *            鍒嗙被id
-	 * @param labId
-	 *            鏍囩id
-	 * @return
+	 * @param systemCid
+	 * @param formatDate
+	 * @param source
 	 */
+	@Override
+	public void deleteNotUpdateGoods(Long systemCid, String formatDate, int source) {
+		List<Long> list = qualityFactoryMapper.getAuctionIdbyClassId(systemCid, source, formatDate);
+		if (list == null || list.size() == 0) {
+			return;
+		}
+
+		// 灏忎簬100鏉$洿鎺ュ垹闄�
+		if (list.size() <= 100) {
+			// 鍒犻櫎绮鹃�夊簱
+			deleteBatchByTaoBaoGoodsId(list);
+			// 鍒犻櫎鍟嗗搧
+			taoBaoGoodsBriefService.deleteBatchByGoodsId(list);
+			return;
+		} 
+		
+		// 澶т簬100闇�瑕佸垎娈靛垹闄�
+		int start = 0;
+		int end = 100;
+		int countRow = 100;
+
+		int count = list.size() / countRow;
+		if (list.size() % countRow > 0) {
+			count += 1;
+		}
+
+		for (int i = 0; i < count; i++) {
+			List<Long> sublist = new ArrayList<Long>();
+			if (i == count - 1) {
+				sublist = list.subList(start, list.size());
+				deleteBatchByTaoBaoGoodsId(sublist);
+				taoBaoGoodsBriefService.deleteBatchByGoodsId(sublist);
+				break;
+			}
+			sublist = list.subList(start, end);
+			deleteBatchByTaoBaoGoodsId(sublist);
+			taoBaoGoodsBriefService.deleteBatchByGoodsId(sublist);
+			start += countRow;
+			end += countRow;
+		}
+	}
+	
+
+
 	@Override
 	public List<QualityFactory> listQuery(long start, int count, String key, Long classId, Long labId) {
 		return qualityFactoryMapper.listQuery(start, count, key, classId, labId, null, null);
 	}
-
-	/**
-	 * 瀵瑰簲鏌ヨ绮鹃�夊晢鍝佹暟鎹簲鐢ㄥ墠绔粺璁�
-	 */
+	
 	@Override
 	public long countQuery(String key, Integer goodsSource, Long classId, Long labId) {
 		return qualityFactoryMapper.countQuery(key, classId, labId, null, null);
 	}
 
-	public LabelGoods screen9K9(TaoBaoGoodsBrief goodsBrief, Map<String, Label> map) {
-		// 璐翠笂鏂版爣绛�
-		LabelGoods lg = null;
-
-		/* 9k9 */
-		BigDecimal price9k9 = new BigDecimal(10);
-		/* 19k9 */
-		BigDecimal price19k9 = new BigDecimal(20);
-		/* 29.9 */
-		BigDecimal price29K9 = new BigDecimal(30);
-		/* 49.9 */
-		BigDecimal price49K9 = new BigDecimal(50);
-		/* 鍒稿悗浠�--璁$畻 */
-		BigDecimal couponPrice = TaoBaoUtil.getAfterUseCouplePrice(goodsBrief);
-
-		if (couponPrice.compareTo(price9k9) < 0) {
-			Label label = map.get("9.9");
-			if (label == null) {
-				return null;
-			}
-
-			lg = new LabelGoods();
-			lg.setLabel(label);
-
-		} else if (couponPrice.compareTo(price19k9) < 0) {
-			Label label = map.get("19.9");
-			if (label == null) {
-				return null;
-			}
-
-			lg = new LabelGoods();
-			lg.setLabel(label);
-		} else if (couponPrice.compareTo(price29K9) < 0) {
-			Label label = map.get("29.9");
-			if (label == null) {
-				return null;
-			}
-
-			lg = new LabelGoods();
-			lg.setLabel(label);
-		} else if (couponPrice.compareTo(price49K9) < 0) {
-			Label label = map.get("49.9");
-			if (label == null) {
-				return null;
-			}
-
-			lg = new LabelGoods();
-			lg.setLabel(label);
-		} else {
-			return null;
-		}
-
-		lg.setCreateUser(new AdminUser(2L));
-		lg.setCreatetime(new Date());
-		lg.setTaoBaoGoodsBrief(goodsBrief);
-
-		return lg;
+	@Override
+	public List<QualityFactory> listByMinSalesCountOrderByCreateTimeDesc(int salesCount, int page, int pageSize) {
+		return qualityFactoryMapper.listByMinSalesCountOrderByCreateTimeDesc(salesCount, (page - 1) * pageSize,
+				pageSize);
 	}
 
 }

--
Gitblit v1.8.0