u
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import sql from 'mssql';
|
||||
import { isDemoMode } from '../demo/mode.js';
|
||||
import { getDemoCategoryCount } from '../demo/store.js';
|
||||
import { getPool } from '../db.js';
|
||||
import { CATEGORY_TREE_CTE, categoryTreeRequest, getRootCategoryId } from './category-tree.js';
|
||||
|
||||
@@ -12,6 +14,10 @@ WHERE k.kKategorie IN (SELECT kKategorie FROM CategoryTree)
|
||||
`;
|
||||
|
||||
export async function getCategoryCount({ cursor = 0, rootCategoryId = getRootCategoryId() } = {}) {
|
||||
if (isDemoMode()) {
|
||||
return getDemoCategoryCount({ cursor });
|
||||
}
|
||||
|
||||
const result = await categoryTreeRequest(getPool(), rootCategoryId)
|
||||
.input('cursor', sql.BigInt, cursor)
|
||||
.query(CATEGORY_COUNT_SQL);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import sql from 'mssql';
|
||||
import { isDemoMode } from '../demo/mode.js';
|
||||
import { getDemoCategoryList } from '../demo/store.js';
|
||||
import { getPool } from '../db.js';
|
||||
import { CATEGORY_TREE_CTE, categoryTreeRequest, getRootCategoryId } from './category-tree.js';
|
||||
|
||||
@@ -26,6 +28,10 @@ ORDER BY lastChanged ASC;
|
||||
`;
|
||||
|
||||
export async function getCategoryList({ cursor = 0, limit = 20, rootCategoryId = getRootCategoryId() } = {}) {
|
||||
if (isDemoMode()) {
|
||||
return getDemoCategoryList({ cursor, limit });
|
||||
}
|
||||
|
||||
const result = await categoryTreeRequest(getPool(), rootCategoryId)
|
||||
.input('cursor', sql.BigInt, cursor)
|
||||
.input('limit', sql.Int, limit)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import sql from 'mssql';
|
||||
import { isDemoMode } from '../demo/mode.js';
|
||||
import { getDemoCompositeProductCount } from '../demo/store.js';
|
||||
import { getPool } from '../db.js';
|
||||
import { getActiveShopId } from '../shop.js';
|
||||
|
||||
@@ -16,6 +18,10 @@ WHERE a.kStueckliste <> 0
|
||||
`;
|
||||
|
||||
export async function getCompositeProductCount({ cursor = 0 } = {}) {
|
||||
if (isDemoMode()) {
|
||||
return getDemoCompositeProductCount({ cursor });
|
||||
}
|
||||
|
||||
const result = await getPool()
|
||||
.request()
|
||||
.input('cursor', sql.BigInt, cursor)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import sql from 'mssql';
|
||||
import { isDemoMode } from '../demo/mode.js';
|
||||
import { getDemoCompositeProductList } from '../demo/store.js';
|
||||
import { getPool } from '../db.js';
|
||||
import { getActiveShopId } from '../shop.js';
|
||||
|
||||
@@ -21,6 +23,10 @@ ORDER BY lastChanged ASC;
|
||||
`;
|
||||
|
||||
export async function getCompositeProductList({ cursor = 0, limit = 100 } = {}) {
|
||||
if (isDemoMode()) {
|
||||
return getDemoCompositeProductList({ cursor, limit });
|
||||
}
|
||||
|
||||
const result = await getPool()
|
||||
.request()
|
||||
.input('cursor', sql.BigInt, cursor)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import sql from 'mssql';
|
||||
import { isDemoMode } from '../demo/mode.js';
|
||||
import { createDemoOrder } from '../demo/store.js';
|
||||
import { getPool } from '../db.js';
|
||||
import { getActiveShopId, getActiveShopSubshopId } from '../shop.js';
|
||||
import { deliverOrder } from './delivery/index.js';
|
||||
@@ -653,6 +655,10 @@ async function insertPayment(transaction, kAuftrag, payment, order, orderDate, z
|
||||
}
|
||||
|
||||
export async function createOrder(order) {
|
||||
if (isDemoMode()) {
|
||||
return createDemoOrder(order);
|
||||
}
|
||||
|
||||
const kPosAuftrag = Number.parseInt(order.externalId, 10);
|
||||
const externalOrderNumber = order.externalOrderNumber || '';
|
||||
if (Number.isInteger(kPosAuftrag) && kPosAuftrag > 0) {
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import sql from 'mssql';
|
||||
import { isDemoMode } from '../demo/mode.js';
|
||||
import {
|
||||
getDemoCustomerGroupCount,
|
||||
getDemoCustomerGroupIds,
|
||||
getDemoCustomerGroupList,
|
||||
} from '../demo/store.js';
|
||||
import { getPool } from '../db.js';
|
||||
|
||||
const CUSTOMER_GROUP_IDS_SQL = `
|
||||
@@ -26,11 +32,19 @@ WHERE CONVERT(BIGINT, bRowversion) > @cursor;
|
||||
`;
|
||||
|
||||
export async function getCustomerGroupIds() {
|
||||
if (isDemoMode()) {
|
||||
return getDemoCustomerGroupIds();
|
||||
}
|
||||
|
||||
const result = await getPool().request().query(CUSTOMER_GROUP_IDS_SQL);
|
||||
return result.recordset.map((row) => row.kKundenGruppe);
|
||||
}
|
||||
|
||||
export async function getCustomerGroupList({ cursor = 0 } = {}) {
|
||||
if (isDemoMode()) {
|
||||
return getDemoCustomerGroupList({ cursor });
|
||||
}
|
||||
|
||||
const result = await getPool().request().input('cursor', sql.BigInt, cursor).query(CUSTOMER_GROUP_LIST_SQL);
|
||||
|
||||
return result.recordset.map((row) => ({
|
||||
@@ -43,6 +57,10 @@ export async function getCustomerGroupList({ cursor = 0 } = {}) {
|
||||
}
|
||||
|
||||
export async function getCustomerGroupCount({ cursor = 0 } = {}) {
|
||||
if (isDemoMode()) {
|
||||
return getDemoCustomerGroupCount({ cursor });
|
||||
}
|
||||
|
||||
const result = await getPool().request().input('cursor', sql.BigInt, cursor).query(CUSTOMER_GROUP_COUNT_SQL);
|
||||
return result.recordset[0]?.CustomerGroupCount ?? 0;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import sql from 'mssql';
|
||||
import { isDemoMode } from '../demo/mode.js';
|
||||
import { getDemoDeletedEntityCount } from '../demo/store.js';
|
||||
import { getPool } from '../db.js';
|
||||
|
||||
const DELETED_ENTITY_COUNT_SQL = `
|
||||
@@ -8,6 +10,10 @@ WHERE CONVERT(BIGINT, vDeletedEntity.bLastChanged) > @cursor;
|
||||
`;
|
||||
|
||||
export async function getDeletedEntityCount({ cursor = 0 } = {}) {
|
||||
if (isDemoMode()) {
|
||||
return getDemoDeletedEntityCount({ cursor });
|
||||
}
|
||||
|
||||
const result = await getPool()
|
||||
.request()
|
||||
.input('cursor', sql.BigInt, cursor)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import sql from 'mssql';
|
||||
import { isDemoMode } from '../demo/mode.js';
|
||||
import { getDemoDeletedEntityList } from '../demo/store.js';
|
||||
import { getPool } from '../db.js';
|
||||
|
||||
const DELETED_ENTITY_LIST_SQL = `
|
||||
@@ -12,6 +14,10 @@ ORDER BY lastChanged ASC;
|
||||
`;
|
||||
|
||||
export async function getDeletedEntityList({ cursor = 0, limit = 600 } = {}) {
|
||||
if (isDemoMode()) {
|
||||
return getDemoDeletedEntityList({ cursor, limit });
|
||||
}
|
||||
|
||||
const result = await getPool()
|
||||
.request()
|
||||
.input('cursor', sql.BigInt, cursor)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import sql from 'mssql';
|
||||
import { isDemoMode } from '../demo/mode.js';
|
||||
import { getDemoImageByHash } from '../demo/store.js';
|
||||
import { getPool } from '../db.js';
|
||||
|
||||
const IMAGE_BY_HASH_SQL = `
|
||||
@@ -24,6 +26,10 @@ function contentTypeFor(cQuelle) {
|
||||
}
|
||||
|
||||
export async function getImageByHash(hash, size) {
|
||||
if (isDemoMode()) {
|
||||
return getDemoImageByHash(hash);
|
||||
}
|
||||
|
||||
const result = await getPool().request().input('hash', sql.NVarChar, hash).query(IMAGE_BY_HASH_SQL);
|
||||
|
||||
const row = result.recordset[0];
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import sql from 'mssql';
|
||||
import { isDemoMode } from '../demo/mode.js';
|
||||
import { getDemoMaxOrderIdCount } from '../demo/store.js';
|
||||
import { getPool } from '../db.js';
|
||||
import { getActiveShopSubshopId } from '../shop.js';
|
||||
|
||||
@@ -9,6 +11,10 @@ WHERE kShopSubShop = @kShopSubShop;
|
||||
`;
|
||||
|
||||
export async function getMaxOrderIdCount() {
|
||||
if (isDemoMode()) {
|
||||
return getDemoMaxOrderIdCount();
|
||||
}
|
||||
|
||||
const kShopSubShop = getActiveShopSubshopId();
|
||||
if (!kShopSubShop) {
|
||||
return 0;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import sql from 'mssql';
|
||||
import { isDemoMode } from '../demo/mode.js';
|
||||
import { getDemoProductCount } from '../demo/store.js';
|
||||
import { getPool } from '../db.js';
|
||||
import { CATEGORY_TREE_CTE, categoryTreeRequest, getRootCategoryId } from './category-tree.js';
|
||||
|
||||
@@ -22,6 +24,10 @@ WHERE a.cAktiv = 'Y'
|
||||
`;
|
||||
|
||||
export async function getProductCount({ cursor = 0, rootCategoryId = getRootCategoryId() } = {}) {
|
||||
if (isDemoMode()) {
|
||||
return getDemoProductCount({ cursor });
|
||||
}
|
||||
|
||||
const result = await categoryTreeRequest(getPool(), rootCategoryId)
|
||||
.input('cursor', sql.BigInt, cursor)
|
||||
.query(PRODUCT_COUNT_SQL);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import sql from 'mssql';
|
||||
import { isDemoMode } from '../demo/mode.js';
|
||||
import { getDemoProductList } from '../demo/store.js';
|
||||
import { getPool } from '../db.js';
|
||||
import { getCustomerGroupIds } from './customer-groups.js';
|
||||
import { getProductAttributes } from './product-attributes.js';
|
||||
@@ -93,6 +95,10 @@ function grossPrice(netPrice, taxRate) {
|
||||
}
|
||||
|
||||
export async function getProductList({ cursor = 0, limit = 20 } = {}) {
|
||||
if (isDemoMode()) {
|
||||
return getDemoProductList({ cursor, limit });
|
||||
}
|
||||
|
||||
const pool = getPool();
|
||||
|
||||
const [productResult, customerGroupIds] = await Promise.all([
|
||||
|
||||
Reference in New Issue
Block a user