diff --git a/b/baiduc/baidu_confirm_refund_order.dspy b/b/baiduc/baidu_confirm_refund_order.dspy index 10cf3d7..ca8a061 100644 --- a/b/baiduc/baidu_confirm_refund_order.dspy +++ b/b/baiduc/baidu_confirm_refund_order.dspy @@ -110,7 +110,7 @@ async def affirmbz_order(ns={}): return {'status': True, 'msg': '支付成功'} except Exception as error: await sor.rollback() - raise error + return {'status': False, 'msg': str(error)} async def baidu_new_update_resouce(ns={}): @@ -235,10 +235,10 @@ async def get_baidu_orderlist(ns={}): serviceType = orders[0]['orderItems'] # 可能获取得到的是延迟订单 - if orders[0]['type'] == 'REFUND' and orders[0]['status'] != 'CREATED': - 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')}) - return res_refund + # if orders[0]['type'] == 'REFUND' and orders[0]['status'] != 'CREATED': + # 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')}) + # return res_refund # 避免重复退订 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) return { 'status': True, - 'orderid': bz_ns['id'], + 'orderid': bz_ns.get('id'), 'originalprice': bz_ns.get('originalprice'), 'servicename': bz_ns.get('servicename'), 'amount': total_price @@ -713,7 +713,7 @@ async def update_baidu_order_list(ns={}): async def baidu_confirm_refund_order(ns={}): # ns = { - # 'order_id': ["03ee8d08da79458b8f8d3157d3498330", "e711729606024080bf9613d975294616"], + # 'order_id': ["13f3518648054796abf7f3d00ed611bf"], # 'userid': 'KsKhCUPizQyGiw3L1WVRy' # } import asyncio @@ -738,6 +738,10 @@ async def baidu_confirm_refund_order(ns={}): refund_status_li = await sor.R('baidu_orders', {'orderid': order_id}) refundstatus = refund_status_li[0]['refundstatus'] 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: # data_ = {} @@ -771,7 +775,15 @@ async def baidu_confirm_refund_order(ns={}): 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 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'): db = DBPools() async with db.sqlorContext('kboss') as sor: - await sor.U('baidu_orders', {'id': refund_id, 'refundstatus': '2'}) - await sor.U('user_action', {'id': ns_record.get('id'), 'ordertype': 'REFUND', 'reason': '远程退款成功, 本地客户退款成功'}) + baidu_orders_status_update = """update baidu_orders set refundstatus='2' where id='%s';""" % refund_id + await sor.sqlExe(baidu_orders_status_update, {}) + await sor.U('user_action', {'id': ns_record.get('id'), 'ordertype': 'REFUND', 'reason': '远程退款成功, 本地客户退款成功'}) continue # return { diff --git a/crontab/crontab.txt b/crontab/crontab.txt index ffbef15..a004546 100644 --- a/crontab/crontab.txt +++ b/crontab/crontab.txt @@ -2,7 +2,7 @@ */20 * * * * curl https://dev.kaiyuancloud.cn/zj/zj_get_order.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 # 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 @@ -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_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 # 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 @@ -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_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 # 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 diff --git a/f/web-kboss/src/views/customer/unsubscribe/BaiduNetdisk.vue/index.vue b/f/web-kboss/src/views/customer/unsubscribe/BaiduNetdisk.vue/index.vue index 0e67d18..675b64d 100644 --- a/f/web-kboss/src/views/customer/unsubscribe/BaiduNetdisk.vue/index.vue +++ b/f/web-kboss/src/views/customer/unsubscribe/BaiduNetdisk.vue/index.vue @@ -1,11 +1,13 @@ @@ -22,7 +24,6 @@ export default { url: '', loading: true, userid: '', - } }, async created() { @@ -62,24 +63,12 @@ export default { console.log('接收到消息:', event); const data = event.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 if (data && data.refundInfo && Array.isArray(data.refundInfo.uuidList) && data.refundInfo.uuidList.length > 0) { const uuidListArray = data.refundInfo.uuidList; // 这是一个数组 - // 3. 提取订单ID (这里假设取第一个,或者根据需要处理整个数组) - // 如果只需要一个订单ID进行退订 - const orderId = uuidListArray; - // 如果需要处理多个订单ID,可以用逗号连接 - // const orderId = uuidListArray.join(','); - - console.log('提取到的订单ID:', orderId); + console.log('提取到的订单ID:', uuidListArray); // 4. 获取用户ID this.userid = sessionStorage.getItem('userId'); @@ -91,7 +80,7 @@ export default { // 5. 构造请求参数 const payload = { - order_id: orderId, + order_id: uuidListArray, userid: this.userid }; @@ -103,10 +92,10 @@ export default { .then((res) => { console.log("调用 reqBaiduJudgePrice 接口返回:", res); if (res.status) { // 假设 status 为 true 表示成功 - this.$message.success('退订成功'); - // 跳转页面 + this.$message.success('退订成功'); + // 修复页面跳转 - 使用 path 而不是 url this.$router.push({ - url: '/BaiduNetdisk', + path: '/BaiduNetdisk', }); } else { // 显示后端返回的错误信息 @@ -124,7 +113,6 @@ export default { }); } else { console.log('接收到的消息不包含有效的退款信息或 uuidList 为空'); - // 根据需要决定是否提示用户 } } } @@ -137,11 +125,19 @@ export default { height: 100%; } +.loading-container { + width: 100%; + height: 100%; + position: relative; +} + +.login-prompt { + text-align: center; + padding: 50px; +} + .baidu-style { width: 100%; height: calc(100vh - 100px); } - - - - + \ No newline at end of file