From d8dc84a3d56df839895f1c417a4d9cbee763d262 Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期五, 03 三月 2023 14:50:59 +0800
Subject: [PATCH] gzw 测试环境代码更新
---
force-app/main/default/classes/RepairQuoteTrigger.cls | 90 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 88 insertions(+), 2 deletions(-)
diff --git a/force-app/main/default/classes/RepairQuoteTrigger.cls b/force-app/main/default/classes/RepairQuoteTrigger.cls
index ad2e0b5..1f02fff 100644
--- a/force-app/main/default/classes/RepairQuoteTrigger.cls
+++ b/force-app/main/default/classes/RepairQuoteTrigger.cls
@@ -10,6 +10,8 @@
if(Trigger.isUpdate && rq.ListPrice__c != oldMap.get(rq.id).ListPrice__c){
//rqIds.add(rq.id);
flag = true;
+ rqIds.add(rq.id);
+ RqMap.put(rq.id, rq);
}
}
if(flag == false){
@@ -17,8 +19,8 @@
}
for(Repair_Quotation__c rq : newList){
if(Trigger.isUpdate && rq.ListPrice__c != oldMap.get(rq.id).ListPrice__c){
- rqIds.add(rq.id);
- RqMap.put(rq.id, rq);
+ // rqIds.add(rq.id);
+ // RqMap.put(rq.id, rq);
}
}
}else if(Trigger.isInsert){
@@ -43,4 +45,88 @@
}
System.debug('===========> end');
}
+
+
+ public static void SendEmailForRentalApproval(List<Repair_Quotation__c> newList, Map<Id, Repair_Quotation__c> newMap, List<Repair_Quotation__c> oldList, Map<Id, Repair_Quotation__c> oldMap) {
+ Set<Id> repairIds = new Set<Id>();
+ List<Repair_Quotation__c> repairQuotationList = new List<Repair_Quotation__c>();
+
+ for(Repair_Quotation__c rq : newList) {
+ if(Trigger.isUpdate
+ && rq.Rental_Apply_Discount_Status__c != oldMap.get(rq.id).Rental_Apply_Discount_Status__c
+ && rq.Rental_Apply_Discount_Status__c == '鎵瑰噯'){
+ repairIds.add(rq.Repair__c);
+ repairQuotationList.add(rq);
+ }
+ }
+
+ if(repairIds.size() > 0){
+ //鏌ヨ淇悊涓搴旂殑閫夋嫨鐨勬湇鍔℃柟寮忓拰缁翠慨涓績
+ Map<Id, Repair__c> repairMap = new Map<Id, Repair__c>([
+ select id,On_site_repair__c,work_location_select__c
+ from Repair__c
+ where Id in :repairIds]);
+
+ List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
+ // 鑾峰彇Email Template
+ EmailTemplate et = [Select id from EmailTemplate where name = '澶囧搧鍑忎环鐢宠---鎵瑰噯閫氳繃' limit 1];
+ // Email
+ String userEmail = null;
+
+ for (Repair_Quotation__c rqTemp :repairQuotationList) {
+ String addToEmail = null;
+ userEmail = rqTemp.RentalApplyDiscountApplyPersonEmail_sys__c;
+ if (!repairMap.isEmpty() && repairMap.containsKey(rqTemp.Repair__c)) {
+ // 鏈嶅姟鏂瑰紡
+ String siteRepair = repairMap.get(rqTemp.Repair__c).On_site_repair__c;
+ // 缁翠慨涓績
+ String workLocation = repairMap.get(rqTemp.Repair__c).work_location_select__c;
+
+ if (siteRepair == '鐩撮�丱GZ淇悊') {
+ // 鍔炰簨澶勯�氱煡缁勭兢璁惧畾OGZ
+ addToEmail = System.Label.EmailForRentalApproval_OGZ;
+ } else if (siteRepair == '鐩撮�丼ORC淇悊') {
+ // 鍔炰簨澶勯�氱煡缁勭兢璁惧畾SORC
+ addToEmail = System.Label.EmailForRentalApproval_SORC;
+ } else if (siteRepair == 'RC淇悊') {
+ if (workLocation == '涓婃捣鍔炰簨澶�') {
+ // 涓婃捣鍔炰簨澶�
+ addToEmail = System.Label.EmailForRentalApproval_RC_SH;
+ } else if (workLocation == '鏉窞鍔炰簨澶�') {
+ // 鏉窞鍔炰簨澶� + 涓婃捣鍔炰簨澶�
+ addToEmail = System.Label.EmailForRentalApproval_RC_HZ + ';' + System.Label.EmailForRentalApproval_RC_SH;
+ } else if (workLocation == '骞夸笢鍔炰簨澶�') {
+ // 骞夸笢鍔炰簨澶�
+ addToEmail = System.Label.EmailForRentalApproval_RC_GZ;
+ } else if (workLocation == '鎴愰兘鍔炰簨澶�') {
+ // 鎴愰兘鍔炰簨澶� + 骞夸笢鍔炰簨澶�
+ addToEmail = System.Label.EmailForRentalApproval_RC_CD + ';' + System.Label.EmailForRentalApproval_RC_GZ;
+ } else if (workLocation == '鍖椾含鍔炰簨澶�') {
+ // 鍖椾含鍔炰簨澶�
+ addToEmail = System.Label.EmailForRentalApproval_RC_BJ;
+ } else if (workLocation == '娌堥槼鍔炰簨澶�') {
+ // 娌堥槼鍔炰簨澶�
+ addToEmail = System.Label.EmailForRentalApproval_RC_SY;
+ } else if (workLocation == '瑗垮畨鍔炰簨澶�') {
+ // 瑗垮畨鍔炰簨澶�
+ addToEmail = System.Label.EmailForRentalApproval_RC_XA;
+ }
+ }
+ }
+
+ if (String.isNotBlank(addToEmail)) {
+ userEmail = userEmail + ';' + addToEmail;
+ }
+
+ String[] toAddresses = userEmail.split(';');
+ Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
+ mail = Messaging.renderStoredEmailTemplate(et.Id, null , rqTemp.Id);
+ mail.setSaveAsActivity(false);
+ mail.setToAddresses(toAddresses);
+ emails.add(mail);
+ }
+
+ Messaging.sendEmail(emails);
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1