if ($v['type'] == 3) $result[$v['pool_id']] = array_merge($result[$v['pool_id']], $this->getDealQueryResult($v['level_conf'], $v['level'], $v['business_handle']));
}
}
return $result;
return $result;
@ -250,7 +246,7 @@ class PoolCommand extends Command
* @since 2021-04-01
* @since 2021-04-01
* @author fanqi
* @author fanqi
*/
*/
private function getFollowUpQueryResult($type, $levels, $dealStatus, $businessStatus, $customerType)
private function getFollowUpQueryResult($type, $levels, $dealStatus, $businessStatus)
{
{
# 转换格式
# 转换格式
$levels = json_decode($levels, true);
$levels = json_decode($levels, true);
@ -282,10 +278,10 @@ class PoolCommand extends Command
}
}
# 获取最小天数,对于没有设置级别的客户数据使用
# 获取最小天数,对于没有设置级别的客户数据使用
$minLimit = PoolCommand::getMinDay($levels);
$minLimit = $this->getMinDay($levels);
$minTime = (time() - 24 * 60 * 60 * $minLimit);
$minTime = (time() - 24 * 60 * 60 * $minLimit);
$where .= " OR ((ISNULL(`customer`.`level`) AND `customer`.`last_time` < " . $minTime . " AND `customer`.`last_time` > `customer`.`obtain_time`) OR (ISNULL(`customer`.`level`) AND `customer`.`obtain_time` < " . $minTime . " AND `customer`.`obtain_time` > `customer`.`last_time`) OR (ISNULL(`customer`.`level`) AND `customer`.`obtain_time` < " . $minTime . " AND ISNULL(`customer`.`last_time`))) )";
$where .= " OR ((!`customer`.`level` AND `customer`.`last_time` < " . $minTime . " AND `customer`.`last_time` > `customer`.`obtain_time`) OR (!`customer`.`level` AND `customer`.`obtain_time` < " . $minTime . " AND `customer`.`obtain_time` > `customer`.`last_time`) OR (!`customer`.`level` AND `customer`.`obtain_time` < " . $minTime . " AND ISNULL(`customer`.`last_time`))) )";
}
}
# 选择不进入公海的客户(已成交客户)
# 选择不进入公海的客户(已成交客户)
@ -300,7 +296,7 @@ class PoolCommand extends Command
@ -313,7 +309,7 @@ class PoolCommand extends Command
* @since 2021-04-01
* @since 2021-04-01
* @author fanqi
* @author fanqi
*/
*/
private function getBusinessQueryResult($type, $levels, $dealStatus, $customerType)
private function getBusinessQueryResult($type, $levels, $dealStatus)
{
{
# 转换格式
# 转换格式
$levels = json_decode($levels, true);
$levels = json_decode($levels, true);
@ -345,10 +341,10 @@ class PoolCommand extends Command
}
}
# 获取最小天数,对于没有设置级别的客户数据使用
# 获取最小天数,对于没有设置级别的客户数据使用
$minLimit = PoolCommand::getMinDay($levels);
$minLimit = $this->getMinDay($levels);
$minTime = (time() - 24 * 60 * 60 * $minLimit);
$minTime = (time() - 24 * 60 * 60 * $minLimit);
$where .= " OR ((ISNULL(`business`.`customer_id`) AND `customer`.`obtain_time` < " . $minTime . " AND ISNULL(`customer`.`level`)) OR (`customer`.`obtain_time` < " . $minTime . " AND `customer`.`obtain_time` > `business`.`create_time` AND ISNULL(`customer`.`level`)) OR (`business`.`create_time` < " . $minTime . " AND `business`.`create_time` > `customer`.`obtain_time` AND ISNULL(`customer`.`level`))) )";
$where .= " OR ((ISNULL(`business`.`customer_id`) AND `customer`.`obtain_time` < " . $minTime . " AND !`customer`.`level`) OR (`customer`.`obtain_time` < " . $minTime . " AND `customer`.`obtain_time` > `business`.`create_time` AND !`customer`.`level`) OR (`business`.`create_time` < " . $minTime . " AND `business`.`create_time` > `customer`.`obtain_time` AND !`customer`.`level`)) )";
}
}
# 选择不进入公海的客户(已成交客户)
# 选择不进入公海的客户(已成交客户)
@ -360,7 +356,7 @@ class PoolCommand extends Command
@ -373,7 +369,7 @@ class PoolCommand extends Command
* @since 2021-04-01
* @since 2021-04-01
* @author fanqi
* @author fanqi
*/
*/
private function getDealQueryResult($type, $levels, $businessStatus, $customerType)
private function getDealQueryResult($type, $levels, $businessStatus)
{
{
# 转换格式
# 转换格式
$levels = json_decode($levels, true);
$levels = json_decode($levels, true);
@ -405,10 +401,10 @@ class PoolCommand extends Command
}
}
# 获取最小天数,对于没有设置级别的客户数据使用
# 获取最小天数,对于没有设置级别的客户数据使用
$minLimit = PoolCommand::getMinDay($levels);
$minLimit = $this->getMinDay($levels);
$minTime = (time() - 24 * 60 * 60 * $minLimit);
$minTime = (time() - 24 * 60 * 60 * $minLimit);
$where .= " OR ((ISNULL(`contract`.`customer_id`) AND `customer`.`obtain_time` < " . $minTime . " AND ISNULL(`customer`.`level`)) OR (`customer`.`obtain_time` < " . $minTime . " AND `customer`.`obtain_time` > `contract`.`create_time` AND ISNULL(`customer`.`level`)) OR (`contract`.`create_time` < " . $minTime . " AND `contract`.`create_time` > `customer`.`obtain_time` AND ISNULL(`customer`.`level`))) )";
$where .= " OR ((ISNULL(`contract`.`customer_id`) AND `customer`.`obtain_time` < " . $minTime . " AND !`customer`.`level`) OR (`customer`.`obtain_time` < " . $minTime . " AND `customer`.`obtain_time` > `contract`.`create_time` AND !`customer`.`level`) OR (`contract`.`create_time` < " . $minTime . " AND `contract`.`create_time` > `customer`.`obtain_time` AND !`customer`.`level`)) )";
}
}
# 选择不进入公海的客户(有商机客户)
# 选择不进入公海的客户(有商机客户)
@ -421,7 +417,7 @@ class PoolCommand extends Command
$where .= " AND ((`customer`.`last_time` > ".$time." AND `customer`.`last_time` > `customer`.`obtain_time`) OR (`customer`.`obtain_time` > ".$time." AND `customer`.`obtain_time` > `customer`.`last_time`) OR (`customer`.`obtain_time` > ".$time." AND ISNULL(`customer`.`last_time`)))";
$where .= " AND ((`customer`.`last_time` > ".$time." AND `customer`.`last_time` > `customer`.`obtain_time`) OR (`customer`.`obtain_time` > ".$time." AND `customer`.`obtain_time` > `customer`.`last_time`) OR (`customer`.`obtain_time` > ".$time." AND ISNULL(`customer`.`last_time`)))";
@ -1090,7 +1084,7 @@ class Customer extends Common
# 根据用户级别设置条件
# 根据用户级别设置条件
if ($type == 2) {
if ($type == 2) {
foreach ($levels as $k1 => $v1) {
foreach ($levels AS $k1 => $v1) {
if (!empty($v1['level']) && !empty($v1['limit_day'])) {
if (!empty($v1['level']) && !empty($v1['limit_day'])) {
$where .= " OR ((ISNULL(`customer`.`level`) AND `customer`.`last_time` > " . $minTime . " AND `customer`.`last_time` > `customer`.`obtain_time`) OR (ISNULL(`customer`.`level`) AND `customer`.`obtain_time` > " . $time . " AND `customer`.`obtain_time` > `customer`.`last_time`) OR (ISNULL(`customer`.`level`) AND `customer`.`obtain_time` > " . $minTime . " AND ISNULL(`customer`.`last_time`))) )";
$where .= " OR ((!`customer`.`level` AND `customer`.`last_time` > ".$minTime." AND `customer`.`last_time` > `customer`.`obtain_time`) OR (!`customer`.`level` AND `customer`.`obtain_time` > ".$time." AND `customer`.`obtain_time` > `customer`.`last_time`) OR (!`customer`.`level` AND `customer`.`obtain_time` > ".$minTime." AND ISNULL(`customer`.`last_time`))) )";
}
}
# 选择不进入公海的客户(已成交客户)
# 选择不进入公海的客户(已成交客户)
@ -1129,10 +1123,10 @@ class Customer extends Common
$where .= " AND ( (ISNULL(`business`.`customer_id`) AND `customer`.`obtain_time` > ".$time.") OR (`customer`.`obtain_time` > ".$time." AND `customer`.`obtain_time` > `business`.`create_time`) OR (`business`.`create_time` > ".$time." AND `business`.`create_time` > `customer`.`obtain_time`) )";
$where .= " AND ( (ISNULL(`business`.`customer_id`) AND `customer`.`obtain_time` > ".$time.") OR (`customer`.`obtain_time` > ".$time." AND `customer`.`obtain_time` > `business`.`create_time`) OR (`business`.`create_time` > ".$time." AND `business`.`create_time` > `customer`.`obtain_time`) )";
@ -1202,7 +1196,7 @@ class Customer extends Common
# 根据用户级别设置条件
# 根据用户级别设置条件
if ($type == 2) {
if ($type == 2) {
foreach ($levels as $k1 => $v1) {
foreach ($levels AS $k1 => $v1) {
if (!empty($v1['level']) && !empty($v1['limit_day'])) {
if (!empty($v1['level']) && !empty($v1['limit_day'])) {
$where .= " OR ((ISNULL(`business`.`customer_id`) AND `customer`.`obtain_time` > " . $minTime . " AND ISNULL(`customer`.`level`)) OR (`customer`.`obtain_time` > " . $minTime . " AND `customer`.`obtain_time` > `business`.`create_time` AND ISNULL(`customer`.`level`)) OR (`business`.`create_time` > " . $minTime . " AND `business`.`create_time` > `customer`.`obtain_time` AND ISNULL(`customer`.`level`))) )";
$where .= " OR ((ISNULL(`business`.`customer_id`) AND `customer`.`obtain_time` > ".$minTime." AND !`customer`.`level`) OR (`customer`.`obtain_time` > ".$minTime." AND `customer`.`obtain_time` > `business`.`create_time` AND !`customer`.`level`) OR (`business`.`create_time` > ".$minTime." AND `business`.`create_time` > `customer`.`obtain_time` AND !`customer`.`level`)) )";
}
}
# 选择不进入公海的客户(已成交客户)
# 选择不进入公海的客户(已成交客户)
@ -1238,10 +1232,10 @@ class Customer extends Common
$data = db('crm_customer')->alias('customer')
$data = db('crm_customer')->alias('customer')
->field(['customer.customer_id', 'customer.obtain_time AS customer_time', 'customer.level', 'business.create_time AS business_time'])
->field(['customer.customer_id', 'customer.obtain_time AS customer_time', 'customer.level', 'business.create_time AS business_time'])
$where .= " AND ( (ISNULL(`contract`.`customer_id`) AND `customer`.`obtain_time` > ".$time.") OR (`customer`.`obtain_time` > ".$time." AND `customer`.`obtain_time` > `contract`.`create_time`) OR (`contract`.`create_time` > ".$time." AND `contract`.`create_time` > `customer`.`obtain_time`) )";
$where .= " AND ( (ISNULL(`contract`.`customer_id`) AND `customer`.`obtain_time` > ".$time.") OR (`customer`.`obtain_time` > ".$time." AND `customer`.`obtain_time` > `contract`.`create_time`) OR (`contract`.`create_time` > ".$time." AND `contract`.`create_time` > `customer`.`obtain_time`) )";
@ -1311,7 +1305,7 @@ class Customer extends Common
# 根据用户级别设置条件
# 根据用户级别设置条件
if ($type == 2) {
if ($type == 2) {
foreach ($levels as $k1 => $v1) {
foreach ($levels AS $k1 => $v1) {
if (!empty($v1['level']) && !empty($v1['limit_day'])) {
if (!empty($v1['level']) && !empty($v1['limit_day'])) {
$where .= " OR ((ISNULL(`contract`.`customer_id`) AND ISNULL(`customer`.`level`) AND `customer`.`obtain_time` > " . $minTime . ") OR (ISNULL(`customer`.`level`) AND `customer`.`obtain_time` > " . $minTime . " AND `customer`.`obtain_time` > `contract`.`create_time`) OR (`contract`.`create_time` > ".$minTime." AND `contract`.`create_time` > `customer`.`obtain_time` AND ISNULL(`customer`.`level`))) )";
$where .= " OR ((ISNULL(`contract`.`customer_id`) AND !`customer`.`level` AND `customer`.`obtain_time` > ".$minTime.") OR (!`customer`.`level` AND `customer`.`obtain_time` > ".$minTime." AND `customer`.`obtain_time` > `contract`.`create_time`) OR (`contract`.`create_time` > ".$minTime." AND `contract`.`create_time` > `customer`.`obtain_time` AND !`customer`.`level`)) )";
}
}
# 选择不进入公海的客户(有商机客户)
# 选择不进入公海的客户(有商机客户)
@ -1348,10 +1342,10 @@ class Customer extends Common
->field(['customer.customer_id', 'customer.obtain_time AS customer_time', 'customer.level', 'contract.create_time AS contract_time'])
->field(['customer.customer_id', 'customer.obtain_time AS customer_time', 'customer.level', 'contract.create_time AS contract_time'])
'a.customer_check_id as catagory_id ,customer.name as customer_name,a.create_time,a.check_status,a.user_id,a.check_user_id,a.flow_user_id,user.realname,examine_flow.name as examine_name'