luodangjia
2024-08-23 8d2fdc29e9bbe652bba73e4a698edcdf89acf983
ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/wx/controller/WxPayController.java
@@ -87,6 +87,16 @@
    public R<Map<String, Object>> payNotify(HttpServletRequest request) throws Exception {
        try {
            Map<String, Object> params = wxV3Pay.verifyNotify(request, new TypeReference<Map<String, Object>>() {});
            String outRefundNo = (String) params.get("out_refund_no");
            String substring = outRefundNo.substring(0, 2);
            switch (substring){
                //购物订单
                case "GW":
                    //更改订单状态
                    //如果是优惠卷赠送优惠卷
                    break;
            }
            log.info("支付回调:{}", params);
            return R.ok(params);
        } catch (Exception e) {
@@ -151,10 +161,18 @@
     * @return
     */
    @PostMapping("query/queryOrderInfo")
    public R<NotifyV3PayDecodeRespBody> queryOrderInfo(String orderId){
        // todo 需要完善商户号
        NotifyV3PayDecodeRespBody query = wxV3Pay.query(orderId, "");
    public R<NotifyV3PayDecodeRespBody> queryOrderInfo(@RequestParam("orderId") String orderId){
        NotifyV3PayDecodeRespBody query = wxV3Pay.query(orderId);
        return R.ok(query);
    }
    
    /**
     * 关闭订单
     * @param outTradeNo
     */
    @PostMapping("pay/close")
    public void close(@RequestParam("outTradeNo") String outTradeNo){
        wxV3Pay.close(outTradeNo);
    }
}