From 8fd3a5fa4eca64e2a169bb7e3e2d823c8fa82211 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 14 五月 2019 12:36:01 +0800
Subject: [PATCH] 订单增加订单类型
---
fanli/src/main/java/com/yeshi/fanli/service/impl/lable/QualityFactoryServiceImpl.java | 144 +++++++++++++----------------------------------
1 files changed, 40 insertions(+), 104 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 020d4f2..b56cc2d 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
@@ -8,16 +8,15 @@
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;
@@ -41,6 +40,7 @@
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 +59,6 @@
private TaoBaoGoodsBriefMapper taoBaoGoodsBriefMapper;
@Resource
private TaoBaoUnionConfigService taoBaoUnionConfigService;
- @Resource
- private TaoBaoGoodsBriefRecordMapper taoBaoGoodsBriefRecordMapper;
@Resource
private TaoBaoClassRelationMapper taoBaoClassRelationMapper;
@Resource
@@ -174,29 +172,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
@@ -216,98 +198,44 @@
@Override
@Transactional
- public void addBatch(List<Long> auctionIdList, String lableNames, AdminUser admin) throws Exception {
+ 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<TaoBaoGoodsBrief> existList = taoBaoGoodsBriefRecordMapper.queryByAuctionIdList(auctionIdList);
+ // 鍒涘缓鏍囩
+ List<Label> listLabel = labelService.addBatchByNames(lableNames, admin);
- List<QualityFactory> addList = new ArrayList<QualityFactory>();
- List<LabelGoods> addLabelList = new ArrayList<LabelGoods>();
+ List<QualityFactory> listQuality = new ArrayList<QualityFactory>();
+ List<LabelGoods> listLabelGoods = new ArrayList<LabelGoods>();
- for (Long auctionId : auctionIdList) {
+ for (TaoBaoGoodsBrief goodsBrief : listTaoBaoGoods) {
- boolean process = false;
- TaoBaoGoodsBrief goodsBrief = null;
+ // 鏈湴鏄惁宸插瓨鍦ㄦ鍟嗗搧
+ List<TaoBaoGoodsBrief> hasList = taoBaoGoodsBriefService.queryByAuctionId(goodsBrief.getAuctionId());
- 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;
- }
- }
- }
-
- 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);
-
+ if (hasList != null && hasList.size() > 0) {
+ TaoBaoGoodsBrief currentGoodsBrief = hasList.get(0);
goodsBrief.setId(currentGoodsBrief.getId());
// 鏇存柊鍟嗗搧鏈�鏂颁俊鎭�
taoBaoGoodsUpdateService.updateTaoBaoGoods(goodsBrief);
-
} 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);
+ List<QualityFactory> selectionList = qualityFactoryMapper.queryByGoodsId(goodsBrief.getId());
- /* 杩涘叆绮鹃�夊晢鍝佸簱 */
if (selectionList == null || selectionList.size() == 0) {
// 娣诲姞鑷崇簿閫夊晢鍝佸簱
QualityFactory selectionGoods = new QualityFactory();
@@ -322,7 +250,7 @@
selectionGoods.setEntryMode(QualityFactory.MODE_MANUAL);// 浜哄伐绛涢��
selectionGoods.setGoodsSource(QualityFactory.SOURCE_TAOBAO);// 鏉ユ簮娣樺疂
- addList.add(selectionGoods);
+ listQuality.add(selectionGoods);
} else {
// 鏇存柊鍟嗗搧
QualityFactory selectionGoods = selectionList.get(0);
@@ -330,10 +258,10 @@
qualityFactoryMapper.updateByPrimaryKeySelective(selectionGoods);
}
- if (listLabs.size() > 0) {
- for (Label label : listLabs) {
+ if (listLabel != null && listLabel.size() > 0) {
+ for (Label label : listLabel) {
/* 璐翠笂鏍囩 锛� 宸茶创涓嶅鐞嗗垯 */
- Long existence = labelGoodsMapper.isExistence(id, label.getId());
+ Long existence = labelGoodsMapper.isExistence(goodsBrief.getId(), label.getId());
// 璇ュ晢鍝佷笉瀛樺湪姝ゆ爣绛惧垯娣诲姞锛� 鍙嶄箣涓嶅仛澶勭悊
if (existence == null || existence == 0l) {
@@ -343,19 +271,19 @@
lg.setCreateUser(admin);
lg.setCreatetime(new Date());
lg.setTaoBaoGoodsBrief(goodsBrief);
-
- addLabelList.add(lg);
+ listLabelGoods.add(lg);
}
}
}
+
}
- if (addList.size() > 0) {
- qualityFactoryMapper.insertBatch(addList);
+ if (listQuality.size() > 0) {
+ qualityFactoryMapper.insertBatch(listQuality);
}
- if (addLabelList.size() > 0) {
- labelGoodsMapper.insertBatch(addLabelList);
+ if (listLabelGoods.size() > 0) {
+ labelGoodsMapper.insertBatch(listLabelGoods);
}
}
@@ -652,6 +580,7 @@
try {
TaoBaoGoodsBrief taoBaoGoodsBrief = TaoKeApiUtil.searchGoodsDetail(goods.getAuctionId());
if (taoBaoGoodsBrief != null) {
+
listGoodsBrief.add(taoBaoGoodsBrief);
}
@@ -669,6 +598,13 @@
}
}
+ for (int i = 0; i < goodsList.size(); i++) {
+ if (goodsList.get(i).getMaterialLibType() != null && goodsList.get(i).getMaterialLibType() == 0) {
+ goodsList.remove(i);
+ i--;
+ }
+ }
+
// 鍟嗗搧id闆嗗悎
List<Long> listSystemTBid = new ArrayList<Long>();
--
Gitblit v1.8.0