6
0
Fork 0

添加订单支付状态显示

release
vine_liutk 2021-12-20 21:12:35 +08:00
parent fb420a1394
commit c6052f7aa7
4 changed files with 82 additions and 3 deletions

View File

@ -57,7 +57,17 @@ class OrderController extends AdminController
9=>'success',
10=>'#b3b9bf',
]);
$grid->column('pay_way');
$grid->column('pay_way')->using([
'wxpay'=>'微信支付',
'alipay'=>'支付宝',
'offline'=>'线下支付',
'none'=>'无',
])->label([
'wxpay'=>'success',
'alipay'=>'primary',
'offline'=>'warning',
'none'=>'#b3b9bf',
]);
$grid->column('pay_at');
// $grid->column('consignee_name');
// $grid->column('consignee_telephone');
@ -143,7 +153,17 @@ class OrderController extends AdminController
return bcdiv($v, 100, 2);
})->prepend('¥');
$show->field('created_at');
$show->field('pay_way');
$show->field('pay_way')->using([
'wxpay'=>'微信支付',
'alipay'=>'支付宝',
'offline'=>'线下支付',
'none'=>'无',
])->showLabel([
'微信支付'=>'success',
'支付宝'=>'primary',
'线下支付'=>'warning',
'无'=>'#b3b9bf',
]);
$show->field('pay_at');
$show->divider();

View File

@ -0,0 +1,55 @@
<?php
namespace App\Admin\Extensions\Show;
use Dcat\Admin\Admin;
use Dcat\Admin\Show\AbstractField;
use Dcat\Admin\Support\Helper;
use Illuminate\Support\Arr;
class Label extends AbstractField
{
// 这个属性设置为false则不会转义HTML代码
public $escape = false;
public function render($style = 'primary', $max = null)
{
if (! $value = $this->value($max)) {
return;
}
return collect($value)->map(function ($name) use ($style) {
$background = $this->formatStyle(Arr::get($style, $name, 'default'));
return "<span class='label' {$background}>$name</span>";
})->implode(' ');
// return collect($value)->map(function ($name) use ($class, $background) {
// return "<span class='label bg-{$class}' {$background}>$name</span>";
// })->implode(' ');
}
protected function formatStyle($style)
{
$background = 'style="background:#d2d6de;color: #555"';
if ($style !== 'default') {
$style = Admin::color()->get($style);
$background = "style='background:{$style}'";
}
return $background;
}
protected function value($max)
{
$values = Helper::array($this->value);
if ($max && count($values) > $max) {
$values = array_slice($values, 0, $max);
$values[] = '...';
}
return $values;
}
}

View File

@ -42,7 +42,7 @@ class OrderService
if ($order->isPending()) {
//操作订单状态-需要调整为统一支付方法
$orderService = new EndpointOrderService();
$orderService->paySuccess($order, [
$orderService->paySuccess($order->sn, [
'pay_sn' => date('YmdHis').sprintf('%02d', mt_rand(1, 99)),
'pay_way' => Order::PAY_WAY_OFFLINE,
'pay_at' => now(),

View File

@ -3,11 +3,13 @@
use App\Admin\Extensions\Column\Modal;
use App\Admin\Extensions\Form\Product\SelectAttr;
use App\Admin\Extensions\Form\Product\SelectSpec;
use App\Admin\Extensions\Show\Label;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Form\Field\Editor;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\Column;
use Dcat\Admin\Show\Field as ShowField;
/**
* Dcat-admin - admin builder based on Laravel.
@ -53,3 +55,5 @@ Editor::resolving(function (Editor $editor) {
'branding'=> false,
]);
});
ShowField::extend('showLabel', Label::class);