zoukankan      html  css  js  c++  java
  • 部分还款-还款试算接口-python

    一、swagger-ui中

    二、python中调用接口,出现的问题:

    解决办法:

    import requests
    # 还款试算接口
    ur1='http://10.253.43.83:8399/repayment/order/repaymentTrial'
    headers = {'Content-Type':'application/json','Accept': '*/*'}
    Value = {
      "accountNo": "ZH20220202071059",
      "channelNo": "0014",
      "endPeriod": 1,
      "isSettle": "0",
      "loanCode": "JKSQ20220208048780DK",
      "payCode": "5815042292859904",
      "period": 1,
      "repayWay": "2"
    }
    r = requests.post(url=ur1,json=Value,headers=headers)
    repones = r.text
    repones2 =r.json()
    print('1',r.json())
    print('2',r.status_code)
    print('3',r.headers)

     三、json中文输出的问题,输出的不是中文:

    修改后

    import requests
    import json
    # 还款试算接口
    ur1='http://10.253.43.83:8399/repayment/order/repaymentTrial'
    headers = {'Content-Type':'application/json','Accept': '*/*'}
    Value = {
      "accountNo": "ZH20220202071059",
      "channelNo": "0014",
      "endPeriod": 1,
      "isSettle": "0",
      "loanCode": "JKSQ20220208048780DK",
      "payCode": "5815042292859904",
      "period": 1,
      "repayWay": "2"
    }
    r = requests.post(url=ur1,json=Value,headers=headers)
    repones = r.text
    repones2 =r.json()
    repones3=json.dumps(repones2,indent=4,ensure_ascii=False)
    print('1',repones3)
    print('2',r.status_code)
    print('3',r.headers)

     四、添加金额的判断逻辑

    import requests
    import json
    import pymysql
    '''
    # 还款试算接口
    '''
    ur1='http://10.253.43.83:8399/repayment/order/repaymentTrial'
    headers = {'Content-Type':'application/json','Accept': '*/*'}
    Value = {
      "accountNo": "ZH20220202071059",
      "channelNo": "0014",
      "endPeriod": 1,
      "isSettle": "0",
      "loanCode": "JKSQ20220208048780DK",
      "payCode": "5815042292859904",
      "period": 1,
      "repayWay": "2"
    }
    r = requests.post(url=ur1,json=Value,headers=headers)
    repones2 =r.json()
    repones3=json.dumps(repones2,indent=4,ensure_ascii=False)#ensure_ascii=False将返回的json汉字化
    print('1',repones3)
    print('2',r.status_code)
    print('3',r.headers)
    
    repones = r.text
    print('11',repones)
    print(type(repones))#<class 'str'>
    
    s=repones
    s_dic=eval(s)
    print('s_dic的类型为:',type(s_dic))#自发一串转换为字典
    print('s_dic:',s_dic)
    payBen=s_dic['data']['payBen']#打印字典中的某个值
    payIni=s_dic['data']['payIni']#打印字典中的某个值
    payFee=s_dic['data']['payFee']#打印字典中的某个值
    payMoney=s_dic['data']['payMoney']#打印字典中的某个值
    orderId=s_dic['data']['orderId']#打印字典中的某个值
    print('payBen:',payBen,'类型为:',type(payBen))
    print('payIni:',payIni,'类型为:',type(payIni))
    print('payFee:',payFee,'类型为:',type(payFee))
    print('payMoney:',payMoney,'类型为:',type(payMoney))
    print('orderId:',orderId,'类型为:',type(orderId))
    
    #判断payMoney的值是否为payBen、payIni、payFee的和
    payMoneytotal=payBen+payIni+payFee
    print(payMoneytotal)
    payMoneytotal2=round(payMoneytotal,2)#取小数点后两位数
    print(payMoneytotal2)
    if payMoneytotal2==payMoney:
      print('payMoney的值,PASS:','payBen+payIni+payFee=payMoney')
    else:
      print('呵呵哒...')
  • 相关阅读:
    001 spring AOP介绍
    026 spring事件机制--基础内容
    025 使用@Profile完成环境条件注入
    ExpandoObject使用
    企业微信接口问题
    企业号验证后携带URL参数跳转问题
    在创建一个MVC控制器,显示运行所选代码生成器时出错(带读写,使用EF)
    码栈批量提取淘宝后台的图图片空间图片
    码栈编码
    在微信里面打开链接,显示501 Not Implemented,但是同样的链接在其他浏览器是可以打开的。
  • 原文地址:https://www.cnblogs.com/jpr-ok/p/10438101.html
Copyright © 2011-2022 走看看