From f50c0ec115e25dc7f980bafda8169ed5ddfe1a8f Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期五, 08 四月 2022 21:04:16 +0800
Subject: [PATCH] Session
---
force-app/main/default/classes/AccountWebService.cls | 293 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 264 insertions(+), 29 deletions(-)
diff --git a/force-app/main/default/classes/AccountWebService.cls b/force-app/main/default/classes/AccountWebService.cls
index 41cf79e..54b5770 100644
--- a/force-app/main/default/classes/AccountWebService.cls
+++ b/force-app/main/default/classes/AccountWebService.cls
@@ -1,30 +1,265 @@
-global without sharing class AccountWebService {
-
- // 鐒″姽銇瓵ccount銇墍鏈夎�呫倰Batch User銇仚銈�
- WebService static String toBatchOwner(String hpid) {
-
- List<Account> accList = [select Id from Account
- where (Id = :hpid or ParentId = :hpid or Parent.ParentId = :hpid)
- and Is_Active_Formula__c = '鏃犳晥'];
-
- if (accList.size() > 0) {
- try {
- // 鎵�鏈夎�呮洿鏂�
- for (Account acc : accList) {
- acc.OwnerId = '00510000000fSYI';
- }
- update accList;
-
- // 銉併兗銉犮儭銉炽儛銉煎墛闄�
- List<AccountTeamMember> atm = [select Id from AccountTeamMember where AccountId in :accList];
- if (atm.size() > 0) delete atm;
-
- } catch (Exception e) {
- return e.getMessage();
- }
- }
-
- return 'OK';
- }
-
+global class AccountWebService {
+ WebService static String AccountCancel(String accountId) {
+ Account account = new Account();
+ List<Account> accountList = [select Id, OwnerId, AccountStatus__c, CancelReason__c from Account where Id =:accountId];
+ if (accountList.size() == 0) {
+ return '鏃犳晥鐨勫鎴�';
+ } else {
+ account = accountList[0];
+ }
+ if (account.AccountStatus__c == 'Cancel') {
+ return '瀹㈡埛宸茬粡鍙栨秷';
+ }
+ if (account.CancelReason__c == null || account.CancelReason__c.length() == 0) {
+ return '蹇呴』杈撳叆鍙栨秷鐞嗙敱';
+ }
+ account.AccountStatus__c = 'Cancel';
+ account.OwnerId = System.Label.BatchUserId;
+ update account;
+
+ return '1';
+ }
+
+ WebService static String UpdateShare(String accountId, String ownerOld, String ownerNew) {
+ try {
+ Account acc = new Account(
+ Id = accountId,
+ OwnerId = ownerNew
+ );
+ update acc;
+
+ List<AccountShare> asList = [select Id, AccountId, UserOrGroupId, AccountAccessLevel, RowCause from AccountShare where AccountId = :accountId and UserOrGroupId = :ownerOld and RowCause = 'Team' and AccountAccessLevel = 'Read'];
+ for (AccountShare ash : asList) {
+ ash.AccountAccessLevel = 'Edit';
+ }
+ if (asList.size() > 0) {
+ update asList;
+ }
+ } catch (Exception ex) {
+ return ex.getMessage();
+ }
+
+ return '1';
+ }
+ // 鎶�鏈湇鍔¢儴鎷呭綋銆佹妧鏈湇鍔¢儴(閮ㄩ暱銆佸壇閮ㄩ暱)銆両E 鏍锋満绠$悊鑰� 绠�妗� 鍒涘缓瀹㈡埛璺宠繃蹇呭~瀛楁楠岃瘉锛屾敼涓烘彁浜ゅ鎵规椂楠岃瘉
+ // CHAN-BU98HT XHL 20201014
+ WebService static String RequiredField(String accountId) {
+ String result = '1';
+
+ List<String> errorMessageList = new List<String>();
+ // 鐜嬮箯浼熶慨鏀瑰墠 SQL 澶囦唤
+ //List<Account> accList = [select Id,Name,FacilityNameD__c,DivisionName_D__c,DealerSelectOwner__c,Province__c,CityD__c,Address1D__c,Sub_UseD__c,AccountStatusD__c,PostCodeD__c,DepartmentNameD__c,IndustryCD__c,MarketVerticalsD__c,UseD__c,EnglishNameD__c,TargetCustomer__c,CustomerSource__c,UserType__c,RecordTypeId from Account where Id = :accountId ];
+ List<Account> accList = [select Id,Name,FacilityNameD__c,DivisionName_D__c,DealerSelectOwner__c,Province__c,CityD__c,Address1D__c,Sub_UseD__c,AccountStatusD__c,PostCodeD__c,DepartmentNameD__c,IndustryCD__c,MarketVerticalsD__c,UseD__c,EnglishNameD__c,TargetCustomer__c,CustomerSource__c,UserType__c,RecordTypeId,DealerAccount__c,AssetRVI1D__c,serviceCreate__c from Account where Id = :accountId ];
+ if (accList.size() > 0) {
+
+ // 鍏卞悓閮ㄥ垎8涓瓧娈�
+ Account account = accList[0];
+ // 瀹㈡埛/浠g悊鍟嗗悕绉�.
+ if (String.isBlank(account.FacilityNameD__c)) {
+ String errorMessage = '瀹㈡埛/浠g悊鍟嗗悕绉�.';
+ errorMessageList.add(errorMessage);
+ }
+ // 閮ㄩ棬鍚嶇О.
+ if (String.isBlank(account.DivisionName_D__c)) {
+ String errorMessage = '閮ㄩ棬鍚嶇О.';
+ errorMessageList.add(errorMessage);
+ }
+ // 瀹℃壒浜�
+ if (String.isBlank(account.DealerSelectOwner__c)) {
+ String errorMessage = '瀹℃壒浜�';
+ errorMessageList.add(errorMessage);
+ }
+ // 鐪�
+ if (String.isBlank(account.Province__c)) {
+ String errorMessage = '鐪�';
+ errorMessageList.add(errorMessage);
+ }
+ // 鍩庡競.
+ if (String.isBlank(account.CityD__c)) {
+ String errorMessage = '鍩庡競.';
+ errorMessageList.add(errorMessage);
+ }
+ // 鍦板潃1.
+ if (String.isBlank(account.Address1D__c)) {
+ String errorMessage = '鍦板潃1.';
+ errorMessageList.add(errorMessage);
+ }
+ // 璐︽埛鐘舵��.
+ /*if (String.isBlank(account.AccountStatusD__c)) {
+ String errorMessage = '璐︽埛鐘舵��. 蹇呭~ 璇风‘璁�;';
+ errorMessageList.add(errorMessage);
+ }*/
+ // 閭紪.
+ /*if (String.isBlank(account.PostCodeD__c)) {
+ String errorMessage = '閭紪. 蹇呭~ 璇风‘璁�;';
+ errorMessageList.add(errorMessage);
+ }*/
+ // Sub Use.
+ if (String.isBlank(account.Sub_UseD__c)) {
+ String errorMessage = 'Sub Use.';
+ errorMessageList.add(errorMessage);
+ }
+ // ANI NDT RVI IE
+ /*if ('01228000000TdFL'.equals(account.RecordTypeId) || '01228000000TdFG'.equals(account.RecordTypeId) ||
+ '01228000000TdFB'.equals(account.RecordTypeId) || '01228000000TdF6'.equals(account.RecordTypeId)) {
+ // Sub Use.
+ if (String.isBlank(account.Sub_UseD__c)) {
+ String errorMessage = 'Sub Use. 蹇呭~ 璇风‘璁�;';
+ errorMessageList.add(errorMessage);
+ }
+ }*/
+ // RVI IE 鐜嬮箯浼熸柊鍔�
+ if(('01228000000TdFB'.equals(account.RecordTypeId) || '01228000000TdF6'.equals(account.RecordTypeId)) && account.serviceCreate__c == true){
+ //浠g悊鍟�
+ if(!String.isNotBlank(String.valueOf(account.DealerAccount__c))){
+ String errorMessage = '浠g悊鍟�';
+ errorMessageList.add(errorMessage);
+ }
+ }
+ // RVI 鍒ゆ柇RVI浜у搧淇℃伅
+ if('01228000000TdFB'.equals(account.RecordTypeId)){
+ //
+ if(!String.isNotBlank(account.AssetRVI1D__c)){
+ String errorMessage = 'RVI浜у搧淇℃伅';
+ errorMessageList.add(errorMessage);
+ }
+ }
+ // IE
+ if ('01228000000TdF6'.equals(account.RecordTypeId)) {
+ // 鑻辨枃鍚嶇О.
+ /*if (String.isBlank(account.EnglishNameD__c)) {
+ String errorMessage = '鑻辨枃鍚嶇О. 蹇呭~ 璇风‘璁�;';
+ errorMessageList.add(errorMessage);
+ }*/
+ // 瀹㈡埛绫诲瀷
+ /*if (String.isBlank(account.TargetCustomer__c)) {
+ String errorMessage = '瀹㈡埛绫诲瀷 蹇呭~ 璇风‘璁�;';
+ errorMessageList.add(errorMessage);
+ }*/
+ // 瀹㈡埛鏉ユ簮.
+ if (String.isBlank(account.CustomerSource__c)) {
+ String errorMessage = '瀹㈡埛鏉ユ簮.';
+ errorMessageList.add(errorMessage);
+ }
+ // 鐢ㄦ埛灞炴��
+ if (String.isBlank(account.UserType__c)) {
+ String errorMessage = '鐢ㄦ埛灞炴��';
+ errorMessageList.add(errorMessage);
+ }
+ }
+ // BS
+ /*if ('01228000000TdF1'.equals(account.RecordTypeId)) {
+ // 绉戝.
+ if (String.isBlank(account.DepartmentNameD__c)) {
+ String errorMessage = '绉戝. 蹇呭~ 璇风‘璁�;';
+ errorMessageList.add(errorMessage);
+ }
+ // 琛屼笟.
+ if (String.isBlank(account.IndustryCD__c)) {
+ String errorMessage = '琛屼笟. 蹇呭~ 璇风‘璁�;';
+ errorMessageList.add(errorMessage);
+ }
+ // 甯傚満鍒嗙被.
+ if (String.isBlank(account.MarketVerticalsD__c)) {
+ String errorMessage = '甯傚満鍒嗙被. 蹇呭~ 璇风‘璁�;';
+ errorMessageList.add(errorMessage);
+ }
+ // 鐢ㄩ��.
+ if (String.isBlank(account.UseD__c)) {
+ String errorMessage = '鐢ㄩ��. 蹇呭~ 璇风‘璁�;';
+ errorMessageList.add(errorMessage);
+ }
+ }
+*/
+ if (errorMessageList.size() > 0){
+ result = '';
+ for (String error :errorMessageList) {
+ result += error +'\n';
+ }
+ result += '蹇呭~锛岃纭锛�';
+ }
+
+ }
+ return result;
+ }
+ // 鎶�鏈湇鍔¢儴鎷呭綋銆佹妧鏈湇鍔¢儴(閮ㄩ暱銆佸壇閮ㄩ暱)銆両E 鏍锋満绠$悊鑰� 绠�妗� 鍒涘缓鑱旂郴浜鸿烦杩囧繀濉瓧娈甸獙璇侊紝鏀逛负鎻愪氦瀹℃壒鏃堕獙璇�
+ // CHAN-BU98HT XHL 20201014
+ WebService static String ContactRequiredField(String contactId) {
+ String result = '1';
+ List<String> errorMessageList = new List<String>();
+ List<Contact> contactList = [Select Id,Name,MobilePhone,MobilePhoneD__c,Postcode__c,PostcodeD__c,Address1__c,Address1D__c,CreatedById,ContactStatusD__c,RecordTypeId,CreatedBy.ProfileId,ProductSegmentBS__c From Contact where Id = : contactId ];
+ String userId = UserInfo.getUserId();
+ if (contactList.size() > 0) {
+ Contact contact = contactList[0];
+ String profileId = contact.CreatedBy.ProfileId;
+ //鎶�鏈湇鍔¢儴鎷呭綋
+ if ('00e28000001sZE6'.equals(profileId.subString(0,15)) ||
+ '00e28000000eN67'.equals(profileId.subString(0,15))) {
+ if (String.isBlank(contact.MobilePhoneD__c)) {
+ String errorMessage = '鎵嬫満.';
+ errorMessageList.add(errorMessage);
+ }
+ if (String.isBlank(contact.Name)) {
+ String errorMessage = '濮撳悕';
+ errorMessageList.add(errorMessage);
+ }
+
+ if (String.isBlank(contact.Address1D__c)) {
+ String errorMessage = '鍦板潃1.';
+ errorMessageList.add(errorMessage);
+ }
+ if(contact.ProductSegmentBS__c == true){
+ if (String.isBlank(contact.PostcodeD__c)) {
+ String errorMessage = '閭斂缂栫爜.';
+ errorMessageList.add(errorMessage);
+ }
+ if (String.isBlank(contact.ContactStatusD__c)) {
+ String errorMessage = '鐘舵��. ';
+ errorMessageList.add(errorMessage);
+ }
+ }
+ }
+
+ // SSBG IE 鏍锋満绠$悊鑰咃紝SSBG鎶�鏈湇鍔¢儴锛堥儴闀裤兓鍓儴闀匡級
+ if ('00e28000000YQMx'.equals(profileId.subString(0,15)) ||
+ '00e0K000001l0l9'.equals(profileId.subString(0,15)) ||
+ '00e28000000eN67'.equals(profileId.subString(0,15))) {
+
+ if (String.isBlank(contact.MobilePhone)) {
+ String errorMessage = '鎵嬫満';
+ errorMessageList.add(errorMessage);
+ }
+ if (String.isBlank(contact.Name)) {
+ String errorMessage = '濮撳悕';
+ errorMessageList.add(errorMessage);
+ }
+
+ if (String.isBlank(contact.Address1__c)) {
+ String errorMessage = '鍦板潃1';
+ errorMessageList.add(errorMessage);
+ }
+
+ if(contact.ProductSegmentBS__c == true){
+ if (String.isBlank(contact.PostcodeD__c)) {
+ String errorMessage = '閭斂缂栫爜.';
+ errorMessageList.add(errorMessage);
+ }
+ if (String.isBlank(contact.ContactStatusD__c)) {
+ String errorMessage = '鐘舵��. ';
+ errorMessageList.add(errorMessage);
+ }
+ }
+ }
+ }
+
+ if (errorMessageList.size() > 0){
+ result = '';
+ for (String error :errorMessageList) {
+ result += error +'\n';
+ }
+ result += '蹇呭~锛岃纭锛�';
+ }
+ return result;
+ }
+
}
\ No newline at end of file
--
Gitblit v1.9.1