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

37 lines
1.2 KiB
PHP

<?php
namespace App\Admin\Actions\Order;
use App\Models\Order;
use App\Services\Payment\WxpayService;
use Dcat\Admin\Show\AbstractTool;
class ShowWxShareFinish extends AbstractTool
{
protected $title = '解冻资金';
protected $style = 'btn btn-sm btn-warning mr-1';
public function handle()
{
$order = Order::findOrFail($this->getKey());
$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(['wx_share' => $order->wx_share ? array_merge($order->wx_share, $attributes) : $attributes]);
return $this->response()->success('成功!');
}
public function confirm()
{
return ['确定要解冻资金?', '解冻资金后将无法进行分账'];
}
}