| | |
| | | package com.yeshi.fanli.service.impl.taobao.dataoke;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.dataoke.DaTaoKeDetailMapper;
|
| | | import com.yeshi.fanli.dto.dataoke.DaTaoKeApiResult;
|
| | | import com.yeshi.fanli.dto.dataoke.DingDongQiangDTO;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | |
| | | addGoodsList(result.getDetailList());
|
| | | totalCount += result.getDetailList().size();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | LogHelper.test("大淘客总共更新数据数量:" + totalCount);
|
| | |
| | | List<DaTaoKeDetail> dtList = listByGoodsIds(goodsIdList);
|
| | |
|
| | | Map<Long, DaTaoKeDetail> map = new HashMap<>();
|
| | | for (DaTaoKeDetail goods : dtList)
|
| | | map.put(goods.getGoodsId(), goods);
|
| | | if (dtList != null)
|
| | | for (DaTaoKeDetail goods : dtList)
|
| | | map.put(goods.getGoodsId(), goods);
|
| | | for (TaoBaoGoodsBrief goods : goodsList) {
|
| | | DaTaoKeDetail detail = map.get(goods.getAuctionId());
|
| | | goods = DaTaoKeUtil.filterTaoBaoGoods(goods, detail);
|
| | |
| | | return daTaoKeDetailMapper.getGoodsNotInList(cid, listId, count);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<DaTaoKeDetail> listByCidAndMaxPrice(Integer cid, BigDecimal maxPrice, int page, int pageSize) {
|
| | | return daTaoKeDetailMapper.listByCidAndMaxMinPrice(cid, maxPrice, null, (page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Long countByCidAndMaxPrice(Integer cid, BigDecimal maxPrice) {
|
| | |
|
| | | return daTaoKeDetailMapper.countByCidAndMaxMinPrice(cid, maxPrice, null);
|
| | | }
|
| | |
|
| | | @Cacheable(value = "daTaoKeGoodsCache", key = "'getDingDongQiangData'")
|
| | | @Override
|
| | | public List<DingDongQiangDTO> getDingDongQiangData() {
|
| | | List<DingDongQiangDTO> list = null;
|
| | | int count = 0;
|
| | | while ((list == null || list.size() == 0) && count < 3) {
|
| | | count++;
|
| | | list = DaTaoKeUtil.getDingDongQiang();
|
| | | }
|
| | | if (list == null)
|
| | | return null;
|
| | | return list;
|
| | | }
|
| | |
|
| | | private void updateGoods(Long id) {
|
| | | DaTaoKeDetail detail = daTaoKeDetailMapper.selectByPrimaryKey(id);
|
| | | if (detail != null)
|
| | | return;
|
| | | detail = DaTaoKeApiUtil.getGoodsDetailV1(id);
|
| | | if (detail != null) {
|
| | | List<DaTaoKeDetail> list = new ArrayList<>();
|
| | | list.add(detail);
|
| | | addGoodsList(list);
|
| | | }
|
| | | }
|
| | |
|
| | | @Cacheable(value = "daTaoKeGoodsCache", key = "'getDingDongQiangData-'+#time")
|
| | | @Override
|
| | | public List<DaTaoKeDetail> getDingDongQiangData(String time) {
|
| | | List<DingDongQiangDTO> list = getDingDongQiangData();
|
| | | if (list == null)
|
| | | return null;
|
| | | Map<String, DingDongQiangDTO> map = new HashMap<>();
|
| | | for (DingDongQiangDTO dto : list)
|
| | | map.put(dto.getTime(), dto);
|
| | |
|
| | | DingDongQiangDTO dto = map.get(time);
|
| | | if (dto != null) {
|
| | | List<Long> idList = new ArrayList<>();
|
| | | for (DaTaoKeDetail td : dto.getGoodsList())
|
| | | idList.add(td.getId());
|
| | | List<DaTaoKeDetail> finalList = listByIds(idList);
|
| | | if (finalList.size() != idList.size()) {
|
| | | for (Long id : idList)
|
| | | updateGoods(id);
|
| | | finalList = listByIds(idList);
|
| | | }
|
| | |
|
| | | for (DaTaoKeDetail detail : finalList) {
|
| | | detail.setQuanReceive(
|
| | | detail.getQuanSurplus() + detail.getQuanReceive() - (int) (200 + Math.random() * 1000));
|
| | | }
|
| | | return finalList;
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|