order.html
<script type="text/javascript"> function openLink(outTradeNo){ alipayForm.target = "newWindow"; var win = window.open("replayOrder?outTradeNo=" + outTradeNo, "newWindow"); win.focus(); window.location.href="initGoods"; } </script>
<form name="alipayForm" th:object="${alipayForm}" action="replayOrder" method="get"> <table class="table table-bordered table-order" th:each="order,status:${orderList}"> <thead> <tr > <th colspan = "5"> <div class="cf f12 orderT"> <p class="fl">交易时间:<span class="time" th:text="${order.updateTime}"></span>订单号:<span th:text="${order.outTradeNo}"></span></p> <p class="fr"><a th:href="@{deleteOrder(outTradeNo=${order.outTradeNo})}" class="ico-del"></a></p> </div> </th> </tr> </thead> <tbody> <tr> <td class="wp50"> <h4><span th:text="${order.subject}">商品</span></h4> </td> <td class="wp10">¥<span th:text="${order.price}"></span></td> <td class="wp15"> <div th:if="${#strings.isEmpty(order.isPaid)}"> <span>未付款</span> <input type="button" th:onclick="${#strings.concat(‘openLink(‘‘‘).concat(order.outTradeNo).concat(‘‘‘)‘)}" class="button" th:value="登录支付宝重新付款" /> </div> <div th:if="${#bools.isTrue(order.isPaid)}"> <span>已付款</span> </div> </td> </tr> </tbody> </table> </form>
<ul class="pagination fr"> <li><a href="order?index=0">?第一页</a></li> <li th:each="pages,sts:${pagesList}" th:class="${alipayForm.index==sts.index}?‘active‘:‘‘"><a th:href="@{order(index=${sts.index})}" th:text="${pages}">1</a></li> <li><a th:href="@{order(index=${pagesList.size()}-1)}">最后一页?</a></li> </ul>
CartController.java
@RequestMapping(value = "replayOrder", method = RequestMethod.GET) public String replayAlipayOrder(Model model, AlipayForm alipayForm, HttpSession session, Device device) { GoodsForm goodsForm=new GoodsForm(); List<GoodsForm> commodityType = goodsService.getType(); model.addAttribute("goodsForm", goodsForm); model.addAttribute("commodityType", commodityType); log.info("重新支付"); AlipayForm result = cartService.searchAlipayHistory(alipayForm); alipayForm.setOutTradeNo(result.getOutTradeNo()); alipayForm.setBody(result.getBody()); alipayForm.setPrice(result.getPrice()); alipayForm.setReceiveAddress(result.getReceiveAddress()); alipayForm.setReceiveMobile(result.getReceiveMobile()); alipayForm.setReceiveName(result.getReceiveName()); alipayForm.setReceivePhone(result.getReceivePhone()); alipayForm.setReceiveZip(result.getReceiveZip()); alipayForm.setShowUrl(result.getShowUrl()); alipayForm.setSubject(result.getSubject()); model.addAttribute("alipayForm", alipayForm); CartForm cartForm = new CartForm(); UVO uvo = (UVO)session.getAttribute("UVO"); if (uvo == null || StringUtils.isEmpty(uvo.getGuestId())) { return "redirect:/initGuestLogin"; } cartForm.setGuestId(uvo.getGuestId()); model.addAttribute("cartList", cartService.searchCartList(cartForm)); // model.addAttribute("orderList", cartService.searchOrderList(cartForm)); if (device.isNormal()) { model.addAttribute("sHtmlText", alipayRequestWeb(alipayForm)); } else { model.addAttribute("sHtmlText", alipayRequestMobile(alipayForm)); } return "manager/charge/alipay"; } private String alipayRequestWeb(AlipayForm alipayForm) { // 支付类型 String payment_type = "1"; // 必填,不能修改 // 服务器异步通知页面路径 String host = env.getProperty("host.web"); String notify_url = host + "/initReturn"; // 需http://格式的完整路径,不能加?id=123这类自定义参数 // 页面跳转同步通知页面路径 String return_url = host + "/initPayResult"; // 需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ // 商户订单号 String out_trade_no = alipayForm.getOutTradeNo(); // 订单名称 String subject = alipayForm.getSubject(); // 付款金额 String total_fee = alipayForm.getPrice(); // 订单描述 String body = alipayForm.getBody(); // 商品展示地址 String show_url = alipayForm.getShowUrl(); // 需以http://开头的完整路径,如:http://www.商户网站.com/myorder.html //防钓鱼时间戳 String anti_phishing_key = ""; //若要使用请调用类文件submit中的query_timestamp函数 //客户端的IP地址 String exter_invoke_ip = ""; //非局域网的外网IP地址,如:221.0.0.1 // 收货人姓名 String receive_name = alipayForm.getReceiveName(); // 收货人地址 String receive_address = alipayForm.getReceiveAddress(); // 收货人邮编 String receive_zip = alipayForm.getReceiveZip(); // 收货人电话号码 String receive_phone = alipayForm.getReceivePhone(); // 收货人手机号码 String receive_mobile = alipayForm.getReceiveMobile(); body = body + ";" + receive_name + ";" + receive_address + ";" + receive_zip + ";" + receive_phone + ";" + receive_mobile; Map<String, String> sParaTemp = new HashMap<String, String>(); sParaTemp.put("service", "create_direct_pay_by_user"); sParaTemp.put("partner", AlipayConfig.partner); sParaTemp.put("seller_email", AlipayConfig.seller_email); sParaTemp.put("_input_charset", AlipayConfig.input_charset); sParaTemp.put("payment_type", payment_type); sParaTemp.put("notify_url", notify_url); sParaTemp.put("return_url", return_url); sParaTemp.put("out_trade_no", out_trade_no); sParaTemp.put("subject", subject); sParaTemp.put("total_fee", total_fee); sParaTemp.put("body", body); sParaTemp.put("show_url", show_url); sParaTemp.put("anti_phishing_key", anti_phishing_key); sParaTemp.put("exter_invoke_ip", exter_invoke_ip); String sHtmlText = AlipaySubmit.buildRequest(sParaTemp, "get", "确认"); return sHtmlText; } private String alipayRequestMobile(AlipayForm alipayForm) { // 支付类型 String payment_type = "1"; // 必填,不能修改 // 服务器异步通知页面路径 String host = env.getProperty("host.mobile"); String notify_url = host + "/initReturn"; // 需http://格式的完整路径,不能加?id=123这类自定义参数 // 页面跳转同步通知页面路径 String return_url = host + "/initPayResult"; // 需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ // 商户订单号 String out_trade_no = alipayForm.getOutTradeNo(); // 订单名称 String subject = alipayForm.getSubject(); // 付款金额 String total_fee = alipayForm.getPrice(); // 订单描述 String body = alipayForm.getBody(); // 商品展示地址 String show_url = alipayForm.getShowUrl(); // 需以http://开头的完整路径,如:http://www.商户网站.com/myorder.html //超时时间 String it_b_pay = ""; //选填 //钱包token String extern_token = ""; //选填 // 收货人姓名 String receive_name = alipayForm.getReceiveName(); // 收货人地址 String receive_address = alipayForm.getReceiveAddress(); // 收货人邮编 String receive_zip = alipayForm.getReceiveZip(); // 收货人电话号码 String receive_phone = alipayForm.getReceivePhone(); // 收货人手机号码 String receive_mobile = alipayForm.getReceiveMobile(); body = body + ";" + receive_name + ";" + receive_address + ";" + receive_zip + ";" + receive_phone + ";" + receive_mobile; Map<String, String> sParaTemp = new HashMap<String, String>(); sParaTemp.put("service", "alipay.wap.create.direct.pay.by.user"); sParaTemp.put("partner", AlipayConfig.partner); sParaTemp.put("seller_id", AlipayConfig.seller_id); sParaTemp.put("_input_charset", AlipayConfig.input_charset); sParaTemp.put("payment_type", payment_type); sParaTemp.put("notify_url", notify_url); sParaTemp.put("return_url", return_url); sParaTemp.put("out_trade_no", out_trade_no); sParaTemp.put("subject", subject); sParaTemp.put("total_fee", total_fee); sParaTemp.put("show_url", show_url); sParaTemp.put("body", body); sParaTemp.put("it_b_pay", it_b_pay); sParaTemp.put("extern_token", extern_token); String sHtmlText = AlipaySubmit.buildRequest(sParaTemp, "get", "确认"); return sHtmlText; }
时间: 2024-11-05 11:54:41