HeliPayApi.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. package com.caimei.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.caimei.model.ResponseJson;
  4. import com.caimei.model.dto.HeliDto;
  5. import com.caimei.model.vo.AccountResVo;
  6. import com.caimei.model.vo.NotifyResponseVo;
  7. import com.caimei.service.HeliPayService;
  8. import com.caimei.service.PayOrderService;
  9. import io.swagger.annotations.Api;
  10. import io.swagger.annotations.ApiImplicitParam;
  11. import io.swagger.annotations.ApiImplicitParams;
  12. import io.swagger.annotations.ApiOperation;
  13. import lombok.RequiredArgsConstructor;
  14. import org.apache.commons.lang3.StringUtils;
  15. import org.springframework.http.HttpHeaders;
  16. import org.springframework.web.bind.annotation.*;
  17. import java.beans.IntrospectionException;
  18. import java.io.IOException;
  19. import java.lang.reflect.InvocationTargetException;
  20. import java.util.Map;
  21. /**
  22. * Description
  23. *
  24. * @author : zzj
  25. * @date : 2021/11/11
  26. */
  27. @Api(tags = "合利宝支付API")
  28. @RestController
  29. @RequiredArgsConstructor
  30. @RequestMapping("/order/pay")
  31. public class HeliPayApi {
  32. private final HeliPayService heliPayService;
  33. private final PayOrderService payOrderService;
  34. /**
  35. * 获取线上支付全局开关状态
  36. */
  37. @ApiOperation("获取线上支付全局开关状态(旧:/PayOrder/onLineSwitch)")
  38. @GetMapping("/online/switch")
  39. public ResponseJson<Integer> getPayOnLineSwitch() {
  40. return payOrderService.getPayOnLineSwitch();
  41. }
  42. /**
  43. * 判断此次支付是否完成
  44. *
  45. * @param orderId 订单id
  46. * @param paySuccessCounter 付款次数
  47. */
  48. @ApiOperation("判断此次支付是否完成(旧:/PayOrder/payWhetherSuccess)")
  49. @ApiImplicitParams({
  50. @ApiImplicitParam(required = false, name = "orderId", value = "订单id"),
  51. @ApiImplicitParam(required = false, name = "paySuccessCounter", value = "付款次数")
  52. })
  53. @GetMapping("/result/check")
  54. public ResponseJson<String> payWhetherSuccess(Integer orderId, Integer paySuccessCounter) {
  55. if (null == orderId) {
  56. return ResponseJson.error("订单Id不能为空!", null);
  57. }
  58. if (null == paySuccessCounter) {
  59. return ResponseJson.error("付款次数不能为空!", null);
  60. }
  61. return payOrderService.payWhetherSuccess(orderId, paySuccessCounter);
  62. }
  63. /**
  64. * 查询本次支付订单结果
  65. *
  66. * @param mbOrderId 平台唯一流水号
  67. */
  68. @ApiOperation("查询本次支付订单结果(旧:/PayOrder/findOrderStatus)")
  69. @ApiImplicitParam(required = false, name = "mbOrderId", value = "平台唯一流水号")
  70. @GetMapping("/result/json")
  71. public ResponseJson<JSONObject> getPayOrderResult(String mbOrderId) {
  72. if (null == mbOrderId) {
  73. return ResponseJson.error("平台唯一流水号不能为空!", null);
  74. }
  75. return heliPayService.getPayOrderResult(mbOrderId);
  76. }
  77. /**
  78. * 合利宝公众号/小程序支付
  79. */
  80. @ApiOperation("合利宝微信小程序/公众号支付")
  81. @PostMapping("/online")
  82. public ResponseJson<JSONObject> payOnline(@RequestBody HeliDto heliDto, @RequestHeader HttpHeaders headers) {
  83. if (null == heliDto.getShopOrderId()) {
  84. return ResponseJson.error("子订单Id不能为空!", null);
  85. }
  86. return heliPayService.payOnline(heliDto, headers);
  87. }
  88. /**
  89. * 支付异步通知回调
  90. */
  91. @ApiOperation("支付异步通知回调(旧:/PayOrder/paymentCallback)")
  92. @PostMapping("/callback")
  93. public String paymentCallback(NotifyResponseVo res) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
  94. if (res == null) {
  95. return "回调参数失败";
  96. }
  97. return heliPayService.paymentCallback(res);
  98. }
  99. /**
  100. * 延时分账异步通知回调
  101. */
  102. @ApiOperation("延时分账异步通知回调(旧:/PayOrder/delayedSplittingCallback)")
  103. @PostMapping("/delay/split/callback")
  104. public String delayedSplittingCallback(AccountResVo data) {
  105. if (null == data) {
  106. return "回调参数失败";
  107. }
  108. return heliPayService.delayedSplittingCallback(data);
  109. }
  110. }