| | |
| | | public ApexPages.StandardSetController con { get; set; } |
| | | public String soql {get;set;} |
| | | |
| | | private Boolean OSHFLG;//lt 20230517 安徽两票制 add |
| | | |
| | | // 登录者工作地 |
| | | private String userWorkLocation; |
| | | |
| | | // |
| | | public String agencyProType {get;set;} |
| | | public String agencyProType1 {get;set;} //lt 20230526 安徽两票制 add |
| | | |
| | | public String methodType {get;set;} |
| | | public String hospitalName {get;set;} |
| | |
| | | // 画面初始化 |
| | | public void init() { |
| | | |
| | | System.debug('zhj init'); |
| | | this.methodType = ApexPages.currentPage().getParameters().get('type'); |
| | | this.sortKey = '1'; |
| | | this.preSortKey = '1'; |
| | |
| | | userId = UserInfo.getUserId(); |
| | | //userId = '0050l000001dLbc'; |
| | | List<user> Useracc = New List<user>(); |
| | | Useracc = [SELECT accountid, Work_Location__c,UserPro_Type__c FROM user WHERE id = :userId ]; |
| | | //lt 20230517 安徽两票制 add ,OSHFLG__c |
| | | Useracc = [SELECT accountid, Work_Location__c,UserPro_Type__c,OSHFLG__c FROM user WHERE id = :userId ]; |
| | | accountid = Useracc[0].accountid; |
| | | userWorkLocation = Useracc[0].Work_Location__c; |
| | | agencyProType = Useracc[0].UserPro_Type__c; |
| | | agencyProType1 = Useracc[0].UserPro_Type__c; //lt 20230526 安徽两票制 add |
| | | |
| | | //lt 20230526 安徽两票制 start |
| | | OSHFLG = Useracc[0].OSHFLG__c; //lt 20230517 安徽两票制 add |
| | | if(OSHFLG){ |
| | | agencyProType1 = 'OSH'; |
| | | } |
| | | else if(String.isBlank(Useracc[0].UserPro_Type__c)){ |
| | | agencyProType1 = 'ET'; |
| | | } |
| | | //lt 20230526 安徽两票制 end |
| | | |
| | | if(String.isBlank(Useracc[0].UserPro_Type__c)){ |
| | | agencyProType = 'ET'; |
| | | } |
| | |
| | | where RecordType.DeveloperName ='AgencyContract' |
| | | and Contract_Decide_Start_Date__c <= :dateToday |
| | | and Contract_Decide_End_Date__c >= :dateToday |
| | | and Contact_Type__c like :agencyProType |
| | | and Agent_Ref__c =:accountid]; |
| | | and Contact_Type__c like :agencyProType1//lt 20230517 安徽两票制 add 1 |
| | | and Agent_Ref__c =:accountid |
| | | and OSH_Dealer__c =: OSHFLG //lt 20230517 安徽两票制 add |
| | | ]; |
| | | |
| | | for(Account contract : contractList){ |
| | | contactDealer.add(contract.Id); |
| | | } |
| | |
| | | List<Account> contract = [SELECT id,Name,State_Master__c,State_Master__r.Name |
| | | FROM Account |
| | | WHERE ParentId = :accountid |
| | | AND Contact_Type__c like :agencyProType |
| | | AND Contact_Type__c like :agencyProType1 //lt 20230517 安徽两票制 add 1 |
| | | AND Contract_Decide_Start_Date__c <= :Date.Today() |
| | | AND Contract_Decide_End_Date__c >= :Date.Today()]; |
| | | AND Contract_Decide_End_Date__c >= :Date.Today() |
| | | AND OSH_Dealer__c =: OSHFLG //lt 20230517 安徽两票制 add |
| | | ]; |
| | | |
| | | if(contract.size() == 1){ |
| | | contractName = contract[0].Name; |
| | | contractId = contract[0].Id; |
| | |
| | | size = Integer.valueOf(System.Label.orderdetLimitsize); |
| | | initStandardController(); |
| | | product2Selected = Database.query(soql); |
| | | |
| | | System.debug('product2Selected.size() = ' + product2Selected.size()); |
| | | for (Integer i = 0; i < product2Selected.size(); i++) { |
| | | consumableorderdetailsRecords.add(new ConsumableorderdetailsInfo(product2Selected[i])); |
| | | MidMap.put(product2Selected[i].Id, new ConsumableorderdetailsInfo(product2Selected[i])); |
| | |
| | | List<Account> contract = [select Id,Name,Contract_Department_Class__c,Contract_Quote_Decide_Flag__c |
| | | from account |
| | | WHERE Name = :contractName |
| | | AND Id =: contractId //lt 20230517 安徽两票制 add |
| | | AND Contract_Decide_Start_Date__c <= :Date.Today() |
| | | AND Contract_Decide_End_Date__c >= :Date.Today() |
| | | and Contact_Type__c like :agencyProType |
| | | and Agent_Ref__c =:accountid]; |
| | | and Contact_Type__c like :agencyProType1 //lt 20230517 安徽两票制 add 1 |
| | | and Agent_Ref__c =:accountid |
| | | and OSH_Dealer__c =: OSHFLG //lt 20230517 安徽两票制 add |
| | | ]; |
| | | |
| | | if(contract.size() <= 0){ |
| | | coc.Order_effective_contact__c.addError('不存在的合同,请重新确认。'); |
| | |
| | | |
| | | |
| | | //=======================================医院特价,有金额的话取金额 |
| | | // gzw 20230419 医院特价问题修复 start |
| | | // Map<String,Decimal> dealerHospitalmMap = new Map<String,Decimal>(); |
| | | // // Map<String,Decimal> dealerHospitalpMap = new Map<String,Decimal>(); |
| | | // List<hospitalprice__c> hplist = [select Id,hospital__c,mPrice__c,pPrice__c,product__c,account__c |
| | | // from hospitalprice__c |
| | | // where product__c in :tpids and mPrice__c <> null |
| | | // ]; |
| | | // for(hospitalprice__c dealerProduct: hplist){ |
| | | // if (dealerProduct.mPrice__c != null ) { |
| | | // dealerHospitalmMap.put('' + dealerProduct.account__c + dealerProduct.product__c,dealerProduct.mPrice__c); |
| | | // } |
| | | // // if (dealerProduct.pPrice__c != null) { |
| | | // // dealerHospitalpMap.put('' + dealerProduct.account__c + dealerProduct.product__c,dealerProduct.pPrice__c); |
| | | // // } |
| | | // } |
| | | |
| | | Map<String,Decimal> dealerHospitalmMap = new Map<String,Decimal>(); |
| | | // Map<String,Decimal> dealerHospitalpMap = new Map<String,Decimal>(); |
| | | List<hospitalprice__c> hplist = [select Id,hospital__c,mPrice__c,pPrice__c,product__c,account__c |
| | | from hospitalprice__c |
| | | where product__c in :tpids and mPrice__c <> null |
| | | where product__c in :tpids and mPrice__c <> null and account__c=:accountid |
| | | ]; |
| | | for(hospitalprice__c dealerProduct: hplist){ |
| | | if (dealerProduct.mPrice__c != null ) { |
| | | dealerHospitalmMap.put('' + dealerProduct.account__c + dealerProduct.product__c,dealerProduct.mPrice__c); |
| | | dealerHospitalmMap.put('' + dealerProduct.hospital__c + dealerProduct.product__c,dealerProduct.mPrice__c); |
| | | } |
| | | // if (dealerProduct.pPrice__c != null) { |
| | | // dealerHospitalpMap.put('' + dealerProduct.account__c + dealerProduct.product__c,dealerProduct.pPrice__c); |
| | | // } |
| | | } |
| | | // gzw 20230419 医院特价问题修复 end |
| | | |
| | | //促销订货 根据经销商产品中的数据计算金额 |
| | | //=======================================产品特殊折扣 |
| | |
| | | List<Account> at = [SELECT id,Name,State_Master__c,State_Master__r.Name,Sales_Section__c,Dealer_discount__c |
| | | FROM Account |
| | | WHERE Name = :contractName |
| | | and Contact_Type__c like :agencyProType |
| | | AND Id =: contractId //lt 20230517 安徽两票制 add |
| | | AND Contact_Type__c like :agencyProType1 //lt 20230517 安徽两票制 add 1 |
| | | AND Contract_Decide_Start_Date__c <= :Date.Today() |
| | | AND Contract_Decide_End_Date__c >= :Date.Today()]; |
| | | AND Contract_Decide_End_Date__c >= :Date.Today() |
| | | AND OSH_Dealer__c =: OSHFLG //lt 20230517 安徽两票制 add |
| | | ]; |
| | | System.debug('---lt123---at.size():'+at.size()); |
| | | System.debug('---lt123---at[0].Dealer_discount__c:'+at[0].Dealer_discount__c); |
| | | if(at.size() > 0 && at[0].Dealer_discount__c != null){ |
| | | disCount = at[0].Dealer_discount__c; |
| | | }else{ |
| | |
| | | //医院特价 |
| | | Consumable_order[0].Order_ForHospital__c = hospitalId; |
| | | Consumable_order[0].orderPattern__c = 'hospitalorder'; |
| | | if (dealerHospitalmMap.containsKey(accountid + ass.Prod.Id) && dealerHospitalmMap.get(accountid + ass.Prod.Id) != null) { |
| | | // gzw 20230419 医院特价问题修复 start |
| | | // if (dealerHospitalmMap.containsKey(accountid + ass.Prod.Id) && dealerHospitalmMap.get(accountid + ass.Prod.Id) != null) { |
| | | // //直接根据促销金额计算 |
| | | // InsAfterDel.Intra_Trade_List_RMB__c = dealerHospitalmMap.get(''+ accountid + ass.Prod.Id); |
| | | // } |
| | | if (dealerHospitalmMap.containsKey(hospitalId + ass.Prod.Id) && dealerHospitalmMap.get(hospitalId + ass.Prod.Id) != null) { |
| | | //直接根据促销金额计算 |
| | | InsAfterDel.Intra_Trade_List_RMB__c = dealerHospitalmMap.get(''+ accountid + ass.Prod.Id); |
| | | InsAfterDel.Intra_Trade_List_RMB__c = dealerHospitalmMap.get(''+ hospitalId + ass.Prod.Id); |
| | | } |
| | | // gzw 20230419 医院特价问题修复 end |
| | | } |
| | | else if(DealerProductMap.containsKey(ass.Prod.Id)){ |
| | | InsAfterDel.Intra_Trade_List_RMB__c = DealerProductMap.get(ass.Prod.Id).Special_Campaign_Price__c; |
| | |
| | | Consumable_order[0].orderPattern__c = 'hospitalorder'; |
| | | //医院特价 |
| | | Consumable_order[0].Order_ForHospital__c = hospitalId; |
| | | if (dealerHospitalmMap.containsKey(accountid + ass.Prod.Id) && dealerHospitalmMap.get(accountid + ass.Prod.Id) != null) { |
| | | // gzw 20230419 医院特价问题修复 start |
| | | // if (dealerHospitalmMap.containsKey(accountid + ass.Prod.Id) && dealerHospitalmMap.get(accountid + ass.Prod.Id) != null) { |
| | | // //直接根据促销金额计算 |
| | | // InsAfterDel.Intra_Trade_List_RMB__c = dealerHospitalmMap.get(''+ accountid + ass.Prod.Id); |
| | | // } |
| | | if (dealerHospitalmMap.containsKey(hospitalId + ass.Prod.Id) && dealerHospitalmMap.get(hospitalId + ass.Prod.Id) != null) { |
| | | //直接根据促销金额计算 |
| | | InsAfterDel.Intra_Trade_List_RMB__c = dealerHospitalmMap.get(''+ accountid + ass.Prod.Id); |
| | | InsAfterDel.Intra_Trade_List_RMB__c = dealerHospitalmMap.get(''+ hospitalId + ass.Prod.Id); |
| | | } |
| | | // gzw 20230419 医院特价问题修复 end |
| | | } |
| | | else if(DealerProductMap.containsKey(ass.Prod.Id)){ |
| | | InsAfterDel.Intra_Trade_List_RMB__c = DealerProductMap.get(ass.Prod.Id).Special_Campaign_Price__c; |