@pisell/pisellos 2.3.16 → 2.3.18

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.
@@ -30,6 +30,7 @@ var salesSummaryDataKeys = {
30
30
  taxTitle: 'tax_title',
31
31
  taxCountryCode: 'tax_country_code'
32
32
  };
33
+ var DEFAULT_SURCHARGE_CHANNEL = 'online-store';
33
34
  export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
34
35
  _inherits(SalesSummaryModule, _BaseModule);
35
36
  var _super = _createSuper(SalesSummaryModule);
@@ -43,13 +44,15 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
43
44
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
44
45
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
45
46
  _defineProperty(_assertThisInitialized(_this), "surchargeListModuleName", 'surchargeList');
47
+ _defineProperty(_assertThisInitialized(_this), "otherParams", {});
48
+ _defineProperty(_assertThisInitialized(_this), "surchargeListChannel", DEFAULT_SURCHARGE_CHANNEL);
46
49
  return _this;
47
50
  }
48
51
  _createClass(SalesSummaryModule, [{
49
52
  key: "initialize",
50
53
  value: function () {
51
54
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
52
- var _options$initialState, _options$initialState2, _options$otherParams;
55
+ var _options$initialState, _options$initialState2, _this$otherParams;
53
56
  return _regeneratorRuntime().wrap(function _callee$(_context) {
54
57
  while (1) switch (_context.prev = _context.next) {
55
58
  case 0:
@@ -57,24 +60,25 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
57
60
  this.store = options.store;
58
61
  this.appPlugin = this.core.getPlugin('app');
59
62
  this.request = this.core.getPlugin('request');
63
+ this.otherParams = options.otherParams || {};
60
64
  this.store.surchargeList = ((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.surchargeList) || [];
61
65
  this.store.summary = ((_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.summary) || createEmptySalesSummary();
62
- this.surchargeListModuleName = ((_options$otherParams = options.otherParams) === null || _options$otherParams === void 0 ? void 0 : _options$otherParams.surchargeListModuleName) || 'surchargeList';
66
+ this.surchargeListModuleName = ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.surchargeListModuleName) || 'surchargeList';
63
67
  if (this.appPlugin) {
64
- _context.next = 9;
68
+ _context.next = 10;
65
69
  break;
66
70
  }
67
71
  throw new Error('SalesSummaryModule 需要 app 插件支持');
68
- case 9:
72
+ case 10:
69
73
  if (this.request) {
70
- _context.next = 11;
74
+ _context.next = 12;
71
75
  break;
72
76
  }
73
77
  throw new Error('SalesSummaryModule 需要 request 插件支持');
74
- case 11:
75
- _context.next = 13;
78
+ case 12:
79
+ _context.next = 14;
76
80
  return this.getSurchargeList();
77
- case 13:
81
+ case 14:
78
82
  case "end":
79
83
  return _context.stop();
80
84
  }
@@ -86,30 +90,32 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
86
90
  return initialize;
87
91
  }()
88
92
  /**
89
- * 更新父级解决方案透传的运行态参数,并在 surcharge 模块名变化时刷新附加费列表。
93
+ * 更新父级解决方案透传的运行态参数,并在 surcharge 模块名或渠道变化时刷新附加费列表。
90
94
  *
91
95
  * @example
92
- * await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
96
+ * await salesSummaryModule.updateOtherParams({ channel: 'pos', surchargeListModuleName: 'custom_surchargeList' });
93
97
  */
94
98
  }, {
95
99
  key: "updateOtherParams",
96
100
  value: (function () {
97
101
  var _updateOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
98
- var nextSurchargeListModuleName;
102
+ var previousChannel, nextSurchargeListModuleName, nextChannel, shouldReload;
99
103
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
100
104
  while (1) switch (_context2.prev = _context2.next) {
101
105
  case 0:
106
+ previousChannel = this.resolveChannel();
102
107
  nextSurchargeListModuleName = (params === null || params === void 0 ? void 0 : params.surchargeListModuleName) || 'surchargeList';
103
- if (!(nextSurchargeListModuleName === this.surchargeListModuleName)) {
104
- _context2.next = 3;
108
+ nextChannel = this.resolveChannel(params);
109
+ shouldReload = nextSurchargeListModuleName !== this.surchargeListModuleName || nextChannel !== previousChannel;
110
+ this.otherParams = params || {};
111
+ this.surchargeListModuleName = nextSurchargeListModuleName;
112
+ if (!shouldReload) {
113
+ _context2.next = 9;
105
114
  break;
106
115
  }
107
- return _context2.abrupt("return");
108
- case 3:
109
- this.surchargeListModuleName = nextSurchargeListModuleName;
110
- _context2.next = 6;
111
- return this.getSurchargeList();
112
- case 6:
116
+ _context2.next = 9;
117
+ return this.getSurchargeList(nextChannel);
118
+ case 9:
113
119
  case "end":
114
120
  return _context2.stop();
115
121
  }
@@ -120,49 +126,63 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
120
126
  }
121
127
  return updateOtherParams;
122
128
  }())
129
+ }, {
130
+ key: "resolveChannel",
131
+ value: function resolveChannel() {
132
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.otherParams;
133
+ return (params === null || params === void 0 ? void 0 : params.channel) || DEFAULT_SURCHARGE_CHANNEL;
134
+ }
123
135
  }, {
124
136
  key: "getSurchargeList",
125
137
  value: function () {
126
138
  var _getSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
127
- var surchargeListModule, surchargeList;
139
+ var channel,
140
+ surchargeListModule,
141
+ surchargeList,
142
+ _args3 = arguments;
128
143
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
129
144
  while (1) switch (_context3.prev = _context3.next) {
130
145
  case 0:
131
- _context3.prev = 0;
146
+ channel = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : this.resolveChannel();
147
+ _context3.prev = 1;
132
148
  surchargeListModule = this.core.getModule(this.surchargeListModuleName);
133
149
  if (!(surchargeListModule !== null && surchargeListModule !== void 0 && surchargeListModule.getSurchargeList)) {
134
- _context3.next = 7;
150
+ _context3.next = 9;
135
151
  break;
136
152
  }
137
- _context3.next = 5;
138
- return surchargeListModule.getSurchargeList();
139
- case 5:
153
+ _context3.next = 6;
154
+ return surchargeListModule.getSurchargeList({
155
+ channel: channel
156
+ });
157
+ case 6:
140
158
  this.store.surchargeList = _context3.sent;
159
+ this.surchargeListChannel = channel;
141
160
  return _context3.abrupt("return");
142
- case 7:
143
- _context3.next = 9;
161
+ case 9:
162
+ _context3.next = 11;
144
163
  return this.request.get('/order/custom-surcharge/available/v2', {
145
- // TODO 真实的渠道
146
- channel: 'online-store',
164
+ channel: channel,
147
165
  is_assemble_product_data: 1,
148
166
  is_assemble_schedule_data: 1,
149
167
  with: ['relationSchedule']
150
168
  });
151
- case 9:
169
+ case 11:
152
170
  surchargeList = _context3.sent;
153
171
  this.store.surchargeList = (surchargeList === null || surchargeList === void 0 ? void 0 : surchargeList.data) || [];
154
- _context3.next = 17;
172
+ this.surchargeListChannel = channel;
173
+ _context3.next = 21;
155
174
  break;
156
- case 13:
157
- _context3.prev = 13;
158
- _context3.t0 = _context3["catch"](0);
175
+ case 16:
176
+ _context3.prev = 16;
177
+ _context3.t0 = _context3["catch"](1);
159
178
  console.warn('[SalesSummaryModule] 加载附加费配置失败', _context3.t0);
160
179
  this.store.surchargeList = [];
161
- case 17:
180
+ this.surchargeListChannel = channel;
181
+ case 21:
162
182
  case "end":
163
183
  return _context3.stop();
164
184
  }
165
- }, _callee3, this, [[0, 13]]);
185
+ }, _callee3, this, [[1, 16]]);
166
186
  }));
167
187
  function getSurchargeList() {
168
188
  return _getSurchargeList.apply(this, arguments);
@@ -194,11 +214,19 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
194
214
  value: function () {
195
215
  var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
196
216
  var _this$store$surcharge, _ref;
197
- var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount, taxConfig, summarySchedule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary, summaryWithTaxMeta;
217
+ var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount, channel, summaryChannel, taxConfig, summarySchedule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary, summaryWithTaxMeta;
198
218
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
199
219
  while (1) switch (_context4.prev = _context4.next) {
200
220
  case 0:
201
- _params$products = params.products, products = _params$products === void 0 ? [] : _params$products, isPriceIncludeTax = params.isPriceIncludeTax, taxRate = params.taxRate, shopDiscount = params.shopDiscount;
221
+ _params$products = params.products, products = _params$products === void 0 ? [] : _params$products, isPriceIncludeTax = params.isPriceIncludeTax, taxRate = params.taxRate, shopDiscount = params.shopDiscount, channel = params.channel;
222
+ summaryChannel = channel || this.resolveChannel();
223
+ if (!(summaryChannel !== this.surchargeListChannel)) {
224
+ _context4.next = 5;
225
+ break;
226
+ }
227
+ _context4.next = 5;
228
+ return this.getSurchargeList(summaryChannel);
229
+ case 5:
202
230
  taxConfig = this.getTaxConfig();
203
231
  summarySchedule = this.core.getModule("".concat(this.name.split('_')[0], "_schedule"));
204
232
  needScheduleIds = (((_this$store$surcharge = this.store.surchargeList) === null || _this$store$surcharge === void 0 || (_this$store$surcharge = _this$store$surcharge.map(function (item) {
@@ -237,7 +265,7 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
237
265
  });
238
266
  this.store.summary = summaryWithTaxMeta;
239
267
  return _context4.abrupt("return", summaryWithTaxMeta);
240
- case 11:
268
+ case 15:
241
269
  case "end":
242
270
  return _context4.stop();
243
271
  }
@@ -63,5 +63,6 @@ export interface SalesSummaryModuleAPI {
63
63
  isPriceIncludeTax?: number;
64
64
  taxRate?: number;
65
65
  shopDiscount?: string | number;
66
+ channel?: string;
66
67
  }): Promise<SalesSummaryData>;
67
68
  }
@@ -329,11 +329,12 @@ function buildSurchargeQuantityTotals(nodes) {
329
329
  }
330
330
  function getFallbackAllProductSurchargeIds(surchargeList) {
331
331
  return (surchargeList || []).reduce(function (ids, config) {
332
- var _config$open_product, _config$is_all;
332
+ var _config$open_product, _config$is_all, _config$open_schedule;
333
333
  var id = getSurchargeConfigId(config);
334
334
  if (id === undefined) return ids;
335
335
  if (Number((_config$open_product = config.open_product) !== null && _config$open_product !== void 0 ? _config$open_product : 0) === 0) return ids;
336
336
  if (Number((_config$is_all = config.is_all) !== null && _config$is_all !== void 0 ? _config$is_all : 0) !== 1) return ids;
337
+ if (Number((_config$open_schedule = config.open_schedule) !== null && _config$open_schedule !== void 0 ? _config$open_schedule : 0) === 1 && config.schedule_type !== 'all') return ids;
337
338
  ids.push(id);
338
339
  return ids;
339
340
  }, []);
@@ -1,16 +1,18 @@
1
1
  import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { SurchargeListItem, SurchargeListModuleAPI } from './types';
3
+ import { SurchargeListItem, SurchargeListModuleAPI, SurchargeListQuery } from './types';
4
4
  export * from './types';
5
5
  export declare class SurchargeListModule extends BaseModule implements Module, SurchargeListModuleAPI {
6
6
  protected defaultName: string;
7
7
  protected defaultVersion: string;
8
8
  private request;
9
9
  private store;
10
- private loadingPromise;
10
+ private loadingPromises;
11
+ private requestVersion;
11
12
  constructor(name?: string, version?: string);
12
13
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
13
- getSurchargeList(): Promise<SurchargeListItem[]>;
14
- refreshSurchargeList(): Promise<SurchargeListItem[]>;
14
+ private resolveChannel;
15
+ getSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
16
+ refreshSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
15
17
  private loadSurchargeList;
16
18
  }
@@ -17,6 +17,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
17
17
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
18
  import { BaseModule } from "../BaseModule";
19
19
  export * from "./types";
20
+ var DEFAULT_SURCHARGE_CHANNEL = 'online-store';
20
21
  export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
21
22
  _inherits(SurchargeListModule, _BaseModule);
22
23
  var _super = _createSuper(SurchargeListModule);
@@ -28,14 +29,15 @@ export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
28
29
  _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
29
30
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
30
31
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
31
- _defineProperty(_assertThisInitialized(_this), "loadingPromise", null);
32
+ _defineProperty(_assertThisInitialized(_this), "loadingPromises", new Map());
33
+ _defineProperty(_assertThisInitialized(_this), "requestVersion", 0);
32
34
  return _this;
33
35
  }
34
36
  _createClass(SurchargeListModule, [{
35
37
  key: "initialize",
36
38
  value: function () {
37
39
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
38
- var _options$initialState, _options$initialState2, _options$initialState3;
40
+ var _options$initialState, _options$initialState2, _options$initialState3, _options$otherParams, _options$initialState4;
39
41
  var hasInitialSurchargeList;
40
42
  return _regeneratorRuntime().wrap(function _callee$(_context) {
41
43
  while (1) switch (_context.prev = _context.next) {
@@ -45,13 +47,14 @@ export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
45
47
  this.request = this.core.getPlugin('request');
46
48
  hasInitialSurchargeList = Array.isArray((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.surchargeList);
47
49
  this.store.surchargeList = hasInitialSurchargeList ? (_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.surchargeList : [];
48
- this.store.isLoaded = Boolean((_options$initialState3 = options.initialState) === null || _options$initialState3 === void 0 ? void 0 : _options$initialState3.isLoaded) || hasInitialSurchargeList;
50
+ this.store.channel = ((_options$initialState3 = options.initialState) === null || _options$initialState3 === void 0 ? void 0 : _options$initialState3.channel) || ((_options$otherParams = options.otherParams) === null || _options$otherParams === void 0 ? void 0 : _options$otherParams.channel) || DEFAULT_SURCHARGE_CHANNEL;
51
+ this.store.isLoaded = Boolean((_options$initialState4 = options.initialState) === null || _options$initialState4 === void 0 ? void 0 : _options$initialState4.isLoaded) || hasInitialSurchargeList;
49
52
  if (this.request) {
50
- _context.next = 8;
53
+ _context.next = 9;
51
54
  break;
52
55
  }
53
56
  throw new Error('SurchargeListModule 需要 request 插件支持');
54
- case 8:
57
+ case 9:
55
58
  case "end":
56
59
  return _context.stop();
57
60
  }
@@ -62,34 +65,43 @@ export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
62
65
  }
63
66
  return initialize;
64
67
  }()
68
+ }, {
69
+ key: "resolveChannel",
70
+ value: function resolveChannel(query) {
71
+ return (query === null || query === void 0 ? void 0 : query.channel) || DEFAULT_SURCHARGE_CHANNEL;
72
+ }
65
73
  }, {
66
74
  key: "getSurchargeList",
67
75
  value: function () {
68
- var _getSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
76
+ var _getSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(query) {
77
+ var channel, loadingPromise, nextPromise;
69
78
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
70
79
  while (1) switch (_context2.prev = _context2.next) {
71
80
  case 0:
72
- if (!this.store.isLoaded) {
73
- _context2.next = 2;
81
+ channel = this.resolveChannel(query);
82
+ if (!(this.store.isLoaded && this.store.channel === channel)) {
83
+ _context2.next = 3;
74
84
  break;
75
85
  }
76
86
  return _context2.abrupt("return", this.store.surchargeList);
77
- case 2:
78
- if (!this.loadingPromise) {
79
- _context2.next = 4;
87
+ case 3:
88
+ loadingPromise = this.loadingPromises.get(channel);
89
+ if (!loadingPromise) {
90
+ _context2.next = 6;
80
91
  break;
81
92
  }
82
- return _context2.abrupt("return", this.loadingPromise);
83
- case 4:
84
- this.loadingPromise = this.loadSurchargeList();
85
- return _context2.abrupt("return", this.loadingPromise);
93
+ return _context2.abrupt("return", loadingPromise);
86
94
  case 6:
95
+ nextPromise = this.loadSurchargeList(channel);
96
+ this.loadingPromises.set(channel, nextPromise);
97
+ return _context2.abrupt("return", nextPromise);
98
+ case 9:
87
99
  case "end":
88
100
  return _context2.stop();
89
101
  }
90
102
  }, _callee2, this);
91
103
  }));
92
- function getSurchargeList() {
104
+ function getSurchargeList(_x3) {
93
105
  return _getSurchargeList.apply(this, arguments);
94
106
  }
95
107
  return getSurchargeList;
@@ -97,19 +109,22 @@ export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
97
109
  }, {
98
110
  key: "refreshSurchargeList",
99
111
  value: function () {
100
- var _refreshSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
112
+ var _refreshSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(query) {
113
+ var channel, nextPromise;
101
114
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
102
115
  while (1) switch (_context3.prev = _context3.next) {
103
116
  case 0:
104
- this.loadingPromise = this.loadSurchargeList();
105
- return _context3.abrupt("return", this.loadingPromise);
106
- case 2:
117
+ channel = this.resolveChannel(query);
118
+ nextPromise = this.loadSurchargeList(channel);
119
+ this.loadingPromises.set(channel, nextPromise);
120
+ return _context3.abrupt("return", nextPromise);
121
+ case 4:
107
122
  case "end":
108
123
  return _context3.stop();
109
124
  }
110
125
  }, _callee3, this);
111
126
  }));
112
- function refreshSurchargeList() {
127
+ function refreshSurchargeList(_x4) {
113
128
  return _refreshSurchargeList.apply(this, arguments);
114
129
  }
115
130
  return refreshSurchargeList;
@@ -117,42 +132,50 @@ export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
117
132
  }, {
118
133
  key: "loadSurchargeList",
119
134
  value: function () {
120
- var _loadSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
121
- var surchargeList;
135
+ var _loadSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(channel) {
136
+ var currentRequestVersion, surchargeList, nextSurchargeList;
122
137
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
123
138
  while (1) switch (_context4.prev = _context4.next) {
124
139
  case 0:
125
- _context4.prev = 0;
126
- _context4.next = 3;
140
+ currentRequestVersion = ++this.requestVersion;
141
+ _context4.prev = 1;
142
+ _context4.next = 4;
127
143
  return this.request.get('/order/custom-surcharge/available/v2', {
128
- channel: 'online-store',
144
+ channel: channel,
129
145
  is_assemble_product_data: 1,
130
146
  is_assemble_schedule_data: 1,
131
147
  with: ['relationSchedule']
132
148
  });
133
- case 3:
149
+ case 4:
134
150
  surchargeList = _context4.sent;
135
- this.store.surchargeList = (surchargeList === null || surchargeList === void 0 ? void 0 : surchargeList.data) || [];
136
- this.store.isLoaded = true;
137
- return _context4.abrupt("return", this.store.surchargeList);
138
- case 9:
139
- _context4.prev = 9;
140
- _context4.t0 = _context4["catch"](0);
151
+ nextSurchargeList = (surchargeList === null || surchargeList === void 0 ? void 0 : surchargeList.data) || [];
152
+ if (currentRequestVersion === this.requestVersion) {
153
+ this.store.surchargeList = nextSurchargeList;
154
+ this.store.channel = channel;
155
+ this.store.isLoaded = true;
156
+ }
157
+ return _context4.abrupt("return", nextSurchargeList);
158
+ case 10:
159
+ _context4.prev = 10;
160
+ _context4.t0 = _context4["catch"](1);
141
161
  console.warn('[SurchargeListModule] 加载附加费配置失败', _context4.t0);
142
- this.store.surchargeList = [];
143
- this.store.isLoaded = true;
144
- return _context4.abrupt("return", this.store.surchargeList);
162
+ if (currentRequestVersion === this.requestVersion) {
163
+ this.store.surchargeList = [];
164
+ this.store.channel = channel;
165
+ this.store.isLoaded = true;
166
+ }
167
+ return _context4.abrupt("return", []);
145
168
  case 15:
146
169
  _context4.prev = 15;
147
- this.loadingPromise = null;
170
+ this.loadingPromises.delete(channel);
148
171
  return _context4.finish(15);
149
172
  case 18:
150
173
  case "end":
151
174
  return _context4.stop();
152
175
  }
153
- }, _callee4, this, [[0, 9, 15, 18]]);
176
+ }, _callee4, this, [[1, 10, 15, 18]]);
154
177
  }));
155
- function loadSurchargeList() {
178
+ function loadSurchargeList(_x5) {
156
179
  return _loadSurchargeList.apply(this, arguments);
157
180
  }
158
181
  return loadSurchargeList;
@@ -4,8 +4,12 @@ export interface SurchargeListItem {
4
4
  export interface SurchargeListState {
5
5
  surchargeList: SurchargeListItem[];
6
6
  isLoaded: boolean;
7
+ channel?: string;
8
+ }
9
+ export interface SurchargeListQuery {
10
+ channel?: string;
7
11
  }
8
12
  export interface SurchargeListModuleAPI {
9
- getSurchargeList(): Promise<SurchargeListItem[]>;
10
- refreshSurchargeList(): Promise<SurchargeListItem[]>;
13
+ getSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
14
+ refreshSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
11
15
  }
@@ -2604,18 +2604,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2604
2604
  }, {
2605
2605
  key: "getWalletProductList",
2606
2606
  value: function getWalletProductList() {
2607
- var _this$store$order5, _tempOrder$products, _tempOrder$products2;
2607
+ var _this$store$order5, _tempOrder$products;
2608
2608
  var tempOrder = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getTempOrder();
2609
2609
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
2610
2610
  // 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
2611
- var products = tempOrder === null || tempOrder === void 0 || (_tempOrder$products2 = tempOrder.products) === null || _tempOrder$products2 === void 0 ? void 0 : _tempOrder$products2.filter(function (n) {
2612
- return n.product_id;
2613
- });
2614
- var walletProducts = products.map(function (product) {
2615
- var _product$product_vari2, _product$is_charge_ta, _product$holder_id, _metadata$main_produc, _metadata$main_produc2;
2611
+ // debugger
2612
+ // const products = tempOrder?.products?.filter(n => n.product_id)
2613
+
2614
+ var walletProducts = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products.map(function (product) {
2615
+ var _product$holder_id, _product$product_vari2, _product$is_charge_ta, _metadata$main_produc, _metadata$main_produc2;
2616
2616
  var metadata = product.metadata || {};
2617
+ var rawHolderId = (_product$holder_id = product.holder_id) !== null && _product$holder_id !== void 0 ? _product$holder_id : metadata.holder_id;
2618
+ var holderIdValue = Array.isArray(rawHolderId) ? rawHolderId[0] : rawHolderId;
2619
+ var holder_id = Number.isInteger(Number(holderIdValue)) ? Number(holderIdValue) : undefined;
2617
2620
  return {
2618
- product_id: product.product_id,
2621
+ product_id: product.product_id || 0,
2619
2622
  product_variant_id: String((_product$product_vari2 = product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : ''),
2620
2623
  quantity: product.num || 1,
2621
2624
  is_price_include_tax: tempOrder.is_price_include_tax,
@@ -2623,7 +2626,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2623
2626
  tax_fee: product.tax_fee,
2624
2627
  selling_price: Number(product.selling_price || 0),
2625
2628
  discount_list: product.discount_list || [],
2626
- holder_id: (_product$holder_id = product.holder_id) !== null && _product$holder_id !== void 0 ? _product$holder_id : metadata.holder_id,
2629
+ holder_id: holder_id,
2627
2630
  original_price: product.original_price,
2628
2631
  main_product_original_price: (_metadata$main_produc = metadata.main_product_original_price) !== null && _metadata$main_produc !== void 0 ? _metadata$main_produc : product.original_price,
2629
2632
  main_product_selling_price: (_metadata$main_produc2 = metadata.main_product_selling_price) !== null && _metadata$main_produc2 !== void 0 ? _metadata$main_produc2 : product.selling_price,
@@ -66,7 +66,8 @@ function normalizeBundleItems(bundleItems) {
66
66
  price: (_bundleItem$price3 = bundleItem.price) !== null && _bundleItem$price3 !== void 0 ? _bundleItem$price3 : unitStr,
67
67
  bundle_selling_price: unitStr,
68
68
  original_price: (_ref8 = (_ref9 = (_bundleItem$original_ = bundleItem.original_price) !== null && _bundleItem$original_ !== void 0 ? _bundleItem$original_ : bundleItem.product_price) !== null && _ref9 !== void 0 ? _ref9 : bundleItem.price) !== null && _ref8 !== void 0 ? _ref8 : unitStr,
69
- option: normalizeOptionItems(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option)
69
+ option: normalizeOptionItems(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option),
70
+ discount_list: preferPriceField ? [] : bundleItem.discount_list
70
71
  });
71
72
  // bundle_selling_price 落「正净额」:markdown = |price| − Σoptions;markup/原价维持原值。
72
73
  normalizedItem.bundle_selling_price = getBundleSellingMagnitude(magnitudeSource).toFixed(2);
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 5 | 1 | 2 | 3 | 6 | 4;
314
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
322
322
  * 获取当前的客户搜索条件
323
323
  * @returns 当前搜索条件
324
324
  */
325
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
325
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
326
326
  /**
327
327
  * 获取客户列表状态(包含滚动加载相关状态)
328
328
  * @returns 客户状态
@@ -441,19 +441,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
441
441
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
442
442
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
443
443
  */
444
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
445
- action: "reloadCatalog";
446
- } | {
447
- action: "add";
448
- cacheItem: any;
449
- } | {
450
- action: "requiresDetail";
451
- payload: AddProductRequiresDetailPayload;
452
- } | {
453
- action: "requiresBookingEdit";
454
- cacheItem: any;
455
- payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
456
- };
444
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
457
445
  /** 规格弹窗 callback 后的第二段决策。 */
458
446
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
459
447
  /**
@@ -197,6 +197,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
197
197
  private clearManualDepositOverride;
198
198
  private getOriginalSalesSnapshot;
199
199
  private isSnapshotPayableAmountUnchanged;
200
+ private hasShopDiscountChangedFromSnapshot;
200
201
  private restoreOriginalSnapshotIfProductsUnchanged;
201
202
  private clearPersistedAmountFieldsForFullRecalc;
202
203
  private getPaymentTargetAmount;
@@ -230,6 +231,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
230
231
  * const ids = this.collectBookingHolderRecords(booking);
231
232
  */
232
233
  private collectBookingHolderRecords;
234
+ private setProductHolderFromBooking;
235
+ private syncLinkedBookingHoldersToProducts;
233
236
  /**
234
237
  * 按 form_record 顺序读取 booking holder 的主字段名称。
235
238
  *
@@ -458,7 +461,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
458
461
  generateIdempotencyToken(): string;
459
462
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
460
463
  createOrder(params: CommitOrderParams['query']): {
461
- type: "appointment_booking" | "virtual";
464
+ type: "virtual" | "appointment_booking";
462
465
  platform: string;
463
466
  sales_channel: string;
464
467
  order_sales_channel: string;