|
@@ -43,12 +43,31 @@ class MySqlDao:
|
|
|
data = self.db_helper.load_data_with_page(query, params)
|
|
data = self.db_helper.load_data_with_page(query, params)
|
|
|
return data
|
|
return data
|
|
|
|
|
|
|
|
|
|
+ # def load_order_data(self, city_uuid):
|
|
|
|
|
+ # """从数据库中读取订单信息"""
|
|
|
|
|
+ # query = f"SELECT * FROM {self._order_tablename} WHERE city_uuid = :city_uuid"
|
|
|
|
|
+ # params = {"city_uuid": city_uuid}
|
|
|
|
|
+
|
|
|
|
|
+ # data = self.db_helper.load_data_with_page(query, params)
|
|
|
|
|
+ # data.drop('stat_month', axis=1, inplace=True)
|
|
|
|
|
+ # data.drop('city_uuid', axis=1, inplace=True)
|
|
|
|
|
+
|
|
|
|
|
+ # return data
|
|
|
|
|
+
|
|
|
def load_order_data(self, city_uuid):
|
|
def load_order_data(self, city_uuid):
|
|
|
"""从数据库中读取订单信息"""
|
|
"""从数据库中读取订单信息"""
|
|
|
- query = f"SELECT * FROM {self._order_tablename} WHERE city_uuid = :city_uuid"
|
|
|
|
|
|
|
+ cust_list = self.get_cust_list(city_uuid)
|
|
|
|
|
+
|
|
|
|
|
+ cust_id_str = ",".join([f"'{cust_id}'" for cust_id in cust_list])
|
|
|
|
|
+ query = f"""
|
|
|
|
|
+ SELECT *
|
|
|
|
|
+ FROM {self._order_tablename}
|
|
|
|
|
+ WHERE city_uuid = :city_uuid
|
|
|
|
|
+ AND cust_code IN ({cust_id_str})
|
|
|
|
|
+ """
|
|
|
params = {"city_uuid": city_uuid}
|
|
params = {"city_uuid": city_uuid}
|
|
|
-
|
|
|
|
|
data = self.db_helper.load_data_with_page(query, params)
|
|
data = self.db_helper.load_data_with_page(query, params)
|
|
|
|
|
+
|
|
|
data.drop('stat_month', axis=1, inplace=True)
|
|
data.drop('stat_month', axis=1, inplace=True)
|
|
|
data.drop('city_uuid', axis=1, inplace=True)
|
|
data.drop('city_uuid', axis=1, inplace=True)
|
|
|
|
|
|
|
@@ -150,12 +169,16 @@ class MySqlDao:
|
|
|
"""获取指定香烟列表的所有售卖记录"""
|
|
"""获取指定香烟列表的所有售卖记录"""
|
|
|
if not product_ids:
|
|
if not product_ids:
|
|
|
return None
|
|
return None
|
|
|
|
|
+ cust_list = self.get_cust_list(city_uuid)
|
|
|
|
|
+
|
|
|
|
|
+ cust_id_str = ",".join([f"'{cust_id}'" for cust_id in cust_list])
|
|
|
|
|
|
|
|
product_ids_str = ",".join([f"'{product_code}'" for product_code in product_ids])
|
|
product_ids_str = ",".join([f"'{product_code}'" for product_code in product_ids])
|
|
|
query = f"""
|
|
query = f"""
|
|
|
SELECT *
|
|
SELECT *
|
|
|
FROM {self._order_tablename}
|
|
FROM {self._order_tablename}
|
|
|
WHERE city_uuid = :city_uuid
|
|
WHERE city_uuid = :city_uuid
|
|
|
|
|
+ AND cust_code IN ({cust_id_str})
|
|
|
AND product_code IN ({product_ids_str})
|
|
AND product_code IN ({product_ids_str})
|
|
|
"""
|
|
"""
|
|
|
params = {"city_uuid": city_uuid}
|
|
params = {"city_uuid": city_uuid}
|
|
@@ -164,10 +187,15 @@ class MySqlDao:
|
|
|
return data
|
|
return data
|
|
|
|
|
|
|
|
def get_order_by_product(self, city_uuid, product_id):
|
|
def get_order_by_product(self, city_uuid, product_id):
|
|
|
|
|
+ cust_list = self.get_cust_list(city_uuid)
|
|
|
|
|
+
|
|
|
|
|
+ cust_id_str = ",".join([f"'{cust_id}'" for cust_id in cust_list])
|
|
|
|
|
+
|
|
|
query = f"""
|
|
query = f"""
|
|
|
SELECT *
|
|
SELECT *
|
|
|
FROM {self._order_tablename}
|
|
FROM {self._order_tablename}
|
|
|
WHERE city_uuid = :city_uuid
|
|
WHERE city_uuid = :city_uuid
|
|
|
|
|
+ AND cust_code IN ({cust_id_str})
|
|
|
AND product_code = :product_id
|
|
AND product_code = :product_id
|
|
|
"""
|
|
"""
|
|
|
params = {"city_uuid": city_uuid, "product_id": product_id}
|
|
params = {"city_uuid": city_uuid, "product_id": product_id}
|
|
@@ -213,7 +241,9 @@ class MySqlDao:
|
|
|
return data
|
|
return data
|
|
|
|
|
|
|
|
def get_product_from_order(self, city_uuid):
|
|
def get_product_from_order(self, city_uuid):
|
|
|
- query = f"SELECT DISTINCT product_code FROM {self._order_tablename} WHERE city_uuid = :city_uuid"
|
|
|
|
|
|
|
+ cust_list = self.get_cust_list(city_uuid)
|
|
|
|
|
+ cust_id_str = ",".join([f"'{cust_id}'" for cust_id in cust_list])
|
|
|
|
|
+ query = f"SELECT DISTINCT product_code FROM {self._order_tablename} WHERE city_uuid = :city_uuid AND cust_code IN ({cust_id_str})"
|
|
|
params = {"city_uuid": city_uuid}
|
|
params = {"city_uuid": city_uuid}
|
|
|
|
|
|
|
|
data = pd.DataFrame(self.db_helper.fetch_all(text(query), params))
|
|
data = pd.DataFrame(self.db_helper.fetch_all(text(query), params))
|