You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
116 lines
2.8 KiB
116 lines
2.8 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\model\salary;
|
|
|
|
use core\base\BaseModel;
|
|
use think\model\concern\SoftDelete;
|
|
use think\model\relation\HasMany;
|
|
use think\model\relation\HasOne;
|
|
|
|
use app\model\personnel\Personnel;
|
|
|
|
use app\model\departments\Departments;
|
|
|
|
/**
|
|
* 工资模型
|
|
* Class Salary
|
|
* @package app\model\salary
|
|
*/
|
|
class Salary extends BaseModel
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
* 数据表主键
|
|
* @var string
|
|
*/
|
|
protected $pk = 'id';
|
|
|
|
/**
|
|
* 模型名称
|
|
* @var string
|
|
*/
|
|
protected $name = 'salary';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* 搜索器:工资员工
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchStaffIdAttr($query, $value, $data)
|
|
{
|
|
if ($value) {
|
|
$query->where("staff_id", $value);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索器:工资部门
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchDepartmentIdAttr($query, $value, $data)
|
|
{
|
|
if ($value) {
|
|
$query->where("department_id", $value);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索器:工资发放状态
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchPaymentStatusAttr($query, $value, $data)
|
|
{
|
|
if ($value) {
|
|
$query->where("payment_status", $value);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索器:工资创建时间
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchCreatedAtAttr($query, $value, $data)
|
|
{
|
|
$start = empty($value[0]) ? 0 : strtotime($value[0]);
|
|
$end = empty($value[1]) ? 0 : strtotime($value[1]);
|
|
if ($start > 0 && $end > 0) {
|
|
$query->where([["created_at", "between", [$start, $end]]]);
|
|
} else if ($start > 0 && $end == 0) {
|
|
$query->where([["created_at", ">=", $start]]);
|
|
} else if ($start == 0 && $end > 0) {
|
|
$query->where([["created_at", "<=", $end]]);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function personnel(){
|
|
return $this->hasOne(Personnel::class, 'id', 'staff_id')->joinType('left')->withField('name,id')->bind(['staff_id_name'=>'name']);
|
|
}
|
|
|
|
public function departments(){
|
|
return $this->hasOne(Departments::class, 'id', 'department_id')->joinType('left')->withField('department_name,id')->bind(['department_id_name'=>'department_name']);
|
|
}
|
|
|
|
}
|
|
|