29 lines
1.0 KiB
Plaintext
29 lines
1.0 KiB
Plaintext
async def baidu_order_cancel(ns={}):
|
|
baidu_id = ns['baidu_id']
|
|
order_id = ns['order_id']
|
|
paydata = {'queryAccountId': baidu_id, 'orderIds': [order_id]}
|
|
ns_format = '&'.join(['%s=%s' % (k, v) for k, v in ns.items()])
|
|
url = 'https://billing.baidubce.com/v1/order/cancel?%s' % ns_format
|
|
method = 'POST'
|
|
header = {
|
|
"Host": "billing.baidubce.com"
|
|
}
|
|
header = await get_auth_header(method=method, url=url, header=header)
|
|
async with aiohttp_client.request(
|
|
method=method,
|
|
url=url,
|
|
headers=header,
|
|
json=paydata) as res:
|
|
res = await res.json()
|
|
db = DBPools()
|
|
async with db.sqlorContext('kboss') as sor:
|
|
if res.get('success'):
|
|
sql_update = "update baidu_orders set status='CANCELLED' where order_id='%s'" % order_id
|
|
await sor.sqlExe(sql_update, {})
|
|
return {
|
|
'status': True,
|
|
'msg': 'order cancel success, %s' % str(res)
|
|
}
|
|
|
|
ret = await baidu_order_cancel(params_kw)
|
|
return ret |