| | |
| | | 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;
|
| | |
| | | @Resource
|
| | | 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) {
|
| | |
| | | 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
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int removeStorageGoods(String doTime, Long gcids) throws QualityFactoryException {
|
| | | return qualityFactoryMapper.removeStorageGoods(doTime, gcids);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public QualityFactory selectByPrimaryKey(Long id) throws QualityFactoryException {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | List<String> strList = new ArrayList<String>();
|
| | | for (Long id : auctionIdList) {
|
| | | strList.add(id + "");
|
| | | }
|
| | | List<TaoBaoGoodsBrief> existList = taoBaoGoodsBriefRecordMapper.queryGoodsByAuctionId(strList);
|
| | | List<TaoBaoGoodsBrief> existList = taoBaoGoodsBriefRecordMapper.queryByAuctionIdList(auctionIdList);
|
| | |
|
| | | List<QualityFactory> addList = new ArrayList<QualityFactory>();
|
| | | List<LabelGoods> addLabelList = new ArrayList<LabelGoods>();
|
| | |
| | | TaoBaoGoodsBrief currentGoodsBrief = taoBaoGoodsBriefList.get(0);
|
| | |
|
| | | goodsBrief.setId(currentGoodsBrief.getId());
|
| | | // 非空项 处理
|
| | | setTaoBaoGoodsBriefDefault(goodsBrief);
|
| | | |
| | | // 更新商品最新信息
|
| | | taoBaoGoodsBriefService.updateByPrimaryKey(goodsBrief);
|
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(goodsBrief);
|
| | | |
| | | } else {
|
| | |
|
| | | // 插入本地数据库
|
| | |
| | | // 更新商品
|
| | | QualityFactory selectionGoods = selectionList.get(0);
|
| | | selectionGoods.setUpdatetime(new Date());
|
| | | qualityFactoryMapper.updateByPrimaryKey(selectionGoods);
|
| | | qualityFactoryMapper.updateByPrimaryKeySelective(selectionGoods);
|
| | | }
|
| | |
|
| | | if (listLabs.size() > 0) {
|
| | |
| | | }
|
| | |
|
| | | // 修改权重
|
| | | // selectionGoods.setUpdateUser(admin);
|
| | | selectionGoods.setUpdateUser(admin);
|
| | | selectionGoods.setWeight(resultWeight);
|
| | | qualityFactoryMapper.updateByPrimaryKeySelective(selectionGoods);
|
| | | }
|
| | |
| | |
|
| | | @Override
|
| | | public List<Long> queryNeedUpdate(long start, int count, int hour) {
|
| | | return qualityFactoryMapper.queryNeedUpdate(0, count, hour);
|
| | | return qualityFactoryMapper.queryNeedUpdate(start, count, hour);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | |
| | | // 删除精选库
|
| | | List<Long> listDeleteQuality = new ArrayList<Long>();
|
| | | // 删除标签
|
| | | List<Long> listDeleteLabel = new ArrayList<Long>();
|
| | | |
| | |
|
| | | List<QualityFactory> listUpdateQuality = new ArrayList<QualityFactory>();
|
| | |
|
| | |
| | |
|
| | | /* 无券信息 移除精选库 */
|
| | | listDeleteQuality.add(quality.getId());
|
| | | // 移除标签
|
| | | listDeleteLabel.add(goods.getId());
|
| | |
|
| | | } else {
|
| | | /* 无券信息 移除精选库 */
|
| | |
| | |
|
| | | // 移除精选库
|
| | | listDeleteQuality.add(quality.getId());
|
| | | // 移除标签
|
| | | listDeleteLabel.add(goods.getId());
|
| | |
|
| | | } else {
|
| | | /* 更新商品信息 */
|
| | | TaoBaoGoodsBrief updateGoods = taoBaoGoodsUpdateService
|
| | | .getUpdateTaoBaoGoodsBrief(newGoodsBrief);
|
| | | 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);
|
| | | }
|
| | | |
| | | // 添加标签
|
| | | if (listLabelAdd.size() > 0) {
|
| | | labelGoodsMapper.insertBatch(listLabelAdd);
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void updateBatchQualityFactory(List<QualityFactory> listQuality, List<Long> list9Class,
|
| | | Map<String, Label> map) throws Exception {
|
| | |
|
| | | if (listQuality == null || listQuality.size() == 0) {
|
| | | return;
|
| | | }
|
| | |
|
| | | List<Long> listDeleteQuality = new ArrayList<Long>();
|
| | | List<QualityFactory> listUpdateQuality = new ArrayList<QualityFactory>();
|
| | |
|
| | | List<Long> listGid = new ArrayList<Long>();
|
| | | List<TaoBaoGoodsBrief> listUpdateGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
|
| | |
|
| | | List<Long> list9ClassDelete = new ArrayList<Long>();
|
| | | // 添加商品标签列表
|
| | | List<LabelGoods> listLabelAdd = new ArrayList<LabelGoods>();
|
| | |
|
| | | 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);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | } catch (TaobaoGoodsDownException e1) {
|
| | | // 商品下架 移除数据库
|
| | | taoBaoGoodsUpdateService.deleteTaoBaoGoods(auctionId);
|
| | |
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | });
|
| | |
|
| | | // 更新商品信息
|
| | | if (listUpdateGoodsBrief.size() > 0) {
|
| | | taoBaoGoodsBriefService.updateBatchSelective(listUpdateGoodsBrief);
|
| | | }
|
| | |
|
| | | // 更新精选库
|
| | | if (listUpdateQuality.size() > 0) {
|
| | | 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,
|
| | |
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | taoBaoGoodsBriefService.updateBatchSelective(listGoodsUpdate);
|
| | | try {
|
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(listGoodsUpdate);
|
| | | } catch (TaobaoGoodsUpdateException e) {
|
| | | System.out.println(e.getMsg());
|
| | | }
|
| | | }
|
| | |
|
| | | // 淘宝商品插入数据库
|