Add new pricing system (#65)
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
# coding=UTF-8
|
||||
|
||||
from api.extensions import db
|
||||
|
||||
|
||||
def get_wallpaper_m2_price(product_id, material_id, market_id):
|
||||
sql = """
|
||||
select
|
||||
price
|
||||
from
|
||||
v_price_product_segments v
|
||||
join prices_wallpaper_m2 p on v.segment_id = p.segment_id
|
||||
where
|
||||
productid = :product_id and market_id = :market_id and material_id = :material_id
|
||||
order by priority desc
|
||||
limit 1;
|
||||
"""
|
||||
|
||||
result = db.session.execute(sql, {
|
||||
"product_id": product_id,
|
||||
"market_id": market_id,
|
||||
"material_id": material_id,
|
||||
})
|
||||
|
||||
rows = result.fetchall()
|
||||
for row in rows:
|
||||
price = row[0]
|
||||
return float(price)
|
||||
|
||||
raise Exception("Failed reading wallpaper m2 price")
|
||||
|
||||
|
||||
def get_external_product_price(product_id, external_product_id, market_id):
|
||||
sql = """
|
||||
select
|
||||
price
|
||||
from
|
||||
v_price_product_segments v
|
||||
join prices_external_products p on v.segment_id = p.segment_id
|
||||
where
|
||||
productid = :product_id and market_id = :market_id and external_product_id = :external_id
|
||||
order by priority desc
|
||||
limit 1;
|
||||
"""
|
||||
|
||||
result = db.session.execute(sql, {
|
||||
"product_id": product_id,
|
||||
"market_id": market_id,
|
||||
"external_id": external_product_id,
|
||||
})
|
||||
|
||||
rows = result.fetchall()
|
||||
for row in rows:
|
||||
price = row[0]
|
||||
return float(price)
|
||||
|
||||
raise Exception("Failed reading external product price")
|
||||
|
||||
|
||||
def get_own_image_wallpaper_m2_price(material_id, market_id):
|
||||
sql = """
|
||||
select
|
||||
price
|
||||
from
|
||||
prices_wallpaper_m2
|
||||
where
|
||||
market_id = :market_id and material_id = :material_id
|
||||
and segment_id = (select id from price_segments where name = 'OWN-IMAGE')
|
||||
"""
|
||||
|
||||
result = db.session.execute(sql, {
|
||||
"market_id": market_id,
|
||||
"material_id": material_id,
|
||||
})
|
||||
|
||||
rows = result.fetchall()
|
||||
for row in rows:
|
||||
price = row[0]
|
||||
return float(price)
|
||||
|
||||
raise Exception("Failed reading own image wallpaper m2 price")
|
||||
|
||||
|
||||
def get_external_product_own_image_price(external_product_id, market_id):
|
||||
sql = """
|
||||
select
|
||||
price
|
||||
from
|
||||
prices_external_products
|
||||
where
|
||||
market_id = :market_id and external_product_id = :external_id
|
||||
and segment_id = (select id from price_segments where name = 'OWN-IMAGE')
|
||||
"""
|
||||
|
||||
result = db.session.execute(sql, {
|
||||
"market_id": market_id,
|
||||
"external_id": external_product_id,
|
||||
})
|
||||
|
||||
rows = result.fetchall()
|
||||
for row in rows:
|
||||
price = row[0]
|
||||
return float(price)
|
||||
|
||||
raise Exception("Failed reading external product own image price")
|
||||
Reference in New Issue
Block a user