作用域条件

This commit is contained in:
xman 2025-03-05 17:06:22 +08:00
parent bd66abc4a2
commit 21f866d286
3 changed files with 46 additions and 21 deletions

View File

@ -2,6 +2,7 @@
namespace app\admin\controller\finances;
use app\admin\model\Order;
use app\common\controller\Backend;
/**
@ -51,6 +52,7 @@ class Auditorder extends Backend
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->scope('tag',Order::TAB_AUDIT)
->with(['admin'])
->where($where)
->order($sort, $order)

View File

@ -5,23 +5,23 @@ return [
'Order_no' => '订单号',
'Customer' => '客户姓名',
'Tel' => '客户电话',
'Status' => '订单状态',
'Status 10' => '未派单',
'Set status to 10' => '设为未派单',
'Status 20' => '已派单',
'Set status to 20' => '设为已派单',
'Status 30' => '已接单',
'Set status to 30' => '设为已接单',
'Status 40' => '处理中',
'Set status to 40' => '设为处理中',
'Status 50' => '已完成',
'Set status to 50' => '设为已完成',
'Status -10' => '取消',
'Set status to -10' => '设为取消',
'Status -20' => '作废',
'Set status to -20' => '设为作废',
'Status -30' => '已拒接',
'Set status to -30' => '设为已拒接',
'Status' => '订单状态',
'Status 10' => '未派单',
'Set status to 10' => '设为未派单',
'Status 20' => '已派单',
'Set status to 20' => '设为已派单',
'Status 30' => '进行中',
'Set status to 30' => '设为进行中',
'Status 40' => '待验收',
'Set status to 40' => '设为待验收',
'Status 41' => '审核驳回',
'Set status to 41' => '设为审核驳回',
'Status 50' => '待财务审核',
'Set status to 50' => '设为待财务审核',
'Status 60' => '已完成',
'Set status to 60' => '设为已完成',
'Status -10' => '取消',
'Set status to -10' => '设为取消',
'Area_id' => '地域',
'Address' => '详细地址',
'Work_tel_id' => '工作机',

View File

@ -31,12 +31,20 @@ class Order extends Model
'collect_text',
'dispatch_type_text'
];
const TAB_DISPATCH = 'dispatch'; //派单
const TAB_PENDING = 'pending'; //跟进中
const TAB_AUDIT = 'audit'; //审核
const TAB_REVIEW = 'review'; //回访
public function getStatusList()
{
return ['10' => __('Status 10'), '20' => __('Status 20'), '30' => __('Status 30'), '40' => __('Status 40'), '50' => __('Status 50'), '-10' => __('Status -10'), '-20' => __('Status -20'), '-30' => __('Status -30')];
return ['10' => __('Status 10'), '20' => __('Status 20'), '30' => __('Status 30'), '40' => __('Status 40'), '41' => __('Status 41'), '50' => __('Status 50'), '60' => __('Status 60'), '-10' => __('Status -10')];
}
public function getCollectList()
@ -74,6 +82,21 @@ class Order extends Model
}
protected function scopeTab($query, $tab=null)
{
$status = $this->tabStatus($tab);
if(!empty($status)){
$query->whereIn('order.status', $status);
}
}
private function tabStatus($tab){
$tabStatus = [
self::TAB_DISPATCH => [10], //派单管理状态
self::TAB_PENDING => [20,30,40,41], //订单跟进状态
self::TAB_AUDIT => [50], //待审核
self::TAB_REVIEW => [60],
];
return $tabStatus[$tab] ?? [];
}
}