Search in sources :

Example 1 with Einvoice

use of com.itrus.portal.db.Einvoice in project portal by ixinportal.

the class ExtraBillWebController method showDetail.

/**
 * 增值订单详细接口
 *
 * @param id
 * @param processProgress 服务提供商
 *     1默认进度,2为内嵌页面
 * @param uiModel
 * @param request
 * @return
 */
@RequestMapping(value = "/bill/{id}.html", produces = "text/html")
public String showDetail(@PathVariable("id") Long id, @RequestParam(value = "processProgress", required = false) Long processProgress, Model uiModel, HttpServletRequest request) {
    HttpSession session = request.getSession();
    Enterprise enterprise = (Enterprise) session.getAttribute("webenterprise");
    UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
    ExtraBill bill = extraBillService.selectByPrimaryKey(id);
    if (null == bill) {
        uiModel.addAttribute("errorMsg", "订单不存在");
        return "client/errorpage";
    }
    uiModel.addAttribute("bill", bill);
    if (!bill.getUniqueId().equals(userInfo.getId())) {
        uiModel.addAttribute("errorMsg", "您无权操作该订单");
        return "client/errorpage";
    }
    // 订单对应的产品信息
    ExtraProduct product = extraProductService.selectByPrimaryKey(bill.getExtraProduct());
    uiModel.addAttribute("product", product);
    // 订单对应的规格信息
    ExtraProductSpec productSpec = extraProductSpecService.selectByPrimaryKey(bill.getExtraProductSpec());
    uiModel.addAttribute("productSpec", productSpec);
    // 银行卡支付记录信息
    PayInfoExample payInfoex = new PayInfoExample();
    Map<Long, PayInfo> payinfoMap = sqlSession.selectMap("com.itrus.portal.db.PayInfoMapper.selectByExample", payInfoex, "id");
    uiModel.addAttribute("payinfomap", payinfoMap);
    // 获取订单在线支付方式
    if (null != bill.getOnPayInfo()) {
        // 第三方在线支付记录信息
        Map<Long, OnPayInfo> opiMap = sqlSession.selectMap("com.itrus.portal.db.OnPayInfoMapper.selectByExample", "id");
        uiModel.addAttribute("opiMap", opiMap);
        // 在线支付方式配置,目前有微信和支付宝两种
        Map<Long, OnlinePay> opMap = sqlSession.selectMap("com.itrus.portal.db.OnlinePayMapper.selectByExample", "id");
        uiModel.addAttribute("opMap", opMap);
    }
    // 电子发票信息
    if (null != bill.geteInvoice()) {
        Einvoice einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", bill.geteInvoice());
        uiModel.addAttribute("einvoice", einvoice);
    }
    // 纸票模版
    Map<Long, Receipt> receiptmap = sqlSession.selectMap("com.itrus.portal.db.ReceiptMapper.selectByExample", null, "id");
    uiModel.addAttribute("receiptmap", receiptmap);
    // 电票开票模版
    Map<Long, Ereceipt> ereceiptmap = sqlSession.selectMap("com.itrus.portal.db.EreceiptMapper.selectByExample", null, "id");
    uiModel.addAttribute("ereceiptmap", ereceiptmap);
    // 企业
    Enterprise billEnterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
    if (StringUtils.isNotBlank(billEnterprise.getProvince())) {
        String province = sysRegionService.getProvince(billEnterprise.getProvince());
        billEnterprise.setProvince(province);
    }
    if (StringUtils.isNotBlank(billEnterprise.getCity())) {
        String city = sysRegionService.getCity(billEnterprise.getCity());
        billEnterprise.setCity(city);
    }
    uiModel.addAttribute("enterprise", billEnterprise);
    // 开户行信息
    OpenBankInfo openBankInfo = openBankInfoService.getOpenBankInfoByExtraBillId(id, null);
    uiModel.addAttribute("openBankInfo", openBankInfo);
    // 根据订单所处状态,返回不同的页面,或者先统一用一个页面.
    if (processProgress != null && processProgress.intValue() == 2) {
        return "client/banlijindu_neiqian";
    }
    return "client/banlijindu_moren";
}
Also used : Ereceipt(com.itrus.portal.db.Ereceipt) PayInfoExample(com.itrus.portal.db.PayInfoExample) Receipt(com.itrus.portal.db.Receipt) HttpSession(javax.servlet.http.HttpSession) ExtraBill(com.itrus.portal.db.ExtraBill) ExtraProductSpec(com.itrus.portal.db.ExtraProductSpec) UserInfo(com.itrus.portal.db.UserInfo) Einvoice(com.itrus.portal.db.Einvoice) ExtraProduct(com.itrus.portal.db.ExtraProduct) OnPayInfo(com.itrus.portal.db.OnPayInfo) PayInfo(com.itrus.portal.db.PayInfo) OnPayInfo(com.itrus.portal.db.OnPayInfo) OpenBankInfo(com.itrus.portal.db.OpenBankInfo) Enterprise(com.itrus.portal.db.Enterprise) OnlinePay(com.itrus.portal.db.OnlinePay) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Einvoice

use of com.itrus.portal.db.Einvoice in project portal by ixinportal.

the class ExtraQueryBillController method show.

// 显示详情
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) {
    // 管理员项目权限
    Long[] projectsOfAdmin = getProjectLongIdsOfAdmin();
    List<Long> projectsOfAdminList = Arrays.asList(projectsOfAdmin);
    ExtraBillExample billExample = new ExtraBillExample();
    ExtraBillExample.Criteria criteria = billExample.or();
    criteria.andIdEqualTo(id);
    criteria.andProjectIn(projectsOfAdminList);
    ExtraBill bill = sqlSession.selectOne("com.itrus.portal.db.ExtraBillMapper.selectByExample", billExample);
    if (null == bill) {
        uiModel.addAttribute("errorMsg", "未找到该订单");
        return "status403";
    }
    uiModel.addAttribute("bill", bill);
    // 项目
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", bill.getProject());
    uiModel.addAttribute("project", project);
    // 企业
    Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
    if (StringUtils.isNotBlank(enterprise.getProvince())) {
        String province = sysRegionService.getProvince(enterprise.getProvince());
        enterprise.setProvince(province);
    }
    if (StringUtils.isNotBlank(enterprise.getCity())) {
        String city = sysRegionService.getCity(enterprise.getCity());
        enterprise.setCity(city);
    }
    uiModel.addAttribute("enterprise", enterprise);
    // 产品
    ExtraProduct product = sqlSession.selectOne("com.itrus.portal.db.ExtraProductMapper.selectByPrimaryKey", bill.getExtraProduct());
    uiModel.addAttribute("product", product);
    // 规格
    ExtraProductSpec productSpec = sqlSession.selectOne("com.itrus.portal.db.ExtraProductSpecMapper.selectByPrimaryKey", bill.getExtraProductSpec());
    uiModel.addAttribute("productSpec", productSpec);
    // 服务商
    ServiceProvider serviceProvider = serviceProviderService.selectByPrimaryKey(product.getServiceProvider());
    uiModel.addAttribute("serviceProvider", serviceProvider);
    // 用户
    UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
    uiModel.addAttribute("userInfo", userInfo);
    // 第三方支付信息
    OnPayInfo onPayInfo = sqlSession.selectOne("com.itrus.portal.db.OnPayInfoMapper.selectByPrimaryKey", bill.getOnPayInfo());
    uiModel.addAttribute("onPayInfo", onPayInfo);
    if (onPayInfo != null) {
        // 在线支付信息
        OnlinePay onlinePay = sqlSession.selectOne("com.itrus.portal.db.OnlinePayMapper.selectByPrimaryKey", onPayInfo.getOnlinePay());
        uiModel.addAttribute("onlinePay", onlinePay);
    }
    // 电子发票
    Einvoice einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", bill.geteInvoice());
    uiModel.addAttribute("einvoice", einvoice);
    // 电子发票类型
    if (einvoice != null && einvoice.geteReiceipt() != null) {
        Ereceipt ereceipt = sqlSession.selectOne("com.itrus.portal.db.EreceiptMapper.selectByPrimaryKey", einvoice.geteReiceipt());
        uiModel.addAttribute("ereceipt", ereceipt);
    }
    // 其他附加信息
    // 营业执照
    BusinessLicense businessLicense = businessService.getBusinessByExtraBillId(id, null);
    uiModel.addAttribute("bl", businessLicense);
    // 税务登记
    TaxRegisterCert taxRegisterCert = taxCertService.getTaxRegisterCertByExtraBillId(id, null);
    uiModel.addAttribute("trc", taxRegisterCert);
    // 组织机构代码
    OrgCode orgCode = orgCodeService.getOrgCodeByExtraBillId(id, null);
    uiModel.addAttribute("oc", orgCode);
    // 代理人
    Agent agent = agentService.getAgentByExtraBillId(id, null);
    uiModel.addAttribute("agent", agent);
    // 开户行信息
    OpenBankInfo openBankInfo = openBankInfoService.getOpenBankInfoByExtraBillId(id, null);
    uiModel.addAttribute("obi", openBankInfo);
    // 法人信息
    IdentityCard identityCard = identityCardService.getIdentityCardByExtraBillId(id, null);
    uiModel.addAttribute("ic", identityCard);
    // TODO 还需要补充订单对应的附加信息和第三方回调信息
    return "extrabill/show";
}
Also used : Ereceipt(com.itrus.portal.db.Ereceipt) Agent(com.itrus.portal.db.Agent) ExtraBill(com.itrus.portal.db.ExtraBill) ExtraProductSpec(com.itrus.portal.db.ExtraProductSpec) UserInfo(com.itrus.portal.db.UserInfo) Einvoice(com.itrus.portal.db.Einvoice) ExtraBillExample(com.itrus.portal.db.ExtraBillExample) Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) OnPayInfo(com.itrus.portal.db.OnPayInfo) OpenBankInfo(com.itrus.portal.db.OpenBankInfo) ServiceProvider(com.itrus.portal.db.ServiceProvider) Enterprise(com.itrus.portal.db.Enterprise) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) OnlinePay(com.itrus.portal.db.OnlinePay) IdentityCard(com.itrus.portal.db.IdentityCard) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Einvoice

use of com.itrus.portal.db.Einvoice in project portal by ixinportal.

the class ExtraBillPayController method show.

// 显示详情
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel, @RequestParam(value = "payStatus", required = false) Integer payStatus) {
    uiModel.addAttribute("payStatus", payStatus);
    // 管理员项目权限
    Long[] projectsOfAdmin = getProjectLongIdsOfAdmin();
    List<Long> projectsOfAdminList = Arrays.asList(projectsOfAdmin);
    ExtraBillExample billExample = new ExtraBillExample();
    ExtraBillExample.Criteria criteria = billExample.or();
    criteria.andIdEqualTo(id);
    criteria.andProjectIn(projectsOfAdminList);
    ExtraBill bill = sqlSession.selectOne("com.itrus.portal.db.ExtraBillMapper.selectByExample", billExample);
    if (null == bill) {
        uiModel.addAttribute("errorMsg", "未找到该订单");
        return "status403";
    }
    uiModel.addAttribute("bill", bill);
    // 项目
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", bill.getProject());
    uiModel.addAttribute("project", project);
    // 企业
    Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
    uiModel.addAttribute("enterprise", enterprise);
    // 产品
    ExtraProduct product = sqlSession.selectOne("com.itrus.portal.db.ExtraProductMapper.selectByPrimaryKey", bill.getExtraProduct());
    uiModel.addAttribute("product", product);
    // 规格
    ExtraProductSpec productSpec = sqlSession.selectOne("com.itrus.portal.db.ExtraProductSpecMapper.selectByPrimaryKey", bill.getExtraProductSpec());
    uiModel.addAttribute("productSpec", productSpec);
    // 服务商
    ServiceProvider serviceProvider = serviceProviderService.selectByPrimaryKey(product.getServiceProvider());
    uiModel.addAttribute("serviceProvider", serviceProvider);
    // 用户
    UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
    uiModel.addAttribute("userInfo", userInfo);
    // 第三方支付信息
    OnPayInfo onPayInfo = sqlSession.selectOne("com.itrus.portal.db.OnPayInfoMapper.selectByPrimaryKey", bill.getOnPayInfo());
    uiModel.addAttribute("onPayInfo", onPayInfo);
    if (onPayInfo != null && onPayInfo.getOnlinePay() != null) {
        // 在线支付
        OnlinePay onlinePay = sqlSession.selectOne("com.itrus.portal.db.OnlinePayMapper.selectByPrimaryKey", onPayInfo.getOnlinePay());
        uiModel.addAttribute("onlinePay", onlinePay);
    }
    // 电子发票
    Einvoice einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", bill.geteInvoice());
    uiModel.addAttribute("einvoice", einvoice);
    // 其他附加信息
    // 营业执照
    BusinessLicense businessLicense = businessService.getBusinessByExtraBillId(id, null);
    uiModel.addAttribute("businessLicense", businessLicense);
    // 税务登记
    TaxRegisterCert taxRegisterCert = taxCertService.getTaxRegisterCertByExtraBillId(id, null);
    uiModel.addAttribute("taxRegisterCert", taxRegisterCert);
    // 组织机构代码
    OrgCode orgCode = orgCodeService.getOrgCodeByExtraBillId(id, null);
    uiModel.addAttribute("orgCode", orgCode);
    // 代理人
    Agent agent = agentService.getAgentByExtraBillId(id, null);
    uiModel.addAttribute("agent", agent);
    // 开户行信息
    OpenBankInfo openBankInfo = openBankInfoService.getOpenBankInfoByExtraBillId(id, null);
    uiModel.addAttribute("openBankInfo", openBankInfo);
    // 法人信息
    IdentityCard identityCard = identityCardService.getIdentityCardByExtraBillId(id, null);
    uiModel.addAttribute("identityCard", identityCard);
    // TODO 还需要补充订单对应的附加信息和第三方回调信息
    return "extrabillpay/show";
}
Also used : Agent(com.itrus.portal.db.Agent) ExtraBill(com.itrus.portal.db.ExtraBill) ExtraProductSpec(com.itrus.portal.db.ExtraProductSpec) UserInfo(com.itrus.portal.db.UserInfo) Einvoice(com.itrus.portal.db.Einvoice) ExtraBillExample(com.itrus.portal.db.ExtraBillExample) Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) OnPayInfo(com.itrus.portal.db.OnPayInfo) OpenBankInfo(com.itrus.portal.db.OpenBankInfo) ServiceProvider(com.itrus.portal.db.ServiceProvider) Enterprise(com.itrus.portal.db.Enterprise) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) OnlinePay(com.itrus.portal.db.OnlinePay) IdentityCard(com.itrus.portal.db.IdentityCard) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with Einvoice

use of com.itrus.portal.db.Einvoice in project portal by ixinportal.

the class BillWebController method register.

/**
 * 审核拒绝后,重新提交订单
 *
 * @param enterpriseName
 *            企业名称
 * @param enterpriseNature
 *            企业性质
 * @param billId
 *            订单id
 * @param businessLicense
 * @param orgCode
 * @param taxregisterCert
 * @param identityCard
 * @param agent
 * @param proxy
 * @param session
 * @return
 */
@RequestMapping("/register")
@ResponseBody
public Map<String, Object> register(@RequestParam(value = "enterpriseName", required = true) String enterpriseName, @RequestParam(value = "enterprise_nature", required = false) Integer enterpriseNature, @RequestParam(value = "bill_id", required = true) Long billId, @RequestParam(value = "uid", required = true) String uid, @RequestParam(value = "uid1", required = false) String uid1, @RequestParam(value = "uid2", required = false) String uid2, @RequestParam(value = "uid3", required = false) String uid3, @ModelAttribute("businessLicense") BusinessLicense businessLicense, @ModelAttribute("orgCode") OrgCode orgCode, @ModelAttribute("taxregisterCert") TaxRegisterCert taxregisterCert, @ModelAttribute("identityCard") IdentityCard identityCard, @ModelAttribute("agent") Agent agent, @ModelAttribute("proxy") Proxy proxy, HttpSession session) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识失败,1标识成功
    retMap.put("retCode", 0);
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        // 登录状态失效,跳转到注册页面
        // 2表示登录失效
        retMap.put("retCode", 2);
        retMap.put("retMsg", "登录已经失效,请重新登录");
        return retMap;
    }
    // 验证参数完整性
    if (null == enterpriseNature || 0 == enterpriseNature || null == billId) {
        retMap.put("retMsg", "提交参数信息不完整");
        return retMap;
    }
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billId);
    if (null == bill) {
        retMap.put("retMsg", "该订单不存在");
        return retMap;
    }
    if (!webuserInfo.getId().equals(bill.getUniqueId())) {
        retMap.put("retMsg", "您不能修改该订单");
        return retMap;
    }
    if (bill.getBillStatus() != ComNames.BILL_STATUS_4) {
        retMap.put("retMsg", "该订单未审核拒绝");
        return retMap;
    }
    // 根据订单id获取产品需要认证项,
    List<String> certItems = sqlSession.selectList("com.itrus.portal.db.CertificationMapper.selectCertItemsByBillId", billId);
    if (null == certItems || certItems.isEmpty()) {
        retMap.put("retMsg", "服务端出现异常,请联系管理员");
        log.error("获取订单对应产品的认证项失败:订单Id=" + billId + ".");
        return retMap;
    }
    // 记录旧的企业唯一标识:
    String oldEnterpriseSn = webenterprise.getEnterpriseSn();
    // 设置企业唯一标识
    if (enterpriseNature.equals(1) || enterpriseNature.equals(2)) {
        // 类型为企业和个体工商户:当三证合一时,企业标识为统一社会信用代码;当非三证合一时,企业标识为营业执照注册号;
        webenterprise.setEnterpriseSn(businessLicense.getLicenseNo());
    }
    if (enterpriseNature.equals(3)) {
        // 类型为政府机关/事业单位:企业标识为组织机构代码
        webenterprise.setEnterpriseSn(orgCode.getOrgCode());
    }
    // 修改企业名称
    webenterprise.setEnterpriseName(enterpriseName.trim());
    // 修改企业性质
    webenterprise.setEnterpriseNature(enterpriseNature);
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        // 删除订单关联的旧认证项,新增订单对应的新认证项
        billWebService.saveBillAuthenticationItems(certItems.get(0), enterpriseNature, billId, businessLicense, orgCode, taxregisterCert, identityCard, agent, proxy, webenterprise, webuserInfo);
        // 3、判断该订单对应的企业的认证项是否为通过,若是通过,则重新设置为不通过
        if (null != webenterprise.getAuthenticationLevel())
            webenterprise.setAuthenticationLevel(null);
        if (null != webenterprise.getHasBl())
            webenterprise.setHasBl(null);
        if (null != webenterprise.getHasOrgCode())
            webenterprise.setHasOrgCode(null);
        if (null != webenterprise.getHasTaxCert())
            webenterprise.setHasTaxCert(null);
        if (null != webenterprise.getHasIdCard())
            webenterprise.setHasIdCard(null);
        if (null != webenterprise.getHasAgent())
            webenterprise.setHasAgent(null);
        sqlSession.update("com.itrus.portal.db.EnterpriseMapper.updateByPrimaryKey", webenterprise);
        // 修改发票
        if (bill.getInvoice() != null && bill.getIsInvoiced() == null) {
            Invoice invoice = sqlSession.selectOne("com.itrus.portal.db.InvoiceMapper.selectByPrimaryKey", bill.getInvoice());
            invoice.setName(webenterprise.getEnterpriseName());
            sqlSession.update("com.itrus.portal.db.InvoiceMapper.updateByPrimaryKey", invoice);
        }
        if (bill.geteInvoice() != null && bill.getIsInvoiced() == null) {
            Einvoice einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", bill.geteInvoice());
            einvoice.setName(webenterprise.getEnterpriseName());
            sqlSession.update("com.itrus.portal.db.EinvoiceMapper.updateByPrimaryKey", einvoice);
        }
        if (StringUtils.isNotEmpty(uid) && !uid.equals("{}")) {
            bill.setUid(uid);
        }
        if (StringUtils.isNotEmpty(uid1) && !uid1.equals("{}")) {
            bill.setUid1(uid1);
        }
        if (StringUtils.isNotEmpty(uid2) && !uid2.equals("{}")) {
            bill.setUid2(uid2);
        }
        if (StringUtils.isNotEmpty(uid3) && !uid3.equals("{}")) {
            bill.setUid3(uid3);
        }
        // 设置订单为待审核状态
        bill.setBillStatus(ComNames.BILL_STATUS_3);
        sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
        transactionManager.commit(status);
        session.setAttribute("webenterprise", webenterprise);
        // 企业标识改变后,将旧目录中的图片复制到新目录中
        if (!oldEnterpriseSn.equals(webenterprise.getEnterpriseSn())) {
            CopyFile.copyFile(systemConfigService.getTrustDir().getPath() + File.separator + oldEnterpriseSn, systemConfigService.getTrustDir().getPath() + File.separator + webenterprise.getEnterpriseSn());
        }
        retMap.put("retCode", 1);
    } catch (UserInfoServiceException e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (Exception e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        UserLog userlog = new UserLog();
        userlog.setType("重新提交订单");
        userlog.setInfo("url:register,详细错误:" + e.getMessage());
        userlog.setHostId("未知");
        userlog.setProject(webuserInfo.getProject());
        LogUtil.userlog(sqlSession, userlog);
        retMap.put("retMsg", "服务端出现未知错误,请联系管理员");
        log.error(e.getMessage());
        return retMap;
    } finally {
        if (!status.isCompleted())
            transactionManager.rollback(status);
    }
    return retMap;
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) Invoice(com.itrus.portal.db.Invoice) HashMap(java.util.HashMap) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) EncDecException(com.itrus.portal.exception.EncDecException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Einvoice(com.itrus.portal.db.Einvoice) Enterprise(com.itrus.portal.db.Enterprise) EditBill(com.itrus.portal.db.EditBill) Bill(com.itrus.portal.db.Bill) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with Einvoice

use of com.itrus.portal.db.Einvoice in project portal by ixinportal.

the class BillWebController method updateAuditBill.

/**
 * 修改审核中订单
 *
 * @param enterpriseName
 *            企业名称
 * @param enterpriseNature
 *            企业性质
 * @param billId
 *            订单id
 * @param businessLicense
 * @param orgCode
 * @param taxregisterCert
 * @param identityCard
 * @param agent
 * @param proxy
 * @param session
 * @return
 */
@RequestMapping("/updateAuditBill")
@ResponseBody
public Map<String, Object> updateAuditBill(@RequestParam(value = "enterpriseName", required = true) String enterpriseName, @RequestParam(value = "enterprise_nature", required = false) Integer enterpriseNature, @RequestParam(value = "billId", required = true) Long billId, @RequestParam(value = "uid", required = true) String uid, @RequestParam(value = "uid1", required = false) String uid1, @RequestParam(value = "uid2", required = false) String uid2, @RequestParam(value = "uid3", required = false) String uid3, @ModelAttribute("businessLicense") BusinessLicense businessLicense, @ModelAttribute("orgCode") OrgCode orgCode, @ModelAttribute("taxregisterCert") TaxRegisterCert taxregisterCert, @ModelAttribute("identityCard") IdentityCard identityCard, @ModelAttribute("agent") Agent agent, @ModelAttribute("proxy") Proxy proxy, HttpSession session) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识失败,1标识成功
    retMap.put("retCode", 0);
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        // 登录状态失效,跳转到注册页面
        // 2表示登录失效
        retMap.put("retCode", 2);
        retMap.put("retMsg", "登录已经失效,请重新登录");
        return retMap;
    }
    // 验证参数完整性
    if (null == enterpriseNature || 0 == enterpriseNature || null == billId) {
        retMap.put("retMsg", "提交参数信息不完整");
        return retMap;
    }
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billId);
    if (null == bill) {
        retMap.put("retMsg", "该订单不存在");
        return retMap;
    }
    if (!webuserInfo.getId().equals(bill.getUniqueId())) {
        retMap.put("retMsg", "您不能修改该订单");
        return retMap;
    }
    // 1、订单状态为:未支付、支付待确认、已支付待审核、送审中的状态,其余状态不能继续往下执行
    List<Integer> modifiedStatus = new ArrayList<Integer>();
    modifiedStatus.add(ComNames.BILL_STATUS_1);
    modifiedStatus.add(ComNames.BILL_STATUS_2);
    modifiedStatus.add(ComNames.BILL_STATUS_3);
    modifiedStatus.add(ComNames.BILL_STATUS_10);
    // 不在以上状态中
    if (modifiedStatus.indexOf(bill.getBillStatus()) == -1) {
        retMap.put("retMsg", "该订单不能修改");
        return retMap;
    }
    // 根据订单id获取产品需要认证项,
    List<String> certItems = sqlSession.selectList("com.itrus.portal.db.CertificationMapper.selectCertItemsByBillId", billId);
    if (null == certItems || certItems.isEmpty()) {
        retMap.put("retMsg", "服务端出现异常,请联系管理员");
        log.error("获取订单对应产品的认证项失败:订单Id=" + billId + ".");
        return retMap;
    }
    // 记录旧的企业唯一标识:
    String oldEnterpriseSn = webenterprise.getEnterpriseSn();
    // 设置企业唯一标识
    if (enterpriseNature.equals(1) || enterpriseNature.equals(2)) {
        // 类型为企业和个体工商户:当三证合一时,企业标识为统一社会信用代码;当非三证合一时,企业标识为营业执照注册号;
        webenterprise.setEnterpriseSn(businessLicense.getLicenseNo());
    }
    if (enterpriseNature.equals(3)) {
        // 类型为政府机关/事业单位:企业标识为组织机构代码
        webenterprise.setEnterpriseSn(orgCode.getOrgCode());
    }
    // 修改企业名称
    webenterprise.setEnterpriseName(enterpriseName.trim());
    // 修改企业性质
    webenterprise.setEnterpriseNature(enterpriseNature);
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        // 删除订单关联的旧认证项,新增订单对应的新认证项
        billWebService.saveBillAuthenticationItems(certItems.get(0), enterpriseNature, billId, businessLicense, orgCode, taxregisterCert, identityCard, agent, proxy, webenterprise, webuserInfo);
        // 3、判断该订单对应的企业的认证项是否为通过,若是通过,则重新设置为不通过
        if (null != webenterprise.getAuthenticationLevel())
            webenterprise.setAuthenticationLevel(null);
        if (null != webenterprise.getHasBl())
            webenterprise.setHasBl(null);
        if (null != webenterprise.getHasOrgCode())
            webenterprise.setHasOrgCode(null);
        if (null != webenterprise.getHasTaxCert())
            webenterprise.setHasTaxCert(null);
        if (null != webenterprise.getHasIdCard())
            webenterprise.setHasIdCard(null);
        if (null != webenterprise.getHasAgent())
            webenterprise.setHasAgent(null);
        sqlSession.update("com.itrus.portal.db.EnterpriseMapper.updateByPrimaryKey", webenterprise);
        // 修改发票
        if (bill.getInvoice() != null && bill.getIsInvoiced() == null) {
            Invoice invoice = sqlSession.selectOne("com.itrus.portal.db.InvoiceMapper.selectByPrimaryKey", bill.getInvoice());
            invoice.setName(webenterprise.getEnterpriseName());
            sqlSession.update("com.itrus.portal.db.InvoiceMapper.updateByPrimaryKey", invoice);
        }
        if (bill.geteInvoice() != null && bill.getIsInvoiced() == null) {
            Einvoice einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", bill.geteInvoice());
            einvoice.setName(webenterprise.getEnterpriseName());
            sqlSession.update("com.itrus.portal.db.EinvoiceMapper.updateByPrimaryKey", einvoice);
        }
        // 判断该订单状态是否为送审中,假如是,则设置为 3已支付,待审核(用于重新送审)
        if (bill.getBillStatus().equals(ComNames.BILL_STATUS_10)) {
            bill.setBillStatus(ComNames.BILL_STATUS_3);
            sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
        }
        if (StringUtils.isNotEmpty(uid) && !uid.equals("{}")) {
            bill.setUid(uid);
            sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
        } else {
            if (StringUtils.isNotEmpty(uid1) && !uid1.equals("{}")) {
                bill.setUid1(uid1);
            }
            if (StringUtils.isNotEmpty(uid2) && !uid2.equals("{}")) {
                bill.setUid2(uid2);
            }
            if (StringUtils.isNotEmpty(uid3) && !uid3.equals("{}")) {
                bill.setUid3(uid3);
            }
            sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
        }
        transactionManager.commit(status);
        session.setAttribute("webenterprise", webenterprise);
        // 企业标识改变后,将旧目录中的图片复制到新目录中
        if (!oldEnterpriseSn.equals(webenterprise.getEnterpriseSn())) {
            CopyFile.copyFile(systemConfigService.getTrustDir().getPath() + File.separator + oldEnterpriseSn, systemConfigService.getTrustDir().getPath() + File.separator + webenterprise.getEnterpriseSn());
        }
        retMap.put("retCode", 1);
    } catch (UserInfoServiceException e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (Exception e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        UserLog userlog = new UserLog();
        userlog.setType("修改订单");
        userlog.setInfo("url:updateAuditBill,详细错误:" + e.getMessage());
        userlog.setHostId("未知");
        userlog.setProject(webuserInfo.getProject());
        LogUtil.userlog(sqlSession, userlog);
        retMap.put("retMsg", "服务端出现未知错误,请联系管理员");
        log.error(e.getMessage());
        return retMap;
    } finally {
        if (!status.isCompleted())
            transactionManager.rollback(status);
    }
    return retMap;
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) Invoice(com.itrus.portal.db.Invoice) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) EncDecException(com.itrus.portal.exception.EncDecException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Einvoice(com.itrus.portal.db.Einvoice) Enterprise(com.itrus.portal.db.Enterprise) EditBill(com.itrus.portal.db.EditBill) Bill(com.itrus.portal.db.Bill) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Einvoice (com.itrus.portal.db.Einvoice)9 Enterprise (com.itrus.portal.db.Enterprise)8 UserInfo (com.itrus.portal.db.UserInfo)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 ExtraBill (com.itrus.portal.db.ExtraBill)6 ExtraProduct (com.itrus.portal.db.ExtraProduct)6 ExtraProductSpec (com.itrus.portal.db.ExtraProductSpec)6 OnPayInfo (com.itrus.portal.db.OnPayInfo)6 Ereceipt (com.itrus.portal.db.Ereceipt)5 OpenBankInfo (com.itrus.portal.db.OpenBankInfo)5 Agent (com.itrus.portal.db.Agent)4 BusinessLicense (com.itrus.portal.db.BusinessLicense)4 ExtraBillExample (com.itrus.portal.db.ExtraBillExample)4 IdentityCard (com.itrus.portal.db.IdentityCard)4 OnlinePay (com.itrus.portal.db.OnlinePay)4 OrgCode (com.itrus.portal.db.OrgCode)4 Project (com.itrus.portal.db.Project)4 ServiceProvider (com.itrus.portal.db.ServiceProvider)4 TaxRegisterCert (com.itrus.portal.db.TaxRegisterCert)4 Bill (com.itrus.portal.db.Bill)3