Search in sources :

Example 1 with ReceiptConfig

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

the class ReceiptConfigController method show.

// 显示详情
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) {
    /*try {
        	 
        	List<ReceiptConfig> list = sqlSession.selectList("com.itrus.portal.db.ReceiptConfigMapper.selectByExample",new ReceiptConfigExample());
        	if(list==null || list.isEmpty()){
        		return "redirect:/receiptconfig?form";
        	}
        	ReceiptConfig receiptconfig  = list.get(0);
            uiModel.addAttribute("receiptconfig", receiptconfig);
        } catch (Exception e) {
            e.printStackTrace();
        }*/
    ReceiptConfig receiptconfig = sqlSession.selectOne("com.itrus.portal.db.ReceiptConfigMapper.selectByPrimaryKey", id);
    uiModel.addAttribute("receiptconfig", receiptconfig);
    return "receiptconfig/show";
}
Also used : ReceiptConfig(com.itrus.portal.db.ReceiptConfig)

Example 2 with ReceiptConfig

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

the class ReceiptConfigController method list.

// 列表所有信息
@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "message", required = false) Integer message, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) throws Exception {
    // page,size
    if (page == null || page < 1)
        page = 1;
    if (size == null || size < 1)
        size = 10;
    // count,pages
    Integer count = sqlSession.selectOne("com.itrus.portal.db.ReceiptConfigMapper.countByExample", null);
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    // page, size
    if (page > 1 && size * (page - 1) >= count) {
        page = (count + size - 1) / size;
    }
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    // query data
    Integer offset = size * (page - 1);
    ReceiptConfigExample rconfigex = new ReceiptConfigExample();
    // projectex.or().andIdIsNotNull();
    rconfigex.setOffset(offset);
    rconfigex.setLimit(size);
    List<ReceiptConfig> rconfigexall = sqlSession.selectList("com.itrus.portal.db.ReceiptConfigMapper.selectByExample", rconfigex);
    uiModel.addAttribute("receiptconfigs", rconfigexall);
    // itemcount
    uiModel.addAttribute("itemcount", rconfigexall.size());
    uiModel.addAttribute("message", message == null ? "" : "要删除的支付配置存在关联,无法删除");
    return "receiptconfig/list";
}
Also used : ReceiptConfigExample(com.itrus.portal.db.ReceiptConfigExample) ReceiptConfig(com.itrus.portal.db.ReceiptConfig)

Example 3 with ReceiptConfig

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

the class ReceiptConfigController method modify.

// 返回修改页面
@RequestMapping(value = "/{id}", params = "form", produces = "text/html")
public String modify(@PathVariable("id") Long id, Model uiModel) {
    if (id == null) {
        return "receiptconfig/create";
    }
    ReceiptConfig receiptconfig = sqlSession.selectOne("com.itrus.portal.db.ReceiptConfigMapper.selectByPrimaryKey", id);
    uiModel.addAttribute("receiptconfig", receiptconfig);
    return "receiptconfig/create";
}
Also used : ReceiptConfig(com.itrus.portal.db.ReceiptConfig)

Example 4 with ReceiptConfig

use of com.itrus.portal.db.ReceiptConfig 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 5 with ReceiptConfig

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

the class ReceiptConfigController method update.

// 修改/新建处理
@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String update(ReceiptConfig receiptconfig, Model uiModel) {
    try {
        if (receiptconfig.getId() == null) {
            if (receiptconfig == null) {
                throw new ServiceNullException("要添加第三方开票配置为空");
            }
            receiptconfig.setCreateTime(new Date());
            sqlSession.insert("com.itrus.portal.db.ReceiptConfigMapper.insert", receiptconfig);
        } else {
            if (receiptconfig == null || receiptconfig.getId() == null)
                throw new ServiceNullException("要更新第三方开票配置为空");
            ReceiptConfig receiptconfig1 = sqlSession.selectOne("com.itrus.portal.db.ReceiptConfigMapper.selectByPrimaryKey", receiptconfig.getId());
            if (receiptconfig1 == null)
                throw new ServiceNullException("要更新第三方开票配置不存在");
            sqlSession.update("com.itrus.portal.db.ReceiptConfigMapper.updateByPrimaryKeySelective", receiptconfig);
        }
    } catch (Exception e) {
        uiModel.addAttribute("errMsg", e.getMessage());
    }
    String oper = "添加第三方开票配置";
    String info = "第三方开票配置名称: " + receiptconfig.getPlatformName();
    LogUtil.adminlog(sqlSession, oper, info);
    return "redirect:/receiptconfig";
}
Also used : ServiceNullException(com.itrus.portal.exception.ServiceNullException) Date(java.util.Date) ServiceNullException(com.itrus.portal.exception.ServiceNullException) ReceiptConfig(com.itrus.portal.db.ReceiptConfig)

Aggregations

ReceiptConfig (com.itrus.portal.db.ReceiptConfig)6 ServiceNullException (com.itrus.portal.exception.ServiceNullException)2 Date (java.util.Date)2 ApplicationInfo (com.itrus.portal.db.ApplicationInfo)1 ApplicationInfoExample (com.itrus.portal.db.ApplicationInfoExample)1 Bill (com.itrus.portal.db.Bill)1 Einvoice (com.itrus.portal.db.Einvoice)1 Ereceipt (com.itrus.portal.db.Ereceipt)1 ReceiptConfigExample (com.itrus.portal.db.ReceiptConfigExample)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 HostnameVerifier (javax.net.ssl.HostnameVerifier)1 SSLSession (javax.net.ssl.SSLSession)1 Call (org.apache.axis.client.Call)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 BASE64Decoder (sun.misc.BASE64Decoder)1