| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新京东商品-免单 |
| | | */ |
| | | private void updateGoodsJD() { |
| | | int maxNum = 5; |
| | | BigDecimal limitPrice = new BigDecimal(2); |
| | | List<FreeGoodsCoupon> listExist = freeGoodsCouponService.listByType(0, 100, Constant.SOURCE_TYPE_JD); |
| | | |
| | | GoodsMoneyConfigParamsDTO params = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55",SystemEnum.blks); |
| | | params.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(SystemEnum.blks)); |
| | | |
| | | // 信息更新 |
| | | List<GoodsDetailVO> listNew = new ArrayList<GoodsDetailVO>(); |
| | | List<FreeGoodsCoupon> listdel = new ArrayList<FreeGoodsCoupon>(); |
| | | if (listExist != null && listExist.size() > 0) { |
| | | for (FreeGoodsCoupon freeGood : listExist) { |
| | | JDGoods goodsInfo = jdGoodsCacheUtil.getGoodsInfo(Long.parseLong(freeGood.getGoodsId())); |
| | | if (goodsInfo == null) { |
| | | listdel.add(freeGood); |
| | | } else { |
| | | if (listNew.size() >= 5) { |
| | | listdel.add(freeGood); |
| | | continue; |
| | | } |
| | | |
| | | // 比例限制: 金比高于60% |
| | | JDCommissionInfo commissionInfo = goodsInfo.getCommissionInfo(); |
| | | if (commissionInfo == null) { |
| | | continue; |
| | | } |
| | | if (commissionInfo.getCommissionShare().compareTo(BigDecimal.valueOf(60)) < 0) { |
| | | continue; |
| | | } |
| | | |
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertJDGoods(goodsInfo, params); |
| | | |
| | | if (detailVO.getCouponPrice() != null) { |
| | | if (detailVO.getCouponPrice().compareTo(limitPrice) > 0) |
| | | continue; |
| | | } else if (detailVO.getZkPrice().compareTo(limitPrice) > 0) { |
| | | continue; |
| | | } |
| | | |
| | | boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO); |
| | | if (saveResult) { |
| | | listNew.add(detailVO); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // 不足补齐 |
| | | if (listNew.size() < maxNum) { |
| | | JDFilter filterAPI = new JDFilter(); |
| | | filterAPI.setPageSize(Constant.PAGE_SIZE); |
| | | filterAPI.setPriceto(2.0); |
| | | filterAPI.setCommissionShareStart(60); |
| | | for (int page = 1; page < 1000; page++) { |
| | | filterAPI.setPageIndex(page); |
| | | JDSearchResult result = JDApiUtil.queryByKey(filterAPI); |
| | | if (result == null) { |
| | | break; |
| | | } |
| | | |
| | | List<JDGoods> goodsList = result.getGoodsList(); |
| | | if (goodsList == null || goodsList.size() == 0) { |
| | | break; |
| | | } |
| | | |
| | | for (JDGoods goods : goodsList) { |
| | | // 比例限制: 金比高于60% |
| | | JDCommissionInfo commissionInfo = goods.getCommissionInfo(); |
| | | if (commissionInfo == null) { |
| | | continue; |
| | | } |
| | | if (commissionInfo.getCommissionShare().compareTo(BigDecimal.valueOf(60)) < 0) { |
| | | continue; |
| | | } |
| | | |
| | | boolean exist = false; |
| | | if (listNew.size() > 0) { |
| | | for (GoodsDetailVO goodsDetailVO : listNew) { |
| | | if (goodsDetailVO.getGoodsId().equalsIgnoreCase(goods.getSkuId() + "")) { |
| | | exist = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (exist) |
| | | continue; |
| | | |
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertJDGoods(goods, params); |
| | | boolean saveResult = freeGoodsCouponService.saveFreeGoods(detailVO); |
| | | if (saveResult) { |
| | | listNew.add(detailVO); |
| | | } |
| | | |
| | | if (listNew.size() >= maxNum) |
| | | break; |
| | | } |
| | | |
| | | if (listNew.size() >= maxNum) |
| | | break; |
| | | } |
| | | } |
| | | |
| | | // 删除不满足条件 |
| | | if (listdel.size() > 0) { |
| | | for (FreeGoodsCoupon freeGoods : listdel) { |
| | | freeGoodsCouponService.delete(freeGoods.getGoodsId(), freeGoods.getGoodsType()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新京东商品-免单 |