Commit ed82c63f by dliangx

jump url

parent 3ed44ea4
......@@ -13,7 +13,7 @@ import (
func QueryJumpUrl(ctx context.Context, c *app.RequestContext) {
var err error
var req model.HttpBodyReq[model.PayResultReq]
var req model.PayResultReq
var resp model.HttpBodyResp[string]
err = c.BindAndValidate(&req)
if err != nil {
......@@ -23,16 +23,15 @@ func QueryJumpUrl(ctx context.Context, c *app.RequestContext) {
return
}
println(req.Request.DuebillNoOrg)
println(req.DuebillNoOrg)
rows, err := db.DB.Query("select disburse_sign_url from loan_orderinfo where serial_no = ? ", &req.Request.DuebillNoOrg)
rows, err := db.DB.Query("select disburse_sign_url from loan_orderinfo where serial_no = ? ", &req.DuebillNoOrg)
if err != nil {
log.Println(err)
resp.Head.Code = nltconst.SYS_ERROR
resp.Head.ServiceTime = nltconst.GetNowTime()
resp.Head.ServiceSn = req.Head.ServiceSn
c.JSON(consts.StatusOK, resp)
return
}
......@@ -49,14 +48,12 @@ func QueryJumpUrl(ctx context.Context, c *app.RequestContext) {
log.Println(err)
resp.Head.Code = nltconst.NODATA
resp.Head.ServiceTime = nltconst.GetNowTime()
resp.Head.ServiceSn = req.Head.ServiceSn
c.JSON(consts.StatusOK, resp)
return
}
resp.Head.Code = string(nltconst.SUCCESS)
resp.Head.ServiceTime = nltconst.GetNowTime()
resp.Head.ServiceSn = req.Head.ServiceSn
resp.Response = url
c.JSON(consts.StatusOK, resp)
}
......@@ -60,35 +60,7 @@
document.getElementById("confirmButton").onclick = function () {
var url =
"https://tknltdev.agrolinking.cn/api/nlt/pufa/queryJumpUrl";
function generateSerialNumberAndTime() {
// 获取当前时间
const now = new Date();
// 格式化时间为 yyyyMMddHHmmss
const formattedTime =
now.getFullYear() +
padZero(now.getMonth() + 1) + // 月份是从0开始的
padZero(now.getDate()) +
padZero(now.getHours()) +
padZero(now.getMinutes()) +
padZero(now.getSeconds());
// 生成流水号(例如,这里使用当前时间的毫秒作为流水号的一部分)
const randomNum = Math.floor(Math.random() * 900) + 100;
const serialNumber = formattedTime + randomNum;
return {
serialNumber: serialNumber,
formattedTime: formattedTime,
};
}
// 辅助函数,用于在数字前面补零
function padZero(num) {
return num < 10 ? "0" + num : num;
}
const { serialNumber, formattedTime } =
generateSerialNumberAndTime();
const jumpUrl = new URL(window.location.href);
// 创建URLSearchParams对象
......@@ -101,11 +73,6 @@
});
const idParam = searchParams.get("param");
var data = {
head: {
code: "tk",
requestTime: serialNumber,
serviceSn: formattedTime,
},
request: {
duebillNoOrg: idParam,
},
......@@ -119,7 +86,9 @@
})
.then((res) => {
if (res.head.code == "000000") {
window.location.href = res.reponse;
window.location.href = res.body;
}else{
window.history.back()
}
})
.catch((error) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment