6
0
Fork 0
jiqu-library-server/app/Admin/Actions/Order/RowWxShareFinish.php

35 lines
1.1 KiB
PHP

<?php
namespace App\Admin\Actions\Order;
use App\Models\Order;
use App\Services\Payment\WxpayService;
use Dcat\Admin\Grid\RowAction;
class RowWxShareFinish extends RowAction
{
protected $title = '解冻资金';
public function handle()
{
$order = Order::findOrFail($this->primaryKey);
$service = new WxpayService();
$sn = serial_number();
$result = $service->finishShare($order->out_trade_no, $sn);
if (data_get($result, 'return_code') != 'SUCCESS') {
return $this->response()->error(data_get($result, 'return_msg'));
}
if (data_get($result, 'result_code') != 'SUCCESS') {
return $this->response()->error(data_get($result, 'err_code') . ':' . data_get($result, 'err_code_des'));
}
$attributes = ['finish_sn' => $sn, 'status' => 'N'];
$order->update($order->wx_share ? array_merge($order->wx_share, $attributes) : $attributes);
return $this->response()->success('成功!');
}
public function confirm()
{
return ['确定要解冻资金?', '解冻资金后将无法进行分账'];
}
}