游畅
2022-04-22 64b3629116e6f3f5eb3debf9b451d100f4010fa5
询问单相关修改
2个文件已添加
6个文件已修改
566 ■■■■ 已修改文件
force-app/main/default/classes/InquiryFormHandler.cls 164 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/InquiryFormHandlerTest.cls 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OpportunityAndContactDailyUpdateBatch.cls 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/OpportunityAndContactDailyUpdateTest.cls 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/StatusPageController.cls 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/StatusPageControllerTest.cls 118 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/ServiceFollowPage.page 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/pages/ServiceFollowPage.page-meta.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
force-app/main/default/classes/InquiryFormHandler.cls
@@ -16,22 +16,23 @@
    protected override void beforeInsert() {
        beforeExecute();
        //客户人员录入后,【电话】【邮箱】自动录入 thh 20220321 start
        getContactInformation();
        // getContactInformation();
        //客户人员录入后,【电话】【邮箱】自动录入 thh 20220321 end
    }
    protected override void beforeUpdate() {
        beforeExecute();
        //客户人员录入后,【电话】【邮箱】自动录入 thh 20220321 start
        getContactInformation();
        // getContactInformation();
        //客户人员录入后,【电话】【邮箱】自动录入 thh 20220321 end
    }
    protected override void afterInsert() {
        //shareToOSCM();
        //FSE主担当共享
        shareToFSEMain();
    }
     protected override void afterUpdate() {
        //shareToOSCM();
        shareToFSEMain();
    }
     //Before処理
    private void beforeExecute() {
@@ -54,7 +55,18 @@
                nnObj.HospitalName__c = null;     //医院名
                nnObj.Hospital__c = null;         //医院
            }
            //20220419 you SWAG-CBUB2W start
            //公式考文本  给FSE担当赋值
            System.debug(nnObj.FSE_Owner_id__c+'==123=='+nnObj.FSE_Owner__c);
            if(nnObj.FSE_Owner_id__c != nnObj.FSE_Owner__c){
                nnObj.FSE_Owner__c = nnObj.FSE_Owner_id__c;
            }
            if(Trigger.isInsert && (nnObj.Request1__c.indexOf('服务对应') !=-1 || nnObj.ServiceCorrespond__c ==true)){
                nnObj.Service_Status__c ='01.未跟进';
            }
            //20220419 you SWAG-CBUB2W end
        }
        if (depIDList.size()>0) {
            accList  = [Select Id,OwnerId,
                            Hospital__c,Hospital__r.Name,
@@ -101,34 +113,126 @@
            nObj.Product1_Manual__c = '';
        }
    }
    //20220419 you SWAG-CBUB2W start
    private void shareToFSEMain() {
         //存放用于新增的共享数据
         List<Inquiry_form__Share> insertList = new List<Inquiry_form__Share>();
         //存放(产品咨询单id,共享对象)
         Map<Id,Inquiry_form__Share> insertMap = new Map<Id,Inquiry_form__Share>();
         //存放最后需要新增的共享数据
         List<Inquiry_form__Share> lastInsertList = new List<Inquiry_form__Share>();
         //存放已有的相同的共享原因的数据
         List<Id> deleteTargetAOIdList = new List<Id>();
         //存放用于的id
         List<Id> userIdList = new List<Id>();
         // String rowCause = 'Manual';
         //新增一个共享原因
         String rowCause = Schema.Inquiry_form__Share.RowCause.FSE_Owner_c_User__c;
         System.debug('rowCause:'+rowCause);
         String ownerCause = 'Owner';
         //Apex共有の理由名OCSM_Owner_c_User
         for(Inquiry_form__c nObj : newList) {
             Inquiry_form__c oObj = null;
             System.debug('FSE主担当:'+nObj.FSE_Owner__c);
             if (oldMap != null && oldMap.containsKey(nObj.Id)) {
                 oObj = oldMap.get(nObj.Id);
             }
             if ( nObj.FSE_Owner__c != null && (oObj == null || oObj.FSE_Owner__c != nObj.FSE_Owner__c)) {
                 Inquiry_form__Share aos = new Inquiry_form__Share(
                         RowCause = rowCause,
                         ParentId = nObj.Id,
                         UserOrGroupId = nObj.FSE_Owner__c,
                         AccessLevel = 'Edit');
                 //存放要新增的共享数据
                 insertList.add(aos);
                 System.debug('key:'+nObj.Id);
                 //存放(产品咨询单id,共享对象);
                 insertMap.put(nObj.Id,aos);
                 //存放用户id 用作检索条件
                 userIdList.add(nObj.FSE_Owner__c);
             }
             if(oObj != null && oObj.FSE_Owner__c != nObj.FSE_Owner__c){
                deleteTargetAOIdList.add(nObj.Id);
             }
         }
         System.debug('insertList:'+insertList);
         System.debug('insertMap1:'+insertMap);
         System.debug('IDlIST:'+deleteTargetAOIdList);
         // 先 Delete 后 Insert
         if (deleteTargetAOIdList.size() > 0) {
             List<Inquiry_form__Share> deleteList = [SELECT Id
                 FROM Inquiry_form__Share
                 WHERE RowCause = :rowCause
                   AND ParentId IN :deleteTargetAOIdList
             ];
             delete deleteList;
         }
         //判断需要共享的人  是不是创建人 如果是则说明有一条这个人的owner数据 则不新增
         if (insertMap!= null) {
             List<Inquiry_form__Share> ownerList = [SELECT Id,ParentId,UserOrGroupId
                 FROM Inquiry_form__Share
                 WHERE RowCause = :ownerCause
                   AND ParentId IN :insertMap.keySet()
                   AND UserOrGroupId IN :userIdList
             ];
             System.debug('ownerList:'+ownerList);
             if(ownerList.size() > 0){
                 for( Inquiry_form__Share  inq:ownerList){
                     String id = String.valueOf(inq.ParentId);
                     System.debug('id:'+id);
                     if(insertMap.containsKey(id)){
                         insertMap.remove(inq.ParentId);
                     }
                 }
             }
         }
         System.debug('insertMap2:'+insertMap);
         if(insertMap != null){
                 for(Inquiry_form__Share inquiry : insertMap.values()){
                     lastInsertList.add(inquiry);
                 }
         }
         System.debug('共享内容:' +lastInsertList);
         if(lastInsertList.size() > 0){
             insert lastInsertList;
         }
     }
     //20220419 you SWAG-CBUB2W end
    //客户人员录入后,【电话】【邮箱】自动录入 thh 20220321 start
    private void getContactInformation(){
        List<String> ContactIdList = new List<String>();
        List<Contact> ContactList = new List<Contact>();
        Map<String, Contact> ContactMap = new Map<String, Contact>();
        for(Inquiry_form__c nnObj : newList) {
            if(String.isNotBlank(nnObj.Contact_Name__c)){
                ContactIdList.add(nnObj.Contact_Name__c);
            }
        }
        if(ContactIdList.size() > 0){
            ContactList = [select id, Phone, Email from Contact where Id IN :ContactIdList];
            for(Contact contact : ContactList){
                ContactMap.put(contact.Id, contact);
            }
        }
        for(Inquiry_form__c nnObj : newList) {
            if(String.isNotBlank(nnObj.Contact_Name__c)){
                if(String.isNotBlank(ContactMap.get(nnObj.Contact_Name__c).Phone)){
                    nnObj.Phone__c = ContactMap.get(nnObj.Contact_Name__c).Phone;
                }
                if(String.isNotBlank(ContactMap.get(nnObj.Contact_Name__c).Email)){
                    nnObj.Email__c = ContactMap.get(nnObj.Contact_Name__c).Email;
                }
            }
        }
    }
    // private void getContactInformation(){
    //     List<String> ContactIdList = new List<String>();
    //     List<Contact> ContactList = new List<Contact>();
    //     Map<String, Contact> ContactMap = new Map<String, Contact>();
    //     for(Inquiry_form__c nnObj : newList) {
    //         if(String.isNotBlank(nnObj.Contact_Name__c)){
    //             ContactIdList.add(nnObj.Contact_Name__c);
    //         }
    //     }
    //     if(ContactIdList.size() > 0){
    //         ContactList = [select id, Phone, Email from Contact where Id IN :ContactIdList];
    //         for(Contact contact : ContactList){
    //             ContactMap.put(contact.Id, contact);
    //         }
    //     }
    //     for(Inquiry_form__c nnObj : newList) {
    //         if(String.isNotBlank(nnObj.Contact_Name__c)){
    //             if(String.isNotBlank(ContactMap.get(nnObj.Contact_Name__c).Phone)){
    //                 nnObj.Phone__c = ContactMap.get(nnObj.Contact_Name__c).Phone;
    //             }
    //             if(String.isNotBlank(ContactMap.get(nnObj.Contact_Name__c).Email)){
    //                 nnObj.Email__c = ContactMap.get(nnObj.Contact_Name__c).Email;
    //             }
    //         }
    //     }
    // }
    //客户人员录入后,【电话】【邮箱】自动录入 thh 20220321 end
     // 战略科室的主担当 を取得、Inquiry_form__Shareに設定(Read)
force-app/main/default/classes/InquiryFormHandlerTest.cls
@@ -1,12 +1,68 @@
@isTest
private class InquiryFormHandlerTest {
   @TestSetup
    static void setup(){
        TestDataUtility.CreatePIPolicyConfiguration('Agency_Contact__c');
    }
  @isTest
    static void Test1(){
        Test.setMock(HttpCalloutMock.class, new HttpMock());
        List<Agency_Contact__c> lra = new List<Agency_Contact__c>();
        lra.add(new Agency_Contact__c(
            Id = 'a2R1m0000007BPD'
        ));
        Test.startTest();
        //system.debug(PIHelper.getPIIntegrationInfo('Agency_Contact__c').newEncryptUrl);
        AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c');
        AWSServiceTool2.EncryptPushFuture(null,null);
        Test.stopTest();
    }
    class HttpMock implements HttpCalloutMock{
        public HTTPResponse respond(HTTPRequest request) {
        // 创建一个假的回应
        System.debug('------------------------------------------------------');
        HttpResponse response = new HttpResponse();
        string body = '';
        system.debug(request.getEndpoint());
        if(request.getEndpoint().contains('token')){
            system.debug('url=token');
            response.setHeader('Content-Type', 'application/json');
      body='{ "message": "", "object": "freqfewqfewewfewfew", "status": "", "success": true, "timestamp": 0, "txId": "" }';
        } else if(request.getEndpoint().contains('insert')){
            system.debug('url=Insert');
            response.setHeader('Content-Type', 'application/json');
      body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }';
        } else if(request.getEndpoint().contains('update')){
            system.debug('url=update');
            response.setHeader('Content-Type', 'application/json');
      body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }';
        } else{
        }
        response.setBody(body);
        response.setStatus('OK');
        response.setStatusCode(200);
        return response;
        // }
    }
    }
    @isTest static void test_method_one() {
      Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner;
        Inquiry_form__c inquiryform = new Inquiry_form__c();
        inquiryform.Name = '2019102101';
        inquiryform.Request1__c = '需要报价';
        inquiryform.Product1__c = '超声';
        inquiryform.FSE_Owner__c  = hpOwner.id;
        insert inquiryform;
        
    }
@@ -126,11 +182,11 @@
        dpt1.Hospital__c         = hp.Id;
        insert dpt1;
        Contact contact2 = new Contact();
        contact2.AccountId = dpt1.Id;
        contact2.FirstName = '責任者';
        contact2.LastName = 'test1经销商';
        insert contact2;
        //Contact contact2 = new Contact();
        //contact2.AccountId = dpt1.Id;
        //contact2.FirstName = '責任者';
        //contact2.LastName = 'test1经销商';
        //insert contact2;
        Inquiry_form__c inquiryform = new Inquiry_form__c();
        inquiryform.Name = '2019102101';
@@ -143,8 +199,18 @@
        inquiryform.Phone__c = '13844756322';
        inquiryform.Product1__c = '超声';
        inquiryform.Request1__c = '需要报价';
        inquiryform.FSE_Owner__c  = hpOwner.id;
        insert inquiryform;
         Test.setMock(HttpCalloutMock.class, new HttpMock());
            List<Agency_Contact__c> lra = new List<Agency_Contact__c>();
            lra.add(new Agency_Contact__c(
                Id = 'a2R1m0000007BPD',
                Aws_Data_Id__c = '123456'
            ));
            AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c');
        Inquiry_form__c inquiryform0 = new Inquiry_form__c(Id = inquiryform.id);
        inquiryform0.Hospital_Name__c = null;
        //System.runAs (inquiryform){
force-app/main/default/classes/OpportunityAndContactDailyUpdateBatch.cls
@@ -100,7 +100,9 @@
         
         AccountDailyUpdateBatch.updateFromHosToContact(deptUpdateList, iflog);
         updateFromHosToContact(deptUpdateList, iflog);
         //20220415 you SWAG-CBUB2W start
         updateFromHosToInquiryForm(deptUpdateList, iflog);
         //20220415 you SWAG-CBUB2W end
    }
     //同步所属的询价(业务机会)的所有人
    public static void updateFromHosToContact(List<Account> deptUpdateList, BatchIF_Log__c iflog) {
@@ -128,6 +130,33 @@
        }
    }
     //20220415 you SWAG-CBUB2W start
     //同步所属的产品咨询单的所有人
    public static void updateFromHosToInquiryForm(List<Account> deptUpdateList, BatchIF_Log__c iflog) {
         List<Inquiry_form__c> updateInquiryFormList =
            [select id, Ownerid, Hospital_Name__r.ownerId from Inquiry_form__c
        where Hospital_Name__c in:deptUpdateList
        and isOwnerDiffWithAccount__c = true ];
        for (Inquiry_form__c ifo : updateInquiryFormList) {
            if (ifo.Ownerid != ifo.Hospital_Name__r.ownerId) {
                ifo.Ownerid = ifo.Hospital_Name__r.ownerId;
            }
        }
        Integer indexCon = 0;
        Database.SaveResult[] lsrUpdateInq = Database.update(updateInquiryFormList, false);
        for (Database.SaveResult lsrChild : lsrUpdateInq) {
            if (!lsrChild.isSuccess()) {
                iflog.Is_Error__c = 3;
                Database.Error emsg = lsrChild.getErrors()[0];
                iflog.ErrorLog__c += 'ownerId: ' + updateInquiryFormList.get(indexCon).ownerId + ' \n'
                                     + 'InquiryFormID: ' + updateInquiryFormList.get(indexCon).Id + '\n ConLog:' + emsg.getMessage() + '\n';
            }
            indexCon ++ ;
        }
    }
    //20220415 you SWAG-CBUB2W end
    global void finish(Database.BatchableContext BC) {
        system.debug('=====iflog:' + iflog.id);
        iflog.Log__c += 'OpportunityAndContactDailyUpdateBatch finish()\n';
force-app/main/default/classes/OpportunityAndContactDailyUpdateTest.cls
@@ -1,8 +1,8 @@
@isTest
private class OpportunityAndContactDailyUpdateTest {
   @testsetup
   private static void setup (){
    TestDataUtility.CreatePIPolicyConfiguration('Agency_Contact__c');
            string profid = '00e10000000Y3o5';
        string rectHpID = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('HP').getRecordTypeId();
        List<String> classDeptStr = new List<String>();
@@ -169,11 +169,11 @@
        depart.Hospital__c         = Hospital.Id;
        depart.OwnerId             = UserGS.Id;
        insert depart;
        Contact core = new Contact(email='jplumber@salesforce.com',
        firstname='Joe',
        lastname='Plumber',
        accountid=depart.id);
        insert core;
        //Contact core = new Contact(email='jplumber@salesforce.com',
        //firstname='Joe',
        //lastname='Plumber',
        //accountid=depart.id);
        //insert core;
        Opportunity target = new Opportunity( Name = 'aiueo', StageName = 'contact', CloseDate = Date.today(),
                                            accountid=depart.id);
        target.Trade__c = '内貿';
@@ -181,11 +181,87 @@
        target.Wholesale_Price__c = 9000;
        target.Sales_Root__c = 'AAA';
        insert target;
        Inquiry_form__c inf =new Inquiry_form__c();
        inf.Hospital_Name__c = depart.id;
        inf.OwnerId  = UserGI.Id;
        inf.Name = 'test';
        inf.Request1__c = '服务对应';
        inf.Product1__c = '超声';
        insert inf;
   }
   @isTest
    static void Test1(){
        Test.setMock(HttpCalloutMock.class, new HttpMock());
        List<Agency_Contact__c> lra = new List<Agency_Contact__c>();
        lra.add(new Agency_Contact__c(
            Id = 'a2R1m0000007BPD'
        ));
        Test.startTest();
        //system.debug(PIHelper.getPIIntegrationInfo('Agency_Contact__c').newEncryptUrl);
        AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c');
        AWSServiceTool2.EncryptPushFuture(null,null);
        Test.stopTest();
    }
  //@isTest
  //  static void Test2(){
  //      Test.setMock(HttpCalloutMock.class, new HttpMock());
  //      List<Agency_Contact__c> lra = new List<Agency_Contact__c>();
  //      lra.add(new Agency_Contact__c(
  //          Id = 'a2R1m0000007BPD',
  //          Aws_Data_Id__c = '123456'
  //      ));
  //      Test.startTest();
  //      //system.debug(PIHelper.getPIIntegrationInfo('Agency_Contact__c').newEncryptUrl);
  //      AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c');
  //      Test.stopTest();
  //  }
    class HttpMock implements HttpCalloutMock{
        public HTTPResponse respond(HTTPRequest request) {
        // 创建一个假的回应
        System.debug('------------------------------------------------------');
        HttpResponse response = new HttpResponse();
        string body = '';
        system.debug(request.getEndpoint());
        if(request.getEndpoint().contains('token')){
            system.debug('url=token');
            response.setHeader('Content-Type', 'application/json');
      body='{ "message": "", "object": "freqfewqfewewfewfew", "status": "", "success": true, "timestamp": 0, "txId": "" }';
        } else if(request.getEndpoint().contains('insert')){
            system.debug('url=Insert');
            response.setHeader('Content-Type', 'application/json');
      body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }';
        } else if(request.getEndpoint().contains('update')){
            system.debug('url=update');
            response.setHeader('Content-Type', 'application/json');
      body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }';
        } else{
        }
        response.setBody(body);
        response.setStatus('OK');
        response.setStatusCode(200);
        return response;
        // }
    }
    }
    static testMethod void testMethod1() {
        Test.setMock(HttpCalloutMock.class, new HttpMock());
            List<Agency_Contact__c> lra = new List<Agency_Contact__c>();
            lra.add(new Agency_Contact__c(
                Id = 'a2R1m0000007BPD',
                Aws_Data_Id__c = '123456'
            ));
            AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c');
        list<account> acclist = [select id from account where name ='Test Hospital'];
        Id execBTId = Database.executeBatch(new OpportunityAndContactDailyUpdateBatch(), 5);
        execBTId = Database.executeBatch(new OpportunityAndContactDailyUpdateBatch('1.华北'), 5);
force-app/main/default/classes/StatusPageController.cls
@@ -6,7 +6,7 @@
    public void init(){
        String infId = ApexPages.currentPage().getParameters().get('id');
        List<Inquiry_form__c> infList = [SELECT id,Reasons_options__c,Opp_Name_Search__c,Follow_Content__c,Follow_Content_Other__c,Status__c FROM Inquiry_form__c WHERE id =  :infId];
        List<Inquiry_form__c> infList = [SELECT id,Reasons_options__c,Opp_Name_Search__c,Follow_Content__c,Follow_Content_Other__c,Status__c,Service_Follow_Content__c,Service_Follow_Content_Other__c,Service_Status__c FROM Inquiry_form__c WHERE id =  :infId];
        if (infList.size() == 0) {
            
        }else{
@@ -41,6 +41,15 @@
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '跟进内容(其他)不能为空'));
            }
            // Date nowDT = Date.now();
            //20220418 you SWAG-CBUB2W start
            if(String.isNotBlank(Inquiryform.Follow_Content__c) && Inquiryform.Follow_Content__c.indexOf('服务对应')!=-1){
               Inquiryform.ServiceCorrespond__c = true;
               Inquiryform.Service_Status__c = '01.未跟进';
            }else{
                Inquiryform.ServiceCorrespond__c = false;
                Inquiryform.Service_Status__c = '';
            }
            //20220418 you SWAG-CBUB2W end
            Inquiryform.Follow_Date__c = Date.toDay();
            Inquiryform.Status__c = '03.已跟进';
            update Inquiryform;
@@ -50,4 +59,27 @@
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ex.getMessage()));
        }
    }
    //20220418 you SWAG-CBUB2W start
    public void servicesavefo(){
        try {
            if (String.isBlank(Inquiryform.Service_Follow_Content__c) && String.isBlank(Inquiryform.Service_Follow_Content_Other__c)) {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '服务跟进内容不能为空'));
            }
            if (String.isBlank(Inquiryform.Service_Follow_Content__c)) {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '服务跟进内容不能为空'));
            }
            if ('其他'.equals(Inquiryform.Service_Follow_Content__c) && String.isBlank(Inquiryform.Service_Follow_Content_Other__c)) {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '服务跟进内容(其他)不能为空'));
            }
            // Date nowDT = Date.now();
            Inquiryform.Service_Follow_Date__c = Date.toDay();
            Inquiryform.Service_Status__c = '03.已跟进';
            update Inquiryform;
        }
        catch (Exception ex) {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ex.getMessage()));
        }
    }
    //20220418 you SWAG-CBUB2W end
}
force-app/main/default/classes/StatusPageControllerTest.cls
@@ -3,7 +3,7 @@
    static testMethod void testMethod1() {
        //医院
        List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
        List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
        if (rectHp.size() == 0) {
            return;
        }
@@ -14,16 +14,16 @@
        }
        
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner;
        User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner2;
        User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner;
        User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner2;
        Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
        Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
        hp.FSE_GI_Main_Leader__c = hpOwner.Id;
        hp.FSE_SP_Main_Leader__c = hpOwner2.Id;
        insert hp;
@@ -64,15 +64,16 @@
        Test.startTest();
        insert inquiryform;
        PageReference page = new PageReference('/apex/StatusPage?id='+inquiryform.Id);
        System.Test.setCurrentPage(page);
        StatusPageController controller = new StatusPageController();
        controller.init();
        controller.save();
        controller.savefo();
        System.Test.setCurrentPage(page);
        StatusPageController controller = new StatusPageController();
        controller.init();
        controller.save();
        controller.savefo();
        controller.servicesavefo();
    }
    static testMethod void testMethod2() {
        //医院
        List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
        List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
        if (rectHp.size() == 0) {
            return;
        }
@@ -83,16 +84,16 @@
        }
        
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner;
        User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner2;
        User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner;
        User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner2;
        Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
        Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
        hp.FSE_GI_Main_Leader__c = hpOwner.Id;
        hp.FSE_SP_Main_Leader__c = hpOwner2.Id;
        insert hp;
@@ -134,15 +135,16 @@
        Test.startTest();
        insert inquiryform;
        PageReference page = new PageReference('/apex/StatusPage?id='+inquiryform.Id);
        System.Test.setCurrentPage(page);
        StatusPageController controller = new StatusPageController();
        controller.init();
        controller.save();
        controller.savefo();
        System.Test.setCurrentPage(page);
        StatusPageController controller = new StatusPageController();
        controller.init();
        controller.save();
        controller.savefo();
        controller.servicesavefo();
    }
    static testMethod void testMethod2_1() {
        //医院
        List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
        List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
        if (rectHp.size() == 0) {
            return;
        }
@@ -153,16 +155,16 @@
        }
        
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner;
        User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner2;
        User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner;
        User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner2;
        Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
        Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
        hp.FSE_GI_Main_Leader__c = hpOwner.Id;
        hp.FSE_SP_Main_Leader__c = hpOwner2.Id;
        insert hp;
@@ -204,14 +206,14 @@
        Test.startTest();
        insert inquiryform;
        PageReference page = new PageReference('/apex/StatusPage?id='+inquiryform.Id);
        System.Test.setCurrentPage(page);
        StatusPageController controller = new StatusPageController();
        controller.init();
        controller.save();
        System.Test.setCurrentPage(page);
        StatusPageController controller = new StatusPageController();
        controller.init();
        controller.save();
    }
    static testMethod void testMethod3() {
        //医院
        List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
        List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
        if (rectHp.size() == 0) {
            return;
        }
@@ -222,16 +224,16 @@
        }
        
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner;
        User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner2;
        User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner;
        User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner2;
        Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
        Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
        hp.FSE_GI_Main_Leader__c = hpOwner.Id;
        hp.FSE_SP_Main_Leader__c = hpOwner2.Id;
        insert hp;
@@ -274,14 +276,15 @@
        Test.startTest();
        insert inquiryform;
        PageReference page = new PageReference('/apex/FollowPage?id='+inquiryform.Id);
        System.Test.setCurrentPage(page);
        StatusPageController controller = new StatusPageController();
        controller.init();
        controller.savefo();
        System.Test.setCurrentPage(page);
        StatusPageController controller = new StatusPageController();
        controller.init();
        controller.savefo();
        controller.servicesavefo();
    }
    static testMethod void testMethod4() {
        //医院
        List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
        List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
        if (rectHp.size() == 0) {
            return;
        }
@@ -292,16 +295,16 @@
        }
        
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
        User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner;
        User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner2;
        User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner;
        User hpOwner2 = new User(Test_staff__c = true, LastName = 'hp2', FirstName = 'owner', Alias = 'hp2', Work_Location__c = '重庆', CommunityNickname = 'hpOwner2', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner2@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        insert hpOwner2;
        Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
        Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = hpOwner.Id);
        hp.FSE_GI_Main_Leader__c = hpOwner.Id;
        hp.FSE_SP_Main_Leader__c = hpOwner2.Id;
        insert hp;
@@ -344,9 +347,10 @@
        Test.startTest();
        insert inquiryform;
        PageReference page = new PageReference('/apex/FollowPage?id='+inquiryform.Id);
        System.Test.setCurrentPage(page);
        StatusPageController controller = new StatusPageController();
        controller.init();
        controller.savefo();
        System.Test.setCurrentPage(page);
        StatusPageController controller = new StatusPageController();
        controller.init();
        controller.savefo();
        controller.servicesavefo();
    }
}
force-app/main/default/pages/ServiceFollowPage.page
New file
@@ -0,0 +1,48 @@
<apex:page controller="StatusPageController" showHeader="false" id="allPage" sidebar="false" action="{!init}" docType="html-5.0">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="/soap/ajax/29.0/connection.js"/>
<apex:includeScript value="/soap/ajax/29.0/apex.js"/>
    <head>
        <title>跟进</title>
    </head>
    <script type="text/javascript">
        function save(){
            var content = j$(escapeVfId('allPage:allForm:pageBlock:pageBlockSection:content')).value();
            var contentOther = j$(escapeVfId('allPage:allForm:pageBlock:pageBlockSection:contentOther')).value();
            if ((content == '' || content == null) && (contentOther.trim() == null || contentOther.trim() == '')) {
                alert('服务跟进内容不能为空!');
                return;
            }else if (content == '其他' && (contentOther.trim() == '' || contentOther.trim() == null)) {
                alert('服务跟进内容(其他)不能为空!');
                return;
            }else if (content == '' || content == null) {
                alert('服务跟进内容不能为空!');
                return;
            }else{
                blockme();
                allSave();
            }
        }
        function check(){
            window.opener.location.href = "/{!Inquiryform.id}";
            window.close();
        }
    </script>
    <apex:form id="allForm">
        <apex:actionfunction action="{!servicesavefo}" name="allSave" onComplete="check();unblockUI();"></apex:actionfunction>
        <apex:pageBlock id="pageBlock">
            <apex:pageBlockSection id="pageBlockSection">
                    <apex:inputField id="content" value="{!Inquiryform.Service_Follow_Content__c}" />
                    <br />
                    <apex:inputField id="contentOther" value="{!Inquiryform.Service_Follow_Content_Other__c}" style="width: 150px"/>
                    <br />
            </apex:pageBlockSection>
            <apex:pageblockbuttons location="bottom">
                <apex:commandButton onclick="save();return false;" value="保存"></apex:commandButton>
            </apex:pageblockbuttons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
force-app/main/default/pages/ServiceFollowPage.page-meta.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>46.0</apiVersion>
    <label>ServiceFollowPage</label>
</ApexPage>