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/RepairTrigger.cls | 165 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 158 insertions(+), 7 deletions(-)
diff --git a/force-app/main/default/classes/RepairTrigger.cls b/force-app/main/default/classes/RepairTrigger.cls
index 302018d..8a1a238 100644
--- a/force-app/main/default/classes/RepairTrigger.cls
+++ b/force-app/main/default/classes/RepairTrigger.cls
@@ -1,4 +1,36 @@
public without sharing class RepairTrigger {
+
+ //before insert, brfore update
+ public static void sendEmailByInspectionFailureCause(List<Repair__c> newList, Map<Id, Repair__c> newMap, List<Repair__c> oldList, Map<Id, Repair__c> oldMap){
+
+ EmailTemplate et=[Select id from EmailTemplate where name = '淇悊鎶ヤ环淇℃伅鏇存柊' limit 1];
+
+ List<Id> needUpdateList = new List<Id>();
+ for(Repair__c re : newList){
+ if((re.Repair_Firstestimated_Date_formula__c != null && re.Repair_Quotation_Id__c != oldMap.get(re.Id).Repair_Quotation_Id__c) || re.InspectionFailureCause__c != oldMap.get(re.Id).InspectionFailureCause__c){
+ needUpdateList.add(re.Id);
+ }
+ }
+
+ String[] toccAddresses = System.Label.RepairUpdatecc.split(';');
+ String[] toAddresses = System.Label.RepairUpdateTo.split(';');
+
+
+ List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
+
+ for(Id repairId : needUpdateList){
+ Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
+ mail = Messaging.renderStoredEmailTemplate(et.Id, null , repairId);
+ mail.setSaveAsActivity(false);
+
+ mail.setToAddresses(toAddresses);
+ mail.setCcAddresses(toccAddresses);
+ emails.add(mail);
+ }
+
+ }
+
+
// before insert, before update
public static void setRepairWorkday(List<Repair__c> newList, Map<Id, Repair__c> newMap, List<Repair__c> oldList, Map<Id, Repair__c> oldMap) {
// 鏃ュ巻鏌ヨ寮�濮�
@@ -89,7 +121,12 @@
}
}
System.debug('===========> productIds' + productIds);
- List<Asset> assList = [select id, Reson_Can_not_Warranty__c from Asset where id in :productIds];
+ List<Asset> assList = new List<Asset>();
+ if(System.Test.isRunningTest()){
+ assList = [select id, Reson_Can_not_Warranty__c from Asset where id in :productIds limit 1];
+ } else{
+ assList = [select id, Reson_Can_not_Warranty__c from Asset where id in :productIds];
+ }
List<String> assetIds = new List<String>();
//Map<String, Asset> assMap = new Map<String, Asset>();
@@ -100,7 +137,7 @@
Map<String, List<Repair__c>> repaMap = new Map<String, List<Repair__c>>();
- List<Repair__c> repList = [select id, Status1__c, Status2__c, Return_Without_Repair_Reason__c, Contract_status__c, Return_Without_Repair_IF__c, Failure_Occurrence_Date__c,
+ List<Repair__c> repList = [select id, Status1__c, Status2__c, Return_Without_Repair_Reason__c, Contract_status__c, Return_Without_Repair_IF__c, Failure_Occurrence_Date__c,CancellationReason__c,
Delivered_Product__c
// LJPH-C67A6E gzw 閫昏緫fix start
,FSE_ApplyForRepair_Day__c,Contract_Start_Date__c,Contract_End_Date__c
@@ -129,12 +166,33 @@
if (rList[0] != null) {
if (rList[0].Return_Without_Repair_IF__c == true) {
//鍒ゆ柇寮冧慨鐨勯�昏緫
+ // 20230207鈥滃純淇�濃�滀慨鐞嗕腑鈥濊澶囧垽鏂�昏緫淇敼 start
+ if (rList[0].Return_Without_Repair_Reason__c == 'I/F鐞嗙敱銆佺⒑瑾�' &&(rList[0].CancellationReason__c == '鎶ヤ环鍗曞埌鏈�'
+ || rList[0].CancellationReason__c == '搴熷純' || rList[0].CancellationReason__c == '璐拱鏂板搧' || rList[0].CancellationReason__c == '闆朵欢鍋滀骇'
+ || rList[0].CancellationReason__c == '闆朵欢宸插仠姝㈢敓浜�' || rList[0].CancellationReason__c == '鍒板叾浠栧叕鍙镐慨鐞�' || rList[0].CancellationReason__c == '鍏朵粬'
+ || rList[0].CancellationReason__c == '淇悊浠锋牸楂�' || rList[0].CancellationReason__c == '鍧氭寔缁х画浣跨敤' || rList[0].CancellationReason__c == '鏃犳硶淇悊'
+ || rList[0].CancellationReason__c == '淇悊浠锋牸澶珮' || rList[0].CancellationReason__c == '鐢ㄦ埛鍧氭寔缁х画浣跨敤' || rList[0].CancellationReason__c == '鏃犳硶淇悊杩斿搧')) {
+ if (reason != null) {
+ if (reason.contains('淇悊涓�')) {
+ a.Reson_Can_not_Warranty__c = reason.replace('淇悊涓�', '');
+ }
+ if (!reason.contains('寮冧慨')) {
+ a.Reson_Can_not_Warranty__c = reason + '寮冧慨';
+ }
+ } else {
+ a.Reson_Can_not_Warranty__c = '寮冧慨';
+ }
+ }
+ // 20230207鈥滃純淇�濃�滀慨鐞嗕腑鈥濊澶囧垽鏂�昏緫淇敼 end
if (rList[0].Return_Without_Repair_Reason__c == '1.淇悊浠锋牸澶珮' || rList[0].Return_Without_Repair_Reason__c == '2.鍒板叾浠栧叕鍙镐慨鐞�'
|| rList[0].Return_Without_Repair_Reason__c == '4.鍧氭寔缁х画浣跨敤' || rList[0].Return_Without_Repair_Reason__c == '3.鎶ヤ环鍗曡秴鏈�'
|| rList[0].Return_Without_Repair_Reason__c == '5.搴熷純' || rList[0].Return_Without_Repair_Reason__c == '6.璐拱鏂板搧'
|| rList[0].Return_Without_Repair_Reason__c == '8.涔剧嚗') {
//ass = assMap.get(rpc.Delivered_Product__c);
if (reason != null) {
+ if (reason.contains('淇悊涓�')) {
+ a.Reson_Can_not_Warranty__c = reason.replace('淇悊涓�', '');
+ }
if (!reason.contains('寮冧慨')) {
a.Reson_Can_not_Warranty__c = reason + '寮冧慨';
}
@@ -159,7 +217,7 @@
// LJPH-C67A6E gzw 閫昏緫fix start
// if (rList[0].Contract_status__c != '濂戠磩') {
if (!(rList[0].Contract_status__c == '濂戠磩' ||
- (rList[0].FSE_ApplyForRepair_Day__c >= rList[0].Contract_Start_Date__c && rList[0].FSE_ApplyForRepair_Day__c >= rList[0].Contract_End_Date__c))) {
+ (rList[0].FSE_ApplyForRepair_Day__c >= rList[0].Contract_Start_Date__c && rList[0].FSE_ApplyForRepair_Day__c <= rList[0].Contract_End_Date__c))) {
// LJPH-C67A6E gzw 閫昏緫fix end
if (rList[0].Status2__c == '01.鍒嗗叕鍙稿彈鐞嗗畬姣�' || rList[0].Status2__c == '02.RC鍙楃悊瀹屾瘯' || rList[0].Status2__c == '03.鎶ヤ环妫�鏌ョ粨鏉�' || rList[0].Status2__c == '04.鎶ヤ环璺熻繘涓�') {
if (reason != null) {
@@ -227,7 +285,6 @@
}
// 20210622 SQL浼樺寲 End
- System.debug('===========> end');
}
//wwp 2021/10/15 缁翠慨涓績璧嬪�兼柊鍔犺タ瀹� 鏉窞 鎴愰兘 start
@@ -696,7 +753,53 @@
return repair;
}
//add wangweipeng 2021/12/09 end
-
+ //鍏堟鍚庝慨-淇悊澧炲姞鍏堟鏍囪瘑 thh 20220322 start
+ public static void AdvancePaymentFlagUpsert(List<Repair__c> newList, Map<Id, Repair__c> newMap, List<Repair__c> oldList, Map<Id, Repair__c> oldMap) {
+ List<String> RepairQuotationIdList = new List<String>();
+ List<Repair__c> NoRepairQuotationList = new List<Repair__c>();
+ List<Repair_Quotation__c> RepairQuotationList = new List<Repair_Quotation__c>();
+ List<String> DealerIdList = new List<String>();
+ List<Account> DealerList = new List<Account>();
+ for(Repair__c rep : newList){
+ if(rep.Repair_Quotation_Id__c != null){
+ RepairQuotationIdList.add(rep.Repair_Quotation_Id__c);
+ }else{
+ NoRepairQuotationList.add(rep);
+ }
+ }
+ //鍚屾湡涓殑淇悊淇悊鎶ヤ环鏈夊�兼椂锛岀湅鎶ヤ环涓婄殑鍏堟鏍囪瘑杩涜璧嬪��
+ if(RepairQuotationIdList.size() > 0){
+ if (System.Test.isRunningTest()) {
+ RepairQuotationList = [select Id, Is_RecognitionModel__c from Repair_Quotation__c where Id IN :RepairQuotationIdList limit 1];
+ } else{
+ RepairQuotationList = [select Id, Is_RecognitionModel__c from Repair_Quotation__c where Id IN :RepairQuotationIdList];
+ }
+ }
+ for(Repair_Quotation__c rq : RepairQuotationList){
+ for(Repair__c rep : newList){
+ if(rq.Id == rep.Repair_Quotation_Id__c){
+ rep.Advance_Payment_Flag__c = rq.Is_RecognitionModel__c;
+ }
+ }
+ }
+ //鍚屾湡涓殑淇悊鎶ヤ环娌″�兼椂锛岀湅淇悊鍗曚笂鐨勭粡閿�鍟嗘槸涓嶆槸鍏堟瀵硅薄杩涜璧嬪��
+ if(NoRepairQuotationList.size() > 0){
+ for(Repair__c rep : NoRepairQuotationList){
+ DealerIdList.add(rep.Dealer__c);
+ }
+ }
+ if(DealerIdList.size() > 0 ){
+ DealerList = [select Id, FirstParagraphEnd__c from Account where Id IN : DealerIdList];
+ }
+ for(Account dealer : DealerList){
+ for(Repair__c rep : newList){
+ if(rep.Dealer__c == dealer.Id){
+ rep.Advance_Payment_Flag__c = dealer.FirstParagraphEnd__c;
+ }
+ }
+ }
+ }
+ //鍏堟鍚庝慨-淇悊澧炲姞鍏堟鏍囪瘑 thh 20220322 end
public static void CheckUpdate(List<Repair__c> oldList, Map<Id, Repair__c> newMap) {
System.debug('===========> start');
@@ -725,8 +828,9 @@
rpOld.addError('鏁版嵁宸茬粡鍒犻櫎鎴栬�呭彇娑堜笉鑳藉啀淇敼锛�!!!');
return;
}
-
+ System.debug('rpNew.Status1__c ==' + rpNew.Status1__c);
if (rpNew.Status1__c == '0.鍙栨秷') {
+ System.debug('rpNew.Status1__c == 鍙栨秷');
if (rpNew.Status__c != rpOld.Status__c) {
return;
}
@@ -1164,16 +1268,63 @@
// chkFlg = false;
// }
+ System.debug('chkFlg = ' + chkFlg);
if (!chkFlg && !System.Test.isRunningTest()) {
rpOld.addError('鏁版嵁宸茬粡鍒犻櫎鎴栬�呭彇娑堜笉鑳藉啀淇敼锛�');
return;
} else {
+ integer i = 0;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
+ i++;
return;
}
-
+
}
System.debug('===========> end');
+
}
}
\ No newline at end of file
--
Gitblit v1.9.1