fix: colleague price products use DealProduct, not indexGold
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -24,6 +24,17 @@ function hasReferenceReadingMethod(product: Product): boolean {
|
||||
return Boolean(product.reading_method)
|
||||
}
|
||||
|
||||
/** قیمت منبع همکار؛ اگر خالی بود آبشده همان مظنهٔ صفحه اصلی را میگیرد */
|
||||
function getColleagueSourcedUnitPrice(product: Product, live: number, apiPrice = Number(product.price ?? 0)): number {
|
||||
if (apiPrice > 0) {
|
||||
return apiPrice
|
||||
}
|
||||
if (isMeltedTradeGroup(product.group_type) && live > 0) {
|
||||
return applyPriceOffsetPercent(live, product.price_offset_percent)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
function hasProductUnitWeight(product?: Product | null) {
|
||||
if (!product || isMeltedTradeGroup(product.group_type)) {
|
||||
return false
|
||||
@@ -85,6 +96,10 @@ export function getProductBaseBuyPrice(product?: Product | null): number {
|
||||
return 0
|
||||
}
|
||||
|
||||
if (isColleaguePriceProduct(product)) {
|
||||
return getColleagueSourcedUnitPrice(product, getTradeBuyPrice(lastPrice.value))
|
||||
}
|
||||
|
||||
if (isMeltedProductUsingAppPrice(product) || isAppPriceProduct(product)) {
|
||||
const apiPrice = Number(product.price ?? 0)
|
||||
const useLast = productUsesLastPriceIfZero(product)
|
||||
@@ -171,6 +186,14 @@ export function getProductBaseSellPrice(product?: Product | null): number {
|
||||
return 0
|
||||
}
|
||||
|
||||
if (isColleaguePriceProduct(product)) {
|
||||
return getColleagueSourcedUnitPrice(
|
||||
product,
|
||||
getTradeSellPrice(lastPrice.value),
|
||||
Number(product.sellPrice ?? product.price ?? 0),
|
||||
)
|
||||
}
|
||||
|
||||
if (isMeltedProductUsingAppPrice(product) || isAppPriceProduct(product)) {
|
||||
const apiPrice = Number(product.price ?? 0)
|
||||
const useLast = productUsesLastPriceIfZero(product)
|
||||
@@ -199,10 +222,6 @@ export function getProductBaseSellPrice(product?: Product | null): number {
|
||||
return Number(product.sellPrice ?? product.price ?? 0)
|
||||
}
|
||||
|
||||
if (isColleaguePriceProduct(product)) {
|
||||
return Number(product.sellPrice ?? product.price ?? 0)
|
||||
}
|
||||
|
||||
const serverSell = Number(product.sellPrice ?? 0)
|
||||
if (serverSell > 0) {
|
||||
return serverSell
|
||||
|
||||
Reference in New Issue
Block a user