Exemple #1
0
 /**
  * Get return location of return part
  *
  * @param mapping ActionMapping
  * @param form ActionForm
  * @param request HttpServletRequest
  * @param response HttpServletResponse
  */
 public void getReturnLocation(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response) {
   try {
     String id = request.getParameter("returnLocCode");
     //			ReturnLocationBo rlb=new ReturnLocationBo();
     ReturnLocationForm rf = returnLocationBo.find(id);
     PrintWriter writer = response.getWriter();
     response.setContentType("text/xml");
     response.setHeader("Cache-Control", "no-cache");
     if (rf != null) {
       writer.println("<xml>");
       writer.println("<flag>true</flag>");
       if (rf.getReturnLocName() == null) {
         writer.println("<manufacture>" + EscapeUnescape.escape(null) + "</manufacture>");
       } else {
         writer.println(
             "<manufacture>" + EscapeUnescape.escape(rf.getReturnLocName()) + "</manufacture>");
       }
       writer.println("</xml>");
     } else {
       writer.println("<xml>");
       writer.println("<flag>false</flag>");
       writer.println("</xml>");
     }
     writer.flush();
     writer.close();
   } catch (Exception e) {
     e.getStackTrace();
   }
 }
Exemple #2
0
  /**
   * 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();
    }
  }