123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- package com.caimei.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.caimei.model.ResponseJson;
- import com.caimei.model.dto.HeliDto;
- import com.caimei.model.vo.AccountResVo;
- import com.caimei.model.vo.NotifyResponseVo;
- import com.caimei.service.HeliPayService;
- import com.caimei.service.PayOrderService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import lombok.RequiredArgsConstructor;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.http.HttpHeaders;
- import org.springframework.web.bind.annotation.*;
- import java.beans.IntrospectionException;
- import java.io.IOException;
- import java.lang.reflect.InvocationTargetException;
- import java.util.Map;
- /**
- * Description
- *
- * @author : zzj
- * @date : 2021/11/11
- */
- @Api(tags = "合利宝支付API")
- @RestController
- @RequiredArgsConstructor
- @RequestMapping("/order/pay")
- public class HeliPayApi {
- private final HeliPayService heliPayService;
- private final PayOrderService payOrderService;
- /**
- * 获取线上支付全局开关状态
- */
- @ApiOperation("获取线上支付全局开关状态(旧:/PayOrder/onLineSwitch)")
- @GetMapping("/online/switch")
- public ResponseJson<Integer> getPayOnLineSwitch() {
- return payOrderService.getPayOnLineSwitch();
- }
- /**
- * 判断此次支付是否完成
- *
- * @param orderId 订单id
- * @param paySuccessCounter 付款次数
- */
- @ApiOperation("判断此次支付是否完成(旧:/PayOrder/payWhetherSuccess)")
- @ApiImplicitParams({
- @ApiImplicitParam(required = false, name = "orderId", value = "订单id"),
- @ApiImplicitParam(required = false, name = "paySuccessCounter", value = "付款次数")
- })
- @GetMapping("/result/check")
- public ResponseJson<String> payWhetherSuccess(Integer orderId, Integer paySuccessCounter) {
- if (null == orderId) {
- return ResponseJson.error("订单Id不能为空!", null);
- }
- if (null == paySuccessCounter) {
- return ResponseJson.error("付款次数不能为空!", null);
- }
- return payOrderService.payWhetherSuccess(orderId, paySuccessCounter);
- }
- /**
- * 查询本次支付订单结果
- *
- * @param mbOrderId 平台唯一流水号
- */
- @ApiOperation("查询本次支付订单结果(旧:/PayOrder/findOrderStatus)")
- @ApiImplicitParam(required = false, name = "mbOrderId", value = "平台唯一流水号")
- @GetMapping("/result/json")
- public ResponseJson<JSONObject> getPayOrderResult(String mbOrderId) {
- if (null == mbOrderId) {
- return ResponseJson.error("平台唯一流水号不能为空!", null);
- }
- return heliPayService.getPayOrderResult(mbOrderId);
- }
- /**
- * 合利宝公众号/小程序支付
- */
- @ApiOperation("合利宝微信小程序/公众号支付")
- @PostMapping("/online")
- public ResponseJson<JSONObject> payOnline(@RequestBody HeliDto heliDto, @RequestHeader HttpHeaders headers) {
- if (null == heliDto.getShopOrderId()) {
- return ResponseJson.error("子订单Id不能为空!", null);
- }
- return heliPayService.payOnline(heliDto, headers);
- }
- /**
- * 支付异步通知回调
- */
- @ApiOperation("支付异步通知回调(旧:/PayOrder/paymentCallback)")
- @PostMapping("/callback")
- public String paymentCallback(NotifyResponseVo res) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
- if (res == null) {
- return "回调参数失败";
- }
- return heliPayService.paymentCallback(res);
- }
- /**
- * 延时分账异步通知回调
- */
- @ApiOperation("延时分账异步通知回调(旧:/PayOrder/delayedSplittingCallback)")
- @PostMapping("/delay/split/callback")
- public String delayedSplittingCallback(AccountResVo data) {
- if (null == data) {
- return "回调参数失败";
- }
- return heliPayService.delayedSplittingCallback(data);
- }
- }
|