Order/ShowWxShareFinish
parent
fc4920577e
commit
11b6e0c1b8
|
|
@ -0,0 +1,36 @@
|
|||
<?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 ['确定要解冻资金?', '解冻资金后将无法进行分账'];
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ use App\Admin\Actions\Grid\Exports\ShippingOrder as ExportShippingOrder;
|
|||
use App\Admin\Actions\Grid\KuaidiInfo;
|
||||
use App\Admin\Actions\Grid\OrderSetTag;
|
||||
use App\Admin\Actions\Order\RowWxShareFinish;
|
||||
use App\Admin\Actions\Order\ShowWxShareFinish;
|
||||
use App\Admin\Actions\Show\OrderConsigneeInfo;
|
||||
use App\Admin\Actions\Show\OrderCreatePackage;
|
||||
use App\Admin\Actions\Show\OrderPay;
|
||||
|
|
@ -275,9 +276,9 @@ class OrderController extends AdminController
|
|||
$actions->append(new OrderSetTag());
|
||||
}
|
||||
|
||||
if ($row->pay_at && data_get($row->wx_share, 'status') != 'N') {
|
||||
$actions->append(new RowWxShareFinish());
|
||||
}
|
||||
// if ($row->pay_at && data_get($row->wx_share, 'status') != 'N') {
|
||||
// $actions->append(new RowWxShareFinish());
|
||||
// }
|
||||
});
|
||||
|
||||
$grid->footer(function ($collection) use ($grid) {
|
||||
|
|
@ -320,7 +321,7 @@ class OrderController extends AdminController
|
|||
*
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return Show
|
||||
* @return \Closure|Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
|
|
@ -421,6 +422,10 @@ class OrderController extends AdminController
|
|||
if ($show->model()->isPending() || $show->model()->isWaitShipping() || $show->model()->isShipping()) {
|
||||
$tools->append(new OrderConsigneeInfo());
|
||||
}
|
||||
|
||||
if ($show->model()->pay_at && data_get($show->model()->wx_share, 'status') != 'N') {
|
||||
$tools->append(new ShowWxShareFinish());
|
||||
}
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -234,21 +234,24 @@ class DistributeService
|
|||
throw new BizException('用户 '.$item->user_id.' 没有 openid');
|
||||
}
|
||||
$item->update(['pay_way' => PayWay::WxPayShare, 'pay_no' => $sn, 'status' => 1]);
|
||||
array_push($receivers, [
|
||||
"type" => "PERSONAL_SUB_OPENID",
|
||||
"account" => $openid,
|
||||
"amount" => $item->money * 100,
|
||||
"description" => "推荐返利"
|
||||
]);
|
||||
if ($item->money > 0) {
|
||||
array_push($receivers, [
|
||||
"type" => "PERSONAL_SUB_OPENID",
|
||||
"account" => $openid,
|
||||
"amount" => $item->money * 100,
|
||||
"description" => "推荐返利"
|
||||
]);
|
||||
}
|
||||
}
|
||||
$status = 'FINISHED';
|
||||
if (count($receivers) > 0) {
|
||||
$result = (new WxpayService())->share($order->out_trade_no, $sn, $receivers);
|
||||
$status = data_get($result, 'status');
|
||||
logger('DistributeService@wechatShare, order:' . $order->id, $result);
|
||||
}
|
||||
|
||||
$result = (new WxpayService())->share($order->out_trade_no, $sn, $receivers);
|
||||
|
||||
$attributes = ['share_sn' => $sn, 'status' => 'N'];
|
||||
$order->update(['wx_share' => $order->wx_share ? array_merge($order->wx_share, $attributes) : $attributes]);
|
||||
|
||||
$status = data_get($result, 'status');
|
||||
if ($status == 'FINISHED') {
|
||||
$attributes = ['share_sn' => $sn, 'status' => 'N'];
|
||||
$order->update(['wx_share' => $order->wx_share ? array_merge($order->wx_share, $attributes) : $attributes]);
|
||||
$this->success($list, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue