| | |
| | | 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.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.QualityFactoryException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.lable.LabelService;
|
| | |
| | | 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 {
|
| | |
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | | @Resource
|
| | | private TaoBaoGoodsBriefRecordMapper taoBaoGoodsBriefRecordMapper;
|
| | | @Resource
|
| | | private TaoBaoClassRelationMapper taoBaoClassRelationMapper;
|
| | | @Resource
|
| | | private QualityFlashSaleService qualityFlashSaleService;
|
| | |
| | | @Resource
|
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
|
| | |
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKeySelective(QualityFactory record) throws QualityFactoryException {
|
| | | return qualityFactoryMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public void deleteByTbAuctionId(Long auctionId) {
|
| | |
| | | labelGoodsMapper.deleteBatchByGoodsId(listGid);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void deleteByGoodsId(List<String> ids) throws QualityFactoryException {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public QualityFactory selectByPrimaryKey(Long id) throws QualityFactoryException {
|
| | |
| | | }
|
| | |
|
| | | @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<String> strList = new ArrayList<String>();
|
| | | for (Long id : auctionIdList) {
|
| | | strList.add(id + "");
|
| | | }
|
| | | List<TaoBaoGoodsBrief> existList = taoBaoGoodsBriefRecordMapper.queryGoodsByAuctionId(strList);
|
| | | // 创建标签
|
| | | 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);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | return qualityFactoryMapper.queryNeedUpdate(start, 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 {
|
| | |
|
| | | 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) {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | return value;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void updateGoodsFactory(List<Long> listId) {
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | |
| | | // 删除精选库
|
| | | List<Long> listDeleteQuality = new ArrayList<Long>();
|
| | | |
| | | // 删除标签
|
| | | List<Long> listDeleteLabel = new ArrayList<Long>();
|
| | |
|
| | | List<QualityFactory> listUpdateQuality = new ArrayList<QualityFactory>();
|
| | |
|
| | | List<TaoBaoGoodsBrief> listUpdateGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
|
| | |
| | | List<LabelGoods> listLabelAdd = new ArrayList<LabelGoods>();
|
| | |
|
| | | 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)); |
| | | list9Class.add(Long.parseLong(value9K9));
|
| | | }
|
| | | |
| | |
|
| | | if (!StringUtil.isNullOrEmpty(value19K9)) {
|
| | | map.put("19.9", new Label(Long.parseLong(value19K9)));
|
| | | list9Class.add(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)); |
| | | list9Class.add(Long.parseLong(value29K9));
|
| | | }
|
| | | |
| | |
|
| | | if (!StringUtil.isNullOrEmpty(value49K9)) {
|
| | | map.put("49.9", new Label(Long.parseLong(value49K9)));
|
| | | list9Class.add(Long.parseLong(value49K9)); |
| | | list9Class.add(Long.parseLong(value49K9));
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | |
|
| | | listQuality.parallelStream().forEach(quality -> {
|
| | |
| | |
|
| | | /* 无券信息 移除精选库 */
|
| | | listDeleteQuality.add(quality.getId());
|
| | | // 移除标签
|
| | | listDeleteLabel.add(goods.getId());
|
| | |
|
| | | } else {
|
| | | /* 无券信息 移除精选库 */
|
| | |
| | |
|
| | | // 移除精选库
|
| | | listDeleteQuality.add(quality.getId());
|
| | | // 移除标签
|
| | | listDeleteLabel.add(goods.getId());
|
| | |
|
| | | } else {
|
| | | /* 更新商品信息 */
|
| | | TaoBaoGoodsBrief updateGoods = taoBaoGoodsUpdateService
|
| | | .getUpdateTaoBaoGoodsBrief(newGoodsBrief);
|
| | |
|
| | | updateGoods.setId(id);
|
| | | taoBaoGoodsBriefService.setGoodsBriefDefault(updateGoods);
|
| | |
|
| | | listUpdateGoodsBrief.add(updateGoods);
|
| | |
|
| | | /* 更新精选库 信息时间 */
|
| | |
| | |
|
| | | // 更新商品信息
|
| | | if (listUpdateGoodsBrief.size() > 0) {
|
| | | taoBaoGoodsBriefService.updateBatchSelective(listUpdateGoodsBrief);
|
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(listUpdateGoodsBrief);
|
| | | }
|
| | |
|
| | | // 更新精选库
|
| | |
| | | // 批量删除精选库
|
| | | if (listDeleteQuality.size() > 0) {
|
| | | qualityFactoryMapper.deleteBatchByPrimaryKey(listDeleteQuality);
|
| | | // 批量删除限时抢购
|
| | | qualityFlashSaleMapper.deleteBatchByQualityID(listDeleteQuality);
|
| | | }
|
| | |
|
| | | // 删除对应标签
|
| | | if (listDeleteLabel.size() > 0) {
|
| | | labelGoodsMapper.deleteBatchByGoodsId(listDeleteLabel);
|
| | | }
|
| | |
|
| | | // 添加标签
|
| | |
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public void autoInsertOrUpadateStorage(List<TaoBaoGoodsBrief> goodsList, List<Label> listLabs,
|
| | | BoutiqueAutoRule autoRule) throws Exception {
|
| | |
| | | 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>();
|
| | |
|
| | |
| | | List<QualityFactory> listAddInsert = new ArrayList<QualityFactory>();
|
| | | // 进入精选商品列表
|
| | | List<QualityFactory> listAddUpdate = new ArrayList<QualityFactory>();
|
| | | |
| | |
|
| | | // 插入商品淘宝ID集合
|
| | | List<Long> listAuctionId = new ArrayList<Long>();
|
| | |
| | |
|
| | | /* 商品已存在数据库 */
|
| | | if (isExist && systemId != null) {
|
| | | |
| | |
|
| | | // 用于确定是否存在精选库
|
| | | listSystemTBid.add(systemId);
|
| | | |
| | |
|
| | | // 更新商品信息
|
| | | TaoBaoGoodsBrief updateGoods = taoBaoGoodsUpdateService.getUpdateTaoBaoGoodsBrief(newGoodsBrief);
|
| | | // 设置主键id
|
| | |
| | | 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 、同时来源淘宝推荐: 由于获取详情与推荐接口的券信息存在出入 以最后详情为准
|
| | | if (list9Class.contains(label.getId()) && autoRule.isCalss9k9() && QualityFactory.SOURCE_TAOBAO_MATERIAL == autoRule.getGoodsSource()) {
|
| | | |
| | | /* 获取商品详情后计算是否属于 9k9系列 加入对应的标签*/
|
| | |
|
| | | // 包含 9.9/19.9/29.9/49.9 、同时来源淘宝推荐: 由于获取详情与推荐接口的券信息存在出入
|
| | | // 以最后详情为准
|
| | | 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; |
| | | has9k9ID = id;
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | | |
| | |
|
| | | } else {
|
| | | |
| | |
|
| | | long existence = labelGoodsMapper.isExistence(systemId, label.getId());
|
| | | if (existence <= 0) {
|
| | | // 贴上新标签
|
| | |
| | |
|
| | | listLabelAdd.add(lg);
|
| | | } else {
|
| | | if(list9Class.contains(label.getId())){
|
| | | if (list9Class.contains(label.getId())) {
|
| | | // 已存在
|
| | | has9k9ID = 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入库规则 若商品信息变化 对应的标签根据价格 修改
|
| | | // 非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; |
| | | 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); // 状态启用
|
| | |
| | |
|
| | | // 贴上标签
|
| | | if (listLabs != null && listLabs.size() > 0) {
|
| | | |
| | |
|
| | | for (Label label : listLabs) {
|
| | | |
| | | // 包含 9.9/19.9/29.9/49.9 、同时来源淘宝推荐: 由于获取详情与推荐接口的券信息存在出入 以最后详情为准
|
| | | if (list9Class.contains(label.getId()) && autoRule.isCalss9k9() && |
| | | QualityFactory.SOURCE_TAOBAO_MATERIAL == autoRule.getGoodsSource()) {
|
| | | /* 加入对应的9.9/19.9/29.9/49.9 标签*/
|
| | |
|
| | | // 包含 9.9/19.9/29.9/49.9 、同时来源淘宝推荐: 由于获取详情与推荐接口的券信息存在出入
|
| | | // 以最后详情为准
|
| | | 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.setTaoBaoGoodsBrief(newGoodsBrief);
|
| | | listLabelAdd.add(lg);
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | taoBaoGoodsBriefService.updateBatchSelective(listGoodsUpdate);
|
| | | try {
|
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(listGoodsUpdate);
|
| | | } catch (TaobaoGoodsUpdateException e) {
|
| | | System.out.println(e.getMsg());
|
| | | }
|
| | | }
|
| | |
|
| | | // 淘宝商品插入数据库
|
| | |
| | |
|
| | | // 查询已存在显示限时抢购的商品
|
| | | 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));
|
| | | }
|
| | | |
| | |
|
| | | } else {
|
| | | int i = 0;
|
| | | boolean exist = false;
|
| | | |
| | |
|
| | | for (Long qfId : listQFId) {
|
| | | |
| | |
|
| | | for (QualityFlashSale flashSale : listQuery) {
|
| | | QualityFactory qualityFactory = flashSale.getQualityFactory();
|
| | | |
| | |
|
| | | if (qfId.equals(qualityFactory.getId())) {
|
| | | exist = true;
|
| | |
|
| | | //即将准备时间段时间
|
| | | //int nowType = qualityFlashSaleService.getQueryType();
|
| | | //flashSale.setType(nowType);
|
| | | // 即将准备时间段时间
|
| | | // int nowType = qualityFlashSaleService.getQueryType();
|
| | | // flashSale.setType(nowType);
|
| | |
|
| | | double weight = startWeight + (Math.random() * ((endWeight - startWeight) + 1));
|
| | | flashSale.setWeight(weight);
|
| | |
| | | listFlashSale.add(getNewQualityFlashSale(qfId, i, startWeight, endWeight, goodsSource));
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | |
|
| | | // 插入限时抢购
|
| | |
| | | flashSale.setWeight(weight);
|
| | | }
|
| | |
|
| | | //int nowType = qualityFlashSaleService.getNowType();
|
| | | //flashSale.setType(nowType);
|
| | | // int nowType = qualityFlashSaleService.getNowType();
|
| | | // flashSale.setType(nowType);
|
| | |
|
| | | flashSale.setCreatetime(new Date());
|
| | | flashSale.setUpdatetime(new Date());
|
| | |
| | | return lg;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<QualityFactory> listByMinSalesCountOrderByCreateTimeDesc(int salesCount, int page, int pageSize) {
|
| | | return qualityFactoryMapper.listByMinSalesCountOrderByCreateTimeDesc(salesCount, (page - 1) * pageSize,
|
| | | pageSize);
|
| | | }
|
| | |
|
| | | }
|