额外 支付
This commit is contained in:
@@ -1,15 +1,25 @@
|
||||
package com.czg.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import com.czg.order.dto.CheckOrderPay;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.service.OrderInfoService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.order.dto.OrderPayParamDTO;
|
||||
import com.czg.service.order.service.PayService;
|
||||
import com.czg.system.enums.SysParamCodeEnum;
|
||||
import com.czg.system.service.SysParamsService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.ServletUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -23,6 +33,10 @@ import java.util.Map;
|
||||
public class OrderPayController {
|
||||
@Resource
|
||||
private PayService payService;
|
||||
@Resource
|
||||
private OrderInfoService orderService;
|
||||
@DubboReference
|
||||
private SysParamsService paramsService;
|
||||
|
||||
@PostMapping("/creditPay")
|
||||
public CzgResult<Object> creditPayOrder(@RequestHeader Long shopId, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
@@ -102,4 +116,45 @@ public class OrderPayController {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.microPayOrder(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺订单支付URL
|
||||
*/
|
||||
@PostMapping("/shopPayApi/orderPayUrl")
|
||||
public CzgResult<String> getOrderPayUrl(Long shopId, Long orderId, @RequestParam(required = false) String extend,
|
||||
@RequestParam(required = false) CheckOrderPay checkOrderPay) {
|
||||
AssertUtil.isNull(shopId, "店铺id不能为空");
|
||||
AssertUtil.isNull(orderId, "订单Id不能为空");
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("shopId", shopId);
|
||||
map.put("orderId", orderId);
|
||||
map.put("payAmount", checkOrderPay.getOrderAmount());
|
||||
map.put("extend", StrUtil.isEmpty(extend) ? "" : extend);
|
||||
if (checkOrderPay.getOrderId() != null) {
|
||||
OrderInfo orderInfo = orderService.checkOrderPay(checkOrderPay);
|
||||
map.put("payAmount", orderInfo.getOrderAmount());
|
||||
}
|
||||
String baseUrl = paramsService.getSysParamValue(SysParamCodeEnum.SHOP_ORDER_PAY_BASE_URL.getCode());
|
||||
String buildUrl = URLUtil.buildQuery(map, Charset.defaultCharset());
|
||||
String fullUrl = baseUrl.concat("?").concat(buildUrl);
|
||||
return CzgResult.success(fullUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* openId 必填
|
||||
*
|
||||
* checkOrderPay.orderAmount 必填
|
||||
*/
|
||||
@PostMapping("/shopPayApi/js2Pay")
|
||||
public CzgResult<Map<String, Object>> js2PayOrder(@RequestHeader Long shopId, HttpServletRequest request, @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.js2PayOrder(ServletUtil.getClientIPByHeader(request), payParam);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/queryOrderPay")
|
||||
public CzgResult<Map<String, Object>> queryOrderPay(Long orderId){
|
||||
return payService.queryPayOrder(orderId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user