From 1b1347f2e6d40aa75bbfdfb4789d60efeff13ea8 Mon Sep 17 00:00:00 2001
From: GWY <guweiyiscp096@foxmail.com>
Date: 星期五, 15 四月 2022 09:41:12 +0800
Subject: [PATCH] LS内贸未发货和以后的不显示二级经营证(临时)
---
force-app/main/default/classes/NewQuoteEntryWebService.cls | 459 +++++++++++++--------------------------------------------
1 files changed, 106 insertions(+), 353 deletions(-)
diff --git a/force-app/main/default/classes/NewQuoteEntryWebService.cls b/force-app/main/default/classes/NewQuoteEntryWebService.cls
index 17471a1..eab2a28 100644
--- a/force-app/main/default/classes/NewQuoteEntryWebService.cls
+++ b/force-app/main/default/classes/NewQuoteEntryWebService.cls
@@ -1,376 +1,129 @@
global class NewQuoteEntryWebService {
- WebService static List<Product2> getProduct2(List<String> ids) {
- List<Product2> p2 =
- [select Id, Name, SFDA_Status__c, Intra_Trade_Cost_RMB__c,
- Intra_Trade_List_RMB__c, Foreign_Trade_Cost_US__c,
- Foreign_Trade_List_US__c, Sales_Possibility__c,
- Estimation_Entry_Possibility__c, StorageStatus__c
- // 澶氬勾淇濅慨 start
- , GuranteeType__c
- , Entend_gurantee_period_all__c
- //, Foreign_Trade_Gurantee_US__c
- , Intra_Trade_Gurantee_RMB__c
- //, If_Consumable__c
- , Intra_Trade_Service_RMB__c
- ,Maintenance_Price_Year__c
- //澶栬锤澶氬勾淇� 妫�绱㈠璐稿瓧娈� 绮剧悽鎶�鏈� wql 2021/01/29 start
- ,NoDiscount_Foreign__c
- ,Intra_Trade_Foreign_RMB__c
- ,Repair_Contract_USD__c
- //澶栬锤澶氬勾淇� 妫�绱㈠璐稿瓧娈� 绮剧悽鎶�鏈� wql 2021/01/29 start
-
- // 澶氬勾淇濅慨 end
- FROM Product2
- Where Id in :ids];
- return p2;
- }
+ private static Map<String, String> paymentTermsMap = new Map<String, String> {
+ 'Z001' => '棰勬敹娆�/棰勪粯娆�',
+ 'Z002' => '绔嬪嵆浠樻',
+ 'Z003' => '鏈堢粨30澶╁唴浠樻',
+ 'Z004' => '鏈堢粨60澶╁唴浠樻',
+ 'Z005' => '鏈堢粨90澶╁唴浠樻',
+ 'Z006' => '鏈堢粨120澶╁唴浠樻',
+ 'Z007' => '鏈堢粨25澶╁唴浠樻',
+ 'Z008' => '鏈堢粨55澶╁唴浠樻',
+ 'Z009' => '鏈堢粨85澶╁唴浠樻',
+ 'Z010' => '鏈堢粨115澶╁唴浠樻',
+ 'Z011' => '鏈堢粨175澶╁唴浠樻',
+ 'Z012' => '鏈堢粨205澶╁唴浠樻',
+ 'Z013' => '鍗婃湀缁擄紝15鏃ヤ箣鍓嶅彂璐э紝褰撴湀15鏃ュ埌鏈�',
+ 'Z014' => '鏈堢粨30澶╁唴浠樻',
+ 'Z015' => '楠屾敹鍚�15澶╃數姹�',
+ 'Z020' => '100%鍙戣揣鍚�30澶╁唴鏀粯',
+ 'Z021' => '100%鍙戣揣鍚�60澶╁唴鐢垫眹鏀粯',
+ 'Z030' => '鏀跺埌鍙戠エ鍚�30澶╁唴鐢垫眹',
+ 'Z045' => '鏈堢粨45澶╁唴浠樻',
+ 'Z060' => '鏀跺埌鍙戠エ鍚�60澶╁唴鐢垫眹',
+ 'Z075' => '鏀跺埌鍙戠エ鍚�75澶╁唴鐢垫眹',
+ 'Z090' => '鏀跺埌鍙戠エ鍚�90澶╁唴鐢垫眹',
+ 'Z0LC' => '100% L/C (90/10)',
+ 'Z120' => '鏀跺埌鍙戠エ鍚�120澶╁唴鐢垫眹',
+ 'Z1LC' => '100% L/C (80/20)',
+ 'Z1TT' => '90%TT ADV锛�10%TT AFTER',
+ 'Z2LC' => '100% L/C (70/30)',
+ 'Z2TT' => '80%TT ADV锛�20%TT AFTER',
+ 'Z30E' => '涓嬫湀鏈�',
+ 'Z3LC' => '100% L/C 90 days',
+ 'Z3TT' => '70%TT ADV锛�30%TT AFTER',
+ 'Z4LC' => '90%L/CTransfer 10%TT AFTER',
+ 'Z4TT' => '100% TT AFTER',
+ 'Z5LC' => '100%L/C at sight Transfer',
+ 'Z5TT' => '30% TT ADV锛�50% TT AT SIGHT锛�20% TT AFTER',
+ 'Z60E' => '涓�2涓湀鏈�',
+ 'Z6LC' => '100%L/C (85/15)',
+ 'Z6TT' => '30% TT ADV锛�60% TT AT SIGHT锛�10% TT AFTER',
+ 'Z7LC' => '100% L/C (60/40)',
+ 'Z7TT' => '100锛匱T AFTER(80/20)',
+ 'Z8TT' => '100% TT AFTER锛�70/30锛�',
+ 'Z9TT' => '100%TT鍙戣揣鍚�20澶╁唴鏀粯',
+ 'ZCOD' => 'C.O.D.',
+ 'ZD60' => '绔嬪嵆搴斾粯鐨� 鍒版湡鍑�鍊�',
+ 'ZFR1' => '鍗婃湀缁擄紝15鏃ヤ箣鍓嶅彂璐э紝褰撴湀15鏃ュ埌鏈�',
+ 'ZL6T' => '90% LC 60 days锛�10% TT AFTER',
+ 'ZL95' => '95% L/C AFTER,5% L/C AFTER 6M FROM ACCEPTANCE DATE',
+ 'ZLC1' => '100% L/C (90/10) Transfer',
+ 'ZLC2' => '100% L/C AT SIGHT (95/5)',
+ 'ZLT1' => '90%LC锛�10%TT',
+ 'ZLT2' => '80%LC锛�20%TT',
+ 'ZLT3' => '70%LC锛�30%TT',
+ 'ZLT4' => '95%LC锛�5%TT',
+ 'ZLT5' => '50%L/C锛�50%TT after',
+ 'ZT20' => '20% T/T ADV,80% T/T AFTER',
+ 'ZT30' => '30% T/T ADV, 70%T/T AFTER',
+ 'ZT35' => '35% TT ADV锛�65% TT AFTER',
+ 'ZT40' => '40% TT ADV锛�60% TT AFTER',
+ 'ZT50' => '50% TT ADV锛�50% TT AFTER',
+ 'ZT55' => '95%TT ADV锛�5%TT AFTER',
+ 'ZT90' => '楠屾敹鍚堟牸鍚嶵/T鏀粯90%锛岃澶囨甯歌繍琛屼笁涓湀T/T鏀粯10%',
+ 'ZTT1' => 'TT AFTER DELIVERY 45 DAY',
+ 'ZTT2' => 'TT AFTER DELIVERY 120 DAY',
+ 'ZTT3' => '100%TT鍙戣揣鍚�15涓伐浣滄棩鍐呮敮浠�',
+ 'ZTT4' => '楠屾敹鍚堟牸鍚嶵/T鏀粯80%锛岃澶囨甯歌繍琛屼笁涓湀T/T鏀粯20%',
+ 'ZZ60' => '60 DAYS AFTER ISSUING INVOICE',
+ 'ZZ95' => '95% L/C AFTER,5% T/T AFTER 6M FROM ACCEPTANCE DATE',
+ 'ZZLC' => '100% L/C AT SIGHT',
+ 'ZZTT' => '100% TT IN ADVANCE'
+ };
- WebService static List<QuoteLineItem> getQuoteLineItem(String quoId) {
- System.debug(Logginglevel.ERROR, 'NewQuoteEntryWebService getQuoteLineItem Start ' + quoId);
+ WebService static String selectQuotation(String oppId, String quoId) {
+ String rs = '';
- // 鍗板埛鏃ャ亴銇傘倠鍫村悎銆併亱銇ゅ鏇淬亴銇傘倠鍫村悎銆佺⒑瑾嶃儭銉冦偦銉笺偢銈掑嚭銇�
- List<QuoteLineItem> items = new List<QuoteLineItem>();
- if (String.isBlank(quoId) == false) {
- items = [Select Quote.Quote_Date__c, Quote.BidAnnounce__c, PricebookEntry.Product2.Packing_list_manual__c,
- PricebookEntryId, SFDA_Status__c, Cost__c, UnitPrice__c, ListPrice__c, Quantity, Qty_Unit__c,
- Id, ProductCode__c, Asset_Model_No__c, Name__c, Subtotal, AgencySubtotal__c , AgencyUnitPrice__c, Present__c
- // CHAN-B4YAB8 2018/11/09 涓氬姟鏈轰細浜у搧鐨勮禒閫併�佺粡閿�鍟嗗皬璁°�佸崟浠�
- // 澶氬勾淇濅慨 start
- , multiYearWarranty__c , GuaranteePeriod__c,warrantyType__c, NoDiscountTotal__c
- // 澶氬勾淇濅慨 end
- From QuoteLineItem where Quoteid = :quoId Order by Item_Order__c];
- }
+ List<Quote> quotes = [select Id,Name,QuoteNumber,Account.name,ExpirationDate,Subtotal,Discount,TotalPrice,GrandTotal,PaymentTerms__c
+ from Quote
+ where Id = :quoId];
+ List<QuoteLineItem> qlis = [select Id,Product2.name,Product2.ProductCode,Quantity,Subtotal,TotalPrice,PricebookEntryId,UnitPrice,Discount,Description
+ from QuoteLineItem
+ where Quoteid = :quoId
+ Order by Id];
- return items;
- }
-
- WebService static Boolean selectQuotation(String oppId, String quoId) {
- Boolean rt = false;
- // 鍙互閫夋嫨锛屾病鏈夎鍙栨秷杩囩殑鎶ヤ环
- List<Quote> quotes = [select Id, Estimation_List_Price__c, Dealer_Final_Price__c, Agency1__c, Agency1_Profit__c, Agency1_Profit_Rate__c,
- Agency2__c, Agent1_Agent2_Price__c, Agency2_Profit__c, Agency2_Profit_Rate__c, Stocking_Price__c, Quote_No__c, Name,
- OCM_Sales_Forecast__c, OCM_Agent1_Price__c, Opportunity.RecordType.DeveloperName, TotalPrice__c
- from Quote where Id = :quoId and Cancel_Decide__c = false];
- List<QuoteLineItem> qlis = [select Id, Id__c, SFDA_Status__c, Name__c, ListPrice__c, Quantity, UnitPrice__c, Qty_Unit__c, Cost__c,
- BSS_Category__c, Subtotal__c, PricebookEntryId
- from QuoteLineItem where Quoteid = :quoId Order by Item_Order__c, Id];
Savepoint sp = Database.setSavepoint();
try {
if (quotes.size() > 0) {
Quote quo = quotes[0];
+
Opportunity o = New Opportunity();
- List<Opportunity> os = New List<Opportunity>();
- os = [select Id, Estimation_List_Price__c, Dealer_Final_Price__c, Estimation_List_Price_Without_Tax__c,
- Agency1__c, OCM_Agent1_Price__c, Agency1_Profit__c, Agency1_Profit_Rate__c, Stocking_Price__c,
- Agency2__c, Agent1_Agent2_Price__c, Agency2_Profit__c, Agency2_Profit_Rate__c
- From Opportunity Where Id = :oppid];
- if (os.size() > 0) {
+ List<Opportunity> os = [select Id From Opportunity Where Id =:oppId];
+ if (os.size()>0) {
o = os[0];
- o.Estimation_List_Price__c = quo.Estimation_List_Price__c;
- o.Wholesale_Price__c = quo.OCM_Sales_Forecast__c;
- o.Dealer_Final_Price__c = quo.Dealer_Final_Price__c;
- o.Agency1__c = quo.Agency1__c;
- o.OCM_Agent1_Price__c = quo.OCM_Agent1_Price__c;
- o.Agency1_Profit__c = quo.Agency1_Profit__c;
- o.Agency1_Profit_Rate__c = quo.Agency1_Profit_Rate__c;
- o.Agency2__c = quo.Agency2__c;
- o.Agent1_Agent2_Price__c = quo.Agent1_Agent2_Price__c;
- o.Agency2_Profit__c = quo.Agency2_Profit__c;
- o.Agency2_Profit_Rate__c = quo.Agency2_Profit_Rate__c;
- o.Stocking_Price__c = quo.Stocking_Price__c;
- o.Estimation_No__c = quo.Quote_No__c;
- o.Estimation_Name__c = quo.Name;
- o.Estimation_Id__c = quo.Id;
+ o.SyncedQuoteId = quo.Id;
+ o.Quote_PaymentTerms_Text__c = paymentTermsMap.get(quo.PaymentTerms__c);
+ update o;
- ControllerUtil.updOpp(o);
-
- List<OpportunityLineItem> ols = New List<OpportunityLineItem>();
- OpportunityLineItem ol = New OpportunityLineItem();
- ols = [select Id from OpportunityLineItem Where OpportunityId = :oppid];
- if (ols.size() > 0) {
- //delete
- ControllerUtil.delOppLine(ols);
+ /* List<OpportunityLineItem> ols = [select Id from OpportunityLineItem Where OpportunityId =:oppId];
+ if (ols.size()>0) {
+ delete ols;
}
- Integer i = 1;
ols = New List<OpportunityLineItem>();
- if (qlis.size() > 0) {
- for (QuoteLineItem ql : qlis) {
- if (ql.PricebookEntryId != null) {
- ol = New OpportunityLineItem();
- ol.OpportunityId = oppId;
- ol.Id__c = ql.Id__c;
- ol.SFDA_Status__c = ql.SFDA_Status__c;
- ol.Name__c = ql.Name__c;
- ol.ListPrice__c = ql.ListPrice__c;
- ol.Quantity = ql.Quantity;
- ol.UnitPrice = 0;
- ol.UnitPrice__c = ql.UnitPrice__c;
- ol.Qty_Unit__c = ql.Qty_Unit__c;
- //銈炽偣銉堛伅灏忚▓娓堛倰鐧婚尣
- ol.Cost__c = ql.Cost__c;
- ol.BSS_Category__c = ql.BSS_Category__c;
-
- //OCM澹蹭笂浜堟脯閲戦 * (灏忚▓/瑕嬬鍚堣▓)
- if (ql.Subtotal__c != null && quo.OCM_Sales_Forecast__c != null && quo.TotalPrice__c != null) {
- if (ql.Subtotal__c > 0 && quo.TotalPrice__c > 0) {
- ol.OCM_Sales_Forecast__c = quo.OCM_Sales_Forecast__c * (ql.Subtotal__c / quo.TotalPrice__c);
- }
- }
- //渚℃牸琛�
- ol.PricebookEntryId = ql.PricebookEntryId;
- //涓︺伋闋�
- ol.Item_Order__c = i;
- ols.add(ol);
- i++;
- }
- }
- ControllerUtil.insOppLine(ols);
+ for (QuoteLineItem qli : qlis) {
+ OpportunityLineItem ol = New OpportunityLineItem();
+ ol.PricebookEntryId = qli.PricebookEntryId;
+ ol.OpportunityId = oppId;
+ ol.Quantity = qli.Quantity;
+ ol.UnitPrice = qli.UnitPrice;
+ ol.Description = qli.Description;
+ ols.add(ol);
}
- rt = true;
+
+ if (ols.size()>0) {
+ insert ols;
+ }*/
}
}
- } catch (DmlException de) {
- Database.rollback(sp);
- throw de;
+
+ rs = '1';
} catch (Exception e) {
Database.rollback(sp);
- throw e;
+ rs = e.getMessage();
}
- return rt;
- }
- //SWAG-C3BAVY 銆愬鎵樸�戣浠锋柊鏃ode 鏇挎崲 绮剧悽鎶�鏈� wql 20210607 start
- //鐢ㄤ簬鎶ヤ环鍗曟潯鏇挎崲浜у搧otcode
- WebService static Boolean updateOTCode(String tempQuoId){
- Boolean successFlag = true;
- //瀹氫箟璇环id
- String tempOppId = '';
- //瀛樻斁鎵�鏈夋姤浠疯 浜у搧id
- List<String> product2Ids = new List<String>();
- //浜у搧list
- List<Product2> Product2List = new List<Product2>();
- //key:鏃х殑浜у搧鍨嬪彿锛泇alue:瀵瑰簲鐨勬柊浜у搧id
- Map<String,String> newProIdsMap = new Map<String,String>();
- //key:鏂颁骇鍝乮d锛泇alue:鏂颁环鏍兼墜鍐宨d
- Map<String,String> newPriceBookIdMap = new Map<String,String>();
-
- //list灏佽绫� 鐢ㄦ灏佽绫� 璺宠繃 涓嶈兘鐩存帴鏇存柊琛岄」鐩笂浜у搧
- List<QELine> activities;
- //clone鎶ヤ环琛�
- List<QuoteLineItem> QuoteLineItemCloneList = new List<QuoteLineItem>();
- //clone璇环琛�
- List<OpportunityLineItem> OpportunityLineItemCloneList = new List<OpportunityLineItem>();
-
-/* ----------------------------------------鍓嶆湡鏁版嵁鍑嗗 wql start ----------------------------------------- */
- //鍏堣幏鍙栬浠穒d
- List<quote> quoteList= [select OpportunityId from quote where id =:tempQuoId];
- if(quoteList.size()>0){
- tempOppId = quoteList[0].OpportunityId;
- }
- //鑾峰彇鎵�鏈夋姤浠疯 锛堣sql浣滀负鐩存帴insert鍏嬮殕鐢� 鏈�濂戒笉瑕佹坊鍔犲叾浠栦細鏈夊奖鍝嶇殑瀛楁锛�
- List<QuoteLineItem> QuoteLineItemList =
- [Select id,Asset_Model_No__c,ProductCode__c,PricebookEntry.Product2Id, PricebookEntry.Product2.SFDA_Status__c,SFDA_Status__c, BSS_Category__c,Qty_Unit__c, Cost__c, UnitPrice__c,UnitPrice, ListPrice__c, Quantity, PricebookEntryId, UnitPrice_Page__c,AgencyUnitPrice__c, AgencySubtotal__c, Present__c, multiYearWarranty__c , If_Cancel_Guarantee__c , GuaranteePeriod__c, ServicePrice__c , GuranteePrice__c, ProductEntend_gurantee_period_all__c,ProductGuranteePrice__c, GuranteeType__c,warrantyType__c, productServicePrice__c, NoDiscountTotal__c, provistonPeriod__c, Maintenance_Price_Year__c,Quoteid,Id__c,OCM_Sales_Forecast__c,NameForPrint__c,NameForPrintDelimiter__c,Asset_Model_No_forPrint__c,Cost_Subtotal__c,Name__c,Subtotal__c,Quantity__c,ProductSetName__c,CanNotCancelFlag__c From QuoteLineItem where Quoteid =:tempQuoId Order by Item_Order__c, Id];
- //鍒ゆ柇鏄惁鏈夎椤圭洰
- if(QuoteLineItemList.size()>0){
- for(QuoteLineItem qli :QuoteLineItemList){
- Product2Ids.add(qli.PricebookEntry.Product2Id );
- }
- }
- /* ---------------杩欓儴鍒嗗叾瀹為渶瑕佺敤涓ゆ 浣嗘槸webservice娌″姙娉曞啓鍏遍�� wql start ------------------------ */
- //濡傛灉浜у搧id鏈夊��
- if(product2Ids.size()>0){
- //鏍规嵁鐜版湁鐨勪骇鍝乮d 鏌ヨ浜у搧鍨嬪彿鍜屽搴旀柊鐨勪骇鍝乮d
- Product2List = [select ProductCode,Correspond_Code__c from Product2 where id in:product2Ids and Correspond_Code__c !=null];
- }
- //瀛樻斁key:鏃х殑浜у搧鍨嬪彿锛泇alue:瀵瑰簲鐨勬柊浜у搧id
- if(Product2List.size()>0){
- for(Product2 p :Product2List){
- newProIdsMap.put(p.ProductCode,p.Correspond_Code__c);
- }
- }
- //鏍规嵁鏂颁骇鍝乮d锛岃幏鍙栦环鏍兼墜鍐宨d 杩欓噷鍥犱负姣忎釜浜у搧瀵瑰簲涓ゆ潯浠锋牸鎵嬪唽 CNY / USD ,鍏堢洿鎺ラ粯璁ゅ彇CNY鐨勪环鏍兼墜鍐�
- List<PriceBookEntry> priceBookList = [SELECT Id,Product2Id FROM PriceBookEntry WHERE Product2Id in:newProIdsMap.values() and CurrencyIsoCode ='CNY'];
- if(priceBookList.size()>0){
- for(PriceBookEntry pbe:priceBookList){
- newPriceBookIdMap.put(pbe.Product2Id,pbe.Id);
- }
- }
- /* ---------------杩欓儴鍒嗗叾瀹為渶瑕佺敤涓ゆ 浣嗘槸webservice娌″姙娉曞啓鍏遍�� wql end ------------------------ */
-
-/* ----------------------------------------鍓嶆湡鏁版嵁鍑嗗 wql end ----------------------------------------- */
-
-/* ------------------------------- 鎶ヤ环琛� 鍏ㄥ垹鍏ㄥ 鏇挎崲浜у搧otcode wql start ------------------------------------- */
- activities =new List<QELine>();
- if(QuoteLineItemList.size()>0){
- for(QuoteLineItem q :QuoteLineItemList){
- QELine c = null;
- if(q.PricebookEntry.Product2.SFDA_Status__c =='鍋滄'){
- System.debug('111:');
- System.debug('newProIdsMap:'+newProIdsMap);
- System.debug('newPriceBookIdMap:'+newPriceBookIdMap);
- System.debug('q.Asset_Model_No__c');
- c = new QELine(q,'闇�瑕佹浛鎹�',newProIdsMap.get(q.ProductCode__c),newPriceBookIdMap.get(newProIdsMap.get(q.ProductCode__c)));
- }else{
- System.debug('222:');
- c = new QELine(q,'',newProIdsMap.get(q.ProductCode__c),newPriceBookIdMap.get(newProIdsMap.get(q.ProductCode__c)));
- }
-
- System.debug('C::'+c);
- activities.add(c);
- }
- }
- try {
- //鎶ヤ环琛屽厛鍒犲悗澧� start
- if(QuoteLineItemList.size()>0){
- delete QuoteLineItemList;
- }
- if(activities.size()>0){
- for(QELine qe:activities){
- //new 琛岄」鐩�
- QuoteLineItem quo = new QuoteLineItem();
- //澶嶅埗鎶ヤ环琛�
- quo = qe.pageObject;
- //addlist
- QuoteLineItemCloneList.add(quo);
- }
- }
- system.debug('QuoteLineItemCloneList:'+QuoteLineItemCloneList);
- //鎶ヤ环琛屽厛鍒犲悗澧� start
- if(QuoteLineItemCloneList.size()>0){
- insert QuoteLineItemCloneList;
- }
- //鎶ヤ环琛屽厛鍒犲悗澧� end
- } catch (Exception e) {
- successFlag = false;
- }
-
-
-/* ------------------------------- 鎶ヤ环琛� 鍏ㄥ垹鍏ㄥ 鏇挎崲浜у搧otcode wql end ------------------------------------- */
-
-/* ------------------------------- 璇环琛� 鍏ㄥ垹鍏ㄥ 鏇挎崲浜у搧otcode wql start ------------------------------------- */
-List<OpportunityLineItem> OpportunityLineItemList=[Select id,OpportunityId,PricebookEntry.Product2Id, Asset_Model_No__c,PricebookEntry.Product2.SFDA_Status__c, SFDA_Status__c, Name__c, ProductCode__c,Qty_Unit__c, Cost__c, ListPrice__c, Quantity, BSS_Category__c, TotalPrice,Product_Cost__c, Product_ListPrice__c,PricebookEntryId,UnitPrice__c, TotalPrice__c, AgencyUnitPrice__c, AgencySubtotal__c, Present__c, multiYearWarranty__c , If_Cancel_Guarantee__c , GuaranteePeriod__c,ServicePrice__c , GuranteePrice__c,ProductEntend_gurantee_period_all__c,ProductGuranteePrice__c, GuranteeType__c,warrantyType__c, productServicePrice__c,NoDiscountTotal__c, provistonPeriod__c, Maintenance_Price_Year__c,OCM_Sales_Forecast__c,NumberOfObjective_146P__c,Id__c,OCM_man_province_txt__c,Objective_146P__c,Important_Rroduct__c,If_170Pro__c,If_EP_T1_F__c,If_AHPro__c,Is_DangerousChemicals__c,CanNotCancelFlag__c,Item_Order__c,target__c,Register_alleffective__c,strategyProductText__c From OpportunityLineItem Where OpportunityId =:tempOppId Order by Item_Order__c, Id];
- //鍒ゆ柇鏄惁鏈夎椤圭洰
- Product2Ids = new List<String>();
- Product2List = new List<Product2>();
- newProIdsMap.clear();
- newPriceBookIdMap.clear();
- priceBookList = new List<PriceBookEntry>();
-
- if(OpportunityLineItemList.size()>0){
- for(OpportunityLineItem oli :OpportunityLineItemList){
- Product2Ids.add(oli.PricebookEntry.Product2Id );
- }
- }
- /* ---------------杩欓儴鍒嗗叾瀹為渶瑕佺敤涓ゆ 浣嗘槸webservice娌″姙娉曞啓鍏遍�� wql start ------------------------ */
- //濡傛灉浜у搧id鏈夊��
- if(product2Ids.size()>0){
- //鏍规嵁鐜版湁鐨勪骇鍝乮d 鏌ヨ浜у搧鍨嬪彿鍜屽搴旀柊鐨勪骇鍝乮d
- Product2List = [select ProductCode,Correspond_Code__c from Product2 where id in:product2Ids and Correspond_Code__c !=null];
- }
- //瀛樻斁key:鏃х殑浜у搧鍨嬪彿锛泇alue:瀵瑰簲鐨勬柊浜у搧id
- if(Product2List.size()>0){
- for(Product2 p :Product2List){
- newProIdsMap.put(p.ProductCode,p.Correspond_Code__c);
- }
- }
- //鏍规嵁鏂颁骇鍝乮d锛岃幏鍙栦环鏍兼墜鍐宨d 杩欓噷鍥犱负姣忎釜浜у搧瀵瑰簲涓ゆ潯浠锋牸鎵嬪唽 CNY / USD ,鍏堢洿鎺ラ粯璁ゅ彇CNY鐨勪环鏍兼墜鍐�
- priceBookList = [SELECT Id,Product2Id FROM PriceBookEntry WHERE Product2Id in:newProIdsMap.values() and CurrencyIsoCode ='CNY'];
- if(priceBookList.size()>0){
- for(PriceBookEntry pbe:priceBookList){
- newPriceBookIdMap.put(pbe.Product2Id,pbe.Id);
- }
- }
- /* ---------------杩欓儴鍒嗗叾瀹為渶瑕佺敤涓ゆ 浣嗘槸webservice娌″姙娉曞啓鍏遍�� wql end ------------------------ */
- activities =new List<QELine>();
- System.debug('鏈�寮�濮嬬殑锛歄pportunityLineItemList锛�'+OpportunityLineItemList);
- System.debug('鏈�寮�濮嬬殑鏁伴噺锛�'+OpportunityLineItemList.size());
- if(OpportunityLineItemList.size()>0){
- for(OpportunityLineItem opp :OpportunityLineItemList){
- QELine c = null;
- if(opp.PricebookEntry.Product2.SFDA_Status__c =='鍋滄'){
- System.debug('zzzzz:');
- System.debug('newProIdsMap:'+newProIdsMap);
- System.debug('opp.ProductCode__c:'+opp.ProductCode__c);
- c = new QELine(opp,'闇�瑕佹浛鎹�',newProIdsMap.get(opp.ProductCode__c),newPriceBookIdMap.get(newProIdsMap.get(opp.ProductCode__c)));
- }else{
- c = new QELine(opp,'',newProIdsMap.get(opp.ProductCode__c),newPriceBookIdMap.get(newProIdsMap.get(opp.ProductCode__c)));
- }
- System.debug('C::'+c);
- activities.add(c);
- }
- }
- try {
- //璇环琛屽厛鍒犲悗澧� start
- if(OpportunityLineItemList.size()>0){
- delete OpportunityLineItemList;
- }
- system.debug('璇环琛岀殑琛屾暟锛�'+activities.size());
- //璇环琛屽厛鍒犲悗澧� end
- if(activities.size()>0){
- for(QELine ql:activities){
- //new 琛岄」鐩�
- OpportunityLineItem oppli = new OpportunityLineItem();
- //璇环鎶ヤ环琛�
- oppli = ql.pageOppObject;
- //addlist
- OpportunityLineItemCloneList.add(oppli);
- }
- }
-
- system.debug('OpportunityLineItemCloneList:'+OpportunityLineItemCloneList);
- //鎶ヤ环琛屽厛鍒犲悗澧� start
- if(OpportunityLineItemCloneList.size()>0){
- insert OpportunityLineItemCloneList;
- }
- } catch (Exception e) {
- successFlag = false;
- }
-
-/* ------------------------------- 璇环琛� 鍏ㄥ垹鍏ㄥ 鏇挎崲浜у搧otcode wql end ------------------------------------- */
- return successFlag;
- }
-
- //鎶ヤ环鏇挎崲浜у搧code 灏佽绫�
- public class QELine {
- //鎶ヤ环琛�
- public QuoteLineItem pageObject;
- //璇环琛�
- public OpportunityLineItem pageOppObject;
- //鏈夊弬鏋勯��
- public QELine(QuoteLineItem qli,String otcode,String proId,String tempPriceBookEntryId){
- this.pageObject = qli.clone();
- //鏇挎崲浜у搧鍜屼环鏍兼墜鍐�
- System.debug('333:');
- if(String.isNotBlank(otcode)){
- System.debug('444:');
- if(tempPriceBookEntryId!=null){
- this.pageObject.PricebookEntryId=tempPriceBookEntryId ;
- }
- // if(proId!=null){
- // System.debug('555:');
- // this.pageObject.PricebookEntry.Product2Id=proId ;
- // }
-
- }
- }
- //璇环琛岄亶鍘�
- public QELine(OpportunityLineItem oli,String otcode,String proId,String tempPriceBookEntryId){
- this.pageOppObject = oli.clone();
- //insert 鎶ヤ环涓嶉渶瑕乮d
- // this.Id = qli.Id;
- //鏇挎崲浜у搧鍜屼环鏍兼墜鍐�
- if(String.isNotBlank(otcode)){
- if(tempPriceBookEntryId!=null){
- this.pageOppObject.PricebookEntryId=tempPriceBookEntryId ;
- }
- // if(proId!=null){
- // this.pageOppObject.PricebookEntry.Product2Id=proId ;
- // }
-
- }
- }
- }
- //SWAG-C3BAVY 銆愬鎵樸�戣浠锋柊鏃ode 鏇挎崲 绮剧悽鎶�鏈� wql 20210607 end
+ return rs;
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1