import { liveStore, liveOrderUser } from '@/api/cacheLiving.js'
import { checkPurchaseLimit } from '@/api/product'
import { oncePerSession } from './liveRequestGuard.js'

/** 小黄车商品列表（点击购物车后再请求） */
export function fetchLiveStore(liveId, keyword = '', refresh = false) {
	const kw = keyword || ''
	return oncePerSession(`live:store:${liveId}:${kw}`, () => liveStore(liveId, kw), { refresh })
}

/** 正在购买用户 */
export function fetchLiveOrderUser(liveId, refresh = false) {
	return oncePerSession(`live:orderUser:${liveId}`, () => liveOrderUser(liveId), { refresh })
}

/** 跳转商品前限购校验 */
export function verifyPurchaseLimit(productId, num = 1) {
	return checkPurchaseLimit({ productId, num })
}
