import time标签:status,易宝,text,22%,receipt,重推,分账,data,order From: https://www.cnblogs.com/xieweiwen/p/18121251
from USSyunwei.bin import *
from USSapi.Apiserver import *
from USSapi.bascidata import *
sql=f"""select order_no,sfdj_receipt_status,sfdj_failure_reason,site_receipt_status,
site_failure_reason,site_id,receipt_status,failure_reason,engineer_id
from tcl_finance_reconciliation
where
(receipt_status in (0) or sfdj_receipt_status in (0) or site_receipt_status in (0) )
and order_finish_date<'{datetime.datetime.now().date()} 00:00:00' and order_finish_date !='0001-01-01 00:00:00' and
site_name not in ("测试服务商勿理会") and
brand_name not in ("金鱼","熊猫","风行","3M") """
# print(sql)
# 生产环境数据库
#如果生产环境查出来没有数据,说明没有待分账的数据
statu,text=DB_sql(sql,database="uss_payunit",example="生产_营销_十分到家_USS2.0_basicdata_MYSQL_从(10.68.70.37)")
if "空值" not in str(text):
for i in text:
statu,datalist=Api_server("统收统付重推列表查询",order_no=i[0])
if statu :
pass
else:
print(i[0])
fzstatu,fztext=Api_server("重新调起易宝分账",orderNoList= [f'{i[0]}'],Goal_hierarchy="")
print(fztext)
else:
print(f"截止至{datetime.datetime.now().date()}之前没有待完工的数据")
#查询前一天单据状态是已发起清分,状态没有改的数据
sql=f"select order_no,sfdj_receipt_status,sfdj_failure_reason,site_receipt_status,site_failure_reason,site_id," \
"receipt_status,failure_reason,engineer_id " \
"from tcl_finance_reconciliation " \
f"where order_finish_date between '2023-01-01 00:00:00' and '{datetime.datetime.now().date()} 16:40:00' and " \
"(receipt_status in (6) or sfdj_receipt_status in (6) or site_receipt_status in (6) )" \
"and site_name not in ('测试服务商勿理会') and " \
"brand_name not in ('金鱼','熊猫','风行','3M') order by order_finish_date asc"
statu, text = DB_sql(sql, database="uss_payunit",
example="生产_营销_十分到家_USS2.0_basicdata_MYSQL_从(10.68.70.37)")
url="https://gateway.shifendaojia.com/uss-payment-unite/v1/tcl-finance-reconciliations/updateStatusByMerchantNo"
header = {
"Authorization": token,
"Content-Type": "application/json;charset=UTF-8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
"Cookie": "sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%22ex_yong.zeng%22%2C%22first_id%22%3A%2218cce911e5d1c8d-020ee3b22e7e8f6-4c657b58-1327104-18cce911e5e1dd2%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%7D%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMThjY2U5MTFlNWQxYzhkLTAyMGVlM2IyMmU3ZThmNi00YzY1N2I1OC0xMzI3MTA0LTE4Y2NlOTExZTVlMWRkMiIsIiRpZGVudGl0eV9sb2dpbl9pZCI6ImV4X3lvbmcuemVuZyJ9%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%24identity_login_id%22%2C%22value%22%3A%22ex_yong.zeng%22%7D%2C%22%24device_id%22%3A%2218cce911e5d1c8d-020ee3b22e7e8f6-4c657b58-1327104-18cce911e5e1dd2%22%7D"
}
num=1
data = {"orderNoList": []}
order_num=1
if "空值" not in str(text):
print(f"一共查到{len(text)}条数据")
if len(text)>=10:
for order in text:
if order_num<10:
data["orderNoList"].append(order[0])
order_num+=1
else:
try:
re = requests.post(data=json.dumps(data), url=url, headers=header)
except:
sleep(2)
re = requests.post(data=json.dumps(data), url=url, headers=header)
if "SUCCESS" in re.text:
print(f"{num} {order[0]}状态更新成功")
else:
print(f"{num} {order[0]}更新失败---{re.text} {data}")
order_num=1
data = {"orderNoList": []}
num+=1
else:
for order in text:
if order_num != len(text):
data["orderNoList"].append(order[0])
order_num += 1
else:
data["orderNoList"].append(order[0])
try:
re = requests.post(data=json.dumps(data), url=url, headers=header)
except:
sleep(2)
re = requests.post(data=json.dumps(data), url=url, headers=header)
if "SUCCESS" in re.text:
print(f"{len(text)} {order[0]}状态更新成功")
else:
print(f"{len(text)} {order[0]}更新失败---{re.text} {data}")
# order_num = 1
# data = {"orderNoList": []}
num += 1
else:
print("没有单据状态是已发起清分,但是实际状态是已到账的数据")
#查询”费用金额集合不能为空“的数据
sql = "select order_no,sfdj_receipt_status,sfdj_failure_reason,site_receipt_status,site_failure_reason,site_id," \
"receipt_status,failure_reason,engineer_id " \
"from tcl_finance_reconciliation " \
"where (receipt_status in (5) or sfdj_receipt_status in (5) or site_receipt_status in (5) ) " \
"and site_name not in ('测试服务商勿理会') and " \
"brand_name not in ('金鱼','熊猫','风行','3M')"
# 生产环境数据库
statu, text = DB_sql(sql, database="uss_payunit",
example="生产_营销_十分到家_USS2.0_basicdata_MYSQL_从(10.68.70.37)")
starttime = time.time()
if "金额" in str(text):
for u in text:
if "金额" in str(u):
print(u)
else:
print(f"截止至{datetime.datetime.now().date()}之前没有 ‘费用金额集合不能为空’ 的数据")