| | |
| | | global class RadiationUtil { |
| | | |
| | | public static Boolean oldOrder = false; |
| | | |
| | | public static BOolean is_oly = false; |
| | | |
| | | public static Boolean EscapeOrderTriggerHandler = true; |
| | | /** |
| | | * [updateRadiationTypeQuantity description]更新代理商证照明细,更新奥林巴斯代理商的证照明细 |
| | |
| | | */ |
| | | public static void updateRadiationTypeQuantity (String Id, String orderFounder, String dealerId, Boolean toloseFlag, String operationType, String operator) { |
| | | |
| | | |
| | | String olympusAccountId = System.label.Olympus_Id ; |
| | | String olympusAccountId = System.label.Olympus_Id; |
| | | |
| | | String orderId = Id; |
| | | //获取合同的辐射类型和数量 |
| | |
| | | //查代理商的代理商购买明细 |
| | | Map<String, PurchaseDetails__c> dealerModelQuantityMap = GetPurchaseDetailsMap(dealerId); |
| | | //查奥林巴斯的代理商购买明细 |
| | | is_oly = true; |
| | | Map<String, PurchaseDetails__c> olympusModelQuantityMap = GetPurchaseDetailsMap(olympusAccountId); |
| | | is_oly = false; |
| | | // 查找 合同提交对应的代理商购买明细 |
| | | Map<String, PurchaseDetails__c> dealerResult = new Map<String, PurchaseDetails__c>(); |
| | | Map<String, PurchaseDetails__c> olympusResult = new Map<String, PurchaseDetails__c>(); |
| | |
| | | |
| | | } else {//增加已售产品数量 |
| | | reportMap.putAll(upsertChangedReport(olympusAccountId, radiationType, operationType, orderId, quantity, operator)); |
| | | is_oly = true; |
| | | olympusModelQuantityMap = insertPurchaseDetail(olympusModelQuantityMap, olympusAccountId, radiationType, radiationTypeQuantityMap); |
| | | is_oly = false; |
| | | } |
| | | } else {//减去已售产品数量 |
| | | if (toloseFlag) { |
| | |
| | | olympusResult.get(radiationType).SoldNumber__c -= quantity; |
| | | } else {//增加已售产品数量 |
| | | reportMap.putAll(upsertChangedReport(olympusAccountId, radiationType, operationType, orderId, quantity, operator)); |
| | | is_oly = true; |
| | | olympusModelQuantityMap = insertPurchaseDetail(olympusModelQuantityMap, olympusAccountId, radiationType, radiationTypeQuantityMap); |
| | | is_oly = false; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | if ( olympusResult.size() > 0 && olympusResult != null) { |
| | | upsert olympusResult.values(); |
| | | is_oly = true; |
| | | insertReportMap.putAll(insertChangedReport(olympusResult, reportMap)); |
| | | is_oly = false; |
| | | } |
| | | |
| | | } else { |
| | |
| | | |
| | | if ( olympusModelQuantityMap.size() > 0 && olympusModelQuantityMap != null) { |
| | | upsert olympusModelQuantityMap.values(); |
| | | is_oly = true; |
| | | insertReportMap.putAll(insertChangedReport(olympusModelQuantityMap, reportMap)); |
| | | is_oly = false; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | Map<String, Integer> radiationMap = new Map<String, Integer>(); |
| | | String accountDealerErrorMessage = updateCertificationDetails(dealerId, orderFounder, radiationMap, true); |
| | | is_oly = true; |
| | | String olympusDealerErrorMessage = updateCertificationDetails(olympusAccountId, orderFounder, radiationMap, true); |
| | | is_oly = false; |
| | | } |
| | | |
| | | } |
| | |
| | | String accountId = detail.PurchaseAccount__c; |
| | | //String accountIdafter = accountId.subString(0,15); |
| | | String key = accountId.subString(0, 15) + detail.PurProductModel__c; |
| | | |
| | | if (reportMap.containsKey(key)) { |
| | | reportMap.get(key).ChangedPurchase__c = detail.Id; |
| | | } |
| | |
| | | * @return [description] |
| | | */ |
| | | public static String updateCertificationDetails( String accountId, String orderFounder, Map<String, Decimal> dataMap, Boolean updateFlag) { |
| | | |
| | | Map<String, CertificationDetails__c> certificationDetailMap = GetAccountCertificationDetail(accountId); |
| | | |
| | | Map<String, CertificationDetails__c> temporaryCertificationDetailMap = GetAccountCertificationDetail(accountId); |
| | | |
| | | Map<String, CertificationDetails__c> certificationDetailMap = GetAccountCertificationDetail(accountId); |
| | | Map<String, CertificationDetails__c> temporaryCertificationDetailMap = GetAccountCertificationDetail(accountId); |
| | | Map<String, PurchaseDetails__c> purchaseDetailMap = GetPurchaseDetailsMap(accountId); |
| | | |
| | | Map<String, CertificationDetails__c> updatecertificationDetailMap = new Map<String, CertificationDetails__c>(); |
| | |
| | | */ |
| | | public static Map<String, CertificationDetails__c> GetAccountCertificationDetail (String accountId) { |
| | | Map<String, CertificationDetails__c> result = new Map<String, CertificationDetails__c>(); |
| | | List<CertificationDetails__c> certificationDetailsList = new List<CertificationDetails__c>(); |
| | | if (oldOrder && is_oly) { |
| | | certificationDetailsList = [ select Id, Name, ProdustionType__c, |
| | | ProductModelNumber__c, Ceiling80__c, Record80__c, Ceiling90__c, Record90__c , |
| | | CertificationDetailAccount__c, CertificationDetailAccountName__c, |
| | | LicenseInformation__r.IfQuantityCtrl__c,AccountRecordType__c,Record100__c, |
| | | Ceiling100__c |
| | | from CertificationDetails__c |
| | | where CertificationDetailAccount__c = :accountId |
| | | and ActivitieTypes__c = '销售' and IsActive__c = false]; |
| | | |
| | | }else{ |
| | | certificationDetailsList = [ select Id, Name, ProdustionType__c, |
| | | List<CertificationDetails__c> certificationDetailsList = [ select Id, Name, ProdustionType__c, |
| | | ProductModelNumber__c, Ceiling80__c, Record80__c, Ceiling90__c, Record90__c , |
| | | CertificationDetailAccount__c, CertificationDetailAccountName__c, |
| | | LicenseInformation__r.IfQuantityCtrl__c,AccountRecordType__c,Record100__c, |
| | |
| | | from CertificationDetails__c |
| | | where CertificationDetailAccount__c = :accountId |
| | | and ActivitieTypes__c = '销售' and IsActive__c = true]; |
| | | } |
| | | |
| | | |
| | | for (CertificationDetails__c detail : certificationDetailsList) { |
| | | result.put(detail.ProdustionType__c, detail); |
| | |
| | | purchaseDetail.PurProductModel__c = productModel; |
| | | purchaseDetail.PurchaseAccount__c = id; |
| | | purchaseDetail.TakeEffectInYear__c = effectiveYear; |
| | | if (oldOrder && is_oly) { |
| | | purchasedetail.company__c = '奥林巴斯'; |
| | | }else if(is_oly){ |
| | | purchaseDetail.company__c = '仪景通光学科技'; |
| | | } |
| | | |
| | | for (String model:certificationDetailMap.keySet()) { |
| | | if ('Delta和Vanta'.equals(model)) { |
| | |
| | | public static Map<String, PurchaseDetails__c> GetPurchaseDetailsMap( String accountId) { |
| | | String effectiveYear = String.valueOf(Date.today().year()); |
| | | Map<String, PurchaseDetails__c> result = new Map<String, PurchaseDetails__c>(); |
| | | List<PurchaseDetails__c> purchaseDetailsList = new List<PurchaseDetails__c>(); |
| | | if(is_oly == false){ |
| | | purchaseDetailsList = [select Id, Name, RemainingNumber__c, SoldNumber__c, |
| | | List<PurchaseDetails__c> purchaseDetailsList = [select Id, Name, RemainingNumber__c, SoldNumber__c, |
| | | PurProductModel__c, PurchaseAccount__c |
| | | from PurchaseDetails__c |
| | | where TakeEffectInYear__c = :effectiveYear and PurchaseAccount__c = :accountId]; |
| | | }else{ |
| | | if (oldOrder) { |
| | | purchaseDetailsList = [select Id, Name, RemainingNumber__c, SoldNumber__c, |
| | | PurProductModel__c, PurchaseAccount__c |
| | | from PurchaseDetails__c |
| | | where TakeEffectInYear__c = :effectiveYear and PurchaseAccount__c = :accountId and company__c = '奥林巴斯']; |
| | | }else{ |
| | | purchaseDetailsList = [select Id, Name, RemainingNumber__c, SoldNumber__c, |
| | | PurProductModel__c, PurchaseAccount__c |
| | | from PurchaseDetails__c |
| | | where TakeEffectInYear__c = :effectiveYear and PurchaseAccount__c = :accountId and company__c = '仪景通光学科技']; |
| | | } |
| | | } |
| | | if (purchaseDetailsList.size() > 0) { |
| | | for (PurchaseDetails__c purchaseDetail : purchaseDetailsList) { |
| | | result.put(purchaseDetail.PurProductModel__c, purchaseDetail); |