在這項作業中,您將建立事件規則和過濾器,來完成平均值的計算,並決定傳送忠誠主顧獎金的時機。
您可以按照表格的說明來建立過濾器,以計算購買的平均值、判斷購買的時段,以及檢查並確定客戶最近未收到忠誠主顧獎金。您也將建立一項規則稱為
Check for loyalty award status,且該規則會使用過濾器。
過濾器名稱 |
過濾器功能 |
the average purchase amount is greater than 50 |
計算客戶最近 5 次購買的平均值。 |
more than 4 orders placed in the last 2 weeks |
判斷客戶最近五次購買是否是在 2 週內。 |
no loyalty award was given in the last week |
確認客戶在過去一週內沒有收到忠誠主顧獎金。 |
- 按照表格來建立三個過濾器。
- 用滑鼠右鍵按一下資產資料夾,然後按一下。
- 輸入 the average purchase amount is greater than 50 作為過濾器名稱,然後按一下完成。 這時會關閉精靈,並在「過濾器編輯器」中開啟過濾器。
- 在「過濾器編輯器」視窗中,按一下內容欄位,將編輯游標放在欄位內。
- 按 Alt+/,顯示「內容輔助」方框。
- 在「內容輔助」方框中往下捲動,直到您看見 the average of <numbers> 詞組為止。
- 從清單中按兩下選取 the average of <numbers>,將這個詞組新增到過濾器內容欄位。
- 繼續編輯過濾器內容,並新增下列詞組:
- the orders
- amounts
- is more than
- <number>
- 按一下 <number> 變數,並輸入 50,以值 50 取代變數。 這個範例顯示已完成的過濾器內容:
the average of the orders amounts is more than 50
- 按一下。
- 重複步驟,來建立另外兩個過濾器。請使用「內容輔助」方框,找出並新增過濾器內容。
- 關閉「過濾器編輯器」。
- 建立使用過濾器的事件規則。
- 用滑鼠右鍵按一下資產資料夾,然後按一下。
- 在「新建事件規則」精靈中,輸入 Check for loyalty award status 作為事件規則的名稱。
- 按下一步。
- 在「選取事件」畫面中,按一下 order processing
complete,指出該事件規則會套用至選取的事件。
- 按下一步。
- 在「選取環境定義」畫面中,按一下系統環境定義,然後按下一步。
- 在「定義環境定義 ID」畫面中,按一下 the customer ID of the customer details。 您必須在事件規則中設定環境定義 ID,因為事件規則會參照累計陣列物件,且規則也會檢查過去發生的事件與動作。
- 按一下完成。 事件規則會在「規則編輯器」中開啟。
- 如果要新增事件規則內容,請按一下內容欄位內,將編輯游標放在欄位中,然後按 Alt+/,來開啟「內容輔助」方框。
- 從清單中選取 if <conditions>。 繼續編輯規則內容,並新增下列詞組:
- the average purchase amount is greater than 50.
- and <condition>.
- more than 4 orders placed in the last 2 weeks.
- and <condition>.
- no loyalty award was given in the last week.
- then <actions>.
- send loyalty award.
- 按一下分號符號 (;),這表示規則內容結束。 這個範例顯示已完成的事件規則:
- 儲存事件規則,並關閉「事件編輯器」。
在下一項作業中,您將部署指導教學應用程式。
下一步:作業 4:部署應用程式