Commit e88a7710 authored by xianyang's avatar xianyang

盲盒查询列表

parent ea669696
...@@ -586,34 +586,30 @@ class BlindBoxRecharge(object): ...@@ -586,34 +586,30 @@ class BlindBoxRecharge(object):
if self.reference_number: if self.reference_number:
cond_list.append(f"reference_number='{self.reference_number}'") cond_list.append(f"reference_number='{self.reference_number}'")
if self.uuid: if self.uuid:
cond_list.append(f"dst_uuid='{self.uuid}'") cond_list.append(f"uuid='{self.uuid}'")
return cond_list return cond_list
@staticmethod @staticmethod
def time_month(y_month): def time_month(y_month, num):
now_time = datetime.now().strftime('%Y%m') now_time = datetime.now().strftime('%Y%m')
if num == 2:
if int(y_month) > int(now_time): if int(y_month) > int(now_time):
return now_time return now_time
if num == 1:
if int(y_month) < int(now_time):
return now_time
return y_month return y_month
@staticmethod @staticmethod
def _recharge_data(query_data): def _recharge_data(query_data):
if not query_data: if not query_data:
return [] return []
for x in query_data: bk = pd.DataFrame(query_data)
if x['reference_info']: bk['nick_name'] = "商城礼物盲盒"
reference_info = json.loads(x['reference_info']) bk['status'] = 1
x['sid'] = reference_info.get('business_number') pd_to_dict = bk.to_dict(orient='records')
x['paychannel'] = reference_info.get('channel') Logger().logger.info(f"拼接的数据:{pd_to_dict[0]}")
else: return pd_to_dict
x['paychannel'] = ''
x['sid'] = ''
x['income_money'] = x['amount']
x['payment_time'] = x['create_time']
x['nick_name'] = "商城礼物盲盒"
x['status'] = 1
Logger().logger.info(f"拼接的数据:{query_data[0]}")
return query_data
def box_recharge(self, is_export=None): def box_recharge(self, is_export=None):
conditions = self._conditions() conditions = self._conditions()
...@@ -623,21 +619,21 @@ class BlindBoxRecharge(object): ...@@ -623,21 +619,21 @@ class BlindBoxRecharge(object):
self.size = 999999999 self.size = 999999999
# 时间处理,看查询一个月还是两个月 # 时间处理,看查询一个月还是两个月
if start_month == end_month: if start_month == end_month:
year_month = self.time_month(start_month) year_month = self.time_month(start_month, 1)
time_list = [year_month] time_list = [year_month]
else: else:
eny_month = self.time_month(end_month) eny_month = self.time_month(end_month, 2)
time_list = [start_month, eny_month] time_list = [start_month, eny_month]
time_list = list(set(time_list)) time_list = list(set(time_list))
Logger().logger.info(f"开始查询数据!!!!日期:{time_list}") Logger().logger.info(f"开始查询数据!!!!日期:{time_list}, 条件:{conditions}")
if len(time_list) == 1: if len(time_list) == 1:
data_sql = f"SELECT dst_uuid as uuid,amount,FROM_UNIXTIME(create_time) as create_time,reference_type,reference_number,reference_info FROM order_log_{time_list[0]} where {' and '.join(conditions)} ORDER BY create_time desc limit {(int(self.page) - 1) * self.size},{self.size}" data_sql = f"SELECT uuid,amount,FROM_UNIXTIME(create_time) as payment_time,reference_type,reference_number,channel,business_number FROM recharge_log_{time_list[0]} where {' and '.join(conditions)} ORDER BY payment_time desc limit {(int(self.page) - 1) * self.size},{self.size}"
money_sql = f"SELECT sum(amount) as m_sum FROM order_log_{time_list[0]} where {' and '.join(conditions)}" money_sql = f"SELECT sum(amount) as m_sum FROM recharge_log_{time_list[0]} where {' and '.join(conditions)}"
count_sql = f"SELECT count(id) as c_sum FROM order_log_{time_list[0]} where {' and '.join(conditions)}" count_sql = f"SELECT count(id) as c_sum FROM recharge_log_{time_list[0]} where {' and '.join(conditions)}"
else: else:
data_sql = f"SELECT dst_uuid as uuid,amount,FROM_UNIXTIME(create_time) as create_time,reference_type,reference_number,reference_info FROM order_log_{time_list[0]} where {' and '.join(conditions)} UNION ALL SELECT dst_uuid as uuid,amount,FROM_UNIXTIME(create_time) as create_time,reference_type,reference_number,reference_info FROM order_log_{time_list[1]} where {' and '.join(conditions)} ORDER BY create_time desc limit {(self.page - 1) * self.size},{self.size}" data_sql = f"SELECT uuid,amount,FROM_UNIXTIME(create_time) as payment_time,reference_type,reference_number,channel,business_number FROM recharge_log_{time_list[0]} where {' and '.join(conditions)} UNION ALL SELECT uuid,amount,FROM_UNIXTIME(create_time) as payment_time,reference_type,reference_number,channel,business_number FROM recharge_log_{time_list[1]} where {' and '.join(conditions)} ORDER BY payment_time desc limit {(self.page - 1) * self.size},{self.size}"
money_sql = f"SELECT sum(a.b) as m_sum FROM ("f"SELECT sum(amount) as b FROM order_log_{int(time_list[0])} where {' and '.join(conditions)} UNION ALL SELECT sum(amount)FROM order_log_{int(time_list[1])} where {' and '.join(conditions)}) AS a " money_sql = f"SELECT sum(a.b) as m_sum FROM ("f"SELECT sum(amount) as b FROM recharge_log_{int(time_list[0])} where {' and '.join(conditions)} UNION ALL SELECT sum(amount)FROM recharge_log_{int(time_list[1])} where {' and '.join(conditions)}) AS a "
count_sql = "SELECT sum(a.b) as c_sum FROM ("f"SELECT count(id) as b FROM order_log_{int(time_list[0])} where {' and '.join(conditions)} UNION ALL SELECT count(id) FROM order_log_{int(time_list[1])} where {' and '.join(conditions)}) AS a " count_sql = "SELECT sum(a.b) as c_sum FROM ("f"SELECT count(id) as b FROM recharge_log_{int(time_list[0])} where {' and '.join(conditions)} UNION ALL SELECT count(id) FROM recharge_log_{int(time_list[1])} where {' and '.join(conditions)}) AS a "
with ThreadPoolExecutor(max_workers=3) as pool: with ThreadPoolExecutor(max_workers=3) as pool:
future1 = pool.submit(LinkMysql(env.DB_HISTORY).query_mysql, data_sql) future1 = pool.submit(LinkMysql(env.DB_HISTORY).query_mysql, data_sql)
future2 = pool.submit(LinkMysql(env.DB_HISTORY).query_mysql, money_sql) future2 = pool.submit(LinkMysql(env.DB_HISTORY).query_mysql, money_sql)
......
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