截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PayZhengsaoRefund.php 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop开源商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | gitee下载:https://gitee.com/likeshop_gitee
  7. // | github下载:https://github.com/likeshop-github
  8. // | 访问官网:https://www.likeshop.cn
  9. // | 访问社区:https://home.likeshop.cn
  10. // | 访问手册:http://doc.likeshop.cn
  11. // | 微信公众号:likeshop技术社区
  12. // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
  13. // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
  14. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  15. // | likeshop团队版权所有并拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshop.cn.team
  18. // +----------------------------------------------------------------------
  19. namespace app\common\server\DouGong\pay;
  20. use app\common\enum\PayEnum;
  21. use app\common\model\integral\IntegralOrderRefund;
  22. use app\common\model\order\OrderRefund;
  23. use app\common\server\DouGong\BaseRequest;
  24. /**
  25. * @notes 退款
  26. * author lbzy
  27. * @datetime 2023-10-23 14:45:05
  28. * @class PayZhengsaoRefund
  29. * @package app\common\server\DouGong\pay
  30. */
  31. class PayZhengsaoRefund extends BaseRequest
  32. {
  33. protected $request_uri = '/v2/trade/payment/scanpay/refund';
  34. protected function initialize()
  35. {
  36. $this->initRequestData();
  37. }
  38. protected function initRequestData()
  39. {
  40. // 商户id
  41. $this->request_data['data']['huifu_id'] = $this->config['huifu_id'];
  42. // 请求日期req_date
  43. $this->request_data['data']['req_date'] = date("Ymd");
  44. // 退款金额
  45. $this->request_data['data']['ord_amt'] = bcadd($this->params['refund']['money'], 0, 2);
  46. // 退款单号
  47. if ($this->params['from'] == 'order') {
  48. $this->request_data['data']['req_seq_id'] = OrderRefund::where('id', $this->params['refund']['id'])->value('refund_sn');
  49. }
  50. if ($this->params['from'] == 'integral') {
  51. $this->request_data['data']['req_seq_id'] = IntegralOrderRefund::where('id', $this->params['refund']['id'])->value('refund_sn');
  52. }
  53. // 原全局流水号
  54. $this->request_data['data']['org_hf_seq_id'] = $this->params['order']['transaction_id'];
  55. // 原请求日期org_req_date
  56. $this->request_data['data']['org_req_date'] = $this->params['order']['hfdg_params']['pay_request_date'];
  57. $this->request_data['data']['remark'] = implode('-', [
  58. $this->params['from'],
  59. $this->params['order']['id'],
  60. $this->params['refund']['id'],
  61. ]);
  62. // 回调
  63. // $this->request_data['data']['notify_url'];
  64. }
  65. function getRefundResult()
  66. {
  67. if ($this->request_success && in_array($this->request_result['data']['trans_stat'], [ 'P', 'S' ])) {
  68. // 记录请求时间等信息
  69. $update = [
  70. 'hfdg_params' => [
  71. 'refund_request_time' => $_SERVER['REQUEST_TIME'],
  72. 'refund_request_date' => $this->request_data['data']['req_date'],
  73. ],
  74. ];
  75. switch ($this->params['from']) {
  76. case 'order':
  77. OrderRefund::update($update, [ [ 'id', '=', $this->params['refund']['id'] ] ]);
  78. break;
  79. case 'integral':
  80. IntegralOrderRefund::update($update, [ [ 'id', '=', $this->params['refund']['id'] ] ]);
  81. break;
  82. default:
  83. break;
  84. }
  85. return [
  86. 'code' => 1,
  87. 'msg' => $this->request_message,
  88. 'show' => 0,
  89. 'data' => [],
  90. ];
  91. }
  92. return [
  93. 'code' => 0,
  94. 'msg' => $this->request_message,
  95. 'show' => 0,
  96. 'data' => [],
  97. ];
  98. }
  99. }