6
0
Fork 0

调整售后发起判断

release
vine_liutk 2022-01-04 13:14:07 +08:00
parent cc3c4cf159
commit 0890778f61
3 changed files with 8 additions and 9 deletions

View File

@ -132,7 +132,7 @@ class OrderController extends AdminController
{ {
return function (Row $row) use ($id) { return function (Row $row) use ($id) {
$row->column(5, function ($column) use ($id) { $row->column(5, function ($column) use ($id) {
$builder = Order::with(['user', 'userCoupon', 'tags']); $builder = OrderModel::with(['user', 'userCoupon', 'tags'])->withCount('afterSales');
$column->row(Show::make($id, $builder, function (Show $show) { $column->row(Show::make($id, $builder, function (Show $show) {
// $show->field('id'); // $show->field('id');
$show->field('sn'); $show->field('sn');
@ -233,16 +233,15 @@ class OrderController extends AdminController
$grid->column('product_total_amount')->display(function () { $grid->column('product_total_amount')->display(function () {
return bcdiv($this->sell_price * $this->quantity, 100, 2); return bcdiv($this->sell_price * $this->quantity, 100, 2);
})->prepend('¥'); })->prepend('¥');
$grid->column('after_sale_state')->using([ $grid->column('afterSalesCount', '售后情况')->display(function ($value) {
0=>'正常', return $value>0 ? 1 : 0;
1=>'售后中', })->using([
2=>'售后完成', 0=>'正常', 1=>'有售后',
])->dot([ ])->dot([
0=>'success', 0=>'success',
1=>'danger', 1=>'danger',
2=>'primary',
])->if(function () { ])->if(function () {
return in_array($this->after_sale_state, [1, 2]) && Admin::user()->can('dcat.admin.after_sales.index'); return $this->afterSalesCount>0 && Admin::user()->can('dcat.admin.after_sales.index');
}) })
->then(function (Column $column) { ->then(function (Column $column) {
$column->link(function ($value) { $column->link(function ($value) {

View File

@ -220,7 +220,7 @@ class AfterSale extends Model
if ($afterSale->state == self::STATE_FINISH) { if ($afterSale->state == self::STATE_FINISH) {
$afterSale->createFinishLog(); $afterSale->createFinishLog();
$afterSale->orderProduct->update([ $afterSale->orderProduct->update([
'after_sale_state'=>2, 'after_sale_state'=>0,
]); ]);
} }
}); });

View File

@ -103,7 +103,7 @@ class OrderProduct extends Model
//老判断,有过期时间,且未到过期时间,未发起过售后 //老判断,有过期时间,且未到过期时间,未发起过售后
// $oldJudge = !is_null($this->after_expire_at) && $this->after_expire_at > now() && $this->after_sale_state == 0; // $oldJudge = !is_null($this->after_expire_at) && $this->after_expire_at > now() && $this->after_sale_state == 0;
//新判断, 有发货单,在售后时间范围内, 未发起过售后; //新判断, 有发货单,在售后时间范围内, 当前无售后;
if ($this->packages()->where('is_failed', false)->count() >0) { if ($this->packages()->where('is_failed', false)->count() >0) {
if ((is_null($this->after_expire_at) || $this->after_expire_at > now()) && $this->after_sale_state == 0) { if ((is_null($this->after_expire_at) || $this->after_expire_at > now()) && $this->after_sale_state == 0) {
$res = true; $res = true;