(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["chunk-23b03313"],{

/***/ "2f79":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";

// EXPORTS
__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ cores; });
__webpack_require__.d(__webpack_exports__, "b", function() { return /* binding */ multiTskHandleMap; });

// EXTERNAL MODULE: ./src/utils/util.js
var util = __webpack_require__("ca00");

// EXTERNAL MODULE: ./src/data/log.js
var log = __webpack_require__("6b23");

// EXTERNAL MODULE: ./src/platform/temu/index.js
var temu = __webpack_require__("c04e");

// CONCATENATED MODULE: ./src/platform/temu/getSupplierPrice.js
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }



 // 获取本土供货价

var getLocalSupplierPrice = /*#__PURE__*/function () {
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(task, skuIds) {
    var retry,
        changeStoreId,
        _yield$nativeRequest,
        success,
        error_code,
        result,
        succ,
        fail,
        msg,
        _msg,
        _args2 = arguments;

    return _regeneratorRuntime().wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            retry = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : 0;
            _context2.prev = 1;
            changeStoreId = "".concat(task.platform_store_id, "&").concat(task.siteId);
            _context2.next = 5;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/mms/marigold/goods/v2/search#LINGXING"), 'post', {
              page_size: 100,
              page_no: 1,
              order_type: 0,
              order_field: "gmt_create",
              enable_batch_search_text: true,
              goods_search_type: 1,
              search_text: skuIds.join(',')
            });

          case 5:
            _yield$nativeRequest = _context2.sent;
            success = _yield$nativeRequest.success;
            error_code = _yield$nativeRequest.error_code;
            result = _yield$nativeRequest.result;

            if (!(success && result && result.goods_list)) {
              _context2.next = 17;
              break;
            }

            succ = [];
            fail = [];
            _context2.next = 14;
            return Promise.all(result.goods_list.map( /*#__PURE__*/function () {
              var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref2) {
                var supplier_price, sku_id_list, commit_id, goods_id, currency, crt_time, variant;
                return _regeneratorRuntime().wrap(function _callee$(_context) {
                  while (1) {
                    switch (_context.prev = _context.next) {
                      case 0:
                        supplier_price = _ref2.supplier_price, sku_id_list = _ref2.sku_id_list, commit_id = _ref2.commit_id, goods_id = _ref2.goods_id, currency = _ref2.currency, crt_time = _ref2.crt_time;

                        if (!supplier_price) {
                          _context.next = 5;
                          break;
                        }

                        succ.push({
                          productSkuId: sku_id_list[0],
                          supplierPrice: supplier_price,
                          currency: currency,
                          crtTime: crt_time
                        });
                        _context.next = 9;
                        break;

                      case 5:
                        _context.next = 7;
                        return getLocalVariantSupplierPrice({
                          commit_id: commit_id,
                          goods_id: goods_id,
                          host: task.host,
                          changeStoreId: changeStoreId,
                          task: task
                        });

                      case 7:
                        variant = _context.sent;

                        if (variant.code === 0) {
                          succ.push.apply(succ, _toConsumableArray(variant.result));
                        } else {
                          // 获取失败时，因为不知道是任务下发的是哪个skuid，所以得找一下
                          sku_id_list.forEach(function (sku_id) {
                            if (skuIds.includes(sku_id)) fail.push(sku_id);
                          });
                        }

                      case 9:
                      case "end":
                        return _context.stop();
                    }
                  }
                }, _callee);
              }));

              return function (_x3) {
                return _ref3.apply(this, arguments);
              };
            }()));

          case 14:
            return _context2.abrupt("return", {
              code: 0,
              succ: succ,
              fail: fail
            });

          case 17:
            msg = "\u83B7\u53D6\u672C\u571F\u4F9B\u8D27\u4EF7\u5931\u8D25\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(JSON.stringify(result), "-----error_code: ").concat(error_code);
            log["a" /* default */].setLog(msg);
            return _context2.abrupt("return", {
              msg: msg,
              code: 2
            });

          case 20:
            _context2.next = 32;
            break;

          case 22:
            _context2.prev = 22;
            _context2.t0 = _context2["catch"](1);
            _msg = "\u83B7\u53D6\u672C\u571F\u4F9B\u8D27\u4EF7\u5931\u8D25-----".concat(Object(util["r" /* isError */])(_context2.t0, task));
            log["a" /* default */].setLog(_msg); // 重试三次

            if (!(retry < 3)) {
              _context2.next = 31;
              break;
            }

            log["a" /* default */].setLog('正在重试........................');
            _context2.next = 30;
            return Object(util["g" /* delayed */])(3 * 1000);

          case 30:
            return _context2.abrupt("return", getLocalSupplierPrice(task, skuIds, ++retry));

          case 31:
            return _context2.abrupt("return", {
              msg: _msg,
              code: 2
            });

          case 32:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2, null, [[1, 22]]);
  }));

  return function getLocalSupplierPrice(_x, _x2) {
    return _ref.apply(this, arguments);
  };
}(); // 获取本土变体供货价


var getLocalVariantSupplierPrice = /*#__PURE__*/function () {
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
    var commit_id,
        goods_id,
        host,
        changeStoreId,
        task,
        retry,
        taskId,
        _yield$nativeRequest2,
        result,
        success,
        error_code,
        msg,
        _msg2,
        _args3 = arguments;

    return _regeneratorRuntime().wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            commit_id = _ref4.commit_id, goods_id = _ref4.goods_id, host = _ref4.host, changeStoreId = _ref4.changeStoreId, task = _ref4.task;
            retry = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : 0;
            taskId = task.task_id;
            _context3.prev = 3;
            _context3.next = 6;
            return Object(util["u" /* nativeRequest */])("".concat(host, "/mms/marigold/sku/query#LINGXING"), 'POST', {
              commit_id: commit_id,
              goods_id: goods_id,
              source_type_of_sku_query: 1
            });

          case 6:
            _yield$nativeRequest2 = _context3.sent;
            result = _yield$nativeRequest2.result;
            success = _yield$nativeRequest2.success;
            error_code = _yield$nativeRequest2.error_code;

            if (!(success && result.sku_list && result.sku_list.length)) {
              _context3.next = 14;
              break;
            }

            return _context3.abrupt("return", {
              code: 0,
              result: result.sku_list.map(function (_ref6) {
                var sku_id = _ref6.sku_id,
                    supplier_price = _ref6.supplier_price,
                    currency = _ref6.currency,
                    crt_time = _ref6.crt_time;
                return {
                  productSkuId: sku_id,
                  supplierPrice: supplier_price,
                  currency: currency,
                  crtTime: crt_time
                };
              })
            });

          case 14:
            msg = "\u83B7\u53D6\u672C\u571F\u53D8\u4F53\u4F9B\u8D27\u4EF7\u5931\u8D25\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(error_code, ",result----").concat(JSON.stringify(result));
            log["a" /* default */].report(msg, 'except', {
              goods_id: goods_id,
              taskId: taskId
            });
            return _context3.abrupt("return", {
              code: 1,
              msg: msg
            });

          case 17:
            _context3.next = 29;
            break;

          case 19:
            _context3.prev = 19;
            _context3.t0 = _context3["catch"](3);
            _msg2 = "\u83B7\u53D6\u672C\u571F\u53D8\u4F53\u4F9B\u8D27\u4EF7\u8BF7\u6C42\u5931\u8D25----".concat(Object(util["r" /* isError */])(_context3.t0, task));
            log["a" /* default */].report(_msg2, 'except', {
              goods_id: goods_id,
              taskId: taskId
            }); // 重试三次

            if (!(retry < 3)) {
              _context3.next = 28;
              break;
            }

            log["a" /* default */].setLog('正在重试........................');
            _context3.next = 27;
            return Object(util["g" /* delayed */])(3 * 1000);

          case 27:
            return _context3.abrupt("return", getLocalVariantSupplierPrice({
              commit_id: commit_id,
              goods_id: goods_id,
              host: host,
              changeStoreId: changeStoreId,
              taskId: taskId
            }, ++retry));

          case 28:
            return _context3.abrupt("return", {
              code: 1,
              msg: _msg2
            });

          case 29:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3, null, [[3, 19]]);
  }));

  return function getLocalVariantSupplierPrice(_x4) {
    return _ref5.apply(this, arguments);
  };
}(); // 获取跨境供货价


var getCbSupplierPrice = /*#__PURE__*/function () {
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(task, skuIds) {
    var retry,
        _yield$nativeRequest3,
        success,
        errorMsg,
        result,
        msg,
        _msg3,
        _args4 = arguments;

    return _regeneratorRuntime().wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            retry = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : 0;
            _context4.prev = 1;
            _context4.next = 4;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/visage-agent-seller/product/skc/pageQuery"), // host需要改为 cbGLOBALhost
            'post', {
              productSkuIds: skuIds,
              page: 1,
              pageSize: 200
            }, {
              Mallid: task.platform_store_id
            });

          case 4:
            _yield$nativeRequest3 = _context4.sent;
            success = _yield$nativeRequest3.success;
            errorMsg = _yield$nativeRequest3.errorMsg;
            result = _yield$nativeRequest3.result;

            if (!(success && result && result.pageItems)) {
              _context4.next = 12;
              break;
            }

            return _context4.abrupt("return", {
              code: 0,
              succ: result.pageItems.reduce(function (arr, _ref8) {
                var productSkuSummaries = _ref8.productSkuSummaries,
                    createdAt = _ref8.createdAt;
                return arr.concat(productSkuSummaries.map(function (_ref9) {
                  var productSkuId = _ref9.productSkuId,
                      supplierPrice = _ref9.supplierPrice,
                      currencyType = _ref9.currencyType,
                      siteSupplierPrices = _ref9.siteSupplierPrices;
                  return {
                    productSkuId: productSkuId,
                    supplierPrice: supplierPrice,
                    siteSupplierPrices: siteSupplierPrices,
                    crtTime: createdAt,
                    currency: currencyType
                  };
                }));
              }, [])
            });

          case 12:
            msg = "\u83B7\u53D6\u8DE8\u5883\u4F9B\u8D27\u4EF7\u5931\u8D25\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(errorMsg);
            log["a" /* default */].setLog(msg);
            return _context4.abrupt("return", {
              msg: msg,
              code: 2
            });

          case 15:
            _context4.next = 27;
            break;

          case 17:
            _context4.prev = 17;
            _context4.t0 = _context4["catch"](1);
            _msg3 = "\u83B7\u53D6\u8DE8\u5883\u4F9B\u8D27\u4EF7\u5931\u8D25-----".concat(Object(util["r" /* isError */])(_context4.t0, task));
            log["a" /* default */].setLog(_msg3); // 重试三次

            if (!(retry < 3)) {
              _context4.next = 26;
              break;
            }

            log["a" /* default */].setLog('正在重试........................');
            _context4.next = 25;
            return Object(util["g" /* delayed */])(3 * 1000);

          case 25:
            return _context4.abrupt("return", getCbSupplierPrice(task, skuIds, ++retry));

          case 26:
            return _context4.abrupt("return", {
              msg: _msg3,
              code: 2
            });

          case 27:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4, null, [[1, 17]]);
  }));

  return function getCbSupplierPrice(_x5, _x6) {
    return _ref7.apply(this, arguments);
  };
}();

var getSupplierPrice = /*#__PURE__*/function () {
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(task) {
    var num, handle, _res, skuIds, failSkuIds, succSkuIds, msg, res, count, batchSkuIds, i, ids, _yield$handle, code, errormMsg, fail, succ;

    return _regeneratorRuntime().wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            // 获取单次请求skuid数量&不同类型方法
            if (+task.platform_code === 10022) {
              num = 200;
              handle = getCbSupplierPrice;
            } else {
              _res = {
                'GLOBAL': {
                  num: 200,
                  handle: getCbSupplierPrice
                },
                'LOCAL': {
                  num: 100,
                  handle: getLocalSupplierPrice
                }
              }[task.store_type];
              num = _res.num;
              handle = _res.handle;
            }

            skuIds = task.failSkuIds || task.skuIds || [];
            failSkuIds = [];
            succSkuIds = [];
            res = {
              code: 0,
              msg: ''
            };
            count = Math.ceil(skuIds.length / num);
            batchSkuIds = Array(count).fill(1).map(function (i, key) {
              return skuIds.slice(key * 200, (key + 1) * 200);
            }); // 分批遍历获取，一次性拿完后再上报

            i = 0;

          case 8:
            if (!(i < batchSkuIds.length)) {
              _context5.next = 23;
              break;
            }

            ids = batchSkuIds[i]; // 等待5s

            _context5.next = 12;
            return Object(util["g" /* delayed */])(5);

          case 12:
            _context5.next = 14;
            return handle(task, ids);

          case 14:
            _yield$handle = _context5.sent;
            code = _yield$handle.code;
            errormMsg = _yield$handle.errormMsg;
            fail = _yield$handle.fail;
            succ = _yield$handle.succ;

            if (code === 0) {
              // 执行前记录当前已获取数据
              task.currentNum = (i + 1) * 200;
              task.total = skuIds.length;
              succSkuIds.push.apply(succSkuIds, _toConsumableArray(succ || []));
            } else {
              failSkuIds.push.apply(failSkuIds, _toConsumableArray(fail || ids)); // 错误消息的话就取最后一个就行，一搬有报错都是一样的报错

              msg = errormMsg;
            }

          case 20:
            i++;
            _context5.next = 8;
            break;

          case 23:
            if (!succSkuIds.length) {
              _context5.next = 27;
              break;
            }

            // 上报的数据
            res.result = succSkuIds;
            _context5.next = 31;
            break;

          case 27:
            // 一条都没获取到，上报异常
            res.code = 2;
            res.msg = "\u672A\u83B7\u53D6\u5230\u4EFB\u4F55\u6570\u636E,\u9700\u8981\u83B7\u53D6\u7684skuId:".concat(skuIds.join(','));
            task.status = 14;
            return _context5.abrupt("return", res);

          case 31:
            // 记录获取失败的skuid
            if (failSkuIds.length) {
              task.failSkuIds = failSkuIds;
              res.code = 4;
              res.data = {
                failSkuIds: failSkuIds,
                skuIds: task.skuIds
              };
              res.msg = msg;
            } else {
              res.msg = '获取完毕';
            }

            return _context5.abrupt("return", res);

          case 33:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));

  return function getSupplierPrice(_x7) {
    return _ref10.apply(this, arguments);
  };
}();

var handleGetSupplierPrice = /*#__PURE__*/function () {
  var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(task) {
    var loginRes, msg, res;
    return _regeneratorRuntime().wrap(function _callee6$(_context6) {
      while (1) {
        switch (_context6.prev = _context6.next) {
          case 0:
            _context6.prev = 0;

            if (!(task.resCache && task.resCache.code === 0)) {
              _context6.next = 3;
              break;
            }

            return _context6.abrupt("return", task.resCache);

          case 3:
            if (!(task.platform_code === 10022 || task.store_type === 'GLOBAL')) {
              _context6.next = 12;
              break;
            }

            _context6.next = 6;
            return Object(temu["e" /* loginCb */])(task);

          case 6:
            loginRes = _context6.sent;

            if (loginRes) {
              _context6.next = 12;
              break;
            }

            msg = '切换到美区或欧区站点失败，请检查';
            task.msg = msg;
            log["a" /* default */].setLog(msg);
            return _context6.abrupt("return", {
              code: 1,
              msg: msg
            });

          case 12:
            _context6.next = 14;
            return getSupplierPrice(task);

          case 14:
            res = _context6.sent;
            task.status = [1, 2].indexOf(res.code) > -1 ? 14 : 15;
            task.msg = res.msg;
            return _context6.abrupt("return", res);

          case 20:
            _context6.prev = 20;
            _context6.t0 = _context6["catch"](0);
            log["a" /* default */].setLog("handleGetSupplierPrice error: ".concat(Object(util["r" /* isError */])(_context6.t0)));
            task.status = 14;
            task.msg = "\u83B7\u53D6\u4F9B\u8D27\u4EF7\u5931\u8D25\uFF0C\u5931\u8D25\u539F\u56E0\uFF1A".concat(Object(util["r" /* isError */])(_context6.t0));
            return _context6.abrupt("return", {
              code: 2,
              msg: task.msg
            });

          case 26:
          case "end":
            return _context6.stop();
        }
      }
    }, _callee6, null, [[0, 20]]);
  }));

  return function handleGetSupplierPrice(_x8) {
    return _ref11.apply(this, arguments);
  };
}();

/* harmony default export */ var temu_getSupplierPrice = (handleGetSupplierPrice);
// EXTERNAL MODULE: ./node_modules/moment/moment.js
var moment = __webpack_require__("c1df");
var moment_default = /*#__PURE__*/__webpack_require__.n(moment);

// EXTERNAL MODULE: ./src/platform/common/newTask.js
var newTask = __webpack_require__("5e61");

// CONCATENATED MODULE: ./src/platform/temu/getSaleVolume.js
function getSaleVolume_typeof(obj) { "@babel/helpers - typeof"; return getSaleVolume_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, getSaleVolume_typeof(obj); }

function getSaleVolume_toConsumableArray(arr) { return getSaleVolume_arrayWithoutHoles(arr) || getSaleVolume_iterableToArray(arr) || getSaleVolume_unsupportedIterableToArray(arr) || getSaleVolume_nonIterableSpread(); }

function getSaleVolume_nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function getSaleVolume_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return getSaleVolume_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return getSaleVolume_arrayLikeToArray(o, minLen); }

function getSaleVolume_iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }

function getSaleVolume_arrayWithoutHoles(arr) { if (Array.isArray(arr)) return getSaleVolume_arrayLikeToArray(arr); }

function getSaleVolume_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function getSaleVolume_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ getSaleVolume_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == getSaleVolume_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function getSaleVolume_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function getSaleVolume_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { getSaleVolume_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { getSaleVolume_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }





 // 获取销量列表的页数

var $count = 40;
/**
 * @description 获取近三十天销量
 * @param {*} task
 * @returns res object  code: 0: 成功 1:失败 2：异常 5：无销量
 */

var requestSaleVolumeBySkuId = /*#__PURE__*/function () {
  var _ref = getSaleVolume_asyncToGenerator( /*#__PURE__*/getSaleVolume_regeneratorRuntime().mark(function _callee(task, skuIds, retry) {
    var curDate, endDate, startDate, _yield$nativeRequest, success, errorMsg, result, msg, _msg, _msg2;

    return getSaleVolume_regeneratorRuntime().wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.prev = 0;
            _context.next = 3;
            return Object(util["q" /* getServiceTime */])();

          case 3:
            curDate = _context.sent;
            endDate = moment_default()(curDate).format('YYYY-MM-DD');
            startDate = moment_default()(curDate).subtract(30, 'days').format('YYYY-MM-DD');
            _context.next = 8;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/mms/venom/api/supplier/sales/management/querySkuSalesNumber"), // host需要改为 cbGlobalHost
            'post', {
              productSkuIds: skuIds,
              startDate: startDate,
              endDate: endDate
            }, {
              Mallid: task.platform_store_id
            });

          case 8:
            _yield$nativeRequest = _context.sent;
            success = _yield$nativeRequest.success;
            errorMsg = _yield$nativeRequest.errorMsg;
            result = _yield$nativeRequest.result;

            if (!(success && result)) {
              _context.next = 22;
              break;
            }

            if (!result.length) {
              _context.next = 17;
              break;
            }

            return _context.abrupt("return", {
              code: 0,
              result: result
            });

          case 17:
            msg = "".concat(skuIds.splice(0, 3).join(','), "\u7B49skuid\u65E0\u9500\u91CF");
            log["a" /* default */].setLog(msg);
            return _context.abrupt("return", {
              msg: msg,
              code: 5
            });

          case 20:
            _context.next = 25;
            break;

          case 22:
            _msg = "\u83B7\u53D6\u5168\u6258\u7BA1\u9500\u91CF\u5931\u8D25\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(JSON.stringify(errorMsg));
            log["a" /* default */].setLog(_msg);
            return _context.abrupt("return", {
              msg: _msg,
              code: 1
            });

          case 25:
            _context.next = 37;
            break;

          case 27:
            _context.prev = 27;
            _context.t0 = _context["catch"](0);
            _msg2 = "\u83B7\u53D6\u8FD1\u4E09\u5341\u5929\u9500\u91CF\u5931\u8D25-----".concat(Object(util["r" /* isError */])(_context.t0));
            log["a" /* default */].setLog(_msg2); // 重试三次

            if (!(retry < 3)) {
              _context.next = 36;
              break;
            }

            log["a" /* default */].setLog('正在重试........................');
            _context.next = 35;
            return Object(util["g" /* delayed */])(3 * 1000);

          case 35:
            return _context.abrupt("return", requestSaleVolumeBySkuId(task, skuIds, ++retry));

          case 36:
            return _context.abrupt("return", {
              msg: _msg2,
              code: 2
            });

          case 37:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, null, [[0, 27]]);
  }));

  return function requestSaleVolumeBySkuId(_x, _x2, _x3) {
    return _ref.apply(this, arguments);
  };
}();
/**
 * @description 获取全托管近三十天销量列表&供货价&供货价
 * @param {*} task
 * @returns
 */


var requestSkuid = /*#__PURE__*/function () {
  var _ref2 = getSaleVolume_asyncToGenerator( /*#__PURE__*/getSaleVolume_regeneratorRuntime().mark(function _callee2(task) {
    var pageNo,
        retry,
        _yield$nativeRequest2,
        success,
        errorMsg,
        result,
        subOrderList,
        info,
        total,
        msg,
        _msg3,
        _args2 = arguments;

    return getSaleVolume_regeneratorRuntime().wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            pageNo = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 1;
            retry = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : 0;
            _context2.prev = 2;
            _context2.next = 5;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/mms/venom/api/supplier/sales/management/listWarehouse"), // host需要改为 cbGlobalHost
            'post', {
              pageNo: pageNo,
              pageSize: $count,
              isLack: 0,
              priceAdjustRecentDays: 7,
              thirtyDaysSaleVolumMin: 1,
              advancedSort: {
                firstOrderByDesc: 1,
                firstOrderByParam: 'lastThirtyDaysSaleVolume',
                secondOrderByDesc: 1,
                secondOrderByParam: 'lastThirtyDaysSaleVolume'
              }
            }, {
              Mallid: task.platform_store_id
            });

          case 5:
            _yield$nativeRequest2 = _context2.sent;
            success = _yield$nativeRequest2.success;
            errorMsg = _yield$nativeRequest2.errorMsg;
            result = _yield$nativeRequest2.result;

            if (!(success && result && result.subOrderList)) {
              _context2.next = 19;
              break;
            }

            subOrderList = result.subOrderList;
            info = [];
            total = result.total || 0;

            if (subOrderList.length) {
              _context2.next = 15;
              break;
            }

            return _context2.abrupt("return", {
              code: 0,
              msg: '获取完毕',
              info: info,
              total: total
            });

          case 15:
            // 收集skuid&供货价
            subOrderList.forEach(function (_ref3) {
              var skuQuantityDetailList = _ref3.skuQuantityDetailList;

              if (skuQuantityDetailList.length) {
                info.push.apply(info, getSaleVolume_toConsumableArray(skuQuantityDetailList.map(function (_ref4) {
                  var productSkuId = _ref4.productSkuId,
                      supplierPrice = _ref4.supplierPrice,
                      currencyType = _ref4.currencyType,
                      skuExtCode = _ref4.skuExtCode;
                  return {
                    productSkuId: productSkuId,
                    supplierPrice: supplierPrice,
                    currencyType: currencyType,
                    skuExtCode: skuExtCode
                  };
                })));
              }
            });
            return _context2.abrupt("return", {
              code: 0,
              info: info,
              total: total,
              pageNo: pageNo
            });

          case 19:
            msg = "\u83B7\u53D6\u5168\u6258\u7BA1\u8FD130\u5929\u9500\u91CF\u5217\u8868\u5931\u8D25\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(JSON.stringify(errorMsg));
            log["a" /* default */].setLog(msg);
            return _context2.abrupt("return", {
              msg: msg,
              pageNo: pageNo,
              code: 1
            });

          case 22:
            _context2.next = 34;
            break;

          case 24:
            _context2.prev = 24;
            _context2.t0 = _context2["catch"](2);
            _msg3 = "\u83B7\u53D6\u5168\u6258\u7BA1\u8FD1\u4E09\u5341\u5929\u9500\u91CF\u5217\u8868&\u4F9B\u8D27\u4EF7\u5931\u8D25-----".concat(Object(util["r" /* isError */])(_context2.t0, task));
            log["a" /* default */].setLog(_msg3); // 重试三次

            if (!(retry < 3)) {
              _context2.next = 33;
              break;
            }

            log["a" /* default */].setLog('正在重试........................');
            _context2.next = 32;
            return Object(util["g" /* delayed */])(5 * 1000);

          case 32:
            return _context2.abrupt("return", requestSkuid(task, pageNo, ++retry));

          case 33:
            return _context2.abrupt("return", {
              msg: _msg3,
              pageNo: pageNo,
              code: 2
            });

          case 34:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2, null, [[2, 24]]);
  }));

  return function requestSkuid(_x4) {
    return _ref2.apply(this, arguments);
  };
}();
/**
 * 获取全托管skuid&供货价 - 用户单独勾选sku获取销量时用到
 * @param {*} task
 * @param {*} retry
 * @returns
 */


var getSaleVolume_getCbSupplierPrice = /*#__PURE__*/function () {
  var _ref5 = getSaleVolume_asyncToGenerator( /*#__PURE__*/getSaleVolume_regeneratorRuntime().mark(function _callee3(task) {
    var retry,
        pageNo,
        _yield$nativeRequest3,
        success,
        errorMsg,
        result,
        msg,
        _msg4,
        _args3 = arguments;

    return getSaleVolume_regeneratorRuntime().wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            retry = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : 0;
            pageNo = task.pageNo || 1;
            _context3.prev = 2;
            _context3.next = 5;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/visage-agent-seller/product/skc/pageQuery"), // host需要改为 cbGlobalHost
            'post', {
              productSkuIds: task.skuIds,
              page: pageNo,
              pageSize: $count
            }, {
              Mallid: task.platform_store_id
            });

          case 5:
            _yield$nativeRequest3 = _context3.sent;
            success = _yield$nativeRequest3.success;
            errorMsg = _yield$nativeRequest3.errorMsg;
            result = _yield$nativeRequest3.result;

            if (!(success && result && result.pageItems)) {
              _context3.next = 13;
              break;
            }

            return _context3.abrupt("return", {
              code: 0,
              info: result.pageItems.reduce(function (arr, _ref6) {
                var productSkuSummaries = _ref6.productSkuSummaries;
                return arr.concat(productSkuSummaries.filter(function (_ref7) {
                  var productSkuId = _ref7.productSkuId;
                  return task.skuIds.includes(productSkuId + '');
                }).map(function (_ref8) {
                  var productSkuId = _ref8.productSkuId,
                      supplierPrice = _ref8.supplierPrice,
                      currencyType = _ref8.currencyType,
                      extCode = _ref8.extCode;
                  return {
                    productSkuId: productSkuId,
                    supplierPrice: supplierPrice,
                    currencyType: currencyType,
                    skuExtCode: extCode
                  };
                }));
              }, []),
              total: result.total,
              pageNo: pageNo
            });

          case 13:
            msg = "\u83B7\u53D6\u5168\u6258\u7BA1\u4F9B\u8D27\u4EF7\u5931\u8D25\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(errorMsg);
            log["a" /* default */].setLog(msg);
            return _context3.abrupt("return", {
              msg: msg,
              pageNo: pageNo,
              code: 1
            });

          case 16:
            _context3.next = 28;
            break;

          case 18:
            _context3.prev = 18;
            _context3.t0 = _context3["catch"](2);
            _msg4 = "\u83B7\u53D6\u5168\u6258\u7BA1skuid&\u4F9B\u8D27\u4EF7\u5931\u8D25-----".concat(Object(util["r" /* isError */])(_context3.t0, task));
            log["a" /* default */].setLog(_msg4); // 重试三次

            if (!(retry < 3)) {
              _context3.next = 27;
              break;
            }

            log["a" /* default */].setLog('正在重试........................');
            _context3.next = 26;
            return Object(util["g" /* delayed */])(3 * 1000);

          case 26:
            return _context3.abrupt("return", getSaleVolume_getCbSupplierPrice(task, ++retry));

          case 27:
            return _context3.abrupt("return", {
              msg: _msg4,
              pageNo: 1,
              code: 2
            });

          case 28:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3, null, [[2, 18]]);
  }));

  return function getCbSupplierPrice(_x5) {
    return _ref5.apply(this, arguments);
  };
}();

var getAllSaleVolume = /*#__PURE__*/function () {
  var _ref9 = getSaleVolume_asyncToGenerator( /*#__PURE__*/getSaleVolume_regeneratorRuntime().mark(function _callee4(task) {
    var _ref10, code, msg, pageNo, info, total, count, batchSkuIds, saleList, i, saleVolumeList;

    return getSaleVolume_regeneratorRuntime().wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            if (!(task.skuIds && task.skuIds.length)) {
              _context4.next = 6;
              break;
            }

            _context4.next = 3;
            return getSaleVolume_getCbSupplierPrice(task);

          case 3:
            _context4.t0 = _context4.sent;
            _context4.next = 9;
            break;

          case 6:
            _context4.next = 8;
            return requestSkuid(task, task.pageNo || 1);

          case 8:
            _context4.t0 = _context4.sent;

          case 9:
            _ref10 = _context4.t0;
            code = _ref10.code;
            msg = _ref10.msg;
            pageNo = _ref10.pageNo;
            info = _ref10.info;
            total = _ref10.total;
            // 记录当前页数
            task.pageNo = pageNo; // 获取失败，上报状态

            if (!(code !== 0)) {
              _context4.next = 18;
              break;
            }

            return _context4.abrupt("return", {
              code: 2,
              msg: msg,
              data: {
                pageNo: pageNo,
                skuIds: task.skuIds
              }
            });

          case 18:
            count = Math.ceil(info.length / 100);
            batchSkuIds = Array(count).fill(1).map(function (i, key) {
              return info.slice(key * 100, (key + 1) * 100);
            });
            saleList = []; // 批量获取，每次获取100个sku的销量（原因：傻逼temu不能同时获取超过100个sku的销量）

            i = 0;

          case 22:
            if (!(i < batchSkuIds.length)) {
              _context4.next = 35;
              break;
            }

            _context4.next = 25;
            return requestSaleVolumeBySkuId(task, batchSkuIds[i].map(function (_ref11) {
              var productSkuId = _ref11.productSkuId;
              return productSkuId;
            }));

          case 25:
            saleVolumeList = _context4.sent;

            if (!(saleVolumeList.code !== 0)) {
              _context4.next = 31;
              break;
            }

            if (!(saleVolumeList.code !== 5)) {
              _context4.next = 29;
              break;
            }

            return _context4.abrupt("return", {
              code: saleVolumeList.code,
              msg: saleVolumeList.msg + "----sku\u6570\u91CF: ".concat(info.length),
              data: {
                pageNo: pageNo,
                skuIds: task.skuIds
              }
            });

          case 29:
            _context4.next = 32;
            break;

          case 31:
            saleList.push.apply(saleList, getSaleVolume_toConsumableArray(saleVolumeList.result));

          case 32:
            i++;
            _context4.next = 22;
            break;

          case 35:
            if (!(saleList.length === 0)) {
              _context4.next = 37;
              break;
            }

            return _context4.abrupt("return", {
              code: 0,
              result: {
                total: total,
                supplierPriceList: info
              }
            });

          case 37:
            // 记录当前已获取数据，用于显示
            task.currentNum = (task.currentNum || 0) + info.length;
            task.total = total;
            task.curPage = pageNo * $count; // 判断是否获取完毕

            if (!(task.curPage < total)) {
              _context4.next = 45;
              break;
            }

            task.pageNo += 1; // 上报当前状态

            _context4.next = 44;
            return newTask["a" /* default */].uploadTask({
              code: 4,
              data: {
                pageNo: task.pageNo
              },
              result: {
                total: total,
                supplierPriceList: info,
                saleVolume: saleList
              }
            }, task);

          case 44:
            return _context4.abrupt("return", getAllSaleVolume(task));

          case 45:
            return _context4.abrupt("return", {
              code: 0,
              result: {
                total: total,
                supplierPriceList: info,
                saleVolume: saleList
              }
            });

          case 46:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4);
  }));

  return function getAllSaleVolume(_x6) {
    return _ref9.apply(this, arguments);
  };
}();

var getSaleVolume = /*#__PURE__*/function () {
  var _ref12 = getSaleVolume_asyncToGenerator( /*#__PURE__*/getSaleVolume_regeneratorRuntime().mark(function _callee5(task) {
    var loginRes, msg, res;
    return getSaleVolume_regeneratorRuntime().wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            if (!(task.resCache && task.resCache.code === 0)) {
              _context5.next = 2;
              break;
            }

            return _context5.abrupt("return", task.resCache);

          case 2:
            _context5.next = 4;
            return Object(temu["e" /* loginCb */])(task);

          case 4:
            loginRes = _context5.sent;

            if (loginRes) {
              _context5.next = 10;
              break;
            }

            msg = '切换到美区或欧区站点失败，请检查';
            task.msg = msg;
            log["a" /* default */].setLog(msg);
            return _context5.abrupt("return", {
              code: 1,
              msg: msg
            });

          case 10:
            _context5.next = 12;
            return getAllSaleVolume(task);

          case 12:
            res = _context5.sent;
            task.status = [1, 2].indexOf(res.code) > -1 ? 14 : 15;
            task.msg = res.msg;
            return _context5.abrupt("return", res);

          case 16:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));

  return function getSaleVolume(_x7) {
    return _ref12.apply(this, arguments);
  };
}();

/* harmony default export */ var temu_getSaleVolume = (getSaleVolume); // window.requestSaleVolumeBySkuId = () => {
//   requestSaleVolumeBySkuId({
//     host: 'https://seller.kuajingmaihuo.com',
//     skuIds: [
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118,
//       3092153307, 3269504539, 1851325013, 4010808419, 4582729262, 1857468159, 6711667118
//     ],
//     store_id: 65016470556
//   })
// }
// window.requestSkuid = () => {
//   requestSkuid({
//     host: 'https://seller.kuajingmaihuo.com',
//     store_id: 65016470556
//   })
// }
// EXTERNAL MODULE: ./node_modules/axios/index.js
var axios = __webpack_require__("bc3a");
var axios_default = /*#__PURE__*/__webpack_require__.n(axios);

// EXTERNAL MODULE: ./node_modules/jszip/dist/jszip.min.js
var jszip_min = __webpack_require__("c4e3");
var jszip_min_default = /*#__PURE__*/__webpack_require__.n(jszip_min);

// CONCATENATED MODULE: ./src/platform/temu/qtReport/getBillDetailsReport.js
function getBillDetailsReport_typeof(obj) { "@babel/helpers - typeof"; return getBillDetailsReport_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, getBillDetailsReport_typeof(obj); }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function getBillDetailsReport_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ getBillDetailsReport_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == getBillDetailsReport_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function getBillDetailsReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function getBillDetailsReport_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { getBillDetailsReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { getBillDetailsReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }








var generateReport = /*#__PURE__*/function () {
  var _ref = getBillDetailsReport_asyncToGenerator( /*#__PURE__*/getBillDetailsReport_regeneratorRuntime().mark(function _callee(task) {
    var _yield$nativeRequest, success, errorCode, errorMsg, msg;

    return getBillDetailsReport_regeneratorRuntime().wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.prev = 0;
            _context.next = 3;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/file/export"), 'post', {
              beginTime: task.report_custom_datetime_start,
              endTime: task.report_custom_datetime_end,
              fundDetailExport: true,
              taskType: 19
            }, {
              Mallid: task.platform_store_id
            });

          case 3:
            _yield$nativeRequest = _context.sent;
            success = _yield$nativeRequest.success;
            errorCode = _yield$nativeRequest.errorCode;
            errorMsg = _yield$nativeRequest.errorMsg;

            if (!success) {
              _context.next = 12;
              break;
            }

            log["a" /* default */].setLog('全托管财务明细报表生成成功');
            return _context.abrupt("return", true);

          case 12:
            if (!(errorCode == 2000000)) {
              _context.next = 14;
              break;
            }

            return _context.abrupt("return", true);

          case 14:
            msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(JSON.stringify(errorMsg));
            task.status = 3;
            log["a" /* default */].setLog(msg);
            task.msg = msg;

          case 18:
            _context.next = 26;
            break;

          case 20:
            _context.prev = 20;
            _context.t0 = _context["catch"](0);
            task.status = 3;
            task.msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context.t0, task));
            log["a" /* default */].setLog(task.msg);
            return _context.abrupt("return", false);

          case 26:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, null, [[0, 20]]);
  }));

  return function generateReport(_x) {
    return _ref.apply(this, arguments);
  };
}(); // 查询报表生成状态


var awaitReportDownload = /*#__PURE__*/function () {
  var _ref2 = getBillDetailsReport_asyncToGenerator( /*#__PURE__*/getBillDetailsReport_regeneratorRuntime().mark(function _callee2(task) {
    var count,
        res,
        list,
        find,
        _args2 = arguments;
    return getBillDetailsReport_regeneratorRuntime().wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            count = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 0;
            _context2.prev = 1;

            if (!(count >= 5)) {
              _context2.next = 8;
              break;
            }

            log["a" /* default */].setLog('文件正在生成，超过最大重试次数，退出执行下一任务');
            task.run_time = 0;
            task.msg = "\u6587\u4EF6\u6B63\u5728\u751F\u6210\u4E2D";
            task.status = 6;
            return _context2.abrupt("return", false);

          case 8:
            _context2.next = 10;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/file/export/history/page"), 'post', {
              pageNum: 1,
              pageSize: 50,
              taskType: 19
            }, {
              Mallid: task.platform_store_id
            });

          case 10:
            res = _context2.sent;

            if (!(res && res.result)) {
              _context2.next = 38;
              break;
            }

            list = res.result.merchantMerchantFileExportHistoryList;
            find = list.find(function (item) {
              return item.fundDetailExport == true && item.searchExportTimeBegin == task.report_custom_datetime_start && item.searchExportTimeEnd == task.report_custom_datetime_end && item.createTime > Date.now() - 24 * 60 * 60 * 1000;
            });

            if (!find) {
              _context2.next = 33;
              break;
            }

            _context2.t0 = find.status;
            _context2.next = _context2.t0 === 2 ? 18 : _context2.t0 === 1 ? 23 : 23;
            break;

          case 18:
            task.status = 2;
            task.agentSellerExportParams = find.agentSellerExportParams;
            task.agentSellerExportSign = find.agentSellerExportSign;
            task.downloadId = find.id;
            return _context2.abrupt("return", true);

          case 23:
            task.status = 6;
            task.msg = '文件正在生成中';
            log["a" /* default */].setLog(task.msg, "\u5F53\u524D\u91CD\u8BD5\u6B21\u6570-".concat(count));
            _context2.next = 28;
            return Object(util["g" /* delayed */])(30 * 1000);

          case 28:
            _context2.next = 30;
            return awaitReportDownload(task, ++count);

          case 30:
            return _context2.abrupt("return", _context2.sent);

          case 31:
            _context2.next = 36;
            break;

          case 33:
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25----not find\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D";
            log["a" /* default */].setLog(task.msg);

          case 36:
            _context2.next = 41;
            break;

          case 38:
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0CTemu\u89C4\u5219\u53EF\u80FD\u6539\u53D8\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D";
            log["a" /* default */].setLog(task.msg);

          case 41:
            _context2.next = 48;
            break;

          case 43:
            _context2.prev = 43;
            _context2.t1 = _context2["catch"](1);
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u539F\u59CB\u9875\u9762\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context2.t1, task));
            log["a" /* default */].setLog(task.msg);

          case 48:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2, null, [[1, 43]]);
  }));

  return function awaitReportDownload(_x2) {
    return _ref2.apply(this, arguments);
  };
}(); // 获取下载报表链接


var getCnReportUrl = /*#__PURE__*/function () {
  var _ref3 = getBillDetailsReport_asyncToGenerator( /*#__PURE__*/getBillDetailsReport_regeneratorRuntime().mark(function _callee3(task) {
    var res;
    return getBillDetailsReport_regeneratorRuntime().wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            _context3.prev = 0;
            _context3.next = 3;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/file/export/download"), 'post', {
              id: task.downloadId,
              taskType: 19
            }, {
              Mallid: task.platform_store_id
            });

          case 3:
            res = _context3.sent;

            if (!(res.success && res.result)) {
              _context3.next = 9;
              break;
            }

            task.fileUrl = res.result.fileUrl;
            return _context3.abrupt("return", {
              fileUrl: res.result.fileUrl
            });

          case 9:
            task.status = 9;
            task.msg = "\u83B7\u53D6\u4E0B\u8F7D\u62A5\u8868\u94FE\u63A5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u539F\u59CB\u9875\u9762\u62A5\u9519\uFF1A".concat(res.errorMsg);
            log["a" /* default */].setLog(task.msg);

          case 12:
            _context3.next = 19;
            break;

          case 14:
            _context3.prev = 14;
            _context3.t0 = _context3["catch"](0);
            task.status = 9;
            task.msg = "\u83B7\u53D6\u4E0B\u8F7D\u62A5\u8868\u94FE\u63A5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u539F\u59CB\u9875\u9762\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context3.t0, task));
            log["a" /* default */].setLog(task.msg);

          case 19:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3, null, [[0, 14]]);
  }));

  return function getCnReportUrl(_x3) {
    return _ref3.apply(this, arguments);
  };
}(); // 获取英文中心下载报表链接


var getEnReportUrl = /*#__PURE__*/function () {
  var _ref4 = getBillDetailsReport_asyncToGenerator( /*#__PURE__*/getBillDetailsReport_regeneratorRuntime().mark(function _callee4(task, host) {
    var loginRes, changeStoreId, _yield$nativeRequest2, success, result, errorMsg, res, msg;

    return getBillDetailsReport_regeneratorRuntime().wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            // 需要提前登录一下美区或者欧区
            task.host = host;
            _context4.next = 3;
            return Object(temu["e" /* loginCb */])(task);

          case 3:
            loginRes = _context4.sent;

            if (loginRes) {
              _context4.next = 9;
              break;
            }

            task.msg = '切换到美区、欧区或全球站点失败，请检查';
            task.status = 11;
            log["a" /* default */].setLog(task.msg);
            return _context4.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 9:
            _context4.prev = 9;
            changeStoreId = "".concat(task.platform_store_id, "&").concat(task.siteId);
            _context4.next = 13;
            return Object(util["u" /* nativeRequest */])("".concat(host, "/api/merchant/file/export"), 'post', {
              params: task.agentSellerExportParams,
              sign: task.agentSellerExportSign,
              taskType: 31
            }, {
              Mallid: task.platform_store_id,
              changeStoreId: changeStoreId
            });

          case 13:
            _yield$nativeRequest2 = _context4.sent;
            success = _yield$nativeRequest2.success;
            result = _yield$nativeRequest2.result;
            errorMsg = _yield$nativeRequest2.errorMsg;

            if (!(success && result)) {
              _context4.next = 35;
              break;
            }

            _context4.prev = 18;
            _context4.next = 21;
            return Object(util["u" /* nativeRequest */])("".concat(host, "/api/merchant/file/export/download"), 'post', {
              id: result,
              taskType: 31
            }, {
              Mallid: task.platform_store_id,
              changeStoreId: changeStoreId
            });

          case 21:
            res = _context4.sent;

            if (!(res.success && res.result)) {
              _context4.next = 25;
              break;
            }

            task.fileUrl = res.result.fileUrl;
            return _context4.abrupt("return", {
              fileUrl: res.result.fileUrl
            });

          case 25:
            _context4.next = 33;
            break;

          case 27:
            _context4.prev = 27;
            _context4.t0 = _context4["catch"](18);
            task.msg = "\u83B7\u53D6\u4E0B\u8F7D\u62A5\u8868\u94FE\u63A5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u539F\u59CB\u9875\u9762\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context4.t0, task));
            task.status = 9;
            log["a" /* default */].setLog(task.msg);
            return _context4.abrupt("return", false);

          case 33:
            _context4.next = 40;
            break;

          case 35:
            msg = "\u83B7\u53D6\u4E0B\u8F7D\u62A5\u8868\u94FE\u63A5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u539F\u59CB\u9875\u9762\u62A5\u9519\uFF1A".concat(JSON.stringify(errorMsg));
            task.msg = msg;
            task.status = 9;
            log["a" /* default */].setLog(msg);
            return _context4.abrupt("return", {
              msg: msg,
              code: 1
            });

          case 40:
            _context4.next = 48;
            break;

          case 42:
            _context4.prev = 42;
            _context4.t1 = _context4["catch"](9);
            task.msg = "\u83B7\u53D6\u4E0B\u8F7D\u62A5\u8868\u94FE\u63A5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u539F\u59CB\u9875\u9762\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context4.t1, task));
            task.status = 9;
            log["a" /* default */].setLog(task.msg);
            return _context4.abrupt("return", false);

          case 48:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4, null, [[9, 42], [18, 27]]);
  }));

  return function getEnReportUrl(_x4, _x5) {
    return _ref4.apply(this, arguments);
  };
}(); // 下载报表


var downloadReport = /*#__PURE__*/function () {
  var _ref5 = getBillDetailsReport_asyncToGenerator( /*#__PURE__*/getBillDetailsReport_regeneratorRuntime().mark(function _callee5(task) {
    var res, name, oFile, fileRes, zip;
    return getBillDetailsReport_regeneratorRuntime().wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            _context5.prev = 0;
            _context5.next = 3;
            return axios_default()({
              method: 'GET',
              url: task.fileUrl,
              responseType: 'blob'
            });

          case 3:
            res = _context5.sent;

            if (!(res && res.data)) {
              _context5.next = 16;
              break;
            }

            name = Object(util["p" /* getNameByUrl */])(task.fileUrl);
            oFile = new File([res.data], name, {
              type: 'application/zip'
            });
            // 文件压缩
            log["a" /* default */].setLog('源文件大小', "".concat(oFile.size, "b"));
            zip = new jszip_min_default.a();
            zip.file(name, res.data, {
              binary: true
            });
            _context5.next = 12;
            return zip.generateAsync({
              type: "nodebuffer",
              compression: "DEFLATE",
              // STORE：默认不压缩 DEFLATE：需要压缩
              compressionOptions: {
                level: 9 // 压缩等级1~9    1压缩速度最快，9最优压缩方式

              }
            }).then(function (res) {
              var cFile = new File([res], "".concat(name.split('.')[0], ".zip"), {
                type: 'application/zip'
              });
              log["a" /* default */].setLog('压缩后文件大小', "".concat(cFile.size, "b"), cFile.name);
              fileRes = {
                file: cFile
              };
            }).catch(function (e) {
              log["a" /* default */].setLog('财务报表压缩失败', Object(util["r" /* isError */])(e));
              fileRes = {
                file: oFile
              };
            });

          case 12:
            log["a" /* default */].setLog('下载成功');
            task.status = 4;
            task.report_get_date = moment_default()().format('YYYY-MM-DD HH:mm:ss');
            return _context5.abrupt("return", fileRes);

          case 16:
            _context5.next = 23;
            break;

          case 18:
            _context5.prev = 18;
            _context5.t0 = _context5["catch"](0);
            task.status = 5;
            task.msg = "\u4E0B\u8F7D\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u539F\u59CB\u9875\u9762\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context5.t0, task));
            log["a" /* default */].setLog(task.msg);

          case 23:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5, null, [[0, 18]]);
  }));

  return function downloadReport(_x6) {
    return _ref5.apply(this, arguments);
  };
}();

var getBillDetailsReport = /*#__PURE__*/function () {
  var _ref6 = getBillDetailsReport_asyncToGenerator( /*#__PURE__*/getBillDetailsReport_regeneratorRuntime().mark(function _callee6(task) {
    var host, param, res, uploadRes;
    return getBillDetailsReport_regeneratorRuntime().wrap(function _callee6$(_context6) {
      while (1) {
        switch (_context6.prev = _context6.next) {
          case 0:
            _context6.t0 = task.status !== 6;

            if (!_context6.t0) {
              _context6.next = 5;
              break;
            }

            _context6.next = 4;
            return awaitReportDownload(task);

          case 4:
            _context6.t0 = !_context6.sent;

          case 5:
            if (!_context6.t0) {
              _context6.next = 10;
              break;
            }

            _context6.next = 8;
            return generateReport(task);

          case 8:
            if (_context6.sent) {
              _context6.next = 10;
              break;
            }

            return _context6.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 10:
            _context6.t1 = task.status !== 2;

            if (!_context6.t1) {
              _context6.next = 15;
              break;
            }

            _context6.next = 14;
            return awaitReportDownload(task);

          case 14:
            _context6.t1 = !_context6.sent;

          case 15:
            if (!_context6.t1) {
              _context6.next = 17;
              break;
            }

            return _context6.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 17:
            if (!(task.report_type == 51)) {
              _context6.next = 24;
              break;
            }

            _context6.next = 20;
            return getCnReportUrl(task);

          case 20:
            if (_context6.sent) {
              _context6.next = 22;
              break;
            }

            return _context6.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 22:
            _context6.next = 29;
            break;

          case 24:
            host = {
              5: temu["f" /* temu */].cbGlobalHost,
              502: temu["f" /* temu */].cbEuHost,
              503: temu["f" /* temu */].cbUsHost
            }[task.report_type]; // 监听header头修改cookie
            // await changeLocalMallId(task.platform_store_id, task.siteId, host)

            _context6.next = 27;
            return getEnReportUrl(task, host);

          case 27:
            if (_context6.sent) {
              _context6.next = 29;
              break;
            }

            return _context6.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 29:
            // 默认参数
            param = {
              type_id: task.type_id,
              platform_store_id: task.platform_store_id,
              result: null,
              code: 0,
              msg: null
            };
            _context6.next = 32;
            return downloadReport(task);

          case 32:
            res = _context6.sent;

            if (!(res && res.file)) {
              _context6.next = 43;
              break;
            }

            _context6.next = 36;
            return Object(util["G" /* uploadFile */])(res.file);

          case 36:
            uploadRes = _context6.sent;
            log["a" /* default */].setLog('文件上传结果：', JSON.stringify(uploadRes));

            if (!(uploadRes && uploadRes.code === 1)) {
              _context6.next = 40;
              break;
            }

            return _context6.abrupt("return", _objectSpread(_objectSpread({}, param), {}, {
              result: {
                report_file: uploadRes.data,
                cosKey: uploadRes.data.key,
                originFileName: uploadRes.data.originFileName,
                report_custom_date_start: task.report_custom_date_start,
                report_custom_date_end: task.report_custom_date_end,
                reportType: task.report_type,
                reportDate: task.report_date_month
              }
            }));

          case 40:
            // 上传失败
            task.status = 7;
            task.msg = '文件上传cos失败';
            param.result = {
              requestId: uploadRes.requestId,
              msg: uploadRes.msg
            };

          case 43:
            return _context6.abrupt("return", _objectSpread(_objectSpread({}, param), {}, {
              code: 2,
              msg: task.msg
            }));

          case 44:
          case "end":
            return _context6.stop();
        }
      }
    }, _callee6);
  }));

  return function getBillDetailsReport(_x7) {
    return _ref6.apply(this, arguments);
  };
}();

/* harmony default export */ var qtReport_getBillDetailsReport = (getBillDetailsReport);
// CONCATENATED MODULE: ./src/platform/temu/qtReport/getDeductionReportExportDetail.js
function getDeductionReportExportDetail_typeof(obj) { "@babel/helpers - typeof"; return getDeductionReportExportDetail_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, getDeductionReportExportDetail_typeof(obj); }

function getDeductionReportExportDetail_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function getDeductionReportExportDetail_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? getDeductionReportExportDetail_ownKeys(Object(source), !0).forEach(function (key) { getDeductionReportExportDetail_defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : getDeductionReportExportDetail_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function getDeductionReportExportDetail_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function getDeductionReportExportDetail_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ getDeductionReportExportDetail_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == getDeductionReportExportDetail_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function getDeductionReportExportDetail_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function getDeductionReportExportDetail_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { getDeductionReportExportDetail_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { getDeductionReportExportDetail_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }




var remarkMap = {
  52: '消费者及履约保障-售后问题',
  521: '仓储增值服务-贴标费'
}; // 获取账务明细列表

var getAccountingDetailsList = /*#__PURE__*/function () {
  var _ref = getDeductionReportExportDetail_asyncToGenerator( /*#__PURE__*/getDeductionReportExportDetail_regeneratorRuntime().mark(function _callee(task) {
    var list,
        pageNum,
        res,
        _args = arguments;
    return getDeductionReportExportDetail_regeneratorRuntime().wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            list = _args.length > 1 && _args[1] !== undefined ? _args[1] : [];
            pageNum = _args.length > 2 && _args[2] !== undefined ? _args[2] : 1;
            _context.prev = 2;
            _context.next = 5;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/fund/detail/pageSearch"), 'post', {
              beginTime: task.report_custom_datetime_start,
              endTime: task.report_custom_datetime_end,
              pageNum: pageNum,
              pageSize: 100
            }, {
              Mallid: task.platform_store_id
            });

          case 5:
            res = _context.sent;

            if (!(res.success && res.result && res.result.resultList)) {
              _context.next = 15;
              break;
            }

            list = list.concat(res.result.resultList.filter(function (_ref2) {
              var remark = _ref2.remark;
              return remarkMap[task.report_type] === remark;
            })); // 判断是否获取完毕

            if (!(res.result.total > pageNum * 100)) {
              _context.next = 12;
              break;
            }

            _context.next = 11;
            return getAccountingDetailsList(task, list, pageNum++);

          case 11:
            return _context.abrupt("return", _context.sent);

          case 12:
            return _context.abrupt("return", list);

          case 15:
            task.msg = "\u8BF7\u6C42\u5217\u8868\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D----code:".concat(res.errorCode, "--msg:").concat(res.errorMsg);
            log["a" /* default */].setLog(task.msg);

          case 17:
            _context.next = 23;
            break;

          case 19:
            _context.prev = 19;
            _context.t0 = _context["catch"](2);
            task.msg = "\u8BF7\u6C42\u5217\u8868\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context.t0, task));
            log["a" /* default */].setLog(task.msg);

          case 23:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, null, [[2, 19]]);
  }));

  return function getAccountingDetailsList(_x) {
    return _ref.apply(this, arguments);
  };
}(); // 获取账务明细详情，返回值是个数组


var getAccountingDetailsItem = /*#__PURE__*/function () {
  var _ref4 = getDeductionReportExportDetail_asyncToGenerator( /*#__PURE__*/getDeductionReportExportDetail_regeneratorRuntime().mark(function _callee2(task, _ref3) {
    var batchId, createTime, fundType, res;
    return getDeductionReportExportDetail_regeneratorRuntime().wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            batchId = _ref3.batchId, createTime = _ref3.createTime, fundType = _ref3.fundType;
            _context2.prev = 1;
            _context2.next = 4;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/fund/detail/item"), 'post', {
              batchId: batchId,
              createdTime: createTime,
              fundType: fundType
            }, {
              Mallid: task.platform_store_id
            });

          case 4:
            res = _context2.sent;

            if (!(res.success && res.result)) {
              _context2.next = 9;
              break;
            }

            return _context2.abrupt("return", res.result.map(function (item) {
              return getDeductionReportExportDetail_objectSpread({
                batchId: batchId,
                createTime: createTime
              }, item);
            }));

          case 9:
            task.msg = "\u8BF7\u6C42\u8BE6\u60C5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D----code:".concat(res.errorCode, "--msg:").concat(res.errorMsg);
            log["a" /* default */].setLog(task.msg);

          case 11:
            _context2.next = 17;
            break;

          case 13:
            _context2.prev = 13;
            _context2.t0 = _context2["catch"](1);
            task.msg = "\u8BF7\u6C42\u8BE6\u60C5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context2.t0, task));
            log["a" /* default */].setLog(task.msg);

          case 17:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2, null, [[1, 13]]);
  }));

  return function getAccountingDetailsItem(_x2, _x3) {
    return _ref4.apply(this, arguments);
  };
}(); // 获取导出链接


var getFileUrl = /*#__PURE__*/function () {
  var _ref5 = getDeductionReportExportDetail_asyncToGenerator( /*#__PURE__*/getDeductionReportExportDetail_regeneratorRuntime().mark(function _callee3(task, item) {
    var res;
    return getDeductionReportExportDetail_regeneratorRuntime().wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            _context3.prev = 0;
            _context3.next = 3;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/fund/detail/item/download/detail"), 'post', item, {
              Mallid: task.platform_store_id
            });

          case 3:
            res = _context3.sent;

            if (!(res.success && res.result)) {
              _context3.next = 8;
              break;
            }

            return _context3.abrupt("return", res.result.fileUrl);

          case 8:
            task.msg = "\u8BF7\u6C42\u5BFC\u51FA\u6570\u636E\u94FE\u63A5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D----code:".concat(res.errorCode, "--msg:").concat(res.errorMsg);
            log["a" /* default */].setLog(task.msg);

          case 10:
            _context3.next = 16;
            break;

          case 12:
            _context3.prev = 12;
            _context3.t0 = _context3["catch"](0);
            task.msg = "\u8BF7\u6C42\u5BFC\u51FA\u6570\u636E\u94FE\u63A5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context3.t0, task));
            log["a" /* default */].setLog(task.msg);

          case 16:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3, null, [[0, 12]]);
  }));

  return function getFileUrl(_x4, _x5) {
    return _ref5.apply(this, arguments);
  };
}(); // 下载报表


var getDeductionReportExportDetail_downloadReport = /*#__PURE__*/function () {
  var _ref6 = getDeductionReportExportDetail_asyncToGenerator( /*#__PURE__*/getDeductionReportExportDetail_regeneratorRuntime().mark(function _callee4(task, url) {
    var res, name, oFile;
    return getDeductionReportExportDetail_regeneratorRuntime().wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            _context4.prev = 0;
            _context4.next = 3;
            return axios_default()({
              method: 'GET',
              url: url,
              responseType: 'blob'
            });

          case 3:
            res = _context4.sent;

            if (!(res && res.data)) {
              _context4.next = 8;
              break;
            }

            name = Object(util["p" /* getNameByUrl */])(url);
            oFile = new File([res.data], name, {
              type: 'application/zip'
            });
            return _context4.abrupt("return", {
              oFile: oFile,
              name: name,
              blob: res.data
            });

          case 8:
            _context4.next = 15;
            break;

          case 10:
            _context4.prev = 10;
            _context4.t0 = _context4["catch"](0);
            task.status = 5;
            task.msg = "\u4E0B\u8F7D\u62A5\u8868\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context4.t0, task));
            log["a" /* default */].setLog(task.msg);

          case 15:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4, null, [[0, 10]]);
  }));

  return function downloadReport(_x6, _x7) {
    return _ref6.apply(this, arguments);
  };
}();

function getDeductionReportExportDetail(_x8) {
  return _getDeductionReportExportDetail.apply(this, arguments);
}

function _getDeductionReportExportDetail() {
  _getDeductionReportExportDetail = getDeductionReportExportDetail_asyncToGenerator( /*#__PURE__*/getDeductionReportExportDetail_regeneratorRuntime().mark(function _callee5(task) {
    var accountingDetailsList, items, fileUrls, files;
    return getDeductionReportExportDetail_regeneratorRuntime().wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            _context5.next = 2;
            return getAccountingDetailsList(task);

          case 2:
            accountingDetailsList = _context5.sent;

            if (accountingDetailsList) {
              _context5.next = 5;
              break;
            }

            return _context5.abrupt("return", false);

          case 5:
            if (!(accountingDetailsList.length === 0)) {
              _context5.next = 7;
              break;
            }

            return _context5.abrupt("return", 'none');

          case 7:
            _context5.next = 9;
            return Promise.all(accountingDetailsList.map(function (item) {
              return getAccountingDetailsItem(task, item);
            })).catch(function () {
              return false;
            });

          case 9:
            items = _context5.sent;

            if (items) {
              _context5.next = 12;
              break;
            }

            return _context5.abrupt("return", false);

          case 12:
            _context5.next = 14;
            return Promise.all(items.flat().map(function (item) {
              return getFileUrl(task, item);
            })).catch(function () {
              return false;
            });

          case 14:
            fileUrls = _context5.sent;

            if (fileUrls) {
              _context5.next = 17;
              break;
            }

            return _context5.abrupt("return", false);

          case 17:
            _context5.next = 19;
            return Promise.all(fileUrls.map(function (url) {
              return getDeductionReportExportDetail_downloadReport(task, url);
            })).catch(function () {
              return false;
            });

          case 19:
            files = _context5.sent;

            if (files) {
              _context5.next = 22;
              break;
            }

            return _context5.abrupt("return", false);

          case 22:
            return _context5.abrupt("return", files);

          case 23:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));
  return _getDeductionReportExportDetail.apply(this, arguments);
}
// CONCATENATED MODULE: ./src/platform/temu/qtReport/getDeductionReport.js
function getDeductionReport_typeof(obj) { "@babel/helpers - typeof"; return getDeductionReport_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, getDeductionReport_typeof(obj); }

function getDeductionReport_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ getDeductionReport_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == getDeductionReport_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function getDeductionReport_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function getDeductionReport_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? getDeductionReport_ownKeys(Object(source), !0).forEach(function (key) { getDeductionReport_defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : getDeductionReport_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function getDeductionReport_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function getDeductionReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function getDeductionReport_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { getDeductionReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { getDeductionReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }






var deductionType = {
  53: 'SHIP_NOT_ON_TIME',
  54: 'DELIVERY_NOT_ON_TIME',
  55: 'DELIVERY_QUANTITY_NOT_STATIS',
  56: 'JIT_ISSUE',
  57: 'CUSTOMIZED_GOODS_QUALITY_ISSUE'
};
var deductionNameObj = {
  52: '消费者及履约保障-售后问题',
  53: '备货违规 - 发货履约保障-延迟发货',
  54: '备货违规 - 发货履约保障-延迟到货',
  55: '备货违规 - 发货履约保障-缺货',
  56: '备货违规 - 商品品质保障-质量问题(JIT商品)',
  57: '备货违规 - 商品品质保障-质量问题(定制商品)',
  58: '质量事故违规',
  521: '仓储增值服务-贴标费'
};

var getParamsByType = function getParamsByType(type) {
  switch (type) {
    case 52:
      return {
        fundDeductionType: 'AFTER_SALES'
      };

    case 53:
    case 54:
    case 55:
    case 56:
    case 57:
      return {
        fundDeductionType: 'STOCKING_VIOLATION',
        deductionCode: deductionType[type]
      };

    case 58:
      return {
        fundDeductionType: 'QUALITY_ACCIDENT'
      };

    default:
      return {};
  }
};

var getDeductionReport_generateReport = /*#__PURE__*/function () {
  var _ref = getDeductionReport_asyncToGenerator( /*#__PURE__*/getDeductionReport_regeneratorRuntime().mark(function _callee(task) {
    var params, _yield$nativeRequest, success, errorCode, errorMsg, msg;

    return getDeductionReport_regeneratorRuntime().wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.prev = 0;
            // deductionCode: "SHIP_NOT_ON_TIME",
            // fundDeductionType: "STOCKING_VIOLATION", // AFTER_SALES, QUALITY_ACCIDENT
            params = getParamsByType(task.report_type);
            _context.next = 4;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/file/export"), 'post', getDeductionReport_objectSpread(getDeductionReport_objectSpread({
              beginFundTime: task.report_custom_datetime_start,
              endFundTime: task.report_custom_datetime_end
            }, params), {}, {
              taskType: 17
            }), {
              Mallid: task.platform_store_id
            });

          case 4:
            _yield$nativeRequest = _context.sent;
            success = _yield$nativeRequest.success;
            errorCode = _yield$nativeRequest.errorCode;
            errorMsg = _yield$nativeRequest.errorMsg;

            if (!success) {
              _context.next = 13;
              break;
            }

            log["a" /* default */].setLog('全托管支出详情报表生成成功');
            return _context.abrupt("return", true);

          case 13:
            if (!(errorCode == 4000004)) {
              _context.next = 15;
              break;
            }

            return _context.abrupt("return", true);

          case 15:
            msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(JSON.stringify(errorMsg));
            task.status = 3;
            log["a" /* default */].setLog(msg);
            task.msg = msg;

          case 19:
            _context.next = 27;
            break;

          case 21:
            _context.prev = 21;
            _context.t0 = _context["catch"](0);
            task.status = 3;
            task.msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context.t0, task));
            log["a" /* default */].setLog(task.msg);
            return _context.abrupt("return", false);

          case 27:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, null, [[0, 21]]);
  }));

  return function generateReport(_x) {
    return _ref.apply(this, arguments);
  };
}(); // 查询报表生成状态


var getDeductionReport_awaitReportDownload = /*#__PURE__*/function () {
  var _ref2 = getDeductionReport_asyncToGenerator( /*#__PURE__*/getDeductionReport_regeneratorRuntime().mark(function _callee2(task) {
    var count,
        res,
        list,
        find,
        _args2 = arguments;
    return getDeductionReport_regeneratorRuntime().wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            count = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 0;
            _context2.prev = 1;

            if (!(count >= 5)) {
              _context2.next = 8;
              break;
            }

            log["a" /* default */].setLog('文件正在生成，超过最大重试次数，退出执行下一任务');
            task.run_time = 0;
            task.msg = "\u6587\u4EF6\u6B63\u5728\u751F\u6210\u4E2D";
            task.status = 6;
            return _context2.abrupt("return", false);

          case 8:
            _context2.next = 10;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/file/export/history/page"), 'post', {
              pageNum: 1,
              pageSize: 50,
              taskType: 17
            }, {
              Mallid: task.platform_store_id
            });

          case 10:
            res = _context2.sent;

            if (!(res && res.result)) {
              _context2.next = 36;
              break;
            }

            list = res.result.merchantMerchantFileExportHistoryList;
            find = list.find(function (item) {
              return item.deductionName == deductionNameObj[task.report_type] && item.dataBeginDateTime == task.beginTime && item.dataEndDateTime == task.endTime;
            });

            if (!find) {
              _context2.next = 31;
              break;
            }

            _context2.t0 = find.status;
            _context2.next = _context2.t0 === 2 ? 18 : _context2.t0 === 1 ? 21 : 21;
            break;

          case 18:
            task.status = 2;
            task.exportId = find.id;
            return _context2.abrupt("return", true);

          case 21:
            task.status = 6;
            task.msg = '文件正在生成中';
            log["a" /* default */].setLog(task.msg, "\u5F53\u524D\u91CD\u8BD5\u6B21\u6570-".concat(count));
            _context2.next = 26;
            return Object(util["g" /* delayed */])(30 * 1000);

          case 26:
            _context2.next = 28;
            return getDeductionReport_awaitReportDownload(task, ++count);

          case 28:
            return _context2.abrupt("return", _context2.sent);

          case 29:
            _context2.next = 34;
            break;

          case 31:
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D----not find";
            log["a" /* default */].setLog(task.msg);

          case 34:
            _context2.next = 39;
            break;

          case 36:
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0CTemu\u89C4\u5219\u53EF\u80FD\u6539\u53D8\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D";
            log["a" /* default */].setLog(task.msg);

          case 39:
            _context2.next = 46;
            break;

          case 41:
            _context2.prev = 41;
            _context2.t1 = _context2["catch"](1);
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context2.t1, task));
            log["a" /* default */].setLog(task.msg);

          case 46:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2, null, [[1, 41]]);
  }));

  return function awaitReportDownload(_x2) {
    return _ref2.apply(this, arguments);
  };
}(); // 获取下载报表链接


var getReportUrl = /*#__PURE__*/function () {
  var _ref3 = getDeductionReport_asyncToGenerator( /*#__PURE__*/getDeductionReport_regeneratorRuntime().mark(function _callee3(task) {
    var res;
    return getDeductionReport_regeneratorRuntime().wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            _context3.prev = 0;
            _context3.next = 3;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/file/export/download"), 'post', {
              id: task.exportId,
              taskType: 17
            }, {
              Mallid: task.platform_store_id
            });

          case 3:
            res = _context3.sent;

            if (!(res.success && res.result)) {
              _context3.next = 7;
              break;
            }

            task.fileUrl = res.result.fileUrl;
            return _context3.abrupt("return", {
              fileUrl: res.result.fileUrl
            });

          case 7:
            _context3.next = 14;
            break;

          case 9:
            _context3.prev = 9;
            _context3.t0 = _context3["catch"](0);
            task.status = 9;
            task.msg = "\u83B7\u53D6\u4E0B\u8F7D\u62A5\u8868\u94FE\u63A5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context3.t0, task));
            log["a" /* default */].setLog(task.msg);

          case 14:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3, null, [[0, 9]]);
  }));

  return function getReportUrl(_x3) {
    return _ref3.apply(this, arguments);
  };
}(); // 下载报表


var getDeductionReport_downloadReport = /*#__PURE__*/function () {
  var _ref4 = getDeductionReport_asyncToGenerator( /*#__PURE__*/getDeductionReport_regeneratorRuntime().mark(function _callee4(task) {
    var res, name, oFile;
    return getDeductionReport_regeneratorRuntime().wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            _context4.prev = 0;
            _context4.next = 3;
            return axios_default()({
              method: 'GET',
              url: task.fileUrl,
              responseType: 'blob'
            });

          case 3:
            res = _context4.sent;

            if (!(res && res.data)) {
              _context4.next = 11;
              break;
            }

            name = Object(util["p" /* getNameByUrl */])(task.fileUrl);
            oFile = new File([res.data], name, {
              type: 'application/zip'
            });
            log["a" /* default */].setLog('下载成功,源文件大小：', "".concat(oFile.size, "b"));
            task.status = 4;
            task.report_get_date = moment_default()().format('YYYY-MM-DD HH:mm:ss');
            return _context4.abrupt("return", [{
              oFile: oFile,
              name: name,
              blob: res.data
            }]);

          case 11:
            _context4.next = 18;
            break;

          case 13:
            _context4.prev = 13;
            _context4.t0 = _context4["catch"](0);
            task.status = 5;
            task.msg = "\u4E0B\u8F7D\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context4.t0, task));
            log["a" /* default */].setLog(task.msg);

          case 18:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4, null, [[0, 13]]);
  }));

  return function downloadReport(_x4) {
    return _ref4.apply(this, arguments);
  };
}();

var getDeductionReport = /*#__PURE__*/function () {
  var _ref5 = getDeductionReport_asyncToGenerator( /*#__PURE__*/getDeductionReport_regeneratorRuntime().mark(function _callee5(task) {
    var res, fileRes, detailsRes, file, uploadRes;
    return getDeductionReport_regeneratorRuntime().wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            res = [];

            if (!task.beginTime) {
              task.beginTime = task.report_custom_date_start + ' 00:00:00';
              task.endTime = task.report_custom_date_end + ' 23:59:59';
            }

            if ([521].includes(task.report_type)) {
              _context5.next = 23;
              break;
            }

            if (!(task.status !== 6)) {
              _context5.next = 8;
              break;
            }

            _context5.next = 6;
            return getDeductionReport_generateReport(task);

          case 6:
            if (_context5.sent) {
              _context5.next = 8;
              break;
            }

            return _context5.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 8:
            _context5.next = 10;
            return getDeductionReport_awaitReportDownload(task);

          case 10:
            _context5.t0 = !_context5.sent;

            if (_context5.t0) {
              _context5.next = 15;
              break;
            }

            _context5.next = 14;
            return getReportUrl(task);

          case 14:
            _context5.t0 = !_context5.sent;

          case 15:
            if (!_context5.t0) {
              _context5.next = 17;
              break;
            }

            return _context5.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 17:
            _context5.next = 19;
            return getDeductionReport_downloadReport(task);

          case 19:
            fileRes = _context5.sent;

            if (fileRes) {
              _context5.next = 22;
              break;
            }

            return _context5.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 22:
            res = fileRes;

          case 23:
            if (![52, 521].includes(task.report_type)) {
              _context5.next = 32;
              break;
            }

            _context5.next = 26;
            return getDeductionReportExportDetail(task);

          case 26:
            detailsRes = _context5.sent;

            if (detailsRes) {
              _context5.next = 29;
              break;
            }

            return _context5.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 29:
            if (!(detailsRes === 'none' && [521].includes(task.report_type))) {
              _context5.next = 31;
              break;
            }

            return _context5.abrupt("return", {
              code: 0,
              msg: '没有需要导出的数据'
            });

          case 31:
            res = res.concat(detailsRes);

          case 32:
            _context5.next = 34;
            return Object(util["m" /* generateAsync */])(res);

          case 34:
            file = _context5.sent;

            if (file) {
              _context5.next = 37;
              break;
            }

            return _context5.abrupt("return", {
              code: 1,
              msg: '文件压缩失败，稍后可尝试“重新获取”'
            });

          case 37:
            _context5.next = 39;
            return Object(util["G" /* uploadFile */])(file);

          case 39:
            uploadRes = _context5.sent;
            log["a" /* default */].setLog('文件上传结果：', JSON.stringify(uploadRes));

            if (!(uploadRes && uploadRes.code === 1)) {
              _context5.next = 43;
              break;
            }

            return _context5.abrupt("return", {
              code: 0,
              result: {
                report_file: uploadRes.data,
                cosKey: uploadRes.data.key,
                originFileName: uploadRes.data.originFileName,
                report_custom_date_start: task.report_custom_date_start,
                report_custom_date_end: task.report_custom_date_end,
                reportType: task.report_type,
                reportDate: task.report_date_month
              }
            });

          case 43:
            // 上传失败
            task.status = 7;
            task.msg = uploadRes.msg || '文件上传cos失败';
            return _context5.abrupt("return", {
              code: 1,
              msg: task.msg,
              requestId: uploadRes.requestId
            });

          case 46:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));

  return function getDeductionReport(_x5) {
    return _ref5.apply(this, arguments);
  };
}();

/* harmony default export */ var qtReport_getDeductionReport = (getDeductionReport); // window.testDeductionReport = (report_type) => {
//   getDeductionReport({
//     report_type,
//     host:'https://seller.kuajingmaihuo.com',
//     report_custom_date_start:'2025-01-01',
//     report_custom_date_end:'2025-01-13',
//     platform_store_id: 65016470556,
//     status: 0,
//   })
// }
// CONCATENATED MODULE: ./src/platform/temu/qtReport/getEPRReport.js
function getEPRReport_typeof(obj) { "@babel/helpers - typeof"; return getEPRReport_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, getEPRReport_typeof(obj); }

function getEPRReport_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function getEPRReport_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? getEPRReport_ownKeys(Object(source), !0).forEach(function (key) { getEPRReport_defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : getEPRReport_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function getEPRReport_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function getEPRReport_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ getEPRReport_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == getEPRReport_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function getEPRReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function getEPRReport_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { getEPRReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { getEPRReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }








var getEPRReport_generateReport = /*#__PURE__*/function () {
  var _ref = getEPRReport_asyncToGenerator( /*#__PURE__*/getEPRReport_regeneratorRuntime().mark(function _callee(task) {
    var params, _yield$nativeRequest, success, errorCode, errorMsg, msg;

    return getEPRReport_regeneratorRuntime().wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.prev = 0;
            params = [16].includes(task.taskType) ? {
              billingCycleList: [],
              taskType: task.taskType,
              financeDateStart: task.report_custom_date_start,
              financeDateEnd: task.report_custom_date_end
            } : {
              financeStartTime: task.report_custom_datetime_start,
              financeEndTime: task.report_custom_datetime_end,
              exportType: task.exportType,
              taskType: task.taskType
            };
            _context.next = 4;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/file/export"), 'post', params, {
              Mallid: task.platform_store_id,
              changeStoreId: task.changeStoreId
            });

          case 4:
            _yield$nativeRequest = _context.sent;
            success = _yield$nativeRequest.success;
            errorCode = _yield$nativeRequest.errorCode;
            errorMsg = _yield$nativeRequest.errorMsg;

            if (!success) {
              _context.next = 13;
              break;
            }

            log["a" /* default */].setLog('欧区ERP费用生成成功');
            return _context.abrupt("return", true);

          case 13:
            if (!(errorCode == 4000004)) {
              _context.next = 15;
              break;
            }

            return _context.abrupt("return", true);

          case 15:
            msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(JSON.stringify(errorMsg));
            task.status = 3;
            log["a" /* default */].setLog(msg);
            task.msg = msg;

          case 19:
            _context.next = 27;
            break;

          case 21:
            _context.prev = 21;
            _context.t0 = _context["catch"](0);
            task.status = 3;
            task.msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context.t0, task));
            log["a" /* default */].setLog(task.msg);
            return _context.abrupt("return", false);

          case 27:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, null, [[0, 21]]);
  }));

  return function generateReport(_x) {
    return _ref.apply(this, arguments);
  };
}(); // 查询报表生成状态


var getEPRReport_awaitReportDownload = /*#__PURE__*/function () {
  var _ref2 = getEPRReport_asyncToGenerator( /*#__PURE__*/getEPRReport_regeneratorRuntime().mark(function _callee2(task) {
    var count,
        res,
        list,
        find,
        _args2 = arguments;
    return getEPRReport_regeneratorRuntime().wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            count = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 0;
            _context2.prev = 1;

            if (!(count >= 5)) {
              _context2.next = 8;
              break;
            }

            log["a" /* default */].setLog('文件正在生成，超过最大重试次数，退出执行下一任务');
            task.run_time = 0;
            task.msg = "\u6587\u4EF6\u6B63\u5728\u751F\u6210\u4E2D";
            task.status = 6;
            return _context2.abrupt("return", false);

          case 8:
            _context2.next = 10;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/file/export/history/page"), 'post', {
              pageNum: 1,
              pageSize: 50,
              taskType: task.taskType
            }, {
              Mallid: task.platform_store_id,
              changeStoreId: task.changeStoreId
            });

          case 10:
            res = _context2.sent;

            if (!(res && res.result)) {
              _context2.next = 36;
              break;
            }

            list = res.result.merchantMerchantFileExportHistoryList;
            find = list.find(function (item) {
              return [16].includes(task.taskType) ? item.financeDateStart == task.report_custom_date_start && item.financeDateEnd == task.report_custom_date_end : item.exportType == task.exportType && item.financeStartTime == task.report_custom_datetime_start && item.financeEndTime == task.report_custom_datetime_end;
            });

            if (!find) {
              _context2.next = 31;
              break;
            }

            _context2.t0 = find.status;
            _context2.next = _context2.t0 === 2 ? 18 : _context2.t0 === 1 ? 21 : 21;
            break;

          case 18:
            task.status = 2;
            task.exportId = find.id;
            return _context2.abrupt("return", true);

          case 21:
            task.status = 6;
            task.msg = '文件正在生成中';
            log["a" /* default */].setLog(task.msg, "\u5F53\u524D\u91CD\u8BD5\u6B21\u6570-".concat(count));
            _context2.next = 26;
            return Object(util["g" /* delayed */])(30 * 1000);

          case 26:
            _context2.next = 28;
            return getEPRReport_awaitReportDownload(task, ++count);

          case 28:
            return _context2.abrupt("return", _context2.sent);

          case 29:
            _context2.next = 34;
            break;

          case 31:
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D----not find";
            log["a" /* default */].setLog(task.msg);

          case 34:
            _context2.next = 39;
            break;

          case 36:
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0CTemu\u89C4\u5219\u53EF\u80FD\u6539\u53D8\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D";
            log["a" /* default */].setLog(task.msg);

          case 39:
            _context2.next = 46;
            break;

          case 41:
            _context2.prev = 41;
            _context2.t1 = _context2["catch"](1);
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context2.t1, task));
            log["a" /* default */].setLog(task.msg);

          case 46:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2, null, [[1, 41]]);
  }));

  return function awaitReportDownload(_x2) {
    return _ref2.apply(this, arguments);
  };
}(); // 获取下载报表链接


var getEPRReport_getReportUrl = /*#__PURE__*/function () {
  var _ref3 = getEPRReport_asyncToGenerator( /*#__PURE__*/getEPRReport_regeneratorRuntime().mark(function _callee3(task) {
    var res;
    return getEPRReport_regeneratorRuntime().wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            _context3.prev = 0;
            _context3.next = 3;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/file/export/download"), 'post', {
              id: task.exportId,
              taskType: task.taskType
            }, {
              Mallid: task.platform_store_id,
              changeStoreId: task.changeStoreId
            });

          case 3:
            res = _context3.sent;

            if (!(res.success && res.result)) {
              _context3.next = 7;
              break;
            }

            task.fileUrl = res.result.fileUrl;
            return _context3.abrupt("return", {
              fileUrl: res.result.fileUrl
            });

          case 7:
            _context3.next = 14;
            break;

          case 9:
            _context3.prev = 9;
            _context3.t0 = _context3["catch"](0);
            task.status = 9;
            task.msg = "\u83B7\u53D6\u4E0B\u8F7D\u62A5\u8868\u94FE\u63A5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context3.t0, task));
            log["a" /* default */].setLog(task.msg);

          case 14:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3, null, [[0, 9]]);
  }));

  return function getReportUrl(_x3) {
    return _ref3.apply(this, arguments);
  };
}(); // 下载报表


var getEPRReport_downloadReport = /*#__PURE__*/function () {
  var _ref4 = getEPRReport_asyncToGenerator( /*#__PURE__*/getEPRReport_regeneratorRuntime().mark(function _callee4(task) {
    var res, name, oFile, fileRes, zip;
    return getEPRReport_regeneratorRuntime().wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            _context4.prev = 0;
            _context4.next = 3;
            return axios_default()({
              method: 'GET',
              url: task.fileUrl,
              responseType: 'blob'
            });

          case 3:
            res = _context4.sent;

            if (!(res && res.data)) {
              _context4.next = 16;
              break;
            }

            name = Object(util["p" /* getNameByUrl */])(task.fileUrl);
            oFile = new File([res.data], name, {
              type: 'application/zip'
            });
            // 文件压缩
            log["a" /* default */].setLog('源文件大小', "".concat(oFile.size, "b"));
            zip = new jszip_min_default.a();
            zip.file(name, res.data, {
              binary: true
            });
            _context4.next = 12;
            return zip.generateAsync({
              type: "nodebuffer",
              compression: "DEFLATE",
              // STORE：默认不压缩 DEFLATE：需要压缩
              compressionOptions: {
                level: 9 // 压缩等级1~9    1压缩速度最快，9最优压缩方式

              }
            }).then(function (res) {
              var cFile = new File([res], "".concat(name.split('.')[0], ".zip"), {
                type: 'application/zip'
              });
              log["a" /* default */].setLog('压缩后文件大小', "".concat(cFile.size, "b"), cFile.name);
              fileRes = {
                file: cFile
              };
            }).catch(function (e) {
              log["a" /* default */].setLog('财务报表压缩失败', Object(util["r" /* isError */])(e));
              fileRes = {
                file: oFile
              };
            });

          case 12:
            log["a" /* default */].setLog('下载成功');
            task.status = 4;
            task.report_get_date = moment_default()().format('YYYY-MM-DD HH:mm:ss');
            return _context4.abrupt("return", fileRes);

          case 16:
            _context4.next = 23;
            break;

          case 18:
            _context4.prev = 18;
            _context4.t0 = _context4["catch"](0);
            task.status = 5;
            task.msg = "\u4E0B\u8F7D\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context4.t0, task));
            log["a" /* default */].setLog(task.msg);

          case 23:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4, null, [[0, 18]]);
  }));

  return function downloadReport(_x4) {
    return _ref4.apply(this, arguments);
  };
}();

var getEPRReport = /*#__PURE__*/function () {
  var _ref5 = getEPRReport_asyncToGenerator( /*#__PURE__*/getEPRReport_regeneratorRuntime().mark(function _callee5(task) {
    var loginRes, msg, param, res, uploadRes;
    return getEPRReport_regeneratorRuntime().wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            task.changeStoreId = "".concat(task.platform_store_id, "&").concat(task.siteId);
            task.host = temu["f" /* temu */].cbEuHost;
            task.taskType = 18; // 商品环保费18, 包装环保费19, 代付服务费16

            task.exportType = 2; // 已扣费2 ，已退费 4

            if (task.report_type == 59) {
              task.taskType = 18;
              task.exportType = 2;
            }

            if (task.report_type == 510) {
              task.taskType = 18;
              task.exportType = 4;
            }

            if (task.report_type == 511) {
              task.taskType = 19;
              task.exportType = 2;
            }

            if (task.report_type == 512) {
              task.taskType = 19;
              task.exportType = 4;
            } // 代付服务费-已扣费，生成接口传参和page查询不一样


            if (task.report_type == 513) {
              task.taskType = 16;
            } // 监听header头修改cookie
            // await changeLocalMallId(task.platform_store_id, task.siteId, task.host)


            _context5.next = 11;
            return Object(temu["e" /* loginCb */])(task);

          case 11:
            loginRes = _context5.sent;

            if (loginRes) {
              _context5.next = 17;
              break;
            }

            msg = '切换到欧区站点失败，请检查';
            log["a" /* default */].setLog(msg);
            task.msg = msg;
            return _context5.abrupt("return", {
              code: 1,
              msg: msg
            });

          case 17:
            _context5.t0 = task.status !== 6;

            if (!_context5.t0) {
              _context5.next = 22;
              break;
            }

            _context5.next = 21;
            return getEPRReport_awaitReportDownload(task);

          case 21:
            _context5.t0 = !_context5.sent;

          case 22:
            if (!_context5.t0) {
              _context5.next = 27;
              break;
            }

            _context5.next = 25;
            return getEPRReport_generateReport(task);

          case 25:
            if (_context5.sent) {
              _context5.next = 27;
              break;
            }

            return _context5.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 27:
            _context5.t1 = task.status !== 2;

            if (!_context5.t1) {
              _context5.next = 32;
              break;
            }

            _context5.next = 31;
            return getEPRReport_awaitReportDownload(task);

          case 31:
            _context5.t1 = !_context5.sent;

          case 32:
            if (!_context5.t1) {
              _context5.next = 34;
              break;
            }

            return _context5.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 34:
            _context5.next = 36;
            return getEPRReport_getReportUrl(task);

          case 36:
            if (_context5.sent) {
              _context5.next = 38;
              break;
            }

            return _context5.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 38:
            // 默认参数
            param = {
              type_id: task.type_id,
              platform_store_id: task.platform_store_id,
              result: null,
              code: 0,
              msg: null
            };
            _context5.next = 41;
            return getEPRReport_downloadReport(task);

          case 41:
            res = _context5.sent;

            if (!(res && res.file)) {
              _context5.next = 52;
              break;
            }

            _context5.next = 45;
            return Object(util["G" /* uploadFile */])(res.file);

          case 45:
            uploadRes = _context5.sent;
            log["a" /* default */].setLog('文件上传结果：', JSON.stringify(uploadRes));

            if (!(uploadRes && uploadRes.code === 1)) {
              _context5.next = 49;
              break;
            }

            return _context5.abrupt("return", getEPRReport_objectSpread(getEPRReport_objectSpread({}, param), {}, {
              result: {
                report_file: uploadRes.data,
                cosKey: uploadRes.data.key,
                originFileName: uploadRes.data.originFileName,
                report_custom_date_start: task.report_custom_date_start,
                report_custom_date_end: task.report_custom_date_end,
                reportType: task.report_type,
                reportDate: task.report_date_month
              }
            }));

          case 49:
            // 上传失败
            task.status = 7;
            task.msg = '文件上传cos失败';
            param.result = {
              requestId: uploadRes.requestId,
              msg: uploadRes.msg
            };

          case 52:
            if (![8, 12].includes(task.status)) {
              _context5.next = 55;
              break;
            }

            task.isDelete = true;
            return _context5.abrupt("return", getEPRReport_objectSpread(getEPRReport_objectSpread({}, param), {}, {
              msg: task.msg,
              code: task.status === 8 ? 3 : 1
            }));

          case 55:
            return _context5.abrupt("return", getEPRReport_objectSpread(getEPRReport_objectSpread({}, param), {}, {
              code: 2,
              msg: task.msg
            }));

          case 56:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));

  return function getEPRReport(_x5) {
    return _ref5.apply(this, arguments);
  };
}();

/* harmony default export */ var qtReport_getEPRReport = (getEPRReport); // window.testEPRReport = () => {
//   getEPRReport({
//     report_type: 512,
//     host:'https://agentseller-eu.temu.com',
//     report_custom_date_start:'2025-01-01',
//     report_custom_date_end:'2025-01-13',
//     platform_store_id: 65016470556,
//     status: 0,
//   })
// }
// EXTERNAL MODULE: ./src/config.js
var config = __webpack_require__("db49");

// CONCATENATED MODULE: ./src/platform/temu/qtReport/getTemuReport.js
function getTemuReport_typeof(obj) { "@babel/helpers - typeof"; return getTemuReport_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, getTemuReport_typeof(obj); }

function getTemuReport_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function getTemuReport_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? getTemuReport_ownKeys(Object(source), !0).forEach(function (key) { getTemuReport_defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : getTemuReport_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function getTemuReport_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function getTemuReport_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ getTemuReport_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == getTemuReport_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function getTemuReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function getTemuReport_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { getTemuReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { getTemuReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }









var getTemuReport_generateReport = /*#__PURE__*/function () {
  var _ref = getTemuReport_asyncToGenerator( /*#__PURE__*/getTemuReport_regeneratorRuntime().mark(function _callee(task) {
    var _yield$nativeRequest, success, errorMsg, errorCode, errMsg, msg;

    return getTemuReport_regeneratorRuntime().wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.prev = 0;
            _context.next = 3;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/file/export"), 'post', {
              beginTime: task.report_custom_datetime_start,
              endTime: task.report_custom_datetime_end,
              fundDetailExport: true,
              taskType: 19
            }, {
              Mallid: task.platform_store_id
            });

          case 3:
            _yield$nativeRequest = _context.sent;
            success = _yield$nativeRequest.success;
            errorMsg = _yield$nativeRequest.errorMsg;
            errorCode = _yield$nativeRequest.errorCode;

            if (!success) {
              _context.next = 12;
              break;
            }

            log["a" /* default */].setLog('半托管财务报表生成成功');
            return _context.abrupt("return", true);

          case 12:
            errMsg = JSON.stringify(errorMsg);

            // 操作频繁直接不让重试
            if (errorCode === 2000000 || errMsg.includes('请明日再试')) {
              task.error_time = config["d" /* TEMU_MAX_RETRY_COUNT */];
              msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(errMsg);
            } else {
              msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(errMsg);
            }

            log["a" /* default */].setLog(msg);
            task.msg = msg;
            task.status = 3;

          case 17:
            _context.next = 25;
            break;

          case 19:
            _context.prev = 19;
            _context.t0 = _context["catch"](0);
            task.msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context.t0, task));
            task.status = 3;
            log["a" /* default */].setLog(task.msg);
            return _context.abrupt("return", false);

          case 25:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, null, [[0, 19]]);
  }));

  return function generateReport(_x) {
    return _ref.apply(this, arguments);
  };
}(); // 查询报表生成状态


var getTemuReport_awaitReportDownload = /*#__PURE__*/function () {
  var _ref2 = getTemuReport_asyncToGenerator( /*#__PURE__*/getTemuReport_regeneratorRuntime().mark(function _callee2(task) {
    var count,
        res,
        list,
        find,
        _args2 = arguments;
    return getTemuReport_regeneratorRuntime().wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            count = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 0;
            _context2.prev = 1;

            if (!(count >= 5)) {
              _context2.next = 8;
              break;
            }

            log["a" /* default */].setLog('文件正在生成，超过最大重试次数，退出执行下一任务');
            task.run_time = 0;
            task.msg = "\u6587\u4EF6\u6B63\u5728\u751F\u6210\u4E2D";
            task.status = 6;
            return _context2.abrupt("return", false);

          case 8:
            _context2.next = 10;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/file/export/history/page"), 'post', {
              pageNum: 1,
              pageSize: 50,
              taskType: 19
            }, {
              Mallid: task.platform_store_id
            });

          case 10:
            res = _context2.sent;

            if (!(res && res.result)) {
              _context2.next = 38;
              break;
            }

            list = res.result.merchantMerchantFileExportHistoryList;
            find = list.find(function (item) {
              return item.fundDetailExport == true && item.searchExportTimeBegin == task.report_custom_datetime_start && item.searchExportTimeEnd == task.report_custom_datetime_end && item.createTime > Date.now() - 24 * 60 * 60 * 1000;
            });

            if (!find) {
              _context2.next = 33;
              break;
            }

            _context2.t0 = find.status;
            _context2.next = _context2.t0 === 2 ? 18 : _context2.t0 === 1 ? 23 : 23;
            break;

          case 18:
            task.status = 2;
            task.agentSellerExportParams = find.agentSellerExportParams;
            task.agentSellerExportSign = find.agentSellerExportSign;
            task.downloadId = find.id;
            return _context2.abrupt("return", true);

          case 23:
            task.status = 6;
            task.msg = '文件正在生成中';
            log["a" /* default */].setLog(task.msg, "\u5F53\u524D\u91CD\u8BD5\u6B21\u6570-".concat(count));
            _context2.next = 28;
            return Object(util["g" /* delayed */])(30 * 1000);

          case 28:
            _context2.next = 30;
            return getTemuReport_awaitReportDownload(task, ++count);

          case 30:
            return _context2.abrupt("return", _context2.sent);

          case 31:
            _context2.next = 36;
            break;

          case 33:
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D----not find";
            log["a" /* default */].setLog(task.msg);

          case 36:
            _context2.next = 41;
            break;

          case 38:
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0CTemu\u89C4\u5219\u53EF\u80FD\u6539\u53D8\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D";
            log["a" /* default */].setLog(task.msg);

          case 41:
            _context2.next = 48;
            break;

          case 43:
            _context2.prev = 43;
            _context2.t1 = _context2["catch"](1);
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context2.t1, task));
            log["a" /* default */].setLog(task.msg);

          case 48:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2, null, [[1, 43]]);
  }));

  return function awaitReportDownload(_x2) {
    return _ref2.apply(this, arguments);
  };
}(); // 获取英文中心下载报表链接


var getTemuReport_getEnReportUrl = /*#__PURE__*/function () {
  var _ref3 = getTemuReport_asyncToGenerator( /*#__PURE__*/getTemuReport_regeneratorRuntime().mark(function _callee3(task, host) {
    var loginRes, msg, changeStoreId, _yield$nativeRequest2, success, result, errorMsg, res, _msg;

    return getTemuReport_regeneratorRuntime().wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            // 需要提前登录一下美区或者欧区
            task.host = host;
            _context3.next = 3;
            return Object(temu["e" /* loginCb */])(task);

          case 3:
            loginRes = _context3.sent;

            if (loginRes) {
              _context3.next = 10;
              break;
            }

            msg = '切换到美区、欧区或全球站点失败，请检查';
            task.msg = msg;
            task.status = 11;
            log["a" /* default */].setLog(task.msg);
            return _context3.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 10:
            _context3.prev = 10;
            changeStoreId = "".concat(task.platform_store_id, "&").concat(task.siteId);
            _context3.next = 14;
            return Object(util["u" /* nativeRequest */])("".concat(host, "/api/merchant/file/export"), 'post', {
              params: task.agentSellerExportParams,
              sign: task.agentSellerExportSign,
              taskType: 31
            }, {
              Mallid: task.platform_store_id,
              changeStoreId: changeStoreId
            });

          case 14:
            _yield$nativeRequest2 = _context3.sent;
            success = _yield$nativeRequest2.success;
            result = _yield$nativeRequest2.result;
            errorMsg = _yield$nativeRequest2.errorMsg;

            if (!(success && result)) {
              _context3.next = 36;
              break;
            }

            _context3.prev = 19;
            _context3.next = 22;
            return Object(util["u" /* nativeRequest */])("".concat(host, "/api/merchant/file/export/download"), 'post', {
              id: result,
              taskType: 31
            }, {
              Mallid: task.platform_store_id,
              changeStoreId: changeStoreId
            });

          case 22:
            res = _context3.sent;

            if (!(res.success && res.result)) {
              _context3.next = 26;
              break;
            }

            task.fileUrl = res.result.fileUrl;
            return _context3.abrupt("return", {
              fileUrl: res.result.fileUrl
            });

          case 26:
            _context3.next = 34;
            break;

          case 28:
            _context3.prev = 28;
            _context3.t0 = _context3["catch"](19);
            task.msg = "\u4E0B\u8F7D\u62A5\u8868\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context3.t0, task));
            task.status = 9;
            log["a" /* default */].setLog(task.msg);
            return _context3.abrupt("return", false);

          case 34:
            _context3.next = 40;
            break;

          case 36:
            _msg = "\u83B7\u53D6\u62A5\u8868\u4E0B\u8F7D\u94FE\u63A5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(JSON.stringify(errorMsg));
            task.msg = _msg;
            task.status = 9;
            log["a" /* default */].setLog(_msg);

          case 40:
            _context3.next = 48;
            break;

          case 42:
            _context3.prev = 42;
            _context3.t1 = _context3["catch"](10);
            task.msg = "\u83B7\u53D6\u4E0B\u8F7D\u62A5\u8868\u94FE\u63A5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context3.t1, task));
            task.status = 9;
            log["a" /* default */].setLog(task.msg);
            return _context3.abrupt("return", false);

          case 48:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3, null, [[10, 42], [19, 28]]);
  }));

  return function getEnReportUrl(_x3, _x4) {
    return _ref3.apply(this, arguments);
  };
}(); // 获取下载报表链接


var getTemuReport_getCnReportUrl = /*#__PURE__*/function () {
  var _ref4 = getTemuReport_asyncToGenerator( /*#__PURE__*/getTemuReport_regeneratorRuntime().mark(function _callee4(task) {
    var res;
    return getTemuReport_regeneratorRuntime().wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            _context4.prev = 0;
            _context4.next = 3;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/file/export/download"), 'post', {
              id: task.downloadId,
              taskType: 19
            }, {
              Mallid: task.platform_store_id
            });

          case 3:
            res = _context4.sent;

            if (!(res.success && res.result)) {
              _context4.next = 9;
              break;
            }

            task.fileUrl = res.result.fileUrl;
            return _context4.abrupt("return", {
              fileUrl: res.result.fileUrl
            });

          case 9:
            task.status = 9;
            task.msg = "\u83B7\u53D6\u4E0B\u8F7D\u62A5\u8868\u94FE\u63A5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(res.errorMsg);
            log["a" /* default */].setLog(task.msg);

          case 12:
            _context4.next = 19;
            break;

          case 14:
            _context4.prev = 14;
            _context4.t0 = _context4["catch"](0);
            task.status = 9;
            task.msg = "\u83B7\u53D6\u4E0B\u8F7D\u62A5\u8868\u94FE\u63A5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context4.t0, task));
            log["a" /* default */].setLog(task.msg);

          case 19:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4, null, [[0, 14]]);
  }));

  return function getCnReportUrl(_x5) {
    return _ref4.apply(this, arguments);
  };
}(); // 下载报表


var getTemuReport_downloadReport = /*#__PURE__*/function () {
  var _ref5 = getTemuReport_asyncToGenerator( /*#__PURE__*/getTemuReport_regeneratorRuntime().mark(function _callee5(task) {
    var res, name, oFile, fileRes, zip;
    return getTemuReport_regeneratorRuntime().wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            _context5.prev = 0;
            _context5.next = 3;
            return axios_default()({
              method: 'GET',
              url: task.fileUrl,
              responseType: 'blob'
            });

          case 3:
            res = _context5.sent;

            if (!(res && res.data)) {
              _context5.next = 16;
              break;
            }

            name = Object(util["p" /* getNameByUrl */])(task.fileUrl);
            oFile = new File([res.data], name, {
              type: 'application/zip'
            });
            // 文件压缩
            log["a" /* default */].setLog('源文件大小', "".concat(oFile.size, "b"));
            zip = new jszip_min_default.a();
            zip.file(name, res.data, {
              binary: true
            });
            _context5.next = 12;
            return zip.generateAsync({
              type: "nodebuffer",
              compression: "DEFLATE",
              // STORE：默认不压缩 DEFLATE：需要压缩
              compressionOptions: {
                level: 9 // 压缩等级1~9    1压缩速度最快，9最优压缩方式

              }
            }).then(function (res) {
              var cFile = new File([res], "".concat(name.split('.')[0], ".zip"), {
                type: 'application/zip'
              });
              log["a" /* default */].setLog('压缩后文件大小', "".concat(cFile.size, "b"), cFile.name);
              fileRes = {
                file: cFile
              };
            }).catch(function (e) {
              log["a" /* default */].setLog('财务报表压缩失败', Object(util["r" /* isError */])(e));
              fileRes = {
                file: oFile
              };
            });

          case 12:
            log["a" /* default */].setLog('下载成功');
            task.status = 4;
            task.report_get_date = moment_default()().format('YYYY-MM-DD HH:mm:ss');
            return _context5.abrupt("return", fileRes);

          case 16:
            _context5.next = 23;
            break;

          case 18:
            _context5.prev = 18;
            _context5.t0 = _context5["catch"](0);
            task.status = 5;
            task.msg = "\u4E0B\u8F7D\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context5.t0, task));
            log["a" /* default */].setLog(task.msg);

          case 23:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5, null, [[0, 18]]);
  }));

  return function downloadReport(_x6) {
    return _ref5.apply(this, arguments);
  };
}();

var getTemuReport = /*#__PURE__*/function () {
  var _ref6 = getTemuReport_asyncToGenerator( /*#__PURE__*/getTemuReport_regeneratorRuntime().mark(function _callee6(task) {
    var host, param, res, uploadRes;
    return getTemuReport_regeneratorRuntime().wrap(function _callee6$(_context6) {
      while (1) {
        switch (_context6.prev = _context6.next) {
          case 0:
            _context6.t0 = task.status !== 6;

            if (!_context6.t0) {
              _context6.next = 5;
              break;
            }

            _context6.next = 4;
            return getTemuReport_awaitReportDownload(task);

          case 4:
            _context6.t0 = !_context6.sent;

          case 5:
            if (!_context6.t0) {
              _context6.next = 10;
              break;
            }

            _context6.next = 8;
            return getTemuReport_generateReport(task);

          case 8:
            if (_context6.sent) {
              _context6.next = 10;
              break;
            }

            return _context6.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 10:
            _context6.t1 = task.status !== 2;

            if (!_context6.t1) {
              _context6.next = 15;
              break;
            }

            _context6.next = 14;
            return getTemuReport_awaitReportDownload(task);

          case 14:
            _context6.t1 = !_context6.sent;

          case 15:
            if (!_context6.t1) {
              _context6.next = 17;
              break;
            }

            return _context6.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 17:
            if (!(task.report_type == 1)) {
              _context6.next = 24;
              break;
            }

            _context6.next = 20;
            return getTemuReport_getCnReportUrl(task);

          case 20:
            if (_context6.sent) {
              _context6.next = 22;
              break;
            }

            return _context6.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 22:
            _context6.next = 29;
            break;

          case 24:
            host = {
              101: temu["f" /* temu */].cbGlobalHost,
              102: temu["f" /* temu */].cbEuHost,
              103: temu["f" /* temu */].cbUsHost
            }[task.report_type]; // 监听header头修改cookie
            // await changeLocalMallId(task.platform_store_id, task.siteId, host)

            _context6.next = 27;
            return getTemuReport_getEnReportUrl(task, host);

          case 27:
            if (_context6.sent) {
              _context6.next = 29;
              break;
            }

            return _context6.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 29:
            // 默认参数
            param = {
              type_id: task.type_id,
              platform_store_id: task.platform_store_id,
              result: null,
              code: 0,
              msg: null
            };
            _context6.next = 32;
            return getTemuReport_downloadReport(task);

          case 32:
            res = _context6.sent;

            if (!(res && res.file)) {
              _context6.next = 43;
              break;
            }

            _context6.next = 36;
            return Object(util["G" /* uploadFile */])(res.file);

          case 36:
            uploadRes = _context6.sent;
            log["a" /* default */].setLog('文件上传结果：', JSON.stringify(uploadRes));

            if (!(uploadRes && uploadRes.code === 1)) {
              _context6.next = 40;
              break;
            }

            return _context6.abrupt("return", getTemuReport_objectSpread(getTemuReport_objectSpread({}, param), {}, {
              result: {
                report_file: uploadRes.data,
                cosKey: uploadRes.data.key,
                originFileName: uploadRes.data.originFileName,
                report_custom_date_start: task.report_custom_date_start,
                report_custom_date_end: task.report_custom_date_end,
                reportType: task.report_type,
                reportDate: task.report_date_month
              }
            }));

          case 40:
            // 上传失败
            task.status = 7;
            task.msg = '文件上传cos失败';
            param.result = {
              requestId: uploadRes.requestId,
              msg: uploadRes.msg
            };

          case 43:
            if (![8, 12].includes(task.status)) {
              _context6.next = 46;
              break;
            }

            task.isDelete = true;
            return _context6.abrupt("return", getTemuReport_objectSpread(getTemuReport_objectSpread({}, param), {}, {
              msg: task.msg,
              code: task.status === 8 ? 3 : 1
            }));

          case 46:
            return _context6.abrupt("return", getTemuReport_objectSpread(getTemuReport_objectSpread({}, param), {}, {
              code: 2,
              msg: task.msg
            }));

          case 47:
          case "end":
            return _context6.stop();
        }
      }
    }, _callee6);
  }));

  return function getTemuReport(_x7) {
    return _ref6.apply(this, arguments);
  };
}();

/* harmony default export */ var qtReport_getTemuReport = (getTemuReport); // window.testGetTemuReport = () => {
//   getTemuReport({
//     host:'https://seller.kuajingmaihuo.com',
//     report_custom_date_start:'2024-11-01',
//     report_custom_date_end:'2024-11-26',
//     platform_store_id: 634418215364437,
//     beginTime:1730390400000,
//     endTime:1732636799000,
//     area: 'US',
//     status: 6,
//   })
// }
// CONCATENATED MODULE: ./src/platform/temu/qtReport/getStmlReport.js
function getStmlReport_typeof(obj) { "@babel/helpers - typeof"; return getStmlReport_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, getStmlReport_typeof(obj); }

function getStmlReport_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function getStmlReport_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? getStmlReport_ownKeys(Object(source), !0).forEach(function (key) { getStmlReport_defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : getStmlReport_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function getStmlReport_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function getStmlReport_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ getStmlReport_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == getStmlReport_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function getStmlReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function getStmlReport_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { getStmlReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { getStmlReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }









var getStmlReport_generateReport = /*#__PURE__*/function () {
  var _ref = getStmlReport_asyncToGenerator( /*#__PURE__*/getStmlReport_regeneratorRuntime().mark(function _callee(task) {
    var _yield$nativeRequest, success, result, errorMsg, errorCode, errMsg, msg;

    return getStmlReport_regeneratorRuntime().wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.prev = 0;
            _context.next = 3;
            return Object(util["u" /* nativeRequest */])(task.isUdp ? "".concat(task.host, "/api/udp/yuanbenchu/seller_central/recon_bill/download/async") : "".concat(task.host, "/portal/selene/seller/portal/recon/download"), 'post', {
              req: {
                deductTimeBegin: task.report_custom_datetime_start,
                deductTimeEnd: task.report_custom_datetime_end,
                settleStatus: 1
              },
              requestStr: JSON.stringify(["\u8D26\u5355\u652F\u51FA/\u9000\u6B3E\u65F6\u95F4: ".concat(task.report_custom_date_start, " ~ ").concat(task.report_custom_date_end)])
            }, {
              changeStoreId: task.platform_store_id,
              Mallid: task.platform_store_id
            });

          case 3:
            _yield$nativeRequest = _context.sent;
            success = _yield$nativeRequest.success;
            result = _yield$nativeRequest.result;
            errorMsg = _yield$nativeRequest.errorMsg;
            errorCode = _yield$nativeRequest.errorCode;

            if (!(success && result && result.taskId)) {
              _context.next = 14;
              break;
            }

            log["a" /* default */].setLog('发货面单费报表生成成功');
            task.taskId = result.taskId;
            return _context.abrupt("return", true);

          case 14:
            errMsg = JSON.stringify(errorMsg);

            // 操作频繁直接不让重试
            if (errorCode === 2000000 || errMsg.includes('请明日再试')) {
              task.error_time = config["d" /* TEMU_MAX_RETRY_COUNT */];
              msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(errMsg);
            } else {
              msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(errMsg);
            }

            log["a" /* default */].setLog(msg);
            task.msg = msg;

          case 18:
            _context.next = 26;
            break;

          case 20:
            _context.prev = 20;
            _context.t0 = _context["catch"](0);
            task.status = 3;
            task.msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context.t0, task));
            log["a" /* default */].setLog(task.msg);
            return _context.abrupt("return", false);

          case 26:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, null, [[0, 20]]);
  }));

  return function generateReport(_x) {
    return _ref.apply(this, arguments);
  };
}(); // 查询报表生成状态


var getStmlReport_awaitReportDownload = /*#__PURE__*/function () {
  var _ref2 = getStmlReport_asyncToGenerator( /*#__PURE__*/getStmlReport_regeneratorRuntime().mark(function _callee2(task) {
    var count,
        res,
        list,
        curDate,
        requestDate,
        find,
        _args2 = arguments;
    return getStmlReport_regeneratorRuntime().wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            count = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 0;
            _context2.prev = 1;

            if (!(count >= 5)) {
              _context2.next = 8;
              break;
            }

            log["a" /* default */].setLog('文件正在生成，超过最大重试次数，退出执行下一任务');
            task.run_time = 0;
            task.msg = "\u6587\u4EF6\u6B63\u5728\u751F\u6210\u4E2D";
            task.status = 6;
            return _context2.abrupt("return", false);

          case 8:
            _context2.next = 10;
            return Object(util["u" /* nativeRequest */])(task.isUdp ? "".concat(task.host, "/api/udp/yuanbenchu/seller_central/recon_bill/task/info") : "".concat(task.host, "/portal/selene/seller/portal/recon/download_list"), 'post', {
              pageNum: 1,
              pageSize: 50,
              settleStatus: 1
            }, {
              changeStoreId: task.platform_store_id,
              Mallid: task.platform_store_id
            });

          case 10:
            res = _context2.sent;

            if (!(res && res.result)) {
              _context2.next = 40;
              break;
            }

            list = res.result.excelCommonTaskList;
            _context2.next = 15;
            return Object(util["q" /* getServiceTime */])();

          case 15:
            curDate = _context2.sent;
            requestDate = "".concat(task.report_custom_date_start, " ~ ").concat(task.report_custom_date_end);
            find = list.find(function (item) {
              // 判断列表是否已有要获取报表
              if (item.createTime > curDate - 23 * 60 * 60 * 1000 && !task.taskId) {
                return item.requestStr.indexOf(requestDate) > -1;
              } else return item.taskId == task.taskId;
            });

            if (!find) {
              _context2.next = 35;
              break;
            }

            _context2.t0 = find.isFinished;
            _context2.next = _context2.t0 === true ? 22 : _context2.t0 === false ? 25 : 25;
            break;

          case 22:
            task.status = 2;
            task.downloadUrl = find.downloadUrl;
            return _context2.abrupt("return", true);

          case 25:
            task.status = 6;
            task.msg = '文件正在生成中';
            log["a" /* default */].setLog(task.msg, "\u5F53\u524D\u91CD\u8BD5\u6B21\u6570-".concat(count));
            _context2.next = 30;
            return Object(util["g" /* delayed */])(30 * 1000);

          case 30:
            _context2.next = 32;
            return getStmlReport_awaitReportDownload(task, ++count);

          case 32:
            return _context2.abrupt("return", _context2.sent);

          case 33:
            _context2.next = 38;
            break;

          case 35:
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D----not find";
            log["a" /* default */].setLog(task.msg);

          case 38:
            _context2.next = 43;
            break;

          case 40:
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0CTemu\u89C4\u5219\u53EF\u80FD\u6539\u53D8\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D";
            log["a" /* default */].setLog(task.msg);

          case 43:
            _context2.next = 50;
            break;

          case 45:
            _context2.prev = 45;
            _context2.t1 = _context2["catch"](1);
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context2.t1, task));
            log["a" /* default */].setLog(task.msg);

          case 50:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2, null, [[1, 45]]);
  }));

  return function awaitReportDownload(_x2) {
    return _ref2.apply(this, arguments);
  };
}(); // 下载报表


var getStmlReport_downloadReport = /*#__PURE__*/function () {
  var _ref3 = getStmlReport_asyncToGenerator( /*#__PURE__*/getStmlReport_regeneratorRuntime().mark(function _callee3(task) {
    var res, name, oFile, fileRes, zip;
    return getStmlReport_regeneratorRuntime().wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            _context3.prev = 0;
            _context3.next = 3;
            return axios_default()({
              method: 'GET',
              url: task.downloadUrl,
              responseType: 'blob'
            });

          case 3:
            res = _context3.sent;

            if (!(res && res.data)) {
              _context3.next = 16;
              break;
            }

            name = Object(util["p" /* getNameByUrl */])(task.downloadUrl);
            oFile = new File([res.data], name, {
              type: 'application/zip'
            });
            // 文件压缩
            log["a" /* default */].setLog('源文件大小', "".concat(oFile.size, "b"));
            zip = new jszip_min_default.a();
            zip.file(name, res.data, {
              binary: true
            });
            _context3.next = 12;
            return zip.generateAsync({
              type: "nodebuffer",
              compression: "DEFLATE",
              // STORE：默认不压缩 DEFLATE：需要压缩
              compressionOptions: {
                level: 9 // 压缩等级1~9    1压缩速度最快，9最优压缩方式

              }
            }).then(function (res) {
              var cFile = new File([res], "".concat(name.split('.')[0], ".zip"), {
                type: 'application/zip'
              });
              log["a" /* default */].setLog('压缩后文件大小', "".concat(cFile.size, "b"), cFile.name);
              fileRes = {
                file: cFile
              };
            }).catch(function (e) {
              log["a" /* default */].setLog('发货面单费压缩失败', Object(util["r" /* isError */])(e));
              fileRes = {
                file: oFile
              };
            });

          case 12:
            log["a" /* default */].setLog('下载成功');
            task.status = 4;
            task.report_get_date = moment_default()().format('YYYY-MM-DD HH:mm:ss');
            return _context3.abrupt("return", fileRes);

          case 16:
            _context3.next = 23;
            break;

          case 18:
            _context3.prev = 18;
            _context3.t0 = _context3["catch"](0);
            task.status = 5;
            task.msg = "\u4E0B\u8F7D\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context3.t0, task));
            log["a" /* default */].setLog(task.msg);

          case 23:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3, null, [[0, 18]]);
  }));

  return function downloadReport(_x3) {
    return _ref3.apply(this, arguments);
  };
}();

var getStmlReport = /*#__PURE__*/function () {
  var _ref4 = getStmlReport_asyncToGenerator( /*#__PURE__*/getStmlReport_regeneratorRuntime().mark(function _callee4(task) {
    var loginRes, msg, param, res, uploadRes;
    return getStmlReport_regeneratorRuntime().wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            task.host = task.report_type == 1102 ? temu["f" /* temu */].cbUsHost : temu["f" /* temu */].cbEuHost;
            task.isUdp = task.report_type == 1102; // 监听header头修改cookie
            // await changeLocalMallId(task.platform_store_id, task.siteId, task.host)
            // 需要提前登录一下美区或者欧区

            _context4.next = 4;
            return Object(temu["e" /* loginCb */])(task);

          case 4:
            loginRes = _context4.sent;

            if (loginRes) {
              _context4.next = 10;
              break;
            }

            msg = '切换到美区或欧区站点失败，请检查';
            task.msg = msg;
            log["a" /* default */].setLog(msg);
            return _context4.abrupt("return", {
              code: 1,
              msg: msg
            });

          case 10:
            _context4.t0 = task.status !== 6;

            if (!_context4.t0) {
              _context4.next = 15;
              break;
            }

            _context4.next = 14;
            return getStmlReport_awaitReportDownload(task);

          case 14:
            _context4.t0 = !_context4.sent;

          case 15:
            if (!_context4.t0) {
              _context4.next = 20;
              break;
            }

            _context4.next = 18;
            return getStmlReport_generateReport(task);

          case 18:
            if (_context4.sent) {
              _context4.next = 20;
              break;
            }

            return _context4.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 20:
            _context4.t1 = task.status !== 2;

            if (!_context4.t1) {
              _context4.next = 25;
              break;
            }

            _context4.next = 24;
            return getStmlReport_awaitReportDownload(task);

          case 24:
            _context4.t1 = !_context4.sent;

          case 25:
            if (!_context4.t1) {
              _context4.next = 27;
              break;
            }

            return _context4.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 27:
            // 默认参数
            param = {
              type_id: task.type_id,
              platform_store_id: task.platform_store_id,
              result: null,
              code: 0,
              msg: null
            };
            _context4.next = 30;
            return getStmlReport_downloadReport(task);

          case 30:
            res = _context4.sent;

            if (!(res && res.file)) {
              _context4.next = 41;
              break;
            }

            _context4.next = 34;
            return Object(util["G" /* uploadFile */])(res.file);

          case 34:
            uploadRes = _context4.sent;
            log["a" /* default */].setLog('文件上传结果：', JSON.stringify(uploadRes));

            if (!(uploadRes && uploadRes.code === 1)) {
              _context4.next = 38;
              break;
            }

            return _context4.abrupt("return", getStmlReport_objectSpread(getStmlReport_objectSpread({}, param), {}, {
              result: {
                report_file: uploadRes.data,
                cosKey: uploadRes.data.key,
                originFileName: uploadRes.data.originFileName,
                report_custom_date_start: task.report_custom_date_start,
                report_custom_date_end: task.report_custom_date_end,
                reportType: task.report_type,
                reportDate: task.report_date_month
              }
            }));

          case 38:
            // 上传失败
            task.status = 7;
            task.msg = '文件上传cos失败';
            param.result = {
              requestId: uploadRes.requestId,
              msg: uploadRes.msg
            };

          case 41:
            if (![8, 12].includes(task.status)) {
              _context4.next = 44;
              break;
            }

            task.isDelete = true;
            return _context4.abrupt("return", getStmlReport_objectSpread(getStmlReport_objectSpread({}, param), {}, {
              msg: task.msg,
              code: task.status === 8 ? 3 : 1
            }));

          case 44:
            return _context4.abrupt("return", getStmlReport_objectSpread(getStmlReport_objectSpread({}, param), {}, {
              code: 2,
              msg: task.msg
            }));

          case 45:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4);
  }));

  return function getStmlReport(_x4) {
    return _ref4.apply(this, arguments);
  };
}();

/* harmony default export */ var qtReport_getStmlReport = (getStmlReport); // window.testGetStmlReport = () => {
//   getStmlReport({
//     host:'https://agentseller-eu.temu.com',
//     report_custom_date_start:'2024-11-01',
//     report_custom_date_end:'2024-11-30',
//     platform_store_id: 634418215364437,
//     beginTime:1730390400000,
//     endTime:1732636799000,
//     area: 'EU'
//   })
// }
// CONCATENATED MODULE: ./src/platform/temu/qtReport/getReverseReport.js
function getReverseReport_typeof(obj) { "@babel/helpers - typeof"; return getReverseReport_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, getReverseReport_typeof(obj); }

function getReverseReport_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function getReverseReport_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? getReverseReport_ownKeys(Object(source), !0).forEach(function (key) { getReverseReport_defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : getReverseReport_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function getReverseReport_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function getReverseReport_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ getReverseReport_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == getReverseReport_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function getReverseReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function getReverseReport_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { getReverseReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { getReverseReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }









var getReverseReport_generateReport = /*#__PURE__*/function () {
  var _ref = getReverseReport_asyncToGenerator( /*#__PURE__*/getReverseReport_regeneratorRuntime().mark(function _callee(task) {
    var _yield$nativeRequest, success, result, errorMsg, errorCode, errMsg, msg;

    return getReverseReport_regeneratorRuntime().wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.prev = 0;
            _context.next = 3;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/portal/").concat(task.isUdp ? 'udp/' : '').concat(task.serverName, "/seller/center/bill/download/async"), 'post', {
              ext: JSON.stringify({
                deductTimeBegin: task.report_custom_datetime_start,
                deductTimeEnd: task.report_custom_datetime_end,
                rangeTime: "\u5BFC\u51FA\u4EFB\u52A1\u751F\u6210\u65F6\u95F4: ".concat(task.report_custom_date_start, " ~ ").concat(task.report_custom_date_end)
              })
            }, {
              changeStoreId: task.platform_store_id,
              Mallid: task.platform_store_id
            });

          case 3:
            _yield$nativeRequest = _context.sent;
            success = _yield$nativeRequest.success;
            result = _yield$nativeRequest.result;
            errorMsg = _yield$nativeRequest.errorMsg;
            errorCode = _yield$nativeRequest.errorCode;

            if (!(success && result && result.taskId)) {
              _context.next = 14;
              break;
            }

            log["a" /* default */].setLog('退货面单费报表生成成功');
            task.taskId = result.taskId;
            return _context.abrupt("return", true);

          case 14:
            errMsg = JSON.stringify(errorMsg);

            // 操作频繁直接不让重试
            if (errorCode === 2000000 || errMsg.includes('请明日再试')) {
              task.error_time = config["d" /* TEMU_MAX_RETRY_COUNT */];
              msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(errMsg);
            } else {
              msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(errMsg);
            }

            log["a" /* default */].setLog(msg);
            task.msg = msg;
            task.status = 3;
            return _context.abrupt("return", false);

          case 20:
            _context.next = 28;
            break;

          case 22:
            _context.prev = 22;
            _context.t0 = _context["catch"](0);
            task.status = 3;
            task.msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context.t0, task));
            log["a" /* default */].setLog(task.msg);
            return _context.abrupt("return", false);

          case 28:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, null, [[0, 22]]);
  }));

  return function generateReport(_x) {
    return _ref.apply(this, arguments);
  };
}(); // 查询报表生成状态


var getReverseReport_awaitReportDownload = /*#__PURE__*/function () {
  var _ref2 = getReverseReport_asyncToGenerator( /*#__PURE__*/getReverseReport_regeneratorRuntime().mark(function _callee2(task) {
    var count,
        res,
        list,
        curDate,
        find,
        _args2 = arguments;
    return getReverseReport_regeneratorRuntime().wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            count = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 0;
            _context2.prev = 1;

            if (!(count >= 5)) {
              _context2.next = 8;
              break;
            }

            log["a" /* default */].setLog('文件正在生成，超过最大重试次数，退出执行下一任务');
            task.run_time = 0;
            task.msg = "\u6587\u4EF6\u6B63\u5728\u751F\u6210\u4E2D";
            task.status = 6;
            return _context2.abrupt("return", false);

          case 8:
            _context2.next = 10;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/portal/").concat(task.isUdp ? 'udp/' : '').concat(task.serverName, "/seller/center/bill/task/list"), 'post', {
              pageNum: 1,
              pageSize: 50
            }, {
              changeStoreId: task.platform_store_id,
              Mallid: task.platform_store_id
            });

          case 10:
            res = _context2.sent;

            if (!(res && res.result)) {
              _context2.next = 39;
              break;
            }

            list = res.result.excelCommonTaskList;
            _context2.next = 15;
            return Object(util["q" /* getServiceTime */])();

          case 15:
            curDate = _context2.sent;
            find = list.find(function (item) {
              var ext = item.ext && JSON.parse(item.ext);
              var createTime = new Date(item.createdAt).getTime(); // 判断列表是否已有要获取报表

              if (createTime > curDate - 23 * 60 * 60 * 1000 && ext && !task.taskId) {
                return ext.deductTimeBegin == task.report_custom_datetime_start && ext.deductTimeEnd == task.report_custom_datetime_end;
              } else return item.taskId == task.taskId;
            });

            if (!find) {
              _context2.next = 34;
              break;
            }

            _context2.t0 = find.isFinished;
            _context2.next = _context2.t0 === true ? 21 : _context2.t0 === false ? 24 : 24;
            break;

          case 21:
            task.status = 2;
            task.downloadUrl = find.downloadUrl;
            return _context2.abrupt("return", true);

          case 24:
            task.status = 6;
            task.msg = '文件正在生成中';
            log["a" /* default */].setLog(task.msg, "\u5F53\u524D\u91CD\u8BD5\u6B21\u6570-".concat(count));
            _context2.next = 29;
            return Object(util["g" /* delayed */])(30 * 1000);

          case 29:
            _context2.next = 31;
            return getReverseReport_awaitReportDownload(task, ++count);

          case 31:
            return _context2.abrupt("return", _context2.sent);

          case 32:
            _context2.next = 37;
            break;

          case 34:
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D----not find";
            log["a" /* default */].setLog(task.msg);

          case 37:
            _context2.next = 42;
            break;

          case 39:
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0CTemu\u89C4\u5219\u53EF\u80FD\u6539\u53D8\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D";
            log["a" /* default */].setLog(task.msg);

          case 42:
            _context2.next = 49;
            break;

          case 44:
            _context2.prev = 44;
            _context2.t1 = _context2["catch"](1);
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context2.t1, task));
            log["a" /* default */].setLog(task.msg);

          case 49:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2, null, [[1, 44]]);
  }));

  return function awaitReportDownload(_x2) {
    return _ref2.apply(this, arguments);
  };
}(); // 下载报表


var getReverseReport_downloadReport = /*#__PURE__*/function () {
  var _ref3 = getReverseReport_asyncToGenerator( /*#__PURE__*/getReverseReport_regeneratorRuntime().mark(function _callee3(task) {
    var res, name, oFile, fileRes, zip;
    return getReverseReport_regeneratorRuntime().wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            _context3.prev = 0;
            _context3.next = 3;
            return axios_default()({
              method: 'GET',
              url: task.downloadUrl,
              responseType: 'blob'
            });

          case 3:
            res = _context3.sent;

            if (!(res && res.data)) {
              _context3.next = 16;
              break;
            }

            name = Object(util["p" /* getNameByUrl */])(task.downloadUrl);
            oFile = new File([res.data], name, {
              type: 'application/zip'
            });
            // 文件压缩
            log["a" /* default */].setLog('源文件大小', "".concat(oFile.size, "b"));
            zip = new jszip_min_default.a();
            zip.file(name, res.data, {
              binary: true
            });
            _context3.next = 12;
            return zip.generateAsync({
              type: "nodebuffer",
              compression: "DEFLATE",
              // STORE：默认不压缩 DEFLATE：需要压缩
              compressionOptions: {
                level: 9 // 压缩等级1~9    1压缩速度最快，9最优压缩方式

              }
            }).then(function (res) {
              var cFile = new File([res], "".concat(name.split('.')[0], ".zip"), {
                type: 'application/zip'
              });
              log["a" /* default */].setLog('压缩后文件大小', "".concat(cFile.size, "b"), cFile.name);
              fileRes = {
                file: cFile
              };
            }).catch(function (e) {
              log["a" /* default */].setLog('退货面单费压缩失败', Object(util["r" /* isError */])(e));
              fileRes = {
                file: oFile
              };
            });

          case 12:
            log["a" /* default */].setLog('下载成功');
            task.status = 4;
            task.report_get_date = moment_default()().format('YYYY-MM-DD HH:mm:ss');
            return _context3.abrupt("return", fileRes);

          case 16:
            _context3.next = 23;
            break;

          case 18:
            _context3.prev = 18;
            _context3.t0 = _context3["catch"](0);
            task.status = 5;
            task.msg = "\u4E0B\u8F7D\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context3.t0, task));
            log["a" /* default */].setLog(task.msg);

          case 23:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3, null, [[0, 18]]);
  }));

  return function downloadReport(_x3) {
    return _ref3.apply(this, arguments);
  };
}();

var getReverseReport = /*#__PURE__*/function () {
  var _ref4 = getReverseReport_asyncToGenerator( /*#__PURE__*/getReverseReport_regeneratorRuntime().mark(function _callee4(task) {
    var isUs, loginRes, msg, param, res, uploadRes;
    return getReverseReport_regeneratorRuntime().wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            isUs = [1202, 1302].includes(task.report_type);
            task.host = isUs ? temu["f" /* temu */].cbUsHost : temu["f" /* temu */].cbEuHost;
            task.serverName = [1201, 1202].includes(task.report_type) ? 'sunce' : 'sunquan';
            task.isUdp = isUs; // 监听header头修改cookie
            // await changeLocalMallId(task.platform_store_id, task.siteId, task.host)
            // 需要提前登录一下美区或者欧区

            _context4.next = 6;
            return Object(temu["e" /* loginCb */])(task);

          case 6:
            loginRes = _context4.sent;

            if (loginRes) {
              _context4.next = 12;
              break;
            }

            msg = '切换到美区或欧区站点失败，请检查';
            task.msg = msg;
            log["a" /* default */].setLog(msg);
            return _context4.abrupt("return", {
              code: 1,
              msg: msg
            });

          case 12:
            _context4.t0 = task.status !== 6;

            if (!_context4.t0) {
              _context4.next = 17;
              break;
            }

            _context4.next = 16;
            return getReverseReport_awaitReportDownload(task);

          case 16:
            _context4.t0 = !_context4.sent;

          case 17:
            if (!_context4.t0) {
              _context4.next = 22;
              break;
            }

            _context4.next = 20;
            return getReverseReport_generateReport(task);

          case 20:
            if (_context4.sent) {
              _context4.next = 22;
              break;
            }

            return _context4.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 22:
            _context4.t1 = task.status !== 2;

            if (!_context4.t1) {
              _context4.next = 27;
              break;
            }

            _context4.next = 26;
            return getReverseReport_awaitReportDownload(task);

          case 26:
            _context4.t1 = !_context4.sent;

          case 27:
            if (!_context4.t1) {
              _context4.next = 29;
              break;
            }

            return _context4.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 29:
            // 默认参数
            param = {
              type_id: task.type_id,
              platform_store_id: task.platform_store_id,
              result: null,
              code: 0,
              msg: null
            };
            _context4.next = 32;
            return getReverseReport_downloadReport(task);

          case 32:
            res = _context4.sent;

            if (!(res && res.file)) {
              _context4.next = 43;
              break;
            }

            _context4.next = 36;
            return Object(util["G" /* uploadFile */])(res.file);

          case 36:
            uploadRes = _context4.sent;
            log["a" /* default */].setLog('文件上传结果：', JSON.stringify(uploadRes));

            if (!(uploadRes && uploadRes.code === 1)) {
              _context4.next = 40;
              break;
            }

            return _context4.abrupt("return", getReverseReport_objectSpread(getReverseReport_objectSpread({}, param), {}, {
              result: {
                report_file: uploadRes.data,
                cosKey: uploadRes.data.key,
                originFileName: uploadRes.data.originFileName,
                report_custom_date_start: task.report_custom_date_start,
                report_custom_date_end: task.report_custom_date_end,
                reportType: task.report_type,
                reportDate: task.report_date_month
              }
            }));

          case 40:
            // 上传失败
            task.status = 7;
            task.msg = '文件上传cos失败';
            param.result = {
              requestId: uploadRes.requestId,
              msg: uploadRes.msg
            };

          case 43:
            if (![8, 12].includes(task.status)) {
              _context4.next = 46;
              break;
            }

            task.isDelete = true;
            return _context4.abrupt("return", getReverseReport_objectSpread(getReverseReport_objectSpread({}, param), {}, {
              msg: task.msg,
              code: task.status === 8 ? 3 : 1
            }));

          case 46:
            return _context4.abrupt("return", getReverseReport_objectSpread(getReverseReport_objectSpread({}, param), {}, {
              code: 2,
              msg: task.msg
            }));

          case 47:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4);
  }));

  return function getReverseReport(_x4) {
    return _ref4.apply(this, arguments);
  };
}();

/* harmony default export */ var qtReport_getReverseReport = (getReverseReport); // window.testGetReverseReport = () => {
//   getReverseReport({
//     area: 'EU',
//     host:'https://agentseller-eu.temu.com',
//     report_custom_date_start:'2024-11-01',
//     report_custom_date_end:'2024-11-26',
//     platform_store_id: 634418215364437,
//     beginTime:1730390400000,
//     endTime:1732636799000,
//     report_type:12,
//   })
// }
// CONCATENATED MODULE: ./src/platform/temu/qtReport/getPoDetail.js
function getPoDetail_typeof(obj) { "@babel/helpers - typeof"; return getPoDetail_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, getPoDetail_typeof(obj); }

function getPoDetail_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function getPoDetail_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? getPoDetail_ownKeys(Object(source), !0).forEach(function (key) { getPoDetail_defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : getPoDetail_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function getPoDetail_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function getPoDetail_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ getPoDetail_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == getPoDetail_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function getPoDetail_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function getPoDetail_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { getPoDetail_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { getPoDetail_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }







 // 生成报告

var getPoDetail_generateReport = /*#__PURE__*/function () {
  var _ref = getPoDetail_asyncToGenerator( /*#__PURE__*/getPoDetail_regeneratorRuntime().mark(function _callee(task) {
    var _yield$nativeRequest, success, errorMsg, result, errorCode, errMsg, msg;

    return getPoDetail_regeneratorRuntime().wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.prev = 0;
            _context.next = 3;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/file/export"), 'post', {
              accountTimeEnd: task.report_custom_date_end,
              accountTimeStart: task.report_custom_date_start,
              taskType: 36
            }, {
              Mallid: task.platform_store_id
            });

          case 3:
            _yield$nativeRequest = _context.sent;
            success = _yield$nativeRequest.success;
            errorMsg = _yield$nativeRequest.errorMsg;
            result = _yield$nativeRequest.result;
            errorCode = _yield$nativeRequest.errorCode;

            if (!success) {
              _context.next = 14;
              break;
            }

            log["a" /* default */].setLog('半托管po明细生成成功');
            task.reportId = result;
            return _context.abrupt("return", true);

          case 14:
            errMsg = JSON.stringify(errorMsg);

            // 操作频繁直接不让重试
            if (errorCode === 2000000 || errMsg.includes('请明日再试')) {
              task.error_time = config["d" /* TEMU_MAX_RETRY_COUNT */];
              msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(errMsg);
            } else {
              msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(errMsg);
            }

            log["a" /* default */].setLog(msg);
            task.msg = msg;
            task.status = 3;

          case 19:
            _context.next = 27;
            break;

          case 21:
            _context.prev = 21;
            _context.t0 = _context["catch"](0);
            task.msg = "\u62A5\u544A\u751F\u6210\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context.t0, task));
            task.status = 3;
            log["a" /* default */].setLog(task.msg);
            return _context.abrupt("return", false);

          case 27:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, null, [[0, 21]]);
  }));

  return function generateReport(_x) {
    return _ref.apply(this, arguments);
  };
}(); // 查询报表生成状态


var getPoDetail_awaitReportDownload = /*#__PURE__*/function () {
  var _ref2 = getPoDetail_asyncToGenerator( /*#__PURE__*/getPoDetail_regeneratorRuntime().mark(function _callee2(task) {
    var count,
        res,
        list,
        find,
        _args2 = arguments;
    return getPoDetail_regeneratorRuntime().wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            count = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 0;
            _context2.prev = 1;

            if (!(count >= 5)) {
              _context2.next = 8;
              break;
            }

            log["a" /* default */].setLog('文件正在生成，超过最大重试次数，退出执行下一任务');
            task.run_time = 0;
            task.msg = "\u6587\u4EF6\u6B63\u5728\u751F\u6210\u4E2D";
            task.status = 6;
            return _context2.abrupt("return", false);

          case 8:
            _context2.next = 10;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/file/export/history/page"), 'post', {
              pageNum: 1,
              pageSize: 50,
              taskType: 36
            }, {
              Mallid: task.platform_store_id
            });

          case 10:
            res = _context2.sent;

            if (!(res && res.result)) {
              _context2.next = 36;
              break;
            }

            list = res.result.merchantMerchantFileExportHistoryList;
            find = list.find(function (item) {
              var accountTimeStart = moment_default()(item.accountTimeStart).format('YYYY-MM-DD');
              var accountTimeEnd = moment_default()(item.accountTimeEnd).format('YYYY-MM-DD');
              return item.expireSeconds > 0 && accountTimeStart == task.report_custom_date_start && accountTimeEnd == task.report_custom_date_end || item.id == task.reportId;
            });

            if (!find) {
              _context2.next = 31;
              break;
            }

            _context2.t0 = find.status;
            _context2.next = _context2.t0 === 2 ? 18 : _context2.t0 === 1 ? 21 : 21;
            break;

          case 18:
            task.status = 2;
            task.reportId = find.id;
            return _context2.abrupt("return", true);

          case 21:
            task.status = 6;
            task.msg = '文件正在生成中';
            log["a" /* default */].setLog(task.msg, "\u5F53\u524D\u91CD\u8BD5\u6B21\u6570-".concat(count));
            _context2.next = 26;
            return Object(util["g" /* delayed */])(30 * 1000);

          case 26:
            _context2.next = 28;
            return getPoDetail_awaitReportDownload(task, ++count);

          case 28:
            return _context2.abrupt("return", _context2.sent);

          case 29:
            _context2.next = 34;
            break;

          case 31:
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D----not find";
            log["a" /* default */].setLog(task.msg);

          case 34:
            _context2.next = 39;
            break;

          case 36:
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0CTemu\u89C4\u5219\u53EF\u80FD\u6539\u53D8\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D";
            log["a" /* default */].setLog(task.msg);

          case 39:
            _context2.next = 46;
            break;

          case 41:
            _context2.prev = 41;
            _context2.t1 = _context2["catch"](1);
            task.status = 6;
            task.msg = "\u67E5\u8BE2\u62A5\u8868\u751F\u6210\u72B6\u6001\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context2.t1, task));
            log["a" /* default */].setLog(task.msg);

          case 46:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2, null, [[1, 41]]);
  }));

  return function awaitReportDownload(_x2) {
    return _ref2.apply(this, arguments);
  };
}(); // 生成下载报表链接


var getDownloadReportUrl = /*#__PURE__*/function () {
  var _ref3 = getPoDetail_asyncToGenerator( /*#__PURE__*/getPoDetail_regeneratorRuntime().mark(function _callee3(task) {
    var _yield$nativeRequest2, success, result, errorMsg;

    return getPoDetail_regeneratorRuntime().wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            _context3.prev = 0;
            _context3.next = 3;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/merchant/file/export/download"), 'post', {
              id: task.reportId,
              taskType: 36
            }, {
              Mallid: task.platform_store_id
            });

          case 3:
            _yield$nativeRequest2 = _context3.sent;
            success = _yield$nativeRequest2.success;
            result = _yield$nativeRequest2.result;
            errorMsg = _yield$nativeRequest2.errorMsg;

            if (!(success && result.fileUrl)) {
              _context3.next = 12;
              break;
            }

            task.fileUrl = result.fileUrl;
            return _context3.abrupt("return", {
              fileUrl: result.fileUrl
            });

          case 12:
            task.status = 9;
            task.msg = "\u83B7\u53D6\u4E0B\u8F7D\u62A5\u8868\u94FE\u63A5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(errorMsg);
            log["a" /* default */].setLog(task.msg);

          case 15:
            _context3.next = 22;
            break;

          case 17:
            _context3.prev = 17;
            _context3.t0 = _context3["catch"](0);
            task.status = 9;
            task.msg = "\u751F\u6210\u4E0B\u8F7D\u62A5\u8868\u94FE\u63A5\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context3.t0, task));
            log["a" /* default */].setLog(task.msg);

          case 22:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3, null, [[0, 17]]);
  }));

  return function getDownloadReportUrl(_x3) {
    return _ref3.apply(this, arguments);
  };
}(); // 下载报表


var getPoDetail_downloadReport = /*#__PURE__*/function () {
  var _ref4 = getPoDetail_asyncToGenerator( /*#__PURE__*/getPoDetail_regeneratorRuntime().mark(function _callee4(task) {
    var res, name, oFile, fileRes, zip;
    return getPoDetail_regeneratorRuntime().wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            _context4.prev = 0;
            _context4.next = 3;
            return axios_default()({
              method: 'GET',
              url: task.fileUrl,
              responseType: 'blob'
            });

          case 3:
            res = _context4.sent;

            if (!(res && res.data)) {
              _context4.next = 16;
              break;
            }

            name = Object(util["p" /* getNameByUrl */])(task.fileUrl);
            oFile = new File([res.data], name, {
              type: 'application/zip'
            });
            // 文件压缩
            log["a" /* default */].setLog('源文件大小', "".concat(oFile.size, "b"));
            zip = new jszip_min_default.a();
            zip.file(name, res.data, {
              binary: true
            });
            _context4.next = 12;
            return zip.generateAsync({
              type: "nodebuffer",
              compression: "DEFLATE",
              // STORE：默认不压缩 DEFLATE：需要压缩
              compressionOptions: {
                level: 9 // 压缩等级1~9    1压缩速度最快，9最优压缩方式

              }
            }).then(function (res) {
              var cFile = new File([res], "".concat(name.split('.')[0], ".zip"), {
                type: 'application/zip'
              });
              log["a" /* default */].setLog('压缩后文件大小', "".concat(cFile.size, "b"), cFile.name);
              fileRes = {
                file: cFile
              };
            }).catch(function (e) {
              log["a" /* default */].setLog('财务报表压缩失败', Object(util["r" /* isError */])(e));
              fileRes = {
                file: oFile
              };
            });

          case 12:
            log["a" /* default */].setLog('下载成功');
            task.status = 4;
            task.report_get_date = moment_default()().format('YYYY-MM-DD HH:mm:ss');
            return _context4.abrupt("return", fileRes);

          case 16:
            _context4.next = 23;
            break;

          case 18:
            _context4.prev = 18;
            _context4.t0 = _context4["catch"](0);
            task.status = 5;
            task.msg = "\u4E0B\u8F7D\u5931\u8D25\uFF0C\u7A0D\u540E\u53EF\u5C1D\u8BD5\u201C\u91CD\u65B0\u83B7\u53D6\u201D\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(Object(util["r" /* isError */])(_context4.t0, task));
            log["a" /* default */].setLog(task.msg);

          case 23:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4, null, [[0, 18]]);
  }));

  return function downloadReport(_x4) {
    return _ref4.apply(this, arguments);
  };
}();

var getPoDetail = /*#__PURE__*/function () {
  var _ref5 = getPoDetail_asyncToGenerator( /*#__PURE__*/getPoDetail_regeneratorRuntime().mark(function _callee5(task) {
    var loginRes, msg, param, res, uploadRes;
    return getPoDetail_regeneratorRuntime().wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            task.host = {
              201: temu["f" /* temu */].cbGlobalHost,
              202: temu["f" /* temu */].cbEuHost,
              203: temu["f" /* temu */].cbUsHost
            }[task.report_type];
            _context5.next = 3;
            return Object(temu["e" /* loginCb */])(task);

          case 3:
            loginRes = _context5.sent;

            if (loginRes) {
              _context5.next = 10;
              break;
            }

            msg = '切换到美区、欧区或全球站点失败，请检查';
            task.msg = msg;
            task.status = 11;
            log["a" /* default */].setLog(task.msg);
            return _context5.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 10:
            _context5.t0 = task.status !== 6;

            if (!_context5.t0) {
              _context5.next = 15;
              break;
            }

            _context5.next = 14;
            return getPoDetail_awaitReportDownload(task);

          case 14:
            _context5.t0 = !_context5.sent;

          case 15:
            if (!_context5.t0) {
              _context5.next = 20;
              break;
            }

            _context5.next = 18;
            return getPoDetail_generateReport(task);

          case 18:
            if (_context5.sent) {
              _context5.next = 20;
              break;
            }

            return _context5.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 20:
            _context5.t1 = task.status !== 2;

            if (!_context5.t1) {
              _context5.next = 25;
              break;
            }

            _context5.next = 24;
            return getPoDetail_awaitReportDownload(task);

          case 24:
            _context5.t1 = !_context5.sent;

          case 25:
            if (!_context5.t1) {
              _context5.next = 27;
              break;
            }

            return _context5.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 27:
            _context5.next = 29;
            return getDownloadReportUrl(task);

          case 29:
            if (_context5.sent) {
              _context5.next = 31;
              break;
            }

            return _context5.abrupt("return", {
              code: 1,
              msg: task.msg
            });

          case 31:
            // 默认参数
            param = {
              type_id: task.type_id,
              platform_store_id: task.platform_store_id,
              result: null,
              code: 0,
              msg: null
            };
            _context5.next = 34;
            return getPoDetail_downloadReport(task);

          case 34:
            res = _context5.sent;

            if (!(res && res.file)) {
              _context5.next = 45;
              break;
            }

            _context5.next = 38;
            return Object(util["G" /* uploadFile */])(res.file);

          case 38:
            uploadRes = _context5.sent;
            log["a" /* default */].setLog('文件上传结果：', JSON.stringify(uploadRes));

            if (!(uploadRes && uploadRes.code === 1)) {
              _context5.next = 42;
              break;
            }

            return _context5.abrupt("return", getPoDetail_objectSpread(getPoDetail_objectSpread({}, param), {}, {
              result: {
                report_file: uploadRes.data,
                cosKey: uploadRes.data.key,
                originFileName: uploadRes.data.originFileName,
                report_custom_date_start: task.report_custom_date_start,
                report_custom_date_end: task.report_custom_date_end,
                reportType: task.report_type,
                reportDate: task.report_date_month
              }
            }));

          case 42:
            // 上传失败
            task.status = 7;
            task.msg = '文件上传cos失败';
            param.result = {
              requestId: uploadRes.requestId,
              msg: uploadRes.msg
            };

          case 45:
            if (![8, 12].includes(task.status)) {
              _context5.next = 48;
              break;
            }

            task.isDelete = true;
            return _context5.abrupt("return", getPoDetail_objectSpread(getPoDetail_objectSpread({}, param), {}, {
              msg: task.msg,
              code: task.status === 8 ? 3 : 1
            }));

          case 48:
            return _context5.abrupt("return", getPoDetail_objectSpread(getPoDetail_objectSpread({}, param), {}, {
              code: 2,
              msg: task.msg
            }));

          case 49:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));

  return function getPoDetail(_x5) {
    return _ref5.apply(this, arguments);
  };
}();

/* harmony default export */ var qtReport_getPoDetail = (getPoDetail);
// CONCATENATED MODULE: ./src/platform/temu/qtReport/index.js
function qtReport_typeof(obj) { "@babel/helpers - typeof"; return qtReport_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, qtReport_typeof(obj); }

function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = qtReport_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }

function qtReport_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return qtReport_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return qtReport_arrayLikeToArray(o, minLen); }

function qtReport_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function qtReport_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ qtReport_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == qtReport_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function qtReport_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function qtReport_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? qtReport_ownKeys(Object(source), !0).forEach(function (key) { qtReport_defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : qtReport_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function qtReport_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function qtReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function qtReport_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { qtReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { qtReport_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

//     Temu_SETTLEMENT_REPORT(5, "Temu全托管结算报告"),
//     Temu_BILLDETAILS_REPORT(51, "Temu全托管账务明细"),
//     Temu_DEDUCTION_1(52, "Temu全托管支出详情1"),
//     Temu_DEDUCTION_2(53, "Temu全托管支出详情2"),
//     Temu_DEDUCTION_3(54, "Temu全托管支出详情3"),
//     Temu_DEDUCTION_4(55, "Temu全托管支出详情4"),
//     Temu_DEDUCTION_5(56, "Temu全托管支出详情5"),
//     Temu_DEDUCTION_6(57, "Temu全托管支出详情6"),
//     Temu_DEDUCTION_7(58, "Temu全托管支出详情7"),
//     Temu_ERPFEE_1(59, "Temu全托管ERP费用1"),
//     Temu_ERPFEE_2(510, "Temu全托管ERP费用2"),
//     Temu_ERPFEE_3(511, "Temu全托管ERP费用3"),
//     Temu_ERPFEE_4(512, "Temu全托管ERP费用4"),







var BillDetailsReportType = [5, // 全球
51, // 跨境中文中心
502, // 欧区
503 // 美区
];
var DeductionReportType = [52, // 消费者及履约保障-售后问题
53, // 备货违规 - 发货履约保障-延迟发货
54, // 备货违规 - 发货履约保障-延迟到货
55, // 备货违规 - 发货履约保障-缺货
56, // 备货违规 - 商品品质保障-质量问题(JIT商品)
57, // 备货违规 - 商品品质保障-质量问题(定制商品)
58, // 质量事故违规
521 // 仓储增值服务-贴标费
];
var EPRReportType = [59, // Temu全托管ERP费用1
510, // Temu全托管ERP费用2
511, // Temu全托管ERP费用3
512, // Temu全托管ERP费用4
513 // Temu全托管ERP费用5
];
var SemiBillDetailsReportType = [1, // 跨境中文中心
101, // 全球
102, // 欧区
103 // 美区
];
var StmlReportType = [1101, // 欧区
1102 // 美区
];
var ReverseReportType = [1201, // 欧区商家仓
1202, // 美区商家仓
1301, // 欧区Temu仓
1302 // 美区Temu仓
];
var PoDetailType = [201, // 全球
202, // 欧区
203 // 美区
]; // 获取财务任务公共方法

var commonGetReport = /*#__PURE__*/function () {
  var _ref = qtReport_asyncToGenerator( /*#__PURE__*/qtReport_regeneratorRuntime().mark(function _callee(task, type) {
    var handleFunc, res;
    return qtReport_regeneratorRuntime().wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            handleFunc = {
              billDetails: qtReport_getBillDetailsReport,
              deduction: qtReport_getDeductionReport,
              epr: qtReport_getEPRReport,
              semiBillDetails: qtReport_getTemuReport,
              stmlReport: qtReport_getStmlReport,
              reverseReport: qtReport_getReverseReport,
              poDetail: qtReport_getPoDetail
            }[type];
            _context.next = 3;
            return handleFunc(task);

          case 3:
            res = _context.sent;
            return _context.abrupt("return", qtReport_objectSpread({
              report_type: task.report_type,
              msg: res.msg,
              code: res.code
            }, res.result || {}));

          case 5:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));

  return function commonGetReport(_x, _x2) {
    return _ref.apply(this, arguments);
  };
}(); // 公共处理方法


var commonHandleReport = /*#__PURE__*/function () {
  var _ref2 = qtReport_asyncToGenerator( /*#__PURE__*/qtReport_regeneratorRuntime().mark(function _callee2(task, type) {
    var res, taskCache, typeList, _iterator, _step, _loop, _ret, index, errTask, errRes;

    return qtReport_regeneratorRuntime().wrap(function _callee2$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            res = task.resCache ? task.resCache : {
              code: 0,
              msg: '',
              result: []
            };
            taskCache = [];
            typeList = {
              billDetails: BillDetailsReportType,
              deduction: DeductionReportType,
              epr: EPRReportType,
              semiBillDetails: SemiBillDetailsReportType,
              stmlReport: StmlReportType,
              reverseReport: ReverseReportType,
              poDetail: PoDetailType
            }[type];
            _iterator = _createForOfIteratorHelper(typeList);
            _context3.prev = 4;
            _loop = /*#__PURE__*/qtReport_regeneratorRuntime().mark(function _loop() {
              var report_type, findIndex, newTask, _res;

              return qtReport_regeneratorRuntime().wrap(function _loop$(_context2) {
                while (1) {
                  switch (_context2.prev = _context2.next) {
                    case 0:
                      report_type = _step.value;
                      findIndex = res.result.findIndex(function (res) {
                        return res.report_type === report_type;
                      });

                      if (!(findIndex !== -1 && res.result[findIndex].code === 0)) {
                        _context2.next = 6;
                        break;
                      }

                      return _context2.abrupt("return", "continue");

                    case 6:
                      newTask = qtReport_objectSpread(qtReport_objectSpread({}, task), {}, {
                        report_type: report_type
                      });
                      taskCache.push(newTask);
                      _context2.next = 10;
                      return commonGetReport(newTask, type);

                    case 10:
                      _res = _context2.sent;

                      if (findIndex !== -1) {
                        res.result[findIndex] = _res;
                      } else {
                        res.result.push(_res);
                      }

                    case 12:
                    case "end":
                      return _context2.stop();
                  }
                }
              }, _loop);
            });

            _iterator.s();

          case 7:
            if ((_step = _iterator.n()).done) {
              _context3.next = 14;
              break;
            }

            return _context3.delegateYield(_loop(), "t0", 9);

          case 9:
            _ret = _context3.t0;

            if (!(_ret === "continue")) {
              _context3.next = 12;
              break;
            }

            return _context3.abrupt("continue", 12);

          case 12:
            _context3.next = 7;
            break;

          case 14:
            _context3.next = 19;
            break;

          case 16:
            _context3.prev = 16;
            _context3.t1 = _context3["catch"](4);

            _iterator.e(_context3.t1);

          case 19:
            _context3.prev = 19;

            _iterator.f();

            return _context3.finish(19);

          case 22:
            // 找出第一个获取失败的报表
            index = res.result.findIndex(function (_ref3) {
              var code = _ref3.code;
              return code !== 0;
            });

            if (index !== -1) {
              errTask = taskCache[index];
              errRes = res.result[index];
              res.msg = errRes.msg;
              res.code = errRes.code;
              task.status = errTask.status;
              task.msg = errRes.msg;
              task.error_time = errTask.error_time; // 缓存获取成功的报表

              task.resCache = res;
            } else {
              // 全部获取成功
              res.code = 0;
              res.msg = '';
            }

            return _context3.abrupt("return", res);

          case 25:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee2, null, [[4, 16, 19, 22]]);
  }));

  return function commonHandleReport(_x3, _x4) {
    return _ref2.apply(this, arguments);
  };
}();

var getQtReport = /*#__PURE__*/function () {
  var _ref4 = qtReport_asyncToGenerator( /*#__PURE__*/qtReport_regeneratorRuntime().mark(function _callee3(task) {
    return qtReport_regeneratorRuntime().wrap(function _callee3$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            _context4.t0 = +task.type_id;
            _context4.next = _context4.t0 === 22006 ? 3 : _context4.t0 === 22015 ? 4 : _context4.t0 === 22009 ? 5 : _context4.t0 === 22003 ? 6 : _context4.t0 === 22005 ? 7 : _context4.t0 === 22004 ? 8 : _context4.t0 === 22018 ? 9 : 10;
            break;

          case 3:
            return _context4.abrupt("return", commonHandleReport(task, 'billDetails'));

          case 4:
            return _context4.abrupt("return", commonHandleReport(task, 'deduction'));

          case 5:
            return _context4.abrupt("return", commonHandleReport(task, 'epr'));

          case 6:
            return _context4.abrupt("return", commonHandleReport(task, 'semiBillDetails'));

          case 7:
            return _context4.abrupt("return", commonHandleReport(task, 'stmlReport'));

          case 8:
            return _context4.abrupt("return", commonHandleReport(task, 'reverseReport'));

          case 9:
            return _context4.abrupt("return", commonHandleReport(task, 'poDetail'));

          case 10:
            return _context4.abrupt("break", 11);

          case 11:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee3);
  }));

  return function getQtReport(_x5) {
    return _ref4.apply(this, arguments);
  };
}();

/* harmony default export */ var qtReport = (getQtReport);
// CONCATENATED MODULE: ./src/platform/temu/getTodaySaleVolume.js
function getTodaySaleVolume_typeof(obj) { "@babel/helpers - typeof"; return getTodaySaleVolume_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, getTodaySaleVolume_typeof(obj); }

function getTodaySaleVolume_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ getTodaySaleVolume_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == getTodaySaleVolume_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function getTodaySaleVolume_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function getTodaySaleVolume_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { getTodaySaleVolume_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { getTodaySaleVolume_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }





 // 获取销量列表的页数

var getTodaySaleVolume_$count = 40;
/**
 * @description 获取今日销量列表
 * @param {*} task 任务对象
 * @param {number} pageNo 页码
 * @param {number} retry 重试次数
 * @returns {Promise<{
 *   code: number,
 *   msg?: string,
 *   result?: {
 *     total: number,
 *     list: Array<{
 *       todaySaleVolume: number,
 *       supplierPrice: number,
 *       skuExtCode: string,
 *       productSkuId: number,
 *       currencyType: string
 *     }>,
 *     getDate: string
 *   },
 *   data?: {
 *     pageNo: number
 *   }
 * }>}
 */

var requestTodaySaleVolume = /*#__PURE__*/function () {
  var _ref = getTodaySaleVolume_asyncToGenerator( /*#__PURE__*/getTodaySaleVolume_regeneratorRuntime().mark(function _callee(task) {
    var pageNo,
        retry,
        _yield$nativeRequest,
        success,
        errorMsg,
        result,
        total,
        subOrderList,
        list,
        msg,
        _msg,
        _args = arguments;

    return getTodaySaleVolume_regeneratorRuntime().wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            pageNo = _args.length > 1 && _args[1] !== undefined ? _args[1] : 1;
            retry = _args.length > 2 && _args[2] !== undefined ? _args[2] : 0;
            _context.prev = 2;
            _context.next = 5;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/mms/venom/api/supplier/sales/management/listWarehouse"), // host需要改为 cbGLOBALhost
            'post', {
              pageNo: pageNo,
              pageSize: getTodaySaleVolume_$count,
              isLack: 0,
              priceAdjustRecentDays: 7,
              todaySaleVolumMin: 1,
              // sevenDaysSaleVolumMin: 1,
              advancedSort: {
                firstOrderByDesc: 1,
                firstOrderByParam: 'todaySaleVolume',
                secondOrderByDesc: 1,
                secondOrderByParam: 'todaySaleVolume'
              }
            }, {
              Mallid: task.platform_store_id
            });

          case 5:
            _yield$nativeRequest = _context.sent;
            success = _yield$nativeRequest.success;
            errorMsg = _yield$nativeRequest.errorMsg;
            result = _yield$nativeRequest.result;

            if (!(success && result && result.subOrderList)) {
              _context.next = 18;
              break;
            }

            total = result.total, subOrderList = result.subOrderList;

            if (!(!subOrderList || !subOrderList.length)) {
              _context.next = 13;
              break;
            }

            return _context.abrupt("return", {
              code: 0,
              msg: '获取完毕'
            });

          case 13:
            list = []; // 数据收集

            subOrderList.forEach(function (_ref2) {
              var skuQuantityDetailList = _ref2.skuQuantityDetailList;

              if (skuQuantityDetailList.length) {
                skuQuantityDetailList.forEach(function (_ref3) {
                  var productSkuId = _ref3.productSkuId,
                      supplierPrice = _ref3.supplierPrice,
                      currencyType = _ref3.currencyType,
                      todaySaleVolume = _ref3.todaySaleVolume,
                      skuExtCode = _ref3.skuExtCode;
                  // if (todaySaleVolume > 0) {
                  list.push({
                    productSkuId: productSkuId,
                    supplierPrice: supplierPrice,
                    currencyType: currencyType,
                    todaySaleVolume: todaySaleVolume,
                    skuExtCode: skuExtCode
                  }); // }
                });
              }
            });
            return _context.abrupt("return", {
              code: 0,
              total: total,
              list: list
            });

          case 18:
            msg = "\u83B7\u53D6\u4ECA\u65E5\u9500\u91CF\u5217\u8868\u5931\u8D25\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(JSON.stringify(errorMsg));
            log["a" /* default */].report(msg, 'error', task.task_id);
            return _context.abrupt("return", {
              msg: msg,
              code: 1
            });

          case 21:
            _context.next = 33;
            break;

          case 23:
            _context.prev = 23;
            _context.t0 = _context["catch"](2);
            _msg = "\u83B7\u53D6\u4ECA\u65E5\u9500\u91CF\u5217\u8868\u5931\u8D25-----".concat(Object(util["r" /* isError */])(_context.t0, task));
            log["a" /* default */].setLog(_msg); // 重试三次

            if (!(retry < 3)) {
              _context.next = 32;
              break;
            }

            log["a" /* default */].setLog('正在重试........................');
            _context.next = 31;
            return Object(util["g" /* delayed */])(3 * 1000);

          case 31:
            return _context.abrupt("return", requestTodaySaleVolume(task, pageNo, ++retry));

          case 32:
            return _context.abrupt("return", {
              msg: _msg,
              code: 2
            });

          case 33:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, null, [[2, 23]]);
  }));

  return function requestTodaySaleVolume(_x) {
    return _ref.apply(this, arguments);
  };
}();
/**
 * @description 获取所有今日销量数据
 * @param {*} task 任务对象
 * @param {number} pageNo 页码
 * @returns {Promise<{
 *   code: number,
 *   msg?: string,
 *   result?: {
 *     total: number,
 *     list: Array<{
 *       todaySaleVolume: number,
 *       supplierPrice: number,
 *       skuExtCode: string,
 *       productSkuId: number,
 *       currencyType: string
 *     }>,
 *     getDate: string
 *   }
 * }>}
 */


var getAllTodaySaleVolume = /*#__PURE__*/function () {
  var _ref4 = getTodaySaleVolume_asyncToGenerator( /*#__PURE__*/getTodaySaleVolume_regeneratorRuntime().mark(function _callee2(task) {
    var pageNo,
        _yield$requestTodaySa,
        code,
        msg,
        list,
        total,
        res,
        getDate,
        _args2 = arguments;

    return getTodaySaleVolume_regeneratorRuntime().wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            pageNo = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 1;
            _context2.next = 3;
            return requestTodaySaleVolume(task, pageNo);

          case 3:
            _yield$requestTodaySa = _context2.sent;
            code = _yield$requestTodaySa.code;
            msg = _yield$requestTodaySa.msg;
            list = _yield$requestTodaySa.list;
            total = _yield$requestTodaySa.total;

            if (!(code !== 0)) {
              _context2.next = 10;
              break;
            }

            return _context2.abrupt("return", {
              code: 4,
              // 重复任务上报4保证下次还能下发
              msg: msg
            });

          case 10:
            // 商品页总页数
            task.total = total; // 已获取页数

            task.curPage = pageNo * getTodaySaleVolume_$count; // 已获取销量的sku数

            task.currentNum = (task.currentNum || 0) + ((list === null || list === void 0 ? void 0 : list.length) || 0); // 获取当前北京时间

            _context2.next = 15;
            return Object(util["k" /* gateGet */])('api/v1/baseInfos', {}, 'task').catch(function () {});

          case 15:
            res = _context2.sent;
            getDate = res && res.data && res.data.time_format; // 判断是否获取完毕

            if (!(task.curPage < total)) {
              _context2.next = 23;
              break;
            }

            _context2.next = 20;
            return newTask["a" /* default */].uploadTask({
              code: 4,
              result: {
                currentNum: task.currentNum,
                curPage: task.curPage,
                total: total,
                list: list,
                getDate: getDate
              }
            }, task);

          case 20:
            _context2.next = 22;
            return Object(util["g" /* delayed */])(3 * 1000);

          case 22:
            return _context2.abrupt("return", getAllTodaySaleVolume(task, ++pageNo));

          case 23:
            return _context2.abrupt("return", {
              code: 0,
              msg: msg,
              result: (list === null || list === void 0 ? void 0 : list.length) > 0 ? {
                list: list,
                getDate: getDate,
                currentNum: task.currentNum,
                curPage: task.curPage,
                total: total
              } : {
                list: [],
                getDate: getDate,
                currentNum: task.currentNum,
                curPage: task.curPage,
                total: total
              }
            });

          case 24:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));

  return function getAllTodaySaleVolume(_x2) {
    return _ref4.apply(this, arguments);
  };
}();
/**
 * @description 获取今日销量入口函数
 * @param {*} task 任务对象
 * @returns {Promise<{
 *   code: number,
 *   msg?: string,
 *   result?: {
 *     total: number,
 *     list: Array<{
 *       todaySaleVolume: number,
 *       supplierPrice: number,
 *       skuExtCode: string,
 *       productSkuId: number,
 *       currencyType: string
 *     }>,
 *     getDate: string
 *   }
 * }>}
 */


var getTodaySaleVolume = /*#__PURE__*/function () {
  var _ref5 = getTodaySaleVolume_asyncToGenerator( /*#__PURE__*/getTodaySaleVolume_regeneratorRuntime().mark(function _callee3(task) {
    var loginRes, msg, res;
    return getTodaySaleVolume_regeneratorRuntime().wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            if (!(task.resCache && task.resCache.code === 0)) {
              _context3.next = 2;
              break;
            }

            return _context3.abrupt("return", task.resCache);

          case 2:
            _context3.next = 4;
            return Object(temu["e" /* loginCb */])(task);

          case 4:
            loginRes = _context3.sent;

            if (loginRes) {
              _context3.next = 10;
              break;
            }

            msg = '切换到美区或欧区站点失败，请检查';
            task.msg = msg;
            log["a" /* default */].setLog(msg);
            return _context3.abrupt("return", {
              code: 1,
              msg: msg
            });

          case 10:
            _context3.next = 12;
            return getAllTodaySaleVolume(task);

          case 12:
            res = _context3.sent;
            task.status = [1, 2].indexOf(res.code) > -1 ? 14 : 15;
            task.msg = res.msg;
            return _context3.abrupt("return", res);

          case 16:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));

  return function getTodaySaleVolume(_x3) {
    return _ref5.apply(this, arguments);
  };
}();

/* harmony default export */ var temu_getTodaySaleVolume = (getTodaySaleVolume);
// CONCATENATED MODULE: ./src/platform/temu/getActivityPrice.js
function getActivityPrice_typeof(obj) { "@babel/helpers - typeof"; return getActivityPrice_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, getActivityPrice_typeof(obj); }

function getActivityPrice_toConsumableArray(arr) { return getActivityPrice_arrayWithoutHoles(arr) || getActivityPrice_iterableToArray(arr) || getActivityPrice_unsupportedIterableToArray(arr) || getActivityPrice_nonIterableSpread(); }

function getActivityPrice_nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function getActivityPrice_iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }

function getActivityPrice_arrayWithoutHoles(arr) { if (Array.isArray(arr)) return getActivityPrice_arrayLikeToArray(arr); }

function getActivityPrice_createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = getActivityPrice_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }

function getActivityPrice_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return getActivityPrice_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return getActivityPrice_arrayLikeToArray(o, minLen); }

function getActivityPrice_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function getActivityPrice_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ getActivityPrice_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == getActivityPrice_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function getActivityPrice_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function getActivityPrice_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { getActivityPrice_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { getActivityPrice_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }



 // 获取活动列表的页数

var getActivityPrice_$count = 50;
/**
 * @description 获取报名记录列表-获取活动价
 * @param {*} task 任务对象
 * @param {number[]} ids skuId列表
 * @param {number} pageNo 页码
 * @param {number} retry 重试次数
 * @param {number} frequencyRetry 频率限制重试次数
 * @returns {Promise<{}>}
 */

var requestActivityPrice = /*#__PURE__*/function () {
  var _ref = getActivityPrice_asyncToGenerator( /*#__PURE__*/getActivityPrice_regeneratorRuntime().mark(function _callee(task, ids) {
    var pageNo,
        retry,
        frequencyRetry,
        _yield$nativeRequest,
        success,
        errorMsg,
        result,
        errorCode,
        total,
        list,
        _formatActivityData,
        res,
        isIn30Days,
        delaySeconds,
        msg,
        _msg,
        _msg2,
        _args = arguments;

    return getActivityPrice_regeneratorRuntime().wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            pageNo = _args.length > 2 && _args[2] !== undefined ? _args[2] : 1;
            retry = _args.length > 3 && _args[3] !== undefined ? _args[3] : 0;
            frequencyRetry = _args.length > 4 && _args[4] !== undefined ? _args[4] : 0;
            _context.prev = 3;
            _context.next = 6;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/kiana/gamblers/marketing/enroll/list"), 'post', {
              pageNo: pageNo,
              pageSize: getActivityPrice_$count,
              productSkuIds: ids || []
            }, {
              Mallid: task.platform_store_id
            });

          case 6:
            _yield$nativeRequest = _context.sent;
            success = _yield$nativeRequest.success;
            errorMsg = _yield$nativeRequest.errorMsg;
            result = _yield$nativeRequest.result;
            errorCode = _yield$nativeRequest.errorCode;

            if (!(success && result)) {
              _context.next = 19;
              break;
            }

            total = result.total, list = result.list;

            if (!(!list || !list.length)) {
              _context.next = 15;
              break;
            }

            return _context.abrupt("return", {
              code: 0,
              msg: '获取完毕'
            });

          case 15:
            _formatActivityData = getActivityPrice_formatActivityData(list, task), res = _formatActivityData.res, isIn30Days = _formatActivityData.isIn30Days;
            return _context.abrupt("return", {
              code: 0,
              total: total,
              list: res,
              isIn30Days: isIn30Days // 最后一项的报名时间是否在近30天内

            });

          case 19:
            if (!(errorCode === 2000000 && errorMsg.includes('Operation too frequent'))) {
              _context.next = 33;
              break;
            }

            if (!(frequencyRetry < 3)) {
              _context.next = 28;
              break;
            }

            delaySeconds = (frequencyRetry + 1) * 3; // 3秒、6秒、9秒

            log["a" /* default */].setLog("\u83B7\u53D6\u6D3B\u52A8\u4EF7---\u9891\u7387\u9650\u5236\u91CD\u8BD5\u7B2C".concat(frequencyRetry + 1, "\u6B21\uFF0C").concat(delaySeconds, "\u79D2\u540E\u91CD\u8BD5..."));
            _context.next = 25;
            return Object(util["g" /* delayed */])(delaySeconds * 1000);

          case 25:
            return _context.abrupt("return", requestActivityPrice(task, ids, pageNo, retry, ++frequencyRetry));

          case 28:
            // 频率限制重试次数用完，返回失败
            msg = "\u83B7\u53D6\u62A5\u540D\u8BB0\u5F55\u5217\u8868\u5931\u8D25-----\u7FFB\u9875\u8FC7\u4E8E\u9891\u7E41\uFF0C\u5DF2\u91CD\u8BD53\u6B21\u4ECD\u5931\u8D25";
            log["a" /* default */].setLog(msg);
            return _context.abrupt("return", {
              msg: msg,
              code: 1
            });

          case 31:
            _context.next = 36;
            break;

          case 33:
            _msg = "\u83B7\u53D6\u62A5\u540D\u8BB0\u5F55\u5217\u8868\u5931\u8D25\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(JSON.stringify(errorMsg));
            log["a" /* default */].report(_msg, 'error', task.task_id);
            return _context.abrupt("return", {
              msg: _msg,
              code: 1
            });

          case 36:
            _context.next = 48;
            break;

          case 38:
            _context.prev = 38;
            _context.t0 = _context["catch"](3);
            _msg2 = "\u83B7\u53D6\u62A5\u540D\u8BB0\u5F55\u5217\u8868\u5931\u8D25-----".concat(Object(util["r" /* isError */])(_context.t0, task));
            log["a" /* default */].setLog(_msg2); // 重试三次

            if (!(retry < 3)) {
              _context.next = 47;
              break;
            }

            log["a" /* default */].setLog('获取活动价---正在重试........................');
            _context.next = 46;
            return Object(util["g" /* delayed */])(3 * 1000);

          case 46:
            return _context.abrupt("return", requestActivityPrice(task, ids, pageNo, ++retry, frequencyRetry));

          case 47:
            return _context.abrupt("return", {
              msg: _msg2,
              code: 2
            });

          case 48:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, null, [[3, 38]]);
  }));

  return function requestActivityPrice(_x, _x2) {
    return _ref.apply(this, arguments);
  };
}(); // 抽取上报数据结构


var getActivityPrice_formatActivityData = function formatActivityData(data, task) {
  var skuIds = task.skuIds || [];

  if (!Array.isArray(data)) {
    return {
      res: [],
      isIn30Days: false
    };
  }

  var isHalf = String(task.platform_code) !== '10022'; // 是否半托店铺（10022为全托，其他为半托）

  var now = Date.now();
  var THIRTY_DAYS = 30 * 24 * 60 * 60 * 1000;
  var res = [];
  var isIn30Days = true; // 映射报名结果 session 对象

  var mapSession = function mapSession(session) {
    if (!session) return null;
    return {
      sessionName: session.sessionName,
      sessionStatus: session.sessionStatus,
      sessionId: session.sessionId,
      siteName: session.siteName,
      siteId: session.siteId,
      startTime: session.startTime,
      endTime: session.endTime,
      startDateStr: session.startDateStr,
      endDateStr: session.endDateStr
    };
  };

  var _iterator = getActivityPrice_createForOfIteratorHelper(data),
      _step;

  try {
    for (_iterator.s(); !(_step = _iterator.n()).done;) {
      var _item$activityThemati, _item$activityTypeNam, _item$activityThemati2;

      var item = _step.value;

      // 判断是否在近30天内
      if (!item.enrollTime || now - item.enrollTime > THIRTY_DAYS) {
        // 由于数据是按时间倒序排列，后面的都更旧，直接停止循环
        log["a" /* default */].setLog("\u83B7\u53D6\u6D3B\u52A8\u4EF7---\u9047\u5230\u8D85\u8FC730\u5929\u7684\u6D3B\u52A8\u6570\u636E\uFF0C\u505C\u6B62\u83B7\u53D6\u540E\u7EED\u6570\u636E");
        isIn30Days = false;
        break;
      } // 处理 assignSessionList：半托店铺 map 所有项，全托店铺只取第一项


      var assignSessionList = item.assignSessionList || [];
      var processedAssignSessionList = void 0;

      if (isHalf) {
        // 半托店铺：map 所有项
        processedAssignSessionList = assignSessionList.map(mapSession).filter(function (session) {
          return session !== null;
        });
      } else {
        // 全托店铺：只取第一项
        var firstSession = assignSessionList[0] ? mapSession(assignSessionList[0]) : null;
        processedAssignSessionList = firstSession ? [firstSession] : [];
      }

      res.push({
        productId: item.productId,
        activityThematicName: (_item$activityThemati = item.activityThematicName) !== null && _item$activityThemati !== void 0 ? _item$activityThemati : '',
        activityTypeName: (_item$activityTypeNam = item.activityTypeName) !== null && _item$activityTypeNam !== void 0 ? _item$activityTypeNam : '',
        activityThematicId: (_item$activityThemati2 = item.activityThematicId) !== null && _item$activityThemati2 !== void 0 ? _item$activityThemati2 : null,
        enrollId: item.enrollId,
        assignSessionList: processedAssignSessionList,
        skcList: (item.skcList || []).map(function (skc) {
          return {
            skcId: skc.skcId,
            skuList: (skc.skuList || []).filter(function (sku) {
              return skuIds.map(String).includes(String(sku.skuId));
            }).map(function (sku) {
              var _sku$sitePriceList, _sku$sitePriceList$, _sku$sitePriceList2, _sku$sitePriceList2$, _sku$sitePriceList3, _sku$sitePriceList3$, _sku$activityDiscount, _sku$sitePriceList4, _sku$sitePriceList4$, _sku$sitePriceList5, _sku$sitePriceList5$;

              return {
                skuId: sku.skuId,
                currency: sku.currency,
                dailyPrice: isHalf ? (_sku$sitePriceList = sku.sitePriceList) === null || _sku$sitePriceList === void 0 ? void 0 : (_sku$sitePriceList$ = _sku$sitePriceList[0]) === null || _sku$sitePriceList$ === void 0 ? void 0 : _sku$sitePriceList$.dailyPrice : sku.dailyPrice,
                activityPrice: isHalf ? (_sku$sitePriceList2 = sku.sitePriceList) === null || _sku$sitePriceList2 === void 0 ? void 0 : (_sku$sitePriceList2$ = _sku$sitePriceList2[0]) === null || _sku$sitePriceList2$ === void 0 ? void 0 : _sku$sitePriceList2$.activityPrice : sku.activityPrice,
                activityDiscount: isHalf ? (_sku$sitePriceList3 = sku.sitePriceList) === null || _sku$sitePriceList3 === void 0 ? void 0 : (_sku$sitePriceList3$ = _sku$sitePriceList3[0]) === null || _sku$sitePriceList3$ === void 0 ? void 0 : _sku$sitePriceList3$.activityDiscount : (_sku$activityDiscount = sku.activityDiscount) !== null && _sku$activityDiscount !== void 0 ? _sku$activityDiscount : null,
                siteId: isHalf ? (_sku$sitePriceList4 = sku.sitePriceList) === null || _sku$sitePriceList4 === void 0 ? void 0 : (_sku$sitePriceList4$ = _sku$sitePriceList4[0]) === null || _sku$sitePriceList4$ === void 0 ? void 0 : _sku$sitePriceList4$.siteId : null,
                siteName: isHalf ? (_sku$sitePriceList5 = sku.sitePriceList) === null || _sku$sitePriceList5 === void 0 ? void 0 : (_sku$sitePriceList5$ = _sku$sitePriceList5[0]) === null || _sku$sitePriceList5$ === void 0 ? void 0 : _sku$sitePriceList5$.siteName : null
              };
            })
          };
        })
      });
    }
  } catch (err) {
    _iterator.e(err);
  } finally {
    _iterator.f();
  }

  return {
    res: res,
    isIn30Days: isIn30Days
  };
};
/**
 * @description 获取所有活动价数据
 * @param {*} task 任务对象
 * @param {number} pageNo 页码
 * @returns {Promise<{
 *   code: number,
 *   msg?: string,
 *   result?: {
 *     total: number,
 *     currentNum: number,
 *     curPage: number,
 *     list: Array<{
 *       activityThematicId: number,
 *       activityThematicName: string | null,
 *       activityTypeName: string,
 *       enrollStatus: number,
 *       enrollSessionIdList: Array<string>,
 *       sessionStatus: number,
 *       skuId: number,
 *       activityDiscount: number,
 *       activityPrice: number,
 *       currency: string,
 *     }>,
 *     getDate: string
 *   }
 * }>}
 */


var getAllActivityPrice = /*#__PURE__*/function () {
  var _ref2 = getActivityPrice_asyncToGenerator( /*#__PURE__*/getActivityPrice_regeneratorRuntime().mark(function _callee2(task) {
    var skuIds, succList, message, count, batchSkuIds, i, ids, _yield$getOneBatchAct, code, msg, result, timeRes, getDate;

    return getActivityPrice_regeneratorRuntime().wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            skuIds = task.skuIds || []; // const failSkuIds = []

            succList = [];
            message = '';
            count = Math.ceil(skuIds.length / 50); // temu一次最多只能查50个skuid

            batchSkuIds = Array(count).fill(1).map(function (i, key) {
              return skuIds.slice(key * 50, (key + 1) * 50);
            });
            i = 0;

          case 6:
            if (!(i < batchSkuIds.length)) {
              _context2.next = 20;
              break;
            }

            ids = batchSkuIds[i]; // 等待5s

            _context2.next = 10;
            return Object(util["g" /* delayed */])(5 * 1000);

          case 10:
            _context2.next = 12;
            return getOneBatchActivityPrice(task, ids);

          case 12:
            _yield$getOneBatchAct = _context2.sent;
            code = _yield$getOneBatchAct.code;
            msg = _yield$getOneBatchAct.msg;
            result = _yield$getOneBatchAct.result;

            if (code === 0) {
              succList.push.apply(succList, getActivityPrice_toConsumableArray(result.list || []));
            } else {
              // failSkuIds.push(...ids)
              log["a" /* default */].setLog("\u83B7\u53D6\u7B2C".concat(i + 1, "\u6279\u6D3B\u52A8\u4EF7---\u83B7\u53D6\u5931\u8D25:").concat(msg));
            }

          case 17:
            i++;
            _context2.next = 6;
            break;

          case 20:
            message = succList.length > 0 ? '获取完毕' : "\u83B7\u53D6\u6240\u6709\u6D3B\u52A8\u4EF7---\u672A\u83B7\u53D6\u5230\u4EFB\u4F55\u6570\u636E,\u9700\u8981\u83B7\u53D6\u7684skuId:".concat(skuIds.join(','));
            log["a" /* default */].setLog(message);
            _context2.next = 24;
            return Object(util["k" /* gateGet */])('api/v1/baseInfos', {}, 'task').catch(function () {});

          case 24:
            timeRes = _context2.sent;
            getDate = timeRes && timeRes.data && timeRes.data.time_format;
            return _context2.abrupt("return", {
              code: 0,
              msg: message,
              result: {
                list: succList,
                total: succList.length || 0,
                // 用于保持结构，服务端不读取
                currentNum: succList.length || 0,
                // 用于保持结构，服务端不读取
                curPage: 1,
                // 用于保持结构，服务端不读取
                getDate: getDate || ''
              }
            });

          case 27:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));

  return function getAllActivityPrice(_x3) {
    return _ref2.apply(this, arguments);
  };
}();

var getOneBatchActivityPrice = /*#__PURE__*/function () {
  var _ref3 = getActivityPrice_asyncToGenerator( /*#__PURE__*/getActivityPrice_regeneratorRuntime().mark(function _callee3(task, ids) {
    var allResults, currentPage, total, isIn30Days, _yield$requestActivit, code, msg, list, pageTotal, pageIsIn30Days, curPage;

    return getActivityPrice_regeneratorRuntime().wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            allResults = [];
            currentPage = 1;
            total = 0;
            isIn30Days = true;

          case 4:
            if (!isIn30Days) {
              _context3.next = 27;
              break;
            }

            _context3.next = 7;
            return requestActivityPrice(task, ids, currentPage);

          case 7:
            _yield$requestActivit = _context3.sent;
            code = _yield$requestActivit.code;
            msg = _yield$requestActivit.msg;
            list = _yield$requestActivit.list;
            pageTotal = _yield$requestActivit.total;
            pageIsIn30Days = _yield$requestActivit.isIn30Days;
            task.msg = msg;

            if (!(code !== 0)) {
              _context3.next = 16;
              break;
            }

            return _context3.abrupt("return", {
              code: code,
              msg: msg
            });

          case 16:
            // 更新总页数和30天标志
            total = pageTotal || 0;
            isIn30Days = pageIsIn30Days;

            if (list && list.length > 0) {
              allResults.push.apply(allResults, getActivityPrice_toConsumableArray(list));
            } // 判断是否还有下一页


            curPage = currentPage * getActivityPrice_$count;

            if (!(!isIn30Days || curPage >= total)) {
              _context3.next = 22;
              break;
            }

            return _context3.abrupt("break", 27);

          case 22:
            _context3.next = 24;
            return Object(util["g" /* delayed */])(3 * 1000);

          case 24:
            currentPage++;
            _context3.next = 4;
            break;

          case 27:
            // 更新任务状态
            task.total = total;
            task.curPage = currentPage * getActivityPrice_$count;
            task.currentNum = allResults.length || 0;
            return _context3.abrupt("return", {
              code: 0,
              msg: task.msg,
              result: {
                list: allResults
              }
            });

          case 31:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));

  return function getOneBatchActivityPrice(_x4, _x5) {
    return _ref3.apply(this, arguments);
  };
}();
/**
 * @description 获取活动价入口函数
 * @param {*} task 任务对象
 * @returns {Promise<{
 *   code: number,
 *   msg?: string,
 *   result?: {
 *     total: number,
 *     currentNum: number,
 *     curPage: number,
 *     list: Array<{
 *       activityThematicId: number,
 *       activityThematicName: string | null,
 *       activityTypeName: string,
 *       sessionName: string | null,
 *       sessionStatus: number,
 *       skuId: number,
 *       activityDiscount: unknown,
 *       activityPrice: number,
 *       currency: string,
 *     }>,
 *     getDate: string
 *   }
 * }>}
 */


var getActivityPrice = /*#__PURE__*/function () {
  var _ref4 = getActivityPrice_asyncToGenerator( /*#__PURE__*/getActivityPrice_regeneratorRuntime().mark(function _callee4(task) {
    var loginRes, msg, res;
    return getActivityPrice_regeneratorRuntime().wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            if (!(task.resCache && task.resCache.code === 0)) {
              _context4.next = 2;
              break;
            }

            return _context4.abrupt("return", task.resCache);

          case 2:
            _context4.next = 4;
            return Object(temu["e" /* loginCb */])(task);

          case 4:
            loginRes = _context4.sent;

            if (loginRes) {
              _context4.next = 10;
              break;
            }

            msg = '获取活动价---切换到美区或欧区站点失败，请检查';
            task.msg = msg;
            log["a" /* default */].setLog(msg);
            return _context4.abrupt("return", {
              code: 1,
              msg: msg
            });

          case 10:
            _context4.next = 12;
            return getAllActivityPrice(task);

          case 12:
            res = _context4.sent;
            task.status = [1, 2].indexOf(res.code) > -1 ? 14 : 15;
            task.errorMsg = res.msg;
            return _context4.abrupt("return", res);

          case 16:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4);
  }));

  return function getActivityPrice(_x6) {
    return _ref4.apply(this, arguments);
  };
}();

/* harmony default export */ var temu_getActivityPrice = (getActivityPrice);
// CONCATENATED MODULE: ./src/platform/temu/getGoodsTraffic.js
function getGoodsTraffic_typeof(obj) { "@babel/helpers - typeof"; return getGoodsTraffic_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, getGoodsTraffic_typeof(obj); }

function getGoodsTraffic_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ getGoodsTraffic_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == getGoodsTraffic_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function getGoodsTraffic_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function getGoodsTraffic_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { getGoodsTraffic_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { getGoodsTraffic_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }





var getGoodsTraffic_$count = 20; // 50、80、100, 通常在第24个左右的请求就会被temu接口限流, 所以这里设置为20
// 主体逻辑

var getGoodsTrafficList = /*#__PURE__*/function () {
  var _ref = getGoodsTraffic_asyncToGenerator( /*#__PURE__*/getGoodsTraffic_regeneratorRuntime().mark(function _callee3(task) {
    var _yield$requestGoodsTr, code, msg, pageNo, info, total, goodsTrafficList, failedSpuIds, i, currentItem, result, _msg, retryCount, currentFailedItems, _i, failedItem, retryItem, _result, _msg2;

    return getGoodsTraffic_regeneratorRuntime().wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            _context3.next = 2;
            return requestGoodsTrafficList(task, task.pageNo || 1);

          case 2:
            _yield$requestGoodsTr = _context3.sent;
            code = _yield$requestGoodsTr.code;
            msg = _yield$requestGoodsTr.msg;
            pageNo = _yield$requestGoodsTr.pageNo;
            info = _yield$requestGoodsTr.info;
            total = _yield$requestGoodsTr.total;
            // 记录当前页数
            task.pageNo = pageNo; // 获取失败，上报状态

            if (!(code !== 0)) {
              _context3.next = 11;
              break;
            }

            return _context3.abrupt("return", {
              code: 2,
              msg: msg,
              data: {
                pageNo: pageNo
              }
            });

          case 11:
            goodsTrafficList = [];
            failedSpuIds = []; // 记录失败的spu项，用于失败重试

            i = 0;

          case 14:
            if (!(i < info.length)) {
              _context3.next = 33;
              break;
            }

            if (!(i > 0)) {
              _context3.next = 17;
              break;
            }

            return _context3.delegateYield( /*#__PURE__*/getGoodsTraffic_regeneratorRuntime().mark(function _callee() {
              var delay;
              return getGoodsTraffic_regeneratorRuntime().wrap(function _callee$(_context) {
                while (1) {
                  switch (_context.prev = _context.next) {
                    case 0:
                      delay = Math.floor(Math.random() * 1000) + 500; // 500-1500ms

                      _context.next = 3;
                      return new Promise(function (resolve) {
                        return setTimeout(resolve, delay);
                      });

                    case 3:
                    case "end":
                      return _context.stop();
                  }
                }
              }, _callee);
            })(), "t0", 17);

          case 17:
            // 获取当前项
            currentItem = info[i];
            _context3.prev = 18;
            _context3.next = 21;
            return requestGoodsDetail(task, currentItem);

          case 21:
            result = _context3.sent;

            if (result.code !== 0) {
              // 记录失败的spuid，保存完整信息用于重试
              if (currentItem && currentItem.productId) {
                failedSpuIds.push({
                  spuId: currentItem.productId,
                  productName: currentItem.productName,
                  siteId: currentItem.siteId,
                  siteName: currentItem.siteName,
                  category: currentItem.category || null,
                  errorMsg: result.msg,
                  retryCount: 0
                });
              }

              log["a" /* default */].setLog("\u7B2C ".concat(i + 1, " \u4E2A\u8BF7\u6C42\u5931\u8D25: ").concat(result.msg, ", spuId: ").concat((currentItem === null || currentItem === void 0 ? void 0 : currentItem.productId) || 'unknown'));
            } else {
              // 收集成功的结果
              goodsTrafficList.push({
                productId: currentItem.productId,
                productName: currentItem.productName,
                siteId: currentItem.siteId,
                siteName: currentItem.siteName,
                category: currentItem.category || null,
                details: result.result || []
              });
              log["a" /* default */].setLog("\u7B2C ".concat(i + 1, " \u4E2A\u8BF7\u6C42\u6210\u529F: spuId: ").concat((currentItem === null || currentItem === void 0 ? void 0 : currentItem.productId) || 'unknown'));
            }

            _context3.next = 30;
            break;

          case 25:
            _context3.prev = 25;
            _context3.t1 = _context3["catch"](18);
            _msg = "\u83B7\u53D6\u5546\u54C1\u8BE6\u60C5\u5931\u8D25---\u7B2C ".concat(i + 1, " \u4E2A\u8BF7\u6C42\u53D1\u751F\u5F02\u5E38: ").concat(Object(util["r" /* isError */])(_context3.t1, task));
            log["a" /* default */].setLog(_msg);
            return _context3.abrupt("return", {
              code: 2,
              msg: _msg
            });

          case 30:
            i++;
            _context3.next = 14;
            break;

          case 33:
            if (!(failedSpuIds.length > 0)) {
              _context3.next = 71;
              break;
            }

            log["a" /* default */].setLog("\u5F00\u59CB\u91CD\u8BD5\u5931\u8D25\u9879\uFF0C\u5171 ".concat(failedSpuIds.length, " \u4E2A\u5931\u8D25\u9879"));
            retryCount = 1;

          case 36:
            if (!(retryCount <= 3)) {
              _context3.next = 70;
              break;
            }

            if (!(failedSpuIds.length === 0)) {
              _context3.next = 39;
              break;
            }

            return _context3.abrupt("break", 70);

          case 39:
            // 没有失败项了，退出重试
            log["a" /* default */].setLog("\u7B2C ".concat(retryCount, " \u6B21\u91CD\u8BD5\uFF0C\u5269\u4F59 ").concat(failedSpuIds.length, " \u4E2A\u5931\u8D25\u9879"));
            currentFailedItems = [].concat(failedSpuIds); // 复制当前失败项列表

            failedSpuIds.length = 0; // 清空失败项列表，准备重新收集

            _i = 0;

          case 43:
            if (!(_i < currentFailedItems.length)) {
              _context3.next = 63;
              break;
            }

            failedItem = currentFailedItems[_i]; // 每次重试前随机间隔0.5-1.5秒

            if (!(_i > 0)) {
              _context3.next = 47;
              break;
            }

            return _context3.delegateYield( /*#__PURE__*/getGoodsTraffic_regeneratorRuntime().mark(function _callee2() {
              var delay;
              return getGoodsTraffic_regeneratorRuntime().wrap(function _callee2$(_context2) {
                while (1) {
                  switch (_context2.prev = _context2.next) {
                    case 0:
                      delay = Math.floor(Math.random() * 1000) + 500; // 500-1500ms

                      _context2.next = 3;
                      return new Promise(function (resolve) {
                        return setTimeout(resolve, delay);
                      });

                    case 3:
                    case "end":
                      return _context2.stop();
                  }
                }
              }, _callee2);
            })(), "t2", 47);

          case 47:
            _context3.prev = 47;
            retryItem = {
              productId: failedItem.spuId,
              siteId: failedItem.siteId || null
            };
            _context3.next = 51;
            return requestGoodsDetail(task, retryItem);

          case 51:
            _result = _context3.sent;

            if (_result.code !== 0) {
              // 重试仍然失败，重新加入失败列表
              failedSpuIds.push({
                spuId: failedItem.spuId,
                productName: failedItem.productName,
                siteId: failedItem.siteId,
                siteName: failedItem.siteName,
                category: failedItem.category,
                errorMsg: _result.msg,
                retryCount: retryCount
              });
              log["a" /* default */].setLog("\u91CD\u8BD5\u7B2C ".concat(retryCount, " \u6B21\u5931\u8D25: ").concat(_result.msg, ", spuId: ").concat(failedItem.spuId));
            } else {
              // 重试成功，添加到成功列表
              goodsTrafficList.push({
                productId: failedItem.spuId,
                productName: failedItem.productName || '未知商品',
                siteId: failedItem.siteId,
                siteName: failedItem.siteName || '未知站点',
                category: failedItem.category || null,
                details: _result.result || []
              });
              log["a" /* default */].setLog("\u91CD\u8BD5\u7B2C ".concat(retryCount, " \u6B21\u6210\u529F: spuId: ").concat(failedItem.spuId));
            }

            _context3.next = 60;
            break;

          case 55:
            _context3.prev = 55;
            _context3.t3 = _context3["catch"](47);
            _msg2 = "\u91CD\u8BD5\u7B2C ".concat(retryCount, " \u6B21\u53D1\u751F\u5F02\u5E38: ").concat(Object(util["r" /* isError */])(_context3.t3, task), ", spuId: ").concat(failedItem.spuId);
            log["a" /* default */].setLog(_msg2); // 异常情况也重新加入失败列表

            failedSpuIds.push({
              spuId: failedItem.spuId,
              productName: failedItem.productName,
              siteId: failedItem.siteId,
              siteName: failedItem.siteName,
              category: failedItem.category,
              errorMsg: _msg2,
              retryCount: retryCount
            });

          case 60:
            _i++;
            _context3.next = 43;
            break;

          case 63:
            if (!(failedSpuIds.length > 0 && retryCount < 3)) {
              _context3.next = 67;
              break;
            }

            log["a" /* default */].setLog("\u7B2C ".concat(retryCount, " \u6B21\u91CD\u8BD5\u5B8C\u6210\uFF0C\u8FD8\u6709 ").concat(failedSpuIds.length, " \u4E2A\u5931\u8D25\u9879\uFF0C\u7B49\u5F855\u79D2\u540E\u8FDB\u884C\u4E0B\u6B21\u91CD\u8BD5"));
            _context3.next = 67;
            return Object(util["g" /* delayed */])(5 * 1000);

          case 67:
            retryCount++;
            _context3.next = 36;
            break;

          case 70:
            log["a" /* default */].setLog("\u91CD\u8BD5\u5B8C\u6210\uFF0C\u6700\u7EC8\u8FD8\u6709 ".concat(failedSpuIds.length, " \u4E2A\u5931\u8D25\u9879"));

          case 71:
            // 记录当前已获取数据，用于显示
            task.currentNum = (task.currentNum || 0) + goodsTrafficList.length;
            task.total = total;
            task.curPage = pageNo * getGoodsTraffic_$count; // 判断是否获取完毕

            if (!(task.curPage < total)) {
              _context3.next = 81;
              break;
            }

            task.pageNo += 1; // 上报当前状态

            _context3.next = 78;
            return newTask["a" /* default */].uploadTask({
              code: 4,
              data: {
                pageNo: task.pageNo
              },
              result: {
                currentNum: task.currentNum,
                curPage: task.curPage,
                total: total,
                list: goodsTrafficList,
                failedList: failedSpuIds
              }
            }, task);

          case 78:
            _context3.next = 80;
            return Object(util["g" /* delayed */])(3 * 1000);

          case 80:
            return _context3.abrupt("return", getGoodsTrafficList(task));

          case 81:
            return _context3.abrupt("return", {
              code: 0,
              msg: '全部抓取完成',
              result: {
                currentNum: task.currentNum,
                curPage: task.curPage,
                total: total,
                list: goodsTrafficList,
                failedList: failedSpuIds
              }
            });

          case 82:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3, null, [[18, 25], [47, 55]]);
  }));

  return function getGoodsTrafficList(_x) {
    return _ref.apply(this, arguments);
  };
}(); // 获取商品流量列表


var requestGoodsTrafficList = /*#__PURE__*/function () {
  var _ref2 = getGoodsTraffic_asyncToGenerator( /*#__PURE__*/getGoodsTraffic_regeneratorRuntime().mark(function _callee4(task) {
    var pageNo,
        retry,
        _yield$nativeRequest,
        success,
        errorMsg,
        result,
        msg,
        _msg3,
        _msg4,
        _args4 = arguments;

    return getGoodsTraffic_regeneratorRuntime().wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            pageNo = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : 1;
            retry = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : 0;
            _context4.prev = 2;
            _context4.next = 5;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/flow/analysis/list"), // host需要改为 cbGlobalHost
            'post', {
              pageSize: getGoodsTraffic_$count,
              pageNumber: pageNo,
              timeDimension: 5
            }, {
              Mallid: task.platform_store_id
            });

          case 5:
            _yield$nativeRequest = _context4.sent;
            success = _yield$nativeRequest.success;
            errorMsg = _yield$nativeRequest.errorMsg;
            result = _yield$nativeRequest.result;

            if (!(success && result)) {
              _context4.next = 19;
              break;
            }

            if (!result.pageItems) {
              _context4.next = 14;
              break;
            }

            return _context4.abrupt("return", {
              code: 0,
              total: result.total,
              info: result.pageItems,
              pageNo: pageNo
            });

          case 14:
            msg = '获取商品流量列表数据失败，可能规则已改变';
            log["a" /* default */].setLog(msg);
            return _context4.abrupt("return", {
              code: 2,
              msg: msg,
              pageNo: pageNo
            });

          case 17:
            _context4.next = 22;
            break;

          case 19:
            _msg3 = "\u83B7\u53D6\u5546\u54C1\u6D41\u91CF\u5217\u8868\u5931\u8D25\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(JSON.stringify(errorMsg));
            log["a" /* default */].setLog(_msg3);
            return _context4.abrupt("return", {
              msg: _msg3,
              pageNo: pageNo,
              code: 1
            });

          case 22:
            _context4.next = 34;
            break;

          case 24:
            _context4.prev = 24;
            _context4.t0 = _context4["catch"](2);
            _msg4 = "\u83B7\u53D6\u5546\u54C1\u6D41\u91CF\u5217\u8868\u5931\u8D25-----".concat(Object(util["r" /* isError */])(_context4.t0, task));
            log["a" /* default */].setLog(_msg4); // 重试三次

            if (!(retry < 3)) {
              _context4.next = 33;
              break;
            }

            log["a" /* default */].setLog('正在重试........................');
            _context4.next = 32;
            return Object(util["g" /* delayed */])(5 * 1000);

          case 32:
            return _context4.abrupt("return", requestGoodsTrafficList(task, pageNo, ++retry));

          case 33:
            return _context4.abrupt("return", {
              code: 2,
              msg: _msg4,
              pageNo: pageNo
            });

          case 34:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4, null, [[2, 24]]);
  }));

  return function requestGoodsTrafficList(_x2) {
    return _ref2.apply(this, arguments);
  };
}(); // 获取商品流量详情


var requestGoodsDetail = /*#__PURE__*/function () {
  var _ref3 = getGoodsTraffic_asyncToGenerator( /*#__PURE__*/getGoodsTraffic_regeneratorRuntime().mark(function _callee5(task, item) {
    var retry,
        productId,
        siteId,
        _yield$nativeRequest2,
        success,
        errorMsg,
        result,
        msg,
        _msg5,
        _msg6,
        _args5 = arguments;

    return getGoodsTraffic_regeneratorRuntime().wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            retry = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : 0;
            productId = item.productId, siteId = item.siteId;
            _context5.prev = 2;
            _context5.next = 5;
            return Object(util["u" /* nativeRequest */])("".concat(task.host, "/api/flow/analysis/goods/detail"), // host需要改为 cbGlobalHost
            'post', {
              prodId: productId,
              siteId: siteId,
              timeType: 10
            }, {
              Mallid: task.platform_store_id
            });

          case 5:
            _yield$nativeRequest2 = _context5.sent;
            success = _yield$nativeRequest2.success;
            errorMsg = _yield$nativeRequest2.errorMsg;
            result = _yield$nativeRequest2.result;

            if (!(success && result)) {
              _context5.next = 19;
              break;
            }

            if (!(result.list && Array.isArray(result.list))) {
              _context5.next = 14;
              break;
            }

            return _context5.abrupt("return", {
              code: 0,
              result: result.list.slice(0, 31) // 只抓取最近31项

            });

          case 14:
            msg = "".concat(productId, "\u65E0list\u6D41\u91CF\u8BE6\u60C5\u6570\u636E\uFF0C\u53EF\u80FD\u89C4\u5219\u5DF2\u6539\u53D8");
            log["a" /* default */].setLog(msg);
            return _context5.abrupt("return", {
              msg: msg,
              code: 2
            });

          case 17:
            _context5.next = 22;
            break;

          case 19:
            _msg5 = "\u83B7\u53D6\u5546\u54C1\u6D41\u91CF\u8BE6\u60C5\u5931\u8D25\uFF0C\u4EE5\u4E0B\u4E3A\u9875\u9762\u539F\u59CB\u62A5\u9519\uFF1A".concat(JSON.stringify(errorMsg));
            log["a" /* default */].setLog(_msg5);
            return _context5.abrupt("return", {
              msg: _msg5,
              code: 1
            });

          case 22:
            _context5.next = 41;
            break;

          case 24:
            _context5.prev = 24;
            _context5.t0 = _context5["catch"](2);

            if (!(_context5.t0.message && _context5.t0.message.includes('"error_code":40001'))) {
              _context5.next = 33;
              break;
            }

            log["a" /* default */].setLog('检测到登录过期，开始重新登陆........................');
            _context5.next = 30;
            return reLogin(task);

          case 30:
            log["a" /* default */].setLog('重新登陆完成，准备重新请求........................');
            _context5.next = 35;
            break;

          case 33:
            _msg6 = "\u83B7\u53D6\u5546\u54C1\u6D41\u91CF\u8BE6\u60C5\u5931\u8D25-----".concat(Object(util["r" /* isError */])(_context5.t0, task));
            log["a" /* default */].setLog(_msg6);

          case 35:
            if (!(retry < 3)) {
              _context5.next = 40;
              break;
            }

            log["a" /* default */].setLog('正在重试........................');
            _context5.next = 39;
            return Object(util["g" /* delayed */])(3 * 1000);

          case 39:
            return _context5.abrupt("return", requestGoodsDetail(task, item, ++retry));

          case 40:
            return _context5.abrupt("return", {
              code: 2,
              msg: _msg6 || '获取商品流量详情失败'
            });

          case 41:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5, null, [[2, 24]]);
  }));

  return function requestGoodsDetail(_x3, _x4) {
    return _ref3.apply(this, arguments);
  };
}(); // 店铺重新登陆


var reLogin = /*#__PURE__*/function () {
  var _ref4 = getGoodsTraffic_asyncToGenerator( /*#__PURE__*/getGoodsTraffic_regeneratorRuntime().mark(function _callee6(task) {
    var loginRes, msg;
    return getGoodsTraffic_regeneratorRuntime().wrap(function _callee6$(_context6) {
      while (1) {
        switch (_context6.prev = _context6.next) {
          case 0:
            _context6.next = 2;
            return Object(temu["e" /* loginCb */])(task);

          case 2:
            loginRes = _context6.sent;

            if (loginRes) {
              _context6.next = 8;
              break;
            }

            msg = '切换到美区或欧区站点失败，请检查';
            task.msg = msg;
            log["a" /* default */].setLog(msg);
            return _context6.abrupt("return", {
              code: 1,
              msg: msg
            });

          case 8:
          case "end":
            return _context6.stop();
        }
      }
    }, _callee6);
  }));

  return function reLogin(_x5) {
    return _ref4.apply(this, arguments);
  };
}(); // 入口函数


var getGoodsTraffic = /*#__PURE__*/function () {
  var _ref5 = getGoodsTraffic_asyncToGenerator( /*#__PURE__*/getGoodsTraffic_regeneratorRuntime().mark(function _callee7(task) {
    var loginRes, msg, res;
    return getGoodsTraffic_regeneratorRuntime().wrap(function _callee7$(_context7) {
      while (1) {
        switch (_context7.prev = _context7.next) {
          case 0:
            if (!(task.resCache && task.resCache.code === 0)) {
              _context7.next = 2;
              break;
            }

            return _context7.abrupt("return", task.resCache);

          case 2:
            if (!(task.platform_code === 10022 || task.store_type === 'GLOBAL')) {
              _context7.next = 11;
              break;
            }

            _context7.next = 5;
            return Object(temu["e" /* loginCb */])(task);

          case 5:
            loginRes = _context7.sent;

            if (loginRes) {
              _context7.next = 11;
              break;
            }

            msg = '切换到美区或欧区站点失败，请检查';
            task.msg = msg;
            log["a" /* default */].setLog(msg);
            return _context7.abrupt("return", {
              code: 1,
              msg: msg
            });

          case 11:
            _context7.next = 13;
            return getGoodsTrafficList(task);

          case 13:
            res = _context7.sent;
            task.status = [1, 2].indexOf(res.code) > -1 ? 14 : 15; // code: 0 - 成功, 1 - 失败,2 - 异常, 4 - 执行中（进度上报）

            task.msg = res.msg;
            return _context7.abrupt("return", res);

          case 17:
          case "end":
            return _context7.stop();
        }
      }
    }, _callee7);
  }));

  return function getGoodsTraffic(_x6) {
    return _ref5.apply(this, arguments);
  };
}();

/* harmony default export */ var temu_getGoodsTraffic = (getGoodsTraffic);
// CONCATENATED MODULE: ./src/platform/common/taskType.js






var cores = {
  getSupplierPrice: temu_getSupplierPrice,
  getSaleVolume: temu_getSaleVolume,
  getQtReport: qtReport,
  getTodaySaleVolume: temu_getTodaySaleVolume,
  getActivityPrice: temu_getActivityPrice,
  getGoodsTraffic: temu_getGoodsTraffic
}; // export const multiTskHandleMap = {
//   // temum
//   22002: {
//     name: 'TEMU供货价获取',
//     type: 'sale',
//     platform_code: 10022,
//     handle: 'getSupplierPrice',
//     component: 'SupplierPrice'
//   },
//   22001: {
//     name: '历史销量与供货价获取',
//     type: 'supplierPrice',
//     platform_code: 10022,
//     handle: 'getSaleVolume',
//     component: 'SaleVolume'
//   },
//   22003: {
//     name: 'Temu半托管财务报表',
//     type: 'temuReport',
//     platform_code: 10024,
//     handle: 'getTemuReport',
//     component: 'SaleVolume'
//   },
//   22004: {
//     name: 'Temu退货面单费',
//     type: 'temuReport',
//     platform_code: 10024,
//     handle: 'getReverseReport',
//     component: 'ReverseReport'
//   },
//   22005: {
//     name: 'Temu发货面单费',
//     type: 'temuReport',
//     platform_code: 10024,
//     handle: 'getStmlReport',
//     component: 'SaleVolume'
//   },
//   22006: {
//     name: 'TEMU全托管财务数据（Settled&Deduction&BillDetails&EPR）',
//     type: 'temuReport',
//     platform_code: 10022,
//     handle: 'getQtReport',
//     component: 'SaleVolume'
//   },
//   22007: {
//     name: '全托管-当日销量',
//     type: 'todaySaleVolume',
//     platform_code: 10022,
//     handle: 'getTodaySaleVolume',
//     component: 'SaleVolume'
//   },
//   22008: {
//     name: 'Temu活动价',
//     type: 'activityPrice',
//     platform_code: 10022,
//     handle: 'getActivityPrice',
//     component: 'SaleVolume'
//   }
// }

var multiTskHandleMap = {
  // temum半托
  22003: {
    name: '财务/账务明细-半托',
    type: 'temuReport',
    platform_code: 10024,
    handle: 'getQtReport',
    component: 'SaleVolume'
  },
  22005: {
    name: '发货面单费-半托',
    type: 'temuReport',
    platform_code: 10024,
    handle: 'getQtReport',
    component: 'SaleVolume'
  },
  22004: {
    name: '退货面单费-半托',
    type: 'temuReport',
    platform_code: 10024,
    handle: 'getQtReport',
    component: 'ReverseReport'
  },
  22002: {
    name: '最新供货价-半托',
    type: 'supplierPrice',
    platform_code: 10022,
    handle: 'getSupplierPrice',
    component: 'SupplierPrice'
  },
  22008: {
    name: '活动价-半托',
    type: 'activityPrice',
    platform_code: 10022,
    handle: 'getActivityPrice',
    component: 'SaleVolume'
  },
  22017: {
    name: '流量分析-半托',
    type: 'goodsTraffic',
    platform_code: 10022,
    handle: 'getGoodsTraffic',
    component: 'SaleVolume'
  },
  // temu全托
  22006: {
    name: '财务/账务明细-全托',
    type: 'temuReport',
    platform_code: 10024,
    handle: 'getQtReport',
    component: 'SaleVolume'
  },
  22015: {
    name: '支出详情-全托',
    type: 'temuReport',
    platform_code: 10024,
    handle: 'getQtReport',
    component: 'SaleVolume'
  },
  22009: {
    name: 'ERP费用-全托',
    type: 'temuReport',
    platform_code: 10024,
    handle: 'getQtReport',
    component: 'SaleVolume'
  },
  22001: {
    name: '近30天销量-全托',
    type: 'sale',
    platform_code: 10022,
    handle: 'getSaleVolume',
    component: 'SaleVolume'
  },
  22010: {
    name: '最新供货价-全托',
    type: 'supplierPrice',
    platform_code: 10022,
    handle: 'getSupplierPrice',
    component: 'SupplierPrice'
  },
  22016: {
    name: '活动价-全托',
    type: 'activityPrice',
    platform_code: 10022,
    handle: 'getActivityPrice',
    component: 'SaleVolume'
  },
  //temu本土
  22011: {
    name: '最新供货价-本土',
    type: 'supplierPrice',
    platform_code: 10022,
    handle: 'getSupplierPrice',
    component: 'SupplierPrice'
  },
  // temu半托po明细
  22018: {
    name: 'PO明细-本土',
    type: 'temuReport',
    platform_code: 10022,
    handle: 'getQtReport',
    component: 'SaleVolume'
  }
};

/***/ }),

/***/ "5e61":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("c1df");
/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _utils_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("ca00");
/* harmony import */ var _data_log__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("6b23");
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("db49");
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("a1d0");
/* harmony import */ var _taskType__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("2f79");
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }

function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }







/**
 * 重构后的多平台任务管理类
 * 采用扁平化数据结构，以 platform_store_id+report_date_month 作为分组key
 */

var MultiPlatformTaskV2 = /*#__PURE__*/function () {
  function MultiPlatformTaskV2() {
    var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
        sleepTime = _ref.sleepTime;

    _classCallCheck(this, MultiPlatformTaskV2);

    // 任务类型相关
    this.taskTypeTotal = 0; // 扁平化任务分组 - 核心数据结构

    this.taskGroups = {}; // 执行顺序管理

    this.orderedKeys = []; // 指针式调度核心

    this.currentGroupPointer = null; // 当前执行的分组key

    this.currentTaskPointer = 0; // 当前分组内的任务索引

    this.isExecuting = false; // 是否正在执行任务
    // 任务状态

    this.taskStatus = 'idle'; // repeat任务缓存（不受月份分组影响）

    this.repeatMap = {}; // 轮次执行跟踪器

    this.executionRound = 1;
    this.roundExecutionRecord = {}; // 记录每个分组在当前轮次的执行状态
    // 重试定时器

    this.retryTimerName = null;
    this.nextRetryAt = null; // 重试配置

    this.retryConfig = {
      noRetryTypes: [],
      // 不需要重试的任务类型（如重复任务）
      maxRetryCount: _config__WEBPACK_IMPORTED_MODULE_3__[/* TEMU_MAX_RETRY_COUNT */ "d"],
      // 最大延迟时间是2的12次方秒，即4096秒，约1小时15分钟
      retryInterval: function retryInterval(errorTime) {
        return Math.min(Math.pow(2, errorTime) * 1000, Math.pow(2, 12) * 1000);
      }
    }; // 配置参数

    this.notCoverTypes = [22002, 22001, 22010, 22011, 22008, 22016]; // 不需要覆盖的任务类型

    this.sleepTime = sleepTime || 3000; // 1-3s

    this.taskTimeout = 20 * 60 * 1000;
    this.force = false; // 初始化

    this.getTaskList();
  }
  /**
   * @description 获取任务列表
   * @param {boolean} force 是否强制获取
   */


  _createClass(MultiPlatformTaskV2, [{
    key: "getTaskList",
    value: function () {
      var _getTaskList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(force) {
        var res;
        return _regeneratorRuntime().wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                _context.next = 2;
                return Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* gatePost */ "l"])('api/mp/getTask', {
                  platform_code: _index__WEBPACK_IMPORTED_MODULE_4__[/* multiPlatform */ "a"].platformCode,
                  platform_store_ids: _index__WEBPACK_IMPORTED_MODULE_4__[/* multiPlatform */ "a"].storeInfo,
                  force: force
                }, 'task').catch(function (e) {
                  _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('获取任务列表失败----', Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* isError */ "r"])(e));
                });

              case 2:
                res = _context.sent;

                if (res && res.code === 0) {
                  this.initTaskList(res.data, force);
                }

              case 4:
              case "end":
                return _context.stop();
            }
          }
        }, _callee, this);
      }));

      function getTaskList(_x) {
        return _getTaskList.apply(this, arguments);
      }

      return getTaskList;
    }()
    /**
     * @description 任务数据初始化
     * @param {Object} item 任务项
     * @returns {Object} 初始化后的任务
     */

  }, {
    key: "initTask",
    value: function initTask(item) {
      var data = _typeof(item.data) === 'object' ? item.data : JSON.parse(item.data);
      return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, item), item.store_info || {}), data || {}), {}, {
        status: 0,
        error_time: 0,
        hide: false,
        isDelete: false,
        isInit: true,
        endTime: null,
        isRetryable: !this.retryConfig.noRetryTypes.includes(item.type_id)
      });
    }
    /**
     * @description 检查任务是否可执行（基础条件检查）
     * @param {Object} task 任务对象
     * @returns {boolean} 是否可执行
     */

  }, {
    key: "isTaskExecutable",
    value: function isTaskExecutable(task) {
      if (!task) return false;
      if (task.isDelete) return false;
      if (task.status === 1) return false;
      if (task.error_time >= this.retryConfig.maxRetryCount) return false;
      if (!this.shouldRetryNow(task)) return false;
      return true;
    }
    /**
     * @description 弹窗重新获取触发回调，将错误次数大于等于9的任务重置为0
     */

  }, {
    key: "handleReGet",
    value: function handleReGet() {
      var _loop = function _loop() {
        var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
            groupKey = _Object$entries$_i[0],
            group = _Object$entries$_i[1];

        if (group.tasks && group.tasks.length) {
          group.tasks.forEach(function (task) {
            if (task.error_time >= 10) {
              task.error_time = 0;
              _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("\u91CD\u7F6E\u4EFB\u52A1\u9519\u8BEF\u6B21\u6570\uFF1AtaskId-".concat(task.task_id, "\uFF0C\u6240\u5728\u5206\u7EC4\uFF1A").concat(groupKey));
            }
          });
        }
      };

      for (var _i = 0, _Object$entries = Object.entries(this.taskGroups); _i < _Object$entries.length; _i++) {
        _loop();
      }

      this.taskSchedule();
    }
    /**
     * @description 检查是否应该重试
     * @param {Object} task 任务对象
     * @returns {boolean} 是否应该重试
     */

  }, {
    key: "shouldRetryNow",
    value: function shouldRetryNow(task) {
      if (!task.isRetryable) return false;
      if (!task.endTime || task.error_time === 0) return true;
      var nextRetryTime = task.endTime + this.retryConfig.retryInterval(task.error_time);
      return Date.now() >= nextRetryTime;
    }
    /**
     * @description 判断任务是否属于重试候选
     */

  }, {
    key: "isRetryCandidate",
    value: function isRetryCandidate(task) {
      if (!task) return false;
      if (task.repeat > 0) return false; // 重复任务不走重试定时器

      if (!task.isRetryable) return false;
      if (task.isDelete || task.status === 1) return false;
      if (typeof task.endTime !== 'number') return false;
      if (task.error_time <= 0 || task.error_time >= this.retryConfig.maxRetryCount) return false; // 仅考虑未来时间点的重试

      var next = this.getTaskNextRetryTime(task);
      return typeof next === 'number' && next > Date.now();
    }
    /**
     * @description 计算任务下一次重试时间戳
     */

  }, {
    key: "getTaskNextRetryTime",
    value: function getTaskNextRetryTime(task) {
      var interval = this.retryConfig.retryInterval(task.error_time);
      return task.endTime + interval;
    }
    /**
     * @description 汇总所有任务，返回最近的下一次重试时间戳
     */

  }, {
    key: "computeNextRetryAt",
    value: function computeNextRetryAt() {
      var minTs = null;

      for (var _i2 = 0, _Object$values = Object.values(this.taskGroups); _i2 < _Object$values.length; _i2++) {
        var group = _Object$values[_i2];
        if (!group || !group.tasks || group.tasks.length === 0) continue;

        var _iterator = _createForOfIteratorHelper(group.tasks),
            _step;

        try {
          for (_iterator.s(); !(_step = _iterator.n()).done;) {
            var task = _step.value;
            if (!this.isRetryCandidate(task)) continue;
            var ts = this.getTaskNextRetryTime(task);

            if (minTs === null || ts < minTs) {
              minTs = ts;
            }
          }
        } catch (err) {
          _iterator.e(err);
        } finally {
          _iterator.f();
        }
      }

      return minTs;
    }
    /**
     * @description 清除重试定时器
     */

  }, {
    key: "clearRetryTimer",
    value: function clearRetryTimer() {
      if (this.retryTimerName) {
        chrome.alarms.clear(this.retryTimerName);
        this.retryTimerName = null;
        this.nextRetryAt = null;
        _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('已清除重试定时器');
      }
    }
    /**
     * @description 设置重试定时器（当当前无可执行任务时）
     */

  }, {
    key: "scheduleRetryTimer",
    value: function () {
      var _scheduleRetryTimer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
        var _this = this;

        var ts, delay, timerName;
        return _regeneratorRuntime().wrap(function _callee3$(_context3) {
          while (1) {
            switch (_context3.prev = _context3.next) {
              case 0:
                _context3.next = 2;
                return this.discontinue();

              case 2:
                if (!_context3.sent) {
                  _context3.next = 5;
                  break;
                }

                this.clearRetryTimer();
                return _context3.abrupt("return");

              case 5:
                ts = this.computeNextRetryAt();

                if (ts) {
                  _context3.next = 9;
                  break;
                }

                this.clearRetryTimer();
                return _context3.abrupt("return");

              case 9:
                if (!(this.retryTimerName && this.nextRetryAt === ts)) {
                  _context3.next = 11;
                  break;
                }

                return _context3.abrupt("return");

              case 11:
                this.clearRetryTimer();
                delay = Math.max(0, ts - Date.now());
                this.nextRetryAt = ts;
                timerName = "retryTimer";
                this.retryTimerName = timerName;
                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("\u8BBE\u7F6E\u91CD\u8BD5\u5B9A\u65F6\u5668\uFF0C".concat(Math.ceil(delay / 1000), "s \u540E\u89E6\u53D1")); // 设置定时器回调

                _utils_util__WEBPACK_IMPORTED_MODULE_1__[/* alarms */ "b"].setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
                  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
                    while (1) {
                      switch (_context2.prev = _context2.next) {
                        case 0:
                          _this.retryTimerName = null;
                          _this.nextRetryAt = null; // 回调时再次校验状态

                          _context2.next = 4;
                          return _this.discontinue();

                        case 4:
                          if (!_context2.sent) {
                            _context2.next = 6;
                            break;
                          }

                          return _context2.abrupt("return");

                        case 6:
                          // 执行一次调度（此时应有任务达到重试时间）
                          _this.taskSchedule();

                        case 7:
                        case "end":
                          return _context2.stop();
                      }
                    }
                  }, _callee2);
                })), timerName, delay);

              case 18:
              case "end":
                return _context3.stop();
            }
          }
        }, _callee3, this);
      }));

      function scheduleRetryTimer() {
        return _scheduleRetryTimer.apply(this, arguments);
      }

      return scheduleRetryTimer;
    }()
    /**
     * @description 初始化分组的轮次执行记录
     * @param {string} groupKey 分组key
     */

  }, {
    key: "initGroupRoundRecord",
    value: function initGroupRoundRecord(groupKey) {
      if (!this.roundExecutionRecord[groupKey]) {
        this.roundExecutionRecord[groupKey] = {
          currentRound: this.executionRound,
          executedTaskIds: new Set(),
          // 本轮已执行过的任务ID
          allTasksTriedInRound: false // 本轮是否所有任务都已尝试

        };
      }
    }
    /**
     * @description 标记任务在当前轮次已执行
     * @param {string} groupKey 分组key
     * @param {string} taskId 任务ID
     */

  }, {
    key: "markTaskExecutedInRound",
    value: function markTaskExecutedInRound(groupKey, taskId) {
      this.initGroupRoundRecord(groupKey);
      this.roundExecutionRecord[groupKey].executedTaskIds.add(taskId);
    }
    /**
     * @description 检查任务在当前轮次是否已执行过
     * @param {string} groupKey 分组key
     * @param {string} taskId 任务ID
     * @returns {boolean} 是否已执行过
     */

  }, {
    key: "isTaskExecutedInCurrentRound",
    value: function isTaskExecutedInCurrentRound(groupKey, taskId) {
      var record = this.roundExecutionRecord[groupKey];
      return record && record.executedTaskIds.has(taskId);
    }
    /**
     * @description 检查分组在当前轮次是否已完成
     * @param {string} groupKey 分组key
     * @returns {boolean} 是否已完成当前轮次
     */

  }, {
    key: "isGroupRoundComplete",
    value: function isGroupRoundComplete(groupKey) {
      var _this2 = this;

      var group = this.taskGroups[groupKey];
      if (!group || !group.tasks) return true;
      this.initGroupRoundRecord(groupKey);
      var record = this.roundExecutionRecord[groupKey]; // 检查所有可执行任务是否都已在本轮尝试过

      return group.tasks.every(function (task) {
        if (!_this2.isTaskExecutable(task)) {
          return true; // 已删除、已完成或超过最大错误次数的任务不影响轮次完成
        }

        return record.executedTaskIds.has(task.task_id);
      });
    }
    /**
     * @description 重置轮次执行记录，开始新的轮次
     */

  }, {
    key: "startNewExecutionRound",
    value: function startNewExecutionRound() {
      this.executionRound++; // 清除所有分组的轮次记录，但保留分组结构

      for (var _i3 = 0, _Object$keys = Object.keys(this.roundExecutionRecord); _i3 < _Object$keys.length; _i3++) {
        var groupKey = _Object$keys[_i3];
        this.roundExecutionRecord[groupKey] = {
          currentRound: this.executionRound,
          executedTaskIds: new Set(),
          allTasksTriedInRound: false
        };
      }

      _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("\u5F00\u59CB\u65B0\u7684\u6267\u884C\u8F6E\u6B21: ".concat(this.executionRound));
    }
    /**
     * @description 过滤相同任务（扁平化key内按type_id去重）
     * @param {Array} taskList 新任务列表
     * @param {boolean} force 是否强制获取
     */

  }, {
    key: "filterTaskList",
    value: function filterTaskList(taskList) {
      var _this3 = this;

      var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      var clearRepeatMap = {};
      taskList.forEach(function (item, index) {
        // 任务初始化
        taskList[index] = _this3.initTask(item);
        var task = taskList[index]; // 生成分组key

        var groupKey = MultiPlatformTaskV2.generateStoreMonthKey(task.platform_store_id, task.report_date_month); // 特殊处理repeat任务

        if (task.repeat > 0) {
          _this3.initRepeatTask(task, force);

          return;
        }

        if (task.isDelete) return; // 过滤新进任务中相同的任务
        // 在对应分组中查找相同任务（需要覆盖任务根据type_id去重，不需要覆盖任务根据task_id去重）

        var group = _this3.taskGroups[groupKey];

        if (group && group.tasks) {
          var sameTaskIndex = group.tasks.findIndex(function (existingTask) {
            return (_this3.notCoverTypes.includes(+task.type_id) ? existingTask.task_id === task.task_id : existingTask.type_id === task.type_id) && !existingTask.isDelete;
          });

          if (sameTaskIndex !== -1) {
            var sameTask = group.tasks[sameTaskIndex];
            sameTask.isDelete = true;
          }
        }
      });
    }
    /**
     * @description 初始化repeat任务（不受月份分组影响）
     * @param {Object} task 任务对象
     * @param {boolean} force 是否强制获取
     */

  }, {
    key: "initRepeatTask",
    value: function initRepeatTask(task) {
      var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      if (task.repeat <= 0) return;
      var copy = Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* deepClone */ "f"])(task);
      copy.count = 0;
      copy.isRepeatMap = true; // 新的数据结构：{typeId: [task1, task2]}

      if (!this.repeatMap[task.type_id]) {
        this.repeatMap[task.type_id] = [];
      }

      var repeatList = this.repeatMap[task.type_id];
      var existingIndex = repeatList.findIndex(function (item) {
        return item.platform_store_id === task.platform_store_id;
      });

      if (existingIndex !== -1) {
        // 相同站点&不是点击的立即获取&不是repeatMap派遣的任务，则继续走repeat任务管理流程，删掉新进来的任务
        // 防止循环请求拉任务导致repeat任务重复执行
        if (!force && !task.isRepeatMap) {
          task.isDelete = true;
          copy.count = repeatList[existingIndex].count;
        } // 替换现有任务


        repeatList[existingIndex] = copy;
      } else {
        // 添加新任务
        repeatList.push(copy);
      }
    }
    /**
     * @description 任务队列初始化（扁平化分组、优先级排序、去重）
     * @param {Array} taskList 新任务列表
     * @param {boolean} force 是否强制获取
     */

  }, {
    key: "initTaskList",
    value: function () {
      var _initTaskList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(taskList) {
        var _this4 = this;

        var force,
            newStoreIds,
            newGroups,
            _loop2,
            _i4,
            _Object$entries2,
            _ret,
            _args4 = arguments;

        return _regeneratorRuntime().wrap(function _callee4$(_context4) {
          while (1) {
            switch (_context4.prev = _context4.next) {
              case 0:
                force = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : false;

                if (!(taskList.length === 0)) {
                  _context4.next = 3;
                  break;
                }

                return _context4.abrupt("return");

              case 3:
                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('任务初始化（扁平化分组、去重、优先级排序、店铺优先级排序）'); // 过滤相同任务

                this.filterTaskList(taskList, force); // 收集新店铺ID，用于优先级排序

                newStoreIds = new Set(); // 按扁平化key分组新任务

                newGroups = {};
                taskList.forEach(function (task) {
                  // 丢弃被删除任务和repeat任务
                  if (task.isDelete) return;
                  var groupKey = MultiPlatformTaskV2.generateStoreMonthKey(task.platform_store_id, task.report_date_month); // 记录新店铺ID

                  newStoreIds.add(task.platform_store_id);

                  if (newGroups[groupKey]) {
                    newGroups[groupKey].tasks.push(task);
                  } else if (_this4.taskGroups[groupKey]) {
                    _this4.taskGroups[groupKey].tasks.push(task);

                    newGroups[groupKey] = _this4.taskGroups[groupKey];
                  } else {
                    newGroups[groupKey] = {
                      storeInfo: _index__WEBPACK_IMPORTED_MODULE_4__[/* multiPlatform */ "a"].storeInfoOfExhibition.find(function (item) {
                        return item.mallId == task.platform_store_id;
                      }) || task.store_info || {},
                      tasks: [task],
                      storeId: task.platform_store_id,
                      monthId: task.report_date_month
                    };
                  }
                }); // 合并旧任务

                Object.keys(this.taskGroups).forEach(function (key) {
                  var group = _this4.taskGroups[key];

                  if (!newGroups[key]) {
                    newGroups[key] = group;
                  }
                }); // 处理分组中待删除任务&任务排序

                _loop2 = function _loop2() {
                  var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i4], 2),
                      key = _Object$entries2$_i[0],
                      group = _Object$entries2$_i[1];

                  group.tasks = group.tasks.filter(function (task) {
                    return !task.isDelete;
                  }); // 删除没有任务的分组

                  if (group.tasks.length === 0) {
                    delete newGroups[key];
                    newStoreIds.delete(group.storeId);
                    _this4.orderedKeys = _this4.orderedKeys.filter(function (k) {
                      return k !== key;
                    });
                    return "continue";
                  } // 根据任务类型优先级排序后再根据任务优先级排序


                  group.tasks.forEach(function (item) {
                    var obj = _index__WEBPACK_IMPORTED_MODULE_4__[/* multiPlatform */ "a"].taskTypesMap[item.type_id];

                    if (obj) {
                      obj.list.push(item);
                    }
                  });
                  var arr = [];
                  _index__WEBPACK_IMPORTED_MODULE_4__[/* multiPlatform */ "a"].taskTypes.forEach(function (item) {
                    if (item.list && item.list.length) {
                      item.list.sort(function (a, b) {
                        return b.priority - a.priority;
                      });
                      arr.push.apply(arr, _toConsumableArray(item.list));
                      item.list = [];
                    }
                  });
                  group.tasks = arr;
                };

                _i4 = 0, _Object$entries2 = Object.entries(newGroups);

              case 11:
                if (!(_i4 < _Object$entries2.length)) {
                  _context4.next = 18;
                  break;
                }

                _ret = _loop2();

                if (!(_ret === "continue")) {
                  _context4.next = 15;
                  break;
                }

                return _context4.abrupt("continue", 15);

              case 15:
                _i4++;
                _context4.next = 11;
                break;

              case 18:
                // 更新分组
                this.taskGroups = newGroups; // 更新执行顺序（新店铺优先）

                this.updateExecutionOrderWithPriority(Array.from(newStoreIds)); // 如果没有正在执行任务，开始任务调度

                if (!this.isExecuting) {
                  this.taskSchedule();
                }

              case 21:
              case "end":
                return _context4.stop();
            }
          }
        }, _callee4, this);
      }));

      function initTaskList(_x2) {
        return _initTaskList.apply(this, arguments);
      }

      return initTaskList;
    }()
    /**
     * @description 更新执行顺序（新店铺优先）
     * @param {Array} newStoreIds 新店铺ID列表
     */

  }, {
    key: "updateExecutionOrderWithPriority",
    value: function updateExecutionOrderWithPriority(newStoreIds) {
      var _this5 = this;

      // 获取现有店铺顺序（排除新店铺）
      var existingStoreIds = this.orderedKeys.map(function (key) {
        return MultiPlatformTaskV2.parseStoreMonthKey(key).storeId;
      }).filter(function (storeId, index, arr) {
        return arr.indexOf(storeId) === index;
      }) // 去重
      .filter(function (storeId) {
        return !newStoreIds.includes(storeId);
      }); // 新的店铺顺序：新店铺优先，然后是现有店铺顺序

      var finalStoreOrder = [].concat(_toConsumableArray(newStoreIds), _toConsumableArray(existingStoreIds)); // 生成新的执行顺序

      var newOrderedKeys = [];
      finalStoreOrder.forEach(function (storeId) {
        var storeKeys = Object.keys(_this5.taskGroups).filter(function (key) {
          return key.startsWith("".concat(storeId, "_"));
        }).sort(function (a, b) {
          // 按月份倒序
          var monthA = MultiPlatformTaskV2.parseStoreMonthKey(a).monthId;
          var monthB = MultiPlatformTaskV2.parseStoreMonthKey(b).monthId;
          return (monthB || '').localeCompare(monthA || '');
        });
        newOrderedKeys.push.apply(newOrderedKeys, _toConsumableArray(storeKeys));
      }); // 调整当前指针位置

      var oldCurrentKey = this.currentGroupPointer;
      this.orderedKeys = newOrderedKeys; // 如果当前指针指向的分组仍存在，保持指针位置

      if (oldCurrentKey && this.taskGroups[oldCurrentKey]) {
        this.currentGroupPointer = oldCurrentKey;
      } else {
        // 否则重置到第一个分组
        this.currentGroupPointer = newOrderedKeys.length > 0 ? newOrderedKeys[0] : null;
      } // 重置组内任务索引
      // this.currentTaskPointer = 0


      _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("\u6267\u884C\u987A\u5E8F\u5DF2\u66F4\u65B0\uFF0C\u65B0\u5E97\u94FA\u4F18\u5148\uFF1A".concat(newStoreIds.join(','), "\uFF0C\u603B\u6267\u884C\u987A\u5E8F\uFF1A").concat(newOrderedKeys.join(',')));
    }
    /**
     * @description 判断任务能否执行
     * @param {Object} task 任务对象
     * @returns {boolean} 能否执行
     */

  }, {
    key: "canRunTask",
    value: function () {
      var _canRunTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(task) {
        var repeat, task_id, expiration_time, type_id, res, msg;
        return _regeneratorRuntime().wrap(function _callee5$(_context5) {
          while (1) {
            switch (_context5.prev = _context5.next) {
              case 0:
                repeat = task.repeat, task_id = task.task_id, expiration_time = task.expiration_time, type_id = task.type_id; // if (repeat >= 0) return true

                _context5.next = 3;
                return Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* gatePost */ "l"])('api/mp/handleReportInfoByType', {
                  // type: 4,
                  // data: { task_id }
                  task_id: task_id
                }, 'task').catch(function () {});

              case 3:
                res = _context5.sent;

                if (!(res && res.data)) {
                  _context5.next = 20;
                  break;
                }

                _context5.t0 = res.data.status;
                _context5.next = _context5.t0 === 0 ? 8 : _context5.t0 === 1 ? 9 : _context5.t0 === 2 ? 12 : 20;
                break;

              case 8:
                return _context5.abrupt("return", true);

              case 9:
                task.isDelete = true;
                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("\u4EFB\u52A1\u5DF2\u88AB\u6267\u884C,task_id:".concat(task.task_id, " \u5E97\u94FA\uFF1A").concat(task.platform_store_id));
                return _context5.abrupt("return", false);

              case 12:
                task.error_time = this.retryConfig.maxRetryCount;
                task.run_status = 4;
                task.status = 17;
                msg = '任务已失效';
                _context5.next = 18;
                return MultiPlatformTaskV2.uploadTask({
                  code: 1,
                  msg: msg
                }, task);

              case 18:
                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("\u4EFB\u52A1\u5DF2\u5931\u6548,task_id:".concat(task.task_id, " \u5E97\u94FA\uFF1A").concat(task.platform_store_id));
                return _context5.abrupt("return", false);

              case 20:
                task.error_time++;
                return _context5.abrupt("return", false);

              case 22:
              case "end":
                return _context5.stop();
            }
          }
        }, _callee5, this);
      }));

      function canRunTask(_x3) {
        return _canRunTask.apply(this, arguments);
      }

      return canRunTask;
    }()
    /**
     * @description 检查分组是否有可执行任务
     * @param {string} groupKey 分组key
     * @returns {boolean} 是否有可执行任务
     */

  }, {
    key: "hasExecutableInGroup",
    value: function hasExecutableInGroup(groupKey) {
      var _this6 = this;

      var group = this.taskGroups[groupKey];
      if (!group || !group.tasks) return false;
      return group.tasks.some(function (task) {
        return _this6.isTaskExecutable(task);
      });
    }
    /**
     * @description 检查是否还有可执行任务
     * @returns {boolean} 是否有可执行任务
     */

  }, {
    key: "hasExecutable",
    value: function () {
      var _hasExecutable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
        var _iterator2, _step2, key;

        return _regeneratorRuntime().wrap(function _callee6$(_context6) {
          while (1) {
            switch (_context6.prev = _context6.next) {
              case 0:
                _context6.next = 2;
                return Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* executable */ "h"])();

              case 2:
                if (_context6.sent) {
                  _context6.next = 4;
                  break;
                }

                return _context6.abrupt("return", false);

              case 4:
                _iterator2 = _createForOfIteratorHelper(this.orderedKeys);
                _context6.prev = 5;

                _iterator2.s();

              case 7:
                if ((_step2 = _iterator2.n()).done) {
                  _context6.next = 18;
                  break;
                }

                key = _step2.value;
                _context6.t0 = this.hasExecutableInGroup(key);

                if (!_context6.t0) {
                  _context6.next = 14;
                  break;
                }

                _context6.next = 13;
                return this.discontinue();

              case 13:
                _context6.t0 = !_context6.sent;

              case 14:
                if (!_context6.t0) {
                  _context6.next = 16;
                  break;
                }

                return _context6.abrupt("return", true);

              case 16:
                _context6.next = 7;
                break;

              case 18:
                _context6.next = 23;
                break;

              case 20:
                _context6.prev = 20;
                _context6.t1 = _context6["catch"](5);

                _iterator2.e(_context6.t1);

              case 23:
                _context6.prev = 23;

                _iterator2.f();

                return _context6.finish(23);

              case 26:
                return _context6.abrupt("return", false);

              case 27:
              case "end":
                return _context6.stop();
            }
          }
        }, _callee6, this, [[5, 20, 23, 26]]);
      }));

      function hasExecutable() {
        return _hasExecutable.apply(this, arguments);
      }

      return hasExecutable;
    }() // 初始化指针位置

  }, {
    key: "initPointer",
    value: function initPointer() {
      if (!this.currentGroupPointer && this.orderedKeys.length > 0) {
        this.currentGroupPointer = this.orderedKeys[0];
        this.currentTaskPointer = 0;
      }
    }
    /**
     * @description 任务调度核心方法（指针式调度）
     */

  }, {
    key: "taskSchedule",
    value: function () {
      var _taskSchedule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
        var curStatus, executed, nextTask, foundNext;
        return _regeneratorRuntime().wrap(function _callee7$(_context7) {
          while (1) {
            switch (_context7.prev = _context7.next) {
              case 0:
                _context7.prev = 0;
                curStatus = this.multiPlatformTaskStatus();

                if (!curStatus) {
                  _context7.next = 5;
                  break;
                }

                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("\u5F53\u524D\u6B63\u5728\u6267\u884C".concat(curStatus));
                return _context7.abrupt("return");

              case 5:
                // 设置执行状态
                this.multiPlatformTaskStatus(999);
                this.isExecuting = true; // 初始化指针位置

                this.initPointer(); // 指针式执行任务

              case 8:
                _context7.next = 10;
                return this.hasExecutable();

              case 10:
                if (!_context7.sent) {
                  _context7.next = 34;
                  break;
                }

                _context7.next = 13;
                return this.executeCurrentTask();

              case 13:
                executed = _context7.sent;

                if (!executed) {
                  _context7.next = 20;
                  break;
                }

                // 任务执行成功，移动到下一个任务
                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("\u4EFB\u52A1\u6267\u884C\u5B8C\u6BD5\uFF0C\u79FB\u52A8\u5230\u4E0B\u4E00\u4E2A\u4EFB\u52A1");
                nextTask = this.moveToNextTask();

                if (!nextTask) {
                  _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("\u672A\u627E\u5230\u5F53\u524D\u7EC4\uFF1A".concat(this.currentGroupPointer, "\u7684\u4E0B\u4E00\u4E2A\u53EF\u6267\u884C\u4EFB\u52A1"));
                }

                _context7.next = 26;
                break;

              case 20:
                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("\u5F53\u524D\u4F4D\u7F6E\u6CA1\u6709\u53EF\u6267\u884C\u4EFB\u52A1\uFF0C\u5C1D\u8BD5\u627E\u5230\u4E0B\u4E00\u4E2A\u53EF\u6267\u884C\u4EFB\u52A1"); // 当前位置没有可执行任务，尝试找到下一个可执行任务

                foundNext = this.findNextExecutableTask();

                if (foundNext) {
                  _context7.next = 26;
                  break;
                }

                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('本轮已没有更多可执行任务，进行下一轮');
                this.checkAndStartNewRound();
                return _context7.abrupt("break", 34);

              case 26:
                _context7.next = 28;
                return this.discontinue();

              case 28:
                if (!_context7.sent) {
                  _context7.next = 32;
                  break;
                }

                this.isExecuting = false;
                this.multiPlatformTaskStatus('idle');
                return _context7.abrupt("return");

              case 32:
                _context7.next = 8;
                break;

              case 34:
                // 切换空闲状态
                this.isExecuting = false;
                this.multiPlatformTaskStatus('idle');
                Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* setBadge */ "B"])(10);
                this.clearTaskList(); // 检查是否还有可执行任务

                _context7.next = 40;
                return this.hasExecutable();

              case 40:
                if (!_context7.sent) {
                  _context7.next = 44;
                  break;
                }

                this.taskSchedule();
                _context7.next = 45;
                break;

              case 44:
                // 无可执行任务时评估重试定时器
                this.scheduleRetryTimer();

              case 45:
                _context7.next = 53;
                break;

              case 47:
                _context7.prev = 47;
                _context7.t0 = _context7["catch"](0);
                this.isExecuting = false;
                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].report("taskSchedule\u6267\u884C\u51FA\u9519".concat(Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* isError */ "r"])(_context7.t0)), 'error');
                this.multiPlatformTaskStatus('idle'); // 异常情况下也要设置重试定时器，确保任务调度能够恢复

                this.scheduleRetryTimer();

              case 53:
              case "end":
                return _context7.stop();
            }
          }
        }, _callee7, this, [[0, 47]]);
      }));

      function taskSchedule() {
        return _taskSchedule.apply(this, arguments);
      }

      return taskSchedule;
    }()
    /**
     * @description 执行当前指针指向的任务
     * @returns {boolean} 是否执行了任务
     */

  }, {
    key: "executeCurrentTask",
    value: function () {
      var _executeCurrentTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
        var group, task;
        return _regeneratorRuntime().wrap(function _callee8$(_context8) {
          while (1) {
            switch (_context8.prev = _context8.next) {
              case 0:
                if (this.currentGroupPointer) {
                  _context8.next = 2;
                  break;
                }

                return _context8.abrupt("return", false);

              case 2:
                group = this.taskGroups[this.currentGroupPointer];

                if (!(!group || !group.tasks || this.currentTaskPointer >= group.tasks.length)) {
                  _context8.next = 5;
                  break;
                }

                return _context8.abrupt("return", false);

              case 5:
                task = group.tasks[this.currentTaskPointer]; // 检查任务是否可执行

                _context8.t1 = !this.isTaskExecutable(task);

                if (_context8.t1) {
                  _context8.next = 11;
                  break;
                }

                _context8.next = 10;
                return this.discontinue();

              case 10:
                _context8.t1 = _context8.sent;

              case 11:
                _context8.t0 = _context8.t1;

                if (_context8.t0) {
                  _context8.next = 16;
                  break;
                }

                _context8.next = 15;
                return this.canRunTask(task);

              case 15:
                _context8.t0 = !_context8.sent;

              case 16:
                if (!_context8.t0) {
                  _context8.next = 18;
                  break;
                }

                return _context8.abrupt("return", false);

              case 18:
                if (!this.isTaskExecutedInCurrentRound(this.currentGroupPointer, task.task_id)) {
                  _context8.next = 20;
                  break;
                }

                return _context8.abrupt("return", false);

              case 20:
                // 标记任务在当前轮次已执行
                this.markTaskExecutedInRound(this.currentGroupPointer, task.task_id); // 执行任务

                _context8.next = 23;
                return this.executeTask(task);

              case 23:
                return _context8.abrupt("return", true);

              case 24:
              case "end":
                return _context8.stop();
            }
          }
        }, _callee8, this);
      }));

      function executeCurrentTask() {
        return _executeCurrentTask.apply(this, arguments);
      }

      return executeCurrentTask;
    }()
    /**
     * @description 查找当前分组优先级最高的一条未在本轮执行过的任务指针（优先级已按顺序排列）
     */

  }, {
    key: "findHighestPriorityTaskInGroup",
    value: function findHighestPriorityTaskInGroup(curGroup) {
      var _this7 = this;

      var group = this.taskGroups[curGroup];
      if (!group || !group.tasks) return -1;
      return group.tasks.findIndex(function (task) {
        return _this7.isTaskExecutable(task) && !_this7.isTaskExecutedInCurrentRound(curGroup, task.task_id);
      });
    }
    /**
     * @description 移动指针到下一个任务
     */

  }, {
    key: "moveToNextTask",
    value: function moveToNextTask() {
      if (!this.currentGroupPointer) {
        this.initPointer();
        return false;
      }

      var group = this.taskGroups[this.currentGroupPointer];

      if (!group || !group.tasks) {
        _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("[\u5F53\u524D\u7EC4]\u6CA1\u6709\u4EFB\u52A1\uFF0C\u79FB\u52A8\u5230\u4E0B\u4E00\u4E2A\u5206\u7EC4\uFF1A".concat(this.currentGroupPointer));
        this.moveToNextGroup();
        return true;
      } // 查找当前组还未在本轮次执行的任务


      var taskIndex = this.findHighestPriorityTaskInGroup(this.currentGroupPointer);

      if (taskIndex === -1) {
        _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("[\u5F53\u524D\u7EC4]\u6CA1\u6709\u53EF\u6267\u884C\u4EFB\u52A1\uFF0C\u51C6\u5907\u79FB\u52A8\u5230\u4E0B\u4E00\u4E2A\u5206\u7EC4");
        this.moveToNextGroup();
        return true;
      }

      this.currentTaskPointer = taskIndex;
      _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("\u79FB\u52A8\u5230\u4E0B\u4E00\u4E2A\u4EFB\u52A1\uFF1A".concat(group.tasks[taskIndex].task_id, " \u5E97\u94FA\uFF1A").concat(this.currentGroupPointer));
      return true;
    }
    /**
     * @description 移动指针到下一个分组
     */

  }, {
    key: "moveToNextGroup",
    value: function moveToNextGroup() {
      var currentIndex = this.orderedKeys.indexOf(this.currentGroupPointer);

      if (currentIndex === -1 || currentIndex >= this.orderedKeys.length - 1) {
        // 已经是最后一个分组，检查是否需要开始新轮次
        this.checkAndStartNewRound();
      } else {
        // 移动到下一个分组
        this.currentGroupPointer = this.orderedKeys[currentIndex + 1];
        this.currentTaskPointer = 0;
      }
    }
    /**
     * @description 检查并开始新轮次
     */

  }, {
    key: "checkAndStartNewRound",
    value: function checkAndStartNewRound() {
      var _this8 = this;

      // 检查是否所有分组都完成了当前轮次
      var allGroupsComplete = this.orderedKeys.every(function (key) {
        return _this8.isGroupRoundComplete(key);
      });

      if (allGroupsComplete) {
        // 开始新轮次
        _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('所有分组都完成了当前轮次，开始新轮次');
        this.startNewExecutionRound();
      } // 重置到第一个分组


      this.currentGroupPointer = this.orderedKeys.length > 0 ? this.orderedKeys[0] : null;
      this.currentTaskPointer = 0;
    }
    /**
     * @description 查找下一个可执行任务
     * @returns {boolean} 是否找到可执行任务
     */

  }, {
    key: "findNextExecutableTask",
    value: function findNextExecutableTask() {
      console.log("\n      \u5F00\u59CB\u67E5\u627E\u4E0B\u4E00\u4E2A\u53EF\u6267\u884C\u4EFB\u52A1\n      \u5F53\u524D\u6240\u5728\u7EC4\uFF1A".concat(this.currentGroupPointer, "\n      \u6267\u884C\u987A\u5E8F\uFF1A\n      "), this.orderedKeys, '当前任务组列表：', this.taskGroups);

      if (!this.currentGroupPointer || this.orderedKeys.length === 0) {
        return false;
      } // 查找当前组还未在本轮次执行的任务


      var taskIndex = this.findHighestPriorityTaskInGroup(this.currentGroupPointer);

      if (taskIndex > -1) {
        this.currentTaskPointer = taskIndex;
        var task = this.taskGroups[this.currentGroupPointer].tasks[this.currentTaskPointer];
        _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("[\u5F53\u524D\u7EC4]\u627E\u5230\u53EF\u6267\u884C\u4EFB\u52A1\uFF1A".concat(task.task_id, " \u5E97\u94FA\uFF1A").concat(this.currentGroupPointer));
        return true;
      } // 从开头查找，直到找到可执行任务


      for (var groupIndex = 0; groupIndex < this.orderedKeys.length; groupIndex++) {
        var groupKey = this.orderedKeys[groupIndex]; // 跳过当前组

        if (this.currentGroupPointer === groupKey) {
          continue;
        }

        var group = this.taskGroups[groupKey];
        if (!group || !group.tasks) continue;

        for (var _taskIndex = 0; _taskIndex < group.tasks.length; _taskIndex++) {
          var _task = group.tasks[_taskIndex];

          if (this.isTaskExecutable(_task) && !this.isTaskExecutedInCurrentRound(groupKey, _task.task_id)) {
            // 找到可执行任务，更新指针
            this.currentGroupPointer = groupKey;
            this.currentTaskPointer = _taskIndex;
            _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("[\u5F53\u524D\u8F6E\u6B21]\u627E\u5230\u53EF\u6267\u884C\u4EFB\u52A1\uFF1A".concat(_task.task_id, " \u5E97\u94FA\uFF1A").concat(groupKey));
            return true;
          }
        }
      }

      return false; // 没有找到可执行任务
    }
    /**
     * @description 执行单个任务
     * @param {Object} task 任务对象
     * @param {string} groupKey 分组key
     * @param {number} taskIndex 任务索引
     */

  }, {
    key: "executeTask",
    value: function () {
      var _executeTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(task) {
        var _multiPlatform$taskTy, res, taskHandler, errorCode, _yield$multiPlatformO, onlineSiteStatus, mall, msg;

        return _regeneratorRuntime().wrap(function _callee9$(_context9) {
          while (1) {
            switch (_context9.prev = _context9.next) {
              case 0:
                _context9.prev = 0;
                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("\u5F00\u59CB\u6267\u884C\u4EFB\u52A1\uFF0C\u5F53\u524D\u6240\u5728\u7EC4\uFF1A".concat(this.currentGroupPointer));
                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("\u5F53\u524D\u6267\u884C\u4EFB\u52A1".concat(((_multiPlatform$taskTy = _index__WEBPACK_IMPORTED_MODULE_4__[/* multiPlatform */ "a"].taskTypesMap[task.type_id]) === null || _multiPlatform$taskTy === void 0 ? void 0 : _multiPlatform$taskTy.taskName) || task.type_id, "\n        --task_id:").concat(task.task_id, "\n        --type_id:").concat(task.type_id, "\n        --platform_store_id:").concat(task.platform_store_id, "\n        --report_date_month:").concat(task.report_date_month, "\n        ")); // 设置任务状态

                this.multiPlatformTaskStatus(task.type_id);
                task.isRun = true;

                if (task.status !== 6) {
                  task.status = 0;
                }

                !task.startTime && (task.startTime = Date.now()); // 延时执行

                _context9.next = 9;
                return Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* delayed */ "g"])(Math.ceil(Math.random() * this.sleepTime));

              case 9:
                taskHandler = _taskType__WEBPACK_IMPORTED_MODULE_5__[/* multiTskHandleMap */ "b"][task.type_id];

                if (!(!taskHandler || !taskHandler.handle)) {
                  _context9.next = 15;
                  break;
                }

                task.msg = '未找到任务处理器';
                task.isDelete = true;
                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].report(task.msg, 'error', task);
                return _context9.abrupt("return");

              case 15:
                errorCode = task.repeat > 0 ? 4 : 1; // 检查站点状态并执行任务

                _context9.next = 18;
                return Object(_index__WEBPACK_IMPORTED_MODULE_4__[/* multiPlatformOnlineSite */ "g"])(task);

              case 18:
                _yield$multiPlatformO = _context9.sent;
                onlineSiteStatus = _yield$multiPlatformO.onlineSiteStatus;
                mall = _yield$multiPlatformO.mall;
                msg = _yield$multiPlatformO.msg;

                if (!(onlineSiteStatus === 1)) {
                  _context9.next = 34;
                  break;
                }

                _context9.next = 25;
                return Object(_index__WEBPACK_IMPORTED_MODULE_4__[/* multiPlatformChangeSite */ "b"])(task);

              case 25:
                _context9.t0 = _context9.sent;

                if (!_context9.t0) {
                  _context9.next = 30;
                  break;
                }

                _context9.next = 29;
                return _taskType__WEBPACK_IMPORTED_MODULE_5__[/* cores */ "a"][taskHandler.handle](task);

              case 29:
                _context9.t0 = _context9.sent;

              case 30:
                res = _context9.t0;
                res ? res.code !== 0 && ++task.error_time : task.isDelete = true;
                _context9.next = 35;
                break;

              case 34:
                if (onlineSiteStatus === 2) {
                  // 站点离线
                  task.error_time = this.retryConfig.maxRetryCount;
                  task.status = 11;
                  task.msg = '店铺离线，请登录Temu卖家中心';
                  res = {
                    code: errorCode,
                    msg: task.msg,
                    result: null
                  };
                } else if (onlineSiteStatus === 3) {
                  // 店铺被切换
                  task.error_time = this.retryConfig.maxRetryCount;
                  task.status = 11;
                  task.msg = "\u5E97\u94FA\u5DF2\u88AB\u5207\u6362,\u5F53\u524D\u5E97\u94FA:".concat(mall);
                  res = {
                    code: errorCode,
                    msg: task.msg,
                    result: null
                  };
                } else {
                  // 其他异常
                  task.error_time = this.retryConfig.maxRetryCount;
                  task.status = 16;
                  task.msg = msg;
                  res = {
                    code: errorCode,
                    msg: msg,
                    result: null
                  };
                }

              case 35:
                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('获取结果', JSON.stringify(res)); // 上传结果

                _context9.t1 = res;

                if (!_context9.t1) {
                  _context9.next = 41;
                  break;
                }

                _context9.next = 40;
                return this.discontinue();

              case 40:
                _context9.t1 = !_context9.sent;

              case 41:
                if (!_context9.t1) {
                  _context9.next = 44;
                  break;
                }

                _context9.next = 44;
                return MultiPlatformTaskV2.uploadTask(res, task);

              case 44:
                // 记录结束时间
                task.endTime = Date.now();
                _context9.next = 52;
                break;

              case 47:
                _context9.prev = 47;
                _context9.t2 = _context9["catch"](0);
                task.error_time++;
                task.endTime = Date.now();
                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].report("\n        \u4EFB\u52A1\u6267\u884C\u51FA\u9519: ".concat(Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* isError */ "r"])(_context9.t2), "\n        --type_id:").concat(task.type_id, "\n        --task_id:").concat(task.task_id, "\n        "), 'error');

              case 52:
              case "end":
                return _context9.stop();
            }
          }
        }, _callee9, this, [[0, 47]]);
      }));

      function executeTask(_x4) {
        return _executeTask.apply(this, arguments);
      }

      return executeTask;
    }()
    /**
     * @description 执行repeat任务
     */

  }, {
    key: "runRepeat",
    value: function () {
      var _runRepeat = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
        var repeatTaskList, typeId, taskList, _iterator3, _step3, task;

        return _regeneratorRuntime().wrap(function _callee10$(_context10) {
          while (1) {
            switch (_context10.prev = _context10.next) {
              case 0:
                try {
                  repeatTaskList = [];

                  for (typeId in this.repeatMap) {
                    taskList = this.repeatMap[typeId] || [];
                    _iterator3 = _createForOfIteratorHelper(taskList);

                    try {
                      for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
                        task = _step3.value;
                        task.count++;

                        if (task.repeat <= _config__WEBPACK_IMPORTED_MODULE_3__[/* POLLING_TIME */ "c"] * task.count) {
                          _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("[".concat(moment__WEBPACK_IMPORTED_MODULE_0___default()().format('YYYY-MM-DD HH:mm:ss'), "]\u5F00\u59CB\u6267\u884C\u91CD\u590D\u4EFB\u52A1\uFF0Ctype_id\uFF1A").concat(task.type_id, "\uFF0Ctask_id\uFF1A").concat(task.task_id));
                          task.count = 0;
                          repeatTaskList.push(task);
                        }
                      }
                    } catch (err) {
                      _iterator3.e(err);
                    } finally {
                      _iterator3.f();
                    }
                  }

                  this.initTaskList(repeatTaskList);
                } catch (e) {
                  _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].report("\u6267\u884Crepeat\u4EFB\u52A1\u9519\u8BEF----".concat(Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* isError */ "r"])(e)), 'error');
                }

              case 1:
              case "end":
                return _context10.stop();
            }
          }
        }, _callee10, this);
      }));

      function runRepeat() {
        return _runRepeat.apply(this, arguments);
      }

      return runRepeat;
    }()
    /**
     * @description 清理已完成的任务
     */

  }, {
    key: "clearTaskList",
    value: function clearTaskList() {
      var _this9 = this;

      _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('开始清理任务、恢复指针'); // 清理每个分组中的已完成任务

      var _loop3 = function _loop3() {
        var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i5], 2),
            key = _Object$entries3$_i[0],
            group = _Object$entries3$_i[1];

        var isExistMap = {};
        group.tasks = group.tasks.filter(function (task) {
          // 只留一条已执行过的覆盖任务
          if (!_this9.notCoverTypes.includes(+task.type_id) && isExistMap[task.type_id]) return false;
          isExistMap[task.type_id] = true;
          return !task.isDelete;
        });

        if (group.tasks.length === 0) {
          delete _this9.taskGroups[key];
          _this9.orderedKeys = _this9.orderedKeys.filter(function (k) {
            return k !== key;
          });
        }
      };

      for (var _i5 = 0, _Object$entries3 = Object.entries(this.taskGroups); _i5 < _Object$entries3.length; _i5++) {
        _loop3();
      } // 恢复指针


      this.fixPointersAfterCleanup();
    }
  }, {
    key: "fixPointersAfterCleanup",
    value: function fixPointersAfterCleanup() {
      this.currentGroupPointer = this.orderedKeys.length > 0 ? this.orderedKeys[0] : null;
      this.currentTaskPointer = 0;
    }
    /**
     * @description 获取/设置任务执行状态
     * @param {*} type 任务类型
     * @returns {string|boolean} 状态名称或设置结果
     */

  }, {
    key: "multiPlatformTaskStatus",
    value: function multiPlatformTaskStatus(type) {
      if (type) {
        this.taskStatus = type;
      } else {
        var _multiPlatform$taskTy2;

        return this.taskStatus === 'idle' ? false : ((_multiPlatform$taskTy2 = _index__WEBPACK_IMPORTED_MODULE_4__[/* multiPlatform */ "a"].taskTypesMap[this.taskStatus]) === null || _multiPlatform$taskTy2 === void 0 ? void 0 : _multiPlatform$taskTy2.taskName) || this.taskStatus;
      }
    }
    /**
     * @description 检查是否应该暂停
     * @returns {boolean} 是否暂停
     */

  }, {
    key: "discontinue",
    value: function () {
      var _discontinue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
        return _regeneratorRuntime().wrap(function _callee11$(_context11) {
          while (1) {
            switch (_context11.prev = _context11.next) {
              case 0:
                _context11.next = 2;
                return Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* suspend */ "E"])();

              case 2:
                if (!_context11.sent) {
                  _context11.next = 5;
                  break;
                }

                this.multiPlatformTaskStatus('idle');
                return _context11.abrupt("return", true);

              case 5:
                return _context11.abrupt("return", false);

              case 6:
              case "end":
                return _context11.stop();
            }
          }
        }, _callee11, this);
      }));

      function discontinue() {
        return _discontinue.apply(this, arguments);
      }

      return discontinue;
    }()
    /**
     * @description 销毁实例
     */

  }, {
    key: "destroyed",
    value: function destroyed() {
      this.taskGroups = {};
      this.orderedKeys = [];
      this.repeatMap = {};
      this.roundExecutionRecord = {};
      this.multiPlatformTaskStatus('idle');
      this.clearRetryTimer();
    }
  }], [{
    key: "generateStoreMonthKey",
    value:
    /**
     * @description 生成店铺+月份组合key
     * @param {string} storeId 店铺ID
     * @param {string} monthId 月份
     * @returns {string} 组合key
     */
    function generateStoreMonthKey(storeId, monthId) {
      return "".concat(storeId, "_").concat(monthId || 'default');
    }
    /**
     * @description 解析店铺+月份组合key
     * @param {string} key 组合key
     * @returns {object} {storeId, monthId}
     */

  }, {
    key: "parseStoreMonthKey",
    value: function parseStoreMonthKey(key) {
      var _key$split = key.split('_'),
          _key$split2 = _slicedToArray(_key$split, 2),
          storeId = _key$split2[0],
          monthId = _key$split2[1];

      return {
        storeId: storeId,
        monthId: monthId === 'default' ? null : monthId
      };
    }
    /**
     * @description 上传任务执行结果到服务器
     * @param {Object} params 上传参数
     * @param {Object} task 任务对象
     * @param {number} count 重试次数
     */

  }, {
    key: "uploadTask",
    value: function () {
      var _uploadTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params, task) {
        var count,
            res,
            _args12 = arguments;
        return _regeneratorRuntime().wrap(function _callee12$(_context12) {
          while (1) {
            switch (_context12.prev = _context12.next) {
              case 0:
                count = _args12.length > 2 && _args12[2] !== undefined ? _args12[2] : 0;
                _context12.next = 3;
                return Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* gatePost */ "l"])("api/mp/reportTask", _objectSpread({
                  task_id: task.task_id,
                  type_id: task.type_id,
                  platform_store_id: task.platform_store_id,
                  taskIdList: task.taskIdList
                }, params), 'task').catch(function (e) {
                  _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('上传错误：', Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* isError */ "r"])(e));
                });

              case 3:
                res = _context12.sent;
                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('上传结果：', JSON.stringify(res));

                if (!(res && res.code === 0)) {
                  _context12.next = 9;
                  break;
                }

                if (params.code === 0) {
                  // 上传成功，修改状态
                  task.status = 1;
                  task.uploadTime = moment__WEBPACK_IMPORTED_MODULE_0___default()().format('YYYY-MM-DD HH:mm:ss');
                }

                _context12.next = 23;
                break;

              case 9:
                if (!(res && res.code === 3002)) {
                  _context12.next = 15;
                  break;
                }

                // 任务不存在或已删除，直接删掉任务
                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("task_id:".concat(task.task_id, " - ").concat(res.msg));
                task.isDelete = true;
                task.msg = res.msg;
                _context12.next = 23;
                break;

              case 15:
                if (!(count < 2)) {
                  _context12.next = 22;
                  break;
                }

                _context12.next = 18;
                return Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* delayed */ "g"])(5 * 1000);

              case 18:
                _context12.next = 20;
                return MultiPlatformTaskV2.uploadTask(params, task, ++count);

              case 20:
                _context12.next = 23;
                break;

              case 22:
                if (params.code === 0) {
                  // 上传失败，修改状态
                  task.status = 7;
                  task.error_time++;
                  task.msg = '上传失败';
                  task.resCache = params;
                }

              case 23:
              case "end":
                return _context12.stop();
            }
          }
        }, _callee12);
      }));

      function uploadTask(_x5, _x6) {
        return _uploadTask.apply(this, arguments);
      }

      return uploadTask;
    }()
  }]);

  return MultiPlatformTaskV2;
}();

/* harmony default export */ __webpack_exports__["a"] = (MultiPlatformTaskV2);

/***/ }),

/***/ "6b26":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"13207ec7-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/popup/App/MultiPlatform/Task.vue?vue&type=template&id=76bb3dbd&scoped=true&
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"task-contain"},[_c('div',{staticClass:"title"},[_c('div',{staticClass:"get-task"},[_c('span',{staticClass:"suspend-btn"},[_vm._v("\n        获取任务：\n        "),_c('el-radio-group',{on:{"change":_vm.handleDialogVisible},model:{value:(_vm.statusRadio),callback:function ($$v) {_vm.statusRadio=$$v},expression:"statusRadio"}},[_c('el-radio',{attrs:{"label":1,"disabled":_vm.dialogVisible}},[_vm._v("开启")]),_c('el-radio',{attrs:{"label":0,"disabled":_vm.dialogVisible}},[_vm._v("暂停")])],1)],1)]),_c('div',[_c('span',{staticClass:"refresh-btn",on:{"click":function($event){return _vm.$emit('changePage','temuCustom')}}},[_vm._v("自定义获取")])]),_c('div',{staticStyle:{"font-size":"12px","margin-left":"10px"}},[_c('span',[_vm._v("注：当前服务器下发任务时间已调整到晚上9:00至早上9:00，请保持浏览器开启。如需立即获取点击【"),_c('span',{staticClass:"refresh-btn",staticStyle:{"margin-right":"8px"},on:{"click":_vm.imfre}},[_vm._v("立即获取")]),_vm._v("】")])])]),_c('div',{staticClass:"ak-pd-left-8 ak-pd-right-8 task-wrap"},[(_vm.reportTasks && _vm.reportTasks.length)?[_c('div',{staticClass:"task-list",style:({'max-height': _vm.offlineTips ? '330px' : '360px'})},_vm._l((_vm.reportTasks),function(item){return _c('div',{key:item.task_id},[_c('transition',{attrs:{"name":"el-zoom-in-top"}},[(_vm.multiTskHandleMap[item.type_id] && _vm.multiTskHandleMap[item.type_id].component)?_c('div',{staticClass:"task-item"},[_c(_vm.multiTskHandleMap[item.type_id].component,{tag:"component",attrs:{"task":item,"reportType":_vm.multiTskHandleMap[item.type_id].name}}),(item.status == 0 && !item.isRun)?_c('span',{staticClass:"el-icon-close",on:{"click":function($event){return _vm.deleteTask(item)}}}):_vm._e()],1):_vm._e()])],1)}),0)]:_c('div',{staticClass:"seller-contain"},[_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.showTopTip && _vm.refreshTime>0),expression:"showTopTip && refreshTime>0"}],staticClass:"top-tip"},[_vm._v("\n        "+_vm._s(Math.round(_vm.refreshTime / 1000))+"秒后再点击获取哦~\n      ")]),_c('img',{attrs:{"src":__webpack_require__("e04f")}}),_c('p',{directives:[{name:"show",rawName:"v-show",value:(!_vm.hasRefresh),expression:"!hasRefresh"}]},[_vm._v("暂无报告获取记录")]),_c('p',{directives:[{name:"show",rawName:"v-show",value:(_vm.hasRefresh),expression:"hasRefresh"}]},[_vm._v("暂时没有可以获取的报告哦~")]),_c('span',{directives:[{name:"show",rawName:"v-show",value:(!_vm.hasRefresh),expression:"!hasRefresh"}],staticClass:"text-btn",on:{"click":_vm.refresh}},[_vm._v("立即获取")])])],2),_c('el-dialog',{attrs:{"visible":_vm.dialogVisible,"show-close":false,"center":true,"width":"70%","title":"获取任务","top":"30vh","custom-class":"dialog-class","close-on-click-modal":false,"close-on-press-escape":false},on:{"update:visible":function($event){_vm.dialogVisible=$event}}},[_c('span',{staticClass:"dialog-content"},[_vm._v("确认"+_vm._s(_vm.statusRadio ? '开启' : '暂停')+"获取当前任务")]),_c('span',{staticClass:"dialog-footer",attrs:{"slot":"footer"},slot:"footer"},[_c('el-button',{attrs:{"size":"small","plain":""},on:{"click":function($event){return _vm.handleDialogFooter('cancel')}}},[_vm._v("取 消")]),_c('el-button',{attrs:{"size":"small","type":"primary"},on:{"click":function($event){return _vm.handleDialogFooter('confirm')}}},[_vm._v("确 定")])],1)])],1)}
var staticRenderFns = []


// CONCATENATED MODULE: ./src/popup/App/MultiPlatform/Task.vue?vue&type=template&id=76bb3dbd&scoped=true&

// EXTERNAL MODULE: ./src/utils/util.js
var util = __webpack_require__("ca00");

// EXTERNAL MODULE: ./src/config.js
var config = __webpack_require__("db49");

// EXTERNAL MODULE: ./src/platform/common/taskType.js + 14 modules
var taskType = __webpack_require__("2f79");

// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/popup/App/MultiPlatform/Task.vue?vue&type=script&lang=js&
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
var timer;



/* harmony default export */ var Taskvue_type_script_lang_js_ = ({
  name: 'task',
  props: {
    offlineTips: {
      type: Boolean,
      default: false
    }
  },
  components: {
    SupplierPrice: function SupplierPrice() {
      return __webpack_require__.e(/* import() */ "chunk-42908338").then(__webpack_require__.bind(null, "4918"));
    },
    SaleVolume: function SaleVolume() {
      return __webpack_require__.e(/* import() */ "chunk-0be301f2").then(__webpack_require__.bind(null, "c042"));
    },
    ReverseReport: function ReverseReport() {
      return __webpack_require__.e(/* import() */ "chunk-41aa9416").then(__webpack_require__.bind(null, "6515"));
    }
  },
  computed: {
    reportTasks: function reportTasks() {
      return this.taskList ? this.taskList.filter(function (_ref) {
        var isDelete = _ref.isDelete;
        return !isDelete;
      }) : [];
    },
    taskList: {
      set: function set(val) {
        var multiPlatformData = this.$bg.multiPlatform;
        multiPlatformData.multiPlatformTaskInstance && (multiPlatformData.multiPlatformTaskInstance = val);
      },
      get: function get() {
        var multiPlatformTaskInstance = this.$bg.multiPlatform && this.$bg.multiPlatform.multiPlatformTaskInstance;
        return multiPlatformTaskInstance && multiPlatformTaskInstance.taskList;
      }
    }
  },
  data: function data() {
    return {
      multiTskHandleMap: taskType["b" /* multiTskHandleMap */],
      hasRefresh: false,
      refreshTime: 0,
      showTopTip: false,
      statusList: config["l" /* statusList */],
      statusRadio: 1,
      dialogVisible: false
    };
  },
  methods: {
    handleDialogVisible: function handleDialogVisible() {
      var _this = this;

      return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
        return _regeneratorRuntime().wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                _this.dialogVisible = true;

              case 1:
              case "end":
                return _context.stop();
            }
          }
        }, _callee);
      }))();
    },
    deleteTask: function deleteTask(task) {
      var _this2 = this;

      return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
        var res;
        return _regeneratorRuntime().wrap(function _callee2$(_context2) {
          while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                _context2.next = 2;
                return Object(util["l" /* gatePost */])("api/mp/delTask", {
                  task_id: task.task_id
                }, 'task').catch(function () {});

              case 2:
                res = _context2.sent;

                if (res && res.code === 0) {
                  // 火狐浏览器需要将原列表状态改变
                  // if (isFirefox()) {
                  //   this.$bg.task.taskList.forEach(item => {
                  //     if (item.task_id === task.task_id) item.isDelete = true
                  //   })
                  // }
                  chrome.runtime.sendMessage({
                    type: 'deleteTask',
                    params: {
                      taskId: task.task_id,
                      platform: 'temu'
                    }
                  }, function () {});

                  _this2.$message.success({
                    showClose: true,
                    message: '删除成功',
                    duration: 1000
                  });
                } else {
                  _this2.$message.error({
                    showClose: true,
                    message: res ? res.msg : '删除失败',
                    duration: 3000
                  });
                }

              case 4:
              case "end":
                return _context2.stop();
            }
          }
        }, _callee2);
      }))();
    },
    // 立即刷新
    imfre: function imfre() {
      var _this3 = this;

      return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
        return _regeneratorRuntime().wrap(function _callee3$(_context3) {
          while (1) {
            switch (_context3.prev = _context3.next) {
              case 0:
                // 停止中断
                _this3.statusRadio = 1;
                Object(util["E" /* suspend */])(1);

                _this3.getMainData();

              case 3:
              case "end":
                return _context3.stop();
            }
          }
        }, _callee3);
      }))();
    },

    /**
     * @description 立即执行主任务
     */
    getMainData: function getMainData() {
      return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
        return _regeneratorRuntime().wrap(function _callee4$(_context4) {
          while (1) {
            switch (_context4.prev = _context4.next) {
              case 0:
                chrome.runtime.sendMessage({
                  type: 'getTaskList',
                  params: {
                    platform: 'temu'
                  }
                }, function () {});

              case 1:
              case "end":
                return _context4.stop();
            }
          }
        }, _callee4);
      }))();
    },
    refresh: function refresh() {
      var _this4 = this;

      return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
        var type, _yield$localStorage$g, refresh;

        return _regeneratorRuntime().wrap(function _callee5$(_context5) {
          while (1) {
            switch (_context5.prev = _context5.next) {
              case 0:
                if (!(_this4.refreshTime > 0)) {
                  _context5.next = 3;
                  break;
                }

                _this4.showTopTip = true;
                return _context5.abrupt("return");

              case 3:
                // 停止中断
                _this4.statusRadio = 1;
                Object(util["E" /* suspend */])(1);
                type = 1;
                _context5.next = 8;
                return util["t" /* localStorage */].getItem(['refresh']);

              case 8:
                _yield$localStorage$g = _context5.sent;
                refresh = _yield$localStorage$g.refresh;

                if (!refresh) {
                  type = 3;
                  util["t" /* localStorage */].setItem({
                    refresh: 1
                  });
                }

                chrome.runtime.sendMessage({
                  type: 'getTaskList',
                  params: {
                    platform: 'temu'
                  }
                }, function () {
                  _this4.hasRefresh = true;
                  _this4.refreshTime = 60 * 1000;
                  util["t" /* localStorage */].setItem({
                    refresh_time: Date.now()
                  });
                  timer = setInterval(function () {
                    _this4.refreshTime -= 200;
                    if (_this4.refreshTime < 0) clearInterval(timer);
                  }, 200);
                  setTimeout(function () {
                    _this4.hasRefresh = false;
                  }, 1000 * 3);
                });

              case 12:
              case "end":
                return _context5.stop();
            }
          }
        }, _callee5);
      }))();
    },
    // dialog按钮回调
    handleDialogFooter: function handleDialogFooter(type) {
      this.dialogVisible = false;

      if (type === 'cancel') {
        this.statusRadio = this.statusRadio ? 0 : 1;
        return;
      } // 开启执行，触发任务调度


      if (this.statusRadio) {
        var _type = {
          amazon: 'goExecute',
          temu: 'goExecuteTemu'
        }[this.$root.platform];
        chrome.runtime.sendMessage({
          type: _type
        }, function () {});
      } // 如果是中断则设置一年有效期


      Object(util["E" /* suspend */])(this.statusRadio ? 1 : 60 * 1000 * 60 * 24 * 365, '99', 'popup');
    }
  },
  created: function created() {
    var _this5 = this;

    return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
      var multiPlatform, _yield$localStorage$g2, refresh_time, ctime, suspendStatus;

      return _regeneratorRuntime().wrap(function _callee6$(_context6) {
        while (1) {
          switch (_context6.prev = _context6.next) {
            case 0:
              if (_this5.$root.platform === 'amazon') {
                if (!_this5.$bg.amazon.sellerId) {
                  _this5.$emit('changePage', 'no-seller');
                }
              } else {
                multiPlatform = _this5.$bg.multiPlatform || {};

                if (!multiPlatform.storeInfo || !multiPlatform.storeInfo.length) {
                  _this5.$emit('changePage', 'no-seller');
                }
              }

              _context6.next = 3;
              return util["t" /* localStorage */].getItem(['refresh_time']);

            case 3:
              _yield$localStorage$g2 = _context6.sent;
              refresh_time = _yield$localStorage$g2.refresh_time;

              if (refresh_time) {
                ctime = 60 * 1000 - (Date.now() - refresh_time);
                _this5.refreshTime = ctime < 0 ? 0 : ctime;
              } // 初始化中断状态


              _context6.next = 8;
              return Object(util["E" /* suspend */])();

            case 8:
              suspendStatus = _context6.sent;
              _this5.statusRadio = suspendStatus ? 0 : 1;

            case 10:
            case "end":
              return _context6.stop();
          }
        }
      }, _callee6);
    }))();
  }
});
// CONCATENATED MODULE: ./src/popup/App/MultiPlatform/Task.vue?vue&type=script&lang=js&
 /* harmony default export */ var MultiPlatform_Taskvue_type_script_lang_js_ = (Taskvue_type_script_lang_js_); 
// EXTERNAL MODULE: ./src/popup/App/MultiPlatform/Task.vue?vue&type=style&index=0&id=76bb3dbd&lang=scss&scoped=true&
var Taskvue_type_style_index_0_id_76bb3dbd_lang_scss_scoped_true_ = __webpack_require__("a7c5");

// EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
var componentNormalizer = __webpack_require__("2877");

// CONCATENATED MODULE: ./src/popup/App/MultiPlatform/Task.vue






/* normalize component */

var component = Object(componentNormalizer["a" /* default */])(
  MultiPlatform_Taskvue_type_script_lang_js_,
  render,
  staticRenderFns,
  false,
  null,
  "76bb3dbd",
  null
  
)

/* harmony default export */ var Task = __webpack_exports__["default"] = (component.exports);

/***/ }),

/***/ "9224":
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ }),

/***/ "a1d0":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return multiPlatform; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return multiPlatformInit; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return multiPlatformInitTask; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return multiPlatformInitSite; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return multiPlatformOnlineSite; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return multiPlatformChangeSite; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return multiPlatformTaskClear; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return multiPlatformClear; });
/* harmony import */ var _data_task__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("cec6");
/* harmony import */ var _utils_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("ca00");
/* harmony import */ var _data_log__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("6b23");
/* harmony import */ var _utils_event__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("42a5");
/* harmony import */ var _utils_websocket__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("b2eb");
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("db49");
/* harmony import */ var _newTask__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("5e61");
/* harmony import */ var _temu__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__("c04e");
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }










var multiPlatform = {
  refreshing: false,
  // 店铺信息
  storeInfo: [],
  // 用于显示在弹窗上的店铺信息
  storeInfoOfExhibition: [],
  // 平台code
  platformCode: '',
  // 多平台任务管理实例
  multiPlatformTaskInstance: null,
  // 离线店铺
  offlineSite: [],
  // 需要在cbGlobalHost域名下执行的任务
  globalHostOfTypeId: [22002, 22008, 22001, 22010, 22016, 22011, 22017],
  // 任务类型
  taskTypes: [],
  // 任务类型映射
  taskTypesMap: {},
  // 定时任务是否开启
  enableTimerTask: 1
};

var getTaskType = /*#__PURE__*/function () {
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
    var _yield$gatePost$catch, code, data;

    return _regeneratorRuntime().wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.prev = 0;
            _context.next = 3;
            return Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* gatePost */ "l"])('api/mp/getTaskTypes', {
              platform_code: multiPlatform.platformCode
            }, 'task').catch(function () {});

          case 3:
            _yield$gatePost$catch = _context.sent;
            code = _yield$gatePost$catch.code;
            data = _yield$gatePost$catch.data;

            if (code === 0) {
              multiPlatform.taskTypes = data.sort(function (a, b) {
                return b.priority - a.priority;
              });
              multiPlatform.taskTypesMap = {};
              multiPlatform.taskTypes.forEach(function (item) {
                item.list = [];
                multiPlatform.taskTypesMap[item.taskTypeId] = item;
              });
            }

            _context.next = 12;
            break;

          case 9:
            _context.prev = 9;
            _context.t0 = _context["catch"](0);
            _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('获取任务类型失败', Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* isError */ "r"])(_context.t0));

          case 12:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, null, [[0, 9]]);
  }));

  return function getTaskType() {
    return _ref.apply(this, arguments);
  };
}();

var multiPlatformInit = /*#__PURE__*/function () {
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
    var count,
        status,
        _args2 = arguments;
    return _regeneratorRuntime().wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            count = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : 0;
            // 先取消重试定时器，防止用户点击刷新时重复调用
            chrome.alarms.clear('multiPlatformInit'); // 检测版本

            Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* checkVersion */ "c"])(); // 检测插件是否可用

            _context2.next = 5;
            return _data_task__WEBPACK_IMPORTED_MODULE_0__[/* default */ "b"].checkEnable();

          case 5:
            status = _context2.sent;
            _utils_util__WEBPACK_IMPORTED_MODULE_1__[/* localStorage */ "t"].setItem({
              enableObj: {
                status: status
              }
            }); // 检测定时任务是否开启

            checkEnableTimerTask(); // 检测店铺

            _context2.next = 10;
            return multiPlatformInitSite();

          case 10:
            // 获取任务类型
            if (!multiPlatform.taskTypes.length) getTaskType();

            if (multiPlatform.storeInfo && multiPlatform.storeInfo.length) {
              multiPlatformInitTask();
            } else if (count < 3) {
              // 未检测到店铺时，重试三次
              _utils_util__WEBPACK_IMPORTED_MODULE_1__[/* alarms */ "b"].setTimeout(function () {
                _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("[\u68C0\u6D4B\u7AD9\u70B9]\u91CD\u8BD5\u7B2C".concat(count + 1, "\u6B21"));
                multiPlatformInit(++count);
              }, 'multiPlatformInit', 10 * 1000);
            }

          case 12:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));

  return function multiPlatformInit() {
    return _ref2.apply(this, arguments);
  };
}();
var multiPlatformInitTask = function multiPlatformInitTask() {
  if (multiPlatform.multiPlatformTaskInstance) return; // 连接websocket

  var storeIds = multiPlatform.storeInfo.map(function (item) {
    return "".concat(multiPlatform.platformCode, ":").concat(item);
  }).join(',');
  _utils_websocket__WEBPACK_IMPORTED_MODULE_4__[/* default */ "a"].init(storeIds); // 心跳检测

  checkHeartbeat(); // 初始化task实例

  multiPlatform.multiPlatformTaskInstance = new _newTask__WEBPACK_IMPORTED_MODULE_6__[/* default */ "a"](); // 监听推送

  Object(_utils_event__WEBPACK_IMPORTED_MODULE_3__[/* monitor */ "b"])('ReceivePush', receivePush);
  Object(_utils_event__WEBPACK_IMPORTED_MODULE_3__[/* monitor */ "b"])('GoExecuteTemu', goExecuteTemu); // 设置轮询

  setTimerLoop();
};
/**
   * @description 接收推送调度
   */

function receivePush(data) {
  if (multiPlatform.multiPlatformTaskInstance && (!data || !data.platformCode)) return;
  _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('[多平台]task.js接收到推送类型', data.type);

  switch (data.type) {
    case 6:
      multiPlatform.multiPlatformTaskInstance.initTaskList([data.content]);
      break;
    // case 8: this.handleDelete(data.content)
    // break

    case 10:
      multiPlatform.multiPlatformTaskInstance.getTaskList();
      break;
    // case 20: if (data.content == 0) task.clearAutoTaskList()
  }
}
/**
 * @description 任务恢复执行
 */


function goExecuteTemu() {
  _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('GoExecuteTemu');
  multiPlatform.multiPlatformTaskInstance.taskSchedule();
}

var getCheckSiteHandle = function getCheckSiteHandle() {
  var platform = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : multiPlatform.platformCode;
  return {
    10022: _temu__WEBPACK_IMPORTED_MODULE_7__[/* temuCheckSite */ "g"]
  }[platform]();
};
/**
 * @description 初始化-检测平台所有店铺
 */


var multiPlatformInitSite = /*#__PURE__*/function () {
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
    var _yield$localStorage$g, platform, online;

    return _regeneratorRuntime().wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            _context3.next = 2;
            return _utils_util__WEBPACK_IMPORTED_MODULE_1__[/* localStorage */ "t"].getItem(['platform']);

          case 2:
            _yield$localStorage$g = _context3.sent;
            platform = _yield$localStorage$g.platform;

            if (!multiPlatform.refreshing) {
              _context3.next = 9;
              break;
            }

            _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('正在检测站点');
            return _context3.abrupt("return", 'refreshing');

          case 9:
            multiPlatform.refreshing = true;

          case 10:
            multiPlatform.platformCode = _config__WEBPACK_IMPORTED_MODULE_5__[/* platformCodeMap */ "i"][platform];
            _context3.t0 = platform;
            _context3.next = _context3.t0 === 'temu' ? 14 : 22;
            break;

          case 14:
            _context3.next = 16;
            return getCheckSiteHandle();

          case 16:
            _context3.t1 = _context3.sent;

            if (_context3.t1) {
              _context3.next = 19;
              break;
            }

            _context3.t1 = [];

          case 19:
            multiPlatform.storeInfo = _context3.t1;
            multiPlatform.storeInfoOfExhibition = [].concat(_toConsumableArray(_temu__WEBPACK_IMPORTED_MODULE_7__[/* temu */ "f"].cbStoreInfo), _toConsumableArray(_temu__WEBPACK_IMPORTED_MODULE_7__[/* temu */ "f"].localStoreInfo));
            return _context3.abrupt("break", 22);

          case 22:
            // 清除离线店铺
            multiPlatform.offlineSite = [];
            _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('检测到站点----', JSON.stringify(multiPlatform.storeInfo));
            multiPlatform.refreshing = false;
            online = !!multiPlatform.storeInfo.length;
            return _context3.abrupt("return", online);

          case 27:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));

  return function multiPlatformInitSite() {
    return _ref3.apply(this, arguments);
  };
}();
/**
 * @description 执行任务时 - 检测店铺是否在线
 * @returns onlineSiteStatus: 判断店铺是否在线 1: 在线 2: 离线 3: 店铺id不一致,账号可能已被切换
 * @returns mall 当前检测到的店铺id or 店铺名
 */

var multiPlatformOnlineSite = /*#__PURE__*/function () {
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(task) {
    var res, platform_store_id, storeInfo, find, _storeInfo, _find, _storeInfo2, mallInfo, checked, _storeInfo3, _mallInfo, _checked, taskMallInfo, region, _storeInfo4, _mallInfo2, _checked2, msg;

    return _regeneratorRuntime().wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            _context4.prev = 0;
            _context4.t0 = +task.platform_code;
            _context4.next = _context4.t0 === 10022 ? 4 : _context4.t0 === 10024 ? 12 : 56;
            break;

          case 4:
            platform_store_id = task.platform_store_id;
            task.host = multiPlatform.globalHostOfTypeId.includes(+task.type_id) ? _temu__WEBPACK_IMPORTED_MODULE_7__[/* temu */ "f"].cbGlobalHost : _temu__WEBPACK_IMPORTED_MODULE_7__[/* temu */ "f"].cbHost; // 跨境

            _context4.next = 8;
            return Object(_temu__WEBPACK_IMPORTED_MODULE_7__[/* checkTemuCb */ "a"])();

          case 8:
            storeInfo = _context4.sent;
            // 店铺校准
            find = storeInfo && storeInfo.find(function (_ref5) {
              var mallId = _ref5.mallId;
              return mallId == platform_store_id;
            });
            res = {
              onlineSiteStatus: storeInfo ? find ? 1 : 3 : 2,
              storeType: 'global'
            };
            return _context4.abrupt("break", 56);

          case 12:
            if (!(task.store_type === 'GLOBAL')) {
              _context4.next = 21;
              break;
            }

            // 跨境
            task.host = multiPlatform.globalHostOfTypeId.includes(+task.type_id) ? _temu__WEBPACK_IMPORTED_MODULE_7__[/* temu */ "f"].cbGlobalHost : _temu__WEBPACK_IMPORTED_MODULE_7__[/* temu */ "f"].cbHost;
            _context4.next = 16;
            return Object(_temu__WEBPACK_IMPORTED_MODULE_7__[/* checkTemuCb */ "a"])();

          case 16:
            _storeInfo = _context4.sent;
            // 店铺校准
            _find = _storeInfo && _storeInfo.find(function (_ref6) {
              var mallId = _ref6.mallId;
              return mallId == task.platform_store_id;
            });
            res = {
              onlineSiteStatus: _storeInfo ? _find ? 1 : 3 : 2,
              storeType: 'global'
            };
            _context4.next = 55;
            break;

          case 21:
            if (!(task.area === 'US')) {
              _context4.next = 31;
              break;
            }

            // us本土
            task.host = _temu__WEBPACK_IMPORTED_MODULE_7__[/* temu */ "f"].usHost;
            _context4.next = 25;
            return Object(_temu__WEBPACK_IMPORTED_MODULE_7__[/* checkTemuUsLocal */ "d"])();

          case 25:
            _storeInfo2 = _context4.sent;
            mallInfo = _storeInfo2 && _storeInfo2.layoutData.mallData && _storeInfo2.layoutData.mallData.mallInfo; // 店铺校准

            checked = _temu__WEBPACK_IMPORTED_MODULE_7__[/* temu */ "f"].localStoreInfo.find(function (_ref7) {
              var mallId = _ref7.mallId;
              return mallId == mallInfo.mallId;
            });
            res = {
              onlineSiteStatus: mallInfo ? checked ? 1 : 3 : 2,
              storeType: 'local',
              area: 'us'
            };
            _context4.next = 55;
            break;

          case 31:
            if (!(task.area === 'EU')) {
              _context4.next = 42;
              break;
            }

            // eu本土
            task.host = _temu__WEBPACK_IMPORTED_MODULE_7__[/* temu */ "f"].euHost;
            _context4.next = 35;
            return Object(_temu__WEBPACK_IMPORTED_MODULE_7__[/* checkTemuEuLocal */ "b"])();

          case 35:
            _storeInfo3 = _context4.sent;
            _mallInfo = _storeInfo3 && _storeInfo3.layoutData.mallData && _storeInfo3.layoutData.mallData.mallInfo; // 店铺校准

            _checked = _temu__WEBPACK_IMPORTED_MODULE_7__[/* temu */ "f"].localStoreInfo.find(function (_ref8) {
              var mallId = _ref8.mallId;
              return mallId == _mallInfo.mallId;
            });
            task.siteId = _checked && _checked.siteId;
            res = {
              onlineSiteStatus: _mallInfo ? _checked ? 1 : 3 : 2,
              storeType: 'local',
              area: 'eu'
            };
            _context4.next = 55;
            break;

          case 42:
            if (!(task.area === 'GLOBAL')) {
              _context4.next = 55;
              break;
            }

            // 全球其他本土
            taskMallInfo = _temu__WEBPACK_IMPORTED_MODULE_7__[/* temu */ "f"].localStoreInfo.find(function (_ref9) {
              var mallId = _ref9.mallId;
              return mallId == task.platform_store_id;
            });

            if (taskMallInfo) {
              _context4.next = 47;
              break;
            }

            _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog("\u672A\u627E\u5230mallId\u4E3A".concat(task.platform_store_id, "\u7684\u5E97\u94FA\u4FE1\u606F"));
            return _context4.abrupt("return", {
              msg: "\u591A\u5E73\u53F0\u68C0\u6D4B\u5E97\u94FA\u662F\u5426\u5728\u7EBF\u5931\u8D25----\u672A\u77E5\u5E97\u94FA:".concat(task.platform_store_id)
            });

          case 47:
            region = taskMallInfo.region;
            task.host = _temu__WEBPACK_IMPORTED_MODULE_7__[/* temu */ "f"]["".concat(region, "Host")];
            _context4.next = 51;
            return Object(_temu__WEBPACK_IMPORTED_MODULE_7__[/* checkTemuGlobalLocal */ "c"])(region);

          case 51:
            _storeInfo4 = _context4.sent;
            _mallInfo2 = _storeInfo4 && _storeInfo4.layoutData.mallData && _storeInfo4.layoutData.mallData.mallInfo; // 店铺校准

            _checked2 = _temu__WEBPACK_IMPORTED_MODULE_7__[/* temu */ "f"].localStoreInfo.find(function (_ref10) {
              var mallId = _ref10.mallId;
              return mallId == _mallInfo2.mallId;
            });
            res = {
              onlineSiteStatus: _mallInfo2 ? _checked2 ? 1 : 3 : 2,
              storeType: 'local',
              area: region
            };

          case 55:
            return _context4.abrupt("break", 56);

          case 56:
            // 记录离线店铺
            recordOfflineSite(res);
            return _context4.abrupt("return", res);

          case 60:
            _context4.prev = 60;
            _context4.t1 = _context4["catch"](0);
            msg = '多平台检测店铺是否在线失败----' + Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* isError */ "r"])(_context4.t1);
            _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog(msg);
            return _context4.abrupt("return", {
              msg: msg
            });

          case 65:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4, null, [[0, 60]]);
  }));

  return function multiPlatformOnlineSite(_x) {
    return _ref4.apply(this, arguments);
  };
}();
/**
 * @description 记录离线店铺
 */

var recordOfflineSite = function recordOfflineSite(_ref11) {
  var onlineSiteStatus = _ref11.onlineSiteStatus,
      storeType = _ref11.storeType,
      area = _ref11.area;
  var mallIds = storeType === 'global' ? _temu__WEBPACK_IMPORTED_MODULE_7__[/* temu */ "f"].cbStoreInfo.map(function (_ref12) {
    var mallId = _ref12.mallId;
    return mallId;
  }) : _temu__WEBPACK_IMPORTED_MODULE_7__[/* temu */ "f"].localStoreInfo.filter(function (_ref13) {
    var region = _ref13.region;
    return region === area;
  }).map(function (_ref14) {
    var mallId = _ref14.mallId;
    return mallId;
  }); // 如果离线，则添加到离线店铺中，如果在线，则从离线店铺中移除

  multiPlatform.offlineSite = onlineSiteStatus === 1 ? multiPlatform.offlineSite.filter(function (mallId) {
    return !mallIds.includes(mallId);
  }) : _toConsumableArray(new Set([].concat(_toConsumableArray(multiPlatform.offlineSite), _toConsumableArray(mallIds))));
};
/**
 * @description 切换站点店铺
 */


var multiPlatformChangeSite = /*#__PURE__*/function () {
  var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(task) {
    return _regeneratorRuntime().wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            _context5.t0 = +task.platform_code;
            _context5.next = _context5.t0 === 10022 ? 3 : _context5.t0 === 10024 ? 3 : 4;
            break;

          case 3:
            return _context5.abrupt("return", true);

          case 4:
            return _context5.abrupt("return", false);

          case 5:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));

  return function multiPlatformChangeSite(_x2) {
    return _ref15.apply(this, arguments);
  };
}();
/**
 * @description 心跳检测
 */

var checkHeartbeat = /*#__PURE__*/function () {
  var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
    var platform_store_id;
    return _regeneratorRuntime().wrap(function _callee6$(_context6) {
      while (1) {
        switch (_context6.prev = _context6.next) {
          case 0:
            _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('多平台心跳检测----', JSON.stringify(multiPlatform.storeInfo)); // const is_pause = await suspend()

            platform_store_id = multiPlatform.storeInfo.filter(function (mallId) {
              return !multiPlatform.offlineSite.includes(mallId);
            });
            _context6.next = 4;
            return Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* gatePost */ "l"])('api/mp/reportHeartBeat', {
              // is_pause: !!is_pause,
              platform_code: multiPlatform.platformCode,
              platform_store_id: platform_store_id
            }, 'task').catch(function () {});

          case 4:
          case "end":
            return _context6.stop();
        }
      }
    }, _callee6);
  }));

  return function checkHeartbeat() {
    return _ref16.apply(this, arguments);
  };
}();
/**
 * @description 轮询
 */


var setTimerLoop = /*#__PURE__*/function () {
  var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
    var count;
    return _regeneratorRuntime().wrap(function _callee9$(_context9) {
      while (1) {
        switch (_context9.prev = _context9.next) {
          case 0:
            count = 0;
            _utils_util__WEBPACK_IMPORTED_MODULE_1__[/* alarms */ "b"].setInterval( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
              var status;
              return _regeneratorRuntime().wrap(function _callee7$(_context7) {
                while (1) {
                  switch (_context7.prev = _context7.next) {
                    case 0:
                      count++;
                      handlePolling(); // 处理暂停状态（防止非手动暂停后关闭插件使插件永久暂停）

                      handleRestoreSuspend(); // 十分钟执行一次

                      if (!(count === 2)) {
                        _context7.next = 10;
                        break;
                      }

                      // 检测版本
                      Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* checkVersion */ "c"])(); // 检测插件是否可用

                      _context7.next = 7;
                      return _data_task__WEBPACK_IMPORTED_MODULE_0__[/* default */ "b"].checkEnable();

                    case 7:
                      status = _context7.sent;
                      _utils_util__WEBPACK_IMPORTED_MODULE_1__[/* localStorage */ "t"].setItem({
                        enableObj: {
                          status: status
                        }
                      }); // 插件当前是否维护中 status为0：维护中，1：可运行

                      count = 0;

                    case 10:
                      // 执行重复任务
                      multiPlatform.multiPlatformTaskInstance.runRepeat();

                    case 11:
                    case "end":
                      return _context7.stop();
                  }
                }
              }, _callee7);
            })), 'multiPlatformBgLoop', 5); // 站点离线时检测轮询

            _utils_util__WEBPACK_IMPORTED_MODULE_1__[/* alarms */ "b"].setInterval( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
              return _regeneratorRuntime().wrap(function _callee8$(_context8) {
                while (1) {
                  switch (_context8.prev = _context8.next) {
                    case 0:
                      checkSiteOfOfflineTask();

                    case 1:
                    case "end":
                      return _context8.stop();
                  }
                }
              }, _callee8);
            })), 'checkSiteOfOfflineTask', 1);

          case 3:
          case "end":
            return _context9.stop();
        }
      }
    }, _callee9);
  }));

  return function setTimerLoop() {
    return _ref17.apply(this, arguments);
  };
}();
/**
 * @description 定时函数
 */


function handlePolling() {
  return _handlePolling.apply(this, arguments);
}
/**
 * @description 当任务存在站点离线状态，则检测店铺
 */


function _handlePolling() {
  _handlePolling = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
    var _task;

    return _regeneratorRuntime().wrap(function _callee12$(_context12) {
      while (1) {
        switch (_context12.prev = _context12.next) {
          case 0:
            if (!(multiPlatform.storeInfo && multiPlatform.storeInfo.length)) {
              _context12.next = 7;
              break;
            }

            _task = multiPlatform.multiPlatformTaskInstance; // 心跳检测

            checkHeartbeat(); // 五分钟请求一次获取任务接口

            _context12.next = 5;
            return _task.getTaskList();

          case 5:
            // 没有任务类型，则获取任务类型
            if (multiPlatform.taskTypes.length === 0) _task.getTaskType(); // 检测定时任务是否开启

            checkEnableTimerTask();

          case 7:
          case "end":
            return _context12.stop();
        }
      }
    }, _callee12);
  }));
  return _handlePolling.apply(this, arguments);
}

function checkSiteOfOfflineTask() {
  return _checkSiteOfOfflineTask.apply(this, arguments);
}
/**
 * @description 检测定时任务是否开启
 */


function _checkSiteOfOfflineTask() {
  _checkSiteOfOfflineTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
    var multiPlatformTaskInstance, taskGroups, taskList, hasOfflineTask, storeInfo, arr;
    return _regeneratorRuntime().wrap(function _callee13$(_context13) {
      while (1) {
        switch (_context13.prev = _context13.next) {
          case 0:
            multiPlatformTaskInstance = multiPlatform.multiPlatformTaskInstance;
            taskGroups = multiPlatformTaskInstance && multiPlatformTaskInstance.taskGroups;

            if (!(taskGroups && Object.keys(taskGroups).length)) {
              _context13.next = 13;
              break;
            }

            taskList = Object.values(taskGroups).flatMap(function (group) {
              return group.tasks;
            });
            hasOfflineTask = taskList.find(function (task) {
              return task.status === 11;
            });

            if (!hasOfflineTask) {
              _context13.next = 13;
              break;
            }

            _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('有离线任务，准备检测站点'); // 有离线任务，准备检测

            _context13.next = 9;
            return getCheckSiteHandle();

          case 9:
            storeInfo = _context13.sent;
            _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('检测到店铺信息', JSON.stringify(storeInfo)); // 检测到有店铺，将对应店铺状态为离线的任务错误次数重置成0

            if (storeInfo && storeInfo.length) {
              arr = [];
              taskList.forEach(function (task) {
                if (task.status === 11 && storeInfo.find(function (mallId) {
                  return mallId == task.platform_store_id;
                })) {
                  arr.push(task.task_id);
                  task.error_time = 0;
                }
              });
              _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('已重置离线任务', JSON.stringify(arr), '---准备重新调度任务');
              if (arr.length > 0) multiPlatformTaskInstance.taskSchedule();
            } // 检测一次就可以退出了


            return _context13.abrupt("return");

          case 13:
          case "end":
            return _context13.stop();
        }
      }
    }, _callee13);
  }));
  return _checkSiteOfOfflineTask.apply(this, arguments);
}

var checkEnableTimerTask = /*#__PURE__*/function () {
  var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
    var _yield$gateGet, code, data;

    return _regeneratorRuntime().wrap(function _callee10$(_context10) {
      while (1) {
        switch (_context10.prev = _context10.next) {
          case 0:
            _context10.prev = 0;
            _context10.next = 3;
            return Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* gateGet */ "k"])('api/v1/checkSysJobStatus');

          case 3:
            _yield$gateGet = _context10.sent;
            code = _yield$gateGet.code;
            data = _yield$gateGet.data;

            if (code === 0) {
              multiPlatform.enableTimerTask = data.status;
            }

            _context10.next = 12;
            break;

          case 9:
            _context10.prev = 9;
            _context10.t0 = _context10["catch"](0);
            _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('检测定时任务是否开启失败----' + Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* isError */ "r"])(_context10.t0));

          case 12:
          case "end":
            return _context10.stop();
        }
      }
    }, _callee10, null, [[0, 9]]);
  }));

  return function checkEnableTimerTask() {
    return _ref20.apply(this, arguments);
  };
}();
/**
 * 恢复暂停状态
 * @returns 
 */


var handleRestoreSuspend = /*#__PURE__*/function () {
  var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
    var _yield$localStorage$g2, suspend;

    return _regeneratorRuntime().wrap(function _callee11$(_context11) {
      while (1) {
        switch (_context11.prev = _context11.next) {
          case 0:
            _context11.next = 2;
            return _utils_util__WEBPACK_IMPORTED_MODULE_1__[/* localStorage */ "t"].getItem(['suspend']);

          case 2:
            _yield$localStorage$g2 = _context11.sent;
            suspend = _yield$localStorage$g2.suspend;

            if (suspend) {
              _context11.next = 6;
              break;
            }

            return _context11.abrupt("return");

          case 6:
            if (!(suspend == '99')) {
              _context11.next = 8;
              break;
            }

            return _context11.abrupt("return");

          case 8:
            if (suspend == '1' || Number(suspend) < Date.now()) {
              _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].report("\u3010sellerID:".concat(JSON.stringify(multiPlatform.storeInfo), "\u3011\u4EFB\u52A1\u6062\u590D\u6267\u884C\u3002"), 'info');
              _utils_util__WEBPACK_IMPORTED_MODULE_1__[/* localStorage */ "t"].removeItem(['suspend']); // 恢复运行（触发src\platform\common\task.js taskSchedule方法）

              Object(_utils_event__WEBPACK_IMPORTED_MODULE_3__[/* distribute */ "a"])('GoExecuteTemu');
            }

          case 9:
          case "end":
            return _context11.stop();
        }
      }
    }, _callee11);
  }));

  return function handleRestoreSuspend() {
    return _ref21.apply(this, arguments);
  };
}();

var multiPlatformTaskClear = function multiPlatformTaskClear() {
  multiPlatform.multiPlatformTaskInstance && multiPlatform.multiPlatformTaskInstance.destroyed();
  multiPlatform.multiPlatformTaskInstance = null;
  _utils_websocket__WEBPACK_IMPORTED_MODULE_4__[/* default */ "a"] && _utils_websocket__WEBPACK_IMPORTED_MODULE_4__[/* default */ "a"].webSocketClose();
  Object(_utils_event__WEBPACK_IMPORTED_MODULE_3__[/* removeMonitor */ "c"])('ReceivePush', receivePush);
  Object(_utils_event__WEBPACK_IMPORTED_MODULE_3__[/* removeMonitor */ "c"])('GoExecuteTemu', goExecuteTemu); // 清除任务请求轮询定时器

  chrome.alarms.clear('multiPlatformBgLoop');
  chrome.alarms.clear('checkSiteOfOfflineTask');
};
var multiPlatformClear = function multiPlatformClear() {
  _data_log__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].setLog('----清除多平台登录信息----');
  multiPlatform.storeInfo = [];
  multiPlatform.platformCode = '';
  multiPlatformTaskClear();
  Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* clearKeepServiceWorker */ "d"])();
  _utils_util__WEBPACK_IMPORTED_MODULE_1__[/* localStorage */ "t"].removeItem(['token', 'refresh_token', 'company_id', 'uid', 'username', 'env_key', 'domain', 'platform']);
};

/***/ }),

/***/ "a7c5":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_8_oneOf_1_0_node_modules_css_loader_index_js_ref_8_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_8_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_8_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_Task_vue_vue_type_style_index_0_id_76bb3dbd_lang_scss_scoped_true___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("9224");
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_8_oneOf_1_0_node_modules_css_loader_index_js_ref_8_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_8_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_8_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_Task_vue_vue_type_style_index_0_id_76bb3dbd_lang_scss_scoped_true___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_mini_css_extract_plugin_dist_loader_js_ref_8_oneOf_1_0_node_modules_css_loader_index_js_ref_8_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_8_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_8_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_Task_vue_vue_type_style_index_0_id_76bb3dbd_lang_scss_scoped_true___WEBPACK_IMPORTED_MODULE_0__);
/* unused harmony reexport * */


/***/ }),

/***/ "b2eb":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony import */ var _data_log_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("6b23");
/* harmony import */ var _utils_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("ca00");
/* harmony import */ var _utils_event__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("42a5");
/* harmony import */ var _data_amazon_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("ef13");
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }





var ws;
var num = 0;
var disconnection = false;
var time = 10000;
var env = '';
var wsToken;
var reconnecting = false;
var lost = 0; // 丢失心跳包次数

var storeIds;
var urlMap = {
  dev: 'wss://notice-t.umaicloud.com?token=',
  test: 'wss://notice-t.lingxingerp.com?token=',
  pro: 'wss://notice-plug.lingxingerp.com?token='
};

function reconnect(token) {
  if (reconnecting) return;
  reconnecting = true; // 没连接上会一直重连，设置延迟避免请求过多

  chrome.alarms.clear('websocketReconnect');
  _utils_util__WEBPACK_IMPORTED_MODULE_1__[/* alarms */ "b"].setTimeout(function () {
    // console.log('执行断线重连...')
    num += 1;
    webSocket.init(token);
    reconnecting = false;

    if (num == 60) {
      // 10分钟后修改为1分钟重连一次
      time = 60000;
    } else if (num == 80) {
      time = 300000; // 30分钟后修改为5分钟重连一次
    }
  }, 'websocketReconnect', time);
} // 心跳检测


var heartCheck = {
  timeout: 1,
  start: function start() {
    chrome.alarms.clear('websocketHeartCheck');
    _utils_util__WEBPACK_IMPORTED_MODULE_1__[/* alarms */ "b"].setInterval(function () {
      ws.send(heartBeatEncode());
      lost++; // 120秒未收到心跳，主动断开，15s后重连

      if (lost >= 2) {
        lost = 0;
        webSocket.webSocketClose(false, 15000);
        _data_log_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"].report('心跳包丢失，断开连接', 'except');
        return;
      }
    }, 'websocketHeartCheck', this.timeout);
  },
  reset: function reset() {
    chrome.alarms.clear('websocketHeartCheck');
  }
}; // 生成0-255十进制

var toRandomByte = function toRandomByte() {
  var byte = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0xff;
  return Math.floor(Math.random() * byte);
}; // 十进制转十六进制


var toDechex = function toDechex(num) {
  return num.toString(16).padStart(2, '0');
};
/**
 * @description 
 * 加密规则：随机生成四个字节data01-data02-data03-data04，start01取data02&11的结果，start02取data02，end01取start01^start02
 * data01-data04做简单加密处理，每个值^118
 * @returns start01-start02-data01-data02-data03-data04-end01
 */


function heartBeatEncode() {
  // 随机生成头部一个字节
  var tempDataByte = [];
  var start01 = toRandomByte();
  var start02 = toRandomByte();
  tempDataByte[0] = toDechex(start01 & 11);
  tempDataByte[1] = toDechex(start02); // data数据区

  tempDataByte[2] = toDechex(toRandomByte() ^ 118);
  tempDataByte[3] = toDechex(start01 ^ 118);
  tempDataByte[4] = toDechex(start02 ^ 118);
  tempDataByte[5] = toDechex(toRandomByte() ^ 118); // 最后一位校验位

  tempDataByte[6] = toDechex(start01 & 11 ^ start02);
  return tempDataByte.join('');
} // 判断接收到消息是否是心跳


function isHeartCheck(data) {
  if (data == 1) {
    lost = 0;
  }
}

var webSocket = {
  init: function () {
    var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
      var seller_ids,
          _yield$localStorage$g,
          token,
          res,
          _args = arguments;

      return _regeneratorRuntime().wrap(function _callee$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              seller_ids = _args.length > 0 && _args[0] !== undefined ? _args[0] : storeIds;
              _context.next = 3;
              return _utils_util__WEBPACK_IMPORTED_MODULE_1__[/* localStorage */ "t"].getItem(['token']);

            case 3:
              _yield$localStorage$g = _context.sent;
              token = _yield$localStorage$g.token;

              if (!(!token || !seller_ids)) {
                _context.next = 7;
                break;
              }

              return _context.abrupt("return");

            case 7:
              storeIds = seller_ids;
              _context.next = 10;
              return Object(_utils_util__WEBPACK_IMPORTED_MODULE_1__[/* gateGet */ "k"])('v1/app/getWebAuth', {
                channel_type: 'store_plug',
                seller_ids: seller_ids
              }, 'notice').catch(function (e) {
                _data_log_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"].setLog("getWebAuth error----".concat(JSON.stringify(e)));
              });

            case 10:
              res = _context.sent;

              if (!(res && res.code === 1)) {
                _context.next = 17;
                break;
              }

              wsToken = res.data.token;
              env = res.data.app_env; // 销毁之前的ws实例

              ws && ws.webSocketClose();
              _context.next = 19;
              break;

            case 17:
              // token获取失败,重连
              reconnect();
              return _context.abrupt("return");

            case 19:
              // if ('WebSocket' in window) {
              ws = new WebSocket(urlMap[env] + wsToken); // } else {
              //   log.setLog('您的浏览器不支持 WebSocket!')
              //   return
              // }

              ws.onmessage = function (e) {
                if (e && e.data) {
                  try {
                    var data = JSON.parse(e.data); // log.setLog(`[websocket]接收数据----${JSON.stringify(data)}`)

                    isHeartCheck(data);
                    Object(_utils_event__WEBPACK_IMPORTED_MODULE_2__[/* distribute */ "a"])('ReceivePush', data.data);
                  } catch (error) {
                    var _data = e.data; // log.setLog(`[websocket]接收数据----${e.data}`)

                    isHeartCheck(_data);
                    Object(_utils_event__WEBPACK_IMPORTED_MODULE_2__[/* distribute */ "a"])('ReceivePush', _data.data); // log.setLog(`[websocket]处理接收数据错误----${JSON.stringify(error)}`)
                  }
                }
              };

              ws.onerror = function (e) {
                ws = null;
                _data_log_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"].setLog("[websocket]\u6570\u636E\u4F20\u8F93\u53D1\u751F\u9519\u8BEF----".concat(JSON.stringify(e)));
                heartCheck.reset();
                reconnect();
              };

              ws.onclose = function () {
                ws = null;
                _data_log_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"].report('[websocket]连接已关闭', 'except');

                if (!disconnection) {
                  heartCheck.reset();
                  reconnect();
                }
              };

              ws.onopen = function () {
                _data_log_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"].setLog('[websocket]连接成功');
                num = 0;
                time = 10000;
                disconnection = false;
                heartCheck.start();
              };

            case 24:
            case "end":
              return _context.stop();
          }
        }
      }, _callee);
    }));

    function init() {
      return _init.apply(this, arguments);
    }

    return init;
  }(),
  webSocketClose: function webSocketClose() {
    var disConn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
    var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10000;
    disconnection = disConn;
    heartCheck.reset();
    chrome.alarms.clear('websocketReconnect');
    num = 0;
    time = t;
    ws && ws.close();
  },
  getWebSocket: function getWebSocket() {
    return ws;
  },
  getStatus: function getStatus() {
    if (ws.readyState == 0) {
      return '未连接';
    } else if (ws.readyState == 1) {
      return '已连接';
    } else if (ws.readyState == 2) {
      return '连接正在关闭';
    } else if (ws.readyState == 3) {
      return '连接已关闭';
    }
  }
};
/* harmony default export */ __webpack_exports__["a"] = (webSocket);

/***/ }),

/***/ "c04e":
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return temu; });
/* unused harmony export changeLocalMallId */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return temuCheckSite; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return checkTemuCb; });
/* unused harmony export checkTemuCbUS */
/* unused harmony export checkTemuCbTask */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return checkTemuUsLocal; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return checkTemuEuLocal; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return checkTemuGlobalLocal; });
/* unused harmony export changeTemuEuSite */
/* unused harmony export changeLanguage */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return loginCb; });
/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("bc3a");
/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _data_log__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("6b23");
/* harmony import */ var _utils_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("ca00");
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }




var temu = {
  // 跨境host
  cbHost: 'https://seller.kuajingmaihuo.com',
  // 跨境全球host
  cbGlobalHost: 'https://agentseller.temu.com',
  // 跨境美区host
  cbUsHost: 'https://agentseller-us.temu.com',
  // 跨境欧区host
  cbEuHost: 'https://agentseller-eu.temu.com',
  // 本土美区host
  usHost: 'https://seller.temu.com',
  // 本土欧区host
  euHost: 'https://seller-eu.temu.com',
  // 本土墨西哥host
  mxHost: 'https://mx.seller.temu.com',
  // 本土韩国host
  krHost: 'https://kr.seller.temu.com',
  // 本土店铺所有国家sitaid，目前为全平台固定值
  siteIds: [],
  // declarativeNetRequest规则集id
  requestHearderIds: [],

  /**
   * 跨境店铺的信息
   * @param mallId // 店铺id
   * @param mallName // 店铺名
   * @param mallStatus // 店铺状态（目前还不知作用）
   * @param logo
   * @param isSemiManagedMall // 是否是半托管
   * @param storeType // 店铺类型  跨境
   */
  cbStoreInfo: [],

  /**
   * 本土店铺信息
   * @param mallId // 店铺id
   * @param siteId // 站点id
   * @param mallName // 店铺名
   * @param marketPlaceName // 国家名
   * @param region // 区域
   * @param storeType // 店铺类型  本土
   * @param isSemiManagedMall // 是否是半托管 本土默认全半托管
   */
  localStoreInfo: []
}; // 为temu所有接口带上Referer、Origin

var initTemuUrlObserve = /*#__PURE__*/function () {
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
    return _regeneratorRuntime().wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.next = 2;
            return Promise.all([Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* setRequestHearder */ "D"])([{
              name: 'Referer',
              value: temu.cbHost
            }, {
              name: 'Origin',
              value: temu.cbHost
            }], temu.cbHost + '/*'), Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* setRequestHearder */ "D"])([{
              name: 'Referer',
              value: temu.cbUsHost
            }, {
              name: 'Origin',
              value: temu.cbUsHost
            }], temu.cbUsHost + '/*'), Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* setRequestHearder */ "D"])([{
              name: 'Referer',
              value: temu.cbEuHost
            }, {
              name: 'Origin',
              value: temu.cbEuHost
            }], temu.cbEuHost + '/*'), Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* setRequestHearder */ "D"])([{
              name: 'Referer',
              value: temu.cbGlobalHost
            }, {
              name: 'Origin',
              value: temu.cbGlobalHost
            }], temu.cbGlobalHost + '/*'), Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* setRequestHearder */ "D"])([{
              name: 'Referer',
              value: temu.usHost
            }, {
              name: 'Origin',
              value: temu.usHost
            }], temu.usHost + '/*'), Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* setRequestHearder */ "D"])([{
              name: 'Referer',
              value: temu.euHost
            }, {
              name: 'Origin',
              value: temu.euHost
            }], temu.euHost + '/*'), Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* setRequestHearder */ "D"])([{
              name: 'Referer',
              value: temu.mxHost
            }, {
              name: 'Origin',
              value: temu.mxHost
            }], temu.mxHost + '/*'), Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* setRequestHearder */ "D"])([{
              name: 'Referer',
              value: temu.krHost
            }, {
              name: 'Origin',
              value: temu.krHost
            }], temu.krHost + '/*')]);

          case 2:
            temu.requestHearderIds = _context.sent;

          case 3:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));

  return function initTemuUrlObserve() {
    return _ref.apply(this, arguments);
  };
}(); // 监听请求，店铺cookie带上mailid（切换站点）


var changeLocalMallId = /*#__PURE__*/function () {
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
    var mallId,
        siteId,
        url,
        _cookie,
        arr,
        newCookies,
        msg,
        _args2 = arguments;

    return _regeneratorRuntime().wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            mallId = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : '';
            siteId = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : '';
            url = _args2.length > 2 ? _args2[2] : undefined;
            _context2.prev = 3;

            if (url) {
              _context2.next = 6;
              break;
            }

            return _context2.abrupt("return", false);

          case 6:
            _context2.next = 8;
            return Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* getAllCookies */ "n"])({
              url: url
            });

          case 8:
            _cookie = _context2.sent;
            arr = _cookie.map(function (_ref3) {
              var name = _ref3.name,
                  value = _ref3.value;
              if (name === 'MALL_ID') return "MALL_ID=".concat(mallId);
              if (name === 'seller_site') return "seller_site=".concat(siteId);
              if (name === 'mallid') return "mallid=".concat(mallId);
              return "".concat(name, "=").concat(value);
            });
            newCookies = arr.join(';');
            console.log('changeLocalMallId', "url:".concat(url, "---"), 'arr:', arr, '---', '_cookie:', _cookie); // 判断是否有修改cookie，有才拦截

            if (!(newCookies === _cookie.map(function (_ref4) {
              var name = _ref4.name,
                  value = _ref4.value;
              return "".concat(name, "=").concat(value);
            }).join(';'))) {
              _context2.next = 15;
              break;
            }

            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("cookie\u672A\u4FEE\u6539\uFF0C\u4E0D\u9700\u8981\u76D1\u542C");
            return _context2.abrupt("return", true);

          case 15:
            return _context2.abrupt("return", Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* setRequestHearder */ "D"])([{
              name: 'Cookie',
              value: newCookies
            }], "".concat(url, "*")));

          case 18:
            _context2.prev = 18;
            _context2.t0 = _context2["catch"](3);
            msg = "\u76D1\u542Ctemu\u8BF7\u6C42\u5E76\u4FEE\u6539cookie\u5931\u8D25,\u5931\u8D25\u539F\u56E0\uFF1A".concat(Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* isError */ "r"])(_context2.t0));
            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].report(msg, 'error', mallId);
            return _context2.abrupt("return", false);

          case 23:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2, null, [[3, 18]]);
  }));

  return function changeLocalMallId() {
    return _ref2.apply(this, arguments);
  };
}();
/**
 * @description 清除店铺信息
 */

var clearStoreInfo = function clearStoreInfo() {
  temu.cbStoreInfo = [];
  temu.localStoreInfo = [];
};
/**
 * @description temu检测站点
 */


var temuCheckSite = /*#__PURE__*/function () {
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
    var res, storeInfo, _res, cbInfo, usInfo, euInfo, mxInfo, krInfo, infoArray, _iterator, _step, info, _info$layoutData$mall, mallId, mallName, curMallId, _mallName, curSiteId, curMarketPlaceName, marketPlaceList, infoMap, _iterator2, _step2, marketPlace, siteId, _res2, _euInfo, _euInfo$layoutData$ma, _siteId, marketPlaceName, backRes;

    return _regeneratorRuntime().wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            _context3.prev = 0;
            clearStoreInfo();
            _context3.next = 4;
            return initTemuUrlObserve();

          case 4:
            _context3.next = 6;
            return Promise.all([checkTemuCb(), checkTemuUsLocal(), checkTemuEuLocal(), checkTemuGlobalLocal('mx'), checkTemuGlobalLocal('kr')]);

          case 6:
            res = _context3.sent;
            storeInfo = [];
            _res = _slicedToArray(res, 5), cbInfo = _res[0], usInfo = _res[1], euInfo = _res[2], mxInfo = _res[3], krInfo = _res[4]; // 整理跨境店铺信息

            if (cbInfo) {
              temu.cbStoreInfo = cbInfo.map(function (item) {
                return _objectSpread(_objectSpread({}, item), {}, {
                  storeType: '跨境'
                });
              });
              storeInfo.push.apply(storeInfo, _toConsumableArray(cbInfo.map(function (_ref6) {
                var mallId = _ref6.mallId;
                return mallId;
              })));
            } // 整理us|mx|kr本土店铺信息


            if (!(usInfo || mxInfo || krInfo)) {
              _context3.next = 32;
              break;
            }

            infoArray = [usInfo && _objectSpread(_objectSpread({}, usInfo), {}, {
              _region: 'us',
              marketPlaceName: '美国'
            }), mxInfo && _objectSpread(_objectSpread({}, mxInfo), {}, {
              _region: 'mx',
              marketPlaceName: '墨西哥'
            }), krInfo && _objectSpread(_objectSpread({}, krInfo), {}, {
              _region: 'kr',
              marketPlaceName: '韩国'
            })].filter(Boolean);
            _iterator = _createForOfIteratorHelper(infoArray);
            _context3.prev = 13;

            _iterator.s();

          case 15:
            if ((_step = _iterator.n()).done) {
              _context3.next = 24;
              break;
            }

            info = _step.value;

            if (!(!info || !info.layoutData)) {
              _context3.next = 19;
              break;
            }

            return _context3.abrupt("continue", 22);

          case 19:
            _info$layoutData$mall = info.layoutData.mallData.mallInfo, mallId = _info$layoutData$mall.mallId, mallName = _info$layoutData$mall.mallName;
            temu.localStoreInfo.push({
              mallId: mallId,
              mallName: mallName,
              siteId: info.localInfo.site,
              marketPlaceName: info.marketPlaceName,
              region: info._region,
              storeType: '本土',
              isSemiManagedMall: true
            });
            storeInfo.push(mallId);

          case 22:
            _context3.next = 15;
            break;

          case 24:
            _context3.next = 29;
            break;

          case 26:
            _context3.prev = 26;
            _context3.t0 = _context3["catch"](13);

            _iterator.e(_context3.t0);

          case 29:
            _context3.prev = 29;

            _iterator.f();

            return _context3.finish(29);

          case 32:
            if (!euInfo) {
              _context3.next = 71;
              break;
            }

            curMallId = euInfo.layoutData.mallData.mallInfo.mallId;
            _mallName = euInfo.layoutData.mallData.mallInfo.mallName;
            curSiteId = euInfo.layoutData.marketplaceData.currentMarketPlace.siteId;
            curMarketPlaceName = euInfo.layoutData.marketplaceData.currentMarketPlace.marketPlaceName;
            marketPlaceList = euInfo.layoutData.marketplaceData.marketPlaceList; // 站点id映射，key: 店铺id  value: 站点id&店铺名

            infoMap = _defineProperty({}, curMallId, {
              siteId: curSiteId,
              marketPlaceName: curMarketPlaceName
            });
            _iterator2 = _createForOfIteratorHelper(marketPlaceList);
            _context3.prev = 40;

            _iterator2.s();

          case 42:
            if ((_step2 = _iterator2.n()).done) {
              _context3.next = 58;
              break;
            }

            marketPlace = _step2.value;
            siteId = marketPlace.siteId;

            if (!(siteId && siteId !== curSiteId)) {
              _context3.next = 56;
              break;
            }

            _context3.next = 48;
            return changeTemuEuSite(siteId);

          case 48:
            _res2 = _context3.sent;
            _context3.t1 = _res2;

            if (!_context3.t1) {
              _context3.next = 54;
              break;
            }

            _context3.next = 53;
            return checkTemuEuLocal();

          case 53:
            _context3.t1 = _context3.sent;

          case 54:
            _euInfo = _context3.t1;

            if (_euInfo) {
              _euInfo$layoutData$ma = _euInfo.layoutData.marketplaceData.currentMarketPlace, _siteId = _euInfo$layoutData$ma.siteId, marketPlaceName = _euInfo$layoutData$ma.marketPlaceName;
              infoMap[_euInfo.layoutData.mallData.mallInfo.mallId] = {
                siteId: _siteId,
                marketPlaceName: marketPlaceName
              };
            }

          case 56:
            _context3.next = 42;
            break;

          case 58:
            _context3.next = 63;
            break;

          case 60:
            _context3.prev = 60;
            _context3.t2 = _context3["catch"](40);

            _iterator2.e(_context3.t2);

          case 63:
            _context3.prev = 63;

            _iterator2.f();

            return _context3.finish(63);

          case 66:
            _context3.next = 68;
            return changeTemuEuSite(curSiteId);

          case 68:
            backRes = _context3.sent;

            // 没切换回去？看要不要在页面弹窗一下
            if (!backRes) {// do something
            }

            Object.keys(infoMap).forEach(function (key) {
              var _infoMap$key = infoMap[key],
                  siteId = _infoMap$key.siteId,
                  marketPlaceName = _infoMap$key.marketPlaceName;
              storeInfo.push(key);
              temu.localStoreInfo.push({
                mallId: key,
                mallName: _mallName,
                siteId: siteId,
                marketPlaceName: marketPlaceName,
                region: 'eu',
                storeType: '本土',
                isSemiManagedMall: true
              });
            });

          case 71:
            return _context3.abrupt("return", storeInfo);

          case 74:
            _context3.prev = 74;
            _context3.t3 = _context3["catch"](0);
            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].report("temu\u68C0\u6D4B\u7AD9\u70B9\u62A5\u9519,\u89C4\u5219\u53EF\u80FD\u5DF2\u6539\u53D8---".concat(Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* isError */ "r"])(_context3.t3)), 'error');
            return _context3.abrupt("return", false);

          case 78:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3, null, [[0, 74], [13, 26, 29, 32], [40, 60, 63, 66]]);
  }));

  return function temuCheckSite() {
    return _ref5.apply(this, arguments);
  };
}();
/**
 * @description 检测跨境店铺是否在线，在线则返回店铺信息
 */

var checkTemuCb = /*#__PURE__*/function () {
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
    var _yield$axios, data, companyList, storeList, errorMsg;

    return _regeneratorRuntime().wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            _context4.prev = 0;
            _context4.next = 3;
            return axios__WEBPACK_IMPORTED_MODULE_0___default()({
              url: "".concat(temu.cbHost, "/bg/quiet/api/mms/userInfo"),
              method: 'post'
            });

          case 3:
            _yield$axios = _context4.sent;
            data = _yield$axios.data;
            companyList = data && data.result && data.result.companyList;

            if (!companyList) {
              _context4.next = 9;
              break;
            }

            storeList = companyList.reduce(function (arr, i) {
              if (i.malInfoList && i.malInfoList.length) {
                arr = arr.concat(i.malInfoList);
              }

              return arr;
            }, []);
            return _context4.abrupt("return", storeList.length > 0 && storeList);

          case 9:
            _context4.next = 15;
            break;

          case 11:
            _context4.prev = 11;
            _context4.t0 = _context4["catch"](0);
            errorMsg = Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* isError */ "r"])(_context4.t0);

            if (errorMsg.indexOf('403') > -1) {
              _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u68C0\u6D4Btemu\u8DE8\u5883\u7AD9\u70B9\u672A\u767B\u5F55");
            } else {
              _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u68C0\u6D4Btemu\u8DE8\u5883\u7AD9\u70B9\u8BF7\u6C42\u62A5\u9519-----".concat(errorMsg));
            }

          case 15:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4, null, [[0, 11]]);
  }));

  return function checkTemuCb() {
    return _ref7.apply(this, arguments);
  };
}();
/**
 * @description 检测跨境美区/欧区店铺是否在线
 */

var checkTemuCbUS = /*#__PURE__*/function () {
  var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref8) {
    var host, Mallid, _yield$axios2, data, mallList, errorMsg;

    return _regeneratorRuntime().wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            host = _ref8.host, Mallid = _ref8.Mallid;
            _context5.prev = 1;
            _context5.next = 4;
            return axios__WEBPACK_IMPORTED_MODULE_0___default()({
              url: "".concat(host, "/api/seller/auth/userInfo"),
              method: 'post',
              headers: {
                Mallid: Mallid
              }
            });

          case 4:
            _yield$axios2 = _context5.sent;
            data = _yield$axios2.data;
            mallList = data && data.result && data.result.mallList;
            return _context5.abrupt("return", mallList.length > 0 && mallList);

          case 10:
            _context5.prev = 10;
            _context5.t0 = _context5["catch"](1);
            errorMsg = Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* isError */ "r"])(_context5.t0);

            if (errorMsg.indexOf('403') > -1) {
              _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u68C0\u6D4Btemu".concat(host, "\u8DE8\u5883\u7AD9\u70B9\u672A\u767B\u5F55"));
            } else {
              _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u68C0\u6D4Btemu".concat(host, "\u8DE8\u5883\u7AD9\u70B9\u8BF7\u6C42\u62A5\u9519-----").concat(errorMsg));
            }

          case 14:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5, null, [[1, 10]]);
  }));

  return function checkTemuCbUS(_x) {
    return _ref9.apply(this, arguments);
  };
}();
var checkTemuCbTask = /*#__PURE__*/function () {
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(id, task, count) {
    return _regeneratorRuntime().wrap(function _callee8$(_context8) {
      while (1) {
        switch (_context8.prev = _context8.next) {
          case 0:
            if (!(count > 40)) {
              _context8.next = 3;
              break;
            }

            chrome.tabs.remove(id);
            return _context8.abrupt("return", {
              code: 13
            });

          case 3:
            return _context8.abrupt("return", new Promise(function (resolve) {
              setTimeout(function () {
                chrome.tabs.get(id, /*#__PURE__*/function () {
                  var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(tab) {
                    var r, _yield$getCookies, value, executeFunc;

                    return _regeneratorRuntime().wrap(function _callee7$(_context7) {
                      while (1) {
                        switch (_context7.prev = _context7.next) {
                          case 0:
                            _context7.prev = 0;

                            if (tab) {
                              _context7.next = 7;
                              break;
                            }

                            chrome.tabs.remove(id);
                            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog('切换分区站点页面可能已被关闭2');
                            resolve({
                              code: 16
                            });
                            _context7.next = 23;
                            break;

                          case 7:
                            if (!(tab.status == 'loading')) {
                              _context7.next = 14;
                              break;
                            }

                            _context7.next = 10;
                            return checkTemuCbTask(id, task, ++count);

                          case 10:
                            r = _context7.sent;
                            resolve(r);
                            _context7.next = 23;
                            break;

                          case 14:
                            if (!(tab.status == 'complete')) {
                              _context7.next = 23;
                              break;
                            }

                            _context7.next = 17;
                            return Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* getCookies */ "o"])({
                              url: task.host,
                              name: 'mallid'
                            });

                          case 17:
                            _yield$getCookies = _context7.sent;
                            value = _yield$getCookies.value;
                            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u5F53\u524D\u5E97\u94FAid\uFF1A".concat(value, "\uFF0C\u9700\u8981\u5207\u6362\u5E97\u94FA\uFF1A").concat(task.Mallid));
                            _context7.next = 22;
                            return Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* delayed */ "g"])(1000);

                          case 22:
                            if (value === task.Mallid) {
                              _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog('当前店铺id与需要切换店铺id一致，不需要切换店铺'); // chrome.tabs.remove(id)

                              resolve(true);
                            } else {
                              executeFunc = function executeFunc() {
                                try {
                                  // 优化选择器，提高兼容性
                                  var button = document.querySelector('div[data-testid="beast-core-modal-body"] button'); // 如果第一个选择器没找到，尝试备用选择器

                                  if (!button) {
                                    button = document.querySelector('div[data-testid="beast-core-modal-body"] div button');
                                  }

                                  console.log('buttonbuttonbutton', button);

                                  if (button) {
                                    button.click();
                                    return true;
                                  }

                                  return false; // const res = await fetch(`${taskData.host}/api/seller/auth/loginByCode`, {
                                  //   method: 'POST',
                                  //   headers: {
                                  //     'Content-Type': 'application/json'
                                  //   },
                                  //   body: JSON.stringify({
                                  //     code: taskData.code,
                                  //     confirm: true,
                                  //     targetMallId: taskData.Mallid
                                  //   })
                                  // })
                                  // const { success } = await res.json()
                                  // return success
                                } catch (error) {
                                  return false;
                                }
                              }; // 注入脚本


                              chrome.scripting.executeScript({
                                target: {
                                  tabId: id
                                },
                                func: executeFunc
                              }).then( /*#__PURE__*/function () {
                                var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(results) {
                                  var result, retryResult;
                                  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
                                    while (1) {
                                      switch (_context6.prev = _context6.next) {
                                        case 0:
                                          if (!(!results || !results[0])) {
                                            _context6.next = 4;
                                            break;
                                          }

                                          _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog('脚本执行失败：无返回结果'); // chrome.tabs.remove(id)

                                          resolve(false);
                                          return _context6.abrupt("return");

                                        case 4:
                                          result = results[0].result;

                                          if (!(result === true)) {
                                            _context6.next = 13;
                                            break;
                                          }

                                          _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog('切换店铺成功');
                                          _context6.next = 9;
                                          return Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* delayed */ "g"])(1000);

                                        case 9:
                                          chrome.tabs.remove(id);
                                          resolve(true);
                                          _context6.next = 18;
                                          break;

                                        case 13:
                                          _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u7B2C".concat(count + 1, "\u6B21\u67E5\u627E\u6309\u94AE\u5931\u8D25\uFF0C\u7B49\u5F85\u91CD\u8BD5..."));
                                          _context6.next = 16;
                                          return checkTemuCbTask(id, task, ++count);

                                        case 16:
                                          retryResult = _context6.sent;
                                          resolve(retryResult);

                                        case 18:
                                        case "end":
                                          return _context6.stop();
                                      }
                                    }
                                  }, _callee6);
                                }));

                                return function (_x6) {
                                  return _ref12.apply(this, arguments);
                                };
                              }()).catch(function (error) {
                                _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u811A\u672C\u6267\u884C\u5931\u8D25\uFF1A".concat(error.message));
                                chrome.tabs.remove(id);
                                resolve(false);
                              });
                            }
                            /** 页面加载完成 */
                            // const list = await checkTemuCbUS(task)
                            // if(list) {
                            // }else{
                            //   let r = await checkTemuCbTask(id, task, ++count)
                            //   resolve(r)
                            // }


                          case 23:
                            _context7.next = 30;
                            break;

                          case 25:
                            _context7.prev = 25;
                            _context7.t0 = _context7["catch"](0);

                            if (tab) {
                              chrome.tabs.remove(tab.id);
                            }

                            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("checkTemuCbTask error\uFF1A".concat(Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* isError */ "r"])(_context7.t0)));
                            resolve({
                              code: 17,
                              msg: "checkTemuCbTask error".concat(Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* isError */ "r"])(_context7.t0))
                            });

                          case 30:
                          case "end":
                            return _context7.stop();
                        }
                      }
                    }, _callee7, null, [[0, 25]]);
                  }));

                  return function (_x5) {
                    return _ref11.apply(this, arguments);
                  };
                }());
              }, 1000);
            }));

          case 4:
          case "end":
            return _context8.stop();
        }
      }
    }, _callee8);
  }));

  return function checkTemuCbTask(_x2, _x3, _x4) {
    return _ref10.apply(this, arguments);
  };
}();
/**
 * @description 检测美国本土店铺是否在线，在线则返回店铺信息
 */

var checkTemuUsLocal = /*#__PURE__*/function () {
  var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
    var _yield$axios3, data, str, _JSON$parse, store, region, errorMsg;

    return _regeneratorRuntime().wrap(function _callee9$(_context9) {
      while (1) {
        switch (_context9.prev = _context9.next) {
          case 0:
            _context9.prev = 0;
            _context9.next = 3;
            return axios__WEBPACK_IMPORTED_MODULE_0___default()({
              url: temu.usHost + '/home.html',
              method: 'get'
            });

          case 3:
            _yield$axios3 = _context9.sent;
            data = _yield$axios3.data;

            if (!data) {
              _context9.next = 18;
              break;
            }

            _context9.prev = 6;
            str = data.replace(/[\r\n\s]+/g, '');
            _JSON$parse = JSON.parse(str.split('window.rawData=')[1].split(';document')[0]), store = _JSON$parse.store;
            region = JSON.parse(str.split('window.__REGION_CONFIG__=')[1].split(';window.__DOC_SOURCE__="ssr"')[0]); // 记录本土店铺所有国家siteid

            temu.siteIds = region;

            if (!(store.layoutData && store.layoutData.marketplaceData)) {
              _context9.next = 13;
              break;
            }

            return _context9.abrupt("return", store);

          case 13:
            _context9.next = 18;
            break;

          case 15:
            _context9.prev = 15;
            _context9.t0 = _context9["catch"](6);
            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].report("temu\u68C0\u6D4B\u7F8E\u533A\u672C\u571F\u5E97\u62A5\u9519\uFF0C\u53EF\u80FD\u89C4\u5219\u5DF2\u6539\u53D8-----".concat(Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* isError */ "r"])(_context9.t0)), 'error');

          case 18:
            _context9.next = 24;
            break;

          case 20:
            _context9.prev = 20;
            _context9.t1 = _context9["catch"](0);
            errorMsg = Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* isError */ "r"])(_context9.t1);

            if (errorMsg.indexOf('403') > -1) {
              _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u68C0\u6D4Btemu\u7F8E\u533A\u672C\u571F\u7AD9\u70B9\u672A\u767B\u5F55");
            } else {
              _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u68C0\u6D4Btemu\u7F8E\u533A\u672C\u571F\u7AD9\u70B9\u62A5\u9519-----".concat(errorMsg));
            }

          case 24:
          case "end":
            return _context9.stop();
        }
      }
    }, _callee9, null, [[0, 20], [6, 15]]);
  }));

  return function checkTemuUsLocal() {
    return _ref13.apply(this, arguments);
  };
}();
/**
 * @description 检测欧洲本土店铺是否在线，在线则返回店铺信息
 */

var checkTemuEuLocal = /*#__PURE__*/function () {
  var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
    var _yield$axios4, data, str, _JSON$parse2, store, errorMsg;

    return _regeneratorRuntime().wrap(function _callee10$(_context10) {
      while (1) {
        switch (_context10.prev = _context10.next) {
          case 0:
            _context10.prev = 0;
            _context10.next = 3;
            return axios__WEBPACK_IMPORTED_MODULE_0___default()({
              url: temu.euHost + '/home.html',
              method: 'get'
            });

          case 3:
            _yield$axios4 = _context10.sent;
            data = _yield$axios4.data;

            if (!data) {
              _context10.next = 16;
              break;
            }

            _context10.prev = 6;
            str = data.replace(/[\r\n\s]+/g, '');
            _JSON$parse2 = JSON.parse(str.split('window.rawData=')[1].split(';document')[0]), store = _JSON$parse2.store;

            if (!(store.layoutData && store.layoutData.marketplaceData)) {
              _context10.next = 11;
              break;
            }

            return _context10.abrupt("return", store);

          case 11:
            _context10.next = 16;
            break;

          case 13:
            _context10.prev = 13;
            _context10.t0 = _context10["catch"](6);
            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].report("temu\u68C0\u6D4B\u6B27\u533A\u672C\u571F\u5E97\u62A5\u9519\uFF0C\u53EF\u80FD\u89C4\u5219\u5DF2\u6539\u53D8-----".concat(Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* isError */ "r"])(_context10.t0)), 'error');

          case 16:
            _context10.next = 22;
            break;

          case 18:
            _context10.prev = 18;
            _context10.t1 = _context10["catch"](0);
            errorMsg = Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* isError */ "r"])(_context10.t1);

            if (errorMsg.indexOf('403') > -1) {
              _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u68C0\u6D4Btemu\u6B27\u533A\u672C\u571F\u7AD9\u70B9\u672A\u767B\u5F55");
            } else {
              _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u68C0\u6D4Btemu\u6B27\u533A\u672C\u571F\u7AD9\u70B9\u62A5\u9519-----".concat(errorMsg));
            }

          case 22:
          case "end":
            return _context10.stop();
        }
      }
    }, _callee10, null, [[0, 18], [6, 13]]);
  }));

  return function checkTemuEuLocal() {
    return _ref14.apply(this, arguments);
  };
}();
/**
 * @description 检测全球其他本土店铺是否在线，在线则返回店铺信息
 */

var checkTemuGlobalLocal = /*#__PURE__*/function () {
  var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(region) {
    var HostMap, _yield$axios5, data, str, _JSON$parse3, store, errorMsg;

    return _regeneratorRuntime().wrap(function _callee11$(_context11) {
      while (1) {
        switch (_context11.prev = _context11.next) {
          case 0:
            HostMap = {
              'mx': {
                host: temu.mxHost,
                marketPlaceName: '墨西哥'
              },
              'kr': {
                host: temu.krHost,
                marketPlaceName: '韩国'
              }
            }; // 检查region参数是否有效

            if (HostMap[region]) {
              _context11.next = 4;
              break;
            }

            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u68C0\u6D4Btemu\u5168\u7403\u5176\u4ED6\u672C\u571F\u5E97\u94FA\u5931\u8D25----\u4F20\u5165\u4E0D\u652F\u6301\u7684region\u53C2\u6570: ".concat(region));
            return _context11.abrupt("return", false);

          case 4:
            _context11.prev = 4;
            _context11.next = 7;
            return axios__WEBPACK_IMPORTED_MODULE_0___default()({
              url: HostMap[region].host + '/home.html',
              method: 'get'
            });

          case 7:
            _yield$axios5 = _context11.sent;
            data = _yield$axios5.data;

            if (!data) {
              _context11.next = 20;
              break;
            }

            _context11.prev = 10;
            str = data.replace(/[\r\n\s]+/g, '');
            _JSON$parse3 = JSON.parse(str.split('window.rawData=')[1].split(';document')[0]), store = _JSON$parse3.store;

            if (!(store.layoutData && store.layoutData.marketplaceData)) {
              _context11.next = 15;
              break;
            }

            return _context11.abrupt("return", store);

          case 15:
            _context11.next = 20;
            break;

          case 17:
            _context11.prev = 17;
            _context11.t0 = _context11["catch"](10);
            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].report("temu\u68C0\u6D4B".concat(HostMap[region].marketPlaceName, "\u672C\u571F\u5E97\u62A5\u9519\uFF0C\u53EF\u80FD\u89C4\u5219\u5DF2\u6539\u53D8-----").concat(Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* isError */ "r"])(_context11.t0)), 'error');

          case 20:
            _context11.next = 26;
            break;

          case 22:
            _context11.prev = 22;
            _context11.t1 = _context11["catch"](4);
            errorMsg = Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* isError */ "r"])(_context11.t1);

            if (errorMsg.indexOf('403') > -1) {
              _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u68C0\u6D4Btemu".concat(HostMap[region].marketPlaceName, "\u672C\u571F\u7AD9\u70B9\u672A\u767B\u5F55"));
            } else {
              _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u68C0\u6D4Btemu".concat(HostMap[region].marketPlaceName, "\u672C\u571F\u7AD9\u70B9\u62A5\u9519-----").concat(errorMsg));
            }

          case 26:
          case "end":
            return _context11.stop();
        }
      }
    }, _callee11, null, [[4, 22], [10, 17]]);
  }));

  return function checkTemuGlobalLocal(_x7) {
    return _ref15.apply(this, arguments);
  };
}();
/**
 * @description 欧区切换站点
 */

var changeTemuEuSite = /*#__PURE__*/function () {
  var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(siteId) {
    var _yield$axios6, data, errorMsg;

    return _regeneratorRuntime().wrap(function _callee12$(_context12) {
      while (1) {
        switch (_context12.prev = _context12.next) {
          case 0:
            _context12.prev = 0;
            _context12.next = 3;
            return axios__WEBPACK_IMPORTED_MODULE_0___default()({
              url: "".concat(temu.euHost, "/mms/floyd/marketplace/switch"),
              method: 'post',
              data: {
                target_site_id: siteId,
                biz_scene: 0
              }
            });

          case 3:
            _yield$axios6 = _context12.sent;
            data = _yield$axios6.data;

            if (!data.success) {
              _context12.next = 7;
              break;
            }

            return _context12.abrupt("return", true);

          case 7:
            _context12.next = 14;
            break;

          case 9:
            _context12.prev = 9;
            _context12.t0 = _context12["catch"](0);
            errorMsg = Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* isError */ "r"])(_context12.t0);

            if (errorMsg.indexOf('403') > -1) {
              _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u68C0\u6D4Btemu\u6B27\u533A\u672C\u571F\u7AD9\u70B9\u672A\u767B\u5F55");
            } else {
              _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u68C0\u6D4Btemu\u6B27\u533A\u672C\u571F\u7AD9\u70B9\u62A5\u9519-----".concat(errorMsg));
            }

            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u5207\u6362temu\u6B27\u533A\u7AD9\u70B9\u62A5\u9519-----".concat(errorMsg));

          case 14:
          case "end":
            return _context12.stop();
        }
      }
    }, _callee12, null, [[0, 9]]);
  }));

  return function changeTemuEuSite(_x8) {
    return _ref16.apply(this, arguments);
  };
}();
/**
 * 本土店铺切换语言
 */

var changeLanguage = /*#__PURE__*/function () {
  var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(type) {
    var host, _yield$Promise$all, _yield$Promise$all2, siteCookie, languageCookie, site_id, lang, store, _yield$axios7, data, setCookieRes;

    return _regeneratorRuntime().wrap(function _callee13$(_context13) {
      while (1) {
        switch (_context13.prev = _context13.next) {
          case 0:
            if (type) {
              _context13.next = 2;
              break;
            }

            return _context13.abrupt("return");

          case 2:
            _context13.prev = 2;
            host = {
              us: temu.usHost,
              eu: temu.euHost
            }[type]; // 通过cookie获取当前站点和语言

            _context13.t0 = Promise;
            _context13.t1 = Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* getCookies */ "o"])({
              url: host,
              name: 'seller_site'
            });
            _context13.next = 8;
            return Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* getCookies */ "o"])({
              url: host,
              name: 'seller_language'
            });

          case 8:
            _context13.t2 = _context13.sent;
            _context13.t3 = [_context13.t1, _context13.t2];
            _context13.next = 12;
            return _context13.t0.all.call(_context13.t0, _context13.t3);

          case 12:
            _yield$Promise$all = _context13.sent;
            _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
            siteCookie = _yield$Promise$all2[0];
            languageCookie = _yield$Promise$all2[1];
            site_id = siteCookie.value;
            lang = languageCookie.value; // 如果通过cookie获取siteid和当前语言失败，则通过接口拿

            if (!(!site_id || !lang)) {
              _context13.next = 26;
              break;
            }

            _context13.next = 21;
            return checkTemuEuLocal();

          case 21:
            store = _context13.sent;

            if (store) {
              _context13.next = 24;
              break;
            }

            return _context13.abrupt("return");

          case 24:
            site_id = store.localInfo.site;
            lang = store.localInfo.language;

          case 26:
            if (!(lang === 'en')) {
              _context13.next = 29;
              break;
            }

            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("[".concat(type, "]\u5F53\u524D\u8BED\u8A00\u4E3Aen\uFF0C\u4E0D\u9700\u8981\u5207\u6362"));
            return _context13.abrupt("return");

          case 29:
            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("[".concat(type, "]\u5F53\u524D\u8BED\u8A00").concat(site_id, "\uFF0C\u51C6\u5907\u5207\u6362\u81F3en")); // 此接口作用不知道是啥，但是temu有调，那我们也要调

            _context13.next = 32;
            return axios__WEBPACK_IMPORTED_MODULE_0___default()({
              url: "".concat(host, "/api/bg/christiaan/change/site/lang/report"),
              method: 'post',
              data: {
                before: {
                  site_id: site_id,
                  lang: lang
                },
                after: {
                  site_id: site_id,
                  lang: "en"
                },
                scene: 10000,
                path: "/home.html"
              }
            });

          case 32:
            _yield$axios7 = _context13.sent;
            data = _yield$axios7.data;

            if (data) {
              _context13.next = 37;
              break;
            }

            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("[".concat(type, "]\u8BF7\u6C42\u5207\u6362\u8BED\u8A00\u63A5\u53E3\u5931\u8D25"));
            return _context13.abrupt("return");

          case 37:
            _context13.next = 39;
            return Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* setCookies */ "C"])({
              url: host,
              name: 'seller_language',
              value: 'en'
            });

          case 39:
            setCookieRes = _context13.sent;

            if (!(setCookieRes && setCookieRes.value === 'en')) {
              _context13.next = 42;
              break;
            }

            return _context13.abrupt("return", true);

          case 42:
            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("[".concat(type, "]\u8BED\u8A00\u5207\u6362\u5931\u8D25"));
            _context13.next = 48;
            break;

          case 45:
            _context13.prev = 45;
            _context13.t4 = _context13["catch"](2);
            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("[".concat(type, "]\u5207\u6362temu ").concat(type, "\u7AD9\u70B9\u8BED\u8A00\u62A5\u9519-----").concat(Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* isError */ "r"])(_context13.t4)));

          case 48:
          case "end":
            return _context13.stop();
        }
      }
    }, _callee13, null, [[2, 45]]);
  }));

  return function changeLanguage(_x9) {
    return _ref17.apply(this, arguments);
  };
}();

var createNewTabs = function createNewTabs(url, task) {
  return new Promise(function (resolve) {
    chrome.tabs.create({
      url: url,
      active: false
    }, /*#__PURE__*/function () {
      var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(tab) {
        var res;
        return _regeneratorRuntime().wrap(function _callee14$(_context14) {
          while (1) {
            switch (_context14.prev = _context14.next) {
              case 0:
                if (tab) {
                  _context14.next = 4;
                  break;
                }

                _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog('temu分区页面可能已被关闭1');
                resolve({
                  code: 16
                });
                return _context14.abrupt("return");

              case 4:
                _context14.next = 6;
                return checkTemuCbTask(tab.id, task, 1);

              case 6:
                res = _context14.sent;
                resolve(res);

              case 8:
              case "end":
                return _context14.stop();
            }
          }
        }, _callee14);
      }));

      return function (_x10) {
        return _ref18.apply(this, arguments);
      };
    }());
  });
}; // export const loginCb = async (Mallid, redirectUrl) => {
//   try {
//     const { data } = await axios({
//       url: `https://seller.kuajingmaihuo.com/bg/quiet/api/auth/obtainCode`,
//       method: 'post',
//       data: { redirectUrl: redirectUrl + '/main/authentication' },
//       headers: {
//         Mallid
//       }
//     })
//     if (data && data.success) {
//       const res = await createNewTabs(`${redirectUrl}/main/authentication?redirectUrl=${redirectUrl}&mallId=${Mallid}&asCode=${data.result.code}`, { code: data.result.code, host: redirectUrl, Mallid })
//       if (res) {
//         if (res.code) {
//           log.setLog(`切换temu分区站点报错-----${JSON.stringify(res)}`)
//           return false
//         }
//         log.setLog('切换temu分区站点成功')
//         return true
//       } else {
//         log.setLog(`切换temu分区站点报错-----${JSON.stringify(res)}`)
//         return false
//       }
//     }
//   } catch (e) {
//     log.setLog(`切换temu分区站点报错-----${JSON.stringify(e)}`)
//     return false
//   }
// }


var loginCb = /*#__PURE__*/function () {
  var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(task) {
    var Mallid, redirectUrl, _yield$axios8, data, _yield$nativeRequest, errorMsg, success;

    return _regeneratorRuntime().wrap(function _callee15$(_context15) {
      while (1) {
        switch (_context15.prev = _context15.next) {
          case 0:
            _context15.prev = 0;
            Mallid = task.platform_store_id, redirectUrl = task.host;
            _context15.next = 4;
            return axios__WEBPACK_IMPORTED_MODULE_0___default()({
              url: "https://seller.kuajingmaihuo.com/bg/quiet/api/auth/obtainCode",
              method: 'post',
              data: {
                redirectUrl: redirectUrl + '/main/authentication'
              },
              headers: {
                Mallid: Mallid
              }
            });

          case 4:
            _yield$axios8 = _context15.sent;
            data = _yield$axios8.data;

            if (!(data && data.success)) {
              _context15.next = 23;
              break;
            }

            _context15.next = 9;
            return Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* nativeRequest */ "u"])("".concat(redirectUrl, "/api/seller/auth/loginByCode"), 'post', {
              code: data.result.code,
              confirm: true,
              targetMallId: Mallid
            });

          case 9:
            _yield$nativeRequest = _context15.sent;
            errorMsg = _yield$nativeRequest.errorMsg;
            success = _yield$nativeRequest.success;

            if (!success) {
              _context15.next = 19;
              break;
            }

            _context15.next = 15;
            return Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* setCookies */ "C"])({
              url: redirectUrl,
              name: 'mallid',
              value: String(Mallid)
            });

          case 15:
            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog('切换temu分区站点成功');
            return _context15.abrupt("return", true);

          case 19:
            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].report("\u5207\u6362temu\u5206\u533A\u7AD9\u70B9\u62A5\u9519\uFF0CloginByCode\u8BF7\u6C42\u5931\u8D25-----".concat(errorMsg));
            return _context15.abrupt("return", false);

          case 21:
            _context15.next = 25;
            break;

          case 23:
            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u5207\u6362temu\u5206\u533A\u7AD9\u70B9\u62A5\u9519-----errorMsg: ".concat(data ? data.errorMsg : '', "----errorCode:").concat(data ? data.errorCode : ''));
            return _context15.abrupt("return", false);

          case 25:
            _context15.next = 31;
            break;

          case 27:
            _context15.prev = 27;
            _context15.t0 = _context15["catch"](0);
            _data_log__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].setLog("\u5207\u6362temu\u5206\u533A\u7AD9\u70B9\u62A5\u9519-----".concat(Object(_utils_util__WEBPACK_IMPORTED_MODULE_2__[/* isError */ "r"])(_context15.t0, task)));
            return _context15.abrupt("return", false);

          case 31:
          case "end":
            return _context15.stop();
        }
      }
    }, _callee15, null, [[0, 27]]);
  }));

  return function loginCb(_x11) {
    return _ref19.apply(this, arguments);
  };
}(); // window.testUs = async () => {
//   const res = await loginCb(634418215364437, temu.cbEuHost)
//   log.setLog('testUs', res)
// }

/***/ })

}]);