mejoras en el modelo de clarificacion de productos
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { searchSnapshotItems } from "../../shared/wooSnapshot.js";
|
||||
import { listProducts, getProductByWooId } from "../db/repo.js";
|
||||
import { listProducts, getProductByWooId, updateProductSellUnit, bulkUpdateProductSellUnit, updateProduct } from "../db/repo.js";
|
||||
|
||||
export async function handleSearchProducts({ tenantId, q = "", limit = "10", forceWoo = "0" }) {
|
||||
const { items, source } = await searchSnapshotItems({
|
||||
@@ -25,3 +25,18 @@ export async function handleSyncProducts({ tenantId }) {
|
||||
return { ok: true, message: "Sync triggered (use import script for full sync)" };
|
||||
}
|
||||
|
||||
export async function handleUpdateProductUnit({ tenantId, wooProductId, sell_unit }) {
|
||||
await updateProductSellUnit({ tenantId, wooProductId, sell_unit });
|
||||
return { ok: true, woo_product_id: wooProductId, sell_unit };
|
||||
}
|
||||
|
||||
export async function handleBulkUpdateProductUnit({ tenantId, wooProductIds, sell_unit }) {
|
||||
await bulkUpdateProductSellUnit({ tenantId, wooProductIds, sell_unit });
|
||||
return { ok: true, updated_count: wooProductIds.length, sell_unit };
|
||||
}
|
||||
|
||||
export async function handleUpdateProduct({ tenantId, wooProductId, sell_unit, categories }) {
|
||||
await updateProduct({ tenantId, wooProductId, sell_unit, categories });
|
||||
return { ok: true, woo_product_id: wooProductId, sell_unit, categories };
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,10 @@ export async function handleCreateRecommendation({
|
||||
ask_slots = [],
|
||||
active = true,
|
||||
priority = 100,
|
||||
trigger_product_ids = [],
|
||||
recommended_product_ids = [],
|
||||
}) {
|
||||
return insertRecommendation({ tenantId, rule_key, trigger, queries, boosts, ask_slots, active, priority });
|
||||
return insertRecommendation({ tenantId, rule_key, trigger, queries, boosts, ask_slots, active, priority, trigger_product_ids, recommended_product_ids });
|
||||
}
|
||||
|
||||
export async function handleUpdateRecommendation({
|
||||
@@ -37,8 +39,10 @@ export async function handleUpdateRecommendation({
|
||||
ask_slots,
|
||||
active,
|
||||
priority,
|
||||
trigger_product_ids,
|
||||
recommended_product_ids,
|
||||
}) {
|
||||
return updateRecommendation({ tenantId, id, trigger, queries, boosts, ask_slots, active, priority });
|
||||
return updateRecommendation({ tenantId, id, trigger, queries, boosts, ask_slots, active, priority, trigger_product_ids, recommended_product_ids });
|
||||
}
|
||||
|
||||
export async function handleDeleteRecommendation({ tenantId, id }) {
|
||||
|
||||
Reference in New Issue
Block a user