From 35d8f3eb8e8a64f5bf58f767ce9fd543c4d47e31 Mon Sep 17 00:00:00 2001 From: Xia Kaixiang Date: Thu, 11 Jul 2019 11:01:39 +0800 Subject: [PATCH] =?utf8?q?=E9=80=80=E6=AC=BE=E6=9F=A5=E8=AF=A2=E5=AF=B9?= =?utf8?q?=E8=B4=A6=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../com/supwisdom/dlpay/api/ThirdPayCall.kt | 172 +++++++++++++++++- 1 file changed, 171 insertions(+), 1 deletion(-) diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/ThirdPayCall.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/ThirdPayCall.kt index 430499cd..dd978bb1 100644 --- a/payapi/src/main/kotlin/com/supwisdom/dlpay/api/ThirdPayCall.kt +++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/api/ThirdPayCall.kt @@ -374,7 +374,7 @@ class CallService { /** * 大理农商行银行卡代扣消费 * */ - fun callCitizenCardPay(config: Map, transdate: String, transtime: String, refno: String, amount:Double, bankcardno: String, name: String, idtype: String, idno: String, phone: String): CallBackResp { + fun callCitizenCardPay(config: Map, transdate: String, transtime: String, refno: String, amount:Double, bankcardno: String, name: String, idtype: String, idno: String): CallBackResp { val resp = CallBackResp() val ip = config["socket.ip"] val port = config["socket.port"] @@ -445,6 +445,176 @@ class CallService { } } + /** + * 大理农商行银行卡消费退款 + * */ + fun CallCitizenCardPayRefund(config: Map, transdate: String, transtime: String, refno: String, originRefno:String, amount:Double): CallBackResp { + val resp = CallBackResp() + val ip = config["socket.ip"] + val port = config["socket.port"] + if (ip.isNullOrEmpty() || port.isNullOrEmpty()) { + resp.retcode = "99" + resp.retmsg = "市民卡socket的IP和端口未配置" + return resp + } + + val req = DlpayReq().apply { + this.transdate = transdate + this.transtime = transtime + this.sn = refno + this.oriSn = originRefno + this.amount = MoneyUtil.YuanToFen(amount) + this.description="市民卡代扣消费退款" + } + logger.info("请求消费退款发送报文:\n${req.payRefundXml}") + try { + val returnXml = DlpayUtil.send(ip, port.toInt(), 10, req.payRefundXml) + logger.info("请求消费退款返回报文[$refno]:\n$returnXml") + if (returnXml.isNullOrEmpty()) { + resp.retcode = "99" + resp.retmsg = "请求消费退款返回报文为空" + return resp + } + val returnResp = XmlUtils.getXmlToObject(returnXml.substring(8), "GBK", DlpayResp::class.java) + if (null == returnResp) { + resp.retcode = "99" + resp.retmsg = "解析返回报文错误!" + return resp + } + + if ("0000" == returnResp.code) { + resp.retcode = "0" + resp.retmsg = "success" + resp.add("outtradeno", returnResp.bankjourno) //银行流水号 + } else { + resp.retcode = "99" + resp.retmsg = returnResp.message + } + return resp + } catch (e: Exception) { + e.printStackTrace() + //fixme: 查询逻辑? + resp.retcode = "99" + resp.retmsg = "请求消费退款异常!e:${e.message}" + return resp + } + } + + /** + * 大理农商行银行卡消费退款结果查询 + * */ + fun CallCitizenCardPayQueryResult(config: Map, transdate: String, transtime: String, refno: String, originRefno:String): CallBackResp{ + val resp = CallBackResp() + val ip = config["socket.ip"] + val port = config["socket.port"] + if (ip.isNullOrEmpty() || port.isNullOrEmpty()) { + resp.retcode = "99" + resp.retmsg = "市民卡socket的IP和端口未配置" + return resp + } + + val req = DlpayReq().apply { + this.transdate = transdate + this.transtime = transtime + this.sn = refno + this.oriSn = originRefno + } + logger.info("请求查询结果发送报文:\n${req.queryResultXml}") + try { + val returnXml = DlpayUtil.send(ip, port.toInt(), 10, req.queryResultXml) + logger.info("请求查询结果返回报文[$refno]:\n$returnXml") + if (returnXml.isNullOrEmpty()) { + resp.retcode = "99" + resp.retmsg = "请求查询结果返回报文为空" + return resp + } + val returnResp = XmlUtils.getXmlToObject(returnXml.substring(8), "GBK", DlpayResp::class.java) + if (null == returnResp) { + resp.retcode = "99" + resp.retmsg = "解析返回报文错误!" + return resp + } + + if("0401" == returnResp.code){ + //原流水不存在 + resp.retcode = "0" + resp.retmsg = "success" + resp.add("dtlstatus", "notfind") + }else if ("0000" == returnResp.code) { + resp.retcode = "0" + resp.retmsg = "success" + resp.add("outtradeno", returnResp.bankjourno) //银行流水号 + when(returnResp.status){ + "0" -> resp.add("dtlstatus", "success") + "2" -> resp.add("dtlstatus", "refund") + else -> resp.add("dtlstatus", "fail") + } + } else { + //查询失败 + resp.retcode = "99" + resp.retmsg = returnResp.message + } + return resp + } catch (e: Exception) { + e.printStackTrace() + resp.retcode = "99" + resp.retmsg = "请求查询结果异常!e:${e.message}" + return resp + } + } + + fun CallCitizenCardChkfile(config: Map, transdate: String, transtime: String, refno: String, chkdate:String): CallBackResp { + val resp = CallBackResp() + val ip = config["socket.ip"] + val port = config["socket.port"] + if (ip.isNullOrEmpty() || port.isNullOrEmpty()) { + resp.retcode = "99" + resp.retmsg = "市民卡socket的IP和端口未配置" + return resp + } + + val req = DlpayReq().apply { + this.transdate = transdate + this.transtime = transtime + this.sn = refno + this.chkdate = chkdate + } + logger.info("请求[$chkdate]对账发送报文:\n${req.chkfileXml}") + try { + val returnXml = DlpayUtil.send(ip, port.toInt(), 10, req.chkfileXml) + logger.info("请求[$chkdate]对账返回报文[$refno]:\n$returnXml") + if (returnXml.isNullOrEmpty()) { + resp.retcode = "99" + resp.retmsg = "请求[$chkdate]对账返回报文为空" + return resp + } + val returnResp = XmlUtils.getXmlToObject(returnXml.substring(8), "GBK", DlpayResp::class.java) + if (null == returnResp) { + resp.retcode = "99" + resp.retmsg = "解析返回报文错误!" + return resp + } + + if ("0000" == returnResp.code) { + resp.retcode = "0" + resp.retmsg = "success" + resp.add("outtradeno", returnResp.bankjourno) //银行流水号 + resp.add("filename", returnResp.filename) + + } else { + //查询失败 + resp.retcode = "99" + resp.retmsg = returnResp.message + } + return resp + } catch (e: Exception) { + e.printStackTrace() + resp.retcode = "99" + resp.retmsg = "请求[$chkdate]对账异常!e:${e.message}" + return resp + } + } + fun CallCitizenCardPay(config: Map, paydtl: TShopdtl): CallBackResp { val resp = CallBackResp() resp.retcode = "0" -- 2.17.1