小程序微信支付
This commit is contained in:
@@ -14,7 +14,6 @@ import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @FileName: MiniProgramAppController
|
||||
* @Description:
|
||||
* @date 2023-05-29 14:28
|
||||
@@ -22,7 +21,7 @@ import javax.validation.Valid;
|
||||
|
||||
@Api(tags = "微信小程序app接口")
|
||||
@RestController
|
||||
@RequestMapping({"/v1/partnerManage/miniProgram" })
|
||||
@RequestMapping({"/mini/miniProgram" })
|
||||
public class MiniProgramAppController {
|
||||
|
||||
@Resource
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.cool.store.controller.webc;
|
||||
|
||||
import com.cool.store.dto.wx.PreOrderDTO;
|
||||
import com.cool.store.response.ResponseResult;
|
||||
import com.cool.store.service.WxPayService;
|
||||
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
|
||||
import com.wechat.pay.java.service.payments.model.Transaction;
|
||||
import com.wechat.pay.java.service.refund.model.Refund;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @FileName: WechatPayController
|
||||
* @Description:
|
||||
* @date 2024-03-13 14:28
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Api(tags = "微信小程序支付接口")
|
||||
@RestController
|
||||
@RequestMapping({"/mini/wechatPay"})
|
||||
public class WechatPayController {
|
||||
|
||||
@Resource
|
||||
private WxPayService wxPayService;
|
||||
|
||||
@ApiOperation(value = "预支付订单", notes = "预支付订单")
|
||||
@PostMapping("/create")
|
||||
public ResponseResult<PrepayWithRequestPaymentResponse> createOrder(@Validated @RequestBody PreOrderDTO preOrderDTO) {
|
||||
//创建初始化订单
|
||||
PrepayWithRequestPaymentResponse response = wxPayService.jsApiOrder(preOrderDTO);
|
||||
//更新订单状态
|
||||
return ResponseResult.success(response);
|
||||
}
|
||||
|
||||
@ApiOperation("根据商户订单号查询订单")
|
||||
@GetMapping("/queryOrderByOutTradeNo")
|
||||
public ResponseResult<Transaction> queryOrderByOutTradeNo(@RequestParam(value = "outTradeNo",required = true)String outTradeNo) {
|
||||
return ResponseResult.success(wxPayService.queryOrderByOutTradeNo(outTradeNo));
|
||||
}
|
||||
|
||||
@ApiOperation("根据支付订单号查询订单")
|
||||
@GetMapping("/queryOrderByOutTradeNo")
|
||||
public ResponseResult<Transaction> queryOrderByPaymentNo(@RequestParam(value = "paymentNo",required = true)String paymentNo) {
|
||||
return ResponseResult.success(wxPayService.queryOrderByPaymentNo(paymentNo));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "预支付-回调")
|
||||
@PostMapping("/payNotify")
|
||||
public ResponseEntity payNotify(HttpServletRequest request) throws IOException {
|
||||
ResponseEntity responseEntity = wxPayService.payNotify(request);
|
||||
return responseEntity;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "退款申请")
|
||||
@PostMapping("/applyRefund")
|
||||
public ResponseResult applyRefund(@RequestBody Map<String, Object> params){
|
||||
String orderID = String.valueOf(params.get("orderID"));
|
||||
String backID = String.valueOf(params.get("backID"));
|
||||
BigDecimal backAmount = new BigDecimal(String.valueOf(params.get("backAmount")));
|
||||
wxPayService.applyRefund(orderID, backID, backAmount);
|
||||
return ResponseResult.success(true);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "退款回调")
|
||||
@PostMapping("/refundNotify")
|
||||
public ResponseEntity refundNotify(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
ResponseEntity responseEntity = wxPayService.refundNotify(request);
|
||||
return responseEntity;
|
||||
}
|
||||
|
||||
@GetMapping("/getRefundOrderInfo")
|
||||
@ApiOperation("退款查询")
|
||||
public ResponseResult<Refund> getRefundOrderInfo(@RequestParam(value = "outRefundNo",required = true)String outRefundNo){
|
||||
Refund refund = wxPayService.getRefundOrderInfo(outRefundNo);
|
||||
return ResponseResult.success(refund);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -50,4 +50,11 @@ server.connection-timeout=18000000
|
||||
server.tomcat.basedir=/tmp/tomcat/partner-b
|
||||
|
||||
log4j2.formatMsgNoLookups=true
|
||||
mybatis.configuration.variables.enterpriseId=e17cd2dc350541df8a8b0af9bd27f77d
|
||||
mybatis.configuration.variables.enterpriseId=e17cd2dc350541df8a8b0af9bd27f77d
|
||||
|
||||
wx.pay.merchantId=1670560201
|
||||
wx.pay.privateKeyPath=/home/admin/apiclient/apiclient_key.pem
|
||||
wx.pay.merchantSerialNumber=66B8E966AFE796BA06006664FCBFBC3F0E2F5A1B
|
||||
wx.pay.apiV3Key=wxpayzhenghu123JKJHkjafWXCertUt1
|
||||
wx.pay.payNotifyUrl=https://abstore-api.coolstore.cn/xfsg/mini/wechatPay/payNotify
|
||||
wx.pay.backNotifyUrl=https://abstore-api.coolstore.cn/xfsg/mini/wechatPay/backNotify
|
||||
Reference in New Issue
Block a user