| | |
| | | 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) {
|
| | | String searchKey = brandInfo.getSearchKey();
|
| | | 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) {
|
| | | 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(brandInfo.getName())){
|
| | | 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);
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.brand; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.exception.pdd.PDDApiException; |
| | | import com.yeshi.fanli.util.Constant; |
| | | 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.common.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(BrandInfo brandInfo, String 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 |
| | | */ |
| | | @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 |
| | | */ |
| | | @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 = null; |
| | | try { |
| | | result = PinDuoDuoApiUtil.searchGoods(pddfilter, Constant.PDD_SEARCH_CUSTOMER_PARAMS); |
| | | } catch (PDDApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | 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); |
| | | } |
| | | |
| | | |
| | | } |