autosync_backend2 1.1.31 → 1.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +14 -16
- package/dist/index.js +88 -22
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -117,19 +117,19 @@ export declare const app: Elysia<"", {
|
|
|
117
117
|
size: import("@sinclair/typebox").TInteger;
|
|
118
118
|
}>;
|
|
119
119
|
userId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
120
|
+
employeeId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
120
121
|
transactionType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TEnum<{
|
|
121
122
|
IN: "IN";
|
|
122
123
|
OUT: "OUT";
|
|
123
124
|
}>>;
|
|
124
125
|
transactionKind: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TEnum<{
|
|
126
|
+
ORDER: "ORDER";
|
|
125
127
|
TRANSFER: "TRANSFER";
|
|
126
128
|
RETURN: "RETURN";
|
|
127
129
|
ADJUSTMENT: "ADJUSTMENT";
|
|
128
130
|
REJECTION: "REJECTION";
|
|
129
|
-
ORDER: "ORDER";
|
|
130
131
|
SALES: "SALES";
|
|
131
132
|
}>>;
|
|
132
|
-
employeeId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
133
133
|
product: import("@sinclair/typebox").TObject<{
|
|
134
134
|
id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
135
135
|
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
@@ -346,6 +346,7 @@ export declare const app: Elysia<"", {
|
|
|
346
346
|
BANK_TRANSFER: "BANK_TRANSFER";
|
|
347
347
|
POS_TERMINAL: "POS_TERMINAL";
|
|
348
348
|
PAYMENT_PACKAGE: "PAYMENT_PACKAGE";
|
|
349
|
+
CARD: "CARD";
|
|
349
350
|
}>;
|
|
350
351
|
paymentChannel: import("@sinclair/typebox").TString;
|
|
351
352
|
amount: import("@sinclair/typebox").TNumber;
|
|
@@ -432,7 +433,6 @@ export declare const app: Elysia<"", {
|
|
|
432
433
|
spPackageId: import("@sinclair/typebox").TString;
|
|
433
434
|
}>;
|
|
434
435
|
readonly "CrmSpPackageProductModel.create": import("@sinclair/typebox").TObject<{
|
|
435
|
-
priceTotal: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
436
436
|
spPackageId: import("@sinclair/typebox").TString;
|
|
437
437
|
quantity: import("@sinclair/typebox").TInteger;
|
|
438
438
|
priceUnit: import("@sinclair/typebox").TNumber;
|
|
@@ -1966,9 +1966,9 @@ export declare const app: Elysia<"", {
|
|
|
1966
1966
|
params: {};
|
|
1967
1967
|
query: {
|
|
1968
1968
|
userId?: string | undefined;
|
|
1969
|
-
transactionType?: "IN" | "OUT" | undefined;
|
|
1970
|
-
transactionKind?: "TRANSFER" | "RETURN" | "ADJUSTMENT" | "REJECTION" | "ORDER" | "SALES" | undefined;
|
|
1971
1969
|
employeeId?: string | undefined;
|
|
1970
|
+
transactionType?: "IN" | "OUT" | undefined;
|
|
1971
|
+
transactionKind?: "ORDER" | "TRANSFER" | "RETURN" | "ADJUSTMENT" | "REJECTION" | "SALES" | undefined;
|
|
1972
1972
|
product: {
|
|
1973
1973
|
id?: string | undefined;
|
|
1974
1974
|
search?: string | undefined;
|
|
@@ -2022,7 +2022,7 @@ export declare const app: Elysia<"", {
|
|
|
2022
2022
|
itemId: string;
|
|
2023
2023
|
productId: string | null;
|
|
2024
2024
|
transactionType: "IN" | "OUT";
|
|
2025
|
-
transactionKind: "
|
|
2025
|
+
transactionKind: "ORDER" | "TRANSFER" | "RETURN" | "ADJUSTMENT" | "REJECTION" | "SALES";
|
|
2026
2026
|
quantity: number;
|
|
2027
2027
|
quantityBefore: number;
|
|
2028
2028
|
quantityAfter: number;
|
|
@@ -3410,7 +3410,7 @@ export declare const app: Elysia<"", {
|
|
|
3410
3410
|
paymentPackageId?: string | null | undefined;
|
|
3411
3411
|
state: "NOT_PAID" | "PENDING" | "FAILED" | "EXPIRED" | "PAID" | "DECLINED" | "CANCELED" | "REFUNDING" | "REFUNDED";
|
|
3412
3412
|
cpOrderId: string;
|
|
3413
|
-
paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE";
|
|
3413
|
+
paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE" | "CARD";
|
|
3414
3414
|
paymentChannel: string;
|
|
3415
3415
|
amount: number;
|
|
3416
3416
|
};
|
|
@@ -3426,7 +3426,7 @@ export declare const app: Elysia<"", {
|
|
|
3426
3426
|
state: "NOT_PAID" | "PENDING" | "FAILED" | "EXPIRED" | "PAID" | "DECLINED" | "CANCELED" | "REFUNDING" | "REFUNDED";
|
|
3427
3427
|
cpOrderId: string;
|
|
3428
3428
|
paymentPackageId: string | null;
|
|
3429
|
-
paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE";
|
|
3429
|
+
paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE" | "CARD";
|
|
3430
3430
|
paymentChannel: string;
|
|
3431
3431
|
amount: number;
|
|
3432
3432
|
invoiceNumber: string | null;
|
|
@@ -3490,7 +3490,7 @@ export declare const app: Elysia<"", {
|
|
|
3490
3490
|
state: "NOT_PAID" | "PENDING" | "FAILED" | "EXPIRED" | "PAID" | "DECLINED" | "CANCELED" | "REFUNDING" | "REFUNDED";
|
|
3491
3491
|
cpOrderId: string;
|
|
3492
3492
|
paymentPackageId: string | null;
|
|
3493
|
-
paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE";
|
|
3493
|
+
paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE" | "CARD";
|
|
3494
3494
|
paymentChannel: string;
|
|
3495
3495
|
amount: number;
|
|
3496
3496
|
invoiceNumber: string | null;
|
|
@@ -3549,7 +3549,7 @@ export declare const app: Elysia<"", {
|
|
|
3549
3549
|
paymentPackageId?: string | null | undefined;
|
|
3550
3550
|
state: "NOT_PAID" | "PENDING" | "FAILED" | "EXPIRED" | "PAID" | "DECLINED" | "CANCELED" | "REFUNDING" | "REFUNDED";
|
|
3551
3551
|
cpOrderId: string;
|
|
3552
|
-
paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE";
|
|
3552
|
+
paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE" | "CARD";
|
|
3553
3553
|
paymentChannel: string;
|
|
3554
3554
|
amount: number;
|
|
3555
3555
|
};
|
|
@@ -3566,7 +3566,7 @@ export declare const app: Elysia<"", {
|
|
|
3566
3566
|
state: "NOT_PAID" | "PENDING" | "FAILED" | "EXPIRED" | "PAID" | "DECLINED" | "CANCELED" | "REFUNDING" | "REFUNDED";
|
|
3567
3567
|
cpOrderId: string;
|
|
3568
3568
|
paymentPackageId: string | null;
|
|
3569
|
-
paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE";
|
|
3569
|
+
paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE" | "CARD";
|
|
3570
3570
|
paymentChannel: string;
|
|
3571
3571
|
amount: number;
|
|
3572
3572
|
invoiceNumber: string | null;
|
|
@@ -3655,7 +3655,7 @@ export declare const app: Elysia<"", {
|
|
|
3655
3655
|
paymentPackageId?: string | null | undefined;
|
|
3656
3656
|
state: "NOT_PAID" | "PENDING" | "FAILED" | "EXPIRED" | "PAID" | "DECLINED" | "CANCELED" | "REFUNDING" | "REFUNDED";
|
|
3657
3657
|
cpOrderId: string;
|
|
3658
|
-
paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE";
|
|
3658
|
+
paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE" | "CARD";
|
|
3659
3659
|
paymentChannel: string;
|
|
3660
3660
|
amount: number;
|
|
3661
3661
|
};
|
|
@@ -3672,7 +3672,7 @@ export declare const app: Elysia<"", {
|
|
|
3672
3672
|
state: "NOT_PAID" | "PENDING" | "FAILED" | "EXPIRED" | "PAID" | "DECLINED" | "CANCELED" | "REFUNDING" | "REFUNDED";
|
|
3673
3673
|
cpOrderId: string;
|
|
3674
3674
|
paymentPackageId: string | null;
|
|
3675
|
-
paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE";
|
|
3675
|
+
paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE" | "CARD";
|
|
3676
3676
|
paymentChannel: string;
|
|
3677
3677
|
amount: number;
|
|
3678
3678
|
invoiceNumber: string | null;
|
|
@@ -4179,7 +4179,7 @@ export declare const app: Elysia<"", {
|
|
|
4179
4179
|
payments: {
|
|
4180
4180
|
cpOrderId: string;
|
|
4181
4181
|
paymentPackageId: string | null;
|
|
4182
|
-
paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE";
|
|
4182
|
+
paymentMethod: "CASH" | "BANK_TRANSFER" | "POS_TERMINAL" | "PAYMENT_PACKAGE" | "CARD";
|
|
4183
4183
|
paymentChannel: string;
|
|
4184
4184
|
amount: number;
|
|
4185
4185
|
state: "NOT_PAID" | "PENDING" | "FAILED" | "EXPIRED" | "PAID" | "DECLINED" | "CANCELED" | "REFUNDING" | "REFUNDED";
|
|
@@ -4452,7 +4452,6 @@ export declare const app: Elysia<"", {
|
|
|
4452
4452
|
product: {
|
|
4453
4453
|
post: {
|
|
4454
4454
|
body: {
|
|
4455
|
-
priceTotal?: number | undefined;
|
|
4456
4455
|
spPackageId: string;
|
|
4457
4456
|
quantity: number;
|
|
4458
4457
|
priceUnit: number;
|
|
@@ -4490,7 +4489,6 @@ export declare const app: Elysia<"", {
|
|
|
4490
4489
|
many: {
|
|
4491
4490
|
post: {
|
|
4492
4491
|
body: {
|
|
4493
|
-
priceTotal?: number | undefined;
|
|
4494
4492
|
spPackageId: string;
|
|
4495
4493
|
quantity: number;
|
|
4496
4494
|
priceUnit: number;
|
package/dist/index.js
CHANGED
|
@@ -137672,6 +137672,12 @@ __export(exports_schema, {
|
|
|
137672
137672
|
crmSchema: () => crmSchema,
|
|
137673
137673
|
crmPaymentTypeEnum: () => crmPaymentTypeEnum,
|
|
137674
137674
|
crmPaymentTable: () => crmPaymentTable,
|
|
137675
|
+
crmDiscountTypeEnum: () => crmDiscountTypeEnum,
|
|
137676
|
+
crmDiscountTable: () => crmDiscountTable,
|
|
137677
|
+
crmDiscountConditionTypeEnum: () => crmDiscountConditionTypeEnum,
|
|
137678
|
+
crmDiscountConditionTable: () => crmDiscountConditionTable,
|
|
137679
|
+
crmDiscountApplyTypeEnum: () => crmDiscountApplyTypeEnum,
|
|
137680
|
+
crmDiscountApplyTable: () => crmDiscountApplyTable,
|
|
137675
137681
|
crmCustomerVehicleTable: () => crmCustomerVehicleTable,
|
|
137676
137682
|
crmCustomerTable: () => crmCustomerTable,
|
|
137677
137683
|
crmCustomerRelations: () => crmCustomerRelations,
|
|
@@ -137918,7 +137924,7 @@ var crmSpPackageProductTable = crmSchema.table("sp_package_product", {
|
|
|
137918
137924
|
companyProductId: uuid().notNull(),
|
|
137919
137925
|
quantity: integer().notNull(),
|
|
137920
137926
|
priceUnit: numeric({ mode: "number" }).notNull(),
|
|
137921
|
-
priceTotal: numeric({ mode: "number" }).notNull()
|
|
137927
|
+
priceTotal: numeric({ mode: "number" }).notNull()
|
|
137922
137928
|
}, (t2) => [unique().on(t2.spPackageId, t2.companyProductId)]);
|
|
137923
137929
|
var crmCpOrderStateEnum = pgEnum("cp_order_state", [
|
|
137924
137930
|
"CREATED",
|
|
@@ -137966,7 +137972,8 @@ var crmCpOrderPaymentMethodEnum = crmSchema.enum("payment_method", [
|
|
|
137966
137972
|
"CASH",
|
|
137967
137973
|
"BANK_TRANSFER",
|
|
137968
137974
|
"POS_TERMINAL",
|
|
137969
|
-
"PAYMENT_PACKAGE"
|
|
137975
|
+
"PAYMENT_PACKAGE",
|
|
137976
|
+
"CARD"
|
|
137970
137977
|
]);
|
|
137971
137978
|
var crmCpOrderPaymentStateEnum = crmSchema.enum("payment_state", [
|
|
137972
137979
|
"NOT_PAID",
|
|
@@ -138006,6 +138013,52 @@ var crmCpOrderPaymentTable = crmSchema.table("cp_order_payment", {
|
|
|
138006
138013
|
state: crmCpOrderPaymentStateEnum().notNull(),
|
|
138007
138014
|
invoiceNumber: varchar()
|
|
138008
138015
|
});
|
|
138016
|
+
var crmDiscountTypeEnum = crmSchema.enum("discount_type", [
|
|
138017
|
+
"PERCENTAGE",
|
|
138018
|
+
"FIXED"
|
|
138019
|
+
]);
|
|
138020
|
+
var crmDiscountApplyTypeEnum = crmSchema.enum("discount_apply_type", [
|
|
138021
|
+
"ORDER",
|
|
138022
|
+
"ITEM"
|
|
138023
|
+
]);
|
|
138024
|
+
var crmDiscountTable = crmSchema.table("discount", {
|
|
138025
|
+
...base_schema_helper_default,
|
|
138026
|
+
companyId: uuid().notNull(),
|
|
138027
|
+
name: varchar().notNull(),
|
|
138028
|
+
description: varchar(),
|
|
138029
|
+
applyType: crmDiscountApplyTypeEnum().notNull(),
|
|
138030
|
+
discountType: crmDiscountTypeEnum().notNull(),
|
|
138031
|
+
timeStart: timestamp({ withTimezone: true }).notNull(),
|
|
138032
|
+
timeEnd: timestamp({ withTimezone: true }).notNull(),
|
|
138033
|
+
state: varchar()
|
|
138034
|
+
});
|
|
138035
|
+
var crmDiscountConditionTypeEnum = crmSchema.enum("discount_condition_type", [
|
|
138036
|
+
"MIN_TOTAL",
|
|
138037
|
+
"PRODUCT_CATEGORY",
|
|
138038
|
+
"CUSTOMER_GROUP",
|
|
138039
|
+
"PAYMENT_METHOD",
|
|
138040
|
+
"DATE_RANGE",
|
|
138041
|
+
"ITEM_QUANTITY",
|
|
138042
|
+
"COUPON_CODE"
|
|
138043
|
+
]);
|
|
138044
|
+
var crmDiscountConditionTable = crmSchema.table("discount_condition", {
|
|
138045
|
+
...base_schema_helper_default,
|
|
138046
|
+
discountId: uuid().notNull(),
|
|
138047
|
+
conditionType: crmDiscountConditionTypeEnum().notNull(),
|
|
138048
|
+
conditionValue: varchar()
|
|
138049
|
+
});
|
|
138050
|
+
var crmDiscountApplyTable = crmSchema.table("discount_apply", {
|
|
138051
|
+
...base_schema_helper_default,
|
|
138052
|
+
discountId: uuid().notNull(),
|
|
138053
|
+
cpOrderId: uuid().notNull(),
|
|
138054
|
+
cpOrderItemId: uuid(),
|
|
138055
|
+
valueApplied: varchar(),
|
|
138056
|
+
priceBeforeDiscount: numeric({ mode: "number" }).notNull(),
|
|
138057
|
+
priceAfterDiscount: numeric({ mode: "number" }).notNull(),
|
|
138058
|
+
note: varchar(),
|
|
138059
|
+
authUserId: text().notNull(),
|
|
138060
|
+
employeeId: uuid().notNull()
|
|
138061
|
+
});
|
|
138009
138062
|
// src/lib/db/schema/techdoc.schema.ts
|
|
138010
138063
|
var techdocSchema = pgSchema("techdoc");
|
|
138011
138064
|
var techdocVehicleKindEnum = pgEnum("vehicle_kind_enum", [
|
|
@@ -140989,7 +141042,14 @@ var auth2 = betterAuth({
|
|
|
140989
141042
|
}
|
|
140990
141043
|
}
|
|
140991
141044
|
},
|
|
140992
|
-
trustedOrigins: ["http://192.168.0.117:3000"]
|
|
141045
|
+
trustedOrigins: ["http://192.168.0.117:3000"],
|
|
141046
|
+
logger: {
|
|
141047
|
+
log(level, ...args) {
|
|
141048
|
+
if (level === "error" && args[0] === "Error" && args.length === 2 && args[1] instanceof Error && args[1].message === "NOT_FOUND")
|
|
141049
|
+
return;
|
|
141050
|
+
console[level](...args);
|
|
141051
|
+
}
|
|
141052
|
+
}
|
|
140993
141053
|
});
|
|
140994
141054
|
var _schema;
|
|
140995
141055
|
var getSchema2 = async () => _schema ??= auth2.api.generateOpenAPISchema();
|
|
@@ -143794,12 +143854,14 @@ class PaymentGateway {
|
|
|
143794
143854
|
}
|
|
143795
143855
|
this.token = token;
|
|
143796
143856
|
if (this.paymentId) {
|
|
143797
|
-
await db_default.update(crmPaymentTable).set({
|
|
143857
|
+
const [updated] = await db_default.update(crmPaymentTable).set({
|
|
143798
143858
|
accessToken: token.access_token,
|
|
143799
143859
|
refreshToken: token.refresh_token,
|
|
143800
143860
|
expiresIn: token.expires_in,
|
|
143801
143861
|
refreshExpiresIn: token.refresh_expires_in
|
|
143802
|
-
}).where(eq(crmPaymentTable.id, this.paymentId));
|
|
143862
|
+
}).where(eq(crmPaymentTable.id, this.paymentId)).returning();
|
|
143863
|
+
const cacheKey = `crm_payment:${updated.companyId}:${updated.type}:${updated.branchId ?? "null"}`;
|
|
143864
|
+
await redis_client_default.set(cacheKey, updated);
|
|
143803
143865
|
}
|
|
143804
143866
|
}
|
|
143805
143867
|
async getPaymentById(id) {
|
|
@@ -143990,19 +144052,7 @@ var CrmCpOrderPaymentLogic;
|
|
|
143990
144052
|
const gateway = new QpayGateway([
|
|
143991
144053
|
auth3.username,
|
|
143992
144054
|
auth3.password,
|
|
143993
|
-
auth3.invoiceCode
|
|
143994
|
-
async (token) => {
|
|
143995
|
-
await db_default.update(crmPaymentTable).set({
|
|
143996
|
-
accessToken: token.access_token,
|
|
143997
|
-
refreshToken: token.refresh_token,
|
|
143998
|
-
expiresIn: token.expires_in,
|
|
143999
|
-
refreshExpiresIn: token.refresh_expires_in
|
|
144000
|
-
}).where(eq(crmPaymentTable.id, paymentInfo.id));
|
|
144001
|
-
paymentInfo.accessToken = token.access_token;
|
|
144002
|
-
paymentInfo.refreshToken = token.refresh_token;
|
|
144003
|
-
paymentInfo.expiresIn = token.expires_in;
|
|
144004
|
-
paymentInfo.refreshExpiresIn = token.refresh_expires_in ?? 0;
|
|
144005
|
-
}
|
|
144055
|
+
auth3.invoiceCode
|
|
144006
144056
|
]);
|
|
144007
144057
|
gateway.setToken(paymentInfo);
|
|
144008
144058
|
try {
|
|
@@ -144139,10 +144189,16 @@ var CrmCpOrderPaymentLogic;
|
|
|
144139
144189
|
}
|
|
144140
144190
|
};
|
|
144141
144191
|
const getPaymentInfo = async (type, user2) => {
|
|
144192
|
+
const cacheKey = `crm_payment:${user2.companyId}:${type}:${user2.branchId ?? "null"}`;
|
|
144193
|
+
const cached = await redis_client_default.get(cacheKey);
|
|
144194
|
+
if (cached) {
|
|
144195
|
+
return cached;
|
|
144196
|
+
}
|
|
144142
144197
|
const [payment] = await db_default.select().from(crmPaymentTable).where(and(eq(crmPaymentTable.companyId, user2.companyId), eq(crmPaymentTable.type, type), or(isNull2(crmPaymentTable.branchId), eq(crmPaymentTable.branchId, user2.branchId)))).limit(1);
|
|
144143
144198
|
if (!payment) {
|
|
144144
144199
|
return status("Not Found", "\u0422\u04E9\u043B\u0431\u04E9\u0440\u0438\u0439\u043D \u0442\u043E\u0445\u0438\u0440\u0433\u043E\u043E \u043E\u043B\u0434\u0441\u043E\u043D\u0433\u04AF\u0439.");
|
|
144145
144200
|
}
|
|
144201
|
+
await redis_client_default.set(cacheKey, payment);
|
|
144146
144202
|
return payment;
|
|
144147
144203
|
};
|
|
144148
144204
|
const getPaymentInfoByPaymentId = async (id, type) => {
|
|
@@ -144318,8 +144374,9 @@ var CrmCpOrderItemLogic;
|
|
|
144318
144374
|
if (curr.length > 0) {
|
|
144319
144375
|
const [updated] = await db_default.update(crmCpOrderItemTable).set({
|
|
144320
144376
|
...body,
|
|
144377
|
+
quantity: sql3`${crmCpOrderItemTable.quantity} + ${body.quantity}`,
|
|
144321
144378
|
priceUnit: sk?.price ?? product?.product.priceSell ?? 0,
|
|
144322
|
-
priceTotal: body.quantity * (sk?.price ?? product?.product.priceSell ?? 0)
|
|
144379
|
+
priceTotal: sql3`${crmCpOrderItemTable.quantity} * ${body.quantity * (sk?.price ?? product?.product.priceSell ?? 0)}`
|
|
144323
144380
|
}).where(eq(crmCpOrderItemTable.id, curr[0].id)).returning();
|
|
144324
144381
|
return updated;
|
|
144325
144382
|
}
|
|
@@ -144825,16 +144882,25 @@ var CrmSpPackageProductLogic;
|
|
|
144825
144882
|
return result;
|
|
144826
144883
|
};
|
|
144827
144884
|
CrmSpPackageProductLogic.create = async (body) => {
|
|
144828
|
-
const [result] = await db_default.insert(crmSpPackageProductTable).values(
|
|
144885
|
+
const [result] = await db_default.insert(crmSpPackageProductTable).values({
|
|
144886
|
+
...body,
|
|
144887
|
+
priceTotal: body.quantity * body.priceUnit
|
|
144888
|
+
}).returning();
|
|
144829
144889
|
return result;
|
|
144830
144890
|
};
|
|
144831
144891
|
CrmSpPackageProductLogic.createMany = async (body) => {
|
|
144832
144892
|
if (body.length === 0) {
|
|
144833
144893
|
return status("Bad Request", "\u0411\u04AF\u0442\u044D\u044D\u0433\u0434\u044D\u0445\u04AF\u04AF\u043D \u043E\u0440\u0443\u0443\u043B\u0430\u0445 \u043C\u044D\u0434\u044D\u044D\u043B\u044D\u043B \u0431\u0430\u0439\u0445\u0433\u04AF\u0439 \u0431\u0430\u0439\u043D\u0430.");
|
|
144834
144894
|
}
|
|
144895
|
+
console.dir(body, {
|
|
144896
|
+
depth: Infinity
|
|
144897
|
+
});
|
|
144835
144898
|
await db_default.transaction(async (db2) => {
|
|
144836
144899
|
await db2.delete(crmSpPackageProductTable).where(eq(crmSpPackageProductTable.spPackageId, body[0].spPackageId));
|
|
144837
|
-
await db2.insert(crmSpPackageProductTable).values(body)
|
|
144900
|
+
await db2.insert(crmSpPackageProductTable).values(body.map((i2) => ({
|
|
144901
|
+
...i2,
|
|
144902
|
+
priceTotal: i2.quantity * i2.priceUnit
|
|
144903
|
+
})));
|
|
144838
144904
|
});
|
|
144839
144905
|
};
|
|
144840
144906
|
CrmSpPackageProductLogic.update = async (id, body) => {
|
|
@@ -144858,7 +144924,7 @@ var CrmSpPackageProductModel;
|
|
|
144858
144924
|
const createSchema = createInsertSchema(crmSpPackageProductTable);
|
|
144859
144925
|
const updateSchema = createUpdateSchema(crmSpPackageProductTable);
|
|
144860
144926
|
const selectSchema = createSelectSchema(crmSpPackageProductTable);
|
|
144861
|
-
CrmSpPackageProductModel.create = OmitBaseSchema(createSchema);
|
|
144927
|
+
CrmSpPackageProductModel.create = t.Omit(OmitBaseSchema(createSchema), ["priceTotal"]);
|
|
144862
144928
|
CrmSpPackageProductModel.update = OmitBaseSchema(updateSchema);
|
|
144863
144929
|
CrmSpPackageProductModel.select = t.Pick(selectSchema, ["spPackageId"]);
|
|
144864
144930
|
})(CrmSpPackageProductModel ||= {});
|