From b590463699d6ec76c24bdeb846a290a602724a1b Mon Sep 17 00:00:00 2001 From: xtaodada Date: Thu, 12 Jan 2023 23:28:54 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20pay=20log=20AttributeError?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/pay_log/log.py | 10 +++++----- plugins/genshin/pay_log.py | 8 ++++---- resources/genshin/pay_log/example.html | 8 ++++---- resources/genshin/pay_log/pay_log.html | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/pay_log/log.py b/modules/pay_log/log.py index 7c5392d1..6f6d61ef 100644 --- a/modules/pay_log/log.py +++ b/modules/pay_log/log.py @@ -178,7 +178,6 @@ class PayLog: month_data.clear() if not month_datas: raise PayLogNotFound - month_datas.sort(key=lambda k: k["amount"], reverse=True) return all_amount, month_datas async def get_analysis(self, user_id: int, client: Client): @@ -201,18 +200,19 @@ class PayLog: price_data_name = ["大月卡", "小月卡", "648", "328", "198", "98", "30", "6"] real_price = [68, 30, 648, 328, 198, 98, 30, 6] all_amount, month_datas = await PayLog.get_month_data(pay_log, price_data) + month_data = sorted(month_datas, key=lambda k: k["amount"], reverse=True) all_pay = sum((price_data[i]["count"] * real_price[i]) for i in range(len(price_data))) datas = [ {"value": f"¥{all_pay:.0f}", "name": "总消费"}, {"value": all_amount, "name": "总结晶"}, - {"value": f"{month_datas[0]['month']}", "name": "消费最多"}, + {"value": f"{month_data[0]['month']}", "name": "消费最多"}, { - "value": f"¥{month_datas[0]['amount'] / 10:.0f}", - "name": f"{month_datas[0]['month']}消费", + "value": f"¥{month_data[0]['amount'] / 10:.0f}", + "name": f"{month_data[0]['month']}消费", }, *[ { - "value": price_data[i]["count"], + "value": price_data[i]["count"] if i != 0 else "*", "name": f"{price_data_name[i]}", } for i in range(len(price_data)) diff --git a/plugins/genshin/pay_log.py b/plugins/genshin/pay_log.py index aa2aa74d..26a95e7a 100644 --- a/plugins/genshin/pay_log.py +++ b/plugins/genshin/pay_log.py @@ -101,7 +101,7 @@ class PayLogPlugin(Plugin.Conversation, BasePlugin.Conversation): await message.reply_text( "开始导入充值历史记录:请通过 https://paimon.moe/wish/import 获取抽卡记录链接后发送给我" "(非 paimon.moe 导出的文件数据)\n\n" - "> 在绑定 Cookie 时添加 stoken 可能有特殊效果哦(仅限国服)\n" + "> 在绑定 Cookie 时添加 stoken 可能有特殊效果哦(国服)\n" "注意:导入的数据将会与旧数据进行合并。", parse_mode="html", ) @@ -122,9 +122,9 @@ class PayLogPlugin(Plugin.Conversation, BasePlugin.Conversation): async def import_data_from_message(self, update: Update, _: CallbackContext) -> int: message = update.effective_message user = update.effective_user - if message.document: - await self.import_from_file(user, message) - return ConversationHandler.END + if not message.text: + await message.reply_text("输入错误,请重新输入") + return INPUT_URL authkey = from_url_get_authkey(message.text) reply = await message.reply_text("小派蒙正在从服务器获取数据,请稍后") await message.reply_chat_action(ChatAction.TYPING) diff --git a/resources/genshin/pay_log/example.html b/resources/genshin/pay_log/example.html index 091986b9..b570dac1 100644 --- a/resources/genshin/pay_log/example.html +++ b/resources/genshin/pay_log/example.html @@ -44,7 +44,7 @@
-
1
+
*
大月卡
@@ -97,7 +97,7 @@ const barData = JSON.parse(`[{"month": "1月", "amount": 1000}]`); const myChart1 = echarts.init(document.querySelector('#chartContainer'), null, { renderer: 'svg' }); const xData = barData.map(v => v.month) - const yData = barData.map(v => v.amount / 10) + const yData = barData.map(v => v.amount) // 指定图表的配置项和数据 const option = { animation: false, @@ -109,14 +109,14 @@ x:'left', y:'top', show: true, - data: [{ name: '金额' }] + data: [{ name: '结晶' }] }, yAxis: { type: 'value' }, series: [ { - name:'金额', + name:'结晶', data: yData, type: 'bar', itemStyle: { diff --git a/resources/genshin/pay_log/pay_log.html b/resources/genshin/pay_log/pay_log.html index f2296aa7..59c38d92 100644 --- a/resources/genshin/pay_log/pay_log.html +++ b/resources/genshin/pay_log/pay_log.html @@ -67,7 +67,7 @@ const barData = {{ bar_data | tojson }}; const myChart1 = echarts.init(document.querySelector('#chartContainer'), null, {renderer: 'svg'}); const xData = barData.map(v => v.month) - const yData = barData.map(v => v.amount / 10) + const yData = barData.map(v => v.amount) const option = { animation: false, xAxis: { @@ -78,14 +78,14 @@ x:'left', y:'top', show: true, - data: [{ name: '金额' }] + data: [{ name: '结晶' }] }, yAxis: { type: 'value' }, series: [ { - name:'金额', + name:'结晶', data: yData, type: 'bar', itemStyle: {