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.

33 lines
1.3 KiB

7 days ago
# -*- coding: utf-8 -*-
"""票 02 排查:查公海规则表状态 + B2 商机 owner_dept(66014 禁领拦截根因)。"""
import io
import sys
import pymysql
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
conn = pymysql.connect(host='8.129.84.155', port=3306, user='root', password='Itc@123456',
database='crm', charset='utf8mb4', autocommit=True)
cur = conn.cursor()
cur.execute('''SELECT id, rule_name, apply_scope, is_default, allow_free_claim,
allow_manual_pool, status, version_no, create_time
FROM opportunity_pool_rule WHERE deleted=0 ORDER BY create_time DESC''')
rows = cur.fetchall()
hdr = ['id', 'rule_name', 'scope', 'isDef', 'freeClaim', 'manualPool', 'status', 'ver', 'createTime']
print(' | '.join(hdr))
for r in rows:
print(' | '.join(str(x) for x in r))
print()
cur.execute('SELECT id, opp_name, owner_dept_id, opp_status FROM opportunity WHERE id=%s',
(749634119834533888,))
print('B2:', cur.fetchone())
# 部门专用规则的 deptIds 绑定
cur.execute('''SELECT r.id, r.rule_name, rd.dept_id FROM opportunity_pool_rule r
JOIN opportunity_pool_rule_dept rd ON rd.rule_id = r.id
WHERE r.deleted=0''')
print('dept bindings:', cur.fetchall())
conn.close()