支付接口参数接收实体类

master
litao 2 years ago
parent 3dae7a9612
commit 292f68f6d8
  1. 19
      src/main/java/org/springblade/modules/weixin/controller/AppEbLoginController.java
  2. 18
      src/main/java/org/springblade/modules/weixin/dto/PayDTO.java

@ -14,6 +14,7 @@ import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.modules.auth.endpoint.BladeTokenEndPoint;
import org.springblade.modules.desk.entity.Order;
import org.springblade.modules.desk.service.IOrderService;
import org.springblade.modules.weixin.dto.PayDTO;
import org.springblade.modules.weixin.entity.WeChatPhone;
import org.springblade.modules.weixin.entity.WeChatPhoneInfo;
import org.springblade.modules.weixin.entity.WeChatUser;
@ -96,26 +97,24 @@ public class AppEbLoginController {
/**
* 微信下单
*
* @param openId
*/
@PostMapping("/createOrder")
public R createOrder(@RequestParam String openId, @RequestParam String outTradeNo) {
public R createOrder(@RequestBody PayDTO payDTO) {
// 根据订单号查询订单
Order order = orderService.getOne(Wrappers.<Order>lambdaQuery().eq(Order::getOrderNo, outTradeNo));
if (order == null) {
throw new ServiceException("该订单不存在");
}
Order order = orderService.getOne(Wrappers.<Order>lambdaQuery().eq(Order::getOrderNo, payDTO.getOutTradeNo()));
if (order == null) {
throw new ServiceException("该订单不存在");
}
Double totalPrice = order.getTotalPrice() * 100;
int total = totalPrice.intValue();
// int total = 1;
return R.data(WxPayUtils.getPayParam(openId, outTradeNo, total));
return R.data(WxPayUtils.getPayParam(payDTO.getOpenId(), payDTO.getOutTradeNo(), total));
}
@PostMapping("/cloceOrder")
public R cloceOrder(@RequestParam String outTradeNo) {
return R.data(WxPayUtils.cloceOrderJSApiV3(outTradeNo));
public R cloceOrder(@RequestBody PayDTO payDTO) {
return R.data(WxPayUtils.cloceOrderJSApiV3(payDTO.getOutTradeNo()));
}
@GetMapping("/getOrder")

@ -0,0 +1,18 @@
package org.springblade.modules.weixin.dto;
import lombok.Data;
@Data
public class PayDTO {
/**
* openid
*/
private String openId;
/**
* 订单号
*/
private String outTradeNo;
}
Loading…
Cancel
Save