Search in sources :

Example 6 with Einvoice

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

the class MakeInvoiceService method execute.

/**
 * 开票推送
 */
@PostMapping(value = "/execute")
@ResponseBody
public Map<String, Object> execute(@RequestHeader("Content-Signature") String authHmac, @RequestParam("appId") String appId, @RequestParam("billId") String billNo, HttpServletRequest request) {
    Map<String, Object> result = new HashMap<String, Object>();
    result.put("status", -2);
    // 验证参数是否完整
    if (StringUtils.isEmpty(authHmac) || StringUtils.isEmpty(appId) || StringUtils.isEmpty(billNo)) {
        result.put("message", "提交的参数信息不完整");
        return result;
    }
    // 得到应用信息 改成service
    Map<String, ApplicationInfo> appInfoMap = CacheCustomer.getAPP_INFO_MAP();
    ApplicationInfo applicationInfo = appInfoMap.get(appId);
    if (applicationInfo == null) {
        ApplicationInfoExample applicationInfoExample = new ApplicationInfoExample();
        ApplicationInfoExample.Criteria appInfoExampleCriteria = applicationInfoExample.createCriteria();
        appInfoExampleCriteria.andAppIdEqualTo(appId);
        applicationInfo = sqlSession.selectOne("com.itrus.portal.db.ApplicationInfoMapper.selectByExample", applicationInfoExample);
    }
    // 获取配置信息
    ReceiptConfig rc = sqlSession.selectOne("com.itrus.portal.db.ReceiptConfigMapper.selectByExample");
    log.debug("任务开始");
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus ts = null;
    // 验证hmac有效性
    try {
        String macVal = Base64.encode(HMACSHA1.getHmacSHA1(appId + billNo, applicationInfo.getSecretKey()), false);
        if (!authHmac.equals("HMAC-SHA1 " + macVal)) {
            result.put("status", -4);
            result.put("message", "服务密钥错误");
            return result;
        }
    } catch (Exception e) {
        result.put("status", -3);
        result.put("message", "Hmac验证错误");
        e.printStackTrace();
        return result;
    }
    try {
        String ssl_store = getClass().getClassLoader().getResource("").getPath() + File.separator + // 执行命令后,会生成该testclient.truststore
        "fapiao.truststore";
        // 证书的存取密码,即执行命令时填写的密码
        String ssl_pwd = "ixin21060921";
        System.setProperty("javax.net.ssl.trustStore", ssl_store);
        System.setProperty("javax.net.ssl.keyStorePassword", ssl_pwd);
        // String url =
        // "https://218.17.158.39:8999/fpt_dsqz/services/DZFPService?wsdl";
        HostnameVerifier hv = new HostnameVerifier() {

            public boolean verify(String urlHostName, SSLSession session) {
                System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
                return true;
            }
        };
        HttpsURLConnection.setDefaultHostnameVerifier(hv);
        org.apache.axis.client.Service s = new org.apache.axis.client.Service();
        Call call = (Call) s.createCall();
        call.setTargetEndpointAddress(new URL(rc.getAddress()));
        call.setOperation("doService");
        Map param = new HashMap();
        param.put("billNo", billNo);
        Map<String, Object> data = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByBillEreceipt", param);
        // Bill bill =sqlSession.selectOne("", billId);
        String xml;
        String val;
        Bill bill;
        Einvoice einvoice = null;
        Ereceipt ereceipt;
        Map<String, String> temp = null;
        String content;
        if (null != data && data.size() != 0) {
            ereceipt = sqlSession.selectOne("com.itrus.portal.db.EreceiptMapper.selectByPrimaryKey", data.get("eid"));
            content = getContent(data, ereceipt);
            log.error("[input0]{}", content);
            xml = getCommonXml("DFXJ1001", new BASE64Encoder().encodeBuffer(content.getBytes("UTF-8")), rc.getAppId());
            log.error("[input1]{}", xml);
            Object[] fn01 = { xml };
            val = (String) call.invoke(fn01);
            log.error("[output]{}", val);
            temp = parseXml(val);
            if (!temp.get("returnCode").equals("0000")) {
                // LogUtil.syslog(sqlSession, "开票推送", data.get("bill_id") + "开票推送失败,错误:" + temp.get("returnMessage"));
                log.error("ERRORLOG电子发票 {}", data.get("bill_id") + "开票推送失败,错误:" + temp.get("returnMessage"));
                result.put("status", -1);
                result.put("message", "开票推送失败");
                return result;
            }
            temp = parseXml(new String(new BASE64Decoder().decodeBuffer(temp.get("content")), "UTF-8"));
            einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", data.get("e_invoice"));
            einvoice.setInvoiceId(temp.get("FPQQLSH"));
            einvoice.setInvoiceCode(temp.get("FP_DM"));
            einvoice.setInvoiceNo(temp.get("FP_HM"));
            einvoice.setCheckCode(temp.get("JYM"));
            einvoice.setConfirmTime(sdf.parse(temp.get("KPRQ")));
            einvoice.setDlAddress(temp.get("PDF_URL"));
            einvoice.setStatus(1);
            einvoice.setInvoiceSum(Double.valueOf(String.valueOf(data.get("bill_sum"))));
            ts = transactionManager.getTransaction(def);
            sqlSession.update("com.itrus.portal.db.EinvoiceMapper.updateByPrimaryKeySelective", einvoice);
            bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", data.get("id"));
            bill.setIsInvoiced(1);
            bill.setBillTime(new Date());
            if (null == bill.getDelivery() && bill.getBillStatus() == 6) {
                bill.setBillStatus(ComNames.BILL_STATUS_8);
            }
            sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
            transactionManager.commit(ts);
            // count++;
            result.put("status", 1);
            result.put("address", temp.get("PDF_URL"));
        }
        // 返回地址
        // LogUtil.syslog(sqlSession, "开票推送", "开票推送成功,推送" +
        // billexall3.size() + "条,成功" + count + "条。");
        log.debug("任务结束");
    } catch (Exception e) {
        // LogUtil.syslog(sqlSession, "开票推送", "开票推送失败,错误:" + e.toString());
        log.error("ERRORLOG电子发票 {}", "开票推送失败,错误:" + e.toString());
        e.printStackTrace();
    } finally {
        if (ts != null && !ts.isCompleted()) {
            transactionManager.rollback(ts);
        }
    }
    return result;
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) HashMap(java.util.HashMap) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) TransactionStatus(org.springframework.transaction.TransactionStatus) URL(java.net.URL) Einvoice(com.itrus.portal.db.Einvoice) BASE64Decoder(sun.misc.BASE64Decoder) Ereceipt(com.itrus.portal.db.Ereceipt) ApplicationInfoExample(com.itrus.portal.db.ApplicationInfoExample) Call(org.apache.axis.client.Call) BASE64Encoder(sun.misc.BASE64Encoder) SSLSession(javax.net.ssl.SSLSession) Date(java.util.Date) HostnameVerifier(javax.net.ssl.HostnameVerifier) Bill(com.itrus.portal.db.Bill) Map(java.util.Map) HashMap(java.util.HashMap) ReceiptConfig(com.itrus.portal.db.ReceiptConfig) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with Einvoice

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

the class ExtraBillWebController method refusePage.

// 审核拒绝页面
@RequestMapping(value = "/refusebill/{id}.html", produces = "text/html")
public String refusePage(@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");
    if (null == enterprise || null == userInfo) {
        uiModel.addAttribute("errorMsg", "登录失效");
        return "client/errorpage";
    }
    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);
    return "client/shenhejujue";
}
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) Enterprise(com.itrus.portal.db.Enterprise) OnlinePay(com.itrus.portal.db.OnlinePay) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with Einvoice

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

the class ExtraBillReceiptController 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());
    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);
    // 电子发票
    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("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 "extrabillreceipt/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) IdentityCard(com.itrus.portal.db.IdentityCard) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with Einvoice

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

the class ExtraBillReviewController 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());
    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);
    // 电子发票
    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 "extrabillreview/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) IdentityCard(com.itrus.portal.db.IdentityCard) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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