Commit 5340cd82 by 刘豪

更改crm连接的order数据库为从库

parent 00fc7960
Showing with 21 additions and 7 deletions
...@@ -582,11 +582,11 @@ class PiDaily: ...@@ -582,11 +582,11 @@ class PiDaily:
start_time = 0 start_time = 0
end_time = DateHandler.now_datetime() end_time = DateHandler.now_datetime()
lx_order_db = ConnList.LxOrderDb() # lx_order_db = ConnList.LxOrderDb()
wr_db = ConnList.WrCrm() wr_db = ConnList.WrCrm()
user = ExCrm('').crm_user(start_time, end_time) user = ExCrm('').crm_user(start_time, end_time)
ts_user = TsCrm(lx_order_db, wr_db, user) ts_user = TsCrm(wr_db, user)
ts_user.handle_data() ts_user.handle_data()
......
...@@ -9,14 +9,29 @@ from extract.ex_erp import ExERP ...@@ -9,14 +9,29 @@ from extract.ex_erp import ExERP
class TsCrm: class TsCrm:
def __init__(self, db, wr_db, data): def __init__(self, wr_db, data):
self.dd = {} self.dd = {}
self.db = db
self.cursor = self.db.cursor(cursor=pymysql.cursors.DictCursor)
self.wr_db = wr_db self.wr_db = wr_db
self.wr_db_cursor = self.wr_db.cursor() self.wr_db_cursor = self.wr_db.cursor()
self.data = data self.data = data
self.exchange = ExERP(DateHandler.now_date(0, 1)).get_erp_exchange() self.exchange = ExERP(DateHandler.now_date(0, 1)).get_erp_exchange()
self.create_time = DateHandler.date_time(0)
self.conn_db()
def conn_db(self):
conf = {
'host': "business-slave.ichunt.db",
'port': 3306,
'user': "ReadOdersD",
'password': "RLssy2@@!!@$#yttz",
'db': "liexin_order",
'charset': 'utf8'
}
try:
self.db = pymysql.connect(**conf)
self.cursor = self.db.cursor(cursor=pymysql.cursors.DictCursor)
except Exception as e:
print("连接{}数据库失败{}".format(conf["host"], e))
def __del__(self): def __del__(self):
if self.cursor: if self.cursor:
...@@ -182,10 +197,9 @@ class TsCrm: ...@@ -182,10 +197,9 @@ class TsCrm:
print(e) print(e)
def iap_data(self, outter_uids): def iap_data(self, outter_uids):
create_time = DateHandler.date_time(0)
for outter_uid in outter_uids: for outter_uid in outter_uids:
try: try:
self.dd[outter_uid]['create_time'] = create_time self.dd[outter_uid]['create_time'] = self.create_time
sql = "SELECT 1 FROM lie_user_extend WHERE outter_uid = %d" % outter_uid sql = "SELECT 1 FROM lie_user_extend WHERE outter_uid = %d" % outter_uid
is_exist = self.read(self.wr_db_cursor, self.wr_db, sql) is_exist = self.read(self.wr_db_cursor, self.wr_db, sql)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment