| | |
| | |
|
| | | import org.apache.commons.httpclient.HttpClient;
|
| | | import org.apache.commons.httpclient.methods.PostMethod;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | |
| | |
|
| | | public static Long POSITION_FANLI = 1834339426L;
|
| | | public static Long POSITION_SHARE = 1834289924L;
|
| | | public static Long POSITION_COUPON = 1859510742L;
|
| | |
|
| | | // 订单查询类型
|
| | | public static int ORDER_TYPE_CREATETIME = 1;// 下单时间
|
| | |
| | | result = resultJson.optJSONObject("jd_union_open_promotion_common_get_response").optString("result");
|
| | | resultJson = JSONObject.fromObject(result);
|
| | | return resultJson.optJSONObject("data").optString("clickURL");
|
| | | }
|
| | | |
| | | /**
|
| | | * 转链接-短连接
|
| | | * @param materialId
|
| | | * @param couponUrl
|
| | | * @param positionId
|
| | | * @param ext1
|
| | | * @return
|
| | | */
|
| | | public static String convertShortLink(String materialId, String couponUrl, String positionId, String ext1) {
|
| | | String url = convertLink(materialId, couponUrl, positionId, ext1);
|
| | | if (!StringUtil.isNullOrEmpty(url)) {
|
| | | url = HttpUtil.getShortLink(url);
|
| | | }
|
| | | return url;
|
| | | }
|
| | |
|
| | |
|
| | |
| | | // 价格信息
|
| | | Object priceInfo = json.get("priceInfo");
|
| | | JSONObject priceInfoJson = JSONObject.fromObject(priceInfo);
|
| | | BigDecimal price = new BigDecimal(priceInfoJson.optString("price"));
|
| | | goods.setPrice(price);
|
| | | goods.setPrice(new BigDecimal(priceInfoJson.optString("price")));
|
| | |
|
| | | // 店铺信息
|
| | | Object shopInfo = json.get("shopInfo");
|
| | |
| | | commissionInfo.setCommissionShare(new BigDecimal(commissionJson.optString("commissionShare")));
|
| | | goods.setCommissionInfo(commissionInfo);
|
| | |
|
| | | |
| | | // 券信息
|
| | | Object coupon = json.get("couponInfo");
|
| | | if (coupon != null) {
|
| | | JSONObject couponJson = JSONObject.fromObject(coupon);
|
| | | JSONArray couponArray = couponJson.optJSONArray("couponList");
|
| | | if (couponArray != null) {
|
| | | BigDecimal gap = null;
|
| | | JDCouponInfo couponInfo = null;
|
| | | for (int i = 0; i < couponArray.size(); i++) {
|
| | | boolean add = false;
|
| | | JSONObject jdcoupon = couponArray.optJSONObject(i);
|
| | | if (couponInfo == null) {
|
| | | couponInfo = new JDCouponInfo();
|
| | | add = true;
|
| | | }
|
| | | |
| | | BigDecimal quota = new BigDecimal(jdcoupon.optString("quota"));
|
| | | BigDecimal sub = MoneyBigDecimalUtil.sub(price, quota);
|
| | | if (gap == null) {
|
| | | gap = sub;
|
| | | } else if (sub.compareTo(gap) == 0) {
|
| | | BigDecimal discount = new BigDecimal(jdcoupon.optString("discount"));
|
| | | if (discount.compareTo(couponInfo.getDiscount()) > 0) {
|
| | | add = true;
|
| | | }
|
| | | } else if (sub.compareTo(gap) > 0) {
|
| | | add = true;
|
| | | }
|
| | | |
| | | if (add) {
|
| | | couponInfo.setBindType(jdcoupon.optInt("bindType"));
|
| | | couponInfo.setDiscount(new BigDecimal(jdcoupon.optString("discount")));
|
| | | couponInfo.setQuota(new BigDecimal(jdcoupon.optString("quota")));
|
| | | couponInfo.setPlatformType(jdcoupon.optInt("platformType"));
|
| | | couponInfo.setGetEndTime(jdcoupon.optLong("getEndTime"));
|
| | | couponInfo.setGetStartTime(jdcoupon.optLong("getStartTime"));
|
| | | couponInfo.setUseEndTime(jdcoupon.optLong("useEndTime"));
|
| | | couponInfo.setUseStartTime(jdcoupon.optLong("useStartTime"));
|
| | | couponInfo.setLink(jdcoupon.optString("link"));
|
| | | }
|
| | | }
|
| | | goods.setCouponInfo(couponInfo);
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | // 图片信息
|
| | | List<String> imageList = new ArrayList<String>();
|
| | | Object images = json.get("imageInfo");
|
| | |
| | | goods.setPicUrl(imageList.get(0));
|
| | | }
|
| | |
|
| | | BigDecimal price = new BigDecimal(priceInfoJson.optString("price"));
|
| | | // 拼购信息
|
| | | Object pinGouInfo = json.get("pinGouInfo");
|
| | | if (pinGouInfo != null) {
|
| | | JSONObject pinGouInfoJson = JSONObject.fromObject(pinGouInfo);
|
| | | if (!pinGouInfoJson.isEmpty()) {
|
| | | JDPingouInfo jdPinGouInfo = new JDPingouInfo();
|
| | | jdPinGouInfo.setPingouPrice(new BigDecimal(pinGouInfoJson.optString("pingouPrice")));
|
| | | price = new BigDecimal(pinGouInfoJson.optString("pingouPrice"));
|
| | | jdPinGouInfo.setPingouPrice(price);
|
| | | jdPinGouInfo.setPingouTmCount(pinGouInfoJson.optLong("pingouTmCount"));
|
| | | jdPinGouInfo.setPingouUrl(pinGouInfoJson.optString("pingouUrl"));
|
| | | jdPinGouInfo.setTotalCount(pinGouInfoJson.optLong("totalCount"));
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | // 券信息
|
| | | Object coupon = json.get("couponInfo");
|
| | | if (coupon != null) {
|
| | | JSONObject couponJson = JSONObject.fromObject(coupon);
|
| | | JSONArray couponArray = couponJson.optJSONArray("couponList");
|
| | | if (couponArray != null) {
|
| | | BigDecimal discount_temp = null;
|
| | | JDCouponInfo couponInfo = null;
|
| | | for (int i = 0; i < couponArray.size(); i++) {
|
| | | boolean add = false;
|
| | | JSONObject jdcoupon = couponArray.optJSONObject(i);
|
| | | |
| | | BigDecimal quota = new BigDecimal(jdcoupon.optString("quota"));
|
| | | BigDecimal sub = MoneyBigDecimalUtil.sub(price, quota);
|
| | | if (sub.compareTo(new BigDecimal(0)) < 0) {
|
| | | continue; // 商品价格小于优惠券价格限制
|
| | | }
|
| | | |
| | | // 券面额
|
| | | BigDecimal discount = new BigDecimal(jdcoupon.optString("discount"));
|
| | | if (discount_temp == null) {
|
| | | add = true;
|
| | | discount_temp = discount;
|
| | | } else if (discount_temp.compareTo(discount) > 0) { // 券面额大
|
| | | add = true;
|
| | | }
|
| | | |
| | | if (add) {
|
| | | if (couponInfo == null) {
|
| | | couponInfo = new JDCouponInfo();
|
| | | }
|
| | | |
| | | couponInfo.setBindType(jdcoupon.optInt("bindType"));
|
| | | couponInfo.setDiscount(new BigDecimal(jdcoupon.optString("discount")));
|
| | | couponInfo.setQuota(new BigDecimal(jdcoupon.optString("quota")));
|
| | | couponInfo.setPlatformType(jdcoupon.optInt("platformType"));
|
| | | couponInfo.setGetEndTime(jdcoupon.optLong("getEndTime"));
|
| | | couponInfo.setGetStartTime(jdcoupon.optLong("getStartTime"));
|
| | | couponInfo.setUseEndTime(jdcoupon.optLong("useEndTime"));
|
| | | couponInfo.setUseStartTime(jdcoupon.optLong("useStartTime"));
|
| | | couponInfo.setLink(jdcoupon.optString("link"));
|
| | | }
|
| | | }
|
| | | |
| | | goods.setCouponInfo(couponInfo);
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | return goods;
|
| | | }
|
| | |
|