feature:积分交易功能上线
This commit is contained in:
@@ -55,7 +55,6 @@ class PointTrade:
|
|||||||
# 解析 XML 数据
|
# 解析 XML 数据
|
||||||
root = ET.fromstring(xml)
|
root = ET.fromstring(xml)
|
||||||
|
|
||||||
|
|
||||||
# 查找 <atuserlist> 元素并提取其文本内容
|
# 查找 <atuserlist> 元素并提取其文本内容
|
||||||
atuserlist_element = root.find('.//atuserlist')
|
atuserlist_element = root.find('.//atuserlist')
|
||||||
atuserlist_content = (atuserlist_element.text if atuserlist_element is not None else '').strip() # 去除前后的所有空白字符
|
atuserlist_content = (atuserlist_element.text if atuserlist_element is not None else '').strip() # 去除前后的所有空白字符
|
||||||
@@ -136,14 +135,14 @@ class PointTrade:
|
|||||||
|
|
||||||
recipient_user_id, recipient_wx_id, recipient_wx_nick_name, recipient_current_points = recipient_result
|
recipient_user_id, recipient_wx_id, recipient_wx_nick_name, recipient_current_points = recipient_result
|
||||||
|
|
||||||
recipient_current_points =int(recipient_current_points)
|
recipient_current_points = int(recipient_current_points)
|
||||||
# 计算发信人和接收者的新积分
|
# 计算发信人和接收者的新积分
|
||||||
new_sender_points = sender_current_points - reward_points
|
new_sender_points = sender_current_points - reward_points
|
||||||
new_recipient_points = recipient_current_points + reward_points
|
new_recipient_points = recipient_current_points + reward_points
|
||||||
|
|
||||||
# 更新发信人和接收者的积分
|
# 更新发信人和接收者的积分
|
||||||
self._update_user_points(sender_user_id, new_sender_points)
|
self._update_user_points(sender_user_id, new_sender_points, group_id)
|
||||||
self._update_user_points(recipient_user_id, new_recipient_points)
|
self._update_user_points(recipient_user_id, new_recipient_points, group_id)
|
||||||
|
|
||||||
output = (
|
output = (
|
||||||
f"\n-----Bot-----\n"
|
f"\n-----Bot-----\n"
|
||||||
@@ -194,7 +193,7 @@ class PointTrade:
|
|||||||
""", (wx_nick_name, group_id))
|
""", (wx_nick_name, group_id))
|
||||||
return cursor.fetchone()
|
return cursor.fetchone()
|
||||||
|
|
||||||
def _update_user_points(self, user_id, new_points):
|
def _update_user_points(self, user_id, new_points, group_id):
|
||||||
"""
|
"""
|
||||||
更新用户积分
|
更新用户积分
|
||||||
:param user_id: 用户ID
|
:param user_id: 用户ID
|
||||||
@@ -205,5 +204,5 @@ class PointTrade:
|
|||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
UPDATE t_sign_record
|
UPDATE t_sign_record
|
||||||
SET points = %s, update_time = %s
|
SET points = %s, update_time = %s
|
||||||
WHERE id = %s
|
WHERE id = %s AND group_id = %s
|
||||||
""", (new_points, datetime.now(), user_id))
|
""", (new_points, datetime.now(), user_id, group_id))
|
||||||
|
|||||||
Reference in New Issue
Block a user