| | |
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void addBatch(List<Long> auctionIdList, 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);
|
| | | public void addBatchGoodsByTaoBaoId(List<Long> listTaoBaoId, String lableNames, AdminUser admin) |
| | | throws Exception {
|
| | | |
| | | List<TaoBaoGoodsBrief> listAddGoods = new ArrayList<TaoBaoGoodsBrief>();
|
| | | if (listTaoBaoId != null && listTaoBaoId.size() > 0) {
|
| | | for (Long auctionId: listTaoBaoId) {
|
| | | /* 根据auctionId 获取淘宝商品 */
|
| | | TaoBaoGoodsBrief goodsBrief = TaoKeApiUtil.searchGoodsDetail(auctionId);
|
| | | if (goodsBrief != null) {
|
| | | listAddGoods.add(goodsBrief);
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBrief> existList = taoBaoGoodsBriefRecordMapper.queryByAuctionIdList(auctionIdList);
|
| | | |
| | | @Override
|
| | | @Transactional
|
| | | public void addBatchTaoBaoGoods(List<TaoBaoGoodsBrief> listTaoBaoGoods, String lableNames, AdminUser admin) throws Exception {
|
| | | |
| | | if (listTaoBaoGoods == null || listTaoBaoGoods.size() == 0) {
|
| | | throw new Exception("未找到匹配的商品");
|
| | | }
|
| | | |
| | | // 创建标签
|
| | | 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);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | @Transactional
|
| | | public void setWeightBatch(List<Long> idList, AdminUser admin, Integer weight, Integer weightSmall,
|