Commit 82395212 authored by xianyang's avatar xianyang

优化转账

parent 4b479e33
......@@ -248,7 +248,7 @@ def query_token(db, h_list):
return user_info
def transfer_trigger_task(uuid, user_id, balance, type, amount_type=1, remark='用户转账', money_data=[],
def transfer_trigger_task(uuid, user_id, balance, type, amount_type, remark='用户转账', money_data=[],
isUser=1, dst_uuid=False, referNum=''):
"""转账验证"""
......@@ -269,8 +269,8 @@ def transfer_trigger_task(uuid, user_id, balance, type, amount_type=1, remark='
if res['status'] == 0:
errmsg = json.dumps(res['data'])
status = 3
add_sql = f"insert into all_record_table(user_id, type, status, reference_number, remark, money, is_add, money_data,create_time) " \
f"values({user_id}, '{type}', {status},'{get_order()}','{remark}', {balance * 10 if amount_type == 1 else balance * 100},1,'{json.dumps(money_data)}',{get_now_timestamp()});"
add_sql = f"insert into all_record_table(user_id, type, status, reference_number, remark, money, is_add, money_data,create_time,amount_type) " \
f"values({user_id}, '{type}', {status},'{get_order()}','{remark}', {balance * 10 if amount_type == 1 else balance * 100},1,'{json.dumps(money_data)}',{get_now_timestamp()},{amount_type});"
LinkMysql(env.DB_3YV2).perform_mysql(add_sql)
return res
......@@ -278,10 +278,12 @@ def transfer_trigger_task(uuid, user_id, balance, type, amount_type=1, remark='
def transfer_money(db: Session, param, h_list):
"""转账"""
user_id = 0
amount_type_dict = {'withdrawable': 2, 'consumable': 1}
if param.type == 0: # 系统转系统
out_sql = f"select name from fi_account where uuid='{param.dst_id}' limit 0,1"
out = LinkMysql(env.DB_3YV2).query_mysql(out_sql)
dst_name = out[0]['name']
amount_type = 1
if param.type == 1: # 系统转个人/公会
out_sql = f"select name from fi_account where uuid='{param.dst_id}' limit 0,1"
out = LinkMysql(env.DB_3YV2).query_mysql(out_sql)
......@@ -291,6 +293,7 @@ def transfer_money(db: Session, param, h_list):
if income:
user_id = income[0]['user_id']
dst_name = out[0]['name']
amount_type = amount_type_dict.get(param.transfer_type) if amount_type_dict.get(param.transfer_type) else 1
if param.type == 2: # 个人/公会转系统
out_sql = f"select nick_name from v2_user where uuid='{param.dst_id}' limit 0,1"
out = LinkMysql(env.DB_3YV2).query_mysql(out_sql)
......@@ -300,10 +303,11 @@ def transfer_money(db: Session, param, h_list):
out_guild_sql = f"select guild_name from guild where uuid='{param.transfer_id}'"
out_guild = LinkMysql(env.DB_3YV2).query_mysql(out_guild_sql)
dst_name = out_guild[0]['guild_name'] if out_guild else ""
amount_type = amount_type_dict.get(param.transfer_type) if amount_type_dict.get(param.transfer_type) else 1
try:
# 转账
is_success = transfer_trigger_task(param.dst_id, 0, param.amount, 'platformRecharge', 1,
is_success = transfer_trigger_task(param.dst_id, 0, param.amount, 'platformRecharge', amount_type,
f"{param.dst_id}给{param.transfer_id}转账", [], 0, param.transfer_id)
if not is_success['status']:
return is_success
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment