commit
0f67dd6553
BIN
data/售价尾端价格.xlsx (Stored with Git LFS)
BIN
data/售价尾端价格.xlsx (Stored with Git LFS)
Binary file not shown.
|
|
@ -4,7 +4,7 @@ from pathlib import Path
|
|||
|
||||
import pandas as pd
|
||||
|
||||
from utils.gtools import MySQLconnect
|
||||
from utils.gtools import DBconnect
|
||||
|
||||
|
||||
# 根据SPU判断空运或海运,1为海运
|
||||
|
|
@ -62,17 +62,21 @@ def spu_head_type(base_df: pd.DataFrame):
|
|||
|
||||
class SellPriceBase:
|
||||
parent_current_directory = Path(__file__).parent.parent
|
||||
price_path = parent_current_directory.joinpath("data")
|
||||
_price_files = price_path.joinpath("售价尾端价格.xlsx")
|
||||
df_2025 = None
|
||||
df_2024 = None
|
||||
_instance = None
|
||||
def __new__(cls, *args, **kwargs):
|
||||
"""实现单例模式,只加载一次文件"""
|
||||
if cls._instance is None:
|
||||
cls._instance = super().__new__(cls)
|
||||
|
||||
with DBconnect() as db:
|
||||
if cls.df_2024 is None:
|
||||
cls.df_2024 = pd.read_excel(cls._price_files,sheet_name="2025")
|
||||
cls.df_2024 = pd.read_sql("select * from sell_price_ending_2024", db.eng)
|
||||
if cls.df_2025 is None:
|
||||
cls.df_2025 = pd.read_excel(cls._price_files,sheet_name="2025")
|
||||
return super().__new__(cls)
|
||||
cls.df_2025 = pd.read_sql("select * from sell_price_ending_2025", db.eng)
|
||||
return cls._instance
|
||||
return cls._instance
|
||||
def __init__(self, packages, purchase_price, shipping_type, ocean_first_cny, ocean_first_usd, air_first_usd,
|
||||
air_cny_type, air_first_fix, exchange_rate, profit_rate, air_rate,tax_rate):
|
||||
self.packages = packages # 单sku包裹数据
|
||||
|
|
|
|||
|
|
@ -30,3 +30,29 @@ class MySQLconnect():
|
|||
def connect(self):
|
||||
return pymysql.connect(host=self.host, port=3306, database=self.dbname, user="zhenggantian", password="123456",
|
||||
charset="utf8")
|
||||
|
||||
|
||||
class DBconnect():
|
||||
def __init__(self):
|
||||
self.host = '192.168.100.33'
|
||||
|
||||
def __enter__(self):
|
||||
self.eng = self.engine()
|
||||
self.con = self.connect()
|
||||
self.cur = self.con.cursor()
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
self.eng.dispose()
|
||||
self.cur.close()
|
||||
self.con.close()
|
||||
if exc_val:
|
||||
raise
|
||||
|
||||
def engine(self):
|
||||
return create_engine("mysql+pymysql://logistics:logistics123@" + self.host + f":3306/logistics",
|
||||
pool_size=10, max_overflow=5, pool_recycle=3600)
|
||||
|
||||
def connect(self):
|
||||
return pymysql.connect(host=self.host, port=3306, database="logistics", user="logistics", password="logistics123",
|
||||
charset="utf8")
|
||||
414465
售价模型审核.ipynb
414465
售价模型审核.ipynb
File diff suppressed because it is too large
Load Diff
121391
售价模型计算.ipynb
121391
售价模型计算.ipynb
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue