123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- # -*- coding: utf-8 -*-
- # !/usr/bin/env python
- from library.jdbase.exceptions import JDException
- from library.jdopen.client.api.base import BaseJdOpenAPI
- class JdOpenSupport(BaseJdOpenAPI):
- def query_province(self):
- """
- 查询省
- """
- return self._get("/v1/agent/province/list")
- def query_city(self, code):
- """
- 查询市
- """
- return self._get("/v1/agent/city/list/code/{code}".format(code = code))
- def query_district(self, code):
- """
- 查询区
- """
- return self._get("/v1/agent/district/list/code/{code}".format(code = code))
- def query_industry(self):
- """
- 查询一级行业
- """
- return self._get("/v1/agent/industry/list")
- def query_sub_industry(self, num):
- """
- 查询二级行业
- """
- return self._get("/v1/agent/industry/second/list/code/{num}".format(num = num))
- def query_bank(self, k = None):
- """
- 查询银行
- """
- return self._get("/v1/agent/bank/list/{k}".format(k = k or u"银行"))
- def query_sub_bank(self, bankCode, subK = None):
- """
- 查询支行
- """
- return self._get(
- "/v1/agent/bankSub/list/{bankCode}/{subK}".format(bankCode = bankCode or u"", subK = subK or u"行"))
- def query_pay_type(self):
- return self._get("/v1/agent/pay/bankinfo/list")
- def get_product_customer(self, customerNum, payProduct):
- url = "/api/queryTradeRoute"
- data = {
- "customerNum": customerNum,
- "payProduct": payProduct
- }
- return self._post(url = url, data = data)
- def query_sub_channel(self, customerNum, payProduct):
- payProduct = payProduct if payProduct else "WX"
- result = self.get_product_customer(customerNum, payProduct)
- if not result or 'data' not in result:
- return None
- for item in result["data"]:
- if item["status"] == "OPEN":
- return item["subCustomerNum"]
- return None
- def query_auth_status(self, customerNum, payProduct, subMerchantId):
- def processor(self, result):
- if 'success' not in result or not result['success'] or result['code'] != 'success':
- raise JDException(
- errCode = result.get('code'),
- errMsg = result.get("message"),
- client = self)
- else:
- return result
- url = "/api/queryAuthStatus"
- data = {
- 'agentNum': self.agentNum,
- 'customerNum': customerNum,
- 'bankType': payProduct,
- 'subCustomerNum': subMerchantId
- }
- sendData = {_k: str(_v) for _k, _v in data.items() if _v is not None}
- return self._post(url = url, data = sendData, processor = processor)
- def submit_auth(self, customerNum, payProduct, subMerchantId):
- def processor(self, result):
- if 'success' not in result or not result['success'] or result['code'] != 'success':
- raise JDException(
- errCode = result.get('code'),
- errMsg = result.get("message"),
- client = self)
- else:
- return result
- url = "/api/wxCreateAuthorizeInfo"
- data = {
- 'agentNum': self.agentNum,
- 'customerNum': customerNum,
- 'bankType': payProduct,
- 'subCustomerNum': subMerchantId
- }
- sendData = {_k: str(_v) for _k, _v in data.items() if _v is not None}
- return self._post(url = url, data = sendData, processor = processor)
- def add_wechat_auth_pay_dir(self, customerNum, auth_pay_dir):
- """
- 追加商户微信支付目录
- :param customerNum:
- :param auth_pay_dir:
- :return:
- """
- def processor(self, result):
- if 'success' not in result or not result['success'] or result['code'] != 'success':
- raise JDException(
- errCode = result.get('code'),
- errMsg = result.get("message"),
- client = self)
- else:
- return result
- url = '/api/addAuthPayDirsDevConfig'
- data = {
- 'customerNum': customerNum,
- 'authPayDir': auth_pay_dir
- }
- return self._post(url = url, data = data, processor = processor)
- def query_wechat_auth_pay_dir(self, customerNum, batchNum):
- """
- 查询商户微信支付目录
- :param customerNum:
- :param auth_pay_dir:
- :return:
- """
- def processor(self, result):
- if 'success' not in result or not result['success'] or result['code'] != 'success':
- raise JDException(
- errCode = result.get('code'),
- errMsg = result.get("message"),
- client = self)
- else:
- return result
- url = '/api/queryAddAuthPayDirsDevConfigByBatchNum'
- data = {
- 'customerNum': customerNum,
- 'batchNum': batchNum
- }
- return self._post(url = url, data = data, processor = processor)
|