@pisell/pisellos 2.2.132 → 2.2.134
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/Payment/index.js +12 -3
- package/dist/modules/Payment/types.d.ts +13 -3
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.js +3 -2
- package/dist/solution/ShopDiscount/index.js +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Payment/index.js +10 -1
- package/lib/modules/Payment/types.d.ts +13 -3
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.js +5 -5
- package/lib/solution/ShopDiscount/index.js +1 -1
- package/package.json +1 -1
|
@@ -76,6 +76,13 @@ function generateRequestUniqueId() {
|
|
|
76
76
|
|
|
77
77
|
return "".concat(year).concat(month).concat(day).concat(hour).concat(minute).concat(second).concat(millisecond).concat(randomDigits);
|
|
78
78
|
}
|
|
79
|
+
function normalizeCustomPaymentId(paymentItem) {
|
|
80
|
+
var _ref, _paymentItem$custom_p;
|
|
81
|
+
var rawId = (_ref = (_paymentItem$custom_p = paymentItem.custom_payment_id) !== null && _paymentItem$custom_p !== void 0 ? _paymentItem$custom_p : paymentItem.id) !== null && _ref !== void 0 ? _ref : 0;
|
|
82
|
+
var parsedId = Number(rawId);
|
|
83
|
+
if (!Number.isFinite(parsedId)) return 0;
|
|
84
|
+
return parsedId;
|
|
85
|
+
}
|
|
79
86
|
|
|
80
87
|
/**
|
|
81
88
|
* 支付模块实现
|
|
@@ -297,7 +304,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
297
304
|
var network = this.app.plugins.get('network');
|
|
298
305
|
this.logInfo('Registering network status listener');
|
|
299
306
|
network === null || network === void 0 || network.addListener('networkStatusChange', /*#__PURE__*/function () {
|
|
300
|
-
var
|
|
307
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(status) {
|
|
301
308
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
302
309
|
while (1) switch (_context2.prev = _context2.next) {
|
|
303
310
|
case 0:
|
|
@@ -317,7 +324,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
317
324
|
}, _callee2);
|
|
318
325
|
}));
|
|
319
326
|
return function (_x3) {
|
|
320
|
-
return
|
|
327
|
+
return _ref2.apply(this, arguments);
|
|
321
328
|
};
|
|
322
329
|
}());
|
|
323
330
|
}
|
|
@@ -1251,12 +1258,14 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1251
1258
|
currentTime = formatDateTime(new Date());
|
|
1252
1259
|
newPaymentItem = {
|
|
1253
1260
|
uuid: paymentUuid,
|
|
1254
|
-
custom_payment_id: paymentItem
|
|
1261
|
+
custom_payment_id: normalizeCustomPaymentId(paymentItem),
|
|
1255
1262
|
name: paymentItem.name,
|
|
1256
1263
|
code: paymentItem.code,
|
|
1257
1264
|
type: paymentItem.type,
|
|
1258
1265
|
amount: formatAmount(paymentItem.amount),
|
|
1259
1266
|
voucher_id: paymentItem.voucher_id || '',
|
|
1267
|
+
wallet_pass_usage_unit: paymentItem.wallet_pass_usage_unit,
|
|
1268
|
+
wallet_pass_use_value: paymentItem.wallet_pass_use_value,
|
|
1260
1269
|
rounding_amount: paymentItem.rounding_amount || '0.00',
|
|
1261
1270
|
service_charge: paymentItem.service_charge,
|
|
1262
1271
|
status: 'active',
|
|
@@ -104,7 +104,11 @@ export interface PaymentItem {
|
|
|
104
104
|
/** 支付类型type,跟支付列表上对应的支付方式保持一致 */
|
|
105
105
|
type: string;
|
|
106
106
|
/** 代金券、充值卡、积分卡等wallet pass id */
|
|
107
|
-
voucher_id?: string;
|
|
107
|
+
voucher_id?: string | number;
|
|
108
|
+
/** Wallet Pass 使用单位配置 */
|
|
109
|
+
wallet_pass_usage_unit?: unknown;
|
|
110
|
+
/** Wallet Pass 本次使用值 */
|
|
111
|
+
wallet_pass_use_value?: string | number | null;
|
|
108
112
|
/** 拓展参数字段 */
|
|
109
113
|
metadata?: {
|
|
110
114
|
/** 钱箱 ID */
|
|
@@ -227,13 +231,19 @@ export interface PaymentItemInput {
|
|
|
227
231
|
/** 支付类型,跟支付列表上对应的支付方式保持一致 */
|
|
228
232
|
code: string;
|
|
229
233
|
/** 支付类型id,跟支付列表上对应的支付方式保持一致 */
|
|
230
|
-
custom_payment_id
|
|
234
|
+
custom_payment_id?: string | number;
|
|
235
|
+
/** 兼容旧调用方传入的支付方式 id */
|
|
236
|
+
id?: string | number;
|
|
231
237
|
/** 支付类型名称,跟支付列表上对应的支付方式保持一致 */
|
|
232
238
|
name: string;
|
|
233
239
|
/** 支付类型type,跟支付列表上对应的支付方式保持一致 */
|
|
234
240
|
type: string;
|
|
235
241
|
/** 代金券、充值卡、积分卡等wallet pass id */
|
|
236
|
-
voucher_id?: string;
|
|
242
|
+
voucher_id?: string | number;
|
|
243
|
+
/** Wallet Pass 使用单位配置 */
|
|
244
|
+
wallet_pass_usage_unit?: unknown;
|
|
245
|
+
/** Wallet Pass 本次使用值 */
|
|
246
|
+
wallet_pass_use_value?: string | number | null;
|
|
237
247
|
/** 三方支付手续费 */
|
|
238
248
|
service_charge?: {
|
|
239
249
|
percentage?: string;
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -159,10 +159,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
// 合并新旧折扣列表,并计算折扣结果,注意,如果旧折扣里有 isEditMode 为 true 的优惠券,则不合并
|
|
162
|
+
// 保留之前扫码得到的商品券(isScan: true)
|
|
162
163
|
var filteredOldDiscountList = oldDiscountList.filter(function (discount) {
|
|
163
|
-
return !discount.isEditMode && discount.tag !== 'good_pass';
|
|
164
|
+
return !discount.isEditMode && (discount.tag !== 'good_pass' || discount.isScan);
|
|
164
165
|
});
|
|
165
|
-
var mergedDiscountList = uniqueById(
|
|
166
|
+
var mergedDiscountList = uniqueById([].concat(_toConsumableArray(filteredOldDiscountList), _toConsumableArray(newDiscountList)));
|
|
166
167
|
var result = this.calcDiscount({
|
|
167
168
|
discountList: mergedDiscountList,
|
|
168
169
|
productList: _toConsumableArray(productList),
|
|
@@ -480,7 +480,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
480
480
|
this.setDiscountList(newDiscountList || []);
|
|
481
481
|
this.store.originalDiscountList = newDiscountList || [];
|
|
482
482
|
this.setProductList(newProductList || []);
|
|
483
|
-
if (!(this.isWalkIn() && resultDiscountList.length && ((_this$options$otherPa6 = this.options.otherParams) === null || _this$options$otherPa6 === void 0 ? void 0 : _this$options$otherPa6.platform) === 'shop')) {
|
|
483
|
+
if (!(this.isWalkIn() && resultDiscountList.length && ((_this$options$otherPa6 = this.options.otherParams) === null || _this$options$otherPa6 === void 0 ? void 0 : _this$options$otherPa6.platform) === 'shop' && !((resultDiscountList[0].customer_id || 1) === 1))) {
|
|
484
484
|
_context5.next = 24;
|
|
485
485
|
break;
|
|
486
486
|
}
|
|
@@ -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
|
+
});
|
|
@@ -62,6 +62,13 @@ function generateRequestUniqueId() {
|
|
|
62
62
|
const randomDigits = Math.floor(Math.random() * 9e3) + 1e3;
|
|
63
63
|
return `${year}${month}${day}${hour}${minute}${second}${millisecond}${randomDigits}`;
|
|
64
64
|
}
|
|
65
|
+
function normalizeCustomPaymentId(paymentItem) {
|
|
66
|
+
const rawId = paymentItem.custom_payment_id ?? paymentItem.id ?? 0;
|
|
67
|
+
const parsedId = Number(rawId);
|
|
68
|
+
if (!Number.isFinite(parsedId))
|
|
69
|
+
return 0;
|
|
70
|
+
return parsedId;
|
|
71
|
+
}
|
|
65
72
|
var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
66
73
|
constructor(name, version) {
|
|
67
74
|
super(name || "payment", version);
|
|
@@ -633,12 +640,14 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
633
640
|
const currentTime = formatDateTime(/* @__PURE__ */ new Date());
|
|
634
641
|
const newPaymentItem = {
|
|
635
642
|
uuid: paymentUuid,
|
|
636
|
-
custom_payment_id: paymentItem
|
|
643
|
+
custom_payment_id: normalizeCustomPaymentId(paymentItem),
|
|
637
644
|
name: paymentItem.name,
|
|
638
645
|
code: paymentItem.code,
|
|
639
646
|
type: paymentItem.type,
|
|
640
647
|
amount: formatAmount(paymentItem.amount),
|
|
641
648
|
voucher_id: paymentItem.voucher_id || "",
|
|
649
|
+
wallet_pass_usage_unit: paymentItem.wallet_pass_usage_unit,
|
|
650
|
+
wallet_pass_use_value: paymentItem.wallet_pass_use_value,
|
|
642
651
|
rounding_amount: paymentItem.rounding_amount || "0.00",
|
|
643
652
|
service_charge: paymentItem.service_charge,
|
|
644
653
|
status: "active",
|
|
@@ -104,7 +104,11 @@ export interface PaymentItem {
|
|
|
104
104
|
/** 支付类型type,跟支付列表上对应的支付方式保持一致 */
|
|
105
105
|
type: string;
|
|
106
106
|
/** 代金券、充值卡、积分卡等wallet pass id */
|
|
107
|
-
voucher_id?: string;
|
|
107
|
+
voucher_id?: string | number;
|
|
108
|
+
/** Wallet Pass 使用单位配置 */
|
|
109
|
+
wallet_pass_usage_unit?: unknown;
|
|
110
|
+
/** Wallet Pass 本次使用值 */
|
|
111
|
+
wallet_pass_use_value?: string | number | null;
|
|
108
112
|
/** 拓展参数字段 */
|
|
109
113
|
metadata?: {
|
|
110
114
|
/** 钱箱 ID */
|
|
@@ -227,13 +231,19 @@ export interface PaymentItemInput {
|
|
|
227
231
|
/** 支付类型,跟支付列表上对应的支付方式保持一致 */
|
|
228
232
|
code: string;
|
|
229
233
|
/** 支付类型id,跟支付列表上对应的支付方式保持一致 */
|
|
230
|
-
custom_payment_id
|
|
234
|
+
custom_payment_id?: string | number;
|
|
235
|
+
/** 兼容旧调用方传入的支付方式 id */
|
|
236
|
+
id?: string | number;
|
|
231
237
|
/** 支付类型名称,跟支付列表上对应的支付方式保持一致 */
|
|
232
238
|
name: string;
|
|
233
239
|
/** 支付类型type,跟支付列表上对应的支付方式保持一致 */
|
|
234
240
|
type: string;
|
|
235
241
|
/** 代金券、充值卡、积分卡等wallet pass id */
|
|
236
|
-
voucher_id?: string;
|
|
242
|
+
voucher_id?: string | number;
|
|
243
|
+
/** Wallet Pass 使用单位配置 */
|
|
244
|
+
wallet_pass_usage_unit?: unknown;
|
|
245
|
+
/** Wallet Pass 本次使用值 */
|
|
246
|
+
wallet_pass_use_value?: string | number | null;
|
|
237
247
|
/** 三方支付手续费 */
|
|
238
248
|
service_charge?: {
|
|
239
249
|
percentage?: string;
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -105,12 +105,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
const filteredOldDiscountList = oldDiscountList.filter(
|
|
108
|
-
(discount) => !discount.isEditMode && discount.tag !== "good_pass"
|
|
109
|
-
);
|
|
110
|
-
const mergedDiscountList = (0, import_utils.uniqueById)(
|
|
111
|
-
(0, import_utils.uniqueById)([...filteredOldDiscountList, ...newDiscountList]),
|
|
112
|
-
"product_id"
|
|
108
|
+
(discount) => !discount.isEditMode && (discount.tag !== "good_pass" || discount.isScan)
|
|
113
109
|
);
|
|
110
|
+
const mergedDiscountList = (0, import_utils.uniqueById)([
|
|
111
|
+
...filteredOldDiscountList,
|
|
112
|
+
...newDiscountList
|
|
113
|
+
]);
|
|
114
114
|
const result = this.calcDiscount(
|
|
115
115
|
{
|
|
116
116
|
discountList: mergedDiscountList,
|
|
@@ -322,7 +322,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
322
322
|
this.setDiscountList(newDiscountList || []);
|
|
323
323
|
this.store.originalDiscountList = newDiscountList || [];
|
|
324
324
|
this.setProductList(newProductList || []);
|
|
325
|
-
if (this.isWalkIn() && resultDiscountList.length && ((_c = this.options.otherParams) == null ? void 0 : _c.platform) === "shop") {
|
|
325
|
+
if (this.isWalkIn() && resultDiscountList.length && ((_c = this.options.otherParams) == null ? void 0 : _c.platform) === "shop" && !((resultDiscountList[0].customer_id || 1) === 1)) {
|
|
326
326
|
await this.getCustomerWallet(
|
|
327
327
|
resultDiscountList[0].customer_id
|
|
328
328
|
);
|