Commit 8cae1eeb authored by xupeng's avatar xupeng

列表代码提交

parent d5cb7f79
......@@ -184,77 +184,12 @@ class WithdrawStatement(object):
data.append(query)
data.append(query1)
return data
# def query_user_all_data(self, db):
# msg_count = db.query(func.count(UserWC.id)).scalar()
# num = math.ceil(msg_count / 10)
# # 创建线程
# ths = []
# for x in range(num):
# ths.append(threading.Thread(target=self.thread_to_data, args=[db, x]))
# for y in range(num):
# ths[y].start()
# for z in range(num):
# ths[z].join()
# return self.derive_user_list
#
# # def get_user_withdraw_cash(self, db: Session, param):
# # """用户提现"""
# # is_filters = []
# # if param.name:
# # is_filters.append(UserWC.nick_name.like(f'%{param.name}%'))
# # if param.status or param.status == 0:
# # is_filters.append(UserWC.status == param.status)
# # if param.start_time:
# # is_filters.append(UserWC.current >= param.start_time)
# # if param.end_time:
# # is_filters.append(UserWC.current <= param.end_time)
# # # 判断有无条件
# # try:
# # if len(is_filters) > 0:
# # get_user_orm_sql = db.query(UserWC).filter(and_(*is_filters))
# # condition_data = db.execute(get_user_orm_sql).fetchall()
# # user_info = [i[0].to_dict() for i in condition_data]
# # else:
# # user_info = self.query_user_all_data(db)
# # except Exception as e:
# # print(e)
# # return [], 0, 0, 0
# # # 判断是列表还是导出接口
# # user_info.reverse()
# # if user_info:
# # total = len(user_info)
# # df = pd.DataFrame(user_info)
# # count = df['money'].apply(lambda x: x).sum()
# # final_count = df['final_money'].apply(lambda x: float(x)).sum()
# # return user_info[(int(param.page) - 1) * param.size:param.size * param.page], total, count, final_count
# # return [], 0, 0, 0
def get_user_withdraw_cash(self,page, size, name, status,start_time,end_time,month_type):
query = []
if name:
query.append(f" nickname like '%{name}%' ")
if status:
query.append(f"status={status} ")
# if query==[]:
# choice = 1
# count_sql = f'SELECT count(*) FROM `tixian_order` where choice=1 and `status`=3'
# count = self.linkmysql.query_mysql(count_sql)[0].get("count(*)") # 总条数
# sql = f'SELECT t.usernumber as user_number,t.status,t.id as bank_code,t.nickname as nick_name,t.truename as true_name ,t.money,t.current,t.final_money,t.idcard as id_card,t.account,t.platformServiceFee as platform_service_fee,t.thirdServiceFee as third_service_fee FROM `tixian_order` as t where choice={choice} ORDER BY id desc limit {(int(page) - 1) * size},{size}'
# statement_list = self.linkmysql.query_mysql(sql) # 提现总数
# money_sql = f'SELECT sum(money) FROM `tixian_order` where choice=1'
# moeny_data = self.linkmysql.query_mysql(money_sql)[0].get("sum(money)") # 提现金额
# final_data = f'SELECT sum(final_money) FROM `tixian_order` where choice=1'
# final_money = self.linkmysql.query_mysql(final_data)[0].get("sum(final_money)") # 实得金额
# else:
# choice=1
# query = ' and '.join(query)
# count_sql = f'SELECT count(*) FROM `tixian_order` where choice=1 and {query}'
# count = self.linkmysql.query_mysql(count_sql)[0].get("count(*)") #总条数
# sql = f'SELECT t.usernumber as user_number,t.status,t.id as bank_code,t.nickname as nick_name,t.truename as true_name ,t.money,t.current,t.final_money,t.idcard as id_card,t.account,t.platformServiceFee as platform_service_fee,t.thirdServiceFee as third_service_fee FROM `tixian_order` as t where choice={choice} and {query} ORDER BY id desc limit {(int(page) - 1) * size},{size}'
# statement_list = self.linkmysql.query_mysql(sql) #提现总数
# money_sql = f'SELECT sum(money) FROM `tixian_order` where choice=1 and {query}'
# moeny_data = self.linkmysql.query_mysql(money_sql)[0].get("sum(money)") #提现金额
# final_data=f'SELECT sum(final_money) FROM `tixian_order` where choice=1 and {query}'
# final_money=self.linkmysql.query_mysql(final_data)[0].get("sum(final_money)") # 实得金额
query.append(f"reference_type='userWithdrawal' ")
if month_type==1:
if start_time:
......@@ -274,7 +209,6 @@ class WithdrawStatement(object):
def dispose_user(self,month_type,query,page,size,now_month):
if month_type == 1:
count_sql = f"SELECT count(*) FROM assets_log_{now_month} where {query}"
print(count_sql)
count = self.linkmysql.query_mysql(count_sql)[0].get("count(*)")
sql = f'SELECT uuid,a.reference_type,a.reference_number,FROM_UNIXTIME(a.create_time,"%Y-%c-%d %h:%i:%s") as payment_time,a.amount_type FROM assets_log_{now_month} as a where {query} ORDER BY id desc limit {(int(page) - 1) * size},{size}'
once_res = self.linkmysql.query_mysql(sql)
......@@ -292,28 +226,7 @@ class WithdrawStatement(object):
moeny_data = self.linkmysql.query_mysql(money_sql)[0].get("sum(a.b)") if \
self.linkmysql.query_mysql(money_sql)[0].get("sum(a.b)") != None else 0
return count, once_res,moeny_data
# def dispose_guild_to_data(self, db, num):
# user_list = []
# locka.acquire()
# once_res = db.query(GuildWC).filter().offset(num * 10).limit(10).all()
# locka.release()
# for i in once_res:
# info_dict = i.to_dict()
# user_list.append(info_dict)
# self.derive_user_list += user_list
#
# def query_guild_all_data(self, db):
# msg_count = db.query(func.count(UserWC.id)).scalar()
# num = math.ceil(msg_count / 10)
# # 创建线程
# ths = []
# for x in range(num):
# ths.append(threading.Thread(target=self.dispose_guild_to_data, args=[db, x]))
# for y in range(num):
# ths[y].start()
# for z in range(num):
# ths[z].join()
# return self.derive_user_list
def get_guild_withdraw_cash(self,page, size, name, status,start_time,end_time,month_type):
"""公会提现"""
......@@ -337,39 +250,6 @@ class WithdrawStatement(object):
count, once_res, moeny_data = self.dispose_user(month_type, query_data, page, size, now_month)
return count, once_res, moeny_data
# def get_guild_withdraw_cash(self,page,size,guild_id,status,start_time,end_time):
# query = []
# if start_time:
# query.append(f" create_time >= {time_str_to_timestamp(start_time + ' 00:00:00')} ")
# if end_time:
# query.append(f" update_time < {time_str_to_timestamp(end_time + ' 23:59:59')} ")
# if guild_id:
# query.append(f"guild_id={guild_id} ")
# if status:
# query.append(f"status={status} ")
# if query==[]:
# count_sql = f'SELECT count(*) FROM `guild_ti_xian`'
# count = self.linkmysql.query_mysql(count_sql)[0].get("count(*)") # 总条数
# sql = f'SELECT t.guild_id,t.parent_id as merchants_id,g.guild_name,t.money,t.account,t.`status`,t.finalMoney as final_money,t.update_time,t.taxRate as platform_service_fee,t.thirdServiceFee as third_service_fee FROM `guild_ti_xian` as t inner join guild as g on g.id=t.guild_id ORDER BY t.id desc limit {(int(page) - 1) * size},{size}'
# statement_list = self.linkmysql.query_mysql(sql) # 提现总数
# money_sql = f'SELECT sum(money) FROM `guild_ti_xian`'
# moeny_data = self.linkmysql.query_mysql(money_sql)[0].get("sum(money)") # 提现金额
# final_data = f'SELECT sum(finalMoney) FROM `guild_ti_xian`'
# final_money = self.linkmysql.query_mysql(final_data)[0].get("sum(finalMoney)") # 实得金额
# else:
# query1 = ' and '.join(query)
# query_time=' and '.join(query).replace('create_time','t.create_time').replace('update_time','t.update_time').replace('guild_id','t.guild_id').replace('status','t.status')
# count_sql = f'SELECT count(*) FROM `guild_ti_xian` where {query1}'
# count = self.linkmysql.query_mysql(count_sql)[0].get("count(*)") # 总条数
# sql = f'SELECT t.guild_id,t.parent_id as merchants_id,g.guild_name,t.money,t.account,t.`status`,t.finalMoney as final_money,t.update_time,t.taxRate as platform_service_fee,t.thirdServiceFee as third_service_fee FROM `guild_ti_xian` as t inner join guild as g on g.id=t.guild_id where {query_time} ORDER BY t.id desc limit {(int(page) - 1) * size},{size}'
# statement_list = self.linkmysql.query_mysql(sql) # 提现总数
# money_sql = f'SELECT sum(money) FROM `guild_ti_xian` where {query1}'
# moeny_data = self.linkmysql.query_mysql(money_sql)[0].get("sum(money)") if self.linkmysql.query_mysql(money_sql)[0].get("sum(money)")!=None else 0 # 提现金额
# final_data = f'SELECT sum(finalMoney) FROM `guild_ti_xian` where {query1}'
# final_money = self.linkmysql.query_mysql(final_data)[0].get("sum(finalMoney)") # 实得金额
# return statement_list, count, moeny_data, final_money
class FinanceFix(object):
......
......@@ -21,14 +21,14 @@ router = APIRouter()
@router.get("/recharge/list")
def statement_recharge_list(page: Optional[int] = 0, size: Optional[int] = 10,order_number: Optional[str] = "",user_id: Optional[int] = "",sid: Optional[str]="",start_time:Optional[str]='',end_time:Optional[str]="",types:Optional[str]="",reference_type:Optional[str]="",month_type:Optional[int]=""):
def statement_recharge_list(page: Optional[int] = 0, size: Optional[int] = 10,order_number: Optional[str] = "",user_id: Optional[int] = "",sid: Optional[str]="",start_time:Optional[str]='',end_time:Optional[str]="",types:Optional[str]="",reference_type:Optional[str]="",month_type:Optional[int]="",token=Depends(login_required)):
"""充值报表列表"""
total,statement_list,money= RechargeStatement().query_data(page,size,order_number,user_id,sid,start_time,end_time,types,reference_type,month_type)
return HttpResultResponse(total=total,count=float(money),data=statement_list)
@router.post("/derive/excel")
def statement_derive_excel(data: schemas.StatementList, request: Request, db: Session = Depends(get_db)):
def statement_derive_excel(data: schemas.StatementList, request: Request, db: Session = Depends(get_db),token=Depends(login_required)):
"""充值报表导出 需要修改"""
header_list = request.get("headers")
statement_list = RechargeStatement().get_statements(data)
......@@ -36,16 +36,16 @@ def statement_derive_excel(data: schemas.StatementList, request: Request, db: Se
@router.get("/userWithdrawal/list")
def user_withdrawal_list(page: Optional[int] = 0, size: Optional[int] = 10,name:Optional[str]='',status:Optional[int]='',start_time:Optional[str]='',end_time:Optional[str]="",month_type:Optional[int]=""):
def user_withdrawal_list(page: Optional[int] = 0, size: Optional[int] = 10,name:Optional[str]='',status:Optional[int]='',start_time:Optional[str]='',end_time:Optional[str]="",month_type:Optional[int]="",token=Depends(login_required)):
"""用户提现列表"""
total,statement_list,money = WithdrawStatement().get_user_withdraw_cash(page,size,name,status,start_time,end_time,month_type)
total,statement_list,money = WithdrawStatement(). get_user_withdraw_cash(page,size,name,status,start_time,end_time,month_type)
return HttpResultResponse(total=total, count=float(money), data=statement_list)
@router.get("/guildWithdrawal/list")
def guild_withdrawal_list(page: Optional[int] = 0, size: Optional[int] = 10,guild_id:Optional[int]='',status:Optional[int]='',start_time:Optional[str]='',end_time:Optional[str]="", month_type:Optional[int]="",token=Depends(login_required)):
"""公会提现列表 暂无"""
total,statement_list,money= WithdrawStatement().get_guild_withdraw_cash(page,size,guild_id,status,start_time,end_time,month_type)
total,statement_list,money= WithdrawStatement(). get_guild_withdraw_cash(page,size,guild_id,status,start_time,end_time,month_type)
return HttpResultResponse(total=total, count=float(money), data=statement_list)
......
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