/* * 微信二次支付 * param orderId * */ @RequestMapping(value = "/order/pay/wx") @ResponseBody public ResponseObject<PaymentResponseClientVO> submitWXJsAgain( @RequestParam(value = "orderId") String orderId, HttpServletRequest req, @RequestHeader(value = "referer", required = false) String referer) { if (!enableWxJsApiPay(req)) throw new BizException(GlobalErrorCode.UNKNOWN, "需要在高于5.0版本的微信中发起"); String bizNo = this.orderService.load(orderId).getPayNo(); if (StringUtils.isBlank(bizNo)) return null; CashierItem item = cashierService.nextCashierItem(bizNo); if (null == item) return null; try { PaymentRequestVO request = new PaymentRequestVO(); request.setCashierItemId(item.getId()); request.setTradeNo(item.getBizNo()); request.setPayType(PaymentMode.WEIXIN); request.setSubject("想去网:PO=" + item.getBizNo()); String openId = userService.getWeixinPayOpenId(); if (null == openId) throw new BizException(GlobalErrorCode.THIRDPLANT_BUZERROR, "openId为空"); request.setOpenId(openId); request.setTradeUrl(hostName + "/order/" + cashierService.findDefaultBizId(item.getBizNo())); BigDecimal paidFee = this.cashierService.loadPaidFee(request.getTradeNo()); request.setTotalFee(paidFee); request.setRemoteHost(PaymentController.getIpAddr(req)); request.setRequestUrl(referer); PaymentResponseClientVO response = wxJsApiPayment.sign(request); return new ResponseObject<>(response); } catch (Exception e) { throw new BizException(GlobalErrorCode.INVALID_ARGUMENT, "支付请求失败,tradeNo=" + bizNo, e); } }
/** * 临时支持微信内支付的接口 * * @author Tier <QQ:871898560> * @dateTime 2016年1月11日,下午5:38:14 * @param form * @param unionId * @param tuId * @param errors * @param device * @param model * @param request * @param referer */ @RequestMapping(value = "/order/submit/wx") // @Token(remove = true) @ResponseBody public ResponseObject<PaymentResponseClientVO> submitWXJs( @ModelAttribute XqOrderSumbitForm form, @CookieValue(value = "union_id", defaultValue = "") String unionId, @CookieValue(value = "tu_id", defaultValue = "") String tuId, Errors errors, Device device, Model model, HttpServletRequest req, @RequestHeader(value = "referer", required = false) String referer) { if (!enableWxJsApiPay(req)) throw new BizException(GlobalErrorCode.UNKNOWN, "需要在高于5.0版本的微信中发起"); // 订单提交,包括优惠券使用 Map<String, String> m = super.doSubmit(form, unionId, tuId, errors, device, model, req, referer); String bizNo = m.get("pNo"); CashierItem item = cashierService.nextCashierItem(bizNo); // 未支付 if (null == item) { return null; } try { PaymentRequestVO request = new PaymentRequestVO(); request.setCashierItemId(item.getId()); request.setTradeNo(item.getBizNo()); request.setPayType(PaymentMode.WEIXIN); request.setSubject("想去网:PO=" + item.getBizNo()); String openId = userService.getWeixinPayOpenId(); if (null == openId) throw new BizException(GlobalErrorCode.THIRDPLANT_BUZERROR, "openId为空"); request.setOpenId(openId); request.setTradeUrl(hostName + "/order/" + cashierService.findDefaultBizId(item.getBizNo())); BigDecimal paidFee = this.cashierService.loadPaidFee(request.getTradeNo()); request.setTotalFee(paidFee); request.setRemoteHost(PaymentController.getIpAddr(req)); request.setRequestUrl(referer); PaymentResponseClientVO response = wxJsApiPayment.sign(request); return new ResponseObject<>(response); } catch (Exception e) { // log.error("支付请求失败,tradeNo=" + request.getTradeNo(), e); throw new BizException(GlobalErrorCode.INVALID_ARGUMENT, "支付请求失败,tradeNo=" + bizNo, e); } }