This commit is contained in:
hrx 2025-09-25 15:07:35 +08:00
commit dc514871b6
3 changed files with 51 additions and 42 deletions

View File

@ -110,7 +110,7 @@ async def affirmbz_order(ns={}):
return {'status': True, 'msg': '支付成功'} return {'status': True, 'msg': '支付成功'}
except Exception as error: except Exception as error:
await sor.rollback() await sor.rollback()
raise error return {'status': False, 'msg': str(error)}
async def baidu_new_update_resouce(ns={}): async def baidu_new_update_resouce(ns={}):
@ -235,10 +235,10 @@ async def get_baidu_orderlist(ns={}):
serviceType = orders[0]['orderItems'] serviceType = orders[0]['orderItems']
# 可能获取得到的是延迟订单 # 可能获取得到的是延迟订单
if orders[0]['type'] == 'REFUND' and orders[0]['status'] != 'CREATED': # if orders[0]['type'] == 'REFUND' and orders[0]['status'] != 'CREATED':
await update_baidu_order_list({'userid': ns.get('userid')}) # await update_baidu_order_list({'userid': ns.get('userid')})
res_refund = await baidu_confirm_refund_order({'order_id': ns.get('order_id'), 'baidu_id': baidu_users[0]['baidu_id'], 'user_id': ns.get('userid')}) # res_refund = await baidu_confirm_refund_order({'order_id': ns.get('order_id'), 'baidu_id': baidu_users[0]['baidu_id'], 'user_id': ns.get('userid')})
return res_refund # return res_refund
# 避免重复退订 # 避免重复退订
if orders[0]['type'] == 'REFUND' and orders[0]['status'] == 'CREATED': if orders[0]['type'] == 'REFUND' and orders[0]['status'] == 'CREATED':
@ -617,7 +617,7 @@ async def get_baidu_orderlist(ns={}):
# await baidu_new_update_resouce(ns) # await baidu_new_update_resouce(ns)
return { return {
'status': True, 'status': True,
'orderid': bz_ns['id'], 'orderid': bz_ns.get('id'),
'originalprice': bz_ns.get('originalprice'), 'originalprice': bz_ns.get('originalprice'),
'servicename': bz_ns.get('servicename'), 'servicename': bz_ns.get('servicename'),
'amount': total_price 'amount': total_price
@ -713,7 +713,7 @@ async def update_baidu_order_list(ns={}):
async def baidu_confirm_refund_order(ns={}): async def baidu_confirm_refund_order(ns={}):
# ns = { # ns = {
# 'order_id': ["03ee8d08da79458b8f8d3157d3498330", "e711729606024080bf9613d975294616"], # 'order_id': ["13f3518648054796abf7f3d00ed611bf"],
# 'userid': 'KsKhCUPizQyGiw3L1WVRy' # 'userid': 'KsKhCUPizQyGiw3L1WVRy'
# } # }
import asyncio import asyncio
@ -738,6 +738,10 @@ async def baidu_confirm_refund_order(ns={}):
refund_status_li = await sor.R('baidu_orders', {'orderid': order_id}) refund_status_li = await sor.R('baidu_orders', {'orderid': order_id})
refundstatus = refund_status_li[0]['refundstatus'] refundstatus = refund_status_li[0]['refundstatus']
refund_id = refund_status_li[0]['id'] refund_id = refund_status_li[0]['id']
ns_record_li = await sor.R('user_action', {'orderid': order_id})
ns_record_id = ns_record_li[0]['id'] if ns_record_li else None
ns_record = {'id': ns_record_id} if ns_record_id else None
if not refundstatus: if not refundstatus:
# data_ = {} # data_ = {}
@ -771,7 +775,15 @@ async def baidu_confirm_refund_order(ns={}):
await sor.U('baidu_orders', {'id': refund_id, 'refundstatus': '1'}) await sor.U('baidu_orders', {'id': refund_id, 'refundstatus': '1'})
# 增加延迟 # 增加延迟
await asyncio.sleep(2) await asyncio.sleep(1)
# 延迟2-3秒还是获取到 ready状态的订单那就重复请求一次目的是尽快刷新状态
async with aiohttp_client.request(
method=method,
url=url,
headers=header,
json=paydata) as res:
await res.json()
# 把 NEED_CONFIRM的本地库改为CREATED # 把 NEED_CONFIRM的本地库改为CREATED
await update_baidu_order_list({'userid': ns.get('userid')}) await update_baidu_order_list({'userid': ns.get('userid')})
@ -800,8 +812,9 @@ async def baidu_confirm_refund_order(ns={}):
if local_refund_status.get('status'): if local_refund_status.get('status'):
db = DBPools() db = DBPools()
async with db.sqlorContext('kboss') as sor: async with db.sqlorContext('kboss') as sor:
await sor.U('baidu_orders', {'id': refund_id, 'refundstatus': '2'}) baidu_orders_status_update = """update baidu_orders set refundstatus='2' where id='%s';""" % refund_id
await sor.U('user_action', {'id': ns_record.get('id'), 'ordertype': 'REFUND', 'reason': '远程退款成功, 本地客户退款成功'}) await sor.sqlExe(baidu_orders_status_update, {})
await sor.U('user_action', {'id': ns_record.get('id'), 'ordertype': 'REFUND', 'reason': '远程退款成功, 本地客户退款成功'})
continue continue
# return { # return {

View File

@ -2,7 +2,7 @@
*/20 * * * * curl https://dev.kaiyuancloud.cn/zj/zj_get_order.dspy */20 * * * * curl https://dev.kaiyuancloud.cn/zj/zj_get_order.dspy
49 9-10 * * * curl https://dev.kaiyuancloud.cn/zj/zj_get_bill.dspy 49 9-10 * * * curl https://dev.kaiyuancloud.cn/zj/zj_get_bill.dspy
*/20 * * * * curl https://www.kaiyuancloud.cn/dev/hpc/GetUserBill.dspy > /d/zhc/crontab_dev.log 2>&1 #*/20 * * * * curl https://www.kaiyuancloud.cn/dev/hpc/GetUserBill.dspy > /d/zhc/crontab_dev.log 2>&1
0 0 * * * curl https://www.kaiyuancloud.cn/dev/lease/update_stock.dspy > /d/zhc/crontab_dev.log 2>&1 0 0 * * * curl https://www.kaiyuancloud.cn/dev/lease/update_stock.dspy > /d/zhc/crontab_dev.log 2>&1
# 30 9 * * * curl https://www.kaiyuancloud.cn/dev/provider_settle/auto_provider_settle_cron_job.dspy > /d/zhc/crontab_dev.log 2>&1 # 30 9 * * * curl https://www.kaiyuancloud.cn/dev/provider_settle/auto_provider_settle_cron_job.dspy > /d/zhc/crontab_dev.log 2>&1
# 0 1 * * * curl https://www.kaiyuancloud.cn/dev/handover/params_time.dspy > /d/zhc/crontab_dev.log 2>&1 # 0 1 * * * curl https://www.kaiyuancloud.cn/dev/handover/params_time.dspy > /d/zhc/crontab_dev.log 2>&1
@ -13,7 +13,7 @@
* * * * * curl https://www.kaiyuancloud.cn/dev/baiduc/baidu_new_update_resouce.dspy > /d/zhc/crontab_dev.log 2>&1 * * * * * curl https://www.kaiyuancloud.cn/dev/baiduc/baidu_new_update_resouce.dspy > /d/zhc/crontab_dev.log 2>&1
#* * * * * curl https://www.kaiyuancloud.cn/dev/baiduc/baidu_sms_kafka_consumer.dspy > /d/zhc/crontab_dev.log 2>&1 #* * * * * curl https://www.kaiyuancloud.cn/dev/baiduc/baidu_sms_kafka_consumer.dspy > /d/zhc/crontab_dev.log 2>&1
*/20 * * * * curl https://dev.opencomputing.cn/hpc/GetUserBill.dspy > /d/zhc/crontab_dev.log 2>&1 #*/20 * * * * curl https://dev.opencomputing.cn/hpc/GetUserBill.dspy > /d/zhc/crontab_dev.log 2>&1
0 0 * * * curl https://dev.opencomputing.cn/lease/update_stock.dspy > /d/zhc/crontab_dev.log 2>&1 0 0 * * * curl https://dev.opencomputing.cn/lease/update_stock.dspy > /d/zhc/crontab_dev.log 2>&1
# 30 9 * * * curl https://dev.opencomputing.cn/provider_settle/auto_provider_settle_cron_job.dspy > /d/zhc/crontab_dev.log 2>&1 # 30 9 * * * curl https://dev.opencomputing.cn/provider_settle/auto_provider_settle_cron_job.dspy > /d/zhc/crontab_dev.log 2>&1
# 0 1 * * * curl https://dev.opencomputing.cn/handover/params_time.dspy > /d/zhc/crontab_dev.log 2>&1 # 0 1 * * * curl https://dev.opencomputing.cn/handover/params_time.dspy > /d/zhc/crontab_dev.log 2>&1
@ -24,7 +24,7 @@
* * * * * curl https://dev.opencomputing.cn/baiduc/baidu_new_update_resouce.dspy > /d/zhc/crontab_dev.log 2>&1 * * * * * curl https://dev.opencomputing.cn/baiduc/baidu_new_update_resouce.dspy > /d/zhc/crontab_dev.log 2>&1
#* * * * * curl https://dev.opencomputing.cn/baiduc/baidu_sms_kafka_consumer.dspy > /d/zhc/crontab_dev.log 2>&1 #* * * * * curl https://dev.opencomputing.cn/baiduc/baidu_sms_kafka_consumer.dspy > /d/zhc/crontab_dev.log 2>&1
*/20 * * * * curl https://www.opencomputing.cn/hpc/GetUserBill.dspy > /d/zhc/crontab_prod.log 2>&1 #*/20 * * * * curl https://www.opencomputing.cn/hpc/GetUserBill.dspy > /d/zhc/crontab_prod.log 2>&1
0 0 * * * curl https://www.opencomputing.cn/lease/update_stock.dspy > /d/zhc/crontab_prod.log 2>&1 0 0 * * * curl https://www.opencomputing.cn/lease/update_stock.dspy > /d/zhc/crontab_prod.log 2>&1
# 30 9 * * * curl https://www.opencomputing.cn/provider_settle/auto_provider_settle_cron_job.dspy > /d/zhc/crontab_prod.log 2>&1 # 30 9 * * * curl https://www.opencomputing.cn/provider_settle/auto_provider_settle_cron_job.dspy > /d/zhc/crontab_prod.log 2>&1
# 0 1 * * * curl https://www.opencomputing.cn/handover/params_time.dspy > /d/zhc/crontab_prod.log 2>&1 # 0 1 * * * curl https://www.opencomputing.cn/handover/params_time.dspy > /d/zhc/crontab_prod.log 2>&1

View File

@ -1,11 +1,13 @@
<template> <template>
<div class="box"> <div class="box">
<!-- 添加全屏加载效果 -->
<iframe v-loading="loading" v-if="url" :src="url" frameborder="0" class="baidu-style"> <div v-loading="loading" class="loading-container">
</iframe> <iframe v-if="url" :src="url" frameborder="0" class="baidu-style">
<div v-else> </iframe>
<p>请先登录百度云账号</p> <div v-else class="login-prompt">
<button @click="getToken">重试</button> <p>请先登录百度云账号</p>
<button @click="getToken">重试</button>
</div>
</div> </div>
</div> </div>
</template> </template>
@ -22,7 +24,6 @@ export default {
url: '', url: '',
loading: true, loading: true,
userid: '', userid: '',
} }
}, },
async created() { async created() {
@ -62,24 +63,12 @@ export default {
console.log('接收到消息:', event); console.log('接收到消息:', event);
const data = event.data; const data = event.data;
console.log('接收到的 data 是:', data); console.log('接收到的 data 是:', data);
// 1. ()
// const expectedOrigin = 'https://console.vcp.baidu.com';
// if (event.origin !== expectedOrigin) {
// console.warn('Received message from unexpected origin:', event.origin);
// return;
// }
// 2. refundInfo uuidList // 2. refundInfo uuidList
if (data && data.refundInfo && Array.isArray(data.refundInfo.uuidList) && data.refundInfo.uuidList.length > 0) { if (data && data.refundInfo && Array.isArray(data.refundInfo.uuidList) && data.refundInfo.uuidList.length > 0) {
const uuidListArray = data.refundInfo.uuidList; // const uuidListArray = data.refundInfo.uuidList; //
// 3. ID () console.log('提取到的订单ID:', uuidListArray);
// ID退
const orderId = uuidListArray;
// ID
// const orderId = uuidListArray.join(',');
console.log('提取到的订单ID:', orderId);
// 4. ID // 4. ID
this.userid = sessionStorage.getItem('userId'); this.userid = sessionStorage.getItem('userId');
@ -91,7 +80,7 @@ export default {
// 5. // 5.
const payload = { const payload = {
order_id: orderId, order_id: uuidListArray,
userid: this.userid userid: this.userid
}; };
@ -103,10 +92,10 @@ export default {
.then((res) => { .then((res) => {
console.log("调用 reqBaiduJudgePrice 接口返回:", res); console.log("调用 reqBaiduJudgePrice 接口返回:", res);
if (res.status) { // status true if (res.status) { // status true
this.$message.success('退订成功'); this.$message.success('退订成功');
// // - 使 path url
this.$router.push({ this.$router.push({
url: '/BaiduNetdisk', path: '/BaiduNetdisk',
}); });
} else { } else {
// //
@ -124,7 +113,6 @@ export default {
}); });
} else { } else {
console.log('接收到的消息不包含有效的退款信息或 uuidList 为空'); console.log('接收到的消息不包含有效的退款信息或 uuidList 为空');
//
} }
} }
} }
@ -137,11 +125,19 @@ export default {
height: 100%; height: 100%;
} }
.loading-container {
width: 100%;
height: 100%;
position: relative;
}
.login-prompt {
text-align: center;
padding: 50px;
}
.baidu-style { .baidu-style {
width: 100%; width: 100%;
height: calc(100vh - 100px); height: calc(100vh - 100px);
} }
</style> </style>