| | |
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.cache.ehcache.EhCacheCacheManager;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.taobao.TLJBuyGoodsDao;
|
| | |
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | |
| | | @Resource
|
| | | private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
|
| | |
|
| | | @Resource
|
| | | private EhCacheCacheManager ehCacheCacheManager;
|
| | |
|
| | | @Override
|
| | | public void addTLJBuyGoods(TLJBuyGoods goods) {
|
| | | public void addTLJBuyGoods(TLJBuyGoods goods, TaoKeAppInfo taoKeAppInfo) {
|
| | | if (goods == null || StringUtil.isNullOrEmpty(goods.getDay()) || goods.getGoods() == null)
|
| | | return;
|
| | | goods.setId(StringUtil.Md5(goods.getDay() + "#" + goods.getGoods().getAuctionId()));
|
| | | if (goods.getUpdateTime() == null)
|
| | | goods.setUpdateTime(new Date());
|
| | | if (taoKeAppInfo != null)
|
| | | goods.setAppKey(taoKeAppInfo.getAppKey());
|
| | | tljBuyGoodsDao.save(goods);
|
| | | }
|
| | |
|
| | | @Cacheable(value = "commonContentCache", key = "'tljBuy-listByDay'+#day")
|
| | | @Override
|
| | | public List<TLJBuyGoods> listByDay(String day) {
|
| | | return listByDay(day, 10);
|
| | | List<TLJBuyGoods> list = listByDay(day, 10);
|
| | | // if (list.size() <= 10)
|
| | | // return list;
|
| | | // else {
|
| | | // List<TLJBuyGoods> newList = new ArrayList<>();
|
| | | // for (int i = 0; i < 10; i++) {
|
| | | // newList.add(list.get(i));
|
| | | // }
|
| | | // return newList;
|
| | | // }
|
| | | return list;
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | List<TLJBuyGoods> list = tljBuyGoodsDao.listByDayOrderByUpdateTime(day, 1, count);
|
| | | List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | if (list != null) {
|
| | | for (TLJBuyGoods shg : list)
|
| | | for (TLJBuyGoods shg : list) {
|
| | | // 计算推广红包
|
| | | BigDecimal spreadMoney = TaoBaoUtil.getGoodsHongBaoMoney(shg.getGoods(),
|
| | | TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE);
|
| | | BigDecimal finalPrice = TaoBaoUtil.getAfterUseCouplePrice(shg.getGoods());
|
| | |
|
| | | // 推广红包 不能小于1,价格不能大于30
|
| | | if (spreadMoney.compareTo(new BigDecimal(1.0)) < 0 || finalPrice.compareTo(new BigDecimal(30)) >= 0) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | goodsList.add(shg.getGoods());
|
| | | }
|
| | | }
|
| | | // 过滤下线商品
|
| | | goodsList = taoBaoGoodsBriefService.filterOffLineGoods(goodsList);
|
| | |
| | | try {
|
| | | taoLiJinDTO = TaoKeApiUtil.createTaoLiJin(auctionId, "淘礼金验证", new BigDecimal("1.00"), 1, new Date(),
|
| | | new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6), new Date(),
|
| | | new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6),
|
| | | new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
|
| | | TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT));
|
| | | new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 6), TaoBaoConstant.ownBuyApp);
|
| | | } catch (TaoKeApiException e) {
|
| | | if (e.getCode() == TaoKeApiException.CODE_TLJ_FORBIDDEN) {
|
| | | // 该商品不支持创建淘礼金红包
|
| | |
| | |
|
| | | @Override
|
| | | public void updateGoods(TaoBaoGoodsBrief goods) {
|
| | | if (goods == null)
|
| | | return;
|
| | | List<TLJBuyGoods> list = tljBuyGoodsDao.listByAuctionId(goods.getAuctionId());
|
| | | // 查询自购立减是否小于1元
|
| | | BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(goods, TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE);
|
| | | // if (money.compareTo(new BigDecimal(1)) < 0) {// 删除商品
|
| | | // if (list != null)
|
| | | // for (TLJBuyGoods tljGoods : list) {
|
| | | // tljBuyGoodsDao.delete(tljGoods.getId());
|
| | | // }
|
| | | // }
|
| | |
|
| | | if (list != null)
|
| | | for (TLJBuyGoods TLJBuyGoods : list) {
|
| | |
|
| | | if (goods.getCouponInfo() == null)
|
| | | goods.setCouponInfo("");
|
| | | if (goods.getCouponAmount() == null)
|
| | | goods.setCouponAmount(new BigDecimal(0));
|
| | |
|
| | | // 判断 券信息 价格信息 返利比例信息是否改变
|
| | | boolean change = false;
|
| | | if (goods.getZkPrice().compareTo(TLJBuyGoods.getGoods().getZkPrice()) != 0)
|
| | | change = true;
|
| | | if (goods.getCouponAmount().compareTo(TLJBuyGoods.getGoods().getCouponAmount()) != 0)
|
| | | change = true;
|
| | | if (!goods.getCouponInfo().equalsIgnoreCase(TLJBuyGoods.getGoods().getCouponInfo()))
|
| | | change = true;
|
| | | if (goods.getTkRate().compareTo(TLJBuyGoods.getGoods().getTkRate()) != 0)
|
| | | change = true;
|
| | |
|
| | | if (change) {
|
| | | // 清除列表缓存
|
| | | ehCacheCacheManager.getCache("commonContentCache").evict(
|
| | | "tljBuy-listByDay" + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
|
| | | }
|
| | |
|
| | | // 更新券信息 ,价格信息,销量信息
|
| | | TLJBuyGoods.getGoods().setZkPrice(goods.getZkPrice());
|
| | | TLJBuyGoods.getGoods().setCouponAmount(goods.getCouponAmount());
|
| | |
| | | TLJBuyGoods.getGoods().setCouponStartFee(goods.getCouponStartFee());
|
| | | TLJBuyGoods.getGoods().setCouponTotalCount(goods.getCouponTotalCount());
|
| | | TLJBuyGoods.getGoods().setBiz30day(goods.getBiz30day());
|
| | | TLJBuyGoods.getGoods().setTkRate(goods.getTkRate());
|
| | | tljBuyGoodsDao.save(TLJBuyGoods);
|
| | | }
|
| | | }
|