You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

210 lines
13 KiB

import pymysql
from pymysql.cursors import DictCursor
import datetime
db_config_raw = {
'host': '192.168.55.97',
'database': 'cine',
'user': 'dbadmin',
'password': 'fXMSR37mLP7w88ji'
}
db_config_test = {
'host': '192.168.55.97',
'database': 'quan_list',
'user': 'dbadmin',
'password': 'fXMSR37mLP7w88ji'
}
data_dict = {
'积分抵现': '积分',
'商户补贴': '商户补贴',
'会员卡': '储值卡',
'影票计次卡': '影票计次卡',
'微信': '微信',
'支付宝': '支付宝',
'网站第三方合作': '第三方支付',
'第三方支付': '第三方支付',
'电子码': '电子码',
}
class DB:
def __init__(self):
self.db_conn_raw = pymysql.Connect(**db_config_raw)
self.cursor_raw = self.db_conn_raw.cursor(DictCursor)
self.db_conn_test = pymysql.Connect(**db_config_test)
self.cursor_test = self.db_conn_test.cursor(DictCursor)
def get_booking_data_by_ticket_id(self, t_id):
sql_str = """
SELECT
TICKET_NUM,
PAYMENTSEQID,
PAYMENT_TYPE,
MEMBCARD_NUM,
NON_CHARGE_CARDID,
TOTAL_PAYMENT,
REAL_PAYMENT_TICKET,
THIRD_PAY_TYPE,
THIRD_ORDER_NUM,
REAL_PAYMENT,
TOTAL_ALLOWANCE,
VIP_SERVFEE,
TICKET_FEE,
REFUND_FLAG,
cinema_ticket_income
FROM
`booking_ticket_payment` AS btp
LEFT JOIN cinema_sell_log AS s
ON btp.`TICKET_NUM` = s.`cinema_sell_id`
WHERE btp.`TICKET_NUM` IN(%s);"""
self.cursor_raw.execute(sql_str, (t_id,))
return self.cursor_raw.fetchall()
def get_test_data_by_ticket_id(self, t_id):
sql_str = """SELECT * FROM multi_cards_pay_result WHERE ticket_num in (%s);"""
self.cursor_test.execute(sql_str, (t_id,))
return self.cursor_test.fetchall()
def get_test_ticket_list_by_datetime(self, _start_date_str, _end_date_str):
sql_str = """SELECT ticket_num FROM multi_cards_pay_result WHERE add_time >= %s AND add_time < %s"""
self.cursor_test.execute(sql_str, (_start_date_str, _end_date_str))
result = self.cursor_test.fetchall()
result_list = [r['ticket_num'] for r in result]
return sorted(set(result_list))
def get_test_ticket_list_by_id(self, id_str):
sql_str = f"""SELECT result_tickets_no FROM multi_cards_pay_test WHERE id in ({id_str})"""
self.cursor_test.execute(sql_str)
result = self.cursor_test.fetchall()
result_list = []
for r in result:
t = r['result_tickets_no'].split(', ')
result_list.extend(t)
return sorted(set(result_list))
def compare_data(self, t_id):
result_raw = self.get_booking_data_by_ticket_id(t_id)
result_test = self.get_test_data_by_ticket_id(t_id)
# print(result_raw)
# print(result_test)
print('@' * 100)
print(f"测试用例id: {result_test[0]['case_id']}")
if len(result_raw) != len(result_test):
print(f"{t_id}: 数据条数不一致,请检查")
else:
print(t_id)
for raw in result_raw:
for test in result_test:
if data_dict[raw['PAYMENT_TYPE']] == '储值卡':
if data_dict[raw['PAYMENT_TYPE']] == test['pay_type'] and \
raw['MEMBCARD_NUM'] == test['pay_card_no']:
print(f"开始对比: {test['pay_type']}")
if data_dict[raw['PAYMENT_TYPE']] == '会员卡':
if raw['MEMBCARD_NUM'] != test['pay_card_no']:
print(f"会员卡号不一致:{raw['MEMBCARD_NUM']} - {test['pay_card_no']}")
elif data_dict[raw['PAYMENT_TYPE']] == '影票计次卡':
if raw['NON_CHARGE_CARDID'] != test['times_card_no']:
print(f"影票计次卡号不一致:{raw['MEMBCARD_NUM']} - {test['pay_card_no']}")
if str(raw['REAL_PAYMENT_TICKET']) != str(test['ticket']):
print(f"影票支付金额不一致:{raw['REAL_PAYMENT_TICKET']} - {test['ticket']}")
if str(raw['VIP_SERVFEE']) != str(test['service_fee']):
print(f"服务费支付金额不一致:{raw['VIP_SERVFEE']} - {test['service_fee']}")
if str(raw['TICKET_FEE']) != str(test['handle_fee']):
print(f"手续费支付金额不一致:{raw['TICKET_FEE']} - {test['handle_fee']}")
elif data_dict[raw['PAYMENT_TYPE']] == '影票计次卡':
if data_dict[raw['PAYMENT_TYPE']] == test['pay_type'] and \
raw['NON_CHARGE_CARDID'] == test['times_card_no']:
print(f"开始对比: {test['pay_type']}")
if data_dict[raw['PAYMENT_TYPE']] == '会员卡':
if raw['MEMBCARD_NUM'] != test['pay_card_no']:
print(f"会员卡号不一致:{raw['MEMBCARD_NUM']} - {test['pay_card_no']}")
elif data_dict[raw['PAYMENT_TYPE']] == '影票计次卡':
if raw['NON_CHARGE_CARDID'] != test['times_card_no']:
print(f"影票计次卡号不一致:{raw['MEMBCARD_NUM']} - {test['pay_card_no']}")
if str(raw['REAL_PAYMENT_TICKET']) != str(test['ticket']):
print(f"影票支付金额不一致:{raw['REAL_PAYMENT_TICKET']} - {test['ticket']}")
if str(raw['VIP_SERVFEE']) != str(test['service_fee']):
print(f"服务费支付金额不一致:{raw['VIP_SERVFEE']} - {test['service_fee']}")
if str(raw['TICKET_FEE']) != str(test['handle_fee']):
print(f"手续费支付金额不一致:{raw['TICKET_FEE']} - {test['handle_fee']}")
else:
if data_dict[raw['PAYMENT_TYPE']] == test['pay_type']:
print(f"开始对比: {test['pay_type']}")
if data_dict[raw['PAYMENT_TYPE']] == '会员卡':
if raw['MEMBCARD_NUM'] != test['pay_card_no']:
print(f"会员卡号不一致:{raw['MEMBCARD_NUM']} - {test['pay_card_no']}")
elif data_dict[raw['PAYMENT_TYPE']] == '影票计次卡':
if raw['NON_CHARGE_CARDID'] != test['times_card_no']:
print(f"影票计次卡号不一致:{raw['MEMBCARD_NUM']} - {test['pay_card_no']}")
if str(raw['REAL_PAYMENT_TICKET']) != str(test['ticket']):
print(f"影票支付金额不一致:{raw['REAL_PAYMENT_TICKET']} - {test['ticket']}")
if str(raw['VIP_SERVFEE']) != str(test['service_fee']):
print(f"服务费支付金额不一致:{raw['VIP_SERVFEE']} - {test['service_fee']}")
if str(raw['TICKET_FEE']) != str(test['handle_fee']):
print(f"手续费支付金额不一致:{raw['TICKET_FEE']} - {test['handle_fee']}")
def compare(self, ticket_id_list):
for ticket in ticket_id_list:
self.compare_data(ticket)
if __name__ == "__main__":
start_date_str = '2023-11-24 12:04:20'
end_date_str = '2023-11-24 12:15:43'
db = DB()
# ticket_id_list = db.get_test_ticket_list_by_datetime(start_date_str, end_date_str)
# ticket_id_list = db.get_test_ticket_list_by_id('6, 12, 21, 32')
ticket_id_list = ['1000000000011682', '1000000000011683', '1000000000011684', '1000000000011685',
'1000000000011686', '1000000000011687', '1000000000011688', '1000000000011689',
'1000000000011690', '1000000000011691', '1000000000011692', '1000000000011693',
'1000000000011694', '1000000000011695', '1000000000011696', '1000000000011697',
'1000000000011698', '1000000000011699', '1000000000011700', '1000000000011701',
'1000000000011702', '1000000000011703', '1000000000011704', '1000000000011705',
'1000000000011706', '1000000000011707', '1000000000011708', '1000000000011709',
'1000000000011710', '1000000000011711', '1000000000011712', '1000000000011713',
'1000000000011714', '1000000000011715', '1000000000011716', '1000000000011717',
'1000000000011718', '1000000000011719', '1000000000011720', '1000000000011721',
'1000000000011722', '1000000000011723', '1000000000011724', '1000000000011725',
'1000000000011726', '1000000000011727', '1000000000011728', '1000000000011729',
'1000000000011730', '1000000000011731', '1000000000011732', '1000000000011733',
'1000000000011734', '1000000000011735', '1000000000011736', '1000000000011737',
'1000000000011738', '1000000000011739', '1000000000011740', '1000000000011741',
'1000000000011742', '1000000000011743', '1000000000011744', '1000000000011745',
'1000000000011746', '1000000000011747', '1000000000011748', '1000000000011749',
'1000000000011750', '1000000000011751', '1000000000011752', '1000000000011753',
'1000000000011754', '1000000000011755', '1000000000011756', '1000000000011757',
'1000000000011758', '1000000000011759', '1000000000011760', '1000000000011761',
'1000000000011762', '1000000000011763', '1000000000011764', '1000000000011765',
'1000000000011766', '1000000000011767', '1000000000011768', '1000000000011769',
'1000000000011770', '1000000000011771', '1000000000011772', '1000000000011773',
'1000000000011774', '1000000000011775', '1000000000011776', '1000000000011777',
'1000000000011778', '1000000000011779', '1000000000011780', '1000000000011781',
'1000000000011782', '1000000000011783', '1000000000011784', '1000000000011785',
'1000000000011786', '1000000000011787', '1000000000011788', '1000000000011789',
'1000000000011790', '1000000000011791', '1000000000011792', '1000000000011793',
'1000000000011794', '1000000000011795', '1000000000011796', '1000000000011797',
'1000000000011798', '1000000000011799', '1000000000011800', '1000000000011801',
'1000000000011802', '1000000000011803', '1000000000011804', '1000000000011805',
'1000000000011806', '1000000000011807', '1000000000011808', '1000000000011809',
'1000000000011810', '1000000000011811', '1000000000011812', '1000000000011813',
'1000000000011814', '1000000000011815', '1000000000011816', '1000000000011817',
'1000000000011818', '1000000000011819', '1000000000011820', '1000000000011821',
'1000000000011822', '1000000000011823', '1000000000011824', '1000000000011825',
'1000000000011826', '1000000000011827', '1000000000011828', '1000000000011829',
'1000000000011830', '1000000000011831', '1000000000011832', '1000000000011833',
'1000000000011834', '1000000000011835', '1000000000011836', '1000000000011837',
'1000000000011838', '1000000000011839', '1000000000011840', '1000000000011841',
'1000000000011842', '1000000000011843', '1000000000011844', '1000000000011845',
'1000000000011846', '1000000000011847', '1000000000011848', '1000000000011849',
'1000000000011850', '1000000000011851', '1000000000011852', '1000000000011853',
'1000000000011854', '1000000000011855', '1000000000011856', '1000000000011857',
'1000000000011858', '1000000000011859', '1000000000011860', '1000000000011861',
'1000000000011862', '1000000000011863', '1000000000011864', '1000000000011865',
'1000000000011866', '1000000000011867', '1000000000011868', '1000000000011869',
'1000000000011870', '1000000000011871', '1000000000011882', '1000000000011883',
'1000000000011884', '1000000000011885', '1000000000011886', '1000000000011887',
'1000000000011888', '1000000000011889', '1000000000011890', '1000000000011891']
# print(ticket_id_list)
db.compare(ticket_id_list)