生成二维码及根据订单号查询工具类
package exam.common; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSONObject; import exam.entity.JianHangQrCodeResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.xml.bind.JAXBContext; import javax.xml.bind.Unmarshaller; import java.io.StringReader; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.HashMap; import java.util.Map; import static java.nio.charset.StandardCharsets.UTF_8; public class JianHangQrCodeUtils { static Logger logger = LoggerFactory.getLogger(JianHangQrCodeUtils.class); /** * 商户代码 换成建行给的 */ private static final String MERCHANT_ID=""; /** * 商户柜台代码 换成建行给的 */ private static final String POS_ID=""; /** * 分行代码 换成建行给的 */ private static final String BRANCH_ID=""; /** * 公钥 后30位 换成建行给的 */ private static final String PUB_KEY= ""; /** * 币种 01 */ private static final String CUR_CODE="01"; /** * 交易码 */ private static final String TX_CODE = "530550"; /** * 备注1 */ private static final String REMARK_1 = ""; /** * 备注2 */ private static final String REMARK_2 = ""; /** * 返回类型 * 0或空:返回二维码页面,只支持建行龙支付; * 1:返回JSON格式【二维码信息串】,只支持建行龙支付; * 2:返回聚合扫码二维码页面; * 3:返回聚合扫码JSON格式【二维码信息串】 * 聚合扫码只能上送2或3 * 4:返回聚合银联二维码信息串 */ private static final String RETURN_TYPE="3"; /** * 超时时间 * 若送空值则不判断超时 */ private static final String TIME_OUT =""; private static final String BANK_URL="https://ibsbjstar.ccb.com.cn/CCBIS/ccbMain"; /** * 订单时间 元素必须有,但值可为空 */ private static final String ORDER_DATE=""; /** * 起始时间 元素必须有,但值可为空 */ private static final String BEG_ORDER_TIME=""; /** * 订单截止时间 元素必须有,但值可为空 */ private static final String END_ORDER_TIME=""; /** * 查询密码 必输项,主管或操作员的登录密码 换成建行给的 */ private static final String QU_PWD=""; /** * 流水类型 TYPE 必输项 0支付流水 1退款流水 */ private static final String TYPE="0"; /** * 交易码 */ private static final String SEARCH_TX_CODE="410408"; /** * 流水状态 必须项 0未结算流水 1已结算流水 */ private static final String KIND="0"; /** * 交易状态 必须项 0失败 1成功 2不确定 3全部 已结算流水查询不支持全部 */ private static final String STATUS="1"; /** * 查询方式 SEL_TYPE 必输项 1页面形式 2文件返回形式 3xml页面形式 */ private static final String SEL_TYPE="3"; /** * 页码page */ private static final String PAGE = "1"; /** * 操作员 换成建行给的 */ private static final String OPERATOR=""; private static final String BEG_ORDER_ID=""; private static final String END_ORDER_ID=""; //预留字段 private static final String CHANNEL = ""; private static final String BANK_SEARCH_URL="https://ibsbjstar.ccb.com.cn/app/ccbMain"; /** * 生成二维码 * @param ORDERID 订单号 * @param PAYMENT 金额 */ public static String createQrCode(String ORDERID, String PAYMENT) { logger.info("==================================生成二维码==================================="); String decode=""; //验签字段 StringBuffer tmp = new StringBuffer(); tmp.append("MERCHANTID="); tmp.append(MERCHANT_ID); tmp.append("&POSID="); tmp.append(POS_ID); tmp.append("&BRANCHID="); tmp.append(BRANCH_ID); tmp.append("&ORDERID="); tmp.append(ORDERID); tmp.append("&PAYMENT="); tmp.append(PAYMENT); tmp.append("&CURCODE="); tmp.append(CUR_CODE); tmp.append("&TXCODE="); tmp.append(TX_CODE); tmp.append("&REMARK1="); tmp.append(REMARK_1); tmp.append("&REMARK2="); tmp.append(REMARK_2); tmp.append("&RETURNTYPE="); tmp.append(RETURN_TYPE); tmp.append("&TIMEOUT="); tmp.append(TIME_OUT); tmp.append("&PUB="); tmp.append(PUB_KEY); Map<String, Object> map = new HashMap(); map.put("CCB_IBSVersion","V6"); map.put("MERCHANTID",MERCHANT_ID); map.put("BRANCHID",BRANCH_ID); map.put("POSID",POS_ID); map.put("ORDERID",ORDERID); map.put("PAYMENT",PAYMENT); map.put("CURCODE",CUR_CODE); map.put("TXCODE",TX_CODE); map.put("REMARK1",REMARK_1); map.put("REMARK2",REMARK_2); map.put("RETURNTYPE",RETURN_TYPE); map.put("TIMEOUT",TIME_OUT); map.put("MAC", MD5.md5Str(tmp.toString())); //请求二维码生成链接串 try { logger.info("入参:"+map); String postResponse = HttpUtil.post(BANK_URL, map); JianHangQrCodeResponse jianHangQrCodeResponse= JSONObject.parseObject(postResponse, JianHangQrCodeResponse.class); if(jianHangQrCodeResponse.getSUCCESS()!=null&&jianHangQrCodeResponse.getSUCCESS().equals("true") ) { String payUrl = jianHangQrCodeResponse.getPAYURL(); String getResponse = HttpUtil.get(payUrl, UTF_8); String qrurl = JSONObject.parseObject(getResponse).getString("QRURL"); decode = URLDecoder.decode(qrurl, "utf-8"); } }catch (Exception e){ e.printStackTrace(); decode= e.getMessage(); } logger.info("二维码信息:"+decode); return decode; } /** * 查询支付是否成功 * @param ORDERID 订单号码 */ public static Document searchPayStatus(String ORDERID) throws UnsupportedEncodingException { logger.info("===========================================查询商户是否支付成功===================="); Document document=null; //验签字段 String tmp ="MERCHANTID="+MERCHANT_ID+"&BRANCHID="+BRANCH_ID+"&POSID="+POS_ID+"&ORDERDATE="+ORDER_DATE+"&BEGORDERTIME="+BEG_ORDER_TIME +"&ENDORDERTIME="+END_ORDER_TIME+"&BEGORDERID="+BEG_ORDER_ID+"&ENDORDERID="+END_ORDER_ID+"&QUPWD=&TXCODE="+SEARCH_TX_CODE +"&SEL_TYPE="+SEL_TYPE+"&OPERATOR="+OPERATOR; if("410408".equals(SEARCH_TX_CODE)){ tmp ="MERCHANTID="+MERCHANT_ID+"&BRANCHID="+BRANCH_ID+"&POSID="+POS_ID+"&ORDERDATE=" +ORDER_DATE+"&BEGORDERTIME="+BEG_ORDER_TIME+"&ENDORDERTIME="+END_ORDER_TIME+"&ORDERID=" +ORDERID+"&QUPWD=&TXCODE="+SEARCH_TX_CODE+"&TYPE="+TYPE+"&KIND="+KIND+"&STATUS="+STATUS+ "&SEL_TYPE="+SEL_TYPE+"&PAGE="+PAGE+"&OPERATOR="+OPERATOR+"&CHANNEL="+CHANNEL; } Map<String, Object> map = new HashMap(); map.put("MERCHANTID",MERCHANT_ID); map.put("BRANCHID",BRANCH_ID); map.put("POSID",POS_ID); map.put("ORDERDATE",ORDER_DATE); map.put("BEGORDERTIME",BEG_ORDER_TIME); map.put("ENDORDERTIME",END_ORDER_TIME); map.put("QUPWD",QU_PWD); map.put("TXCODE",SEARCH_TX_CODE); map.put("TYPE",TYPE); map.put("KIND",KIND); map.put("STATUS",STATUS); map.put("ORDERID",ORDERID); map.put("PAGE",PAGE); map.put("CHANNEL",CHANNEL); map.put("SEL_TYPE",SEL_TYPE); map.put("OPERATOR",OPERATOR); map.put("MAC",MD5.md5Str(tmp.toString())); logger.info("入参"+MD5.md5Str(tmp.toString())); String ret = HttpUtil.post(BANK_SEARCH_URL, map); ret = ret.replaceAll("\\n", ""). replaceAll("\\t", ""). replaceAll("\\r", ""); logger.info(ret); if(ret !=null && !ret.equals("")){ JAXBContext jaxbContext=null; Unmarshaller unmarshaller=null; try { logger.info("ret::"+ret); jaxbContext = JAXBContext.newInstance(Document.class); unmarshaller = jaxbContext.createUnmarshaller(); document= (Document)unmarshaller.unmarshal(new StringReader(ret)); logger.info("document==={}"+document); }catch (Exception e){ e.printStackTrace(); } } return document; } public static void main(String[] args) throws UnsupportedEncodingException { //createQrCode("53032219051","0.1"); searchPayStatus("10024_1679912790819"); } }
查询返回的实体类
package exam.common; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; import java.util.ArrayList; import java.util.List; @XmlRootElement(name = "DOCUMENT") public class Document { /** * 返回码 交易返回码,成功时总为 000000 */ @XmlElement(name = "RETURN_CODE") private String RETURN_CODE; /** * 响应信息 */ @XmlElement(name = "RETURN_MSG") private String RETURN_MSG; /** * 当前页 */ @XmlElement(name = "CURPAGE") private String CURPAGE; /** * 总页数 */ @XmlElement(name = "PAGECOUNT") private String PAGECOUNT; /** * 总笔数 */ @XmlElement(name = "TOTAL") private String TOTAL; /** * 支付总金额 */ @XmlElement(name = "PAYAMOUNT") private String PAYAMOUNT; /** * 退款总金额 */ @XmlElement(name = "REFUNDAMOUNT") private String REFUNDAMOUNT; @XmlElement(name = "QUERYORDER") private List<QueryOrder> queryOrders=new ArrayList<>(); @XmlTransient public String getRETURN_CODE() { return RETURN_CODE; } public void setRETURN_CODE(String RETURN_CODE) { this.RETURN_CODE = RETURN_CODE; } @XmlTransient public String getRETURN_MSG() { return RETURN_MSG; } public void setRETURN_MSG(String RETURN_MSG) { this.RETURN_MSG = RETURN_MSG; } @XmlTransient public String getCURPAGE() { return CURPAGE; } public void setCURPAGE(String CURPAGE) { this.CURPAGE = CURPAGE; } @XmlTransient public String getPAGECOUNT() { return PAGECOUNT; } public void setPAGECOUNT(String PAGECOUNT) { this.PAGECOUNT = PAGECOUNT; } @XmlTransient public String getTOTAL() { return TOTAL; } public void setTOTAL(String TOTAL) { this.TOTAL = TOTAL; } @XmlTransient public String getPAYAMOUNT() { return PAYAMOUNT; } public void setPAYAMOUNT(String PAYAMOUNT) { this.PAYAMOUNT = PAYAMOUNT; } @XmlTransient public String getREFUNDAMOUNT() { return REFUNDAMOUNT; } public void setREFUNDAMOUNT(String REFUNDAMOUNT) { this.REFUNDAMOUNT = REFUNDAMOUNT; } @XmlTransient public List<QueryOrder> getQueryOrders() { return queryOrders; } public void setQueryOrders(List<QueryOrder> queryOrders) { this.queryOrders = queryOrders; } @Override public String toString() { return "Document{" + "RETURN_CODE='" + RETURN_CODE + '\'' + ", RETURN_MSG='" + RETURN_MSG + '\'' + ", CURPAGE='" + CURPAGE + '\'' + ", PAGECOUNT='" + PAGECOUNT + '\'' + ", TOTAL='" + TOTAL + '\'' + ", PAYAMOUNT='" + PAYAMOUNT + '\'' + ", REFUNDAMOUNT='" + REFUNDAMOUNT + '\'' + ", queryOrders=" + queryOrders + '}'; } /** * 子类 详细信息 */ public static class QueryOrder{ /** * 商户代码 */ @XmlElement(name = "MERCHANTID") private String MERCHANTID; /** * 分行代码 */ @XmlElement(name = "BRANCHID") private String BRANCHID; /** * 柜台号码 */ @XmlElement(name = "POSID") private String POSID; /** * 订单号 */ @XmlElement(name = "ORDERID") private String ORDERID; /** * 支付/退款交易时间 */ @XmlElement(name = "ORDERDATE") private String ORDERDATE; /** * 记录日期 */ @XmlElement(name = "ACCDATE") private String ACCDATE; /** * 支付金额 */ @XmlElement(name = "AMOUNT") private String AMOUNT; /** * 状态码 */ @XmlElement(name = "STATUSCODE") private String STATUSCODE; /** * 支付状态 */ @XmlElement(name = "STATUS") private String STATUS; /** * 签名串 */ @XmlElement(name = "SIGN") private String SIGN; @XmlTransient public String getMERCHANTID() { return MERCHANTID; } public void setMERCHANTID(String MERCHANTID) { this.MERCHANTID = MERCHANTID; } @XmlTransient public String getBRANCHID() { return BRANCHID; } public void setBRANCHID(String BRANCHID) { this.BRANCHID = BRANCHID; } @XmlTransient public String getPOSID() { return POSID; } public void setPOSID(String POSID) { this.POSID = POSID; } @XmlTransient public String getORDERID() { return ORDERID; } public void setORDERID(String ORDERID) { this.ORDERID = ORDERID; } @XmlTransient public String getORDERDATE() { return ORDERDATE; } public void setORDERDATE(String ORDERDATE) { this.ORDERDATE = ORDERDATE; } @XmlTransient public String getACCDATE() { return ACCDATE; } public void setACCDATE(String ACCDATE) { this.ACCDATE = ACCDATE; } @XmlTransient public String getAMOUNT() { return AMOUNT; } public void setAMOUNT(String AMOUNT) { this.AMOUNT = AMOUNT; } @XmlTransient public String getSTATUSCODE() { return STATUSCODE; } public void setSTATUSCODE(String STATUSCODE) { this.STATUSCODE = STATUSCODE; } @XmlTransient public String getSTATUS() { return STATUS; } public void setSTATUS(String STATUS) { this.STATUS = STATUS; } @XmlTransient public String getSIGN() { return SIGN; } public void setSIGN(String SIGN) { this.SIGN = SIGN; } @Override public String toString() { return "QueryOrder{" + "MERCHANTID='" + MERCHANTID + '\'' + ", BRANCHID='" + BRANCHID + '\'' + ", POSID='" + POSID + '\'' + ", ORDERID='" + ORDERID + '\'' + ", ORDERDATE='" + ORDERDATE + '\'' + ", ACCDATE='" + ACCDATE + '\'' + ", AMOUNT='" + AMOUNT + '\'' + ", STATUSCODE='" + STATUSCODE + '\'' + ", STATUS='" + STATUS + '\'' + ", SIGN='" + SIGN + '\'' + '}'; } } }
生成二维码业务层
@Override @Transactional public ServiceResult saveOrder(ExamineePayOrder examineePayOrder) { ServiceResult serviceResult=new ServiceResult(); try { //1、把未支付的订单删除 String hql=" from ExamineePayOrder where examineeNo=:examineeNo and createTime<:createTime order by createTime desc"; Map<String, Object> queryParams = new HashMap<String, Object>(); queryParams.put("examineeNo", examineePayOrder.getExamineeNo()); queryParams.put("createTime", examineePayOrder.getCreateTime()); List<ExamineePayOrder> list = examineePayOrderDao.findByHql(hql, queryParams); if (CollUtil.isNotEmpty(list)){ for (ExamineePayOrder payOrder : list) { payOrder.setIsDeleted(1); examineePayOrderDao.saveorupdate(payOrder); } }
//2、保存订单并生成支付二维码 examineePayOrderDao.save(examineePayOrder); PayConfig payConfig = payConfigDao.getPayConfig(); BigDecimal payAmount = payConfig.getPayAmount(); String qrCode = JianHangQrCodeUtils.createQrCode(examineePayOrder.getOrderId(), String.valueOf(payAmount)); serviceResult.setCode("0000"); serviceResult.setMessage("订单保存成功"); Map<String,Object> map=new HashMap(); map.put("orderId",examineePayOrder.getOrderId());//订单id map.put("payAmount",String.valueOf(payAmount));//支付金额 map.put("payStatus",examineePayOrder.getPayStatus());//支付状态 map.put("qrCode",qrCode);//二维码链接 serviceResult.setObject(map); return serviceResult; }catch (Exception e){ e.printStackTrace(); serviceResult.setCode("9999"); serviceResult.setMessage("订单保存失败"+e.getMessage()); serviceResult.setObject(null); return serviceResult; } }
根据订单查询是否支付成功 查询时需要建行维护IP地址
@Transactional @Override public ServiceResult getOrderPayStatus(ExamineeInfo examineeInfo,String orderId) throws UnsupportedEncodingException { ServiceResult serviceResult=new ServiceResult(); String hql=" from ExamineePayOrder where examineeNo=:examineeNo and orderId=:orderId and isDeleted=:isDeleted order by createTime desc"; Map<String, Object> queryParams = new HashMap<String, Object>(); queryParams.put("examineeNo", examineeInfo.getExamineeNo()); queryParams.put("orderId", orderId);//有效订单 queryParams.put("isDeleted", 0);//有效订单 List<ExamineePayOrder> list = examineePayOrderDao.findByHql(hql, queryParams);//只能查出一条记录 Document document = JianHangQrCodeUtils.searchPayStatus(orderId);//只能查出一条记录 if ("000000".equals(document.getRETURN_CODE())){ List<Document.QueryOrder> queryOrders = document.getQueryOrders(); for (Document.QueryOrder queryOrder : queryOrders) { if ("成功".equals(queryOrder.getSTATUS())&&"1".equals(queryOrder.getSTATUSCODE())){//支付成功 //更新订单表 if (CollUtil.isNotEmpty(list)){ for (ExamineePayOrder examineePayOrder : list) { examineePayOrder.setPayStatus(1);//已支付 examineePayOrder.setUpdateTime(DateUtil.parse(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"))); examineePayOrder.setAccDate(queryOrder.getACCDATE()); examineePayOrder.setSign(queryOrder.getSIGN()); examineePayOrderService.updateExamineePayOrderService(examineePayOrder); } } //更新ExamineeStatus支付状态 ExamineeStatus examineeStatus=examineeStatusDao.getExamineeStatusById(examineeInfo.getExamineeId()); if (ObjectUtil.isNotEmpty(examineeStatus)){ examineeStatus.setPayStatus(1); examineeStatus.setPayTime(DateUtil.parse(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"))); examineeStatus.setPayDesc("支付成功"); examineeStatus.setExamineeVerifyDesc("已交费成功!"); examineeStatusService.updateExamineeStatus(examineeStatus); } } } serviceResult.setObject(true);//已支付 }else { serviceResult.setObject(false);//还未支付 } return serviceResult; }
前端展示二维码使用qrcode.js 自行下载
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> <!DOCTYPE html> <html> <body> <body class="layui-layout-body"> <div class="layui-layout layui-layout-admin"> <!-- 引入头部文件 --> <jsp:include page="../homeHeader.jsp" flush="true" /> <!-- 引入左侧导航 --> <jsp:include page="leftNav.jsp" flush="true" /> <div class="layui-body" style="right: 0px; bottom: 0px; background-color: #FFFFFF"> <div style="padding: 10px 20px;height:300px;"> <div id="paymentEd" class="layui-hide" style="border:2px solid;height:150px;background:#FFE1FF; margin:0px 60px;font-size:18px;text-align: center;"> <table class="paymentInfoTable" style="margin-left:50px;margin-bottom:40px;"> <tr> <th>订单编号:</th> <td id="orderId2"></td> </tr> <tr> <th >订单金额:</th> <td id="payAmount2"></td> </tr> <tr> <th>订单支付状态:</th> <td id="payStatus2"></td> </tr> </table> </div> <div style="text-align: center" id="payBtn"> <div id="paymentTable" class="layui-hide" > 未缴费,请点击缴费按钮,使用微信或支付宝扫码二维码缴费 <div style="padding: 10px 20px;height:300px;"> <button id="QRBtn" type="button" data-type="auto" class="btn btn-primary layui-btn " >缴费按钮</button> </div> </div> </div> </div> <div> <div id="model" style="display: none;"> <div style="margin-top: 20px;text-align: center;" > <table class="paymentInfoTable" style="margin-left:50px;margin-bottom:40px;"> <tr> <th>订单编号:</th> <td id="orderId"></td> </tr> <tr> <th>订单金额:</th> <td id="payAmount"></td> </tr> <tr> <th>订单支付状态:</th> <td id="status"></td> </tr> </table> <div style="text-align: center;display: inline-table" id="qrcode"></div> </div> </div> </div> <!-- 引入底部文件 --> <jsp:include page="../homeFooter.jsp" flush="true" /> </div> </div> </body> <script type="text/javascript" src="<%=basePath%>resources/layui/layui.js"></script> <script src="<%=basePath%>resources/js/common/qrcode.js"></script> <script> var $; var form; var layer; var timeInterval='' layui.use(["form", "jquery","layer"], function() { //独立版的layer无需执行这一句 $ = layui.jquery, form = layui.form, layer = layui.layer; $(function(){ //查询缴费状态 getPayStatus() }); $("#QRBtn").click(function(){ layer.open({ type: 1, title:"支付二维码", id: 'layerDemo', //防止重复弹出 content: $('#model'), area: ['700px', '500px'],//定义宽和高 btnAlign: 'c', //按钮居中 shade: 0, //不显示遮罩 success:function (layero, index){ //弹出层加载成功后执行 getQRCode() }, cancel: function(){ layer.closeAll(); clearQRCode() clearInterval(timeInterval) } }); }); }); function getQRCode() { $.ajax({ url : "getQRCodeByOrderId", type : "POST", dataType : "json", success : function(jsonResult) { if (jsonResult.code === "0000") { var retObject=jsonResult['object']; $("#payStatus").text('未支付'); $("#orderId").text(retObject.orderId); $("#payAmount").text(retObject.payAmount); let text=retObject.qrCode var qrcodetwo = new QRCode("qrcode", { render : "table", width: 128, height: 128, text: text //返回的路径 });
//轮询查询是否支付成功 timeInterval=window.setInterval("getOrderPayStatus('"+retObject.orderId+"')",1500) }else{ alert(jsonResult.message); } } }); } //清除生成的二维码防止二维码重叠 function clearQRCode() { const codeHtml = document.getElementById("qrcode"); codeHtml.innerHTML = ""; } function getPayStatus() { $.ajax({ // 几个参数需要注意一下 url : "getPayStatus", type : "POST",// 方法类型 dataType : "json",// 预期服务器返回的数据类型 success : function(jsonResult) { var noPaymentDiv=$('#noPayment'); var paymentEdDiv=$('#paymentEd'); var paymentTable=$('#paymentTable'); var payBtn=$('#payBtn'); if (jsonResult.code == "000") { var retObject=jsonResult['object']; //如果有支付信息 if (retObject!=null){ if (!noPaymentDiv.hasClass("layui-hide")){ noPaymentDiv.addClass("layui-hide"); } if (paymentTable.hasClass("layui-hide")){ paymentTable.removeClass("layui-hide"); } var payStatus=retObject['payStatus']; if (payStatus=='0'){//未支付才显示支付按钮 if (payBtn.hasClass("layui-hide")){ payBtn.removeClass("layui-hide"); } } if (payStatus=='1'){//已支付显示支付结果 if (!payBtn.hasClass("layui-hide")){ payBtn.addClass("layui-hide"); } $("#orderId2").text(retObject.orderId); $("#payAmount2").text(retObject.payAmount); $("#payStatus2").text('支付成功'); if (paymentEdDiv.hasClass("layui-hide")){ paymentEdDiv.removeClass("layui-hide"); } } }else{ if (noPaymentDiv.hasClass("layui-hide")){ noPaymentDiv.removeClass("layui-hide"); } if (!paymentTable.hasClass("layui-hide")){ paymentTable.addClass("layui-hide"); } $("#payDesc").text("尚未产生支付信息,请在报考审核后查看!"); } }else{ if (noPaymentDiv.hasClass("layui-hide")){ noPaymentDiv.removeClass("layui-hide"); } if (!paymentTable.hasClass("layui-hide")){ paymentTable.addClass("layui-hide"); } $("#payDesc").text(jsonResult.message); } }, error : function() { alert("异常!"); } }); } function getOrderPayStatus(orderID){ $.ajax({ // 几个参数需要注意一下 url : "getOrderPayStatus", type:"GET",// 方法类型 dataType : "json",// 预期服务器返回的数据类型 data : {"orderId":orderID}, success : function(jsonResult) { if (jsonResult.code === "0000") { layer.open({ type: 1 ,title:'提示' ,id: 'postSuccess' //防止重复弹出 ,content: '<div style="padding: 20px 100px;">'+ jsonResult.message +'</div>' ,btn: '确定' ,btnAlign: 'c' //按钮居中 ,shade: 0.5 //不显示遮罩 ,yes: function(index,layero){ layer.close(index); window.location.href='payment'; } }); } } }); } </script> </html>