123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- // +----------------------------------------------------------------------
- // | likeshop开源商城系统
- // +----------------------------------------------------------------------
- // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
- // | gitee下载:https://gitee.com/likeshop_gitee
- // | github下载:https://github.com/likeshop-github
- // | 访问官网:https://www.likeshop.cn
- // | 访问社区:https://home.likeshop.cn
- // | 访问手册:http://doc.likeshop.cn
- // | 微信公众号:likeshop技术社区
- // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
- // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
- // | 禁止对系统程序代码以任何目的,任何形式的再发布
- // | likeshop团队版权所有并拥有最终解释权
- // +----------------------------------------------------------------------
- // | author: likeshop.cn.team
- // +----------------------------------------------------------------------
- namespace app\common\server\DouGong\pay;
-
- use app\common\enum\PayEnum;
- use app\common\model\integral\IntegralOrderRefund;
- use app\common\model\order\OrderRefund;
- use app\common\server\DouGong\BaseRequest;
-
- /**
- * @notes 退款
- * author lbzy
- * @datetime 2023-10-23 14:45:05
- * @class PayZhengsaoRefund
- * @package app\common\server\DouGong\pay
- */
- class PayZhengsaoRefund extends BaseRequest
- {
- protected $request_uri = '/v2/trade/payment/scanpay/refund';
-
- protected function initialize()
- {
- $this->initRequestData();
- }
-
- protected function initRequestData()
- {
- // 商户id
- $this->request_data['data']['huifu_id'] = $this->config['huifu_id'];
- // 请求日期req_date
- $this->request_data['data']['req_date'] = date("Ymd");
- // 退款金额
- $this->request_data['data']['ord_amt'] = bcadd($this->params['refund']['money'], 0, 2);
- // 退款单号
- if ($this->params['from'] == 'order') {
- $this->request_data['data']['req_seq_id'] = OrderRefund::where('id', $this->params['refund']['id'])->value('refund_sn');
- }
- if ($this->params['from'] == 'integral') {
- $this->request_data['data']['req_seq_id'] = IntegralOrderRefund::where('id', $this->params['refund']['id'])->value('refund_sn');
- }
- // 原全局流水号
- $this->request_data['data']['org_hf_seq_id'] = $this->params['order']['transaction_id'];
- // 原请求日期org_req_date
- $this->request_data['data']['org_req_date'] = $this->params['order']['hfdg_params']['pay_request_date'];
-
- $this->request_data['data']['remark'] = implode('-', [
- $this->params['from'],
- $this->params['order']['id'],
- $this->params['refund']['id'],
- ]);
-
- // 回调
- // $this->request_data['data']['notify_url'];
- }
-
- function getRefundResult()
- {
- if ($this->request_success && in_array($this->request_result['data']['trans_stat'], [ 'P', 'S' ])) {
- // 记录请求时间等信息
- $update = [
- 'hfdg_params' => [
- 'refund_request_time' => $_SERVER['REQUEST_TIME'],
- 'refund_request_date' => $this->request_data['data']['req_date'],
- ],
- ];
-
- switch ($this->params['from']) {
- case 'order':
- OrderRefund::update($update, [ [ 'id', '=', $this->params['refund']['id'] ] ]);
- break;
- case 'integral':
- IntegralOrderRefund::update($update, [ [ 'id', '=', $this->params['refund']['id'] ] ]);
- break;
- default:
- break;
- }
-
- return [
- 'code' => 1,
- 'msg' => $this->request_message,
- 'show' => 0,
- 'data' => [],
- ];
- }
-
- return [
- 'code' => 0,
- 'msg' => $this->request_message,
- 'show' => 0,
- 'data' => [],
- ];
- }
- }
|