| | |
| | | package com.yeshi.fanli.service.impl.brand;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | |
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.brand.BrandGoodsCaheDao;
|
| | | import com.yeshi.fanli.dao.brand.BrandShopCaheDao;
|
| | | import com.yeshi.fanli.dto.jd.JDFilter;
|
| | | import com.yeshi.fanli.dto.jd.JDSearchFilter;
|
| | | import com.yeshi.fanli.dto.jd.JDSearchResult;
|
| | | import com.yeshi.fanli.dto.jd.JDShopInfo;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
|
| | | import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
|
| | | import com.yeshi.fanli.entity.brand.BrandGoodsCahe;
|
| | | import com.yeshi.fanli.entity.brand.BrandInfo;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.taobao.SearchFilter;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.brand.BrandShopCahe;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoShop;
|
| | | import com.yeshi.fanli.service.inter.brand.BrandShopCaheService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.jd.JDUtil;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.goods.ShopInfoVOFactory;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.SearchFilterUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.goods.ShopInfoVO;
|
| | |
|
| | | @Service
|
| | | public class BrandShopCaheServiceImpl implements BrandShopCaheService {
|
| | |
| | | @Resource
|
| | | private BrandShopCaheDao brandShopCaheDao;
|
| | |
|
| | | |
| | | @Override
|
| | | public void addBrandShop(BrandInfo brandInfo) {
|
| | | int count = 0;
|
| | | // // 淘宝
|
| | | // count += addBrandShopTB(brandInfo);
|
| | | // // 京东
|
| | | // count += addBrandShopJD(brandInfo);
|
| | | // // 拼多多
|
| | | // count += addBrandShopPDD(brandInfo);
|
| | | |
| | | }
|
| | | @Resource
|
| | | private TaoBaoShopService taoBaoShopService;
|
| | |
|
| | |
|
| | | /**
|
| | | * 淘宝商品
|
| | | * 淘宝店铺
|
| | | * @param brandInfo
|
| | | * @return
|
| | | */
|
| | | private void addBrandShopTB(BrandInfo brandInfo) {
|
| | | @Override
|
| | | public boolean addBrandShopTB(BrandInfo brandInfo, Long auctionId, Long sellerId) {
|
| | | TaoBaoShop taoBaoShop = taoBaoShopService.getTaoBaoShop(auctionId, sellerId);
|
| | | if (taoBaoShop == null)
|
| | | return true;
|
| | |
|
| | | ShopInfoVO shopInfoVO = ShopInfoVOFactory.convertTaoBaoShop(taoBaoShop);
|
| | | shopInfoVO.setShopIcon(brandInfo.getIcon());
|
| | | |
| | | BrandShopCahe brandShop = new BrandShopCahe();
|
| | | brandShop.setBrandId(brandInfo.getId());
|
| | | brandShop.setShop(shopInfoVO);
|
| | | brandShop.setCreateTime(new Date());
|
| | | brandShopCaheDao.insert(brandShop);
|
| | | return false;
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 京东商品
|
| | | * 京东
|
| | | *
|
| | | * @param brandInfo
|
| | | * @return
|
| | | */
|
| | | private void addBrandShopJD(BrandInfo brandInfo) {
|
| | | @Override
|
| | | public void addBrandShopJD(BrandInfo brandInfo, JDShopInfo shopInfo) {
|
| | | ShopInfoVO shopInfoVO = ShopInfoVOFactory.convertJDShop(shopInfo);
|
| | | shopInfoVO.setShopIcon(brandInfo.getIcon());
|
| | |
|
| | | BrandShopCahe brandShop = new BrandShopCahe();
|
| | | brandShop.setBrandId(brandInfo.getId());
|
| | | brandShop.setShop(shopInfoVO);
|
| | | brandShop.setCreateTime(new Date());
|
| | | brandShopCaheDao.insert(brandShop);
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 拼多多商品
|
| | | * 拼多多
|
| | | * @param brandInfo
|
| | | * @return
|
| | | */
|
| | | private void addBrandShopPDD(BrandInfo brandInfo) {
|
| | | @Override
|
| | | public int addBrandShopPDD(BrandInfo brandInfo) {
|
| | | String shopKey = brandInfo.getShopKeyPDD();
|
| | | if (StringUtil.isNullOrEmpty(shopKey))
|
| | | return 0;
|
| | |
|
| | | String searchKey = brandInfo.getSearchKeyPDD();
|
| | | if (StringUtil.isNullOrEmpty(searchKey))
|
| | | searchKey = brandInfo.getName();
|
| | | |
| | | ShopInfoVO shopInfoVO = null;
|
| | | PDDSearchFilter pddfilter = new PDDSearchFilter();
|
| | | pddfilter.setKw(searchKey);
|
| | | pddfilter.setPage(1);
|
| | | pddfilter.setPageSize(100);
|
| | | pddfilter.setSortType(6);
|
| | | pddfilter.setMerchantType(3);
|
| | | |
| | | PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
|
| | | if (result != null && result.getGoodsList() != null && result.getGoodsList().size() > 0) {
|
| | | boolean addShop = true;
|
| | | List<PDDGoodsDetail> goodsList = result.getGoodsList();
|
| | | for (PDDGoodsDetail goods : goodsList) {
|
| | | // 包含店铺id 、包含品牌名称
|
| | | String mallName = goods.getMallName();
|
| | | if(addShop && !StringUtil.isNullOrEmpty(mallName) && mallName.toLowerCase().contains(shopKey.toLowerCase()) |
| | | && goods.getMallId() != null){
|
| | | shopInfoVO = new ShopInfoVO();
|
| | | shopInfoVO.setId(goods.getMallId().toString());
|
| | | shopInfoVO.setShopName(mallName);
|
| | | addShop = false;
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | if (shopInfoVO != null) {
|
| | | shopInfoVO.setShopIcon(brandInfo.getIcon());
|
| | | shopInfoVO.setUserType(30);
|
| | | shopInfoVO.setShopLink("https://mobile.yangkeduo.com/mall_page.html?mall_id=" + shopInfoVO.getId());
|
| | | BrandShopCahe brandShop = new BrandShopCahe();
|
| | | brandShop.setBrandId(brandInfo.getId());
|
| | | brandShop.setShop(shopInfoVO);
|
| | | brandShop.setCreateTime(new Date());
|
| | | brandShopCaheDao.insert(brandShop);
|
| | | return 1;
|
| | | }
|
| | | return 0;
|
| | | }
|
| | | |
| | | |
| | | |
| | | @Override
|
| | | public List<BrandShopCahe> getByBrandId(Long brandId){
|
| | | return brandShopCaheDao.getByBrandId(brandId);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public void removeAgoByDate(Date createTime) {
|
| | | brandShopCaheDao.removeAgoByDate(createTime);
|
| | | }
|
| | | |
| | | @Override
|
| | | public void removeByBrandId(Long brandId) {
|
| | | brandShopCaheDao.removeByBrandId(brandId);
|
| | | }
|
| | | |
| | | @Override
|
| | | public void removeByDateAndType(Long brandId, int type, Date date) {
|
| | | brandShopCaheDao.removeByDate(brandId, type, date);
|
| | | }
|
| | | |
| | | |
| | | }
|