| | |
| | | * @param: orderChannelName |
| | | **/ |
| | | public static boolean isMerchantCanPay(OrderChannelEnum channel, String merchant, BigDecimal payMoney) throws UnsupportedEncodingException { |
| | | if (channel == OrderChannelEnum.cyx) { |
| | | String url = String.format("https://api.youihuo.com/open/free.checkKsCompanyName?bsName=%s&apiKey=%s", URLEncoder.encode(merchant, "UTF-8"), OrderChannelUtil.CYX_API_KEY); |
| | | String result = HttpUtil.get(url); |
| | | logger.info(String.format("超佣享商家付款判断:%s-%s-%s", merchant, result, payMoney!=null?payMoney.setScale(2,RoundingMode.HALF_UP).toString():null)); |
| | | JSONObject root = JSONObject.fromObject(result); |
| | | System.out.println(result); |
| | | if (root.optInt("code") == 1000) { |
| | | return true; |
| | | } |
| | | } else if (channel == OrderChannelEnum.bps) { |
| | | String url = String.format("https://api.bpshe.com/mall/douyinOMS/getSubsidyOrderInfo?appKey=cdaef330f1324961a73e15a85ab67fd2&payAccount=%s", URLEncoder.encode(merchant, StandardCharsets.UTF_8.displayName())); |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Accept", "application/json;charset=utf-8"); |
| | | String result = HttpUtil.get(url, headers); |
| | | logger.info(String.format("爆品社商家付款判断:%s-%s-%s", merchant, result, payMoney!=null?payMoney.setScale(2,RoundingMode.HALF_UP).toString():null)); |
| | | JSONObject root = JSONObject.fromObject(result); |
| | | if (root.optInt("errCode") == 0) { |
| | | JSONArray array = root.optJSONObject("data").optJSONArray("payAmounts"); |
| | | if (array != null) { |
| | | if (payMoney == null) { |
| | | return true; |
| | | } |
| | | Set<String> moneys = new HashSet<>(); |
| | | for (int i = 0; i < array.size(); i++) { |
| | | moneys.add(array.optString(i)); |
| | | } |
| | | return moneys.contains(payMoney.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | } |
| | | } |
| | | } |
| | | try { |
| | | if (channel == OrderChannelEnum.cyx) { |
| | | String url = String.format("https://api.youihuo.com/open/free.checkKsCompanyName?bsName=%s&apiKey=%s", URLEncoder.encode(merchant, "UTF-8"), OrderChannelUtil.CYX_API_KEY); |
| | | String result = HttpUtil.get(url); |
| | | logger.info(String.format("超佣享商家付款判断:%s-%s-%s", merchant, result, payMoney != null ? payMoney.setScale(2, RoundingMode.HALF_UP).toString() : null)); |
| | | JSONObject root = JSONObject.fromObject(result); |
| | | System.out.println(result); |
| | | if (root.optInt("code") == 1000) { |
| | | return true; |
| | | } |
| | | } else if (channel == OrderChannelEnum.bps) { |
| | | String url = String.format("https://api.bpshe.com/mall/douyinOMS/getSubsidyOrderInfo?appKey=cdaef330f1324961a73e15a85ab67fd2&payAccount=%s", URLEncoder.encode(merchant, StandardCharsets.UTF_8.displayName())); |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Accept", "application/json;charset=utf-8"); |
| | | String result = HttpUtil.get(url, headers); |
| | | logger.info(String.format("爆品社商家付款判断:%s-%s-%s", merchant, result, payMoney != null ? payMoney.setScale(2, RoundingMode.HALF_UP).toString() : null)); |
| | | JSONObject root = JSONObject.fromObject(result); |
| | | if (root.optInt("errCode") == 0) { |
| | | JSONArray array = root.optJSONObject("data").optJSONArray("payAmounts"); |
| | | if (array != null) { |
| | | if (payMoney == null) { |
| | | return true; |
| | | } |
| | | Set<String> moneys = new HashSet<>(); |
| | | for (int i = 0; i < array.size(); i++) { |
| | | moneys.add(array.optString(i)); |
| | | } |
| | | return moneys.contains(payMoney.setScale(2, RoundingMode.HALF_UP).toString()); |
| | | } |
| | | } |
| | | } |
| | | }catch(Exception e){ |
| | | logger.error("商家验证错误:", e); |
| | | } |
| | | return false; |
| | | } |
| | | |