| | |
| | | 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.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 {
|
| | |
| | | private TaoBaoGoodsBriefMapper taoBaoGoodsBriefMapper;
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | | @Resource
|
| | | private TaoBaoGoodsBriefRecordMapper taoBaoGoodsBriefRecordMapper;
|
| | | @Resource
|
| | | private TaoBaoClassRelationMapper taoBaoClassRelationMapper;
|
| | | @Resource
|
| | |
| | | }
|
| | |
|
| | | @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
|
| | |
| | |
|
| | | @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();
|
| | |
| | | selectionGoods.setEntryMode(QualityFactory.MODE_MANUAL);// 人工筛选
|
| | | selectionGoods.setGoodsSource(QualityFactory.SOURCE_TAOBAO);// 来源淘宝
|
| | |
|
| | | addList.add(selectionGoods);
|
| | | listQuality.add(selectionGoods);
|
| | | } else {
|
| | | // 更新商品
|
| | | QualityFactory selectionGoods = selectionList.get(0);
|
| | |
| | | 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) {
|
| | |
| | | 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);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | try {
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = TaoKeApiUtil.searchGoodsDetail(goods.getAuctionId());
|
| | | if (taoBaoGoodsBrief != null) {
|
| | |
|
| | | listGoodsBrief.add(taoBaoGoodsBrief);
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | 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>();
|
| | |
|