| | |
| | | // query += ' where Id in :IdList'; |
| | | // } |
| | | // 2022-01-18 修改 从失单报告取值 |
| | | String query = 'SELECT Id FROM Lost_cancel_report__c WHERE Report_Status__c = \'批准\' AND LostType__c in (\'失单\', \'部分失单\') '; |
| | | String query = 'SELECT Id, Opportunity__c FROM Lost_cancel_report__c WHERE Report_Status__c = \'批准\' AND LostType__c in (\'失单\', \'部分失单\') '; |
| | | //20230215 lt DB202302247719 add , Opportunity__c |
| | | if (start_date != null) { |
| | | query += ' AND Submit_Day__c >= :start_date'; |
| | | } |
| | |
| | | |
| | | // 2022-01-18 修改 从失单报告取值 |
| | | global void execute(Database.BatchableContext BC, List<Lost_cancel_report__c> scope) { |
| | | |
| | | // List<String> reportIdList=new List<String>();//20230215 lt DB202302247719 注释 |
| | | Set<String> reportIdList = new Set<String>();//20230215 lt DB202302247719 |
| | | |
| | | List<String> reportIdList=new List<String>(); |
| | | for (Lost_cancel_report__c report : scope) { |
| | | reportIdList.add(report.Id); |
| | | // reportIdList.add(report.Id); //20230215 lt DB202302247719 注释 |
| | | reportIdList.add(report.Opportunity__c); //20230215 lt DB202302247719 |
| | | } |
| | | |
| | | List<PCLLostProduct__c> pclLpList=[select |
| | |
| | | PCLLostBrand__r.AgencyMannual__c, // 中标经销商(手动) |
| | | PCLLostBrand__r.Lost_cancel_report__r.LostType__c, // 失单类型 |
| | | PCLLostBrand__r.Lost_cancel_report__r.LostTotalAmount__c, // 失单总金额 |
| | | PCLLostBrand__r.Lost_cancel_report__r.TotalAmountLost__c, // 失单总金额(不含税) //20230215 lt DB202302247719 |
| | | PCLLostBrand__r.Lost_cancel_report__r.of_lost_system_processor__c, // 失单主机台数 |
| | | PCLLostBrand__r.Lost_cancel_report__r.Opportunity__c |
| | | from |
| | | PCLLostProduct__c |
| | | where |
| | | PCLLostBrand__r.Lost_cancel_report__c in :reportIdList]; |
| | | PCLLostBrand__r.Lost_cancel_report__r.Opportunity__c in :reportIdList]; |
| | | //20230215 lt DB202302247719 PCLLostBrand__r.Lost_cancel_report__c ---update--- PCLLostBrand__r.Lost_cancel_report__r.Opportunity__c |
| | | |
| | | |
| | | // 初始化保存参数 |
| | | Map<String, Opportunity> opp_map = new Map<String, Opportunity>(); |
| | |
| | | opp.of_lost_system_processor__c = 0; |
| | | opp_map.put(opp_id, opp); |
| | | } |
| | | |
| | | //20230215 lt DB202302247719 start |
| | | opp.LostPrices__c += lost.PCLLostBrand__r.Lost_cancel_report__r.TotalAmountLost__c; // 失单金额 |
| | | |
| | | //DB202302247719 注释 lt 注释原因:DB202302247719课题刷失单报告数据只刷失单金额 |
| | | // 赋值 |
| | | opp.LostTypeText__c = lost.PCLLostBrand__r.Lost_cancel_report__r.LostType__c; // 失单类型 |
| | | opp.LostPrices__c = lost.PCLLostBrand__r.Lost_cancel_report__r.LostTotalAmount__c; // 失单金额 |
| | | opp.Lost_reason_main__c = lost.PCLLostBrand__r.Lost_reason_main__c; // 失单原因(主) |
| | | opp.Lost_Reason_Sub__c = lost.PCLLostBrand__r.Lost_Reason_Sub__c; // 失单理由(次) |
| | | opp.of_lost_system_processor__c += lost.Quantity__c; // 失单主机台数(累加) |
| | | // opp.LostTypeText__c = lost.PCLLostBrand__r.Lost_cancel_report__r.LostType__c; // 失单类型 |
| | | // //opp.LostPrices__c = lost.PCLLostBrand__r.Lost_cancel_report__r.LostTotalAmount__c; // 失单金额 |
| | | // opp.Lost_reason_main__c = lost.PCLLostBrand__r.Lost_reason_main__c; // 失单原因(主) |
| | | // opp.Lost_Reason_Sub__c = lost.PCLLostBrand__r.Lost_Reason_Sub__c; // 失单理由(次) |
| | | // opp.of_lost_system_processor__c += lost.Quantity__c; // 失单主机台数(累加) |
| | | |
| | | |
| | | // 失单产品123 start |
| | | if (opp.CompetitorProduct1__c == null) { |
| | | opp.CompetitorProduct1__c = lost_product_name(lost.LostProductName__c, lost.LostProductMannual__c); |
| | | }else if (opp.CompetitorProduct2__c == null) { |
| | | opp.CompetitorProduct2__c = lost_product_name(lost.LostProductName__c, lost.LostProductMannual__c); |
| | | }else if (opp.CompetitorProduct3__c == null) { |
| | | opp.CompetitorProduct3__c = lost_product_name(lost.LostProductName__c, lost.LostProductMannual__c); |
| | | } |
| | | // if (opp.CompetitorProduct1__c == null) { |
| | | // opp.CompetitorProduct1__c = lost_product_name(lost.LostProductName__c, lost.LostProductMannual__c); |
| | | // }else if (opp.CompetitorProduct2__c == null) { |
| | | // opp.CompetitorProduct2__c = lost_product_name(lost.LostProductName__c, lost.LostProductMannual__c); |
| | | // }else if (opp.CompetitorProduct3__c == null) { |
| | | // opp.CompetitorProduct3__c = lost_product_name(lost.LostProductName__c, lost.LostProductMannual__c); |
| | | // } |
| | | // 失单产品123 end |
| | | |
| | | // 失单品牌 |
| | | opp.PCLLostBrands__c = lost_brand_name(opp.PCLLostBrands__c, lost.PCLLostBrand__r.Lost_By_Company__c, lost.PCLLostBrand__r.Lost_By_Company_Mannual__c); |
| | | // opp.PCLLostBrands__c = lost_brand_name(opp.PCLLostBrands__c, lost.PCLLostBrand__r.Lost_By_Company__c, lost.PCLLostBrand__r.Lost_By_Company_Mannual__c); |
| | | |
| | | // 中标经销商 |
| | | opp.Agencies__c = lost_agency_name(opp.Agencies__c, lost.PCLLostBrand__r.Agency__r.Name, lost.PCLLostBrand__r.AgencyMannual__c); |
| | | // opp.Agencies__c = lost_agency_name(opp.Agencies__c, lost.PCLLostBrand__r.Agency__r.Name, lost.PCLLostBrand__r.AgencyMannual__c); |
| | | //DB202302247719 注释 lt |
| | | //20230215 lt DB202302247719 end |
| | | |
| | | } |
| | | System.debug(opp_map); |
| | | StaticParameter.EscapeOppandStaTrigger = true; //20230215 lt DB202302247719 |
| | | update opp_map.values(); |
| | | StaticParameter.EscapeOppandStaTrigger = true; //20230215 lt DB202302247719 |
| | | } |
| | | |
| | | // 失单对手型号 |
| | |
| | | // 初始化参数 |
| | | String plus = ''; |
| | | // 判断 |
| | | if ('其他'.equals(lost_brand) && String.isNotBlank(lost_brand_mannual)) { |
| | | plus = lost_brand_mannual; |
| | | } else { |
| | | plus = lost_brand; |
| | | } |
| | | // SWAG-CCC6F6 2022-04-22 ssm start |
| | | // 询价上都只显示选项列表的值,不需要手动的值 |
| | | // if ('其他'.equals(lost_brand) && String.isNotBlank(lost_brand_mannual)) { |
| | | // plus = lost_brand_mannual; |
| | | // } else { |
| | | // plus = lost_brand; |
| | | // } |
| | | plus = lost_brand; |
| | | // SWAG-CCC6F6 2022-04-22 ssm end |
| | | // 初始化返回值 |
| | | if (String.isBlank(lost_brand_in_opp)) { |
| | | lost_brand_in_opp = ''; |
| | |
| | | // 初始化参数 |
| | | String plus = ''; |
| | | // 判断 |
| | | if ('对手经销商'.equals(lost_agency) && String.isNotBlank(lost_agency_mannual)) { |
| | | plus = lost_agency_mannual; |
| | | } else { |
| | | plus = lost_agency; |
| | | } |
| | | // SWAG-CCC6F6 2022-04-22 ssm start |
| | | // 询价上都只显示选项列表的值,不需要手动的值 |
| | | // if ('对手经销商'.equals(lost_agency) && String.isNotBlank(lost_agency_mannual)) { |
| | | // plus = lost_agency_mannual; |
| | | // } else { |
| | | // plus = lost_agency; |
| | | // } |
| | | plus = lost_agency; |
| | | // SWAG-CCC6F6 2022-04-22 ssm end |
| | | // 初始化返回值 |
| | | if (String.isBlank(lost_agency_in_opp)) { |
| | | lost_agency_in_opp = ''; |