/** * RC add warranty claim fee * * @param request HttpServletRequest * @param form ActionForm * @return String Return results page */ public String addBalanceFee(HttpServletRequest request, ActionForm form) { String forward = "resultMessage"; ArrayList al = new ArrayList(); int ftag = -1; int ptag = -1; try { /** * ******************************************************************** /*@Added/Modified by : * Veena /*@Date : 4/09/2012 /*@Reason : INC000000441294, CR 19 - Tax calculation by system * /********************************************************************* */ String stateCode = null; String cityCode = null; String unitCode = null; Long organizationCode = null; String customerGroupId = null; ArrayList<String> feeTypeList = new ArrayList<String>(); TreeMap<String, ServiceTaxListBean> serviceTaxMap = null; /** **********************Ends here********************************************* */ Set balanceIdSet = new HashSet(); HttpSession session = request.getSession(); Long chargeStaffId = (Long) session.getAttribute("userId"); String chks = (String) request.getParameter("chksBalanceId"); BalanceFeeForm2 bf = (BalanceFeeForm2) form; String status = ""; if ("bcApprove".equals(bf.getSheetType())) { status = "1"; } else { status = "27"; } // System.out.println("sheetType---------------"+bf.getSheetType()); // System.out.println("status---------------"+status); // BCBalanceApproveBo rbo=new BCBalanceApproveBo(); List tempList = bcBalanceApproveBo.listVersion(chks); for (int i = 0; i < tempList.size(); i++) { BalanceFeeForm2 balanceFeeForm = (BalanceFeeForm2) tempList.get(i); balanceIdSet.add(balanceFeeForm.getBalanceId()); // 取不重复的balanceId } Iterator it = balanceIdSet.iterator(); while (it.hasNext()) { BalanceFeeForm2 addFeeForm = new BalanceFeeForm2(); Long tempBalanceId = (Long) it.next(); addFeeForm.setBalanceId(tempBalanceId); addFeeForm.setBalanceFeeType(bf.getBalanceFeeType()); addFeeForm.setBalanceSponsor(new Long(request.getParameter("hiddenFactoryInfo"))); addFeeForm.setBalanceFee(bf.getBalanceFee()); /** * ******************************************************************** /*@Added/Modified by * : Veena /*@Date : 4/09/2012 /*@Reason : INC000000441294, CR 19 - Tax calculation by * system /********************************************************************* */ feeTypeList.add(bf.getBalanceFeeType()); Long repairNo = Long.valueOf(bcBalanceApproveBo.findRepairNoByBalanceId(tempBalanceId.toString())); RepairServiceForm rsf = getRepairInfo(repairNo); organizationCode = rsf.getOrganizationCode(); cityCode = cs.getCityCode(organizationCode); stateCode = cs.getStateCode(organizationCode); unitCode = cs.findUnitCodeByOrgCode(organizationCode); /* *******************************************************************/ /*@Added/Modified by : Manohar /*@Date : 17/04/2013 /*@Reason : INC000000518392 - NeWSIS :: System issue :: Fee modification for jobs /**********************************************************************/ if (null != rsf.getCustomerId() && rsf.getCustomerId().equals("")) { customerGroupId = cs.getCustomGrpId(rsf.getCustomerId().toString()).toString(); } /* ************************ENDS HERE**************************************** */ SearchOptionListSetting taxOptionList = new SearchOptionListSetting(); taxOptionList.createServiceTaxDefaultInstance( stateCode, cityCode, unitCode, feeTypeList, customerGroupId); MultiEntity multiEntity = (MultiEntity) SpringContextUtil.getBean("multiEntity"); String countryCode = multiEntity.getCountryCode(); CommonSearchService commonSearchService = (CommonSearchService) SpringContextUtil.getBean("commonSearchService" + countryCode); serviceTaxMap = commonSearchService.getTaxList(taxOptionList); ServiceTaxListBean taxList = (serviceTaxMap == null) ? null : serviceTaxMap.get(bf.getBalanceFeeType()); if (taxList != null) { taxList.calculate(bf.getBalanceFee()); /* *******************************************************************/ /*@Added/Modified by : Sanjay /*@Date : 25/09/2012 /*@Reason : INC000000456989 - IW Module Add fee Issue - Operation failed /**********************************************************************/ if (null != taxList.getTotalTaxAmt().toString()) { addFeeForm.setTaxTotal(taxList.getTotalTaxAmt().toString()); } /* ************************ENDS HERE********************************** */ } addFeeForm.setBalanceFeeStatus( status); // 设置状æ€�å�Œæ¤é¡µé�¢ç»“ç®—å�•çŠ¶æ€�为BCæš‚å�œ addFeeForm.setCreateBy(chargeStaffId); addFeeForm.setCreateDate(Operate.toUtilDate()); addFeeForm.setIsSysGen("N"); // 代表是 BC手工添加的这笔费用 addFeeForm.setRepairCode( bcBalanceApproveBo.findRepairCodeByBalanceId(tempBalanceId.toString())); // 方法代码 if (bf.getBcRemark() != null && !"".equals(bf.getBcRemark())) { addFeeForm.setBcRemark("BC Manul Create:" + bf.getBcRemark()); } ftag = bcBalanceApproveBo.add(addFeeForm); if (ftag == 1) { // 插入结算费用变化过程表 SettlementFeeChangeProcdureForm sfcpf = new SettlementFeeChangeProcdureForm(); sfcpf.setBalanceId(tempBalanceId); sfcpf.setBalanceFeeId(addFeeForm.getBalanceFeeId()); sfcpf.setBalanceFee(bf.getBalanceFee()); // wubin at 20100527 增加taxTotal Double tempTaxTotal = bf.getTaxTotal() == null || "".equals(bf.getTaxTotal().trim()) ? 0 : Double.parseDouble(bf.getTaxTotal()); sfcpf.setTaxTotal(tempTaxTotal); sfcpf.setBalanceStatus(status); sfcpf.setChangeBy(chargeStaffId); sfcpf.setRemark(bf.getBcRemark()); sfcpf.setCreateBy(chargeStaffId); sfcpf.setCreateDate(Operate.toUtilDate()); ptag = bcBalanceApproveBo.add(sfcpf); if (ptag == -1) { bcBalanceApproveBo.delete(addFeeForm); } } } request.setAttribute("tag", ptag + ""); if ("bcApprove".equals(bf.getSheetType())) { request.setAttribute("businessFlag", "RcApprove"); } else { request.setAttribute("businessFlag", "BCWait"); } } catch (VersionException ve) { forward = "versionErr"; } catch (Exception e) { e.printStackTrace(); } return forward; }
/** * Part accessory sale index save * * @param request HttpServletRequest * @param form ActionForm form data * @param mapping ActionMapping * @param response HttpServletResponse */ public void validate( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { try { MultiEntity multiEntity = (MultiEntity) SpringContextUtil.getBean("multiEntity"); HttpSession session = request.getSession(); PrintWriter writer = response.getWriter(); response.setContentType("text/xml"); response.setHeader("Cache-Control", "no-cache"); writer.println("<xml>"); Long orgCode = (Long) session.getAttribute("orgCode"); Boolean isSSC = (Boolean) session.getAttribute("isSSC"); String stType = (String) session.getAttribute("stType"); String pcType = ((CommonSearch) SpringContextUtil.getBean("commonSearch")).findPcTypeByOrgCode(orgCode); String partCode = request.getParameter("skuCode"); String customerId = request.getParameter("customerId"); int quantity = new Integer(request.getParameter("quantity")).intValue(); // 得到 part info PartInfoForm partInfoForm = partInfoBo.find(partCode); PartsPriceLogic priceLogic = new PartsPriceLogic(); // if (partInfoForm != null) { String clientType = ""; Double partStdCost = null; FactorMarkUp priceGroupRelation = null; boolean hasPriceGroupFee = true; if (customerId != null && !customerId.equals("") && NumberUtils.isDigits(customerId)) { // 得到customer group id Long cusGrpid = ((CommonSearch) SpringContextUtil.getBean("commonSearch")).getCustomGrpId(customerId); if (cusGrpid != null) { clientType = cusGrpid.toString(); priceGroupRelation = priceGroupBo.findGroupRelation(Long.parseLong(customerId), orgCode); TdCustomerInfoForm cus = (TdCustomerInfoForm) priceGroupBo .getDao() .findById(TdCustomerInfoForm.class, Long.parseLong(customerId)); if (priceGroupRelation == null) { priceLogic = new PartsPriceLogic(); } else { priceLogic = new PartsPriceLogic(priceGroupRelation.getPriceGroupId(), cus.getForSsc()); } partStdCost = priceLogic.getPartPrice(partCode, "SS", orgCode, pcType, clientType); String enableMU6 = CommonSearch.getSystemCode("ENABLE_MU6", "MU6", multiEntity.getCountryCode()); if ("P".equals(stType) && isSSC && (null != enableMU6 && "Y".equals(enableMU6.toUpperCase()))) { if (null != priceGroupRelation) { hasPriceGroupFee = partStdCost != 0d; } else { hasPriceGroupFee = false; } } } } boolean flag = partInfoBo.isCanUsePart(partCode, "S"); /** *****新的计价逻辑****** */ CommonSearch cs = ((CommonSearch) SpringContextUtil.getBean("commonSearch")); ArrayList<PartsSalesInfo> partList = new ArrayList<PartsSalesInfo>(); SearchOptionListSetting extOptionList = null; String productSubCategory = partInfoForm.getProduct_Subcategory(); String cityCode = cs.getCityCode(orgCode); String stateCode = cs.getStateCode(orgCode); String unitCode = cs.findUnitCodeByOrgCode(orgCode); String ascLevel = cs.getAscLevelByOrgCode(orgCode); RepairBasicInfo repairBasicInfo = new RepairBasicInfo( null, stateCode, cityCode, "", productSubCategory, "", "", orgCode, new Long(customerId), unitCode, ascLevel, ""); repairBasicInfo.setOrgType(pcType); repairBasicInfo.setClientType(clientType); repairBasicInfo.setAbandonFlag(true); PartsSalesInfo partsSalesInfo = new PartsSalesInfo(); partsSalesInfo.setPartCode(partInfoForm.getPartCode()); partsSalesInfo.setChargableFlag("N"); partsSalesInfo.setQuantity(quantity); partList.add(partsSalesInfo); PartFeeInterface partFeeInterface = (PartFeeInterface) SpringContextUtil.getBean("partFeeInterface" + multiEntity.getCountryCode()); partFeeInterface.initSales(repairBasicInfo); PartFeeListBean partFeeListBean = partFeeInterface.getSalesPartFee(extOptionList, partList); ArrayList<PartFeeBean> partFeeBeanList = partFeeListBean.listFee(); PartFeeBean partFeeBean = partFeeBeanList.get(0); PartTaxListBean partTaxListBean = partFeeBean.getTaxList(); ArrayList<PartTaxBean> partTaxBeanList = partTaxListBean.listTax(); writer.println("<partFlag>true</partFlag>"); writer.println( "<partName>" + EscapeUnescape.escape(partInfoForm.getPartName()) + "</partName>"); writer.println( "<partDesc>" + EscapeUnescape.escape(partInfoForm.getPartDesc()) + "</partDesc>"); writer.println( "<partPrice>" + Operate.DoubleTransfer(partFeeBean.getPartPrice()) + "</partPrice>"); // System.out.println("<partPrice>" + Operate.DoubleTransfer(partFeeBean.getPartPrice()) // + "</partPrice>"); writer.println( "<stdCost>" + Operate.DoubleTransfer(partInfoForm.getStdCost()) + "</stdCost>"); writer.println("<isHasSn>" + partInfoForm.getIsHasSn() + "</isHasSn>"); writer.println("<isCanUsePart>" + flag + "</isCanUsePart>"); writer.println("<perCost>" + Operate.DoubleTransfer(partStdCost) + "</perCost>"); // System.out.println("<perCost>"+Operate.DoubleTransfer(partStdCost)+"</perCost>"); StringBuffer taxBuffer = new StringBuffer(); int count = 0; Double totalTax = 0.0; for (PartTaxBean partTaxBean : partTaxBeanList) { writer.println("<taxRow id=\"" + count + "\">"); writer.println( "<taxCode>" + EscapeUnescape.escape(partTaxBean.getTaxCode()) + "</taxCode>"); writer.println( "<taxName>" + EscapeUnescape.escape(popupSaleInfoBo.findTaxName(partTaxBean.getTaxCode())) + "</taxName>"); writer.println( "<taxRate>" + EscapeUnescape.escape( String.valueOf(Operate.formatPrice(partTaxBean.getTaxRate() * 100))) + "</taxRate>"); writer.println( "<taxAmt>" + EscapeUnescape.escape(Operate.DoubleTransfer(partTaxBean.getTaxAmt())) + "</taxAmt>"); writer.println( "<convertedTaxRate>" + EscapeUnescape.escape( String.valueOf(Operate.formatPrice(partTaxBean.getActualTaxRate() * 100))) + "</convertedTaxRate>"); writer.println( "<taxType>" + EscapeUnescape.escape(partTaxBean.getTaxType()) + "</taxType>"); writer.println("</taxRow>"); Double tax = partTaxBean.getTaxAmt(); String taxType = partTaxBean.getTaxType(); totalTax = PriceLogicCommonHelper.calculateTaxByTaxType(totalTax, tax, taxType); String taxString = partTaxBean.getTaxCode() + SPLITER1_STR + popupSaleInfoBo.findTaxName(partTaxBean.getTaxCode()) + SPLITER1_STR + partTaxBean.getTaxRate() + SPLITER1_STR + Operate.DoubleTransfer(partTaxBean.getTaxAmt()) + SPLITER1_STR + partTaxBean.getActualTaxRate(); taxBuffer.append(taxString); taxBuffer.append(SPLITER2_STR); count += 1; } writer.println( "<totalTax>" + EscapeUnescape.escape(Operate.DoubleTransfer(totalTax)) + "</totalTax>"); writer.println( "<taxBuffer>" + EscapeUnescape.escape(taxBuffer.toString()) + "</taxBuffer>"); writer.println("<hasPriceGroup>" + hasPriceGroupFee + "</hasPriceGroup>"); } else { writer.println("<partFlag>false</partFlag>"); } writer.println("</xml>"); writer.flush(); writer.close(); } catch (Exception e) { e.printStackTrace(); } }