| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- from dao import Mysql
- def load_order_data_from_mysql(city_uuid):
- """从数据库中读取订单数据"""
- client = Mysql()
- tablename = "yunfu_mock_data"
- query_text = "*"
- # city_uuid = "00000000000000000000000011441801"
- # df = client.load_data(tablename, query_text, "city_uuid", city_uuid)
- df = client.load_mock_data(tablename, query_text)
- if len(df) == 0:
- return None
-
- # df.drop('stat_month', axis=1, inplace=True)
- # df.drop('city_uuid', axis=1, inplace=True)
-
- # 去除重复值和填补缺失值
- df.drop_duplicates(inplace=True)
- df.fillna(0, inplace=True)
- df = df.infer_objects(copy=False)
- return df
- def load_cust_data_from_mysql(city_uuid):
- """从数据库中读取商户信息数据"""
- client = Mysql()
- tablename = "tads_brandcul_cust_info"
- query_text = "*"
-
- df = client.load_data(tablename, query_text, "BA_CITY_ORG_CODE", city_uuid)
- if len(df) == 0:
- return None
-
- return df
- def get_cust_list_from_database(city_uuid):
- client = Mysql()
- tablename = "tads_brandcul_cust_info"
- query_text = "*"
-
- df = client.load_data(tablename, query_text, "BA_CITY_ORG_CODE", city_uuid)
- cust_list = df["BB_RETAIL_CUSTOMER_CODE"].to_list()
- if len(cust_list) == 0:
- return []
-
- return cust_list
- def load_product_data_from_mysql(city_uuid):
- """从数据库中读取商品信息"""
- client = Mysql()
- tablename = "tads_brandcul_product_info"
- query_text = "*"
-
- df = client.load_data(tablename, query_text, "city_uuid", city_uuid)
- if len(df) == 0:
- return None
-
- return df
- def get_product_by_id(city_uuid, product_id):
- client = Mysql()
-
- res = client.get_product_by_id(city_uuid, product_id)
- if len(res) == 0:
- return None
- return res
- def get_custs_by_ids(city_uuid, cust_ids):
- client = Mysql()
-
- res = client.get_cust_by_ids(city_uuid, cust_ids)
- if len(res) == 0:
- return None
- return res
- if __name__ == '__main__':
- data = load_order_data_from_mysql("00000000000000000000000011445301")
- print(data)
|