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.
145 lines
4.1 KiB
145 lines
4.1 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\model\six_speed;
|
|
|
|
use app\model\dict\Dict;
|
|
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\customer_resources\CustomerResources;
|
|
|
|
/**
|
|
* 六一速模型
|
|
* Class SixSpeed
|
|
* @package app\model\six_speed
|
|
*/
|
|
class SixSpeed extends BaseModel
|
|
{
|
|
|
|
use SoftDelete;
|
|
|
|
/**
|
|
* 数据表主键
|
|
* @var string
|
|
*/
|
|
protected $pk = 'id';
|
|
|
|
/**
|
|
* 模型名称
|
|
* @var string
|
|
*/
|
|
protected $name = 'six_speed';
|
|
|
|
/**
|
|
* 定义软删除标记字段.
|
|
* @var string
|
|
*/
|
|
protected $deleteTime = 'deleted_at';
|
|
|
|
/**
|
|
* 定义软删除字段的默认值.
|
|
* @var int
|
|
*/
|
|
protected $defaultSoftDelete = 0;
|
|
|
|
|
|
|
|
//定义一个常量数组-字段中文映射
|
|
const FieldZh = [
|
|
'id' => '编号',
|
|
'purchase_power' => '需求购买力',
|
|
'concept_awareness' => '认知理念',
|
|
'preferred_class_time' => '可选上课时间',
|
|
'distance' => '距离',
|
|
'communication' => '沟通备注',
|
|
'promised_visit_time' => '承诺到访时间',
|
|
'actual_visit_time' => '实际到访时间',
|
|
'call_intent' => '电话后的意向程度',
|
|
'first_visit_status' => '一访情况',
|
|
'second_visit_status' => '二访情况',
|
|
'is_closed' => '是否关单',
|
|
'staff_id' => '人员ID',
|
|
'resource_id' => '资源ID',
|
|
'created_at' => '创建时间',
|
|
'updated_at' => '更新时间',
|
|
'deleted_at' => '逻辑删除时间'
|
|
];
|
|
|
|
|
|
public function personnel(){
|
|
return $this->hasOne(Personnel::class, 'id', 'staff_id')->joinType('left')->withField('name,id')->bind(['staff_id_name'=>'name']);
|
|
}
|
|
|
|
public function customerResources(){
|
|
return $this->hasOne(CustomerResources::class, 'id', 'resource_id')->joinType('left')->withField('name,id')->bind(['resource_id_name'=>'name']);
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取需求购买力类型名称
|
|
* @param $value
|
|
* @param $data
|
|
* @return array|mixed|string
|
|
*/
|
|
public function getPurchasePowerNameAttr($value, $data)
|
|
{
|
|
$key = 'customer_purchasing_power';
|
|
$val = (String)$data['purchase_power'];
|
|
if ((!empty($val) || isset($val)) && $val !== '') {
|
|
$dict = Dict::where('key',$key)->find();
|
|
$dictionary = $dict['dictionary'] ?? [];
|
|
// 查找匹配的 name
|
|
$res = '';
|
|
foreach ($dictionary as $item) {
|
|
if ($item['value'] == $val) {
|
|
$res = $item['name'];
|
|
break;
|
|
}
|
|
}
|
|
return $res;
|
|
} else {
|
|
return '';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取认知理念类型名称
|
|
* @param $value
|
|
* @param $data
|
|
* @return array|mixed|string
|
|
*/
|
|
public function getConceptAwarenessNameAttr($value, $data)
|
|
{
|
|
$key = 'customer_purchasing_power';
|
|
$val = (String)$data['concept_awareness'];
|
|
if ((!empty($val) || isset($val)) && $val !== '') {
|
|
$dict = Dict::where('key',$key)->find();
|
|
$dictionary = $dict['dictionary'] ?? [];
|
|
// 查找匹配的 name
|
|
$res = '';
|
|
foreach ($dictionary as $item) {
|
|
if ($item['value'] == $val) {
|
|
$res = $item['name'];
|
|
break;
|
|
}
|
|
}
|
|
return $res;
|
|
} else {
|
|
return '';
|
|
}
|
|
}
|
|
|
|
}
|
|
|