作用域条件

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

View File

@ -10,18 +10,18 @@ return [
'Set status to 10' => '设为未派单', 'Set status to 10' => '设为未派单',
'Status 20' => '已派单', 'Status 20' => '已派单',
'Set status to 20' => '设为已派单', 'Set status to 20' => '设为已派单',
'Status 30' => '已接单', 'Status 30' => '进行中',
'Set status to 30' => '设为已接单', 'Set status to 30' => '设为进行中',
'Status 40' => '处理中', 'Status 40' => '待验收',
'Set status to 40' => '设为处理中', 'Set status to 40' => '设为待验收',
'Status 50' => '已完成', 'Status 41' => '审核驳回',
'Set status to 50' => '设为已完成', 'Set status to 41' => '设为审核驳回',
'Status 50' => '待财务审核',
'Set status to 50' => '设为待财务审核',
'Status 60' => '已完成',
'Set status to 60' => '设为已完成',
'Status -10' => '取消', 'Status -10' => '取消',
'Set status to -10' => '设为取消', 'Set status to -10' => '设为取消',
'Status -20' => '作废',
'Set status to -20' => '设为作废',
'Status -30' => '已拒接',
'Set status to -30' => '设为已拒接',
'Area_id' => '地域', 'Area_id' => '地域',
'Address' => '详细地址', 'Address' => '详细地址',
'Work_tel_id' => '工作机', 'Work_tel_id' => '工作机',

View File

@ -33,10 +33,18 @@ class Order extends Model
]; ];
const TAB_DISPATCH = 'dispatch'; //派单
const TAB_PENDING = 'pending'; //跟进中
const TAB_AUDIT = 'audit'; //审核
const TAB_REVIEW = 'review'; //回访
public function getStatusList() 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() 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] ?? [];
}
} }