@steedos-labs/content-compliance-bev 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateSpotCheckPool = exports.clickPoolSpotEmail = exports.clickReportSpotEmail = exports.sendMonthlySpotCheckReport = exports.clickSpotEmail = exports.spotCheckMaterial = void 0;
3
+ exports.remindSpotCheckIncomplete = exports.generateSpotCheckPool = exports.clickPoolSpotEmail = exports.clickReportSpotEmail = exports.sendMonthlySpotCheckReport = exports.clickSpotEmail = exports.spotCheckMaterial = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var lodash_1 = require("lodash");
6
6
  var axios_1 = require("axios");
@@ -428,7 +428,7 @@ exports.sendMonthlySpotCheckReport = {
428
428
  },
429
429
  handler: function (ctx) {
430
430
  return tslib_1.__awaiter(this, void 0, void 0, function () {
431
- var user, rid, logger, report, yearMonth, data, _a, monthStart, monthEnd, brandList, brandLeaderList, _loop_1, brandLeaderList_1, brandLeaderList_1_1, brandLeader, e_3_1;
431
+ var user, rid, logger, report, yearMonth, data, _a, monthStart, monthEnd, brandList, brandLeaderList, results, skipped, _loop_1, brandLeaderList_1, brandLeaderList_1_1, brandLeader, e_3_1;
432
432
  var e_3, _b;
433
433
  return tslib_1.__generator(this, function (_c) {
434
434
  switch (_c.label) {
@@ -462,6 +462,8 @@ exports.sendMonthlySpotCheckReport = {
462
462
  return [4, ctx.getObject('pepsico_brand_leader').directFind({ filters: [] })];
463
463
  case 3:
464
464
  brandLeaderList = _c.sent();
465
+ results = [];
466
+ skipped = [];
465
467
  _loop_1 = function (brandLeader) {
466
468
  var list, subject, brand, lid, html, toUsers, toUsersAll, error_3, ccUsers, ccUsersAll, error_4, result;
467
469
  return tslib_1.__generator(this, function (_d) {
@@ -474,46 +476,65 @@ exports.sendMonthlySpotCheckReport = {
474
476
  console.log('sendMonthlySpotCheckReport find', brandLeader.name, list.length, JSON.stringify({
475
477
  filters: [['spot_checked_done', '=', true], ['product', '=', brandLeader.name], ['classification', '=', brandLeader.classification], ['spot_checked_done_time', '>=', monthStart], ['spot_checked_done_time', '<=', monthEnd]]
476
478
  }));
477
- if (!(list.length > 0)) return [3, 13];
479
+ if (!(list.length > 0)) return [3, 14];
478
480
  subject = "\u3010\u7CFB\u7EDF\u901A\u77E5\u3011".concat(brandLeader.remark, "\u6708\u5EA6\u62BD\u67E5\u62A5\u544A[").concat(yearMonth, "]");
479
481
  brand = (0, lodash_1.find)(brandList, function (item) { return item.value === brandLeader.name; });
480
- if (!brandLeader) return [3, 13];
481
- return [4, ctx.getObject('pepsico_mail_send_log')._makeNewID()];
482
+ if (!!brand) return [3, 2];
483
+ skipped.push({
484
+ product: brandLeader.name,
485
+ classification: brandLeader.classification,
486
+ count: list.length,
487
+ reason: '未找到品牌映射'
488
+ });
489
+ console.log('sendMonthlySpotCheckReport skip unknown brand', brandLeader.name, brandLeader.classification);
490
+ return [3, 14];
482
491
  case 2:
492
+ if (!brandLeader) return [3, 14];
493
+ return [4, ctx.getObject('pepsico_mail_send_log')._makeNewID()];
494
+ case 3:
483
495
  lid = _d.sent();
484
496
  html = "\n <p>\u4EB2\u7231\u7684\u7528\u6237\uFF0C</p>\n <p>\u672C\u6708".concat(brand.label, "\u62BD\u67E5\u7D20\u6750\u62A5\u544A\u5DF2\u751F\u6210\u3002 \u8BF7\u70B9\u51FB\u4E0B\u9762\u94FE\u63A5\u67E5\u770B").concat(brand.label, "\u6708\u5EA6\u62BD\u67E5\u62A5\u544A\uFF0C\u5EFA\u8BAE\u5206\u4EAB\u7ED9\u56E2\u961F\u6210\u5458\u8FDB\u884C\u5B66\u4E60\u3002</p>\n <a href=\"").concat(process.env.ROOT_URL, "/api/pepsico-content/material/click/spot-report/").concat(rid, "/").concat(lid, "\">").concat(brandLeader.remark, "\uFF1A").concat(yearMonth, "</a>\n <p>\u6709\u4EFB\u4F55\u7591\u95EE\uFF0C\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\u3002</p>\n <p>\u8C22\u8C22\uFF01</p>\n ");
485
497
  toUsers = [];
486
- if (!brandLeader.to) return [3, 6];
487
- _d.label = 3;
488
- case 3:
489
- _d.trys.push([3, 5, , 6]);
490
- return [4, ctx.getObject('space_users').find({ filters: ['user', 'in', brandLeader.to] })];
498
+ if (!brandLeader.to) return [3, 7];
499
+ _d.label = 4;
491
500
  case 4:
501
+ _d.trys.push([4, 6, , 7]);
502
+ return [4, ctx.getObject('space_users').find({ filters: ['user', 'in', brandLeader.to] })];
503
+ case 5:
492
504
  toUsersAll = _d.sent();
493
505
  toUsers = toUsersAll.filter(function (u) { return u.email && u.email.endsWith('@pepsico.com'); });
494
- return [3, 6];
495
- case 5:
506
+ return [3, 7];
507
+ case 6:
496
508
  error_3 = _d.sent();
497
509
  console.log(error_3);
498
- return [3, 6];
499
- case 6:
500
- ccUsers = [];
501
- if (!brandLeader.cc) return [3, 10];
502
- _d.label = 7;
510
+ return [3, 7];
503
511
  case 7:
504
- _d.trys.push([7, 9, , 10]);
505
- return [4, ctx.getObject('space_users').find({ filters: ['user', 'in', brandLeader.cc] })];
512
+ ccUsers = [];
513
+ if (!brandLeader.cc) return [3, 11];
514
+ _d.label = 8;
506
515
  case 8:
516
+ _d.trys.push([8, 10, , 11]);
517
+ return [4, ctx.getObject('space_users').find({ filters: ['user', 'in', brandLeader.cc] })];
518
+ case 9:
507
519
  ccUsersAll = _d.sent();
508
520
  ccUsers = ccUsersAll.filter(function (u) { return u.email && u.email.endsWith('@pepsico.com'); });
509
- return [3, 10];
510
- case 9:
521
+ return [3, 11];
522
+ case 10:
511
523
  error_4 = _d.sent();
512
524
  console.log(error_4);
513
- return [3, 10];
514
- case 10: return [4, sendEmail(process.env.B6_EMAIL_FROM, (0, lodash_1.join)((0, lodash_1.map)(toUsers, 'email'), ';'), subject, '', html, (0, lodash_1.join)((0, lodash_1.map)(ccUsers, 'email'), ';'))];
515
- case 11:
525
+ return [3, 11];
526
+ case 11: return [4, sendEmail(process.env.B6_EMAIL_FROM, (0, lodash_1.join)((0, lodash_1.map)(toUsers, 'email'), ';'), subject, '', html, (0, lodash_1.join)((0, lodash_1.map)(ccUsers, 'email'), ';'))];
527
+ case 12:
516
528
  result = _d.sent();
529
+ results.push({
530
+ product: brand.value,
531
+ product_label: brand.label,
532
+ classification: brandLeader.classification,
533
+ count: list.length,
534
+ to: (0, lodash_1.map)(toUsers, 'email'),
535
+ cc: (0, lodash_1.map)(ccUsers, 'email'),
536
+ result: result
537
+ });
517
538
  return [4, ctx.getObject('pepsico_mail_send_log').insert({
518
539
  _id: lid,
519
540
  name: subject,
@@ -528,10 +549,10 @@ exports.sendMonthlySpotCheckReport = {
528
549
  result: result,
529
550
  space: report.space
530
551
  }, user)];
531
- case 12:
552
+ case 13:
532
553
  _d.sent();
533
- _d.label = 13;
534
- case 13: return [2];
554
+ _d.label = 14;
555
+ case 14: return [2];
535
556
  }
536
557
  });
537
558
  };
@@ -567,7 +588,18 @@ exports.sendMonthlySpotCheckReport = {
567
588
  })];
568
589
  case 12:
569
590
  _c.sent();
570
- return [2];
591
+ return [2, {
592
+ status: 200,
593
+ msg: '月度抽查报告邮件发送完成',
594
+ data: {
595
+ year_month: yearMonth,
596
+ brand_leader_count: brandLeaderList.length,
597
+ sent_count: results.length,
598
+ skipped_count: skipped.length,
599
+ results: results,
600
+ skipped: skipped
601
+ }
602
+ }];
571
603
  }
572
604
  });
573
605
  });
@@ -858,34 +890,34 @@ exports.generateSpotCheckPool = {
858
890
  },
859
891
  handler: function (ctx) {
860
892
  return tslib_1.__awaiter(this, void 0, void 0, function () {
861
- var user, pid, logger, pool, yearMonth, pools, logs, _a, _b, material, approval, e_5_1, _c, _d, material, approval, e_6_1, subject, html, toUsers, users, toUsersAll, error_6, ccUsers, result, error_7;
862
- var e_5, _e, e_6, _f;
863
- return tslib_1.__generator(this, function (_g) {
864
- switch (_g.label) {
893
+ var user, pid, logger, pool, yearMonth, pools, logs, logs_1, departmentUserIds_2, _a, _b, material, approval, _c, _d, field, users, e_5_1, specialistUserIds_2, _e, _f, material, approval, sUsers, e_6_1, ROOT_URL, subject, midTierLink, midTierHtml, departmentToUsers, toUsersAll, error_6, midTierResult, _g, microLink, microHtml, specialistToUsers, toUsersAll, error_7, microResult, _h, fromUserId, departmentUserIds_1, departmentUserIds_1_1, userId, e_7_1, specialistUserIds_1, specialistUserIds_1_1, userId, e_8_1, error_8, error_9, message, updateError_1;
894
+ var e_5, _j, e_9, _k, e_6, _l, e_7, _m, e_8, _o;
895
+ return tslib_1.__generator(this, function (_p) {
896
+ switch (_p.label) {
865
897
  case 0:
866
898
  user = ctx.meta.user;
867
899
  pid = ctx.params.pid;
868
900
  ctx.getObject = this.getObject;
869
901
  return [4, this.getLogger()];
870
902
  case 1:
871
- logger = _g.sent();
903
+ logger = _p.sent();
872
904
  ctx.logger = logger;
873
905
  if (user && !user.is_space_admin) {
874
906
  throw new Error('无权限');
875
907
  }
876
908
  return [4, ctx.getObject('pepsico_spot_check_pool').findOne(pid)];
877
909
  case 2:
878
- pool = _g.sent();
910
+ pool = _p.sent();
879
911
  if (!pool) {
880
912
  throw new Error('无效的id');
881
913
  }
882
914
  yearMonth = pool.year_month;
883
- _g.label = 3;
915
+ _p.label = 3;
884
916
  case 3:
885
- _g.trys.push([3, 29, , 30]);
917
+ _p.trys.push([3, 58, , 63]);
886
918
  return [4, getSpotCheckPool(yearMonth)];
887
919
  case 4:
888
- pools = _g.sent();
920
+ pools = _p.sent();
889
921
  console.log('=== 腰部(Mid-tier)抽查池子 ===');
890
922
  console.log("\u603B\u62BD\u6837\u6570: ".concat(pools['Mid-tier'].samplingPool.length), (0, lodash_1.map)(pools['Mid-tier'].samplingPool, function (item) { return (0, lodash_1.pick)(item, ['_id', 'product']); }));
891
923
  console.log('品牌统计:', pools['Mid-tier'].statistics.byBrand);
@@ -893,21 +925,38 @@ exports.generateSpotCheckPool = {
893
925
  console.log("\u603B\u62BD\u6837\u6570: ".concat(pools['Micro'].samplingPool.length), (0, lodash_1.map)(pools['Micro'].samplingPool, function (item) { return (0, lodash_1.pick)(item, ['_id', 'product']); }));
894
926
  console.log('品牌统计:', pools['Micro'].statistics.byBrand);
895
927
  logs = "\n [".concat(yearMonth, "] \u627E\u5230 ").concat(pools.count, " \u4E2A\u5BA1\u6279\u5B8C\u6210\u7684\u7D20\u6750 \r\n\n === \u8170\u90E8(Mid-tier)\u62BD\u67E5\u6C60\u5B50 === \r\n\n \u603B\u62BD\u6837\u6570: ").concat(pools['Mid-tier'].samplingPool.length, ", ").concat(JSON.stringify((0, lodash_1.map)(pools['Mid-tier'].samplingPool, function (item) { return (0, lodash_1.pick)(item, ['_id', 'product']); })), " \r\n\n \u54C1\u724C\u7EDF\u8BA1:, ").concat(JSON.stringify(pools['Mid-tier'].statistics.byBrand), " \r\n\n \n=== \u5C3E\u90E8(Micro)\u62BD\u67E5\u6C60\u5B50 ===' \r\n\n \u603B\u62BD\u6837\u6570: ").concat(pools['Micro'].samplingPool.length, ", ").concat(JSON.stringify((0, lodash_1.map)(pools['Micro'].samplingPool, function (item) { return (0, lodash_1.pick)(item, ['_id', 'product']); })), " \r\n\n \u54C1\u724C\u7EDF\u8BA1:, ").concat(JSON.stringify(pools['Micro'].statistics.byBrand), " \r\n\n ");
896
- if (pools.count < 1) {
897
- console.log('无可抽查素材. 不发送邮件.');
898
- return [2];
899
- }
900
- _g.label = 5;
928
+ if (!(pools.count < 1)) return [3, 6];
929
+ logs_1 = "[".concat(yearMonth, "] \u627E\u5230 0 \u4E2A\u5BA1\u6279\u5B8C\u6210\u7684\u7D20\u6750\uFF0C\u672A\u53D1\u9001\u90AE\u4EF6\u3002");
930
+ console.log('无可抽查素材. 不发送邮件.');
931
+ return [4, ctx.getObject('pepsico_spot_check_pool').directUpdate(pid, {
932
+ logs: logs_1
933
+ })];
901
934
  case 5:
902
- _g.trys.push([5, 11, 12, 13]);
903
- _a = tslib_1.__values(pools['Mid-tier'].samplingPool), _b = _a.next();
904
- _g.label = 6;
935
+ _p.sent();
936
+ return [2, {
937
+ status: 200,
938
+ msg: '无可抽查素材,未发送邮件',
939
+ data: {
940
+ year_month: yearMonth,
941
+ count: pools.count
942
+ }
943
+ }];
905
944
  case 6:
906
- if (!!_b.done) return [3, 10];
945
+ departmentUserIds_2 = new Set();
946
+ _p.label = 7;
947
+ case 7:
948
+ _p.trys.push([7, 13, 14, 15]);
949
+ _a = tslib_1.__values(pools['Mid-tier'].samplingPool), _b = _a.next();
950
+ _p.label = 8;
951
+ case 8:
952
+ if (!!_b.done) return [3, 12];
907
953
  material = _b.value;
908
954
  return [4, ctx.getObject('pepsico_material_approval').findOne(material.pepsico_material_approval)];
909
- case 7:
910
- approval = _g.sent();
955
+ case 9:
956
+ approval = _p.sent();
957
+ if (!approval) {
958
+ throw new Error("\u7D20\u6750 ".concat(material._id, " \u672A\u627E\u5230\u5173\u8054\u7684\u7D20\u6750\u5BA1\u6279\u5355"));
959
+ }
911
960
  return [4, ctx.getObject('pepsico_material').directUpdate(material._id, {
912
961
  spot_check_pool_year_month: yearMonth,
913
962
  spot_checked: true,
@@ -917,98 +966,486 @@ exports.generateSpotCheckPool = {
917
966
  ns_spot_check_user: approval.ns_spot_check,
918
967
  ca_spot_check_user: approval.ca_spot_check
919
968
  })];
920
- case 8:
921
- _g.sent();
922
- _g.label = 9;
923
- case 9:
924
- _b = _a.next();
925
- return [3, 6];
926
- case 10: return [3, 13];
969
+ case 10:
970
+ _p.sent();
971
+ try {
972
+ for (_c = (e_9 = void 0, tslib_1.__values(['legal_spot_check', 'sra_spot_check', 'ns_spot_check', 'ca_spot_check'])), _d = _c.next(); !_d.done; _d = _c.next()) {
973
+ field = _d.value;
974
+ users = approval[field];
975
+ if (users) {
976
+ (Array.isArray(users) ? users : [users]).forEach(function (id) { return departmentUserIds_2.add(id); });
977
+ }
978
+ }
979
+ }
980
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
981
+ finally {
982
+ try {
983
+ if (_d && !_d.done && (_k = _c.return)) _k.call(_c);
984
+ }
985
+ finally { if (e_9) throw e_9.error; }
986
+ }
987
+ _p.label = 11;
927
988
  case 11:
928
- e_5_1 = _g.sent();
989
+ _b = _a.next();
990
+ return [3, 8];
991
+ case 12: return [3, 15];
992
+ case 13:
993
+ e_5_1 = _p.sent();
929
994
  e_5 = { error: e_5_1 };
930
- return [3, 13];
931
- case 12:
995
+ return [3, 15];
996
+ case 14:
932
997
  try {
933
- if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
998
+ if (_b && !_b.done && (_j = _a.return)) _j.call(_a);
934
999
  }
935
1000
  finally { if (e_5) throw e_5.error; }
936
1001
  return [7];
937
- case 13:
938
- _g.trys.push([13, 19, 20, 21]);
939
- _c = tslib_1.__values(pools['Micro'].samplingPool), _d = _c.next();
940
- _g.label = 14;
941
- case 14:
942
- if (!!_d.done) return [3, 18];
943
- material = _d.value;
944
- return [4, ctx.getObject('pepsico_material_approval').findOne(material.pepsico_material_approval)];
945
1002
  case 15:
946
- approval = _g.sent();
1003
+ specialistUserIds_2 = new Set();
1004
+ _p.label = 16;
1005
+ case 16:
1006
+ _p.trys.push([16, 22, 23, 24]);
1007
+ _e = tslib_1.__values(pools['Micro'].samplingPool), _f = _e.next();
1008
+ _p.label = 17;
1009
+ case 17:
1010
+ if (!!_f.done) return [3, 21];
1011
+ material = _f.value;
1012
+ return [4, ctx.getObject('pepsico_material_approval').findOne(material.pepsico_material_approval)];
1013
+ case 18:
1014
+ approval = _p.sent();
1015
+ if (!approval) {
1016
+ throw new Error("\u7D20\u6750 ".concat(material._id, " \u672A\u627E\u5230\u5173\u8054\u7684\u7D20\u6750\u5BA1\u6279\u5355"));
1017
+ }
947
1018
  return [4, ctx.getObject('pepsico_material').directUpdate(material._id, {
948
1019
  spot_check_pool_year_month: yearMonth,
949
1020
  spot_checked: true,
950
1021
  spot_check_type: '审核专员抽查',
951
1022
  guding_spot_check_user: approval.special_spot_check || []
952
1023
  })];
953
- case 16:
954
- _g.sent();
955
- _g.label = 17;
956
- case 17:
957
- _d = _c.next();
958
- return [3, 14];
959
- case 18: return [3, 21];
960
1024
  case 19:
961
- e_6_1 = _g.sent();
962
- e_6 = { error: e_6_1 };
963
- return [3, 21];
1025
+ _p.sent();
1026
+ sUsers = approval.special_spot_check;
1027
+ if (sUsers) {
1028
+ (Array.isArray(sUsers) ? sUsers : [sUsers]).forEach(function (id) { return specialistUserIds_2.add(id); });
1029
+ }
1030
+ _p.label = 20;
964
1031
  case 20:
1032
+ _f = _e.next();
1033
+ return [3, 17];
1034
+ case 21: return [3, 24];
1035
+ case 22:
1036
+ e_6_1 = _p.sent();
1037
+ e_6 = { error: e_6_1 };
1038
+ return [3, 24];
1039
+ case 23:
965
1040
  try {
966
- if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
1041
+ if (_f && !_f.done && (_l = _e.return)) _l.call(_e);
967
1042
  }
968
1043
  finally { if (e_6) throw e_6.error; }
969
1044
  return [7];
970
- case 21:
971
- subject = '【系统通知】抽查素材通知';
972
- html = "\n <p>\u4EB2\u7231\u7684\u7528\u6237\uFF0C</p>\n <p>\u3010".concat(yearMonth, "\u3011\u6708\u5EA6\u62BD\u67E5\u7D20\u6750\u6C60\u5DF2\u751F\u6210\uFF0C\u8BF7\u767B\u5F55Bev\u5185\u5BB9\u5BA1\u6838\u7CFB\u7EDF\u8FDB\u884C\u7D20\u6750\u62BD\u67E5\u3002</p>\n <p>\u6709\u4EFB\u4F55\u7591\u95EE\uFF0C\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\u3002</p>\n <p>\u8C22\u8C22\uFF01</p>\n ");
973
- toUsers = [];
974
- return [4, ctx.getObject('permission_set').directFind({
975
- filters: ['name', '=', 'pepsico_spot_check_users']
976
- })];
977
- case 22:
978
- users = _g.sent();
979
- if (!(users.length > 0)) return [3, 26];
980
- _g.label = 23;
981
- case 23:
982
- _g.trys.push([23, 25, , 26]);
983
- return [4, ctx.getObject('space_users').find({ filters: ['user', 'in', users[0].users || []] })];
984
1045
  case 24:
985
- toUsersAll = _g.sent();
986
- toUsers = toUsersAll.filter(function (u) { return u.email && u.email.endsWith('@pepsico.com'); });
987
- return [3, 26];
1046
+ ROOT_URL = process.env.ROOT_URL;
1047
+ subject = '【系统通知】抽查素材通知';
1048
+ midTierLink = "".concat(ROOT_URL, "/app/pepsico_content_review/pepsico_midtier_spot_check");
1049
+ midTierHtml = "\n <p>\u4EB2\u7231\u7684\u7528\u6237\uFF0C</p>\n <p>\u3010".concat(yearMonth, "\u3011\u6708\u5EA6\u62BD\u67E5\u7D20\u6750\u6C60\u5DF2\u751F\u6210\u3002\u8BF7\u70B9\u51FB\u4EE5\u4E0B\u94FE\u63A5\u8FDB\u5165\u62BD\u67E5\u9875\u9762\uFF1A</p>\n <p><a href=\"").concat(midTierLink, "\">\u70B9\u51FB\u8FDB\u5165\u62BD\u67E5</a></p>\n <p>\u6709\u4EFB\u4F55\u7591\u95EE\uFF0C\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\u3002</p>\n <p>\u8C22\u8C22\uFF01</p>\n ");
1050
+ departmentToUsers = [];
1051
+ if (!(departmentUserIds_2.size > 0)) return [3, 28];
1052
+ _p.label = 25;
988
1053
  case 25:
989
- error_6 = _g.sent();
990
- console.log(error_6);
991
- return [3, 26];
1054
+ _p.trys.push([25, 27, , 28]);
1055
+ return [4, ctx.getObject('space_users').find({ filters: ['user', 'in', Array.from(departmentUserIds_2)] })];
992
1056
  case 26:
993
- ccUsers = [];
994
- return [4, sendEmail(process.env.B6_EMAIL_FROM, (0, lodash_1.join)((0, lodash_1.map)(toUsers, 'email'), ';'), subject, '', html, (0, lodash_1.join)((0, lodash_1.map)(ccUsers, 'email'), ';'))];
1057
+ toUsersAll = _p.sent();
1058
+ departmentToUsers = toUsersAll.filter(function (u) { return u.email && u.email.endsWith('@pepsico.com'); });
1059
+ return [3, 28];
995
1060
  case 27:
996
- result = _g.sent();
997
- return [4, ctx.getObject('pepsico_spot_check_pool').directUpdate(pid, {
998
- mail_send: true,
999
- mail_send_date: new Date(),
1000
- mid_tier_pepsico_material: (0, lodash_1.map)(pools['Mid-tier'].samplingPool, '_id'),
1001
- micro_pepsico_material: (0, lodash_1.map)(pools['Micro'].samplingPool, '_id'),
1002
- logs: logs + '\r\n' + "=== \u53D1\u9001\u90AE\u4EF6 === \r\n\n \u90AE\u4EF6\u4E3B\u9898: ".concat(subject, "\r\n\n \u6536\u4EF6\u4EBA: ").concat((0, lodash_1.join)((0, lodash_1.map)(toUsers, 'email'), ';'), "\r\n\n \u6284\u9001: ").concat((0, lodash_1.join)((0, lodash_1.map)(ccUsers, 'email'), ';'), "\r\n\n \u90AE\u4EF6\u5185\u5BB9: ").concat(html, "\r\n\n \u90AE\u4EF6\u53D1\u9001\u7ED3\u679C: ").concat(result, "\n ")
1003
- })];
1061
+ error_6 = _p.sent();
1062
+ console.log(error_6);
1063
+ return [3, 28];
1004
1064
  case 28:
1005
- _g.sent();
1006
- return [3, 30];
1065
+ if (!(departmentToUsers.length > 0)) return [3, 30];
1066
+ return [4, sendEmail(process.env.B6_EMAIL_FROM, (0, lodash_1.join)((0, lodash_1.map)(departmentToUsers, 'email'), ';'), subject, '', midTierHtml, '')];
1007
1067
  case 29:
1008
- error_7 = _g.sent();
1009
- console.error('执行失败:', error_7);
1010
- return [3, 30];
1011
- case 30: return [2];
1068
+ _g = _p.sent();
1069
+ return [3, 31];
1070
+ case 30:
1071
+ _g = '无收件人';
1072
+ _p.label = 31;
1073
+ case 31:
1074
+ midTierResult = _g;
1075
+ microLink = "".concat(ROOT_URL, "/app/pepsico_content_review/pepsico_spot_check");
1076
+ microHtml = "\n <p>\u4EB2\u7231\u7684\u7528\u6237\uFF0C</p>\n <p>\u3010".concat(yearMonth, "\u3011\u6708\u5EA6\u62BD\u67E5\u7D20\u6750\u6C60\u5DF2\u751F\u6210\u3002\u8BF7\u70B9\u51FB\u4EE5\u4E0B\u94FE\u63A5\u8FDB\u5165\u62BD\u67E5\u9875\u9762\uFF1A</p>\n <p><a href=\"").concat(microLink, "\">\u70B9\u51FB\u8FDB\u5165\u62BD\u67E5</a></p>\n <p>\u6709\u4EFB\u4F55\u7591\u95EE\uFF0C\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\u3002</p>\n <p>\u8C22\u8C22\uFF01</p>\n ");
1077
+ specialistToUsers = [];
1078
+ if (!(specialistUserIds_2.size > 0)) return [3, 35];
1079
+ _p.label = 32;
1080
+ case 32:
1081
+ _p.trys.push([32, 34, , 35]);
1082
+ return [4, ctx.getObject('space_users').find({ filters: ['user', 'in', Array.from(specialistUserIds_2)] })];
1083
+ case 33:
1084
+ toUsersAll = _p.sent();
1085
+ specialistToUsers = toUsersAll.filter(function (u) { return u.email && u.email.endsWith('@pepsico.com'); });
1086
+ return [3, 35];
1087
+ case 34:
1088
+ error_7 = _p.sent();
1089
+ console.log(error_7);
1090
+ return [3, 35];
1091
+ case 35:
1092
+ if (!(specialistToUsers.length > 0)) return [3, 37];
1093
+ return [4, sendEmail(process.env.B6_EMAIL_FROM, (0, lodash_1.join)((0, lodash_1.map)(specialistToUsers, 'email'), ';'), subject, '', microHtml, '')];
1094
+ case 36:
1095
+ _h = _p.sent();
1096
+ return [3, 38];
1097
+ case 37:
1098
+ _h = '无收件人';
1099
+ _p.label = 38;
1100
+ case 38:
1101
+ microResult = _h;
1102
+ _p.label = 39;
1103
+ case 39:
1104
+ _p.trys.push([39, 55, , 56]);
1105
+ fromUserId = (user === null || user === void 0 ? void 0 : user.userId) || pool.owner || pool.created_by;
1106
+ _p.label = 40;
1107
+ case 40:
1108
+ _p.trys.push([40, 45, 46, 47]);
1109
+ departmentUserIds_1 = tslib_1.__values(departmentUserIds_2), departmentUserIds_1_1 = departmentUserIds_1.next();
1110
+ _p.label = 41;
1111
+ case 41:
1112
+ if (!!departmentUserIds_1_1.done) return [3, 44];
1113
+ userId = departmentUserIds_1_1.value;
1114
+ return [4, ctx.broker.call('notifications.add', {
1115
+ message: {
1116
+ name: "\u3010".concat(yearMonth, "\u3011\u6708\u5EA6\u62BD\u67E5\u7D20\u6750\u6C60\u5DF2\u751F\u6210\uFF0C\u8BF7\u8FDB\u884C\u8170\u90E8\u7D20\u6750\u62BD\u67E5"),
1117
+ body: '',
1118
+ related_to: { o: 'pepsico_spot_check_pool', ids: [pid] },
1119
+ related_name: pool.name || yearMonth,
1120
+ from: fromUserId,
1121
+ space: pool.space
1122
+ },
1123
+ from: fromUserId,
1124
+ to: userId
1125
+ })];
1126
+ case 42:
1127
+ _p.sent();
1128
+ _p.label = 43;
1129
+ case 43:
1130
+ departmentUserIds_1_1 = departmentUserIds_1.next();
1131
+ return [3, 41];
1132
+ case 44: return [3, 47];
1133
+ case 45:
1134
+ e_7_1 = _p.sent();
1135
+ e_7 = { error: e_7_1 };
1136
+ return [3, 47];
1137
+ case 46:
1138
+ try {
1139
+ if (departmentUserIds_1_1 && !departmentUserIds_1_1.done && (_m = departmentUserIds_1.return)) _m.call(departmentUserIds_1);
1140
+ }
1141
+ finally { if (e_7) throw e_7.error; }
1142
+ return [7];
1143
+ case 47:
1144
+ _p.trys.push([47, 52, 53, 54]);
1145
+ specialistUserIds_1 = tslib_1.__values(specialistUserIds_2), specialistUserIds_1_1 = specialistUserIds_1.next();
1146
+ _p.label = 48;
1147
+ case 48:
1148
+ if (!!specialistUserIds_1_1.done) return [3, 51];
1149
+ userId = specialistUserIds_1_1.value;
1150
+ return [4, ctx.broker.call('notifications.add', {
1151
+ message: {
1152
+ name: "\u3010".concat(yearMonth, "\u3011\u6708\u5EA6\u62BD\u67E5\u7D20\u6750\u6C60\u5DF2\u751F\u6210\uFF0C\u8BF7\u8FDB\u884C\u5C3E\u90E8\u7D20\u6750\u62BD\u67E5"),
1153
+ body: '',
1154
+ related_to: { o: 'pepsico_spot_check_pool', ids: [pid] },
1155
+ related_name: pool.name || yearMonth,
1156
+ from: fromUserId,
1157
+ space: pool.space
1158
+ },
1159
+ from: fromUserId,
1160
+ to: userId
1161
+ })];
1162
+ case 49:
1163
+ _p.sent();
1164
+ _p.label = 50;
1165
+ case 50:
1166
+ specialistUserIds_1_1 = specialistUserIds_1.next();
1167
+ return [3, 48];
1168
+ case 51: return [3, 54];
1169
+ case 52:
1170
+ e_8_1 = _p.sent();
1171
+ e_8 = { error: e_8_1 };
1172
+ return [3, 54];
1173
+ case 53:
1174
+ try {
1175
+ if (specialistUserIds_1_1 && !specialistUserIds_1_1.done && (_o = specialistUserIds_1.return)) _o.call(specialistUserIds_1);
1176
+ }
1177
+ finally { if (e_8) throw e_8.error; }
1178
+ return [7];
1179
+ case 54: return [3, 56];
1180
+ case 55:
1181
+ error_8 = _p.sent();
1182
+ console.log('站内通知发送失败:', error_8);
1183
+ return [3, 56];
1184
+ case 56: return [4, ctx.getObject('pepsico_spot_check_pool').directUpdate(pid, {
1185
+ mail_send: true,
1186
+ mail_send_date: new Date(),
1187
+ mid_tier_pepsico_material: (0, lodash_1.map)(pools['Mid-tier'].samplingPool, '_id'),
1188
+ micro_pepsico_material: (0, lodash_1.map)(pools['Micro'].samplingPool, '_id'),
1189
+ logs: logs + '\r\n' + "=== \u53D1\u9001\u90AE\u4EF6\uFF08\u56DB\u90E8\u95E8-\u8170\u90E8\uFF09 === \r\n\n \u90AE\u4EF6\u4E3B\u9898: ".concat(subject, "\r\n\n \u6536\u4EF6\u4EBA: ").concat((0, lodash_1.join)((0, lodash_1.map)(departmentToUsers, 'email'), ';'), "\r\n\n \u90AE\u4EF6\u5185\u5BB9: ").concat(midTierHtml, "\r\n\n \u90AE\u4EF6\u53D1\u9001\u7ED3\u679C: ").concat(midTierResult, "\r\n\n === \u53D1\u9001\u90AE\u4EF6\uFF08\u4E13\u5458-\u5C3E\u90E8\uFF09 === \r\n\n \u90AE\u4EF6\u4E3B\u9898: ").concat(subject, "\r\n\n \u6536\u4EF6\u4EBA: ").concat((0, lodash_1.join)((0, lodash_1.map)(specialistToUsers, 'email'), ';'), "\r\n\n \u90AE\u4EF6\u5185\u5BB9: ").concat(microHtml, "\r\n\n \u90AE\u4EF6\u53D1\u9001\u7ED3\u679C: ").concat(microResult, "\n ")
1190
+ })];
1191
+ case 57:
1192
+ _p.sent();
1193
+ return [2, {
1194
+ status: 200,
1195
+ msg: '抽查素材池邮件发送完成',
1196
+ data: {
1197
+ year_month: yearMonth,
1198
+ count: pools.count,
1199
+ mid_tier_count: pools['Mid-tier'].samplingPool.length,
1200
+ micro_count: pools['Micro'].samplingPool.length,
1201
+ mid_tier_mail_result: midTierResult,
1202
+ micro_mail_result: microResult
1203
+ }
1204
+ }];
1205
+ case 58:
1206
+ error_9 = _p.sent();
1207
+ message = (error_9 === null || error_9 === void 0 ? void 0 : error_9.message) || String(error_9);
1208
+ console.error('执行失败:', error_9);
1209
+ _p.label = 59;
1210
+ case 59:
1211
+ _p.trys.push([59, 61, , 62]);
1212
+ return [4, ctx.getObject('pepsico_spot_check_pool').directUpdate(pid, {
1213
+ logs: "[".concat(yearMonth, "] \u62BD\u67E5\u7D20\u6750\u6C60\u90AE\u4EF6\u53D1\u9001\u5931\u8D25\uFF1A").concat(message)
1214
+ })];
1215
+ case 60:
1216
+ _p.sent();
1217
+ return [3, 62];
1218
+ case 61:
1219
+ updateError_1 = _p.sent();
1220
+ console.error('记录抽查素材池失败日志失败:', updateError_1);
1221
+ return [3, 62];
1222
+ case 62: throw error_9;
1223
+ case 63: return [2];
1224
+ }
1225
+ });
1226
+ });
1227
+ }
1228
+ };
1229
+ exports.remindSpotCheckIncomplete = {
1230
+ rest: {
1231
+ method: "GET",
1232
+ fullPath: "/api/pepsico-content/remind/spot-check-incomplete"
1233
+ },
1234
+ handler: function (ctx) {
1235
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
1236
+ var user, logger, yearMonth, pendingUsers, midTierMaterials, midTierMaterials_1, midTierMaterials_1_1, material, deptFields, deptFields_1, deptFields_1_1, _a, done, user_1, users, users_2, users_2_1, uid, existing, microMaterials, microMaterials_1, microMaterials_1_1, material, users, users_3, users_3_1, uid, existing, ROOT_URL, midTierLink, microLink, subject, results, userIds, spaceUsers, _loop_2, pendingUsers_1, pendingUsers_1_1, _b, userId, info, e_10_1;
1237
+ var e_11, _c, e_12, _d, e_13, _e, e_14, _f, e_15, _g, e_10, _h;
1238
+ return tslib_1.__generator(this, function (_j) {
1239
+ switch (_j.label) {
1240
+ case 0:
1241
+ user = ctx.meta.user;
1242
+ if (user && !user.is_space_admin) {
1243
+ throw new Error('无权限');
1244
+ }
1245
+ ctx.getObject = this.getObject;
1246
+ return [4, this.getLogger()];
1247
+ case 1:
1248
+ logger = _j.sent();
1249
+ ctx.logger = logger;
1250
+ yearMonth = moment().format('YYYY-MM');
1251
+ console.log("[remindSpotCheckIncomplete] \u5F00\u59CB\u626B\u63CF ".concat(yearMonth, " \u672A\u5B8C\u6210\u62BD\u67E5\u4EFB\u52A1..."));
1252
+ pendingUsers = new Map();
1253
+ return [4, ctx.getObject('pepsico_material').find({
1254
+ filters: [
1255
+ ['spot_check_pool_year_month', '=', yearMonth],
1256
+ ['spot_checked', '=', true],
1257
+ ['spot_checked_done', '!=', true],
1258
+ ['spot_check_type', '=', '四部门抽查']
1259
+ ]
1260
+ })];
1261
+ case 2:
1262
+ midTierMaterials = _j.sent();
1263
+ console.log("[remindSpotCheckIncomplete] \u8170\u90E8\u672A\u5B8C\u6210\u7D20\u6750: ".concat(midTierMaterials.length));
1264
+ try {
1265
+ for (midTierMaterials_1 = tslib_1.__values(midTierMaterials), midTierMaterials_1_1 = midTierMaterials_1.next(); !midTierMaterials_1_1.done; midTierMaterials_1_1 = midTierMaterials_1.next()) {
1266
+ material = midTierMaterials_1_1.value;
1267
+ deptFields = [
1268
+ { done: 'legal_spot_check', user: 'legal_spot_check_user' },
1269
+ { done: 'ns_spot_check', user: 'ns_spot_check_user' },
1270
+ { done: 'sra_spot_check', user: 'sra_spot_check_user' },
1271
+ { done: 'ca_spot_check', user: 'ca_spot_check_user' },
1272
+ ];
1273
+ try {
1274
+ for (deptFields_1 = (e_12 = void 0, tslib_1.__values(deptFields)), deptFields_1_1 = deptFields_1.next(); !deptFields_1_1.done; deptFields_1_1 = deptFields_1.next()) {
1275
+ _a = deptFields_1_1.value, done = _a.done, user_1 = _a.user;
1276
+ if (!material[done] && material[user_1]) {
1277
+ users = Array.isArray(material[user_1]) ? material[user_1] : [material[user_1]];
1278
+ try {
1279
+ for (users_2 = (e_13 = void 0, tslib_1.__values(users)), users_2_1 = users_2.next(); !users_2_1.done; users_2_1 = users_2.next()) {
1280
+ uid = users_2_1.value;
1281
+ if (uid) {
1282
+ existing = pendingUsers.get(uid) || { count: 0, type: '四部门抽查' };
1283
+ existing.count++;
1284
+ pendingUsers.set(uid, existing);
1285
+ }
1286
+ }
1287
+ }
1288
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
1289
+ finally {
1290
+ try {
1291
+ if (users_2_1 && !users_2_1.done && (_e = users_2.return)) _e.call(users_2);
1292
+ }
1293
+ finally { if (e_13) throw e_13.error; }
1294
+ }
1295
+ }
1296
+ }
1297
+ }
1298
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
1299
+ finally {
1300
+ try {
1301
+ if (deptFields_1_1 && !deptFields_1_1.done && (_d = deptFields_1.return)) _d.call(deptFields_1);
1302
+ }
1303
+ finally { if (e_12) throw e_12.error; }
1304
+ }
1305
+ }
1306
+ }
1307
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
1308
+ finally {
1309
+ try {
1310
+ if (midTierMaterials_1_1 && !midTierMaterials_1_1.done && (_c = midTierMaterials_1.return)) _c.call(midTierMaterials_1);
1311
+ }
1312
+ finally { if (e_11) throw e_11.error; }
1313
+ }
1314
+ return [4, ctx.getObject('pepsico_material').find({
1315
+ filters: [
1316
+ ['spot_check_pool_year_month', '=', yearMonth],
1317
+ ['spot_checked', '=', true],
1318
+ ['spot_checked_done', '!=', true],
1319
+ ['spot_check_type', '=', '审核专员抽查']
1320
+ ]
1321
+ })];
1322
+ case 3:
1323
+ microMaterials = _j.sent();
1324
+ console.log("[remindSpotCheckIncomplete] \u5C3E\u90E8\u672A\u5B8C\u6210\u7D20\u6750: ".concat(microMaterials.length));
1325
+ try {
1326
+ for (microMaterials_1 = tslib_1.__values(microMaterials), microMaterials_1_1 = microMaterials_1.next(); !microMaterials_1_1.done; microMaterials_1_1 = microMaterials_1.next()) {
1327
+ material = microMaterials_1_1.value;
1328
+ if (!material.guding_spot_check && material.guding_spot_check_user) {
1329
+ users = Array.isArray(material.guding_spot_check_user) ? material.guding_spot_check_user : [material.guding_spot_check_user];
1330
+ try {
1331
+ for (users_3 = (e_15 = void 0, tslib_1.__values(users)), users_3_1 = users_3.next(); !users_3_1.done; users_3_1 = users_3.next()) {
1332
+ uid = users_3_1.value;
1333
+ if (uid) {
1334
+ existing = pendingUsers.get(uid) || { count: 0, type: '审核专员抽查' };
1335
+ existing.count++;
1336
+ pendingUsers.set(uid, existing);
1337
+ }
1338
+ }
1339
+ }
1340
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
1341
+ finally {
1342
+ try {
1343
+ if (users_3_1 && !users_3_1.done && (_g = users_3.return)) _g.call(users_3);
1344
+ }
1345
+ finally { if (e_15) throw e_15.error; }
1346
+ }
1347
+ }
1348
+ }
1349
+ }
1350
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
1351
+ finally {
1352
+ try {
1353
+ if (microMaterials_1_1 && !microMaterials_1_1.done && (_f = microMaterials_1.return)) _f.call(microMaterials_1);
1354
+ }
1355
+ finally { if (e_14) throw e_14.error; }
1356
+ }
1357
+ if (pendingUsers.size === 0) {
1358
+ console.log("[remindSpotCheckIncomplete] \u5F53\u6708\u65E0\u672A\u5B8C\u6210\u62BD\u67E5\u4EFB\u52A1\uFF0C\u65E0\u9700\u50AC\u529E\u3002");
1359
+ return [2, { success: true, message: '无未完成抽查任务' }];
1360
+ }
1361
+ console.log("[remindSpotCheckIncomplete] \u9700\u50AC\u529E\u7528\u6237\u6570: ".concat(pendingUsers.size));
1362
+ ROOT_URL = process.env.ROOT_URL;
1363
+ midTierLink = "".concat(ROOT_URL, "/app/pepsico_content_review/pepsico_midtier_spot_check");
1364
+ microLink = "".concat(ROOT_URL, "/app/pepsico_content_review/pepsico_spot_check");
1365
+ subject = '【催办通知】您有未完成的抽查任务';
1366
+ results = [];
1367
+ userIds = Array.from(pendingUsers.keys());
1368
+ return [4, ctx.getObject('space_users').find({ filters: ['user', 'in', userIds] })];
1369
+ case 4:
1370
+ spaceUsers = _j.sent();
1371
+ _loop_2 = function (userId, info) {
1372
+ var spaceUser, link, html, error_10, error_11;
1373
+ return tslib_1.__generator(this, function (_k) {
1374
+ switch (_k.label) {
1375
+ case 0:
1376
+ spaceUser = (0, lodash_1.find)(spaceUsers, function (u) { return u.user === userId; });
1377
+ if (!spaceUser)
1378
+ return [2, "continue"];
1379
+ link = info.type === '四部门抽查' ? midTierLink : microLink;
1380
+ html = "\n <p>\u4EB2\u7231\u7684\u5BA1\u6838\u8001\u5E08\uFF0C</p>\n <p>\u60A8\u5728\u3010".concat(yearMonth, "\u3011\u62BD\u67E5\u5E93\u4E2D\u4ECD\u6709 <b>").concat(info.count, "</b> \u4E2A\u7D20\u6750\u5C1A\u672A\u5B8C\u6210\u62BD\u67E5\uFF0C\u8BF7\u5728\u6708\u5E95\u524D\u5B8C\u6210\u3002</p>\n <p>\u8BF7\u70B9\u51FB\u4EE5\u4E0B\u94FE\u63A5\u8FDB\u5165\u62BD\u67E5\u9875\u9762\uFF1A</p>\n <p><a href=\"").concat(link, "\">\u70B9\u51FB\u8FDB\u5165\u62BD\u67E5</a></p>\n <p>\u5982\u6709\u7591\u95EE\uFF0C\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\u3002</p>\n ");
1381
+ if (!(spaceUser.email && spaceUser.email.endsWith('@pepsico.com'))) return [3, 4];
1382
+ _k.label = 1;
1383
+ case 1:
1384
+ _k.trys.push([1, 3, , 4]);
1385
+ return [4, sendEmail(process.env.B6_EMAIL_FROM, spaceUser.email, subject, '', html, '')];
1386
+ case 2:
1387
+ _k.sent();
1388
+ results.push({ userId: userId, email: spaceUser.email, status: 'sent' });
1389
+ return [3, 4];
1390
+ case 3:
1391
+ error_10 = _k.sent();
1392
+ console.log("[remindSpotCheckIncomplete] \u90AE\u4EF6\u53D1\u9001\u5931\u8D25: ".concat(spaceUser.email), error_10);
1393
+ results.push({ userId: userId, email: spaceUser.email, status: 'failed' });
1394
+ return [3, 4];
1395
+ case 4:
1396
+ _k.trys.push([4, 6, , 7]);
1397
+ return [4, ctx.broker.call('notifications.add', {
1398
+ message: {
1399
+ name: "\u3010\u50AC\u529E\u3011\u60A8\u6709 ".concat(info.count, " \u4E2A\u7D20\u6750\u672A\u5B8C\u6210\u62BD\u67E5\uFF0C\u8BF7\u5C3D\u5FEB\u5904\u7406"),
1400
+ body: '',
1401
+ related_to: { o: 'pepsico_material', ids: [] },
1402
+ related_name: "".concat(yearMonth, " \u62BD\u67E5\u50AC\u529E"),
1403
+ from: spaceUser.user,
1404
+ space: spaceUser.space
1405
+ },
1406
+ from: spaceUser.user,
1407
+ to: userId
1408
+ })];
1409
+ case 5:
1410
+ _k.sent();
1411
+ return [3, 7];
1412
+ case 6:
1413
+ error_11 = _k.sent();
1414
+ console.log("[remindSpotCheckIncomplete] \u7AD9\u5185\u901A\u77E5\u53D1\u9001\u5931\u8D25: ".concat(userId), error_11);
1415
+ return [3, 7];
1416
+ case 7: return [2];
1417
+ }
1418
+ });
1419
+ };
1420
+ _j.label = 5;
1421
+ case 5:
1422
+ _j.trys.push([5, 10, 11, 12]);
1423
+ pendingUsers_1 = tslib_1.__values(pendingUsers), pendingUsers_1_1 = pendingUsers_1.next();
1424
+ _j.label = 6;
1425
+ case 6:
1426
+ if (!!pendingUsers_1_1.done) return [3, 9];
1427
+ _b = tslib_1.__read(pendingUsers_1_1.value, 2), userId = _b[0], info = _b[1];
1428
+ return [5, _loop_2(userId, info)];
1429
+ case 7:
1430
+ _j.sent();
1431
+ _j.label = 8;
1432
+ case 8:
1433
+ pendingUsers_1_1 = pendingUsers_1.next();
1434
+ return [3, 6];
1435
+ case 9: return [3, 12];
1436
+ case 10:
1437
+ e_10_1 = _j.sent();
1438
+ e_10 = { error: e_10_1 };
1439
+ return [3, 12];
1440
+ case 11:
1441
+ try {
1442
+ if (pendingUsers_1_1 && !pendingUsers_1_1.done && (_h = pendingUsers_1.return)) _h.call(pendingUsers_1);
1443
+ }
1444
+ finally { if (e_10) throw e_10.error; }
1445
+ return [7];
1446
+ case 12:
1447
+ console.log("[remindSpotCheckIncomplete] \u50AC\u529E\u5B8C\u6210\u3002\u7ED3\u679C:", results);
1448
+ return [2, { success: true, yearMonth: yearMonth, totalUsers: pendingUsers.size, results: results }];
1012
1449
  }
1013
1450
  });
1014
1451
  });