优化积分流水写入为昵称优先并覆盖打劫/保释场景
This commit is contained in:
@@ -209,10 +209,21 @@ class PointTradePlugin(MessagePluginInterface):
|
||||
group_id = roomid
|
||||
|
||||
try:
|
||||
# 先解析双方昵称,再执行转账:
|
||||
# 这样流水入库时可以直接使用昵称,避免写入 wxid。
|
||||
from_user_info = self._get_user_record(trader_wxid, group_id)
|
||||
to_user_info = self._get_user_record(target_wxid, group_id)
|
||||
|
||||
from_user_name = from_user_info.get('wx_nick_name', trader_wxid) if from_user_info else trader_wxid
|
||||
to_user_name = to_user_info.get('wx_nick_name', target_wxid) if to_user_info else target_wxid
|
||||
|
||||
# 使用积分系统进行转账
|
||||
success, result = self.points_db.transfer_points(
|
||||
trader_wxid, target_wxid, group_id,
|
||||
reward_points, f"积分转账命令执行"
|
||||
reward_points,
|
||||
"积分转账命令执行",
|
||||
from_user_name=from_user_name,
|
||||
to_user_name=to_user_name,
|
||||
)
|
||||
|
||||
if not success:
|
||||
@@ -236,13 +247,6 @@ class PointTradePlugin(MessagePluginInterface):
|
||||
from_user = result.get("from_user", {})
|
||||
to_user = result.get("to_user", {})
|
||||
|
||||
# 获取用户昵称
|
||||
from_user_info = self._get_user_record(trader_wxid, group_id)
|
||||
to_user_info = self._get_user_record(target_wxid, group_id)
|
||||
|
||||
from_user_name = from_user_info.get('wx_nick_name', trader_wxid) if from_user_info else trader_wxid
|
||||
to_user_name = to_user_info.get('wx_nick_name', target_wxid) if to_user_info else target_wxid
|
||||
|
||||
output = (
|
||||
f"✅积分转账成功!\n"
|
||||
f"👤{from_user_name} 转给 👤{to_user_name} {reward_points} 积分\n"
|
||||
@@ -644,13 +648,19 @@ class PointTradePlugin(MessagePluginInterface):
|
||||
# 执行积分转移(从目标到打劫者)
|
||||
success, result = self.points_db.transfer_points(
|
||||
target_wxid, robber_wxid, roomid,
|
||||
actual_rob_amount, f"被{robber_name}打劫"
|
||||
actual_rob_amount,
|
||||
f"被{robber_name}打劫",
|
||||
from_user_name=target_name,
|
||||
to_user_name=robber_name,
|
||||
)
|
||||
|
||||
# 执行抽水(从目标到SYSTEM)
|
||||
tax_success, tax_result = self.points_db.transfer_points(
|
||||
target_wxid, "SYSTEM", roomid,
|
||||
tax_amount, f"打劫抽水"
|
||||
tax_amount,
|
||||
"打劫抽水",
|
||||
from_user_name=target_name,
|
||||
to_user_name="系统",
|
||||
)
|
||||
|
||||
if success and tax_success:
|
||||
@@ -685,7 +695,10 @@ class PointTradePlugin(MessagePluginInterface):
|
||||
# 记录积分变动
|
||||
success, result = self.points_db.transfer_points(
|
||||
robber_wxid, target_wxid, roomid,
|
||||
penalty_amount, f"打劫{target_name}失败的惩罚"
|
||||
penalty_amount,
|
||||
f"打劫{target_name}失败的惩罚",
|
||||
from_user_name=robber_name,
|
||||
to_user_name=target_name,
|
||||
)
|
||||
|
||||
if success:
|
||||
@@ -768,7 +781,13 @@ class PointTradePlugin(MessagePluginInterface):
|
||||
bailout_name = bailout_info.get('wx_nick_name', bailout_wxid) if bailout_info else bailout_wxid
|
||||
|
||||
# 执行保释
|
||||
success, message = self.points_db.bailout_user(prisoner_wxid, bailout_wxid, roomid)
|
||||
success, message = self.points_db.bailout_user(
|
||||
prisoner_wxid,
|
||||
bailout_wxid,
|
||||
roomid,
|
||||
prisoner_name=prisoner_name,
|
||||
bailout_user_name=bailout_name,
|
||||
)
|
||||
|
||||
if success:
|
||||
output = (
|
||||
|
||||
Reference in New Issue
Block a user