客户与跟进

This commit is contained in:
2025-03-14 14:27:33 +08:00
parent 0b95eb8bf0
commit 2dc378734f
23 changed files with 1102 additions and 22 deletions
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace app\model;
use support\Model;
class Area extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'area';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
}
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace app\model;
use support\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class CarType extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'car_type';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
public static function getAll()
{
$list = CarType::get()->select('id','name','status')->where('status',0)->toArray();
return $list;
}
}
+46 -2
View File
@@ -3,7 +3,10 @@
namespace app\model;
use Illuminate\Database\Eloquent\Model;
use app\util\Util;
use config\constants\Constants;
use support\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Customer extends Model
{
@@ -21,10 +24,51 @@ class Customer extends Model
*/
protected $primaryKey = 'id';
//设置黑名单
protected $guarded = ['id','created_at','updated_at'];
// 指定日期字段存储格式为时间戳
protected $dateFormat = 'U';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;
public $timestamps = true;
protected $casts = [
// 'updated_at' => 'datetime:Y-m-d H:i:s', // 指定序列化格式
// 'created_at' => 'datetime:Y-m-d H:i:s', // 指定序列化格式
'updated_at' => 'timestamp', // 指定序列化格式
'created_at' => 'timestamp', // 指定序列化格式
];
public static function getCustomer($customer)
{
$customer['grade_txt'] = Constants::GRADE[$customer['grade']];
$customer['magnitude_txt'] = Constants::MAGNITUDE[$customer['magnitude']];
if ($customer['grade']<=2) {
$customer['follow'] = 0;
$customer['follow_txt'] = '跟进中';
}elseif ($customer['grade']<=5) {
$customer['follow'] = 1;
$customer['follow_txt'] = '已成交';
}else{
$customer['follow'] = 2;
$customer['follow_txt'] = '已流失';
}
$where = [
'customer_id' => $customer['id']
];
$begin_follow = Follow::select('id','created_at','updated_at')
->where($where)
->min('created_at');
$customer['begin_follow'] = $begin_follow;
// $customer['last_follow'] = $last_follow;
return $customer;
}
}
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace app\model;
use config\constants\Constants;
use support\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Follow extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'follow';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
//设置黑名单
protected $guarded = ['id','created_at','updated_at'];
// 指定日期字段存储格式为时间戳
protected $dateFormat = 'U';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $casts = [
// 'updated_at' => 'datetime:Y-m-d H:i:s', // 指定序列化格式
// 'created_at' => 'datetime:Y-m-d H:i:s', // 指定序列化格式
'updated_at' => 'timestamp', // 指定序列化格式
'created_at' => 'timestamp', // 指定序列化格式
];
public static function getFollow($follow)
{
$follow['type_txt'] = Constants::FOLLOW[$follow['type']];
return $follow;
}
}
+40
View File
@@ -0,0 +1,40 @@
<?php
namespace app\model;
use support\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class User extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'user';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
public static function getUser($userId)
{
$user = User::first()->select(['id','name','sex','role','avatar','email','password'])
->where('status',0)
->toArray();
return $user;
}
}