package com.yeshi.fanli.service.impl.brand;
|
|
import java.util.Date;
|
import java.util.List;
|
|
import javax.annotation.Resource;
|
|
import org.springframework.stereotype.Service;
|
|
import com.yeshi.fanli.dao.brand.BrandShopCaheDao;
|
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.BrandInfo;
|
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.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.vo.goods.ShopInfoVO;
|
|
@Service
|
public class BrandShopCaheServiceImpl implements BrandShopCaheService {
|
|
@Resource
|
private BrandShopCaheDao brandShopCaheDao;
|
|
@Resource
|
private TaoBaoShopService taoBaoShopService;
|
|
|
/**
|
* 淘宝店铺
|
* @param brandInfo
|
* @return
|
*/
|
@Override
|
public boolean addBrandShopTB(Long brandId, Long auctionId, Long sellerId) {
|
TaoBaoShop taoBaoShop = taoBaoShopService.getTaoBaoShop(auctionId, sellerId);
|
if (taoBaoShop == null)
|
return true;
|
|
Date date = new Date();
|
BrandShopCahe brandShop = new BrandShopCahe();
|
brandShop.setBrandId(brandId);
|
brandShop.setShop(ShopInfoVOFactory.convertTaoBaoShop(taoBaoShop));
|
brandShop.setCreateTime(date);
|
brandShopCaheDao.insert(brandShop);
|
|
// 删除店铺
|
brandShopCaheDao.removeByDate(brandId, 11, date);
|
|
return false;
|
}
|
|
|
/**
|
* 京东
|
*
|
* @param brandInfo
|
* @return
|
*/
|
@Override
|
public void addBrandShopJD(BrandInfo brandInfo, JDShopInfo shopInfo) {
|
Date date = new Date();
|
ShopInfoVO shopInfoVO = ShopInfoVOFactory.convertJDShop(shopInfo);
|
shopInfoVO.setShopIcon(brandInfo.getIcon());
|
BrandShopCahe brandShop = new BrandShopCahe();
|
brandShop.setBrandId(brandInfo.getId());
|
brandShop.setShop(shopInfoVO);
|
brandShop.setCreateTime(date);
|
brandShopCaheDao.save(brandShop);
|
|
brandShopCaheDao.removeByDate(brandInfo.getId(), 20, date);
|
}
|
|
|
/**
|
* 拼多多
|
* @param brandInfo
|
* @return
|
*/
|
@Override
|
public void addBrandShopPDD(BrandInfo brandInfo) {
|
ShopInfoVO shopInfoVO = null;
|
String key = brandInfo.getName();
|
PDDSearchFilter pddfilter = new PDDSearchFilter();
|
pddfilter.setKw(key);
|
pddfilter.setPage(1);
|
pddfilter.setPageSize(100);
|
pddfilter.setSortType(6);
|
pddfilter.setMerchantType(3);
|
PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
|
if (result != null) {
|
List<PDDGoodsDetail> goodsList = result.getGoodsList();
|
if (goodsList != null && goodsList.size() > 0) {
|
for (PDDGoodsDetail goods : goodsList) {
|
String mallName = goods.getMallName();
|
if(goods.getMallId() != null && !StringUtil.isNullOrEmpty(mallName) && mallName.contains(key)){
|
shopInfoVO = new ShopInfoVO();
|
shopInfoVO.setId(goods.getMallId().toString());
|
shopInfoVO.setShopName(mallName);
|
break;
|
}
|
}
|
}
|
}
|
|
|
if (shopInfoVO != null) {
|
shopInfoVO.setShopIcon(brandInfo.getIcon());
|
shopInfoVO.setUserType(30);
|
shopInfoVO.setShopLink("https://mobile.yangkeduo.com/mall_page.html?mall_id=" + shopInfoVO.getId());
|
|
Date date = new Date();
|
BrandShopCahe brandShop = new BrandShopCahe();
|
brandShop.setBrandId(brandInfo.getId());
|
brandShop.setShop(shopInfoVO);
|
brandShop.setCreateTime(date);
|
brandShopCaheDao.insert(brandShop);
|
|
brandShopCaheDao.removeByDate(brandInfo.getId(), 30, date);
|
}
|
}
|
|
|
|
@Override
|
public List<BrandShopCahe> getByBrandId(Long brandId){
|
return brandShopCaheDao.getByBrandId(brandId);
|
}
|
}
|