| | |
| | | package com.yeshi.fanli.service.impl.dynamic;
|
| | |
|
| | | import java.lang.reflect.InvocationTargetException;
|
| | | import java.math.BigDecimal;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.dynamic.DynamicInfoDao;
|
| | | import com.yeshi.fanli.dto.ConfigParamsDTO;
|
| | | import com.yeshi.fanli.dto.taobao.TaoBaoShopDTO;
|
| | | import com.yeshi.fanli.entity.bus.activity.ActivityRuleUser;
|
| | | import com.yeshi.fanli.entity.bus.activity.ActivityUser;
|
| | |
| | | import com.yeshi.fanli.service.inter.dynamic.DynamicInfoService;
|
| | | import com.yeshi.fanli.service.inter.dynamic.InviteMaterialService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | 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.service.inter.taobao.dataoke.DaTaoKeGoodsService;
|
| | |
| | | buffer.append(" ");
|
| | | buffer.append("早安~\n");
|
| | | buffer.append("我的邀请码:【邀请码】\n");
|
| | | buffer.append("购物省钱返利券App:【邀请链接】");
|
| | | buffer.append("购物省钱板栗快省App:【邀请链接】");
|
| | |
|
| | | content = content.replaceAll("\\,", "\\,").replaceAll("\\.", "\\。").replaceAll("\\;", "\\;")
|
| | | .replaceAll("\\!", "\\!").replaceAll("\\?", "\\?").replaceAll("\\:", "\\:");
|
| | |
| | | if (StringUtil.isNullOrEmpty(shopLink)) {
|
| | | taoBaoShop.setShopLink(TaoBaoUtil.getShopLink(taoBaoShop.getId()));
|
| | | }
|
| | | |
| | | if(StringUtil.isNullOrEmpty(taoBaoShop.getShopIcon())) |
| | | taoBaoShop.setShopIcon(dynamicShopInfo.getShopIcon());
|
| | |
|
| | | DynamicInfo dynamicVO = new DynamicInfo();
|
| | | dynamicVO.setId(brandId);
|
| | |
| | | public void insertTimeHotSale() {
|
| | | Long classId = 1L;
|
| | | try {
|
| | | saveHotSale(classId, 0L);
|
| | | for (int i = 0; i < 3; i++) {
|
| | | boolean addSuccess = saveHotSale(classId, 0L);
|
| | | if (addSuccess) {
|
| | | break;
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | List<GoodsClass> list = DaTaoKeUtil.goodsClasses;
|
| | | for (GoodsClass goodsClass : list) {
|
| | | try {
|
| | | saveHotSale(classId, goodsClass.getId());
|
| | | for (int i = 0; i < 3; i++) {
|
| | | boolean addSuccess = saveHotSale(classId, goodsClass.getId());
|
| | | if (addSuccess) {
|
| | | break;
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | * @param subclassId
|
| | | * @throws TaobaoGoodsDownException
|
| | | */
|
| | | public void saveHotSale(Long classId, Long subclassId) throws TaobaoGoodsDownException {
|
| | | public boolean saveHotSale(Long classId, Long subclassId) throws TaobaoGoodsDownException {
|
| | | boolean addSuccess = false;
|
| | | List<Long> listId = null;
|
| | | List<DynamicInfo> listInfo = dynamicInfoDao.query(classId, subclassId);
|
| | | if (listInfo != null && listInfo.size() > 0) {
|
| | |
| | | }
|
| | | // 大淘客数据
|
| | | DaTaoKeDetail daTaoKe = daTaoKeGoodsService.getGoodsNotInList(subclassId, listId, 1).get(0);
|
| | | if (daTaoKe == null) {
|
| | | return addSuccess;
|
| | | }
|
| | |
|
| | | try {
|
| | | daTaoKe = DaTaoKeUtil.filterDaTaoKe(TaoKeApiUtil.searchGoodsDetail(daTaoKe.getGoodsId()), daTaoKe);
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | | |
| | | // 过滤为空的
|
| | | if (daTaoKe == null) {
|
| | | return;
|
| | |
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = TaoBaoUtil.convert(daTaoKe);
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | TaoBaoGoodsBriefExtra goodsExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(),
|
| | | null);
|
| | |
|
| | | if (!goodsExtra.isCoupon() || (goodsExtra.getState() != null && goodsExtra.getState() == 1)) {
|
| | | return addSuccess; // 已下架 、无券 不加入
|
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBrief> listGoods = new ArrayList<TaoBaoGoodsBrief>();
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = TaoBaoUtil.convert(daTaoKe);
|
| | | listGoods.add(taoBaoGoodsBrief);
|
| | |
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief,
|
| | | proportion.toString(), null);
|
| | | |
| | | // 商品图片
|
| | | goodsExtra.setTkRate(taoBaoGoodsBrief.getTkRate());
|
| | | goodsExtra.setUpdatetime(new Date());
|
| | | goodsExtra.setCouponInfo(null);
|
| | |
|
| | | GoodsPicture goodsPicture = getGoodsPicture(daTaoKe);
|
| | | if (!taoBaoGoodsBriefExtra.isCoupon()) {
|
| | | taoBaoGoodsBriefExtra.setState(1);
|
| | | goodsPicture.setGoodState(1);
|
| | | }
|
| | | taoBaoGoodsBriefExtra.setTkRate(taoBaoGoodsBrief.getTkRate());
|
| | | taoBaoGoodsBriefExtra.setUpdatetime(new Date());
|
| | | taoBaoGoodsBriefExtra.setCouponInfo(null);
|
| | | goodsPicture.setGoods(taoBaoGoodsBriefExtra);
|
| | | |
| | | goodsPicture.setGoods(goodsExtra);
|
| | | // 商品列表
|
| | | List<GoodsPicture> listPicture = new ArrayList<GoodsPicture>();
|
| | | listPicture.add(goodsPicture);
|
| | | |
| | | // 分享奖金
|
| | | BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(taoBaoGoodsBrief);
|
| | | ClientTextStyleVO shareMoneyDesc = new ClientTextStyleVO();
|
| | | shareMoneyDesc.setColor("#FFFFFF");
|
| | | shareMoneyDesc.setBottomColor("#E8AE48");
|
| | | shareMoneyDesc.setContent("预估分享奖金:¥" + shareMoney);
|
| | | |
| | |
|
| | | // 获取商品列表图片
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief2 = TaoKeApiUtil.getSimpleGoodsInfo(daTaoKe.getGoodsId());
|
| | |
| | | listPicture.add(picture);
|
| | | }
|
| | | }
|
| | | goodsExtra.setImgList(imgList);
|
| | |
|
| | | taoBaoGoodsBriefExtra.setImgList(imgList);
|
| | | // 分享奖金
|
| | | BigDecimal shareMoney = taoBaoGoodsBriefService.getShareGoodsUserHongBao(taoBaoGoodsBrief);
|
| | | ClientTextStyleVO shareMoneyDesc = new ClientTextStyleVO();
|
| | | shareMoneyDesc.setColor("#FFFFFF");
|
| | | shareMoneyDesc.setBottomColor("#E8AE48");
|
| | | shareMoneyDesc.setContent("预估分享奖金:¥" + shareMoney);
|
| | |
|
| | | // 组织动态信息
|
| | | DynamicInfo dynamicInfo = getDynamicInfo(daTaoKe, classId, subclassId);
|
| | |
| | |
|
| | | // 保存信息
|
| | | dynamicInfoDao.insert(dynamicInfo);
|
| | |
|
| | | addSuccess = true;
|
| | | return addSuccess;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | | return list;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | private Map<Long, TaoBaoGoodsBrief> getFilterGoodsMap(List<DynamicInfo> list) {
|
| | | // 提取过滤商品
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | for (DynamicInfo dynamicInfo : list) {
|
| | | List<GoodsPicture> gpList = dynamicInfo.getImgs();
|
| | | if (gpList != null)
|
| | | for (GoodsPicture gp : gpList) {
|
| | | if (gp != null && gp.getGoods() != null) {
|
| | | TaoBaoGoodsBriefExtra newGoods = new TaoBaoGoodsBriefExtra();
|
| | | try {
|
| | | PropertyUtils.copyProperties(newGoods, gp.getGoods());
|
| | | goodsList.add(newGoods);
|
| | | } catch (IllegalAccessException e) {
|
| | | e.printStackTrace();
|
| | | } catch (InvocationTargetException e) {
|
| | | e.printStackTrace();
|
| | | } catch (NoSuchMethodException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | goodsList = taoBaoGoodsUpdateService.filterImportantTaoBaoGoods(goodsList);
|
| | | Map<Long, TaoBaoGoodsBrief> map = new HashMap<>();
|
| | | if (goodsList != null)
|
| | | for (TaoBaoGoodsBrief goods : goodsList)
|
| | | map.put(goods.getAuctionId(), goods);
|
| | | return map;
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "dynamicCache", key = "'queryV2-'+#platform+'-'+#version+'-'+#start+'-'+#count+'-'+#cid+'-'+#subId")
|
| | | public List<DynamicInfo> queryV2(int platform, int version, int start, int count, Long cid, Long subId) {
|
| | | List<DynamicInfo> listNew = new ArrayList<DynamicInfo>();
|
| | | List<DynamicInfo> list = dynamicInfoDao.query(start, count, cid, subId);
|
| | | // 需要更新的商品
|
| | | List<TaoBaoGoodsBrief> taoBaoGoodsUpdateList = new ArrayList<>();
|
| | | if (list != null && list.size() > 0) {
|
| | | // 提取商品
|
| | | Map<Long, TaoBaoGoodsBrief> goodsMap = getFilterGoodsMap(list);
|
| | |
|
| | | BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate();
|
| | | for (DynamicInfo dynamicInfo: list) {
|
| | | ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE);
|
| | |
|
| | | for (DynamicInfo dynamicInfo : list) {
|
| | | DynamicInfo dynamicNew = new DynamicInfo();
|
| | | try {
|
| | | PropertyUtils.copyProperties(dynamicNew, dynamicInfo);
|
| | |
| | | e.printStackTrace();
|
| | | continue;
|
| | | }
|
| | | |
| | |
|
| | | // 店铺信息
|
| | | TaoBaoShop shop = dynamicNew.getShop();
|
| | | if (shop != null) {
|
| | | Integer userType = shop.getUserType();
|
| | | if (userType == null || userType == 0) {
|
| | | shop.setUserType(10);
|
| | | } else {
|
| | | shop.setUserType(11);
|
| | | TaoBaoShop shopNew = new TaoBaoShop();
|
| | | try {
|
| | | PropertyUtils.copyProperties(shopNew, shop);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | continue;
|
| | | }
|
| | | dynamicNew.setShop(shop);
|
| | | Integer userType = shopNew.getUserType();
|
| | | if (userType == null || userType == 0) {
|
| | | shopNew.setUserType(10);
|
| | | } else {
|
| | | shopNew.setUserType(11);
|
| | | }
|
| | | dynamicNew.setShop(shopNew);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | List<GoodsPicture> imgsNew = new ArrayList<GoodsPicture>();
|
| | | List<GoodsPicture> imgs = dynamicNew.getImgs();
|
| | | if (imgs != null && imgs.size() > 0) {
|
| | | for (GoodsPicture goodsPicture: imgs) {
|
| | | for (GoodsPicture goodsPicture : imgs) {
|
| | | TaoBaoGoodsBriefExtra goods = goodsPicture.getGoods();
|
| | | if (goods == null) {
|
| | | imgsNew.add(goodsPicture);
|
| | | continue;
|
| | | }
|
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBaoGoodsBriefExtra(goods, fanLiRate, shareRate);
|
| | | goodsPicture.setGoodsVO(detailVO);
|
| | | goodsPicture.setGoods(null);
|
| | | |
| | | JumpDetailV2 jumpDetail = goodsPicture.getJumpDetail();
|
| | |
|
| | | taoBaoGoodsUpdateList.add(goods);
|
| | |
|
| | | GoodsPicture goodsNew = new GoodsPicture();
|
| | | try {
|
| | | PropertyUtils.copyProperties(goodsNew, goodsPicture);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | continue;
|
| | | }
|
| | |
|
| | | // 过滤券信息与资金信息
|
| | | goods.setCouponAmount(goodsMap.get(goods.getAuctionId()).getCouponAmount());
|
| | | goods.setZkPrice(goodsMap.get(goods.getAuctionId()).getZkPrice());
|
| | | goods.setCouponStartFee(goodsMap.get(goods.getAuctionId()).getCouponStartFee());
|
| | | goods.setTkRate(goodsMap.get(goods.getAuctionId()).getTkRate());
|
| | |
|
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBaoGoodsBriefExtra(goods, paramsDTO);
|
| | |
|
| | | goodsNew.setGoodsVO(detailVO);
|
| | | goodsNew.setGoods(null);
|
| | |
|
| | | JumpDetailV2 jumpDetail = goodsNew.getJumpDetail();
|
| | | if (jumpDetail != null) {
|
| | | JumpDetailV2 jumpDetailV2 = jumpDetailV2Service.getByTypeCache(jumpDetail.getType(), platform, version);
|
| | | JumpDetailV2 jumpDetailV2 = jumpDetailV2Service.getByTypeCache(jumpDetail.getType(),
|
| | | platform, version);
|
| | | if (jumpDetailV2 != null) {
|
| | | goodsPicture.setJumpDetail(jumpDetailV2);
|
| | | goodsNew.setJumpDetail(jumpDetailV2);
|
| | | }
|
| | | }
|
| | |
|
| | | imgsNew.add(goodsNew);
|
| | | }
|
| | | dynamicNew.setImgs(imgsNew);
|
| | | }
|
| | | dynamicNew.setImgs(imgs);
|
| | | listNew.add(dynamicNew);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | // 更新商品信息
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | |
| | | updateGoodInfo(list);
|
| | | }
|
| | | });
|
| | |
|
| | | taoBaoGoodsUpdateService.addUpdateQueueAsync(taoBaoGoodsUpdateList);
|
| | | return listNew;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 更新商品信息
|
| | |
| | | if (list == null || list.size() == 0) {
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | | for (DynamicInfo dynamicInfo : list) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | boolean needUpdate = false;
|
| | | // 已下架ID
|
| | | List<Long> listDown = new ArrayList<Long>();
|
| | | // 商品列表
|
| | |
| | | continue;
|
| | | }
|
| | |
|
| | | Integer state = oldExtra.getState();
|
| | | if (state != null && state == 1) {
|
| | | continue;
|
| | | }
|
| | | /*
|
| | | * Integer state = oldExtra.getState(); if (state != null && state == 1) {
|
| | | * continue; }
|
| | | */
|
| | |
|
| | | TaoBaoGoodsBrief goodsBrief = null;
|
| | | try {
|
| | |
| | | dynamicInfo.setDesc(shareMoneyDesc);
|
| | | }
|
| | | }
|
| | |
|
| | | // 需要更新信息;
|
| | | needUpdate = true;
|
| | | }
|
| | |
|
| | | // 无效更新信息
|
| | | if (!needUpdate) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | // 更新商品信息
|
| | | dynamicInfo.setImgs(listPicture);
|
| | |
|
| | | // 商品已下架
|