From 2a980203a5df8d8fd045865952af90735250fe84 Mon Sep 17 00:00:00 2001 From: ping <1017253325@qq.com> Date: Thu, 25 Sep 2025 14:21:00 +0800 Subject: [PATCH] update --- b/baiduc/baidu_confirm_refund_order.dspy | 30 ++++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/b/baiduc/baidu_confirm_refund_order.dspy b/b/baiduc/baidu_confirm_refund_order.dspy index d7fd76c..ca8a061 100644 --- a/b/baiduc/baidu_confirm_refund_order.dspy +++ b/b/baiduc/baidu_confirm_refund_order.dspy @@ -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': @@ -615,9 +615,6 @@ async def get_baidu_orderlist(ns={}): # 更新资源时间 资源id # if order_type == 'NEW': # await baidu_new_update_resouce(ns) - # with open('baiducloud_orderlist.log', 'a+') as f: - # now_time = time.strftime('%Y-%m-%d %H:%M:%S') - # f.write(now_time + str({'orderid': bz_ns.get('id'), 'originalprice': bz_ns.get('originalprice'), 'servicename': bz_ns.get('servicename'), 'amount': total_price})) return { 'status': True, 'orderid': bz_ns.get('id'), @@ -741,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_ = {} @@ -774,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')}) @@ -803,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 {