@ -246,14 +246,14 @@ class PoolCommand extends Command
* @since 2021-04-01
* @since 2021-04-01
* @author fanqi
* @author fanqi
*/
*/
private function getFollowUpQueryResult($type, $levels, $dealStatus, $businessStatus)
private function getFollowUpQueryResult($type, $levels, $dealStatus, $businessStatus, $customerType)
{
{
# 转换格式
# 转换格式
$levels = json_decode($levels, true);
$levels = json_decode($levels, true);
# 默认条件
# 默认条件
$where = "`customer`.`owner_user_id` > 0";
$where = "`customer`.`owner_user_id` > 0";
# 所有用户,不区分级别
# 所有用户,不区分级别
if ($type == 1) {
if ($type == 1) {
foreach ($levels as $k1 => $v1) {
foreach ($levels as $k1 => $v1) {
@ -263,7 +263,7 @@ class PoolCommand extends Command
}
}
}
}
}
}
# 根据用户级别设置条件
# 根据用户级别设置条件
if ($type == 2) {
if ($type == 2) {
foreach ($levels as $k1 => $v1) {
foreach ($levels as $k1 => $v1) {
@ -276,29 +276,35 @@ class PoolCommand extends Command
}
}
}
}
}
}
# 获取最小天数,对于没有设置级别的客户数据使用
# 获取最小天数,对于没有设置级别的客户数据使用
$minLimit = $this->getMinDay($levels);
$minLimit = $this->getMinDay($levels);
$minTime = (time() - 24 * 60 * 60 * $minLimit);
$minTime = (time() - 24 * 60 * 60 * $minLimit);
$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`))) )";
$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`))) )";
}
}
# 选择不进入公海的客户(已成交客户)
# 选择不进入公海的客户(已成交客户)
if (!empty($dealStatus)) $where .= " AND (`customer`.`deal_status` <> '已成交' OR ISNULL(`customer`.`deal_status`))";
if (!empty($dealStatus)) $where .= " AND (`customer`.`deal_status` <> '已成交' OR ISNULL(`customer`.`deal_status`))";
# 选择不进入公海的客户(有商机客户)
# 选择不进入公海的客户(有商机客户)
if (!empty($businessStatus)) $where .= " AND ISNULL(`business`.`customer_id`)";
if (!empty($businessStatus)) $where .= " AND ISNULL(`business`.`customer_id`)";
# 锁定的客户不提醒
# 锁定的客户不提醒
$where .= " AND `customer`.`is_lock` = 0";
$where .= " AND `customer`.`is_lock` = 0";
# 过滤客户类型
if (!empty($customerType)) {
$where .= "And `customer`.`customer_type` in " . $customerType;
@ -309,14 +315,14 @@ class PoolCommand extends Command
* @since 2021-04-01
* @since 2021-04-01
* @author fanqi
* @author fanqi
*/
*/
private function getBusinessQueryResult($type, $levels, $dealStatus)
private function getBusinessQueryResult($type, $levels, $dealStatus, $customerType)
{
{
# 转换格式
# 转换格式
$levels = json_decode($levels, true);
$levels = json_decode($levels, true);
# 默认条件
# 默认条件
$where = "`customer`.`owner_user_id` > 0";
$where = "`customer`.`owner_user_id` > 0";
# 所有用户,不区分级别
# 所有用户,不区分级别
if ($type == 1) {
if ($type == 1) {
foreach ($levels as $k1 => $v1) {
foreach ($levels as $k1 => $v1) {
@ -326,7 +332,7 @@ class PoolCommand extends Command
}
}
}
}
}
}
# 根据用户级别设置条件
# 根据用户级别设置条件
if ($type == 2) {
if ($type == 2) {
foreach ($levels as $k1 => $v1) {
foreach ($levels as $k1 => $v1) {
@ -339,26 +345,30 @@ class PoolCommand extends Command
}
}
}
}
}
}
# 获取最小天数,对于没有设置级别的客户数据使用
# 获取最小天数,对于没有设置级别的客户数据使用
$minLimit = $this->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 !`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`)) )";
$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`)) )";
}
}
# 选择不进入公海的客户(已成交客户)
# 选择不进入公海的客户(已成交客户)
if (!empty($dealStatus)) $where .= " AND (`customer`.`deal_status` <> '已成交' OR ISNULL(`customer`.`deal_status`))";
if (!empty($dealStatus)) $where .= " AND (`customer`.`deal_status` <> '已成交' OR ISNULL(`customer`.`deal_status`))";
# 锁定的客户不提醒
# 锁定的客户不提醒
$where .= " AND `customer`.`is_lock` = 0";
$where .= " AND `customer`.`is_lock` = 0";
# 过滤客户类型
if (!empty($customerType)) {
$where .= "And `customer`.`customer_type` in " . $customerType;
@ -369,14 +379,14 @@ class PoolCommand extends Command
* @since 2021-04-01
* @since 2021-04-01
* @author fanqi
* @author fanqi
*/
*/
private function getDealQueryResult($type, $levels, $businessStatus)
private function getDealQueryResult($type, $levels, $businessStatus, $customerType)
{
{
# 转换格式
# 转换格式
$levels = json_decode($levels, true);
$levels = json_decode($levels, true);
# 默认条件
# 默认条件
$where = "`customer`.`owner_user_id` > 0";
$where = "`customer`.`owner_user_id` > 0";
# 所有用户,不区分级别
# 所有用户,不区分级别
if ($type == 1) {
if ($type == 1) {
foreach ($levels as $k1 => $v1) {
foreach ($levels as $k1 => $v1) {
@ -386,7 +396,7 @@ class PoolCommand extends Command
}
}
}
}
}
}
# 根据用户级别设置条件
# 根据用户级别设置条件
if ($type == 2) {
if ($type == 2) {
foreach ($levels as $k1 => $v1) {
foreach ($levels as $k1 => $v1) {
@ -399,27 +409,31 @@ class PoolCommand extends Command
}
}
}
}
}
}
# 获取最小天数,对于没有设置级别的客户数据使用
# 获取最小天数,对于没有设置级别的客户数据使用
$minLimit = $this->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 !`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`)) )";
$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`)) )";
}
}
# 选择不进入公海的客户(有商机客户)
# 选择不进入公海的客户(有商机客户)
if (!empty($businessStatus)) $where .= " AND ISNULL(`business`.`customer_id`)";
if (!empty($businessStatus)) $where .= " AND ISNULL(`business`.`customer_id`)";
# 锁定的客户不提醒
# 锁定的客户不提醒
$where .= " AND `customer`.`is_lock` = 0";
$where .= " AND `customer`.`is_lock` = 0";
# 过滤客户类型
if (!empty($customerType)) {
$where .= "And `customer`.`customer_type` in " . $customerType;