@steedos-labs/content-compliance-bev 0.2.4 → 0.2.6

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.
@@ -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,7 +890,7 @@ 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, 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, departmentUserIds_1, departmentUserIds_1_1, userId, e_7_1, specialistUserIds_1, specialistUserIds_1_1, userId, e_8_1, error_8, error_9;
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, midTierSubject, microSubject, 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;
862
894
  var e_5, _j, e_9, _k, e_6, _l, e_7, _m, e_8, _o;
863
895
  return tslib_1.__generator(this, function (_p) {
864
896
  switch (_p.label) {
@@ -882,7 +914,7 @@ exports.generateSpotCheckPool = {
882
914
  yearMonth = pool.year_month;
883
915
  _p.label = 3;
884
916
  case 3:
885
- _p.trys.push([3, 56, , 57]);
917
+ _p.trys.push([3, 58, , 63]);
886
918
  return [4, getSpotCheckPool(yearMonth)];
887
919
  case 4:
888
920
  pools = _p.sent();
@@ -893,22 +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
- departmentUserIds_2 = new Set();
901
- _p.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
+ })];
902
934
  case 5:
903
- _p.trys.push([5, 11, 12, 13]);
904
- _a = tslib_1.__values(pools['Mid-tier'].samplingPool), _b = _a.next();
905
- _p.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
+ }];
906
944
  case 6:
907
- 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];
908
953
  material = _b.value;
909
954
  return [4, ctx.getObject('pepsico_material_approval').findOne(material.pepsico_material_approval)];
910
- case 7:
955
+ case 9:
911
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
+ }
912
960
  return [4, ctx.getObject('pepsico_material').directUpdate(material._id, {
913
961
  spot_check_pool_year_month: yearMonth,
914
962
  spot_checked: true,
@@ -918,7 +966,7 @@ exports.generateSpotCheckPool = {
918
966
  ns_spot_check_user: approval.ns_spot_check,
919
967
  ca_spot_check_user: approval.ca_spot_check
920
968
  })];
921
- case 8:
969
+ case 10:
922
970
  _p.sent();
923
971
  try {
924
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()) {
@@ -936,128 +984,133 @@ exports.generateSpotCheckPool = {
936
984
  }
937
985
  finally { if (e_9) throw e_9.error; }
938
986
  }
939
- _p.label = 9;
940
- case 9:
941
- _b = _a.next();
942
- return [3, 6];
943
- case 10: return [3, 13];
987
+ _p.label = 11;
944
988
  case 11:
989
+ _b = _a.next();
990
+ return [3, 8];
991
+ case 12: return [3, 15];
992
+ case 13:
945
993
  e_5_1 = _p.sent();
946
994
  e_5 = { error: e_5_1 };
947
- return [3, 13];
948
- case 12:
995
+ return [3, 15];
996
+ case 14:
949
997
  try {
950
998
  if (_b && !_b.done && (_j = _a.return)) _j.call(_a);
951
999
  }
952
1000
  finally { if (e_5) throw e_5.error; }
953
1001
  return [7];
954
- case 13:
1002
+ case 15:
955
1003
  specialistUserIds_2 = new Set();
956
- _p.label = 14;
957
- case 14:
958
- _p.trys.push([14, 20, 21, 22]);
1004
+ _p.label = 16;
1005
+ case 16:
1006
+ _p.trys.push([16, 22, 23, 24]);
959
1007
  _e = tslib_1.__values(pools['Micro'].samplingPool), _f = _e.next();
960
- _p.label = 15;
961
- case 15:
962
- if (!!_f.done) return [3, 19];
1008
+ _p.label = 17;
1009
+ case 17:
1010
+ if (!!_f.done) return [3, 21];
963
1011
  material = _f.value;
964
1012
  return [4, ctx.getObject('pepsico_material_approval').findOne(material.pepsico_material_approval)];
965
- case 16:
1013
+ case 18:
966
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
+ }
967
1018
  return [4, ctx.getObject('pepsico_material').directUpdate(material._id, {
968
1019
  spot_check_pool_year_month: yearMonth,
969
1020
  spot_checked: true,
970
1021
  spot_check_type: '审核专员抽查',
971
1022
  guding_spot_check_user: approval.special_spot_check || []
972
1023
  })];
973
- case 17:
1024
+ case 19:
974
1025
  _p.sent();
975
1026
  sUsers = approval.special_spot_check;
976
1027
  if (sUsers) {
977
1028
  (Array.isArray(sUsers) ? sUsers : [sUsers]).forEach(function (id) { return specialistUserIds_2.add(id); });
978
1029
  }
979
- _p.label = 18;
980
- case 18:
981
- _f = _e.next();
982
- return [3, 15];
983
- case 19: return [3, 22];
1030
+ _p.label = 20;
984
1031
  case 20:
1032
+ _f = _e.next();
1033
+ return [3, 17];
1034
+ case 21: return [3, 24];
1035
+ case 22:
985
1036
  e_6_1 = _p.sent();
986
1037
  e_6 = { error: e_6_1 };
987
- return [3, 22];
988
- case 21:
1038
+ return [3, 24];
1039
+ case 23:
989
1040
  try {
990
1041
  if (_f && !_f.done && (_l = _e.return)) _l.call(_e);
991
1042
  }
992
1043
  finally { if (e_6) throw e_6.error; }
993
1044
  return [7];
994
- case 22:
1045
+ case 24:
995
1046
  ROOT_URL = process.env.ROOT_URL;
996
- subject = '【系统通知】抽查素材通知';
997
- midTierLink = "".concat(ROOT_URL, "/app/pepsico_content_review/pepsico_midtier_spot_check");
1047
+ midTierSubject = '【系统通知】腰部素材抽查通知';
1048
+ microSubject = '【系统通知】尾部素材抽查通知';
1049
+ midTierLink = "".concat(ROOT_URL, "/app/pepsico_content_review/page/pepsico_midtier_spot_check");
998
1050
  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 ");
999
1051
  departmentToUsers = [];
1000
- if (!(departmentUserIds_2.size > 0)) return [3, 26];
1001
- _p.label = 23;
1002
- case 23:
1003
- _p.trys.push([23, 25, , 26]);
1052
+ if (!(departmentUserIds_2.size > 0)) return [3, 28];
1053
+ _p.label = 25;
1054
+ case 25:
1055
+ _p.trys.push([25, 27, , 28]);
1004
1056
  return [4, ctx.getObject('space_users').find({ filters: ['user', 'in', Array.from(departmentUserIds_2)] })];
1005
- case 24:
1057
+ case 26:
1006
1058
  toUsersAll = _p.sent();
1007
1059
  departmentToUsers = toUsersAll.filter(function (u) { return u.email && u.email.endsWith('@pepsico.com'); });
1008
- return [3, 26];
1009
- case 25:
1060
+ return [3, 28];
1061
+ case 27:
1010
1062
  error_6 = _p.sent();
1011
1063
  console.log(error_6);
1012
- return [3, 26];
1013
- case 26:
1014
- if (!(departmentToUsers.length > 0)) return [3, 28];
1015
- return [4, sendEmail(process.env.B6_EMAIL_FROM, (0, lodash_1.join)((0, lodash_1.map)(departmentToUsers, 'email'), ';'), subject, '', midTierHtml, '')];
1016
- case 27:
1017
- _g = _p.sent();
1018
- return [3, 29];
1064
+ return [3, 28];
1019
1065
  case 28:
1020
- _g = '无收件人';
1021
- _p.label = 29;
1066
+ if (!(departmentToUsers.length > 0)) return [3, 30];
1067
+ return [4, sendEmail(process.env.B6_EMAIL_FROM, (0, lodash_1.join)((0, lodash_1.map)(departmentToUsers, 'email'), ';'), midTierSubject, '', midTierHtml, '')];
1022
1068
  case 29:
1069
+ _g = _p.sent();
1070
+ return [3, 31];
1071
+ case 30:
1072
+ _g = '无收件人';
1073
+ _p.label = 31;
1074
+ case 31:
1023
1075
  midTierResult = _g;
1024
- microLink = "".concat(ROOT_URL, "/app/pepsico_content_review/pepsico_spot_check");
1076
+ microLink = "".concat(ROOT_URL, "/app/pepsico_content_review/page/pepsico_spot_check");
1025
1077
  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 ");
1026
1078
  specialistToUsers = [];
1027
- if (!(specialistUserIds_2.size > 0)) return [3, 33];
1028
- _p.label = 30;
1029
- case 30:
1030
- _p.trys.push([30, 32, , 33]);
1079
+ if (!(specialistUserIds_2.size > 0)) return [3, 35];
1080
+ _p.label = 32;
1081
+ case 32:
1082
+ _p.trys.push([32, 34, , 35]);
1031
1083
  return [4, ctx.getObject('space_users').find({ filters: ['user', 'in', Array.from(specialistUserIds_2)] })];
1032
- case 31:
1084
+ case 33:
1033
1085
  toUsersAll = _p.sent();
1034
1086
  specialistToUsers = toUsersAll.filter(function (u) { return u.email && u.email.endsWith('@pepsico.com'); });
1035
- return [3, 33];
1036
- case 32:
1087
+ return [3, 35];
1088
+ case 34:
1037
1089
  error_7 = _p.sent();
1038
1090
  console.log(error_7);
1039
- return [3, 33];
1040
- case 33:
1041
- if (!(specialistToUsers.length > 0)) return [3, 35];
1042
- return [4, sendEmail(process.env.B6_EMAIL_FROM, (0, lodash_1.join)((0, lodash_1.map)(specialistToUsers, 'email'), ';'), subject, '', microHtml, '')];
1043
- case 34:
1044
- _h = _p.sent();
1045
- return [3, 36];
1091
+ return [3, 35];
1046
1092
  case 35:
1047
- _h = '无收件人';
1048
- _p.label = 36;
1093
+ if (!(specialistToUsers.length > 0)) return [3, 37];
1094
+ return [4, sendEmail(process.env.B6_EMAIL_FROM, (0, lodash_1.join)((0, lodash_1.map)(specialistToUsers, 'email'), ';'), microSubject, '', microHtml, '')];
1049
1095
  case 36:
1050
- microResult = _h;
1051
- _p.label = 37;
1096
+ _h = _p.sent();
1097
+ return [3, 38];
1052
1098
  case 37:
1053
- _p.trys.push([37, 53, , 54]);
1099
+ _h = '无收件人';
1054
1100
  _p.label = 38;
1055
1101
  case 38:
1056
- _p.trys.push([38, 43, 44, 45]);
1057
- departmentUserIds_1 = tslib_1.__values(departmentUserIds_2), departmentUserIds_1_1 = departmentUserIds_1.next();
1102
+ microResult = _h;
1058
1103
  _p.label = 39;
1059
1104
  case 39:
1060
- if (!!departmentUserIds_1_1.done) return [3, 42];
1105
+ _p.trys.push([39, 55, , 56]);
1106
+ fromUserId = (user === null || user === void 0 ? void 0 : user.userId) || pool.owner || pool.created_by;
1107
+ _p.label = 40;
1108
+ case 40:
1109
+ _p.trys.push([40, 45, 46, 47]);
1110
+ departmentUserIds_1 = tslib_1.__values(departmentUserIds_2), departmentUserIds_1_1 = departmentUserIds_1.next();
1111
+ _p.label = 41;
1112
+ case 41:
1113
+ if (!!departmentUserIds_1_1.done) return [3, 44];
1061
1114
  userId = departmentUserIds_1_1.value;
1062
1115
  return [4, ctx.broker.call('notifications.add', {
1063
1116
  message: {
@@ -1065,35 +1118,35 @@ exports.generateSpotCheckPool = {
1065
1118
  body: '',
1066
1119
  related_to: { o: 'pepsico_spot_check_pool', ids: [pid] },
1067
1120
  related_name: pool.name || yearMonth,
1068
- from: user.userId,
1121
+ from: fromUserId,
1069
1122
  space: pool.space
1070
1123
  },
1071
- from: user.userId,
1124
+ from: fromUserId,
1072
1125
  to: userId
1073
1126
  })];
1074
- case 40:
1127
+ case 42:
1075
1128
  _p.sent();
1076
- _p.label = 41;
1077
- case 41:
1078
- departmentUserIds_1_1 = departmentUserIds_1.next();
1079
- return [3, 39];
1080
- case 42: return [3, 45];
1129
+ _p.label = 43;
1081
1130
  case 43:
1131
+ departmentUserIds_1_1 = departmentUserIds_1.next();
1132
+ return [3, 41];
1133
+ case 44: return [3, 47];
1134
+ case 45:
1082
1135
  e_7_1 = _p.sent();
1083
1136
  e_7 = { error: e_7_1 };
1084
- return [3, 45];
1085
- case 44:
1137
+ return [3, 47];
1138
+ case 46:
1086
1139
  try {
1087
1140
  if (departmentUserIds_1_1 && !departmentUserIds_1_1.done && (_m = departmentUserIds_1.return)) _m.call(departmentUserIds_1);
1088
1141
  }
1089
1142
  finally { if (e_7) throw e_7.error; }
1090
1143
  return [7];
1091
- case 45:
1092
- _p.trys.push([45, 50, 51, 52]);
1144
+ case 47:
1145
+ _p.trys.push([47, 52, 53, 54]);
1093
1146
  specialistUserIds_1 = tslib_1.__values(specialistUserIds_2), specialistUserIds_1_1 = specialistUserIds_1.next();
1094
- _p.label = 46;
1095
- case 46:
1096
- if (!!specialistUserIds_1_1.done) return [3, 49];
1147
+ _p.label = 48;
1148
+ case 48:
1149
+ if (!!specialistUserIds_1_1.done) return [3, 51];
1097
1150
  userId = specialistUserIds_1_1.value;
1098
1151
  return [4, ctx.broker.call('notifications.add', {
1099
1152
  message: {
@@ -1101,49 +1154,74 @@ exports.generateSpotCheckPool = {
1101
1154
  body: '',
1102
1155
  related_to: { o: 'pepsico_spot_check_pool', ids: [pid] },
1103
1156
  related_name: pool.name || yearMonth,
1104
- from: user.userId,
1157
+ from: fromUserId,
1105
1158
  space: pool.space
1106
1159
  },
1107
- from: user.userId,
1160
+ from: fromUserId,
1108
1161
  to: userId
1109
1162
  })];
1110
- case 47:
1163
+ case 49:
1111
1164
  _p.sent();
1112
- _p.label = 48;
1113
- case 48:
1114
- specialistUserIds_1_1 = specialistUserIds_1.next();
1115
- return [3, 46];
1116
- case 49: return [3, 52];
1165
+ _p.label = 50;
1117
1166
  case 50:
1167
+ specialistUserIds_1_1 = specialistUserIds_1.next();
1168
+ return [3, 48];
1169
+ case 51: return [3, 54];
1170
+ case 52:
1118
1171
  e_8_1 = _p.sent();
1119
1172
  e_8 = { error: e_8_1 };
1120
- return [3, 52];
1121
- case 51:
1173
+ return [3, 54];
1174
+ case 53:
1122
1175
  try {
1123
1176
  if (specialistUserIds_1_1 && !specialistUserIds_1_1.done && (_o = specialistUserIds_1.return)) _o.call(specialistUserIds_1);
1124
1177
  }
1125
1178
  finally { if (e_8) throw e_8.error; }
1126
1179
  return [7];
1127
- case 52: return [3, 54];
1128
- case 53:
1180
+ case 54: return [3, 56];
1181
+ case 55:
1129
1182
  error_8 = _p.sent();
1130
1183
  console.log('站内通知发送失败:', error_8);
1131
- return [3, 54];
1132
- case 54: return [4, ctx.getObject('pepsico_spot_check_pool').directUpdate(pid, {
1184
+ return [3, 56];
1185
+ case 56: return [4, ctx.getObject('pepsico_spot_check_pool').directUpdate(pid, {
1133
1186
  mail_send: true,
1134
1187
  mail_send_date: new Date(),
1135
1188
  mid_tier_pepsico_material: (0, lodash_1.map)(pools['Mid-tier'].samplingPool, '_id'),
1136
1189
  micro_pepsico_material: (0, lodash_1.map)(pools['Micro'].samplingPool, '_id'),
1137
- 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
+ logs: logs + '\r\n' + "=== \u53D1\u9001\u90AE\u4EF6\uFF08\u56DB\u90E8\u95E8-\u8170\u90E8\uFF09 === \r\n\n \u90AE\u4EF6\u4E3B\u9898: ".concat(midTierSubject, "\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(microSubject, "\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 ")
1138
1191
  })];
1139
- case 55:
1192
+ case 57:
1140
1193
  _p.sent();
1141
- return [3, 57];
1142
- case 56:
1194
+ return [2, {
1195
+ status: 200,
1196
+ msg: '抽查素材池邮件发送完成',
1197
+ data: {
1198
+ year_month: yearMonth,
1199
+ count: pools.count,
1200
+ mid_tier_count: pools['Mid-tier'].samplingPool.length,
1201
+ micro_count: pools['Micro'].samplingPool.length,
1202
+ mid_tier_mail_result: midTierResult,
1203
+ micro_mail_result: microResult
1204
+ }
1205
+ }];
1206
+ case 58:
1143
1207
  error_9 = _p.sent();
1208
+ message = (error_9 === null || error_9 === void 0 ? void 0 : error_9.message) || String(error_9);
1144
1209
  console.error('执行失败:', error_9);
1145
- return [3, 57];
1146
- case 57: return [2];
1210
+ _p.label = 59;
1211
+ case 59:
1212
+ _p.trys.push([59, 61, , 62]);
1213
+ return [4, ctx.getObject('pepsico_spot_check_pool').directUpdate(pid, {
1214
+ logs: "[".concat(yearMonth, "] \u62BD\u67E5\u7D20\u6750\u6C60\u90AE\u4EF6\u53D1\u9001\u5931\u8D25\uFF1A").concat(message)
1215
+ })];
1216
+ case 60:
1217
+ _p.sent();
1218
+ return [3, 62];
1219
+ case 61:
1220
+ updateError_1 = _p.sent();
1221
+ console.error('记录抽查素材池失败日志失败:', updateError_1);
1222
+ return [3, 62];
1223
+ case 62: throw error_9;
1224
+ case 63: return [2];
1147
1225
  }
1148
1226
  });
1149
1227
  });
@@ -1152,29 +1230,47 @@ exports.generateSpotCheckPool = {
1152
1230
  exports.remindSpotCheckIncomplete = {
1153
1231
  rest: {
1154
1232
  method: "GET",
1155
- path: "/remind/spot-check-incomplete"
1233
+ fullPath: "/api/pepsico-content/remind/spot-check-incomplete"
1156
1234
  },
1157
1235
  handler: function (ctx) {
1158
1236
  return tslib_1.__awaiter(this, void 0, void 0, function () {
1159
- var yearMonth, pendingUsers, midTierMaterials, midTierMaterials_1, midTierMaterials_1_1, material, deptFields, deptFields_1, deptFields_1_1, _a, done, user, 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 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;
1160
1238
  var e_11, _c, e_12, _d, e_13, _e, e_14, _f, e_15, _g, e_10, _h;
1161
1239
  return tslib_1.__generator(this, function (_j) {
1162
1240
  switch (_j.label) {
1163
1241
  case 0:
1242
+ user = ctx.meta.user;
1243
+ if (user && !user.is_space_admin) {
1244
+ throw new Error('无权限');
1245
+ }
1246
+ ctx.getObject = this.getObject;
1247
+ return [4, this.getLogger()];
1248
+ case 1:
1249
+ logger = _j.sent();
1250
+ ctx.logger = logger;
1164
1251
  yearMonth = moment().format('YYYY-MM');
1165
- console.log("[remindSpotCheckIncomplete] \u5F00\u59CB\u626B\u63CF ".concat(yearMonth, " \u672A\u5B8C\u6210\u62BD\u67E5\u4EFB\u52A1..."));
1252
+ console.log("[remindSpotCheckIncomplete] \u5F00\u59CB\u626B\u63CF\u622A\u6B62\u76EE\u524D\u6240\u6709\u672A\u5B8C\u6210\u62BD\u67E5\u4EFB\u52A1...");
1253
+ return [4, logger.info('[抽查催办] 开始扫描截止目前所有未完成抽查任务', {
1254
+ yearMonth: yearMonth
1255
+ })];
1256
+ case 2:
1257
+ _j.sent();
1166
1258
  pendingUsers = new Map();
1167
1259
  return [4, ctx.getObject('pepsico_material').find({
1168
1260
  filters: [
1169
- ['spot_check_pool_year_month', '=', yearMonth],
1170
1261
  ['spot_checked', '=', true],
1171
1262
  ['spot_checked_done', '!=', true],
1172
1263
  ['spot_check_type', '=', '四部门抽查']
1173
1264
  ]
1174
1265
  })];
1175
- case 1:
1266
+ case 3:
1176
1267
  midTierMaterials = _j.sent();
1177
1268
  console.log("[remindSpotCheckIncomplete] \u8170\u90E8\u672A\u5B8C\u6210\u7D20\u6750: ".concat(midTierMaterials.length));
1269
+ return [4, logger.info('[抽查催办] 腰部未完成素材统计', {
1270
+ count: midTierMaterials.length
1271
+ })];
1272
+ case 4:
1273
+ _j.sent();
1178
1274
  try {
1179
1275
  for (midTierMaterials_1 = tslib_1.__values(midTierMaterials), midTierMaterials_1_1 = midTierMaterials_1.next(); !midTierMaterials_1_1.done; midTierMaterials_1_1 = midTierMaterials_1.next()) {
1180
1276
  material = midTierMaterials_1_1.value;
@@ -1186,15 +1282,15 @@ exports.remindSpotCheckIncomplete = {
1186
1282
  ];
1187
1283
  try {
1188
1284
  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()) {
1189
- _a = deptFields_1_1.value, done = _a.done, user = _a.user;
1190
- if (!material[done] && material[user]) {
1191
- users = Array.isArray(material[user]) ? material[user] : [material[user]];
1285
+ _a = deptFields_1_1.value, done = _a.done, user_1 = _a.user;
1286
+ if (!material[done] && material[user_1]) {
1287
+ users = Array.isArray(material[user_1]) ? material[user_1] : [material[user_1]];
1192
1288
  try {
1193
1289
  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()) {
1194
1290
  uid = users_2_1.value;
1195
1291
  if (uid) {
1196
- existing = pendingUsers.get(uid) || { count: 0, type: '四部门抽查' };
1197
- existing.count++;
1292
+ existing = pendingUsers.get(uid) || { midTierCount: 0, microCount: 0 };
1293
+ existing.midTierCount++;
1198
1294
  pendingUsers.set(uid, existing);
1199
1295
  }
1200
1296
  }
@@ -1227,15 +1323,19 @@ exports.remindSpotCheckIncomplete = {
1227
1323
  }
1228
1324
  return [4, ctx.getObject('pepsico_material').find({
1229
1325
  filters: [
1230
- ['spot_check_pool_year_month', '=', yearMonth],
1231
1326
  ['spot_checked', '=', true],
1232
1327
  ['spot_checked_done', '!=', true],
1233
1328
  ['spot_check_type', '=', '审核专员抽查']
1234
1329
  ]
1235
1330
  })];
1236
- case 2:
1331
+ case 5:
1237
1332
  microMaterials = _j.sent();
1238
1333
  console.log("[remindSpotCheckIncomplete] \u5C3E\u90E8\u672A\u5B8C\u6210\u7D20\u6750: ".concat(microMaterials.length));
1334
+ return [4, logger.info('[抽查催办] 尾部未完成素材统计', {
1335
+ count: microMaterials.length
1336
+ })];
1337
+ case 6:
1338
+ _j.sent();
1239
1339
  try {
1240
1340
  for (microMaterials_1 = tslib_1.__values(microMaterials), microMaterials_1_1 = microMaterials_1.next(); !microMaterials_1_1.done; microMaterials_1_1 = microMaterials_1.next()) {
1241
1341
  material = microMaterials_1_1.value;
@@ -1245,8 +1345,8 @@ exports.remindSpotCheckIncomplete = {
1245
1345
  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()) {
1246
1346
  uid = users_3_1.value;
1247
1347
  if (uid) {
1248
- existing = pendingUsers.get(uid) || { count: 0, type: '审核专员抽查' };
1249
- existing.count++;
1348
+ existing = pendingUsers.get(uid) || { midTierCount: 0, microCount: 0 };
1349
+ existing.microCount++;
1250
1350
  pendingUsers.set(uid, existing);
1251
1351
  }
1252
1352
  }
@@ -1268,30 +1368,47 @@ exports.remindSpotCheckIncomplete = {
1268
1368
  }
1269
1369
  finally { if (e_14) throw e_14.error; }
1270
1370
  }
1271
- if (pendingUsers.size === 0) {
1272
- console.log("[remindSpotCheckIncomplete] \u5F53\u6708\u65E0\u672A\u5B8C\u6210\u62BD\u67E5\u4EFB\u52A1\uFF0C\u65E0\u9700\u50AC\u529E\u3002");
1273
- return [2, { success: true, message: '无未完成抽查任务' }];
1274
- }
1371
+ if (!(pendingUsers.size === 0)) return [3, 8];
1372
+ console.log("[remindSpotCheckIncomplete] \u65E0\u672A\u5B8C\u6210\u62BD\u67E5\u4EFB\u52A1\uFF0C\u65E0\u9700\u50AC\u529E\u3002");
1373
+ return [4, logger.info('[抽查催办] 无未完成抽查任务,无需催办', {
1374
+ midTierCount: midTierMaterials.length,
1375
+ microCount: microMaterials.length
1376
+ })];
1377
+ case 7:
1378
+ _j.sent();
1379
+ return [2, { success: true, message: '无未完成抽查任务' }];
1380
+ case 8:
1275
1381
  console.log("[remindSpotCheckIncomplete] \u9700\u50AC\u529E\u7528\u6237\u6570: ".concat(pendingUsers.size));
1382
+ return [4, logger.info('[抽查催办] 需催办用户统计', {
1383
+ userCount: pendingUsers.size,
1384
+ midTierCount: midTierMaterials.length,
1385
+ microCount: microMaterials.length
1386
+ })];
1387
+ case 9:
1388
+ _j.sent();
1276
1389
  ROOT_URL = process.env.ROOT_URL;
1277
- midTierLink = "".concat(ROOT_URL, "/app/pepsico_content_review/pepsico_midtier_spot_check");
1278
- microLink = "".concat(ROOT_URL, "/app/pepsico_content_review/pepsico_spot_check");
1279
- subject = '【催办通知】您有未完成的抽查任务';
1390
+ midTierLink = "".concat(ROOT_URL, "/app/pepsico_content_review/page/pepsico_midtier_spot_check");
1391
+ microLink = "".concat(ROOT_URL, "/app/pepsico_content_review/page/pepsico_spot_check");
1392
+ subject = '【系统通知】您有未完成的腰部/尾部素材抽查工作';
1280
1393
  results = [];
1281
1394
  userIds = Array.from(pendingUsers.keys());
1282
1395
  return [4, ctx.getObject('space_users').find({ filters: ['user', 'in', userIds] })];
1283
- case 3:
1396
+ case 10:
1284
1397
  spaceUsers = _j.sent();
1285
1398
  _loop_2 = function (userId, info) {
1286
- var spaceUser, link, html, error_10, error_11;
1399
+ var spaceUser, totalCount, linkHtml, html, error_10, error_11;
1287
1400
  return tslib_1.__generator(this, function (_k) {
1288
1401
  switch (_k.label) {
1289
1402
  case 0:
1290
1403
  spaceUser = (0, lodash_1.find)(spaceUsers, function (u) { return u.user === userId; });
1291
1404
  if (!spaceUser)
1292
1405
  return [2, "continue"];
1293
- link = info.type === '四部门抽查' ? midTierLink : microLink;
1294
- 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 ");
1406
+ totalCount = info.midTierCount + info.microCount;
1407
+ linkHtml = [
1408
+ info.midTierCount > 0 ? "<p><a href=\"".concat(midTierLink, "\">\u70B9\u51FB\u8FDB\u5165\u8170\u90E8\u7D20\u6750\u62BD\u67E5</a></p>") : '',
1409
+ info.microCount > 0 ? "<p><a href=\"".concat(microLink, "\">\u70B9\u51FB\u8FDB\u5165\u5C3E\u90E8\u7D20\u6750\u62BD\u67E5</a></p>") : ''
1410
+ ].join('');
1411
+ html = "\n <p>\u4EB2\u7231\u7684\u5BA1\u6838\u8001\u5E08\uFF0C</p>\n <p>\u60A8\u5728\u5BA1\u6838\u7CFB\u7EDF\uFF0C\u8170\u90E8/\u5C3E\u90E8\u7D20\u6750\u62BD\u67E5\u5E93\u4E2D\u8FD8\u6709 <b>".concat(totalCount, "</b> \u4E2A\u7D20\u6750\u672A\u5B8C\u6210\u62BD\u67E5\u5DE5\u4F5C\uFF0C\u8BF7\u767B\u5F55\u7CFB\u7EDF\u8FDB\u884C\u62BD\u67E5\u3002</p>\n <p>\u8BF7\u70B9\u51FB\u4EE5\u4E0B\u94FE\u63A5\u8FDB\u5165\u62BD\u67E5\u9875\u9762\uFF1A</p>\n ").concat(linkHtml, "\n <p>\u5982\u6709\u7591\u95EE\uFF0C\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\u3002</p>\n ");
1295
1412
  if (!(spaceUser.email && spaceUser.email.endsWith('@pepsico.com'))) return [3, 4];
1296
1413
  _k.label = 1;
1297
1414
  case 1:
@@ -1310,7 +1427,7 @@ exports.remindSpotCheckIncomplete = {
1310
1427
  _k.trys.push([4, 6, , 7]);
1311
1428
  return [4, ctx.broker.call('notifications.add', {
1312
1429
  message: {
1313
- name: "\u3010\u50AC\u529E\u3011\u60A8\u6709 ".concat(info.count, " \u4E2A\u7D20\u6750\u672A\u5B8C\u6210\u62BD\u67E5\uFF0C\u8BF7\u5C3D\u5FEB\u5904\u7406"),
1430
+ name: "\u3010\u50AC\u529E\u3011\u60A8\u6709 ".concat(totalCount, " \u4E2A\u7D20\u6750\u672A\u5B8C\u6210\u62BD\u67E5\uFF0C\u8BF7\u5C3D\u5FEB\u5904\u7406"),
1314
1431
  body: '',
1315
1432
  related_to: { o: 'pepsico_material', ids: [] },
1316
1433
  related_name: "".concat(yearMonth, " \u62BD\u67E5\u50AC\u529E"),
@@ -1331,34 +1448,40 @@ exports.remindSpotCheckIncomplete = {
1331
1448
  }
1332
1449
  });
1333
1450
  };
1334
- _j.label = 4;
1335
- case 4:
1336
- _j.trys.push([4, 9, 10, 11]);
1451
+ _j.label = 11;
1452
+ case 11:
1453
+ _j.trys.push([11, 16, 17, 18]);
1337
1454
  pendingUsers_1 = tslib_1.__values(pendingUsers), pendingUsers_1_1 = pendingUsers_1.next();
1338
- _j.label = 5;
1339
- case 5:
1340
- if (!!pendingUsers_1_1.done) return [3, 8];
1455
+ _j.label = 12;
1456
+ case 12:
1457
+ if (!!pendingUsers_1_1.done) return [3, 15];
1341
1458
  _b = tslib_1.__read(pendingUsers_1_1.value, 2), userId = _b[0], info = _b[1];
1342
1459
  return [5, _loop_2(userId, info)];
1343
- case 6:
1460
+ case 13:
1344
1461
  _j.sent();
1345
- _j.label = 7;
1346
- case 7:
1462
+ _j.label = 14;
1463
+ case 14:
1347
1464
  pendingUsers_1_1 = pendingUsers_1.next();
1348
- return [3, 5];
1349
- case 8: return [3, 11];
1350
- case 9:
1465
+ return [3, 12];
1466
+ case 15: return [3, 18];
1467
+ case 16:
1351
1468
  e_10_1 = _j.sent();
1352
1469
  e_10 = { error: e_10_1 };
1353
- return [3, 11];
1354
- case 10:
1470
+ return [3, 18];
1471
+ case 17:
1355
1472
  try {
1356
1473
  if (pendingUsers_1_1 && !pendingUsers_1_1.done && (_h = pendingUsers_1.return)) _h.call(pendingUsers_1);
1357
1474
  }
1358
1475
  finally { if (e_10) throw e_10.error; }
1359
1476
  return [7];
1360
- case 11:
1477
+ case 18:
1361
1478
  console.log("[remindSpotCheckIncomplete] \u50AC\u529E\u5B8C\u6210\u3002\u7ED3\u679C:", results);
1479
+ return [4, logger.info('[抽查催办] 催办完成', {
1480
+ userCount: pendingUsers.size,
1481
+ results: results
1482
+ })];
1483
+ case 19:
1484
+ _j.sent();
1362
1485
  return [2, { success: true, yearMonth: yearMonth, totalUsers: pendingUsers.size, results: results }];
1363
1486
  }
1364
1487
  });