| | |
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collections;
|
| | | import java.util.Comparator;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.cache.annotation.CacheEvict;
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.cache.ehcache.EhCacheCacheManager;
|
| | | import org.springframework.stereotype.Service;
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.exception.tlj.TaoLiJinCreateException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | |
| | | goods.setUpdateTime(new Date());
|
| | | if (taoKeAppInfo != null)
|
| | | goods.setAppKey(taoKeAppInfo.getAppKey());
|
| | | if (goods.getWeight() == null)
|
| | | goods.setWeight(1);
|
| | | tljBuyGoodsDao.save(goods);
|
| | | }
|
| | |
|
| | |
| | | List<TLJBuyGoods> goodsList = new ArrayList<>();
|
| | | for (TaoBaoUnionConfig appInfo : configList) {
|
| | | List<TLJBuyGoods> list = listByDay(appInfo.getAppKey(), day, 10);
|
| | | if (list != null)
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | // 过滤淘礼金大于10块钱的
|
| | | BigDecimal hongBao = TaoBaoUtil.getGoodsHongBaoMoney(list.get(i).getGoods(),
|
| | | TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE);
|
| | | if (hongBao.compareTo(new BigDecimal(10)) > 0) {
|
| | | list.remove(i--);
|
| | | }
|
| | | }
|
| | |
|
| | | if (list != null && list.size() > 0)
|
| | | goodsList.addAll(list);
|
| | | }
|
| | | Collections.shuffle(goodsList);
|
| | | Comparator<TLJBuyGoods> cm = new Comparator<TLJBuyGoods>() {
|
| | |
|
| | | @Override
|
| | | public int compare(TLJBuyGoods o1, TLJBuyGoods o2) {
|
| | | return o1.getWeight() != null && o2.getWeight() != null ? o2.getWeight() - o1.getWeight() : 0;
|
| | | }
|
| | | };
|
| | | Collections.sort(goodsList, cm);
|
| | | return goodsList;
|
| | | }
|
| | |
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean verifyCanCreateTLJ(Long auctionId,TaoKeAppInfo app) {
|
| | | public boolean verifyCanCreateTLJ(Long auctionId, TaoKeAppInfo app) {
|
| | | TaoLiJinDTO taoLiJinDTO = null;
|
| | | 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), app);
|
| | | } catch (TaoKeApiException e) {
|
| | | if (e.getCode() == TaoKeApiException.CODE_TLJ_FORBIDDEN) {
|
| | | } catch (TaoLiJinCreateException e1) {
|
| | | LogHelper.test("商品ID:"+auctionId);
|
| | | LogHelper.test("淘礼金验证出错:"+e1.getMsg());
|
| | | |
| | | if (e1.getCode() == TaoLiJinCreateException.CODE_TLJ_FORBIDDEN) {
|
| | | // 该商品不支持创建淘礼金红包
|
| | | deleteByGoodsId(auctionId);
|
| | | return false;
|
| | | } else if (e.getCode() == TaoKeApiException.CODE_TLJ_NO_MONEY) {
|
| | | } else if (e1.getCode() == TaoLiJinCreateException.CODE_TLJ_NO_MONEY) {
|
| | | // 官方玩法钱包余额不足 TODO
|
| | | }
|
| | | } catch (TaoKeApiException e) {
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
| | | return tljBuyGoodsDao.selectByAuctionIdAndDay(auctionId, day);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void removeGoods(Long auctionId) {
|
| | | tljBuyGoodsDao.deleteByAuctionId(auctionId);
|
| | | // 清除列表缓存
|
| | | ehCacheCacheManager.getCache("commonContentCache")
|
| | | .evict("tljBuy-listByDay" + TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
|
| | | }
|
| | |
|
| | | } |