fix: colleague price products use DealProduct, not indexGold
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -42,6 +42,7 @@ export interface Product {
|
||||
inventory:number
|
||||
app_price?: boolean | number | null
|
||||
colleague_price?: boolean | number | null
|
||||
colleague_price_product_id?: string | number | null
|
||||
tv_price?: number | null
|
||||
tv_sell_price?: number | null
|
||||
direct_price?: number | null
|
||||
|
||||
@@ -54,11 +54,19 @@ export function resolveMeltedPriceSource(product?: {
|
||||
/** قیمت از همکار: قیمت هر عدد، نه هر گرم */
|
||||
export function isColleaguePriceProduct(product?: {
|
||||
colleague_price?: boolean | number | null
|
||||
colleague_price_product_id?: string | number | null
|
||||
} | null) {
|
||||
if (!product) {
|
||||
return false
|
||||
}
|
||||
return product.colleague_price === true || Number(product.colleague_price) === 1
|
||||
const flagged = product.colleague_price === true || Number(product.colleague_price) === 1
|
||||
if (!flagged) {
|
||||
return false
|
||||
}
|
||||
if (product.colleague_price_product_id === undefined) {
|
||||
return true
|
||||
}
|
||||
return Number(product.colleague_price_product_id) > 0
|
||||
}
|
||||
|
||||
/** محصول با پرچم صریح «قیمت اپ» */
|
||||
@@ -79,8 +87,9 @@ export function isMeltedProductUsingAppPrice(product?: {
|
||||
direct_price?: number | null
|
||||
trade_by_quantity?: boolean | number | null
|
||||
price?: number | null
|
||||
colleague_price?: boolean | number | null
|
||||
} | null) {
|
||||
if (!product || resolveMeltedPriceSource(product) !== 'app') {
|
||||
if (!product || isColleaguePriceProduct(product) || resolveMeltedPriceSource(product) !== 'app') {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
<BasicActionSheet placement="bottom" v-model:show="showFilter">
|
||||
<div>
|
||||
<indexGold v-if="selectedProduct?.group_type == 'آبشده'" :ProductItem="selectedProduct" />
|
||||
<indexGold v-if="isMeltedProductUsingAppPrice(selectedProduct)" :ProductItem="selectedProduct" />
|
||||
<DealProduct v-else :ProductItem="selectedProduct" @close="showFilter = false" />
|
||||
</div>
|
||||
</BasicActionSheet>
|
||||
@@ -75,6 +75,7 @@ import type { Product } from '@/models/products'
|
||||
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
||||
import indexGold from '@/views/base/gold/index.vue'
|
||||
import DealProduct from '@/views/base/products/components/DealProduct.vue'
|
||||
import { isMeltedProductUsingAppPrice } from '@/utils/productCategories'
|
||||
import img from '@/assets/img/user_ly1.svg'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import ProductItemVertical from '@/views/base/products/components/ProductItemVertical.vue'
|
||||
|
||||
Reference in New Issue
Block a user