| | |
| | | package com.yeshi.fanli.service.impl.brand;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.brand.BrandClassShopMapper;
|
| | | import com.yeshi.fanli.entity.brand.BrandClass;
|
| | | import com.yeshi.fanli.entity.brand.BrandClassShop;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.taobao.SearchFilter;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoShop;
|
| | | import com.yeshi.fanli.exception.brand.BrandClassShopException;
|
| | | import com.yeshi.fanli.service.inter.brand.BrandClassShopService;
|
| | | import com.yeshi.fanli.service.inter.brand.TaoBaoShopHistoryService;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.brand.TaoBaoShopVO;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Service
|
| | | public class BrandClassShopServiceImpl implements BrandClassShopService {
|
| | |
|
| | | @Resource
|
| | | private BrandClassShopMapper brandClassShopMapper;
|
| | |
|
| | | @Resource
|
| | | private CommonGoodsService commonGoodsService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoShopService taoBaoShopService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoShopHistoryService taoBaoShopHistoryService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private QualityGoodsService qualityGoodsService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
|
| | |
|
| | | @Override
|
| | | public List<BrandClassShop> getExistByShopIds(List<Long> list) {
|
| | | return brandClassShopMapper.getExistByShopIds(list);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public String saveShopInfo(Long cid, List<Long> list) throws BrandClassShopException {
|
| | | if (list == null || list.size() == 0) {
|
| | | throw new BrandClassShopException(1, "请选择店铺");
|
| | | }
|
| | |
|
| | | if (cid == null) {
|
| | | throw new BrandClassShopException(1, "请选择店铺类型");
|
| | | }
|
| | |
|
| | | String shopIds = "";
|
| | | BrandClass brandClass = new BrandClass(cid);
|
| | |
|
| | | for (Long shopId : list) {
|
| | | List<CommonGoods> listGoods = commonGoodsService.listBySellerId(shopId, Constant.SOURCE_TYPE_TAOBAO);
|
| | |
|
| | | TaoBaoShop taoBaoShop = null;
|
| | | for (CommonGoods commonGoods : listGoods) {
|
| | | try {
|
| | | taoBaoShop = TaoBaoUtil.getTaoBaoShopDetailByAuctionId(commonGoods.getGoodsId());
|
| | | if (taoBaoShop != null && taoBaoShop.getId() != null) {
|
| | | break;
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | if (taoBaoShop == null) {
|
| | | shopIds = shopIds + "," + shopId;
|
| | | continue;
|
| | | }
|
| | |
|
| | | TaoBaoShop current = taoBaoShopService.selectByPrimaryKey(shopId);
|
| | | if (current == null) {
|
| | | taoBaoShopService.insertSelective(taoBaoShop);
|
| | | } else {
|
| | | taoBaoShopService.updateByPrimaryKeySelective(taoBaoShop);
|
| | | }
|
| | |
|
| | | BrandClassShop brandClassShop = brandClassShopMapper.getByShopIdAndCid(cid, shopId);
|
| | | if (brandClassShop == null) {
|
| | | brandClassShop = new BrandClassShop();
|
| | | brandClassShop.setOrderby(brandClassShopMapper.getMaxOrder(cid) + 1);
|
| | | brandClassShop.setState(0);
|
| | | brandClassShop.setTop(0);
|
| | | brandClassShop.setBrandClass(brandClass);
|
| | | brandClassShop.setShop(taoBaoShop);
|
| | | brandClassShop.setCreateTime(new Date());
|
| | | brandClassShop.setUpdateTime(new Date());
|
| | | brandClassShopMapper.insertSelective(brandClassShop);
|
| | | }
|
| | | }
|
| | | return shopIds;
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void changeShopInfo(MultipartFile file, Long id, Long cid, String shopName, Integer state, Integer top,
|
| | | String key) throws BrandClassShopException {
|
| | |
|
| | | if (id == null) {
|
| | | throw new BrandClassShopException(1, "数据为空:请选择店铺");
|
| | | }
|
| | |
|
| | | if (cid == null) {
|
| | | throw new BrandClassShopException(1, "请选择店铺类型");
|
| | | }
|
| | |
|
| | | BrandClassShop current = brandClassShopMapper.selectByPrimaryKey(id);
|
| | | if (current == null) {
|
| | | throw new BrandClassShopException(1, "该数据已不存在");
|
| | | }
|
| | |
|
| | | TaoBaoShop shop = current.getShop();
|
| | | if (shop == null) {
|
| | | throw new BrandClassShopException(1, "店铺信息已不存在");
|
| | | }
|
| | |
|
| | | // 自定义图片
|
| | | taoBaoShopService.changeInfo(file, shop.getId(), shopName, key);
|
| | |
|
| | | BrandClassShop updateshop = new BrandClassShop();
|
| | | updateshop.setState(state);
|
| | | updateshop.setTop(top);
|
| | | updateshop.setId(current.getId());
|
| | | updateshop.setBrandClass(new BrandClass(cid));
|
| | | brandClassShopMapper.updateByPrimaryKeySelective(updateshop);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<BrandClassShop> listQuery(long start, int count, String key, Long cid, Integer state) {
|
| | | List<BrandClassShop> listQuery = brandClassShopMapper.listQuery(start, count, key, cid, state);
|
| | | if (listQuery == null || listQuery.size() == 0) {
|
| | | return listQuery;
|
| | | }
|
| | |
|
| | | for (BrandClassShop brandClassShop : listQuery) {
|
| | | TaoBaoShop shop = brandClassShop.getShop();
|
| | | if (shop != null) {
|
| | | long couponNum = commonGoodsService.countBySellerIdAndHasCoupon(shop.getId(),
|
| | | Constant.SOURCE_TYPE_TAOBAO);
|
| | | brandClassShop.setCouponNum(couponNum);
|
| | |
|
| | | String shopLink = shop.getShopLink();
|
| | | if (StringUtil.isNullOrEmpty(shopLink)) {
|
| | | shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId()));
|
| | | }
|
| | |
|
| | | String shopNameCustom = shop.getShopNameCustom();
|
| | | if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
|
| | | shop.setShopName(shopNameCustom);
|
| | | }
|
| | |
|
| | | String shopIconCustom = shop.getShopIconCustom();
|
| | | if (!StringUtil.isNullOrEmpty(shopIconCustom)) {
|
| | | shop.setShopIcon(shopIconCustom);
|
| | | }
|
| | | }
|
| | | }
|
| | | return listQuery;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countQuery(String key, Long cid, Integer state) {
|
| | | return brandClassShopMapper.countQuery(key, cid, state);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void deleteBatchByPrimaryKey(List<Long> list) {
|
| | | if (list == null || list.size() == 0) {
|
| | | return;
|
| | | }
|
| | | for (Long id : list) {
|
| | | brandClassShopMapper.deleteByPrimaryKey(id);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteBatchByClassId(List<Long> list) {
|
| | | if (list == null || list.size() == 0) {
|
| | | return;
|
| | | }
|
| | | brandClassShopMapper.deleteBatchByClassId(list);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void updateOrder(Long id, Integer moveType) throws BrandClassShopException, Exception {
|
| | |
|
| | | if (moveType == null || (!moveType.equals(1) && !moveType.equals(-1))) {
|
| | | throw new BrandClassShopException(1, "传递的类型不正确");
|
| | | }
|
| | |
|
| | | if (id == null) {
|
| | | throw new BrandClassShopException(1, "ID不能为空");
|
| | | }
|
| | |
|
| | | BrandClassShop resultObj = brandClassShopMapper.selectByPrimaryKey(id);
|
| | | if (resultObj == null) {
|
| | | throw new BrandClassShopException(1, "操作数据已不存在");
|
| | | }
|
| | |
|
| | | BrandClass brandClass = resultObj.getBrandClass();
|
| | | if (brandClass == null) {
|
| | | throw new BrandClassShopException(1, "分类数据已不存在");
|
| | | }
|
| | |
|
| | | Integer oldOrder = resultObj.getOrderby();
|
| | | BrandClassShop changeObj = brandClassShopMapper.getByAdjoinOrder(brandClass.getId(), oldOrder, moveType);
|
| | |
|
| | | if (changeObj == null) {
|
| | | throw new BrandClassShopException(1, "已经在最边缘,无可交换的位置");
|
| | | }
|
| | | // 交换排序序号
|
| | | resultObj.setOrderby(changeObj.getOrderby());
|
| | | changeObj.setOrderby(oldOrder);
|
| | |
|
| | | brandClassShopMapper.updateByPrimaryKeySelective(changeObj);
|
| | | brandClassShopMapper.updateByPrimaryKeySelective(resultObj);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "brandCache", key = "'listEffectiveCache-'+#page+'-'+#cid")
|
| | | public JSONObject listEffectiveCache(int page, Long cid) {
|
| | | long countShop = 0;
|
| | |
|
| | | if (cid != null && cid <= 0) {
|
| | | cid = null;
|
| | | }
|
| | |
|
| | | List<TaoBaoShop> listShop = new ArrayList<TaoBaoShop>();
|
| | | // 第一页 查询全部分类下店铺
|
| | | if (page == 1 && cid != null) {
|
| | | List<BrandClassShop> list = brandClassShopMapper.listEffective(cid);
|
| | | if (list == null) {
|
| | | list = new ArrayList<BrandClassShop>();
|
| | | } else if (list.size() > 0) {
|
| | | countShop = brandClassShopMapper.countEffective(cid);
|
| | | }
|
| | |
|
| | | for (BrandClassShop brandClassShop : list) {
|
| | | TaoBaoShop shop = brandClassShop.getShop();
|
| | | if (shop != null) {
|
| | | String shopLink = shop.getShopLink();
|
| | | if (StringUtil.isNullOrEmpty(shopLink)) {
|
| | | shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId()));
|
| | | }
|
| | |
|
| | | String shopNameCustom = shop.getShopNameCustom();
|
| | | if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
|
| | | shop.setShopName(shopNameCustom);
|
| | | }
|
| | |
|
| | | String shopIconCustom = shop.getShopIconCustom();
|
| | | if (!StringUtil.isNullOrEmpty(shopIconCustom)) {
|
| | | shop.setShopIcon(shopIconCustom);
|
| | | }
|
| | |
|
| | | listShop.add(shop);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("countShop", countShop);
|
| | | data.put("listShop", JsonUtil.getApiCommonGson().toJson(listShop));
|
| | |
|
| | | long count = 0;
|
| | | List<TaoBaoShopVO> listInfo = taoBaoShopService.listBrandShopinfo((page - 1) * Constant.PAGE_SIZE,
|
| | | Constant.PAGE_SIZE, cid);
|
| | | if (listInfo == null) {
|
| | | listInfo = new ArrayList<TaoBaoShopVO>();
|
| | | } else if (listInfo.size() > 0) {
|
| | | count = taoBaoShopService.countBrandShopinfo(cid);
|
| | | }
|
| | |
|
| | | // 淘宝商品信息过滤
|
| | | Map<Long, TaoBaoGoodsBrief> goodsMap = getFilterTaoBaoGoods(listInfo);
|
| | |
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | for (TaoBaoShopVO taoBaoShopVO : listInfo) {
|
| | |
|
| | | String shopLink = taoBaoShopVO.getShopLink();
|
| | | if (StringUtil.isNullOrEmpty(shopLink)) {
|
| | | taoBaoShopVO.setShopLink(TaoBaoUtil.getShopLink(taoBaoShopVO.getId()));
|
| | | }
|
| | |
|
| | | String shopNameCustom = taoBaoShopVO.getShopNameCustom();
|
| | | if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
|
| | | taoBaoShopVO.setShopName(shopNameCustom);
|
| | | }
|
| | |
|
| | | String shopIconCustom = taoBaoShopVO.getShopIconCustom();
|
| | | if (!StringUtil.isNullOrEmpty(shopIconCustom)) {
|
| | | taoBaoShopVO.setShopIcon(shopIconCustom);
|
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBriefExtra> listGoods = new ArrayList<TaoBaoGoodsBriefExtra>();
|
| | | List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief();
|
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
|
| | | listGoods.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsMap.get(taoBaoGoodsBrief.getAuctionId()),
|
| | | proportion.toString(), null));
|
| | | }
|
| | | taoBaoShopVO.setListGoods(listGoods);
|
| | | }
|
| | | data.put("count", count);
|
| | | data.put("list", JsonUtil.getApiCommonGson().toJson(listInfo));
|
| | |
|
| | | return data;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取过滤商品
|
| | | * |
| | | * @param listInfo
|
| | | * @return
|
| | | */
|
| | | private Map<Long, TaoBaoGoodsBrief> getFilterTaoBaoGoods(List<TaoBaoShopVO> listInfo) {
|
| | | // 过滤商品
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | for (TaoBaoShopVO taoBaoShopVO : listInfo) {
|
| | | goodsList.addAll(taoBaoShopVO.getListGoodsBrief());
|
| | | }
|
| | | goodsList = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(goodsList);
|
| | | Map<Long, TaoBaoGoodsBrief> goodsMap = new HashMap<>();
|
| | | for (TaoBaoGoodsBrief goods : goodsList)
|
| | | goodsMap.put(goods.getAuctionId(), goods);
|
| | | return goodsMap;
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "brandCache", key = "'listEffectiveCacheV2-'+#page+'-'+#cid")
|
| | | public JSONObject listEffectiveCacheV2(int page, Long cid) {
|
| | | long countShop = 0;
|
| | |
|
| | | if (cid != null && cid <= 0) {
|
| | | cid = null;
|
| | | }
|
| | |
|
| | | List<TaoBaoShop> listShop = new ArrayList<TaoBaoShop>();
|
| | | // 第一页 查询全部分类下店铺
|
| | | if (page == 1 && cid != null) {
|
| | | List<BrandClassShop> list = brandClassShopMapper.listEffective(cid);
|
| | | if (list == null) {
|
| | | list = new ArrayList<BrandClassShop>();
|
| | | } else if (list.size() > 0) {
|
| | | countShop = brandClassShopMapper.countEffective(cid);
|
| | | }
|
| | |
|
| | | for (BrandClassShop brandClassShop : list) {
|
| | | TaoBaoShop shop = brandClassShop.getShop();
|
| | | if (shop != null) {
|
| | |
|
| | | Integer userType = shop.getUserType();
|
| | | if (userType == null || userType == 0) {
|
| | | shop.setUserType(10);
|
| | | } else {
|
| | | shop.setUserType(11);
|
| | | }
|
| | |
|
| | | String shopLink = shop.getShopLink();
|
| | | if (StringUtil.isNullOrEmpty(shopLink)) {
|
| | | shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId()));
|
| | | }
|
| | |
|
| | | String shopNameCustom = shop.getShopNameCustom();
|
| | | if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
|
| | | shop.setShopName(shopNameCustom);
|
| | | }
|
| | |
|
| | | String shopIconCustom = shop.getShopIconCustom();
|
| | | if (!StringUtil.isNullOrEmpty(shopIconCustom)) {
|
| | | shop.setShopIcon(shopIconCustom);
|
| | | }
|
| | |
|
| | | listShop.add(shop);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("countShop", countShop);
|
| | | data.put("listShop", JsonUtil.getApiCommonGson().toJson(listShop));
|
| | |
|
| | | long count = 0;
|
| | | List<TaoBaoShopVO> listInfo = taoBaoShopService.listBrandShopinfo((page - 1) * Constant.PAGE_SIZE,
|
| | | Constant.PAGE_SIZE, cid);
|
| | | if (listInfo == null) {
|
| | | listInfo = new ArrayList<TaoBaoShopVO>();
|
| | | } else if (listInfo.size() > 0) {
|
| | | count = taoBaoShopService.countBrandShopinfo(cid);
|
| | | }
|
| | |
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | |
|
| | | // 淘宝商品信息过滤
|
| | | Map<Long, TaoBaoGoodsBrief> goodsMap = getFilterTaoBaoGoods(listInfo);
|
| | |
|
| | | for (TaoBaoShopVO taoBaoShopVO : listInfo) {
|
| | |
|
| | | Integer userType = taoBaoShopVO.getUserType();
|
| | | if (userType == null || userType == 0) {
|
| | | taoBaoShopVO.setUserType(10);
|
| | | } else {
|
| | | taoBaoShopVO.setUserType(11);
|
| | | }
|
| | |
|
| | | String shopLink = taoBaoShopVO.getShopLink();
|
| | | if (StringUtil.isNullOrEmpty(shopLink)) {
|
| | | taoBaoShopVO.setShopLink(TaoBaoUtil.getShopLink(taoBaoShopVO.getId()));
|
| | | }
|
| | |
|
| | | String shopNameCustom = taoBaoShopVO.getShopNameCustom();
|
| | | if (!StringUtil.isNullOrEmpty(shopNameCustom)) {
|
| | | taoBaoShopVO.setShopName(shopNameCustom);
|
| | | }
|
| | |
|
| | | String shopIconCustom = taoBaoShopVO.getShopIconCustom();
|
| | | if (!StringUtil.isNullOrEmpty(shopIconCustom)) {
|
| | | taoBaoShopVO.setShopIcon(shopIconCustom);
|
| | | }
|
| | |
|
| | | List<GoodsDetailVO> listGoods = new ArrayList<GoodsDetailVO>();
|
| | | List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief();
|
| | |
|
| | | // 商品添加到更新队列
|
| | | taoBaoGoodsUpdateService.addUpdateQueueAsync(listGoodsBrief);
|
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) {
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory
|
| | | .convertTaoBao(goodsMap.get(taoBaoGoodsBrief.getAuctionId()), null, fanLiRate, shareRate);
|
| | | listGoods.add(goodsDetailVO);
|
| | | }
|
| | | taoBaoShopVO.setListGoodsVO(listGoods);
|
| | | }
|
| | | data.put("count", count);
|
| | | data.put("list", JsonUtil.getApiCommonGson().toJson(listInfo));
|
| | |
|
| | | return data;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void addClick(Long shopId) {
|
| | | BrandClassShop brandClassShop = brandClassShopMapper.getByShopId(shopId);
|
| | | if (brandClassShop != null) {
|
| | | Long browseNum = brandClassShop.getBrowseNum();
|
| | | if (browseNum == null) {
|
| | | browseNum = 0L;
|
| | | }
|
| | |
|
| | | BrandClassShop classShop = new BrandClassShop();
|
| | | classShop.setId(brandClassShop.getId());
|
| | | classShop.setBrowseNum(browseNum++);
|
| | | brandClassShopMapper.updateByPrimaryKeySelective(classShop);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void updateShopGoods() {
|
| | | // 查询店铺
|
| | | List<BrandClassShop> shopList = listQuery(0, 1000, "", null, BrandClassShop.STATE_VALID);
|
| | | if (shopList != null)
|
| | | for (BrandClassShop shop : shopList) {
|
| | | SearchFilter sf = new SearchFilter();
|
| | | sf.setKey(shop.getShop().getShopName().replace("官方旗舰店", "").replace("旗舰店", ""));
|
| | | sf.setPage(1);
|
| | | sf.setPageSize(100);
|
| | | TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(sf);
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null)
|
| | | for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) {
|
| | | if (goods.getSellerId().longValue() == shop.getShop().getId()) {
|
| | | if (taoBaoGoodsBriefService.queryByAuctionId(goods.getAuctionId()).size() == 0) {
|
| | | goods.setCreatetime(new Date());
|
| | | goods.setState(0);
|
| | | goods.setUpdatetime(new Date());
|
| | | goodsList.add(goods);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (goodsList.size() > 0)
|
| | | taoBaoGoodsBriefService.insertBatch(goodsList);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.brand; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import org.springframework.cache.annotation.Cacheable; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import com.yeshi.fanli.dao.mybatis.brand.BrandClassShopMapper; |
| | | import com.yeshi.fanli.dto.GoodsMoneyConfigParamsDTO; |
| | | import com.yeshi.fanli.entity.brand.BrandClass; |
| | | import com.yeshi.fanli.entity.brand.BrandClassShop; |
| | | import com.yeshi.fanli.entity.goods.CommonGoods; |
| | | import com.yeshi.fanli.entity.taobao.SearchFilter; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBriefExtra; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult; |
| | | import com.yeshi.common.entity.taobao.TaoBaoShop; |
| | | import com.yeshi.fanli.exception.brand.BrandClassShopException; |
| | | import com.yeshi.fanli.service.inter.brand.BrandClassShopService; |
| | | import com.yeshi.fanli.service.inter.brand.TaoBaoShopHistoryService; |
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService; |
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService; |
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService; |
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; |
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil; |
| | | import com.yeshi.fanli.vo.brand.TaoBaoShopVO; |
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO; |
| | | |
| | | import net.sf.json.JSONObject; |
| | | |
| | | @Service |
| | | public class BrandClassShopServiceImpl implements BrandClassShopService { |
| | | |
| | | @Resource |
| | | private BrandClassShopMapper brandClassShopMapper; |
| | | |
| | | @Resource |
| | | private CommonGoodsService commonGoodsService; |
| | | |
| | | @Resource |
| | | private TaoBaoShopService taoBaoShopService; |
| | | |
| | | @Resource |
| | | private TaoBaoShopHistoryService taoBaoShopHistoryService; |
| | | |
| | | @Resource |
| | | private HongBaoManageService hongBaoManageService; |
| | | |
| | | @Resource |
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; |
| | | |
| | | @Resource |
| | | private QualityGoodsService qualityGoodsService; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; |
| | | |
| | | @Override |
| | | public List<BrandClassShop> getExistByShopIds(List<Long> list) { |
| | | return brandClassShopMapper.getExistByShopIds(list); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor=Exception.class) |
| | | public String saveShopInfo(Long cid, List<Long> list) throws BrandClassShopException { |
| | | if (list == null || list.size() == 0) { |
| | | throw new BrandClassShopException(1, "请选择店铺"); |
| | | } |
| | | |
| | | if (cid == null) { |
| | | throw new BrandClassShopException(1, "请选择店铺类型"); |
| | | } |
| | | |
| | | String shopIds = ""; |
| | | BrandClass brandClass = new BrandClass(cid); |
| | | |
| | | for (Long shopId : list) { |
| | | List<CommonGoods> listGoods = commonGoodsService.listBySellerId(shopId, Constant.SOURCE_TYPE_TAOBAO); |
| | | |
| | | TaoBaoShop taoBaoShop = null; |
| | | for (CommonGoods commonGoods : listGoods) { |
| | | try { |
| | | taoBaoShop = TaoBaoUtil.getTaoBaoShopDetailByAuctionId(commonGoods.getGoodsId()); |
| | | if (taoBaoShop != null && taoBaoShop.getId() != null) { |
| | | break; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | if (taoBaoShop == null) { |
| | | shopIds = shopIds + "," + shopId; |
| | | continue; |
| | | } |
| | | |
| | | TaoBaoShop current = taoBaoShopService.selectByPrimaryKey(shopId); |
| | | if (current == null) { |
| | | taoBaoShopService.insertSelective(taoBaoShop); |
| | | } else { |
| | | taoBaoShopService.updateByPrimaryKeySelective(taoBaoShop); |
| | | } |
| | | |
| | | BrandClassShop brandClassShop = brandClassShopMapper.getByShopIdAndCid(cid, shopId); |
| | | if (brandClassShop == null) { |
| | | brandClassShop = new BrandClassShop(); |
| | | brandClassShop.setOrderby(brandClassShopMapper.getMaxOrder(cid) + 1); |
| | | brandClassShop.setState(0); |
| | | brandClassShop.setTop(0); |
| | | brandClassShop.setBrandClass(brandClass); |
| | | brandClassShop.setShop(taoBaoShop); |
| | | brandClassShop.setCreateTime(new Date()); |
| | | brandClassShop.setUpdateTime(new Date()); |
| | | brandClassShopMapper.insertSelective(brandClassShop); |
| | | } |
| | | } |
| | | return shopIds; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor=Exception.class) |
| | | public void changeShopInfo(MultipartFile file, Long id, Long cid, String shopName, Integer state, Integer top, |
| | | String key) throws BrandClassShopException { |
| | | |
| | | if (id == null) { |
| | | throw new BrandClassShopException(1, "数据为空:请选择店铺"); |
| | | } |
| | | |
| | | if (cid == null) { |
| | | throw new BrandClassShopException(1, "请选择店铺类型"); |
| | | } |
| | | |
| | | BrandClassShop current = brandClassShopMapper.selectByPrimaryKey(id); |
| | | if (current == null) { |
| | | throw new BrandClassShopException(1, "该数据已不存在"); |
| | | } |
| | | |
| | | TaoBaoShop shop = current.getShop(); |
| | | if (shop == null) { |
| | | throw new BrandClassShopException(1, "店铺信息已不存在"); |
| | | } |
| | | |
| | | // 自定义图片 |
| | | taoBaoShopService.changeInfo(file, shop.getId(), shopName, key); |
| | | |
| | | BrandClassShop updateshop = new BrandClassShop(); |
| | | updateshop.setState(state); |
| | | updateshop.setTop(top); |
| | | updateshop.setId(current.getId()); |
| | | updateshop.setBrandClass(new BrandClass(cid)); |
| | | brandClassShopMapper.updateByPrimaryKeySelective(updateshop); |
| | | } |
| | | |
| | | @Override |
| | | public List<BrandClassShop> listQuery(long start, int count, String key, Long cid, Integer state) { |
| | | List<BrandClassShop> listQuery = brandClassShopMapper.listQuery(start, count, key, cid, state); |
| | | if (listQuery == null || listQuery.size() == 0) { |
| | | return listQuery; |
| | | } |
| | | |
| | | for (BrandClassShop brandClassShop : listQuery) { |
| | | TaoBaoShop shop = brandClassShop.getShop(); |
| | | if (shop != null) { |
| | | long couponNum = commonGoodsService.countBySellerIdAndHasCoupon(shop.getId(), |
| | | Constant.SOURCE_TYPE_TAOBAO); |
| | | brandClassShop.setCouponNum(couponNum); |
| | | |
| | | String shopLink = shop.getShopLink(); |
| | | if (StringUtil.isNullOrEmpty(shopLink)) { |
| | | shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId())); |
| | | } |
| | | |
| | | String shopNameCustom = shop.getShopNameCustom(); |
| | | if (!StringUtil.isNullOrEmpty(shopNameCustom)) { |
| | | shop.setShopName(shopNameCustom); |
| | | } |
| | | |
| | | String shopIconCustom = shop.getShopIconCustom(); |
| | | if (!StringUtil.isNullOrEmpty(shopIconCustom)) { |
| | | shop.setShopIcon(shopIconCustom); |
| | | } |
| | | } |
| | | } |
| | | return listQuery; |
| | | } |
| | | |
| | | @Override |
| | | public long countQuery(String key, Long cid, Integer state) { |
| | | return brandClassShopMapper.countQuery(key, cid, state); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void deleteBatchByPrimaryKey(List<Long> list) { |
| | | if (list == null || list.size() == 0) { |
| | | return; |
| | | } |
| | | for (Long id : list) { |
| | | brandClassShopMapper.deleteByPrimaryKey(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void deleteBatchByClassId(List<Long> list) { |
| | | if (list == null || list.size() == 0) { |
| | | return; |
| | | } |
| | | brandClassShopMapper.deleteBatchByClassId(list); |
| | | } |
| | | |
| | | @Override |
| | | public void updateOrder(Long id, Integer moveType) throws BrandClassShopException, Exception { |
| | | |
| | | if (moveType == null || (!moveType.equals(1) && !moveType.equals(-1))) { |
| | | throw new BrandClassShopException(1, "传递的类型不正确"); |
| | | } |
| | | |
| | | if (id == null) { |
| | | throw new BrandClassShopException(1, "ID不能为空"); |
| | | } |
| | | |
| | | BrandClassShop resultObj = brandClassShopMapper.selectByPrimaryKey(id); |
| | | if (resultObj == null) { |
| | | throw new BrandClassShopException(1, "操作数据已不存在"); |
| | | } |
| | | |
| | | BrandClass brandClass = resultObj.getBrandClass(); |
| | | if (brandClass == null) { |
| | | throw new BrandClassShopException(1, "分类数据已不存在"); |
| | | } |
| | | |
| | | Integer oldOrder = resultObj.getOrderby(); |
| | | BrandClassShop changeObj = brandClassShopMapper.getByAdjoinOrder(brandClass.getId(), oldOrder, moveType); |
| | | |
| | | if (changeObj == null) { |
| | | throw new BrandClassShopException(1, "已经在最边缘,无可交换的位置"); |
| | | } |
| | | // 交换排序序号 |
| | | resultObj.setOrderby(changeObj.getOrderby()); |
| | | changeObj.setOrderby(oldOrder); |
| | | |
| | | brandClassShopMapper.updateByPrimaryKeySelective(changeObj); |
| | | brandClassShopMapper.updateByPrimaryKeySelective(resultObj); |
| | | } |
| | | |
| | | @Override |
| | | @Cacheable(value = "brandCache", key = "'listEffectiveCache-'+#page+'-'+#cid+'-'+#system") |
| | | public JSONObject listEffectiveCache(int page, Long cid,SystemEnum system) { |
| | | long countShop = 0; |
| | | |
| | | if (cid != null && cid <= 0) { |
| | | cid = null; |
| | | } |
| | | |
| | | List<TaoBaoShop> listShop = new ArrayList<TaoBaoShop>(); |
| | | // 第一页 查询全部分类下店铺 |
| | | if (page == 1 && cid != null) { |
| | | List<BrandClassShop> list = brandClassShopMapper.listEffective(cid,system); |
| | | if (list == null) { |
| | | list = new ArrayList<BrandClassShop>(); |
| | | } else if (list.size() > 0) { |
| | | countShop = brandClassShopMapper.countEffective(cid); |
| | | } |
| | | |
| | | for (BrandClassShop brandClassShop : list) { |
| | | TaoBaoShop shop = brandClassShop.getShop(); |
| | | if (shop != null) { |
| | | String shopLink = shop.getShopLink(); |
| | | if (StringUtil.isNullOrEmpty(shopLink)) { |
| | | shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId())); |
| | | } |
| | | |
| | | String shopNameCustom = shop.getShopNameCustom(); |
| | | if (!StringUtil.isNullOrEmpty(shopNameCustom)) { |
| | | shop.setShopName(shopNameCustom); |
| | | } |
| | | |
| | | String shopIconCustom = shop.getShopIconCustom(); |
| | | if (!StringUtil.isNullOrEmpty(shopIconCustom)) { |
| | | shop.setShopIcon(shopIconCustom); |
| | | } |
| | | |
| | | listShop.add(shop); |
| | | } |
| | | } |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("countShop", countShop); |
| | | data.put("listShop", JsonUtil.getApiCommonGson().toJson(listShop)); |
| | | |
| | | long count = 0; |
| | | List<TaoBaoShopVO> listInfo = taoBaoShopService.listBrandShopinfo((page - 1) * Constant.PAGE_SIZE, |
| | | Constant.PAGE_SIZE, cid); |
| | | if (listInfo == null) { |
| | | listInfo = new ArrayList<TaoBaoShopVO>(); |
| | | } else if (listInfo.size() > 0) { |
| | | count = taoBaoShopService.countBrandShopinfo(cid); |
| | | } |
| | | |
| | | // 淘宝商品信息过滤 |
| | | Map<String, TaoBaoGoodsBrief> goodsMap = getFilterTaoBaoGoods(listInfo); |
| | | |
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate(system); |
| | | for (TaoBaoShopVO taoBaoShopVO : listInfo) { |
| | | |
| | | String shopLink = taoBaoShopVO.getShopLink(); |
| | | if (StringUtil.isNullOrEmpty(shopLink)) { |
| | | taoBaoShopVO.setShopLink(TaoBaoUtil.getShopLink(taoBaoShopVO.getId())); |
| | | } |
| | | |
| | | String shopNameCustom = taoBaoShopVO.getShopNameCustom(); |
| | | if (!StringUtil.isNullOrEmpty(shopNameCustom)) { |
| | | taoBaoShopVO.setShopName(shopNameCustom); |
| | | } |
| | | |
| | | String shopIconCustom = taoBaoShopVO.getShopIconCustom(); |
| | | if (!StringUtil.isNullOrEmpty(shopIconCustom)) { |
| | | taoBaoShopVO.setShopIcon(shopIconCustom); |
| | | } |
| | | |
| | | List<TaoBaoGoodsBriefExtra> listGoods = new ArrayList<TaoBaoGoodsBriefExtra>(); |
| | | List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief(); |
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) { |
| | | listGoods.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsMap.get(taoBaoGoodsBrief.getAuctionId()), |
| | | proportion.toString(), null)); |
| | | } |
| | | taoBaoShopVO.setListGoods(listGoods); |
| | | } |
| | | data.put("count", count); |
| | | data.put("list", JsonUtil.getApiCommonGson().toJson(listInfo)); |
| | | |
| | | return data; |
| | | } |
| | | |
| | | /** |
| | | * 获取过滤商品 |
| | | * |
| | | * @param listInfo |
| | | * @return |
| | | */ |
| | | private Map<String, TaoBaoGoodsBrief> getFilterTaoBaoGoods(List<TaoBaoShopVO> listInfo) { |
| | | // 过滤商品 |
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); |
| | | for (TaoBaoShopVO taoBaoShopVO : listInfo) { |
| | | goodsList.addAll(taoBaoShopVO.getListGoodsBrief()); |
| | | } |
| | | goodsList = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(goodsList); |
| | | Map<String, TaoBaoGoodsBrief> goodsMap = new HashMap<>(); |
| | | for (TaoBaoGoodsBrief goods : goodsList) |
| | | goodsMap.put(goods.getAuctionId(), goods); |
| | | return goodsMap; |
| | | } |
| | | |
| | | @Override |
| | | @Cacheable(value = "brandCache", key = "'listEffectiveCacheV2-'+#page+'-'+#cid+'-'+#platform+'-'+#version+'-'+#system") |
| | | public JSONObject listEffectiveCacheV2(int page, Long cid,String platform,String version,SystemEnum system) { |
| | | long countShop = 0; |
| | | |
| | | if (cid != null && cid <= 0) { |
| | | cid = null; |
| | | } |
| | | |
| | | List<TaoBaoShop> listShop = new ArrayList<>(); |
| | | // 第一页 查询全部分类下店铺 |
| | | if (page == 1 && cid != null) { |
| | | List<BrandClassShop> list = brandClassShopMapper.listEffective(cid,system); |
| | | if (list == null) { |
| | | list = new ArrayList<BrandClassShop>(); |
| | | } else if (list.size() > 0) { |
| | | countShop = brandClassShopMapper.countEffective(cid); |
| | | } |
| | | |
| | | for (BrandClassShop brandClassShop : list) { |
| | | TaoBaoShop shop = brandClassShop.getShop(); |
| | | if (shop != null) { |
| | | |
| | | Integer userType = shop.getUserType(); |
| | | if (userType == null || userType == 0) { |
| | | shop.setUserType(10); |
| | | } else { |
| | | shop.setUserType(11); |
| | | } |
| | | |
| | | String shopLink = shop.getShopLink(); |
| | | if (StringUtil.isNullOrEmpty(shopLink)) { |
| | | shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId())); |
| | | } |
| | | |
| | | String shopNameCustom = shop.getShopNameCustom(); |
| | | if (!StringUtil.isNullOrEmpty(shopNameCustom)) { |
| | | shop.setShopName(shopNameCustom); |
| | | } |
| | | |
| | | String shopIconCustom = shop.getShopIconCustom(); |
| | | if (!StringUtil.isNullOrEmpty(shopIconCustom)) { |
| | | shop.setShopIcon(shopIconCustom); |
| | | } |
| | | |
| | | listShop.add(shop); |
| | | } |
| | | } |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("countShop", countShop); |
| | | data.put("listShop", JsonUtil.getApiCommonGson().toJson(listShop)); |
| | | |
| | | long count = 0; |
| | | List<TaoBaoShopVO> listInfo = taoBaoShopService.listBrandShopinfo((page - 1) * Constant.PAGE_SIZE, |
| | | Constant.PAGE_SIZE, cid); |
| | | if (listInfo == null) { |
| | | listInfo = new ArrayList<TaoBaoShopVO>(); |
| | | } else if (listInfo.size() > 0) { |
| | | count = taoBaoShopService.countBrandShopinfo(cid); |
| | | } |
| | | |
| | | GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(platform, version,system); |
| | | |
| | | // 淘宝商品信息过滤 |
| | | Map<String, TaoBaoGoodsBrief> goodsMap = getFilterTaoBaoGoods(listInfo); |
| | | |
| | | for (TaoBaoShopVO taoBaoShopVO : listInfo) { |
| | | |
| | | Integer userType = taoBaoShopVO.getUserType(); |
| | | if (userType == null || userType == 0) { |
| | | taoBaoShopVO.setUserType(10); |
| | | } else { |
| | | taoBaoShopVO.setUserType(11); |
| | | } |
| | | |
| | | String shopLink = taoBaoShopVO.getShopLink(); |
| | | if (StringUtil.isNullOrEmpty(shopLink)) { |
| | | taoBaoShopVO.setShopLink(TaoBaoUtil.getShopLink(taoBaoShopVO.getId())); |
| | | } |
| | | |
| | | String shopNameCustom = taoBaoShopVO.getShopNameCustom(); |
| | | if (!StringUtil.isNullOrEmpty(shopNameCustom)) { |
| | | taoBaoShopVO.setShopName(shopNameCustom); |
| | | } |
| | | |
| | | String shopIconCustom = taoBaoShopVO.getShopIconCustom(); |
| | | if (!StringUtil.isNullOrEmpty(shopIconCustom)) { |
| | | taoBaoShopVO.setShopIcon(shopIconCustom); |
| | | } |
| | | |
| | | List<GoodsDetailVO> listGoods = new ArrayList<GoodsDetailVO>(); |
| | | List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief(); |
| | | |
| | | // 商品添加到更新队列 |
| | | taoBaoGoodsUpdateService.addUpdateQueueAsync(listGoodsBrief); |
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) { |
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory |
| | | .convertTaoBao(goodsMap.get(taoBaoGoodsBrief.getAuctionId()),paramsDTO); |
| | | listGoods.add(goodsDetailVO); |
| | | } |
| | | taoBaoShopVO.setListGoodsVO(listGoods); |
| | | } |
| | | data.put("count", count); |
| | | data.put("list", JsonUtil.getApiCommonGson().toJson(listInfo)); |
| | | |
| | | return data; |
| | | } |
| | | |
| | | @Override |
| | | public void addClick(Long shopId) { |
| | | BrandClassShop brandClassShop = brandClassShopMapper.getByShopId(shopId); |
| | | if (brandClassShop != null) { |
| | | Long browseNum = brandClassShop.getBrowseNum(); |
| | | if (browseNum == null) { |
| | | browseNum = 0L; |
| | | } |
| | | |
| | | BrandClassShop classShop = new BrandClassShop(); |
| | | classShop.setId(brandClassShop.getId()); |
| | | classShop.setBrowseNum(browseNum++); |
| | | brandClassShopMapper.updateByPrimaryKeySelective(classShop); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void updateShopGoods() { |
| | | // 查询店铺 |
| | | List<BrandClassShop> shopList = listQuery(0, 1000, "", null, BrandClassShop.STATE_VALID); |
| | | if (shopList != null) |
| | | for (BrandClassShop shop : shopList) { |
| | | SearchFilter sf = new SearchFilter(); |
| | | sf.setKey(shop.getShop().getShopName().replace("官方旗舰店", "").replace("旗舰店", "")); |
| | | sf.setPage(1); |
| | | sf.setPageSize(100); |
| | | TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiaoNew(sf,null,null); |
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); |
| | | if (result != null && result.getTaoBaoGoodsBriefs() != null) |
| | | for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) { |
| | | if (goods.getSellerId().longValue() == shop.getShop().getId()) { |
| | | if (taoBaoGoodsBriefService.queryByAuctionId(goods.getAuctionId()).size() == 0) { |
| | | goods.setCreatetime(new Date()); |
| | | goods.setState(0); |
| | | goods.setUpdatetime(new Date()); |
| | | goodsList.add(goods); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (goodsList.size() > 0) |
| | | taoBaoGoodsBriefService.insertBatch(goodsList); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<TaoBaoShopVO> listEffectiveShop(long start, int count, Long cid,String platform,String version,SystemEnum system) { |
| | | if (cid != null && cid <= 0) { |
| | | cid = null; |
| | | } |
| | | |
| | | List<TaoBaoShopVO> listInfo = taoBaoShopService.listBrandShopinfo(start, count, cid); |
| | | if (listInfo == null || listInfo.size() == 0) |
| | | return listInfo; |
| | | |
| | | |
| | | GoodsMoneyConfigParamsDTO paramsDTO = |
| | | orderHongBaoMoneyComputeService.getShowComputeRate(platform, version,system); |
| | | // 淘宝商品信息过滤 |
| | | Map<String, TaoBaoGoodsBrief> goodsMap = getFilterTaoBaoGoods(listInfo); |
| | | |
| | | for (TaoBaoShopVO taoBaoShopVO : listInfo) { |
| | | String shopNameCustom = taoBaoShopVO.getShopNameCustom(); |
| | | if (!StringUtil.isNullOrEmpty(shopNameCustom)) { |
| | | taoBaoShopVO.setShopName(shopNameCustom); |
| | | } |
| | | |
| | | String shopIconCustom = taoBaoShopVO.getShopIconCustom(); |
| | | if (!StringUtil.isNullOrEmpty(shopIconCustom)) { |
| | | taoBaoShopVO.setShopIcon(shopIconCustom); |
| | | } |
| | | |
| | | List<GoodsDetailVO> listGoods = new ArrayList<GoodsDetailVO>(); |
| | | List<TaoBaoGoodsBrief> listGoodsBrief = taoBaoShopVO.getListGoodsBrief(); |
| | | // 商品添加到更新队列 |
| | | taoBaoGoodsUpdateService.addUpdateQueueAsync(listGoodsBrief); |
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : listGoodsBrief) { |
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory |
| | | .convertTaoBao(goodsMap.get(taoBaoGoodsBrief.getAuctionId()), paramsDTO); |
| | | listGoods.add(goodsDetailVO); |
| | | } |
| | | taoBaoShopVO.setListGoodsVO(listGoods); |
| | | } |
| | | return listInfo; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public long countBrandShopinfo(Long cid) { |
| | | if (cid != null && cid <= 0) { |
| | | cid = null; |
| | | } |
| | | return taoBaoShopService.countBrandShopinfo(cid); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<TaoBaoShop> listEffectiveClassShop(Long cid, SystemEnum system) { |
| | | if (cid == null) |
| | | return null; |
| | | |
| | | List<BrandClassShop> list = brandClassShopMapper.listEffective(cid,system); |
| | | if (list == null || list.size() == 0) |
| | | return null; |
| | | |
| | | List<TaoBaoShop> listShop = new ArrayList<TaoBaoShop>(); |
| | | for (BrandClassShop brandClassShop : list) { |
| | | TaoBaoShop shop = brandClassShop.getShop(); |
| | | if (shop != null) { |
| | | Integer userType = shop.getUserType(); |
| | | if (userType == null || userType == 0) { |
| | | shop.setUserType(10); |
| | | } else { |
| | | shop.setUserType(11); |
| | | } |
| | | |
| | | String shopLink = shop.getShopLink(); |
| | | if (StringUtil.isNullOrEmpty(shopLink)) { |
| | | shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId())); |
| | | } |
| | | |
| | | String shopNameCustom = shop.getShopNameCustom(); |
| | | if (!StringUtil.isNullOrEmpty(shopNameCustom)) { |
| | | shop.setShopName(shopNameCustom); |
| | | } |
| | | |
| | | String shopIconCustom = shop.getShopIconCustom(); |
| | | if (!StringUtil.isNullOrEmpty(shopIconCustom)) { |
| | | shop.setShopIcon(shopIconCustom); |
| | | } |
| | | |
| | | listShop.add(shop); |
| | | } |
| | | } |
| | | return listShop; |
| | | } |
| | | |
| | | } |