| | |
| | | import org.yeshi.utils.BigDecimalUtil;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.GoodsClassDTO;
|
| | | import com.yeshi.fanli.dto.jd.JDCommissionInfo;
|
| | | import com.yeshi.fanli.dto.jd.JDCouponInfo;
|
| | | import com.yeshi.fanli.dto.jd.JDPingouInfo;
|
| | |
| | | import com.yeshi.fanli.dto.jd.JDSearchResult;
|
| | | import com.yeshi.fanli.dto.jd.JDShopInfo;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | return BigDecimalUtil.getWithNoZera(MoneyBigDecimalUtil.mul(money, new BigDecimal("0.9")));
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 商品佣金计算
|
| | | * |
| | | * @param goods
|
| | | * @param rate
|
| | | * @return
|
| | | */
|
| | | public static BigDecimal getGoodsFanLiMoneyPlus(JDGoods goods, BigDecimal rate) {
|
| | | BigDecimal money = new BigDecimal(0);
|
| | | BigDecimal commissionPlus = goods.getCommissionPlus();
|
| | | if (commissionPlus == null) {
|
| | | return money;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | BigDecimal price = null;
|
| | | JDPingouInfo pinGouInfo = goods.getPinGouInfo();
|
| | | if (pinGouInfo == null) {
|
| | | price = goods.getPrice();
|
| | | } else {
|
| | | price = pinGouInfo.getPingouPrice();
|
| | | }
|
| | |
|
| | | JDCouponInfo couponInfo = goods.getCouponInfo();
|
| | | if (couponInfo == null) {
|
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil
|
| | | .mul(MoneyBigDecimalUtil.mul(price, commissionPlus), new BigDecimal("0.01")),
|
| | | MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | | } else {
|
| | | BigDecimal quota = couponInfo.getQuota();
|
| | | BigDecimal discount = couponInfo.getDiscount();
|
| | | if (quota.compareTo(price) <= 0 && price.compareTo(discount) > 0) {
|
| | |
|
| | | BigDecimal finalPrice = price.subtract(discount);
|
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(
|
| | | MoneyBigDecimalUtil.mul(finalPrice, commissionPlus),
|
| | | new BigDecimal("0.01")), MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | |
|
| | | } else {// 不能用券
|
| | | money = MoneyBigDecimalUtil.mul(
|
| | | MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(price,commissionPlus),
|
| | | new BigDecimal("0.01")),
|
| | | MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | | }
|
| | | }
|
| | | // 返利比例为原来的90%
|
| | | return BigDecimalUtil.getWithNoZera(MoneyBigDecimalUtil.mul(money, new BigDecimal("0.9")));
|
| | | }
|
| | | |
| | | /**
|
| | | * 计算商品券后价,没有券则返回原价
|
| | | *
|
| | |
| | | }
|
| | | return jdGoods;
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 获取类目
|
| | | * @param level 等级
|
| | | * @param parentId 上级id
|
| | | * @return
|
| | | */
|
| | | public static List<GoodsClassDTO> getCategoryList(int level, int parentId) {
|
| | | try {
|
| | | // 请求地址
|
| | | String requestUrl = "https://union.jd.com/api/help/getCategoryList?level=%s&parentId=%s";
|
| | | // 执行请求
|
| | | String result = HttpUtil.get(String.format(requestUrl, level, parentId));
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(result)) {
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONArray jsonArray = json.getJSONArray("data");
|
| | | if (jsonArray != null && jsonArray.size() > 0) {
|
| | | List<GoodsClassDTO> list = new ArrayList<GoodsClassDTO>();
|
| | | for (int i=0;i <jsonArray.size() ;i ++ ) {
|
| | | Object object = jsonArray.get(i);
|
| | | if (object == null)
|
| | | continue;
|
| | | JSONObject jsonClass = JSONObject.fromObject(object);
|
| | | |
| | | GoodsClassDTO goodsClass = new GoodsClassDTO();
|
| | | goodsClass.setId(jsonClass.optString("id"));
|
| | | goodsClass.setName(jsonClass.optString("categoryName"));
|
| | | list.add(goodsClass);
|
| | | }
|
| | | return list;
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取类目
|
| | | * @param level 等级
|
| | | * @param parentId 上级id
|
| | | * @return
|
| | | */
|
| | | public static List<GoodsClassDTO> getCategoryCommiPlus(int level, int parentId) {
|
| | | try {
|
| | | // 请求地址
|
| | | String requestUrl = "https://union.jd.com/api/help/getCategoryCommiPlus?level=%s&parentId=%s";
|
| | | // 执行请求
|
| | | String result = HttpUtil.get(String.format(requestUrl, level, parentId));
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(result)) {
|
| | | JSONObject json = JSONObject.fromObject(result);
|
| | | JSONArray jsonArray = json.getJSONArray("data");
|
| | | if (jsonArray != null && jsonArray.size() > 0) {
|
| | | List<GoodsClassDTO> list = new ArrayList<GoodsClassDTO>();
|
| | | for (int i=0;i <jsonArray.size() ;i ++ ) {
|
| | | Object object = jsonArray.get(i);
|
| | | if (object == null)
|
| | | continue;
|
| | | JSONObject jsonClass = JSONObject.fromObject(object);
|
| | | |
| | | GoodsClassDTO goodsClass = new GoodsClassDTO();
|
| | | goodsClass.setId(jsonClass.optString("id"));
|
| | | goodsClass.setName(jsonClass.optString("name"));
|
| | | |
| | | String selfMobileComm = jsonClass.optString("selfMobileComm");
|
| | | if (!StringUtil.isNullOrEmpty(selfMobileComm)) |
| | | goodsClass.setSelfComm(new BigDecimal(selfMobileComm));
|
| | | |
| | | String popMobileComm = jsonClass.optString("popMobileComm");
|
| | | if (!StringUtil.isNullOrEmpty(popMobileComm)) |
| | | goodsClass.setPopComm(new BigDecimal(popMobileComm));
|
| | | |
| | | list.add(goodsClass);
|
| | | }
|
| | | return list;
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | | }
|