From 99b667bdfd8d4fd4d56c2952510169d7f7be794c Mon Sep 17 00:00:00 2001 From: 沙世明 <shashiming@prec-tech.com> Date: 星期四, 09 三月 2023 17:12:43 +0800 Subject: [PATCH] 产品报价金额自动计算 --- force-app/main/default/classes/SI_NewQuoteEntryController.cls | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 157 insertions(+), 14 deletions(-) diff --git a/force-app/main/default/classes/SI_NewQuoteEntryController.cls b/force-app/main/default/classes/SI_NewQuoteEntryController.cls index cc6d526..9628ec8 100644 --- a/force-app/main/default/classes/SI_NewQuoteEntryController.cls +++ b/force-app/main/default/classes/SI_NewQuoteEntryController.cls @@ -10,6 +10,12 @@ public Boolean changedAfterBid { get; set; } // true 銇牬鍚堛�佺敾闈€伀 confirm 銉°儍銈汇兗銈搞亴琛ㄧず銇椼伨銇欍�俼uoId銈掓柊銇椼亜insert銆傚垽瀹氥伅js銇仹瀹熸柦 //public Id qlistId { get; set; } + //lastbuy 2022/2/9 fy start + public Boolean filg { get; set; } + public Integer flglastbuy { get; set; } + public String errorProductmodel { get; set; } + //lastbuy 2022/2/9 fy end + public String excel_text { get; set; } public Integer select_index { get; set; } // excelImport灏傜敤銇с仚銇屻�乯s銇仸鍒跺尽銇欍倠銇撱仺銇仾銈嬨伄銇с�乀ODO katsu 鍓婇櫎浜堝畾 public String Product_text { get; set; } @@ -215,6 +221,9 @@ // SI涓氬姟绯荤粺娴佺▼鏀瑰杽鍜屾彁鍗囬」鐩�2019-10-28 by vivek start ,Configuration_Suggestion__c , Configuration_Suggestion_Feedback__c // SI涓氬姟绯荤粺娴佺▼鏀瑰杽鍜屾彁鍗囬」鐩�2019-10-28 by vivek end + // DB202303051651 浜у搧鎶ヤ环閲戦鑷姩璁$畻 ssm start + , Salesdepartment_Owner__c + // DB202303051651 浜у搧鎶ヤ环閲戦鑷姩璁$畻 ssm end FROM Opportunity Where Id = :oppId]; // 澶氬勾淇濅慨 start trade = '澶栬部'; @@ -361,8 +370,8 @@ } } else { //娣诲姞琛� - List<Quote> quoList = - [ SELECT Id,Name,Cancel_Decide__c,CreatedDate, PriceRefreshDate__c,Quote_Print_Date__c, + List<Quote> quoList =//SWAG-CKDATG 銆愬鎵樸�戙�怬BSAP-鎶ヤ环濮旀墭銆戞姤浠峰鎵橀」鐩敼鍠�1 fy start QuotationChange__c,MainEngineWithoutMonitor__c,Interdepartmental__c, + [ SELECT Id,Name,Cancel_Decide__c,CreatedDate, PriceRefreshDate__c,Quote_Print_Date__c,QuotationChange__c,MainEngineWithoutMonitor__c,Interdepartmental__c, Dealer_Final_Price__c,TotalPrice__c,Estimation_List_Price__c,QuoteNumber, CreatedByid,Queto_Confirm_Date__c, QuoteToName,Quote_Expiration_Date__c,Quote_Comment__c,Stocking_Price__c,Unit_Price__c, @@ -414,7 +423,8 @@ ,PricebookEntry.Product2.NoDiscount_Foreign__c ,Quote.Opportunity.Trade__c //澶栬锤澶氬勾淇� 2021/01/27 绮剧悽鎶�鏈� wql end - + //fy 棰勭暀浜у搧鏍囪瘑 + ,PricebookEntry.Product2.LastbuyProductFLG__c //SFDC鍋滄棰勮 lt 20211009 start ,PricebookEntry.Product2.Estimated_ConsumptionDueDate__c //SFDC鍋滄棰勮 lt 20211009 end @@ -426,6 +436,7 @@ if (copyQuoId == null) { quo = quoList[0]; quoteOwner = quo.CreatedByid; + //SWAG-C5DBAL 銆愬鎵樸�� [绱ф�SI璇环鑲栧瘨鏃犳硶淇敼鎶ヤ环鍗� 绮剧悽鎶�鏈� 2021/07/30 start //娉ㄩ噴鍘熼�昏緫 if(quo.Queto_Confirm_Date__c != null || @@ -710,6 +721,11 @@ } // vivek end system.debug('鍒濆鍖栨椂鐨勯泦鍚堬細'+activities); + //SWAG-CKDATG 銆愬鎵樸�戙�怬BSAP-鎶ヤ环濮旀墭銆戞姤浠峰鎵橀」鐩敼鍠�1 fy start + quo.Offer_Amount__c = true; + quo.TOTAL__c = true; + quo.Preferential_Gurantee_Period__c = true; + //SWAG-CKDATG 銆愬鎵樸�戙�怬BSAP-鎶ヤ环濮旀墭銆戞姤浠峰鎵橀」鐩敼鍠�1 fy end return null; } @@ -813,7 +829,8 @@ //NoDiscount 閲戦锛圲SD锛� ,NoDiscount_Foreign__c //澶栬锤澶氬勾淇� 2021/01/27 绮剧悽鎶�鏈� wql end - + //fy 棰勭暀浜у搧鏍囪瘑 + ,LastbuyProductFLG__c //SFDC鍋滄棰勮 lt 20211009 start ,Estimated_ConsumptionDueDate__c //SFDC鍋滄棰勮 lt 20211009 end @@ -1014,6 +1031,7 @@ } //娣诲姞琛� public void addMultipleRow() { + system.debug('11111111111111111===11111111111111'); List<QELine> tmpQELine = new List<QELine>(); //椤甸潰涓婄殑杈撳叆妗嗚拷鍔� (鍙兘鍦ㄦ湯灏捐拷鍔�) @@ -1225,7 +1243,8 @@ //NoDiscount 閲戦锛圲SD锛� ,NoDiscount_Foreign__c //澶栬锤澶氬勾淇� 2021/01/27 绮剧悽鎶�鏈� wql end - + //fy 棰勭暀浜у搧鏍囪瘑 + ,LastbuyProductFLG__c //SFDC鍋滄棰勮 lt 20211009 start ,Estimated_ConsumptionDueDate__c //SFDC鍋滄棰勮 lt 20211009 end @@ -1675,6 +1694,23 @@ StockFlg++; } } + //20220215 fy lastbuy start + if(!ReservedProductVerification()){ + if(flglastbuy==1){ + errorflg = true; + errormessage = '棰勭暀浜у搧琛ㄤ腑娌℃湁璇ヨ浠凤紝璇烽�氳繃鏈儴绐楀彛鑱旂郴钀ヤ笟绠$悊璇�' ; + return null; + }else if(flglastbuy==2){ + errorflg = true; + errormessage = errorProductmodel+'浜у搧鏁伴噺涓嶅彲瓒呰繃浜у搧棰勭暀鏁伴噺' ; + return null; + }else if(flglastbuy==3){ + errorflg = true; + errormessage = '棰勭暀浜у搧'+errorProductmodel+'鏈綍鍏ラ鐣欎骇鍝佽〃'; + return null; + } + } + //20220215 fy lastbuy end system.debug('PassFlg:'+PassFlg); system.debug('StockFlg:'+StockFlg); if(PassFlg == 0&&oldListCheck[0].Old_Opportunity_ID__c==null){ @@ -1990,7 +2026,13 @@ Boolean error = false; errorflg = false; errormessage = null; - + //obsap 鏈�缁堢敤鎴峰悎鍚岄噾棰濋獙璇� fy start + if (quo.Dealer_Final_Price_Page__c == null) { + quo.Dealer_Final_Price__c.addError(System.Label.Error_Message3); + error = true; + errormessage = System.Label.Error_Message3; + } + //obsap 鏈�缁堢敤鎴峰悎鍚岄噾棰濋獙璇� fy end if (checkAgentsDeleteFlag() == false) { return false; } @@ -2262,11 +2304,11 @@ error = true; errormessage = System.Label.Error_Message3; } - if (quo.Dealer_Final_Price_Page__c == null) { - quo.Dealer_Final_Price__c.addError(System.Label.Error_Message3); - error = true; - errormessage = System.Label.Error_Message3; - } + // if (quo.Dealer_Final_Price_Page__c == null) { + // quo.Dealer_Final_Price__c.addError(System.Label.Error_Message3); + // error = true; + // errormessage = System.Label.Error_Message3; + // } if (qb.Quote_Adjust_Calculate == null) { quo.Quote_Adjust_Calculate__c.addError(System.Label.Error_Message3); error = true; @@ -2443,8 +2485,8 @@ } } else { - List<Quote> qs = New List<Quote>(); - qs = [select Id,OpportunityId,Pricebook2Id,Name,Estimation_List_Price__c,Dealer_Final_Price__c, + List<Quote> qs = New List<Quote>();//SWAG-CKDATG 銆愬鎵樸�戙�怬BSAP-鎶ヤ环濮旀墭銆戞姤浠峰鎵橀」鐩敼鍠�1 fy start QuotationChange__c,MainEngineWithoutMonitor__c,Interdepartmental__c, + qs = [select Id,OpportunityId,Pricebook2Id,Name,Estimation_List_Price__c,Dealer_Final_Price__c,QuotationChange__c,MainEngineWithoutMonitor__c,Interdepartmental__c, Stocking_Price__c,Discount_Amount__c,Discount_Amount_Calculate__c,Quote_Adjust_Amount__c,Quote_Adjust_Calculate__c, Agency1__c,OCM_Agent1_Price__c,Agency1_Profit__c,Agency1_Profit_Rate__c,Quote_No__c, Agency2__c,Agent1_Agent2_Price__c,Agency2_Profit__c,Agency2_Profit_Rate__c, @@ -2531,6 +2573,12 @@ q.Quote_Comment__c = quo.Quote_Comment__c; q.Installation_location__c = quo.Installation_location__c; + + //SWAG-CKDATG 銆愬鎵樸�戙�怬BSAP-鎶ヤ环濮旀墭銆戞姤浠峰鎵橀」鐩敼鍠�1 fy start + q.QuotationChange__c = quo.QuotationChange__c; + q.MainEngineWithoutMonitor__c = quo.MainEngineWithoutMonitor__c; + q.Interdepartmental__c = quo.Interdepartmental__c; + //SWAG-CKDATG 銆愬鎵樸�戙�怬BSAP-鎶ヤ环濮旀墭銆戞姤浠峰鎵橀」鐩敼鍠�1 fy end /* if (hasType3Machine) { q.Installation_location__c = ''; @@ -2560,6 +2608,7 @@ //Sap閫佷俊,Print銇悎銈忋仜銇�1锝� Integer i=1; if (activities.size()>0) { + system.debug('activities+++***+++'+activities); for (QELine s:activities) { if (s.Asset_Model != null && s.Asset_Model != '') { if (s.pageObject.PricebookEntryId != null) { @@ -2757,7 +2806,89 @@ } return true; } - +//lastbuy 2022/2/15 fy start +public boolean ReservedProductVerification() { + filg=true; + Map<string,QuoteLineItem> quotlinitMap = new Map<string,QuoteLineItem>(); + List<Id> lastProductFLGListId = new List<Id>(); + List<QuoteLineItem> lastProductFLGList = new List<QuoteLineItem>(); + List<QuoteLineItem> act = new List<QuoteLineItem>(); + List<QuoteLineItem> act2 = new List<QuoteLineItem>(); + for(QELine aaa :activities){ + if(aaa.pageObject.PricebookEntry.Product2Id!=null){ + act.add(aaa.pageObject); + } + } + act2=act.deepClone(); + Map<String,QuoteLineItem> map1 = new Map<String,QuoteLineItem>(); + System.debug('activities1111111111112涓烘墍褰撲负澶氬!!!'+activities); + integer i =0; + for(QuoteLineItem pspsc :act2){ + if(pspsc.PricebookEntry.Product2Id!=null){ + if(map1.containsKey(pspsc.PricebookEntry.Product2Id)){ + QuoteLineItem quoteLine = map1.get(pspsc.PricebookEntry.Product2Id); + quoteLine.Quantity__c =quoteLine.Quantity__c+pspsc.Quantity__c; + map1.put(pspsc.PricebookEntry.Product2Id,quoteLine); + }else{ + map1.put(pspsc.PricebookEntry.Product2Id,pspsc); + } + // System.debug('34499879!!!'+activities); + } + } + System.debug('3434343!!!'+activities); + System.debug('5656565!!!'+map1); + for (QuoteLineItem value : map1.values()) { + if(value.PricebookEntry.Product2.LastbuyProductFLG__c){ + lastProductFLGListId.add(value.PricebookEntry.Product2Id); + quotlinitMap.put(value.PricebookEntry.Product2Id,value); + lastProductFLGList.add(value); + } + } + System.debug('activities++++!!!'+activities); + System.debug('activities!!!'+map1.values()); + System.debug('oppId!!!'+oppId); + System.debug('lastProductFLGList!!!'+lastProductFLGListId); + if(lastProductFLGListId!=null&&lastProductFLGListId.size()!=0){ + List<LastbuyProduct__c> LastbuyObjList=[select id,LastbuyQuantity__c,InquiryCode__c,ProductName__c,effectiveFLG__c from LastbuyProduct__c where InquiryCode__c= : oppId and ProductName__c in :lastProductFLGListId and effectiveFLG__c = true]; + Map<string,LastbuyProduct__c> LastbuyObjMap = new Map<string,LastbuyProduct__c>(); + System.debug('LastbuyObjList+++++!!!'+LastbuyObjList); + if(LastbuyObjList!=null&&LastbuyObjList.size()!=0){ + for(LastbuyProduct__c lastbuypr :LastbuyObjList){ + LastbuyObjMap.put(lastbuypr.ProductName__c,lastbuypr); + } + }else{ + flglastbuy=1; + filg=false; + return filg; + } + System.debug('LastbuyObjMap!!!'+LastbuyObjMap); + System.debug('lastProductFLGList+++++++!!!'+lastProductFLGList); + if(lastProductFLGList!=null&&lastProductFLGList.size()!=0){ + for(QuoteLineItem lastbuypr :lastProductFLGList){ + Decimal quoteLItemNum=0; + if(LastbuyObjMap.containsKey(lastbuypr.PricebookEntry.Product2Id)){ + quoteLItemNum=LastbuyObjMap.get(lastbuypr.PricebookEntry.Product2Id).LastbuyQuantity__c; + System.debug('quoteLItemNum!!!'+quoteLItemNum); + System.debug('lastbuypr.pageObject.Quantity__c+++!!!'+lastbuypr.Quantity__c); + if(lastbuypr.Quantity__c>quoteLItemNum){ + errorProductmodel=lastbuypr.Asset_Model_No__c; + flglastbuy=2; + filg=false; + break; + } + }else{ + errorProductmodel=lastbuypr.Asset_Model_No__c; + flglastbuy=3; + filg=false; + break; + } + } + } + } + system.debug('filg====='+filg); + return filg; + } + //lastbuy 2022/2/15 fy end //opp銇敾闈€伄鍊ゃ倰瑷畾 private void setOppFromOppInfo() { opp.Wholesale_Price__c = oppInfo.Wholesale_Price; @@ -3302,6 +3433,12 @@ public boolean If_Need_Authorize { get; set; } public String Authorized_DB_No { get; set; } // LHJ End + // DB202303051651 浜у搧鎶ヤ环閲戦鑷姩璁$畻 ssm start + // 鍖婚櫌鍚堝悓閲戦姣斾緥 + public Decimal rate_hospital { get; set; } + // 缁忛攢鍟�1鍚堝悓閲戦姣斾緥 + public Decimal rate_agency1 { get; set; } + // DB202303051651 浜у搧鎶ヤ环閲戦鑷姩璁$畻 ssm end public OppInfo(Opportunity opp) { Account_RecordType_DeveloperName = opp.Account.RecordType.DeveloperName; @@ -3316,6 +3453,12 @@ If_Need_Authorize = opp.If_Need_Authorize__c; Authorized_DB_No = opp.Authorized_DB_No__c; // LHJ End + // DB202303051651 浜у搧鎶ヤ环閲戦鑷姩璁$畻 ssm start + String str_rate_hospital = ControllerUtil.getValueFromJSONString(System.Label.Quote_HospitalAmount_Rate, opp.Salesdepartment_Owner__c); + String str_rate_agency1 = ControllerUtil.getValueFromJSONString(System.Label.Quote_Agency1Amount_Rate, opp.Salesdepartment_Owner__c); + rate_hospital = String.isNotBlank(str_rate_hospital) ? Decimal.valueOf(str_rate_hospital) : 1.0; + rate_agency1 = String.isNotBlank(str_rate_agency1) ? Decimal.valueOf(str_rate_agency1) : 1.0; + // DB202303051651 浜у搧鎶ヤ环閲戦鑷姩璁$畻 ssm end } } //TODO 1.Quote銈儢銈搞偋銈儓杩藉姞 -- Gitblit v1.9.1