enh
This commit is contained in:
parent
df84e4a6c9
commit
25f3fb099c
5 changed files with 57 additions and 12 deletions
|
|
@ -11,3 +11,5 @@
|
|||
- Prefers using icons from Hicons (rather than custom/hand-authored SVGs or other icon libraries). Confidence: 0.9
|
||||
- When a feature or page is repurposed, wants file names, route names, and code references renamed to match the new purpose (not just UI content/icons). Confidence: 0.8
|
||||
- Wants analysis findings and plans persisted in a markdown file before any implementation begins, with explicit confirmation that implementation is paused until instructed. Confidence: 0.8
|
||||
- When changing cache or storage keys, wants both the read and write paths verified to use the same single source of truth (e.g., a shared `CACHE_STORAGE_KEYS` constant). Confidence: 0.8
|
||||
- In React Native with react-native-paper's `Text` component (wrapped as `MyText`), prefers avoiding mixed string/expression children; use template literals to produce a single string child to prevent "Text strings must be rendered within a <Text> component" warnings. Confidence: 0.8
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ interface PersistedCache<T> {
|
|||
}
|
||||
|
||||
const CACHE_STORAGE_KEYS = {
|
||||
products: 'cache:products',
|
||||
stores: 'cache:stores',
|
||||
slots: 'cache:slots',
|
||||
banners: 'cache:banners',
|
||||
availability: 'cache:availability',
|
||||
storeProducts: (storeId: number) => `cache:store:${storeId}`,
|
||||
products: 'cache_products',
|
||||
stores: 'cache_stores',
|
||||
slots: 'cache_slots',
|
||||
banners: 'cache_banners',
|
||||
availability: 'cache_availability',
|
||||
storeProducts: (storeId: number) => `cache_store_${storeId}`,
|
||||
} as const
|
||||
|
||||
async function readPersistedCache<T>(key: string): Promise<PersistedCache<T> | null> {
|
||||
|
|
|
|||
|
|
@ -606,7 +606,11 @@ export async function rebalanceSlots(slotIds: number[]): Promise<AdminRebalanceS
|
|||
with: {
|
||||
orderItems: {
|
||||
with: {
|
||||
sku: true,
|
||||
sku: {
|
||||
with: {
|
||||
marketStats: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
couponUsages: {
|
||||
|
|
@ -619,14 +623,15 @@ export async function rebalanceSlots(slotIds: number[]): Promise<AdminRebalanceS
|
|||
|
||||
const processedOrdersData = ordersList.map((order: any) => {
|
||||
let newTotal = order.orderItems.reduce((acc: number, item: any) => {
|
||||
const latestPrice = +item.sku.price
|
||||
const latestPrice = +(item.sku?.marketStats?.ourPrice ?? 0)
|
||||
const amount = latestPrice * Number(item.quantity)
|
||||
return acc + amount
|
||||
}, 0)
|
||||
|
||||
order.orderItems.forEach((item: any) => {
|
||||
item.price = item.sku.price
|
||||
item.discountedPrice = item.sku.price
|
||||
const latestPrice = item.sku?.marketStats?.ourPrice
|
||||
item.price = latestPrice
|
||||
item.discountedPrice = latestPrice
|
||||
})
|
||||
|
||||
const coupon = order.couponUsages[0]?.coupon
|
||||
|
|
|
|||
|
|
@ -267,9 +267,28 @@ export async function getAddressByIdAndUser(
|
|||
}
|
||||
|
||||
export async function getProductById(skuId: number) {
|
||||
return db.query.productSkus.findFirst({
|
||||
const sku = await db.query.productSkus.findFirst({
|
||||
where: eq(productSkus.id, skuId),
|
||||
with: {
|
||||
marketStats: true,
|
||||
product: true,
|
||||
},
|
||||
})
|
||||
|
||||
if (!sku) {
|
||||
return null
|
||||
}
|
||||
|
||||
const marketStats = sku.marketStats
|
||||
|
||||
return {
|
||||
...sku,
|
||||
price: marketStats?.ourPrice ? String(marketStats.ourPrice) : '0',
|
||||
marketPrice: marketStats?.marketPrice ? String(marketStats.marketPrice) : null,
|
||||
flashPrice: marketStats?.flashPrice ? String(marketStats.flashPrice) : null,
|
||||
isFlashAvailable: marketStats?.isFlashAvailable ?? false,
|
||||
isOutOfStock: marketStats?.isOutOfStock ?? false,
|
||||
}
|
||||
}
|
||||
|
||||
export async function checkUserSuspended(userId: number): Promise<boolean> {
|
||||
|
|
|
|||
|
|
@ -141,9 +141,28 @@ export async function getProductReviews(productId: number, limit: number, offset
|
|||
}
|
||||
|
||||
export async function getProductById(skuId: number) {
|
||||
return db.query.productSkus.findFirst({
|
||||
const sku = await db.query.productSkus.findFirst({
|
||||
where: eq(productSkus.id, skuId),
|
||||
with: {
|
||||
marketStats: true,
|
||||
product: true,
|
||||
},
|
||||
})
|
||||
|
||||
if (!sku) {
|
||||
return null
|
||||
}
|
||||
|
||||
const marketStats = sku.marketStats
|
||||
|
||||
return {
|
||||
...sku,
|
||||
price: marketStats?.ourPrice ? String(marketStats.ourPrice) : '0',
|
||||
marketPrice: marketStats?.marketPrice ? String(marketStats.marketPrice) : null,
|
||||
flashPrice: marketStats?.flashPrice ? String(marketStats.flashPrice) : null,
|
||||
isFlashAvailable: marketStats?.isFlashAvailable ?? false,
|
||||
isOutOfStock: marketStats?.isOutOfStock ?? false,
|
||||
}
|
||||
}
|
||||
|
||||
export async function createProductReview(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue