@mamindom/contracts 1.0.152 → 1.0.155
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/events/orders/index.d.ts +1 -0
- package/dist/events/orders/index.js +1 -0
- package/dist/events/orders/order-cancelled.interface.d.ts +1 -0
- package/dist/events/orders/order-created.interface.d.ts +5 -5
- package/dist/events/orders/order-crm.interface.d.ts +24 -0
- package/dist/events/orders/order-crm.interface.js +2 -0
- package/dist/events/orders/order-status-changed.interface.d.ts +1 -0
- package/dist/events/payments/payment-cancelled.interface.d.ts +1 -1
- package/dist/events/payments/payment-captured.interface.d.ts +2 -2
- package/dist/events/payments/payment-failed.interface.d.ts +1 -1
- package/dist/events/payments/payment-held.interface.d.ts +1 -1
- package/dist/events/payments/payment-refunded.interface.d.ts +3 -3
- package/dist/gen/cart.d.ts +7 -0
- package/dist/gen/cart.js +1 -0
- package/dist/gen/crm_calculation.d.ts +98 -0
- package/dist/gen/crm_calculation.js +28 -0
- package/dist/gen/order.d.ts +18 -0
- package/dist/gen/order.js +2 -0
- package/dist/gen/users.d.ts +1 -0
- package/dist/proto/cart.proto +11 -0
- package/dist/proto/crm_calculation.proto +122 -0
- package/dist/proto/order.proto +27 -0
- package/dist/proto/users.proto +2 -0
- package/dist/src/proto/paths.d.ts +1 -0
- package/dist/src/proto/paths.js +1 -0
- package/events/orders/index.ts +1 -0
- package/events/orders/order-cancelled.interface.ts +2 -0
- package/events/orders/order-created.interface.ts +5 -5
- package/events/orders/order-crm.interface.ts +26 -0
- package/events/orders/order-status-changed.interface.ts +2 -0
- package/events/payments/payment-cancelled.interface.ts +1 -1
- package/events/payments/payment-captured.interface.ts +2 -2
- package/events/payments/payment-failed.interface.ts +1 -1
- package/events/payments/payment-held.interface.ts +1 -1
- package/events/payments/payment-refunded.interface.ts +3 -3
- package/gen/cart.ts +13 -0
- package/gen/crm_calculation.ts +151 -0
- package/gen/order.ts +26 -0
- package/gen/users.ts +1 -0
- package/package.json +1 -1
- package/proto/cart.proto +11 -0
- package/proto/crm_calculation.proto +122 -0
- package/proto/order.proto +27 -0
- package/proto/users.proto +2 -0
|
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./order-cancelled.interface"), exports);
|
|
18
18
|
__exportStar(require("./order-created.interface"), exports);
|
|
19
19
|
__exportStar(require("./order-status-changed.interface"), exports);
|
|
20
|
+
__exportStar(require("./order-crm.interface"), exports);
|
|
@@ -5,16 +5,16 @@ export interface OrderCreatedEvent {
|
|
|
5
5
|
guestId?: string;
|
|
6
6
|
source: string;
|
|
7
7
|
totals: {
|
|
8
|
-
grandTotal:
|
|
9
|
-
shippingCost:
|
|
10
|
-
bonusesEarned:
|
|
8
|
+
grandTotal: string;
|
|
9
|
+
shippingCost: string;
|
|
10
|
+
bonusesEarned: string;
|
|
11
11
|
};
|
|
12
12
|
items: Array<{
|
|
13
13
|
productId: string;
|
|
14
14
|
variantId?: string;
|
|
15
15
|
sku: string;
|
|
16
16
|
quantity: number;
|
|
17
|
-
price:
|
|
17
|
+
price: string;
|
|
18
18
|
}>;
|
|
19
19
|
delivery: {
|
|
20
20
|
method: string;
|
|
@@ -24,7 +24,7 @@ export interface OrderCreatedEvent {
|
|
|
24
24
|
};
|
|
25
25
|
payment: {
|
|
26
26
|
provider: string;
|
|
27
|
-
amount:
|
|
27
|
+
amount: string;
|
|
28
28
|
idempotencyKey: string;
|
|
29
29
|
};
|
|
30
30
|
customer: {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface OrderCrmPlacedEvent {
|
|
2
|
+
orderId: string;
|
|
3
|
+
orderNumber: string;
|
|
4
|
+
userId?: string;
|
|
5
|
+
cartSessionId?: string;
|
|
6
|
+
placedAt: number;
|
|
7
|
+
grandTotal: string;
|
|
8
|
+
bonusesUsed: string;
|
|
9
|
+
items: Array<{
|
|
10
|
+
productId: string;
|
|
11
|
+
variantId?: string;
|
|
12
|
+
quantity: number;
|
|
13
|
+
price: string;
|
|
14
|
+
lineTotal: string;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
export interface OrderSaleRecordedEvent {
|
|
18
|
+
orderId: string;
|
|
19
|
+
invoiceId: string;
|
|
20
|
+
pickupPointId?: string;
|
|
21
|
+
totalAmount: string;
|
|
22
|
+
saleDate: string;
|
|
23
|
+
recordedAt: number;
|
|
24
|
+
}
|
|
@@ -3,9 +3,9 @@ export interface PaymentRefundedEvent {
|
|
|
3
3
|
orderId: string;
|
|
4
4
|
provider: string;
|
|
5
5
|
providerInvoiceId: string;
|
|
6
|
-
refundAmount:
|
|
7
|
-
totalRefunded:
|
|
8
|
-
originalAmount:
|
|
6
|
+
refundAmount: string;
|
|
7
|
+
totalRefunded: string;
|
|
8
|
+
originalAmount: string;
|
|
9
9
|
isPartial: boolean;
|
|
10
10
|
reason?: string;
|
|
11
11
|
refundedAt: number;
|
package/dist/gen/cart.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Observable } from "rxjs";
|
|
2
|
+
import { CalculateCartResponse } from "./crm_calculation";
|
|
2
3
|
export declare const protobufPackage = "cart.v1";
|
|
3
4
|
export interface CartItem {
|
|
4
5
|
productId: string;
|
|
@@ -113,6 +114,10 @@ export interface CartOwner {
|
|
|
113
114
|
export interface GetCartRequest {
|
|
114
115
|
owner: CartOwner | undefined;
|
|
115
116
|
}
|
|
117
|
+
export interface CalculateCrmRequest {
|
|
118
|
+
owner: CartOwner | undefined;
|
|
119
|
+
calculationDate: string;
|
|
120
|
+
}
|
|
116
121
|
export interface ClearCartRequest {
|
|
117
122
|
owner: CartOwner | undefined;
|
|
118
123
|
}
|
|
@@ -224,6 +229,7 @@ export interface CartServiceClient {
|
|
|
224
229
|
setComment(request: SetCommentRequest): Observable<CartResponse>;
|
|
225
230
|
setCheckoutDraft(request: SetCheckoutDraftRequest): Observable<CartResponse>;
|
|
226
231
|
recalculate(request: RecalculateRequest): Observable<CartResponse>;
|
|
232
|
+
calculateCrm(request: CalculateCrmRequest): Observable<CalculateCartResponse>;
|
|
227
233
|
mergeGuestToUser(request: MergeGuestToUserRequest): Observable<CartResponse>;
|
|
228
234
|
addToWishlist(request: WishlistItemRequest): Observable<WishlistResponse>;
|
|
229
235
|
removeFromWishlist(request: WishlistItemRequest): Observable<WishlistResponse>;
|
|
@@ -247,6 +253,7 @@ export interface CartServiceController {
|
|
|
247
253
|
setComment(request: SetCommentRequest): Promise<CartResponse> | Observable<CartResponse> | CartResponse;
|
|
248
254
|
setCheckoutDraft(request: SetCheckoutDraftRequest): Promise<CartResponse> | Observable<CartResponse> | CartResponse;
|
|
249
255
|
recalculate(request: RecalculateRequest): Promise<CartResponse> | Observable<CartResponse> | CartResponse;
|
|
256
|
+
calculateCrm(request: CalculateCrmRequest): Promise<CalculateCartResponse> | Observable<CalculateCartResponse> | CalculateCartResponse;
|
|
250
257
|
mergeGuestToUser(request: MergeGuestToUserRequest): Promise<CartResponse> | Observable<CartResponse> | CartResponse;
|
|
251
258
|
addToWishlist(request: WishlistItemRequest): Promise<WishlistResponse> | Observable<WishlistResponse> | WishlistResponse;
|
|
252
259
|
removeFromWishlist(request: WishlistItemRequest): Promise<WishlistResponse> | Observable<WishlistResponse> | WishlistResponse;
|
package/dist/gen/cart.js
CHANGED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
export declare const protobufPackage = "crm.v1";
|
|
3
|
+
export interface CrmCalculationItem {
|
|
4
|
+
productId: string;
|
|
5
|
+
variantId: string;
|
|
6
|
+
categoryId: string;
|
|
7
|
+
brandId: string;
|
|
8
|
+
quantity: number;
|
|
9
|
+
unitPrice: number;
|
|
10
|
+
subtotal: number;
|
|
11
|
+
}
|
|
12
|
+
export interface CalculateCartRequest {
|
|
13
|
+
cartSessionId: string;
|
|
14
|
+
userId: string;
|
|
15
|
+
items: CrmCalculationItem[];
|
|
16
|
+
bonusToSpend: number;
|
|
17
|
+
totalAmount: number;
|
|
18
|
+
calculationDate: string;
|
|
19
|
+
orderId: string;
|
|
20
|
+
couponCodes: string[];
|
|
21
|
+
businessUnitEntryId: string;
|
|
22
|
+
}
|
|
23
|
+
export interface CrmCalculatedItem {
|
|
24
|
+
productId: string;
|
|
25
|
+
variantId: string;
|
|
26
|
+
quantity: number;
|
|
27
|
+
unitPrice: number;
|
|
28
|
+
lineTotal: number;
|
|
29
|
+
discountAmount: number;
|
|
30
|
+
promotionName: string;
|
|
31
|
+
}
|
|
32
|
+
export interface CrmAppliedPromotion {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
discountAmount: number;
|
|
36
|
+
}
|
|
37
|
+
export interface CrmPromoError {
|
|
38
|
+
code: string;
|
|
39
|
+
message: string;
|
|
40
|
+
}
|
|
41
|
+
export interface CalculateCartResponse {
|
|
42
|
+
source: string;
|
|
43
|
+
degraded: boolean;
|
|
44
|
+
parsed: boolean;
|
|
45
|
+
subtotal: number;
|
|
46
|
+
discountTotal: number;
|
|
47
|
+
total: number;
|
|
48
|
+
bonusToDeduct: number;
|
|
49
|
+
bonusMaxSpend: number;
|
|
50
|
+
cashbackToEarn: number;
|
|
51
|
+
items: CrmCalculatedItem[];
|
|
52
|
+
promotions: CrmAppliedPromotion[];
|
|
53
|
+
promoErrors: CrmPromoError[];
|
|
54
|
+
crmTaskId: string;
|
|
55
|
+
crmCommentId: string;
|
|
56
|
+
rawResult: string;
|
|
57
|
+
durationMs: number;
|
|
58
|
+
}
|
|
59
|
+
export interface ReserveBonusesRequest {
|
|
60
|
+
userId: string;
|
|
61
|
+
cartSessionId: string;
|
|
62
|
+
amount: number;
|
|
63
|
+
}
|
|
64
|
+
export interface ReserveBonusesResponse {
|
|
65
|
+
success: boolean;
|
|
66
|
+
reserveId: string;
|
|
67
|
+
expiresAt: number;
|
|
68
|
+
available: number;
|
|
69
|
+
error: string;
|
|
70
|
+
}
|
|
71
|
+
export interface ReleaseBonusReserveRequest {
|
|
72
|
+
reserveId: string;
|
|
73
|
+
cartSessionId: string;
|
|
74
|
+
}
|
|
75
|
+
export interface ReleaseBonusReserveResponse {
|
|
76
|
+
success: boolean;
|
|
77
|
+
}
|
|
78
|
+
export interface InvalidateCartSessionRequest {
|
|
79
|
+
cartSessionId: string;
|
|
80
|
+
}
|
|
81
|
+
export interface InvalidateCartSessionResponse {
|
|
82
|
+
success: boolean;
|
|
83
|
+
}
|
|
84
|
+
export declare const CRM_V1_PACKAGE_NAME = "crm.v1";
|
|
85
|
+
export interface CrmCalculationServiceClient {
|
|
86
|
+
calculateCart(request: CalculateCartRequest): Observable<CalculateCartResponse>;
|
|
87
|
+
invalidateCartSession(request: InvalidateCartSessionRequest): Observable<InvalidateCartSessionResponse>;
|
|
88
|
+
reserveBonuses(request: ReserveBonusesRequest): Observable<ReserveBonusesResponse>;
|
|
89
|
+
releaseBonusReserve(request: ReleaseBonusReserveRequest): Observable<ReleaseBonusReserveResponse>;
|
|
90
|
+
}
|
|
91
|
+
export interface CrmCalculationServiceController {
|
|
92
|
+
calculateCart(request: CalculateCartRequest): Promise<CalculateCartResponse> | Observable<CalculateCartResponse> | CalculateCartResponse;
|
|
93
|
+
invalidateCartSession(request: InvalidateCartSessionRequest): Promise<InvalidateCartSessionResponse> | Observable<InvalidateCartSessionResponse> | InvalidateCartSessionResponse;
|
|
94
|
+
reserveBonuses(request: ReserveBonusesRequest): Promise<ReserveBonusesResponse> | Observable<ReserveBonusesResponse> | ReserveBonusesResponse;
|
|
95
|
+
releaseBonusReserve(request: ReleaseBonusReserveRequest): Promise<ReleaseBonusReserveResponse> | Observable<ReleaseBonusReserveResponse> | ReleaseBonusReserveResponse;
|
|
96
|
+
}
|
|
97
|
+
export declare function CrmCalculationServiceControllerMethods(): (constructor: Function) => void;
|
|
98
|
+
export declare const CRM_CALCULATION_SERVICE_NAME = "CrmCalculationService";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
|
+
// versions:
|
|
4
|
+
// protoc-gen-ts_proto v2.11.4
|
|
5
|
+
// protoc v3.21.12
|
|
6
|
+
// source: crm_calculation.proto
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.CRM_CALCULATION_SERVICE_NAME = exports.CRM_V1_PACKAGE_NAME = exports.protobufPackage = void 0;
|
|
9
|
+
exports.CrmCalculationServiceControllerMethods = CrmCalculationServiceControllerMethods;
|
|
10
|
+
/* eslint-disable */
|
|
11
|
+
const microservices_1 = require("@nestjs/microservices");
|
|
12
|
+
exports.protobufPackage = "crm.v1";
|
|
13
|
+
exports.CRM_V1_PACKAGE_NAME = "crm.v1";
|
|
14
|
+
function CrmCalculationServiceControllerMethods() {
|
|
15
|
+
return function (constructor) {
|
|
16
|
+
const grpcMethods = ["calculateCart", "invalidateCartSession", "reserveBonuses", "releaseBonusReserve"];
|
|
17
|
+
for (const method of grpcMethods) {
|
|
18
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
19
|
+
(0, microservices_1.GrpcMethod)("CrmCalculationService", method)(constructor.prototype[method], method, descriptor);
|
|
20
|
+
}
|
|
21
|
+
const grpcStreamMethods = [];
|
|
22
|
+
for (const method of grpcStreamMethods) {
|
|
23
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
24
|
+
(0, microservices_1.GrpcStreamMethod)("CrmCalculationService", method)(constructor.prototype[method], method, descriptor);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exports.CRM_CALCULATION_SERVICE_NAME = "CrmCalculationService";
|
package/dist/gen/order.d.ts
CHANGED
|
@@ -124,6 +124,9 @@ export interface Order {
|
|
|
124
124
|
updatedAt: number;
|
|
125
125
|
notes: OrderNote[];
|
|
126
126
|
archivedAt: number;
|
|
127
|
+
cancelledBy: string;
|
|
128
|
+
crmOrderId: string;
|
|
129
|
+
saleRecordedAt: number;
|
|
127
130
|
}
|
|
128
131
|
export interface CreateOrderRequest {
|
|
129
132
|
idempotencyKey: string;
|
|
@@ -193,12 +196,23 @@ export interface UpdateStatusRequest {
|
|
|
193
196
|
reason: string;
|
|
194
197
|
actorId: string;
|
|
195
198
|
actorName: string;
|
|
199
|
+
cancelledBy: string;
|
|
196
200
|
}
|
|
197
201
|
export interface CancelOrderRequest {
|
|
198
202
|
id: string;
|
|
199
203
|
reason: string;
|
|
200
204
|
actorId: string;
|
|
201
205
|
actorName: string;
|
|
206
|
+
cancelledBy: string;
|
|
207
|
+
}
|
|
208
|
+
export interface SetCrmOrderIdRequest {
|
|
209
|
+
id: string;
|
|
210
|
+
crmOrderId: string;
|
|
211
|
+
}
|
|
212
|
+
export interface ConfirmPickupRequest {
|
|
213
|
+
id: string;
|
|
214
|
+
actorId: string;
|
|
215
|
+
actorName: string;
|
|
202
216
|
}
|
|
203
217
|
export interface ArchiveOrderRequest {
|
|
204
218
|
id: string;
|
|
@@ -281,6 +295,8 @@ export interface OrderServiceClient {
|
|
|
281
295
|
removeTag(request: RemoveTagRequest): Observable<OrderResponse>;
|
|
282
296
|
editItems(request: EditItemsRequest): Observable<OrderResponse>;
|
|
283
297
|
setTrackingNumber(request: SetTrackingNumberRequest): Observable<OrderResponse>;
|
|
298
|
+
setCrmOrderId(request: SetCrmOrderIdRequest): Observable<OrderResponse>;
|
|
299
|
+
confirmPickup(request: ConfirmPickupRequest): Observable<OrderResponse>;
|
|
284
300
|
reorderOrder(request: ReorderOrderRequest): Observable<ReorderResponse>;
|
|
285
301
|
listHistory(request: ListHistoryRequest): Observable<ListHistoryResponse>;
|
|
286
302
|
aggregateByCustomers(request: AggregateByCustomersRequest): Observable<AggregateByCustomersResponse>;
|
|
@@ -302,6 +318,8 @@ export interface OrderServiceController {
|
|
|
302
318
|
removeTag(request: RemoveTagRequest): Promise<OrderResponse> | Observable<OrderResponse> | OrderResponse;
|
|
303
319
|
editItems(request: EditItemsRequest): Promise<OrderResponse> | Observable<OrderResponse> | OrderResponse;
|
|
304
320
|
setTrackingNumber(request: SetTrackingNumberRequest): Promise<OrderResponse> | Observable<OrderResponse> | OrderResponse;
|
|
321
|
+
setCrmOrderId(request: SetCrmOrderIdRequest): Promise<OrderResponse> | Observable<OrderResponse> | OrderResponse;
|
|
322
|
+
confirmPickup(request: ConfirmPickupRequest): Promise<OrderResponse> | Observable<OrderResponse> | OrderResponse;
|
|
305
323
|
reorderOrder(request: ReorderOrderRequest): Promise<ReorderResponse> | Observable<ReorderResponse> | ReorderResponse;
|
|
306
324
|
listHistory(request: ListHistoryRequest): Promise<ListHistoryResponse> | Observable<ListHistoryResponse> | ListHistoryResponse;
|
|
307
325
|
aggregateByCustomers(request: AggregateByCustomersRequest): Promise<AggregateByCustomersResponse> | Observable<AggregateByCustomersResponse> | AggregateByCustomersResponse;
|
package/dist/gen/order.js
CHANGED
package/dist/gen/users.d.ts
CHANGED
package/dist/proto/cart.proto
CHANGED
|
@@ -2,6 +2,8 @@ syntax = "proto3";
|
|
|
2
2
|
|
|
3
3
|
package cart.v1;
|
|
4
4
|
|
|
5
|
+
import "crm_calculation.proto";
|
|
6
|
+
|
|
5
7
|
service CartService {
|
|
6
8
|
rpc GetCart(GetCartRequest) returns (CartResponse);
|
|
7
9
|
|
|
@@ -29,6 +31,9 @@ service CartService {
|
|
|
29
31
|
|
|
30
32
|
rpc Recalculate(RecalculateRequest) returns (CartResponse);
|
|
31
33
|
|
|
34
|
+
|
|
35
|
+
rpc CalculateCrm(CalculateCrmRequest) returns (crm.v1.CalculateCartResponse);
|
|
36
|
+
|
|
32
37
|
rpc MergeGuestToUser(MergeGuestToUserRequest) returns (CartResponse);
|
|
33
38
|
|
|
34
39
|
rpc AddToWishlist(WishlistItemRequest) returns (WishlistResponse);
|
|
@@ -167,6 +172,12 @@ message GetCartRequest {
|
|
|
167
172
|
CartOwner owner = 1;
|
|
168
173
|
}
|
|
169
174
|
|
|
175
|
+
message CalculateCrmRequest {
|
|
176
|
+
CartOwner owner = 1;
|
|
177
|
+
|
|
178
|
+
string calculation_date = 2;
|
|
179
|
+
}
|
|
180
|
+
|
|
170
181
|
message ClearCartRequest {
|
|
171
182
|
CartOwner owner = 1;
|
|
172
183
|
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package crm.v1;
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
service CrmCalculationService {
|
|
7
|
+
rpc CalculateCart(CalculateCartRequest) returns (CalculateCartResponse);
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
rpc InvalidateCartSession(InvalidateCartSessionRequest) returns (InvalidateCartSessionResponse);
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
rpc ReserveBonuses(ReserveBonusesRequest) returns (ReserveBonusesResponse);
|
|
14
|
+
rpc ReleaseBonusReserve(ReleaseBonusReserveRequest) returns (ReleaseBonusReserveResponse);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
message CrmCalculationItem {
|
|
18
|
+
string product_id = 1;
|
|
19
|
+
string variant_id = 2;
|
|
20
|
+
string category_id = 3;
|
|
21
|
+
string brand_id = 4;
|
|
22
|
+
int32 quantity = 5;
|
|
23
|
+
double unit_price = 6;
|
|
24
|
+
double subtotal = 7;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
message CalculateCartRequest {
|
|
28
|
+
string cart_session_id = 1;
|
|
29
|
+
string user_id = 2;
|
|
30
|
+
repeated CrmCalculationItem items = 3;
|
|
31
|
+
double bonus_to_spend = 4;
|
|
32
|
+
double total_amount = 5;
|
|
33
|
+
|
|
34
|
+
string calculation_date = 6;
|
|
35
|
+
string order_id = 7;
|
|
36
|
+
repeated string coupon_codes = 8;
|
|
37
|
+
string business_unit_entry_id = 9;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
message CrmCalculatedItem {
|
|
41
|
+
string product_id = 1;
|
|
42
|
+
string variant_id = 2;
|
|
43
|
+
int32 quantity = 3;
|
|
44
|
+
double unit_price = 4;
|
|
45
|
+
double line_total = 5;
|
|
46
|
+
double discount_amount = 6;
|
|
47
|
+
string promotion_name = 7;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
message CrmAppliedPromotion {
|
|
51
|
+
string id = 1;
|
|
52
|
+
string name = 2;
|
|
53
|
+
double discount_amount = 3;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
message CrmPromoError {
|
|
57
|
+
string code = 1;
|
|
58
|
+
string message = 2;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
message CalculateCartResponse {
|
|
62
|
+
|
|
63
|
+
string source = 1;
|
|
64
|
+
|
|
65
|
+
bool degraded = 2;
|
|
66
|
+
|
|
67
|
+
bool parsed = 3;
|
|
68
|
+
|
|
69
|
+
double subtotal = 4;
|
|
70
|
+
double discount_total = 5;
|
|
71
|
+
double total = 6;
|
|
72
|
+
double bonus_to_deduct = 7;
|
|
73
|
+
double bonus_max_spend = 8;
|
|
74
|
+
double cashback_to_earn = 9;
|
|
75
|
+
|
|
76
|
+
repeated CrmCalculatedItem items = 10;
|
|
77
|
+
repeated CrmAppliedPromotion promotions = 11;
|
|
78
|
+
repeated CrmPromoError promo_errors = 12;
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
string crm_task_id = 13;
|
|
82
|
+
string crm_comment_id = 14;
|
|
83
|
+
|
|
84
|
+
string raw_result = 15;
|
|
85
|
+
|
|
86
|
+
int32 duration_ms = 16;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
message ReserveBonusesRequest {
|
|
90
|
+
string user_id = 1;
|
|
91
|
+
string cart_session_id = 2;
|
|
92
|
+
double amount = 3;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
message ReserveBonusesResponse {
|
|
96
|
+
bool success = 1;
|
|
97
|
+
string reserve_id = 2;
|
|
98
|
+
|
|
99
|
+
int64 expires_at = 3;
|
|
100
|
+
|
|
101
|
+
double available = 4;
|
|
102
|
+
|
|
103
|
+
string error = 5;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
message ReleaseBonusReserveRequest {
|
|
107
|
+
|
|
108
|
+
string reserve_id = 1;
|
|
109
|
+
string cart_session_id = 2;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
message ReleaseBonusReserveResponse {
|
|
113
|
+
bool success = 1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
message InvalidateCartSessionRequest {
|
|
117
|
+
string cart_session_id = 1;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
message InvalidateCartSessionResponse {
|
|
121
|
+
bool success = 1;
|
|
122
|
+
}
|
package/dist/proto/order.proto
CHANGED
|
@@ -26,6 +26,11 @@ service OrderService {
|
|
|
26
26
|
rpc EditItems(EditItemsRequest) returns (OrderResponse);
|
|
27
27
|
rpc SetTrackingNumber(SetTrackingNumberRequest) returns (OrderResponse);
|
|
28
28
|
|
|
29
|
+
|
|
30
|
+
rpc SetCrmOrderId(SetCrmOrderIdRequest) returns (OrderResponse);
|
|
31
|
+
|
|
32
|
+
rpc ConfirmPickup(ConfirmPickupRequest) returns (OrderResponse);
|
|
33
|
+
|
|
29
34
|
rpc ReorderOrder(ReorderOrderRequest) returns (ReorderResponse);
|
|
30
35
|
|
|
31
36
|
rpc ListHistory(ListHistoryRequest) returns (ListHistoryResponse);
|
|
@@ -183,6 +188,13 @@ message Order {
|
|
|
183
188
|
|
|
184
189
|
|
|
185
190
|
int64 archived_at = 23;
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
string cancelled_by = 24;
|
|
194
|
+
|
|
195
|
+
string crm_order_id = 25;
|
|
196
|
+
|
|
197
|
+
int64 sale_recorded_at = 26;
|
|
186
198
|
}
|
|
187
199
|
|
|
188
200
|
|
|
@@ -265,6 +277,8 @@ message UpdateStatusRequest {
|
|
|
265
277
|
string reason = 3;
|
|
266
278
|
string actor_id = 4;
|
|
267
279
|
string actor_name = 5;
|
|
280
|
+
|
|
281
|
+
string cancelled_by = 6;
|
|
268
282
|
}
|
|
269
283
|
|
|
270
284
|
message CancelOrderRequest {
|
|
@@ -272,6 +286,19 @@ message CancelOrderRequest {
|
|
|
272
286
|
string reason = 2;
|
|
273
287
|
string actor_id = 3;
|
|
274
288
|
string actor_name = 4;
|
|
289
|
+
|
|
290
|
+
string cancelled_by = 5;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
message SetCrmOrderIdRequest {
|
|
294
|
+
string id = 1;
|
|
295
|
+
string crm_order_id = 2;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
message ConfirmPickupRequest {
|
|
299
|
+
string id = 1;
|
|
300
|
+
string actor_id = 2;
|
|
301
|
+
string actor_name = 3;
|
|
275
302
|
}
|
|
276
303
|
|
|
277
304
|
message ArchiveOrderRequest {
|
package/dist/proto/users.proto
CHANGED
package/dist/src/proto/paths.js
CHANGED
|
@@ -40,6 +40,7 @@ exports.PROTO_PATHS = {
|
|
|
40
40
|
PAGE: (0, node_path_1.join)(__dirname, '../../proto/page.proto'),
|
|
41
41
|
SITE_SETTINGS: (0, node_path_1.join)(__dirname, '../../proto/site_settings.proto'),
|
|
42
42
|
CART: (0, node_path_1.join)(__dirname, '../../proto/cart.proto'),
|
|
43
|
+
CRM_CALCULATION: (0, node_path_1.join)(__dirname, '../../proto/crm_calculation.proto'),
|
|
43
44
|
ORDER: (0, node_path_1.join)(__dirname, '../../proto/order.proto'),
|
|
44
45
|
MANAGER: (0, node_path_1.join)(__dirname, '../../proto/manager.proto'),
|
|
45
46
|
PAYMENT: (0, node_path_1.join)(__dirname, '../../proto/payment.proto'),
|
package/events/orders/index.ts
CHANGED
|
@@ -5,16 +5,16 @@ export interface OrderCreatedEvent {
|
|
|
5
5
|
guestId?: string
|
|
6
6
|
source: string
|
|
7
7
|
totals: {
|
|
8
|
-
grandTotal:
|
|
9
|
-
shippingCost:
|
|
10
|
-
bonusesEarned:
|
|
8
|
+
grandTotal: string
|
|
9
|
+
shippingCost: string
|
|
10
|
+
bonusesEarned: string
|
|
11
11
|
}
|
|
12
12
|
items: Array<{
|
|
13
13
|
productId: string
|
|
14
14
|
variantId?: string
|
|
15
15
|
sku: string
|
|
16
16
|
quantity: number
|
|
17
|
-
price:
|
|
17
|
+
price: string
|
|
18
18
|
}>
|
|
19
19
|
delivery: {
|
|
20
20
|
method: string
|
|
@@ -24,7 +24,7 @@ export interface OrderCreatedEvent {
|
|
|
24
24
|
}
|
|
25
25
|
payment: {
|
|
26
26
|
provider: string
|
|
27
|
-
amount:
|
|
27
|
+
amount: string
|
|
28
28
|
idempotencyKey: string
|
|
29
29
|
}
|
|
30
30
|
customer: {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface OrderCrmPlacedEvent {
|
|
2
|
+
orderId: string
|
|
3
|
+
orderNumber: string
|
|
4
|
+
userId?: string
|
|
5
|
+
|
|
6
|
+
cartSessionId?: string
|
|
7
|
+
placedAt: number
|
|
8
|
+
grandTotal: string
|
|
9
|
+
bonusesUsed: string
|
|
10
|
+
items: Array<{
|
|
11
|
+
productId: string
|
|
12
|
+
variantId?: string
|
|
13
|
+
quantity: number
|
|
14
|
+
price: string
|
|
15
|
+
lineTotal: string
|
|
16
|
+
}>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface OrderSaleRecordedEvent {
|
|
20
|
+
orderId: string
|
|
21
|
+
invoiceId: string
|
|
22
|
+
pickupPointId?: string
|
|
23
|
+
totalAmount: string
|
|
24
|
+
saleDate: string
|
|
25
|
+
recordedAt: number
|
|
26
|
+
}
|
|
@@ -3,9 +3,9 @@ export interface PaymentRefundedEvent {
|
|
|
3
3
|
orderId: string
|
|
4
4
|
provider: string
|
|
5
5
|
providerInvoiceId: string
|
|
6
|
-
refundAmount:
|
|
7
|
-
totalRefunded:
|
|
8
|
-
originalAmount:
|
|
6
|
+
refundAmount: string
|
|
7
|
+
totalRefunded: string
|
|
8
|
+
originalAmount: string
|
|
9
9
|
isPartial: boolean
|
|
10
10
|
reason?: string
|
|
11
11
|
refundedAt: number
|
package/gen/cart.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
|
|
9
9
|
import { Observable } from "rxjs";
|
|
10
|
+
import { CalculateCartResponse } from "./crm_calculation";
|
|
10
11
|
|
|
11
12
|
export const protobufPackage = "cart.v1";
|
|
12
13
|
|
|
@@ -137,6 +138,11 @@ export interface GetCartRequest {
|
|
|
137
138
|
owner: CartOwner | undefined;
|
|
138
139
|
}
|
|
139
140
|
|
|
141
|
+
export interface CalculateCrmRequest {
|
|
142
|
+
owner: CartOwner | undefined;
|
|
143
|
+
calculationDate: string;
|
|
144
|
+
}
|
|
145
|
+
|
|
140
146
|
export interface ClearCartRequest {
|
|
141
147
|
owner: CartOwner | undefined;
|
|
142
148
|
}
|
|
@@ -287,6 +293,8 @@ export interface CartServiceClient {
|
|
|
287
293
|
|
|
288
294
|
recalculate(request: RecalculateRequest): Observable<CartResponse>;
|
|
289
295
|
|
|
296
|
+
calculateCrm(request: CalculateCrmRequest): Observable<CalculateCartResponse>;
|
|
297
|
+
|
|
290
298
|
mergeGuestToUser(request: MergeGuestToUserRequest): Observable<CartResponse>;
|
|
291
299
|
|
|
292
300
|
addToWishlist(request: WishlistItemRequest): Observable<WishlistResponse>;
|
|
@@ -331,6 +339,10 @@ export interface CartServiceController {
|
|
|
331
339
|
|
|
332
340
|
recalculate(request: RecalculateRequest): Promise<CartResponse> | Observable<CartResponse> | CartResponse;
|
|
333
341
|
|
|
342
|
+
calculateCrm(
|
|
343
|
+
request: CalculateCrmRequest,
|
|
344
|
+
): Promise<CalculateCartResponse> | Observable<CalculateCartResponse> | CalculateCartResponse;
|
|
345
|
+
|
|
334
346
|
mergeGuestToUser(request: MergeGuestToUserRequest): Promise<CartResponse> | Observable<CartResponse> | CartResponse;
|
|
335
347
|
|
|
336
348
|
addToWishlist(
|
|
@@ -366,6 +378,7 @@ export function CartServiceControllerMethods() {
|
|
|
366
378
|
"setComment",
|
|
367
379
|
"setCheckoutDraft",
|
|
368
380
|
"recalculate",
|
|
381
|
+
"calculateCrm",
|
|
369
382
|
"mergeGuestToUser",
|
|
370
383
|
"addToWishlist",
|
|
371
384
|
"removeFromWishlist",
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.11.4
|
|
4
|
+
// protoc v3.21.12
|
|
5
|
+
// source: crm_calculation.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
|
|
9
|
+
import { Observable } from "rxjs";
|
|
10
|
+
|
|
11
|
+
export const protobufPackage = "crm.v1";
|
|
12
|
+
|
|
13
|
+
export interface CrmCalculationItem {
|
|
14
|
+
productId: string;
|
|
15
|
+
variantId: string;
|
|
16
|
+
categoryId: string;
|
|
17
|
+
brandId: string;
|
|
18
|
+
quantity: number;
|
|
19
|
+
unitPrice: number;
|
|
20
|
+
subtotal: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface CalculateCartRequest {
|
|
24
|
+
cartSessionId: string;
|
|
25
|
+
userId: string;
|
|
26
|
+
items: CrmCalculationItem[];
|
|
27
|
+
bonusToSpend: number;
|
|
28
|
+
totalAmount: number;
|
|
29
|
+
calculationDate: string;
|
|
30
|
+
orderId: string;
|
|
31
|
+
couponCodes: string[];
|
|
32
|
+
businessUnitEntryId: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface CrmCalculatedItem {
|
|
36
|
+
productId: string;
|
|
37
|
+
variantId: string;
|
|
38
|
+
quantity: number;
|
|
39
|
+
unitPrice: number;
|
|
40
|
+
lineTotal: number;
|
|
41
|
+
discountAmount: number;
|
|
42
|
+
promotionName: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface CrmAppliedPromotion {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
discountAmount: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface CrmPromoError {
|
|
52
|
+
code: string;
|
|
53
|
+
message: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface CalculateCartResponse {
|
|
57
|
+
source: string;
|
|
58
|
+
degraded: boolean;
|
|
59
|
+
parsed: boolean;
|
|
60
|
+
subtotal: number;
|
|
61
|
+
discountTotal: number;
|
|
62
|
+
total: number;
|
|
63
|
+
bonusToDeduct: number;
|
|
64
|
+
bonusMaxSpend: number;
|
|
65
|
+
cashbackToEarn: number;
|
|
66
|
+
items: CrmCalculatedItem[];
|
|
67
|
+
promotions: CrmAppliedPromotion[];
|
|
68
|
+
promoErrors: CrmPromoError[];
|
|
69
|
+
crmTaskId: string;
|
|
70
|
+
crmCommentId: string;
|
|
71
|
+
rawResult: string;
|
|
72
|
+
durationMs: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface ReserveBonusesRequest {
|
|
76
|
+
userId: string;
|
|
77
|
+
cartSessionId: string;
|
|
78
|
+
amount: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ReserveBonusesResponse {
|
|
82
|
+
success: boolean;
|
|
83
|
+
reserveId: string;
|
|
84
|
+
expiresAt: number;
|
|
85
|
+
available: number;
|
|
86
|
+
error: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface ReleaseBonusReserveRequest {
|
|
90
|
+
reserveId: string;
|
|
91
|
+
cartSessionId: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface ReleaseBonusReserveResponse {
|
|
95
|
+
success: boolean;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface InvalidateCartSessionRequest {
|
|
99
|
+
cartSessionId: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface InvalidateCartSessionResponse {
|
|
103
|
+
success: boolean;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const CRM_V1_PACKAGE_NAME = "crm.v1";
|
|
107
|
+
|
|
108
|
+
export interface CrmCalculationServiceClient {
|
|
109
|
+
calculateCart(request: CalculateCartRequest): Observable<CalculateCartResponse>;
|
|
110
|
+
|
|
111
|
+
invalidateCartSession(request: InvalidateCartSessionRequest): Observable<InvalidateCartSessionResponse>;
|
|
112
|
+
|
|
113
|
+
reserveBonuses(request: ReserveBonusesRequest): Observable<ReserveBonusesResponse>;
|
|
114
|
+
|
|
115
|
+
releaseBonusReserve(request: ReleaseBonusReserveRequest): Observable<ReleaseBonusReserveResponse>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface CrmCalculationServiceController {
|
|
119
|
+
calculateCart(
|
|
120
|
+
request: CalculateCartRequest,
|
|
121
|
+
): Promise<CalculateCartResponse> | Observable<CalculateCartResponse> | CalculateCartResponse;
|
|
122
|
+
|
|
123
|
+
invalidateCartSession(
|
|
124
|
+
request: InvalidateCartSessionRequest,
|
|
125
|
+
): Promise<InvalidateCartSessionResponse> | Observable<InvalidateCartSessionResponse> | InvalidateCartSessionResponse;
|
|
126
|
+
|
|
127
|
+
reserveBonuses(
|
|
128
|
+
request: ReserveBonusesRequest,
|
|
129
|
+
): Promise<ReserveBonusesResponse> | Observable<ReserveBonusesResponse> | ReserveBonusesResponse;
|
|
130
|
+
|
|
131
|
+
releaseBonusReserve(
|
|
132
|
+
request: ReleaseBonusReserveRequest,
|
|
133
|
+
): Promise<ReleaseBonusReserveResponse> | Observable<ReleaseBonusReserveResponse> | ReleaseBonusReserveResponse;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function CrmCalculationServiceControllerMethods() {
|
|
137
|
+
return function (constructor: Function) {
|
|
138
|
+
const grpcMethods: string[] = ["calculateCart", "invalidateCartSession", "reserveBonuses", "releaseBonusReserve"];
|
|
139
|
+
for (const method of grpcMethods) {
|
|
140
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
141
|
+
GrpcMethod("CrmCalculationService", method)(constructor.prototype[method], method, descriptor);
|
|
142
|
+
}
|
|
143
|
+
const grpcStreamMethods: string[] = [];
|
|
144
|
+
for (const method of grpcStreamMethods) {
|
|
145
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
146
|
+
GrpcStreamMethod("CrmCalculationService", method)(constructor.prototype[method], method, descriptor);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export const CRM_CALCULATION_SERVICE_NAME = "CrmCalculationService";
|
package/gen/order.ts
CHANGED
|
@@ -146,6 +146,9 @@ export interface Order {
|
|
|
146
146
|
updatedAt: number;
|
|
147
147
|
notes: OrderNote[];
|
|
148
148
|
archivedAt: number;
|
|
149
|
+
cancelledBy: string;
|
|
150
|
+
crmOrderId: string;
|
|
151
|
+
saleRecordedAt: number;
|
|
149
152
|
}
|
|
150
153
|
|
|
151
154
|
export interface CreateOrderRequest {
|
|
@@ -224,6 +227,7 @@ export interface UpdateStatusRequest {
|
|
|
224
227
|
reason: string;
|
|
225
228
|
actorId: string;
|
|
226
229
|
actorName: string;
|
|
230
|
+
cancelledBy: string;
|
|
227
231
|
}
|
|
228
232
|
|
|
229
233
|
export interface CancelOrderRequest {
|
|
@@ -231,6 +235,18 @@ export interface CancelOrderRequest {
|
|
|
231
235
|
reason: string;
|
|
232
236
|
actorId: string;
|
|
233
237
|
actorName: string;
|
|
238
|
+
cancelledBy: string;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface SetCrmOrderIdRequest {
|
|
242
|
+
id: string;
|
|
243
|
+
crmOrderId: string;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface ConfirmPickupRequest {
|
|
247
|
+
id: string;
|
|
248
|
+
actorId: string;
|
|
249
|
+
actorName: string;
|
|
234
250
|
}
|
|
235
251
|
|
|
236
252
|
export interface ArchiveOrderRequest {
|
|
@@ -344,6 +360,10 @@ export interface OrderServiceClient {
|
|
|
344
360
|
|
|
345
361
|
setTrackingNumber(request: SetTrackingNumberRequest): Observable<OrderResponse>;
|
|
346
362
|
|
|
363
|
+
setCrmOrderId(request: SetCrmOrderIdRequest): Observable<OrderResponse>;
|
|
364
|
+
|
|
365
|
+
confirmPickup(request: ConfirmPickupRequest): Observable<OrderResponse>;
|
|
366
|
+
|
|
347
367
|
reorderOrder(request: ReorderOrderRequest): Observable<ReorderResponse>;
|
|
348
368
|
|
|
349
369
|
listHistory(request: ListHistoryRequest): Observable<ListHistoryResponse>;
|
|
@@ -394,6 +414,10 @@ export interface OrderServiceController {
|
|
|
394
414
|
request: SetTrackingNumberRequest,
|
|
395
415
|
): Promise<OrderResponse> | Observable<OrderResponse> | OrderResponse;
|
|
396
416
|
|
|
417
|
+
setCrmOrderId(request: SetCrmOrderIdRequest): Promise<OrderResponse> | Observable<OrderResponse> | OrderResponse;
|
|
418
|
+
|
|
419
|
+
confirmPickup(request: ConfirmPickupRequest): Promise<OrderResponse> | Observable<OrderResponse> | OrderResponse;
|
|
420
|
+
|
|
397
421
|
reorderOrder(request: ReorderOrderRequest): Promise<ReorderResponse> | Observable<ReorderResponse> | ReorderResponse;
|
|
398
422
|
|
|
399
423
|
listHistory(
|
|
@@ -424,6 +448,8 @@ export function OrderServiceControllerMethods() {
|
|
|
424
448
|
"removeTag",
|
|
425
449
|
"editItems",
|
|
426
450
|
"setTrackingNumber",
|
|
451
|
+
"setCrmOrderId",
|
|
452
|
+
"confirmPickup",
|
|
427
453
|
"reorderOrder",
|
|
428
454
|
"listHistory",
|
|
429
455
|
"aggregateByCustomers",
|
package/gen/users.ts
CHANGED
package/package.json
CHANGED
package/proto/cart.proto
CHANGED
|
@@ -2,6 +2,8 @@ syntax = "proto3";
|
|
|
2
2
|
|
|
3
3
|
package cart.v1;
|
|
4
4
|
|
|
5
|
+
import "crm_calculation.proto";
|
|
6
|
+
|
|
5
7
|
service CartService {
|
|
6
8
|
rpc GetCart(GetCartRequest) returns (CartResponse);
|
|
7
9
|
|
|
@@ -29,6 +31,9 @@ service CartService {
|
|
|
29
31
|
|
|
30
32
|
rpc Recalculate(RecalculateRequest) returns (CartResponse);
|
|
31
33
|
|
|
34
|
+
|
|
35
|
+
rpc CalculateCrm(CalculateCrmRequest) returns (crm.v1.CalculateCartResponse);
|
|
36
|
+
|
|
32
37
|
rpc MergeGuestToUser(MergeGuestToUserRequest) returns (CartResponse);
|
|
33
38
|
|
|
34
39
|
rpc AddToWishlist(WishlistItemRequest) returns (WishlistResponse);
|
|
@@ -167,6 +172,12 @@ message GetCartRequest {
|
|
|
167
172
|
CartOwner owner = 1;
|
|
168
173
|
}
|
|
169
174
|
|
|
175
|
+
message CalculateCrmRequest {
|
|
176
|
+
CartOwner owner = 1;
|
|
177
|
+
|
|
178
|
+
string calculation_date = 2;
|
|
179
|
+
}
|
|
180
|
+
|
|
170
181
|
message ClearCartRequest {
|
|
171
182
|
CartOwner owner = 1;
|
|
172
183
|
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package crm.v1;
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
service CrmCalculationService {
|
|
7
|
+
rpc CalculateCart(CalculateCartRequest) returns (CalculateCartResponse);
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
rpc InvalidateCartSession(InvalidateCartSessionRequest) returns (InvalidateCartSessionResponse);
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
rpc ReserveBonuses(ReserveBonusesRequest) returns (ReserveBonusesResponse);
|
|
14
|
+
rpc ReleaseBonusReserve(ReleaseBonusReserveRequest) returns (ReleaseBonusReserveResponse);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
message CrmCalculationItem {
|
|
18
|
+
string product_id = 1;
|
|
19
|
+
string variant_id = 2;
|
|
20
|
+
string category_id = 3;
|
|
21
|
+
string brand_id = 4;
|
|
22
|
+
int32 quantity = 5;
|
|
23
|
+
double unit_price = 6;
|
|
24
|
+
double subtotal = 7;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
message CalculateCartRequest {
|
|
28
|
+
string cart_session_id = 1;
|
|
29
|
+
string user_id = 2;
|
|
30
|
+
repeated CrmCalculationItem items = 3;
|
|
31
|
+
double bonus_to_spend = 4;
|
|
32
|
+
double total_amount = 5;
|
|
33
|
+
|
|
34
|
+
string calculation_date = 6;
|
|
35
|
+
string order_id = 7;
|
|
36
|
+
repeated string coupon_codes = 8;
|
|
37
|
+
string business_unit_entry_id = 9;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
message CrmCalculatedItem {
|
|
41
|
+
string product_id = 1;
|
|
42
|
+
string variant_id = 2;
|
|
43
|
+
int32 quantity = 3;
|
|
44
|
+
double unit_price = 4;
|
|
45
|
+
double line_total = 5;
|
|
46
|
+
double discount_amount = 6;
|
|
47
|
+
string promotion_name = 7;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
message CrmAppliedPromotion {
|
|
51
|
+
string id = 1;
|
|
52
|
+
string name = 2;
|
|
53
|
+
double discount_amount = 3;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
message CrmPromoError {
|
|
57
|
+
string code = 1;
|
|
58
|
+
string message = 2;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
message CalculateCartResponse {
|
|
62
|
+
|
|
63
|
+
string source = 1;
|
|
64
|
+
|
|
65
|
+
bool degraded = 2;
|
|
66
|
+
|
|
67
|
+
bool parsed = 3;
|
|
68
|
+
|
|
69
|
+
double subtotal = 4;
|
|
70
|
+
double discount_total = 5;
|
|
71
|
+
double total = 6;
|
|
72
|
+
double bonus_to_deduct = 7;
|
|
73
|
+
double bonus_max_spend = 8;
|
|
74
|
+
double cashback_to_earn = 9;
|
|
75
|
+
|
|
76
|
+
repeated CrmCalculatedItem items = 10;
|
|
77
|
+
repeated CrmAppliedPromotion promotions = 11;
|
|
78
|
+
repeated CrmPromoError promo_errors = 12;
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
string crm_task_id = 13;
|
|
82
|
+
string crm_comment_id = 14;
|
|
83
|
+
|
|
84
|
+
string raw_result = 15;
|
|
85
|
+
|
|
86
|
+
int32 duration_ms = 16;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
message ReserveBonusesRequest {
|
|
90
|
+
string user_id = 1;
|
|
91
|
+
string cart_session_id = 2;
|
|
92
|
+
double amount = 3;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
message ReserveBonusesResponse {
|
|
96
|
+
bool success = 1;
|
|
97
|
+
string reserve_id = 2;
|
|
98
|
+
|
|
99
|
+
int64 expires_at = 3;
|
|
100
|
+
|
|
101
|
+
double available = 4;
|
|
102
|
+
|
|
103
|
+
string error = 5;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
message ReleaseBonusReserveRequest {
|
|
107
|
+
|
|
108
|
+
string reserve_id = 1;
|
|
109
|
+
string cart_session_id = 2;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
message ReleaseBonusReserveResponse {
|
|
113
|
+
bool success = 1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
message InvalidateCartSessionRequest {
|
|
117
|
+
string cart_session_id = 1;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
message InvalidateCartSessionResponse {
|
|
121
|
+
bool success = 1;
|
|
122
|
+
}
|
package/proto/order.proto
CHANGED
|
@@ -26,6 +26,11 @@ service OrderService {
|
|
|
26
26
|
rpc EditItems(EditItemsRequest) returns (OrderResponse);
|
|
27
27
|
rpc SetTrackingNumber(SetTrackingNumberRequest) returns (OrderResponse);
|
|
28
28
|
|
|
29
|
+
|
|
30
|
+
rpc SetCrmOrderId(SetCrmOrderIdRequest) returns (OrderResponse);
|
|
31
|
+
|
|
32
|
+
rpc ConfirmPickup(ConfirmPickupRequest) returns (OrderResponse);
|
|
33
|
+
|
|
29
34
|
rpc ReorderOrder(ReorderOrderRequest) returns (ReorderResponse);
|
|
30
35
|
|
|
31
36
|
rpc ListHistory(ListHistoryRequest) returns (ListHistoryResponse);
|
|
@@ -183,6 +188,13 @@ message Order {
|
|
|
183
188
|
|
|
184
189
|
|
|
185
190
|
int64 archived_at = 23;
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
string cancelled_by = 24;
|
|
194
|
+
|
|
195
|
+
string crm_order_id = 25;
|
|
196
|
+
|
|
197
|
+
int64 sale_recorded_at = 26;
|
|
186
198
|
}
|
|
187
199
|
|
|
188
200
|
|
|
@@ -265,6 +277,8 @@ message UpdateStatusRequest {
|
|
|
265
277
|
string reason = 3;
|
|
266
278
|
string actor_id = 4;
|
|
267
279
|
string actor_name = 5;
|
|
280
|
+
|
|
281
|
+
string cancelled_by = 6;
|
|
268
282
|
}
|
|
269
283
|
|
|
270
284
|
message CancelOrderRequest {
|
|
@@ -272,6 +286,19 @@ message CancelOrderRequest {
|
|
|
272
286
|
string reason = 2;
|
|
273
287
|
string actor_id = 3;
|
|
274
288
|
string actor_name = 4;
|
|
289
|
+
|
|
290
|
+
string cancelled_by = 5;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
message SetCrmOrderIdRequest {
|
|
294
|
+
string id = 1;
|
|
295
|
+
string crm_order_id = 2;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
message ConfirmPickupRequest {
|
|
299
|
+
string id = 1;
|
|
300
|
+
string actor_id = 2;
|
|
301
|
+
string actor_name = 3;
|
|
275
302
|
}
|
|
276
303
|
|
|
277
304
|
message ArchiveOrderRequest {
|