y2kbug

Untitled

Sep 23rd, 2020
598
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let picowayNoticed = false;
  2.       let ultravliftNoticed = false;
  3.       let eyebagNoticed = false;
  4.       await Promise.all(allItems.map(async item => {
  5.         if (item.contractGuaranteeRemarks && !contractGuaranteeRemarks) {
  6.           contractGuaranteeRemarks = item.contractGuaranteeRemarks;
  7.         }
  8.  
  9.         if (item.treatmentRemarks && !contractGuaranteeRemarks) {
  10.           contractGuaranteeRemarks = item.treatmentRemarks;
  11.         }
  12.  
  13.         if (
  14.           !picowayNoticed &&
  15.           (item.picowayDays > 0 || item.silkpeelDays > 0 || item.ecoolsDays > 0)
  16.         ) {
  17.           let remarks: Array<string> = ['Picoway 皮秒激光去斑療程須知:\n為能達至最佳效果,請定期進行療程,並配合防曬(早上搽)及保濕(晚上搽)\n\n療程日期建議:'];
  18.  
  19.           const result: Array<any> = await wemQueryRunner.query(`SELECT * FROM ${WEM_DATABASE_PERFECTSHAPE_SQL_NAME}.dbo.EquipmentDaysRemarks(GETDATE(), @0, @1, @2) ORDER BY TMDate`, [
  20.             item.picowayDays,
  21.             item.silkpeelDays,
  22.             item.ecoolsDays,
  23.           ]);
  24.  
  25.           for (let i = 0; i < result.length; i++) {
  26.             remarks.push([
  27.               (i + 1).toString(),
  28.               result[i]['TMDate']
  29.             ].join('. '));
  30.           }
  31.  
  32.           console.log('___DEBUG___', 'ITEM_REMARKS', remarks);
  33.  
  34.           suggestedDateRemarks.push(remarks.join('\n'));
  35.           picowayNoticed = true;
  36.         }
  37.  
  38.         if (
  39.           !ultravliftNoticed &&
  40.           (item.ultravliftDays > 0 || item.ultravliftDeepDays > 0 || item.ultravliftMediumDays > 0)
  41.         ) {
  42.           let remarks: Array<string> = ['隔空埋線療程須知:\n為達到隔空埋線的最佳效果,建議客人每月到店進行1次隔空埋線療程: \n\n療程日期建議:'];
  43.  
  44.           let result: Array<any> | undefined;
  45.           if (item.ultravliftDeepDays > 0 || item.ultravliftMediumDays > 0) {
  46.             result = await wemQueryRunner.query(`SELECCT * FROM ${WEM_DATABASE_PERFECTSHAPE_SQL_NAME}.dbo.UltraVLiftDeepMediumDaysRemarks(GETDATE(), @0, @1) ORDER BY TMDate`, [
  47.               item.ultravliftDeepDays,
  48.               item.ultravliftMediumDays,
  49.             ]);
  50.           } else if (item.ultravliftDays > 0) {
  51.             result = await wemQueryRunner.query(`Select * from ${WEM_DATABASE_PERFECTSHAPE_SQL_NAME}.dbo.UltraVLiftDaysRemarks(GETDATE(), " & UltraVLift_days & ") order by TMDate`, [
  52.               item.ultravliftDays,
  53.             ]);
  54.           }
  55.  
  56.           if (result) {
  57.             if (item.ultravliftDeepDays > 0 || item.ultravliftMediumDays > 0) {
  58.               for (let i = 0; i < result.length; i++) {
  59.                 remarks.push((i + 1).toString() + '. ' + result[i]['TMDate'] + ' [' + result[i]['EQName'] + ']',);
  60.               }
  61.             } else if (item.ultravliftDays > 0) {
  62.               for (let i = 0; i < result.length; i++) {
  63.                 remarks.push([
  64.                   (i + 1).toString(),
  65.                   result[i]['TMDate']
  66.                 ].join('. '));
  67.               }
  68.             }
  69.  
  70.             suggestedDateRemarks.push(remarks.join('\n'));
  71.             ultravliftNoticed = true;
  72.           }
  73.         }
  74.  
  75.         if (
  76.           !eyebagNoticed && item.eyebagDays > 0
  77.         ) {
  78.           let remarks: Array<string> = ['眼袋槍療程須知:\n為達到眼袋槍的最佳效果,建議客人每星期到店進行1次眼袋槍療程: \n\n療程日期建議:'];
  79.  
  80.           const result: Array<any> = await wemQueryRunner.query(`SELECT * FROM ${WEM_DATABASE_PERFECTSHAPE_SQL_NAME}.dbo.EyebagDaysRemarks(GETDATE(), @0) order by TMDate`, [
  81.             item.eyebagDays,
  82.           ]);
  83.  
  84.           for (let i = 0; i < result.length; i++) {
  85.             remarks.push([
  86.               (i + 1).toString(),
  87.               result[i]['TMDate']
  88.             ].join('. '));
  89.           }
  90.  
  91.           suggestedDateRemarks.push(remarks.join('\n'));
  92.           eyebagNoticed = true;
  93.         }
  94.       }));
RAW Paste Data