@pisell/pisellos 2.2.229 → 2.2.230
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/modules/Order/index.d.ts +1 -0
- package/dist/modules/Order/index.js +38 -25
- package/dist/server/index.js +27 -13
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Order/index.d.ts +1 -0
- package/lib/modules/Order/index.js +12 -1
- package/lib/server/index.js +11 -0
- package/package.json +1 -1
|
@@ -372,6 +372,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
372
372
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
373
373
|
}): Promise<T>;
|
|
374
374
|
private markLocalOrderSynced;
|
|
375
|
+
private applyRemoteOrderNumbersToTempOrder;
|
|
375
376
|
private isSubmitResponseRejected;
|
|
376
377
|
private isLocalPendingSubmitResult;
|
|
377
378
|
private isSubmitErrorResponse;
|
|
@@ -3740,7 +3740,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3740
3740
|
var enhancedPayload = params !== null && params !== void 0 && params.enhancePayload ? params.enhancePayload(nextPayload, ctx) : nextPayload;
|
|
3741
3741
|
return enhancedPayload;
|
|
3742
3742
|
} : undefined;
|
|
3743
|
-
debugger;
|
|
3744
3743
|
payload = buildSubmitPayload({
|
|
3745
3744
|
tempOrder: tempOrder,
|
|
3746
3745
|
cacheId: effectiveCacheId,
|
|
@@ -3754,10 +3753,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3754
3753
|
if (!payload.created_at) {
|
|
3755
3754
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
3756
3755
|
}
|
|
3757
|
-
_context26.next =
|
|
3756
|
+
_context26.next = 20;
|
|
3758
3757
|
return this.saveDraft();
|
|
3759
|
-
case
|
|
3760
|
-
_context26.prev =
|
|
3758
|
+
case 20:
|
|
3759
|
+
_context26.prev = 20;
|
|
3761
3760
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
3762
3761
|
orderId: payload.order_id,
|
|
3763
3762
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -3766,26 +3765,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3766
3765
|
paymentsCount: ((_payload$payments = payload.payments) === null || _payload$payments === void 0 ? void 0 : _payload$payments.length) || 0,
|
|
3767
3766
|
smallTicketDataFlag: payload.small_ticket_data_flag
|
|
3768
3767
|
});
|
|
3769
|
-
_context26.next =
|
|
3768
|
+
_context26.next = 24;
|
|
3770
3769
|
return this.submitSalesOrder({
|
|
3771
3770
|
query: payload
|
|
3772
3771
|
});
|
|
3773
|
-
case
|
|
3772
|
+
case 24:
|
|
3774
3773
|
result = _context26.sent;
|
|
3775
|
-
_context26.next =
|
|
3774
|
+
_context26.next = 37;
|
|
3776
3775
|
break;
|
|
3777
|
-
case
|
|
3778
|
-
_context26.prev =
|
|
3779
|
-
_context26.t2 = _context26["catch"](
|
|
3776
|
+
case 27:
|
|
3777
|
+
_context26.prev = 27;
|
|
3778
|
+
_context26.t2 = _context26["catch"](20);
|
|
3780
3779
|
backendErrorResponse = this.extractSubmitErrorResponse(_context26.t2);
|
|
3781
3780
|
if (!backendErrorResponse) {
|
|
3782
|
-
_context26.next =
|
|
3781
|
+
_context26.next = 34;
|
|
3783
3782
|
break;
|
|
3784
3783
|
}
|
|
3785
3784
|
this.store.syncState = 'failed';
|
|
3786
3785
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
3787
3786
|
return _context26.abrupt("return", backendErrorResponse);
|
|
3788
|
-
case
|
|
3787
|
+
case 34:
|
|
3789
3788
|
this.store.syncState = 'failed';
|
|
3790
3789
|
this.logError('submitTempOrder failed', {
|
|
3791
3790
|
error: _context26.t2 instanceof Error ? _context26.t2.message : String(_context26.t2),
|
|
@@ -3795,40 +3794,40 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3795
3794
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
3796
3795
|
});
|
|
3797
3796
|
throw _context26.t2;
|
|
3798
|
-
case
|
|
3797
|
+
case 37:
|
|
3799
3798
|
if (!this.isSubmitResponseRejected(result)) {
|
|
3800
|
-
_context26.next =
|
|
3799
|
+
_context26.next = 41;
|
|
3801
3800
|
break;
|
|
3802
3801
|
}
|
|
3803
3802
|
this.store.syncState = 'failed';
|
|
3804
3803
|
this.logSubmitBackendRejected(result, payload);
|
|
3805
3804
|
return _context26.abrupt("return", result);
|
|
3806
|
-
case
|
|
3805
|
+
case 41:
|
|
3807
3806
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
3808
3807
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
3809
|
-
_context26.next =
|
|
3808
|
+
_context26.next = 49;
|
|
3810
3809
|
break;
|
|
3811
3810
|
}
|
|
3812
3811
|
tempOrder.order_id = submittedOrderId;
|
|
3813
3812
|
resultRecord = result;
|
|
3814
|
-
_context26.next =
|
|
3813
|
+
_context26.next = 47;
|
|
3815
3814
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
3816
|
-
case
|
|
3817
|
-
_context26.next =
|
|
3815
|
+
case 47:
|
|
3816
|
+
_context26.next = 50;
|
|
3818
3817
|
break;
|
|
3819
|
-
case
|
|
3818
|
+
case 49:
|
|
3820
3819
|
if (this.isLocalPendingSubmitResult(result)) {
|
|
3821
3820
|
this.store.syncState = 'local';
|
|
3822
3821
|
} else {
|
|
3823
3822
|
this.store.syncState = 'submitted';
|
|
3824
3823
|
}
|
|
3825
|
-
case
|
|
3824
|
+
case 50:
|
|
3826
3825
|
return _context26.abrupt("return", result);
|
|
3827
|
-
case
|
|
3826
|
+
case 51:
|
|
3828
3827
|
case "end":
|
|
3829
3828
|
return _context26.stop();
|
|
3830
3829
|
}
|
|
3831
|
-
}, _callee24, this, [[
|
|
3830
|
+
}, _callee24, this, [[20, 27]]);
|
|
3832
3831
|
}));
|
|
3833
3832
|
function submitTempOrder(_x26) {
|
|
3834
3833
|
return _submitTempOrder.apply(this, arguments);
|
|
@@ -3845,12 +3844,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3845
3844
|
case 0:
|
|
3846
3845
|
tempOrder = this.ensureTempOrder();
|
|
3847
3846
|
tempOrder.order_id = orderId;
|
|
3847
|
+
this.applyRemoteOrderNumbersToTempOrder(tempOrder, remoteOrder);
|
|
3848
3848
|
this.store.lastOrderInfo = remoteOrder;
|
|
3849
3849
|
this.store.syncState = 'submitted';
|
|
3850
3850
|
this.persistTempOrder();
|
|
3851
|
-
_context27.next =
|
|
3851
|
+
_context27.next = 8;
|
|
3852
3852
|
return this.saveDraft();
|
|
3853
|
-
case
|
|
3853
|
+
case 8:
|
|
3854
3854
|
case "end":
|
|
3855
3855
|
return _context27.stop();
|
|
3856
3856
|
}
|
|
@@ -3861,6 +3861,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3861
3861
|
}
|
|
3862
3862
|
return markLocalOrderSynced;
|
|
3863
3863
|
}()
|
|
3864
|
+
}, {
|
|
3865
|
+
key: "applyRemoteOrderNumbersToTempOrder",
|
|
3866
|
+
value: function applyRemoteOrderNumbersToTempOrder(tempOrder, remoteOrder) {
|
|
3867
|
+
var applyOrderNumber = function applyOrderNumber(key) {
|
|
3868
|
+
var value = remoteOrder === null || remoteOrder === void 0 ? void 0 : remoteOrder[key];
|
|
3869
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
3870
|
+
tempOrder[key] = String(value);
|
|
3871
|
+
}
|
|
3872
|
+
};
|
|
3873
|
+
applyOrderNumber('order_number');
|
|
3874
|
+
applyOrderNumber('shop_order_number');
|
|
3875
|
+
applyOrderNumber('shop_full_order_number');
|
|
3876
|
+
}
|
|
3864
3877
|
}, {
|
|
3865
3878
|
key: "isSubmitResponseRejected",
|
|
3866
3879
|
value: function isSubmitResponseRejected(response) {
|
package/dist/server/index.js
CHANGED
|
@@ -3785,7 +3785,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3785
3785
|
key: "normalizeCheckoutSubmitData",
|
|
3786
3786
|
value: function () {
|
|
3787
3787
|
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(data, title) {
|
|
3788
|
-
var next, externalSaleNumber, shouldClearLocalOrderId, localOrder;
|
|
3788
|
+
var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
|
|
3789
3789
|
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3790
3790
|
while (1) switch (_context40.prev = _context40.next) {
|
|
3791
3791
|
case 0:
|
|
@@ -3799,8 +3799,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
3799
3799
|
externalSaleNumber = next.external_sale_number;
|
|
3800
3800
|
shouldClearLocalOrderId = this.isLocalCheckoutOrderId(next.order_id);
|
|
3801
3801
|
if (shouldClearLocalOrderId) next.order_id = null;
|
|
3802
|
+
hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
|
|
3803
|
+
if (!hasCheckoutOrderNumbers) {
|
|
3804
|
+
_context40.next = 10;
|
|
3805
|
+
break;
|
|
3806
|
+
}
|
|
3807
|
+
this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
|
|
3808
|
+
original_order_id: data.order_id,
|
|
3809
|
+
order_id: next.order_id,
|
|
3810
|
+
external_sale_number: externalSaleNumber,
|
|
3811
|
+
shop_order_number: next.shop_order_number,
|
|
3812
|
+
shop_full_order_number: next.shop_full_order_number
|
|
3813
|
+
});
|
|
3814
|
+
return _context40.abrupt("return", next);
|
|
3815
|
+
case 10:
|
|
3802
3816
|
if (!this.isBlankCheckoutValue(externalSaleNumber)) {
|
|
3803
|
-
_context40.next =
|
|
3817
|
+
_context40.next = 13;
|
|
3804
3818
|
break;
|
|
3805
3819
|
}
|
|
3806
3820
|
if (shouldClearLocalOrderId) {
|
|
@@ -3810,9 +3824,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
3810
3824
|
});
|
|
3811
3825
|
}
|
|
3812
3826
|
return _context40.abrupt("return", next);
|
|
3813
|
-
case
|
|
3827
|
+
case 13:
|
|
3814
3828
|
if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
|
|
3815
|
-
_context40.next =
|
|
3829
|
+
_context40.next = 16;
|
|
3816
3830
|
break;
|
|
3817
3831
|
}
|
|
3818
3832
|
if (shouldClearLocalOrderId) {
|
|
@@ -3822,11 +3836,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3822
3836
|
});
|
|
3823
3837
|
}
|
|
3824
3838
|
return _context40.abrupt("return", next);
|
|
3825
|
-
case
|
|
3826
|
-
_context40.prev =
|
|
3839
|
+
case 16:
|
|
3840
|
+
_context40.prev = 16;
|
|
3827
3841
|
localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
|
|
3828
3842
|
if (localOrder) {
|
|
3829
|
-
_context40.next =
|
|
3843
|
+
_context40.next = 21;
|
|
3830
3844
|
break;
|
|
3831
3845
|
}
|
|
3832
3846
|
if (shouldClearLocalOrderId) {
|
|
@@ -3837,7 +3851,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3837
3851
|
});
|
|
3838
3852
|
}
|
|
3839
3853
|
return _context40.abrupt("return", next);
|
|
3840
|
-
case
|
|
3854
|
+
case 21:
|
|
3841
3855
|
if (this.isBlankCheckoutValue(next.shop_order_number)) {
|
|
3842
3856
|
next.shop_order_number = localOrder.shop_order_number;
|
|
3843
3857
|
}
|
|
@@ -3853,20 +3867,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
3853
3867
|
shop_full_order_number: next.shop_full_order_number
|
|
3854
3868
|
});
|
|
3855
3869
|
return _context40.abrupt("return", next);
|
|
3856
|
-
case
|
|
3857
|
-
_context40.prev =
|
|
3858
|
-
_context40.t0 = _context40["catch"](
|
|
3870
|
+
case 27:
|
|
3871
|
+
_context40.prev = 27;
|
|
3872
|
+
_context40.t0 = _context40["catch"](16);
|
|
3859
3873
|
this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
|
|
3860
3874
|
external_sale_number: externalSaleNumber,
|
|
3861
3875
|
error: this.getUnknownErrorMessage(_context40.t0),
|
|
3862
3876
|
error_detail: this.normalizeUnknownError(_context40.t0)
|
|
3863
3877
|
});
|
|
3864
3878
|
return _context40.abrupt("return", next);
|
|
3865
|
-
case
|
|
3879
|
+
case 31:
|
|
3866
3880
|
case "end":
|
|
3867
3881
|
return _context40.stop();
|
|
3868
3882
|
}
|
|
3869
|
-
}, _callee40, this, [[
|
|
3883
|
+
}, _callee40, this, [[16, 27]]);
|
|
3870
3884
|
}));
|
|
3871
3885
|
function normalizeCheckoutSubmitData(_x42, _x43) {
|
|
3872
3886
|
return _normalizeCheckoutSubmitData.apply(this, arguments);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
+
var promotion_exports = {};
|
|
31
|
+
__export(promotion_exports, {
|
|
32
|
+
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
+
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
+
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
+
default: () => import_adapter2.default
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
+
var import_evaluator = require("./evaluator");
|
|
40
|
+
var import_adapter = require("./adapter");
|
|
41
|
+
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
+
var import_examples = require("./examples");
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
+
PromotionAdapter,
|
|
47
|
+
PromotionEvaluator,
|
|
48
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
+
});
|
|
@@ -372,6 +372,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
372
372
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
373
373
|
}): Promise<T>;
|
|
374
374
|
private markLocalOrderSynced;
|
|
375
|
+
private applyRemoteOrderNumbersToTempOrder;
|
|
375
376
|
private isSubmitResponseRejected;
|
|
376
377
|
private isLocalPendingSubmitResult;
|
|
377
378
|
private isSubmitErrorResponse;
|
|
@@ -2761,7 +2761,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2761
2761
|
const enhancedPayload = (params == null ? void 0 : params.enhancePayload) ? params.enhancePayload(nextPayload, ctx) : nextPayload;
|
|
2762
2762
|
return enhancedPayload;
|
|
2763
2763
|
} : void 0;
|
|
2764
|
-
debugger;
|
|
2765
2764
|
const payload = (0, import_utils.buildSubmitPayload)({
|
|
2766
2765
|
tempOrder,
|
|
2767
2766
|
cacheId: effectiveCacheId,
|
|
@@ -2829,11 +2828,23 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2829
2828
|
async markLocalOrderSynced(orderId, remoteOrder) {
|
|
2830
2829
|
const tempOrder = this.ensureTempOrder();
|
|
2831
2830
|
tempOrder.order_id = orderId;
|
|
2831
|
+
this.applyRemoteOrderNumbersToTempOrder(tempOrder, remoteOrder);
|
|
2832
2832
|
this.store.lastOrderInfo = remoteOrder;
|
|
2833
2833
|
this.store.syncState = "submitted";
|
|
2834
2834
|
this.persistTempOrder();
|
|
2835
2835
|
await this.saveDraft();
|
|
2836
2836
|
}
|
|
2837
|
+
applyRemoteOrderNumbersToTempOrder(tempOrder, remoteOrder) {
|
|
2838
|
+
const applyOrderNumber = (key) => {
|
|
2839
|
+
const value = remoteOrder == null ? void 0 : remoteOrder[key];
|
|
2840
|
+
if (value !== void 0 && value !== null && value !== "") {
|
|
2841
|
+
tempOrder[key] = String(value);
|
|
2842
|
+
}
|
|
2843
|
+
};
|
|
2844
|
+
applyOrderNumber("order_number");
|
|
2845
|
+
applyOrderNumber("shop_order_number");
|
|
2846
|
+
applyOrderNumber("shop_full_order_number");
|
|
2847
|
+
}
|
|
2837
2848
|
isSubmitResponseRejected(response) {
|
|
2838
2849
|
const isErrorCode = (response == null ? void 0 : response.code) !== void 0 && response.code !== 200 && response.code !== "200";
|
|
2839
2850
|
const isErrorStatus = (response == null ? void 0 : response.status) === false || typeof (response == null ? void 0 : response.status) === "number" && response.status >= 400;
|
package/lib/server/index.js
CHANGED
|
@@ -2373,6 +2373,17 @@ var Server = class {
|
|
|
2373
2373
|
const shouldClearLocalOrderId = this.isLocalCheckoutOrderId(next.order_id);
|
|
2374
2374
|
if (shouldClearLocalOrderId)
|
|
2375
2375
|
next.order_id = null;
|
|
2376
|
+
const hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
|
|
2377
|
+
if (hasCheckoutOrderNumbers) {
|
|
2378
|
+
this.logInfo(`${title}: checkout 已携带订单号,跳过查重`, {
|
|
2379
|
+
original_order_id: data.order_id,
|
|
2380
|
+
order_id: next.order_id,
|
|
2381
|
+
external_sale_number: externalSaleNumber,
|
|
2382
|
+
shop_order_number: next.shop_order_number,
|
|
2383
|
+
shop_full_order_number: next.shop_full_order_number
|
|
2384
|
+
});
|
|
2385
|
+
return next;
|
|
2386
|
+
}
|
|
2376
2387
|
if (this.isBlankCheckoutValue(externalSaleNumber)) {
|
|
2377
2388
|
if (shouldClearLocalOrderId) {
|
|
2378
2389
|
this.logInfo(`${title}: checkout 本地订单号已清理`, {
|