app支持用户余额,有时需要余额支付的时候,修改表,还需要找好几个表,而且直接修改表,app页面
也不会出现充值记录。用python进行接口请求,模拟真实操作。
#!/usr/bin/python #coding=UTF-8 import requests import hashlib import conf def
get_cash(uid):#获取余额操作码 cash_code_url = conf.cash_code_url cash_code_data = {
"uid":uid,"operator_id":"1002543687","operator_name":"zhaoyuzhong"} req_post =
requests.post(cash_code_url,data=cash_code_data)try: idx = str(req_post.json()[
'data']['cash_idx']) return idx except: print req_post.json()['msg'] def
recharge(uid,username,count_balance):# 手工补款接口 cash_idx=get_cash(uid) check_str
= conf.check_str checksum = md5(checkstr) recharge_url = conf.recharge_url
recharge_data = conf.recharge_data req_post =
requests.post(recharge_url,data=recharge_data)#post方法使用data参数传递 print "手动补款接口"
,req_post.json()['msg'] def withdraw(uid,username,count_cash,count_balance):
#财务提现接口 cash_idx=get_cash(uid) check_str = conf.check_str checksum =
md5(checkstr) withdraw_url = conf.withdraw_url withdraw_data =
conf.withdraw_data req_post = requests.post(withdraw_url,data=withdraw_data)
print "财务提现接口",req_post.json()['msg'] def md5(str):#加密字符串为md5 m=hashlib.md5()
m.update(str) psw=m.hexdigest()return psw def getBalance(uid):#查询个人余额接口
get_Balance_url = conf.getBalance_url get_Balance_data = {"uid":uid} req_post =
requests.post(get_Balance_url,data=get_Balance_data) cash = myreq_post.json()[
'data']['cash'] balance= myreq_post.json()['data']['balance'] usable =
myreq_post.json()['data']['usable'] print "可提现cash=",cash,"余额balance=",balance,
"可用的usable=",usable if __name__ == '__main__': #给手机号18688888888,uid为933634
用户充值1000元 getBalance(933634)# 先查询用户uid 的余额 recharge(933634,18688888888,100000)
#手动充余额,uid,手机号,充值金额:单位:分 getBalance(933634) #再查询下余额
执行结果:

技术
©2019-2020 Toolsou All rights reserved,
JS三个数取最大值(优化算法写法)IDA分析HELLO ARM 程序的ARM 反汇编EPC事件过程链一个项目的开发过程及成员组成Boost源码学习---shared_ptr.hppJava岗秋招:已拿阿里、字节跳动offer,详细面经奉上112路径总和——力扣算法系列2020.07.07 Python影响K8S Pod分配和调度策略的两大关键特性(acm)C++加速输入的几种方法Spring注解驱动开发(一)