|
|
@ -13,6 +13,7 @@ namespace app\model\customer_resources; |
|
|
|
|
|
|
|
|
use app\model\dict\Dict; |
|
|
use app\model\dict\Dict; |
|
|
use app\model\resource_sharing\ResourceSharing; |
|
|
use app\model\resource_sharing\ResourceSharing; |
|
|
|
|
|
use app\model\six_speed\SixSpeed; |
|
|
use core\base\BaseModel; |
|
|
use core\base\BaseModel; |
|
|
use think\model\concern\SoftDelete; |
|
|
use think\model\concern\SoftDelete; |
|
|
use think\model\relation\HasMany; |
|
|
use think\model\relation\HasMany; |
|
|
@ -85,6 +86,7 @@ class CustomerResources extends BaseModel |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取顾问名字 |
|
|
public function personnel(){ |
|
|
public function personnel(){ |
|
|
return $this->hasOne(Personnel::class, 'id', 'consultant')->joinType('left')->withField('name,id')->bind(['consultant_name'=>'name']); |
|
|
return $this->hasOne(Personnel::class, 'id', 'consultant')->joinType('left')->withField('name,id')->bind(['consultant_name'=>'name']); |
|
|
} |
|
|
} |
|
|
@ -100,6 +102,12 @@ class CustomerResources extends BaseModel |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//一对一关联six_speed模型 |
|
|
|
|
|
public function sixSpeed() |
|
|
|
|
|
{ |
|
|
|
|
|
return $this->hasOne(SixSpeed::class, 'resource_id', 'id'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取客户初步意向度类型名称 |
|
|
* 获取客户初步意向度类型名称 |
|
|
* @param $value |
|
|
* @param $value |
|
|
@ -108,13 +116,15 @@ class CustomerResources extends BaseModel |
|
|
*/ |
|
|
*/ |
|
|
public function getInitialIntentNameAttr($value, $data) |
|
|
public function getInitialIntentNameAttr($value, $data) |
|
|
{ |
|
|
{ |
|
|
if (isset($data['initial_intent']) && $data['initial_intent'] !== '') { |
|
|
$key = 'preliminarycustomerintention'; |
|
|
$dict = Dict::where('key','preliminarycustomerintention')->find(); |
|
|
$val = (String)$data['initial_intent']; |
|
|
|
|
|
if ((!empty($val) || isset($val)) && $val !== '') { |
|
|
|
|
|
$dict = Dict::where('key',$key)->find(); |
|
|
$dictionary = $dict['dictionary'] ?? []; |
|
|
$dictionary = $dict['dictionary'] ?? []; |
|
|
// 查找匹配的 name |
|
|
// 查找匹配的 name |
|
|
$res = ''; |
|
|
$res = ''; |
|
|
foreach ($dictionary as $item) { |
|
|
foreach ($dictionary as $item) { |
|
|
if ($item['value'] === $data['initial_intent']) { |
|
|
if ($item['value'] == $val) { |
|
|
$res = $item['name']; |
|
|
$res = $item['name']; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
@ -125,4 +135,148 @@ class CustomerResources extends BaseModel |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 获取来源渠道类型名称 |
|
|
|
|
|
* @param $value |
|
|
|
|
|
* @param $data |
|
|
|
|
|
* @return array|mixed|string |
|
|
|
|
|
*/ |
|
|
|
|
|
public function getSourceChannelNameAttr($value, $data) |
|
|
|
|
|
{ |
|
|
|
|
|
$key = 'SourceChannel'; |
|
|
|
|
|
$val = (String)$data['source_channel']; |
|
|
|
|
|
if ((!empty($val) || isset($val)) && $val !== '') { |
|
|
|
|
|
$dict = Dict::where('key',$key)->find(); |
|
|
|
|
|
$dictionary = $dict['dictionary'] ?? []; |
|
|
|
|
|
// 查找匹配的 name |
|
|
|
|
|
$res = ''; |
|
|
|
|
|
$arr = [ |
|
|
|
|
|
"name" => "线下", |
|
|
|
|
|
"value" => "0", |
|
|
|
|
|
"sort" => 0, |
|
|
|
|
|
"memo" => "", |
|
|
|
|
|
]; |
|
|
|
|
|
array_unshift($dictionary, $arr); |
|
|
|
|
|
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 getSourceNameAttr($value, $data) |
|
|
|
|
|
{ |
|
|
|
|
|
$key = 'source'; |
|
|
|
|
|
$val = (String)$data['source']; |
|
|
|
|
|
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 getGenderNameAttr($value, $data) |
|
|
|
|
|
{ |
|
|
|
|
|
$key = 'zy_sex'; |
|
|
|
|
|
$val = (String)$data['gender']; |
|
|
|
|
|
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 getPurchasingPowerNameAttr($value, $data) |
|
|
|
|
|
{ |
|
|
|
|
|
$key = 'customer_purchasing_power'; |
|
|
|
|
|
$val = (String)$data['purchasing_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 getStatusNameAttr($value, $data) |
|
|
|
|
|
{ |
|
|
|
|
|
$key = 'kh_status'; |
|
|
|
|
|
$val = (String)$data['status']; |
|
|
|
|
|
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 ''; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|