liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
@isTest
private class SyncLostProductBatchTest {
 
    @IsTest
    static void TestMethod01() {
 
        List<RecordType> rectLost = [select Id, Name from RecordType where IsActive = true and SobjectType = 'Lost_cancel_report__c' and DeveloperName IN ('PCL_Lost_report', 'PCL_Cancel_report') order by DeveloperName desc];
        if (rectLost.size() == 0) {
            throw new ControllerUtil.myException('not found Lost_cancel_report recodetype');
        }
 
        Product2 pro = new Product2();
        pro.Name = 'test20240228';
        pro.ProductClass__c = '镜子';
        pro.ProductCategory__c = 'CHF纤维胆道镜';
        pro.RecordTypeId = '012C80000000NIPIA2';
        pro.Category5__c='竞争对手';
        pro.IsActive=true;
        insert pro;
 
        Product2 pro1 = new Product2(Name='name01', Brand_Name__c='蛇牌',Category5__c='竞争对手',IsActive=true,Family='SP',Fixture_Model_No__c='n01',Serial_Lot_No__c='S/N tracing',Fixture_Model_No_T__c = 'n01',ProductCode_Ext__c='pc01',Manual_Entry__c=false);
        pro1.RecordTypeId = '012C80000000NIPIA2';
        insert pro1;
 
         // 询价
         Opportunity opp1 = new Opportunity(
            Name='opp1', StageName='oppName', CloseDate=Date.today()
            // ,Hospital__c = company1.Id,Department_Class__c = dc1s[0].Id,AccountId = depart1.Id
            );
         insert opp1;
 
         //招标项目
        Tender_information__c ten = new Tender_information__c();
        ten.Name = 'QLMTEST08111057-02';
        insert ten;
 
        //招标-询价关系
        Tender_Opportunity_Link__c tol = new Tender_Opportunity_Link__c();
        tol.Opportunity__c = opp1.Id;
        tol.CurrencyIsoCode = 'CNY';
        tol.Tender_information__c = ten.Id;
        StaticParameter.EscapeTOLinkTrigger = true;
        insert tol;
        StaticParameter.EscapeTOLinkTrigger = false;
        
        //失单报告
        Lost_cancel_report__c lcr1 = new Lost_cancel_report__c(
            Opportunity__c = opp1.Id,RecordTypeId = rectLost[0].Id,
            Report_Status__c = '批准');
        insert lcr1;
 
        //失单品牌1
        PCLLostBrand__c pcllb1=new PCLLostBrand__c();
        pcllb1.LostPrice__c=1332;
        pcllb1.Lost_Reason_Sub__c='价格';   //原因次
        pcllb1.Lost_reason_main__c='价格';     //原因主
        pcllb1.Lost_By_Company__c='蛇牌';       //品牌(主)
        // pcllb1.Agency__c=depart3.Id;            //经销商
        pcllb1.Lost_cancel_report__c=lcr1.Id;
        insert pcllb1;
 
        pro.ProductClass__c = '主机';
        pro.ProductCategory__c = 'CV主机';
        update pro;
 
        //失单型号
        PCLLostProduct__c pcllp1=new PCLLostProduct__c();
        pcllp1.Quantity__c=2;
        pcllp1.LostBrandName__c='蛇牌';
        pcllp1.ProductClass__c='主机';
        pcllp1.ProductCategory__c='CV主机';
        pcllp1.LostProduct__c = pro1.Id;     //产品Id
        pcllp1.PCLLostBrand__c=pcllb1.Id;     //询价失单品牌
        insert pcllp1;
 
        List<Product2> proList = new List<Product2>();
        proList.add(pro1);
 
        Test.startTest();
        Database.executeBatch (new SyncLostProductBatch(proList),200);
        Test.stopTest();
 
        // List<String> str = new List<String>();
        // str.add(TenInfo.Id);
 
        // Test.StartTest();
        // Database.executeBatch( new SyncLostProductBatch(str),100);
        // Test.stopTest();
    }
 
}