@pisell/materials 1.0.466 → 1.0.467

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.
@@ -145,7 +145,7 @@ export var getServeStartTime = function getServeStartTime(start_time) {
145
145
  * @Date: 2024-04-26 14:04
146
146
  */
147
147
  export var getServiceTime = function getServiceTime(item, currentDate) {
148
- var _item$_extend, _item$_extend2, _item$_extend3, _item$_extend5, _item$_extend6;
148
+ var _item$_extend, _item$_extend2, _item$_extend3, _item$_extend6, _item$_extend7;
149
149
  if (!currentDate || !(item !== null && item !== void 0 && (_item$_extend = item._extend) !== null && _item$_extend !== void 0 && _item$_extend.start_time) || !dayjs(currentDate).isValid()) return '';
150
150
  var locale = (item === null || item === void 0 ? void 0 : item.locale) || 'en-US';
151
151
  var isEn = locale === 'en-US' || locale === 'en';
@@ -155,19 +155,17 @@ export var getServiceTime = function getServiceTime(item, currentDate) {
155
155
 
156
156
  // 跨日
157
157
  if ((item === null || item === void 0 ? void 0 : (_item$_extend3 = item._extend) === null || _item$_extend3 === void 0 ? void 0 : _item$_extend3.sub_type) === 'days') {
158
- var _item$_extend4;
159
- // 结束日期 + 1 分钟计算天数
160
- var endDate = dayjs(item === null || item === void 0 ? void 0 : (_item$_extend4 = item._extend) === null || _item$_extend4 === void 0 ? void 0 : _item$_extend4.end_date);
161
- var newEndDate = endDate.add(1, 'minute');
162
- var _endTime = endDate.format('HH:mm');
163
- var diffInDays = newEndDate.diff(startDate, 'day');
158
+ var _item$_extend4, _item$_extend5;
159
+ var _startDate = dayjs(item === null || item === void 0 ? void 0 : (_item$_extend4 = item._extend) === null || _item$_extend4 === void 0 ? void 0 : _item$_extend4.start_date);
160
+ var endDate = dayjs(item === null || item === void 0 ? void 0 : (_item$_extend5 = item._extend) === null || _item$_extend5 === void 0 ? void 0 : _item$_extend5.end_date);
161
+ var diffInDays = endDate.diff(_startDate, 'day');
164
162
  var _format = isEn ? 'ddd, DD/MM/YYYY' : 'YYYY-MM-DD,ddd';
165
- var date = "".concat(startDate.format(_format), " ~ ").concat(endDate.format(_format));
163
+ var date = "".concat(_startDate.format(_format), " ~ ").concat(endDate.format(_format));
166
164
  var _duration = "".concat(diffInDays, " ").concat(locales.getText('pisell2.product.card.day')(diffInDays));
167
165
  return "".concat(date, " (").concat(_duration, ")");
168
166
  }
169
- var endTime = startDate.add(flexibleObj.getValue(item === null || item === void 0 ? void 0 : (_item$_extend5 = item._extend) === null || _item$_extend5 === void 0 ? void 0 : _item$_extend5.duration), 'minute').format('HH:mm');
170
- var duration = getDiscountTime(flexibleObj.getValue(item === null || item === void 0 ? void 0 : (_item$_extend6 = item._extend) === null || _item$_extend6 === void 0 ? void 0 : _item$_extend6.duration));
167
+ var endTime = startDate.add(flexibleObj.getValue(item === null || item === void 0 ? void 0 : (_item$_extend6 = item._extend) === null || _item$_extend6 === void 0 ? void 0 : _item$_extend6.duration), 'minute').format('HH:mm');
168
+ var duration = getDiscountTime(flexibleObj.getValue(item === null || item === void 0 ? void 0 : (_item$_extend7 = item._extend) === null || _item$_extend7 === void 0 ? void 0 : _item$_extend7.duration));
171
169
  return "".concat(startTime, " - ").concat(endTime, " ( ").concat(duration, " )");
172
170
  };
173
171
  export var findNextSlice = function findNextSlice(_ref) {
@@ -623,10 +621,10 @@ export var getServerItemExtend = function getServerItemExtend(state, cacheItem,
623
621
 
624
622
  // 商品价格: (商品价格 + (套餐价格 + 单规格价格 * 单规格数量) * 套餐数量) * 商品数量
625
623
  export var getProductTotalPrice = function getProductTotalPrice(item) {
626
- var _item$_extend7;
624
+ var _item$_extend8;
627
625
  var price = 0;
628
626
  price += Number(item._extend.price);
629
- var other = (_item$_extend7 = item._extend) === null || _item$_extend7 === void 0 ? void 0 : _item$_extend7.other;
627
+ var other = (_item$_extend8 = item._extend) === null || _item$_extend8 === void 0 ? void 0 : _item$_extend8.other;
630
628
  if (other !== null && other !== void 0 && other.bundle) {
631
629
  // bundle
632
630
  price = other === null || other === void 0 ? void 0 : other.bundle.reduce(function (accumulator, currentValue) {
@@ -137,7 +137,7 @@ var getServeStartTime = (start_time) => {
137
137
  return start_time;
138
138
  };
139
139
  var getServiceTime = (item, currentDate) => {
140
- var _a, _b, _c, _d, _e, _f;
140
+ var _a, _b, _c, _d, _e, _f, _g;
141
141
  if (!currentDate || !((_a = item == null ? void 0 : item._extend) == null ? void 0 : _a.start_time) || !(0, import_dayjs.default)(currentDate).isValid())
142
142
  return "";
143
143
  const locale = (item == null ? void 0 : item.locale) || "en-US";
@@ -148,17 +148,16 @@ var getServiceTime = (item, currentDate) => {
148
148
  );
149
149
  const startTime = startDate.format("HH:mm");
150
150
  if (((_c = item == null ? void 0 : item._extend) == null ? void 0 : _c.sub_type) === "days") {
151
- const endDate = (0, import_dayjs.default)((_d = item == null ? void 0 : item._extend) == null ? void 0 : _d.end_date);
152
- const newEndDate = endDate.add(1, "minute");
153
- const endTime2 = endDate.format("HH:mm");
154
- const diffInDays = newEndDate.diff(startDate, "day");
151
+ const startDate2 = (0, import_dayjs.default)((_d = item == null ? void 0 : item._extend) == null ? void 0 : _d.start_date);
152
+ const endDate = (0, import_dayjs.default)((_e = item == null ? void 0 : item._extend) == null ? void 0 : _e.end_date);
153
+ const diffInDays = endDate.diff(startDate2, "day");
155
154
  const _format = isEn ? "ddd, DD/MM/YYYY" : "YYYY-MM-DD,ddd";
156
- const date = `${startDate.format(_format)} ~ ${endDate.format(_format)}`;
155
+ const date = `${startDate2.format(_format)} ~ ${endDate.format(_format)}`;
157
156
  const duration2 = `${diffInDays} ${import_utils.locales.getText("pisell2.product.card.day")(diffInDays)}`;
158
157
  return `${date} (${duration2})`;
159
158
  }
160
- const endTime = startDate.add(flexibleObj.getValue((_e = item == null ? void 0 : item._extend) == null ? void 0 : _e.duration), "minute").format("HH:mm");
161
- const duration = getDiscountTime(flexibleObj.getValue((_f = item == null ? void 0 : item._extend) == null ? void 0 : _f.duration));
159
+ const endTime = startDate.add(flexibleObj.getValue((_f = item == null ? void 0 : item._extend) == null ? void 0 : _f.duration), "minute").format("HH:mm");
160
+ const duration = getDiscountTime(flexibleObj.getValue((_g = item == null ? void 0 : item._extend) == null ? void 0 : _g.duration));
162
161
  return `${startTime} - ${endTime} ( ${duration} )`;
163
162
  };
164
163
  var findNextSlice = ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "1.0.466",
3
+ "version": "1.0.467",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",