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.
108 lines
3.0 KiB
108 lines
3.0 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\model\order_table;
|
|
|
|
use core\base\BaseModel;
|
|
use think\model\concern\SoftDelete;
|
|
use think\model\relation\HasMany;
|
|
use think\model\relation\HasOne;
|
|
|
|
use app\model\customer_resources\CustomerResources;
|
|
|
|
use app\model\course\Course;
|
|
|
|
use app\model\class_grade\ClassGrade;
|
|
|
|
use app\model\personnel\Personnel;
|
|
|
|
use app\model\student_courses\StudentCourses;
|
|
|
|
/**
|
|
* 订单模型
|
|
* Class OrderTable
|
|
* @package app\model\order_table
|
|
*/
|
|
class OrderTable extends BaseModel
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
* 数据表主键
|
|
* @var string
|
|
*/
|
|
protected $pk = 'id';
|
|
|
|
/**
|
|
* 模型名称
|
|
* @var string
|
|
*/
|
|
protected $name = 'order_table';
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
* 搜索器:订单订单状态
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchOrderStatusAttr($query, $value, $data)
|
|
{
|
|
if ($value) {
|
|
$query->where("order_status", $value);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 搜索器:订单付款类型
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchPaymentTypeAttr($query, $value, $data)
|
|
{
|
|
if ($value) {
|
|
$query->where("payment_type", $value);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//客户资源表-客户姓名
|
|
public function customerResources(){
|
|
return $this->hasOne(CustomerResources::class, 'id', 'resource_id')->joinType('left')->withField('name,id')->bind(['resource_id_name'=>'name']);
|
|
}
|
|
|
|
//课程表-课程名称
|
|
public function course(){
|
|
return $this->hasOne(Course::class, 'id', 'course_id')->joinType('left')->withField('course_name,id')->bind(['course_id_name'=>'course_name']);
|
|
}
|
|
|
|
//班级表-班级名称
|
|
public function classGrade(){
|
|
return $this->hasOne(ClassGrade::class, 'id', 'class_id')->joinType('left')->withField('class_name,id')->bind(['class_id_name'=>'class_name']);
|
|
}
|
|
|
|
//员工表-员工姓名
|
|
public function personnel(){
|
|
return $this->hasOne(Personnel::class, 'id', 'staff_id')->joinType('left')->withField('name,id')->bind(['staff_id_name'=>'name']);
|
|
}
|
|
|
|
//学员课程表-课时信息
|
|
public function studentCourses(){
|
|
return $this->hasOne(StudentCourses::class, 'id', 'course_plan_id')->joinType('left')->withField('total_hours,gift_hours,use_total_hours,use_gift_hours')->bind(['total_hours'=>'total_hours','gift_hours'=>'gift_hours','use_total_hours'=>'use_total_hours','use_gift_hours'=>'use_gift_hours']);
|
|
}
|
|
|
|
}
|
|
|