From f8d8e0f63bcdfded26c644bc8e2295c3d3bcbfc1 Mon Sep 17 00:00:00 2001 From: dengbw Date: Tue, 18 Oct 2022 11:52:15 +0800 Subject: [PATCH] user_10118 --- api/controllers/wxapp/licheb/Customers.php | 11 +++-- api/controllers/wxapp/licheb/User.php | 52 +++++++++------------- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index 1ad1cc8f..158f5ca1 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -945,12 +945,17 @@ class Customers extends Wxapp $s_c_time = strtotime($s_c_time); $e_c_time = strtotime($e_c_time); $where = ['biz_id' => $this->biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1]; + $str_uids = ''; if ($group_id == 1) { - $where['admin_id'] = $this->myuid; - $where["id in(select customer_id from lc_receiver_customer_oplogs where type={$oplogs_type} and c_time>={$s_c_time} and c_time<={$e_c_time} and uid={$this->myuid})"] = null; + $str_uids = $this->myuid; } else { - $where["id in(select customer_id from lc_receiver_customer_oplogs where type={$oplogs_type} and c_time>={$s_c_time} and c_time<={$e_c_time})"] = null; + $res_user = $this->app_user_model->select(['biz_id' => $this->biz_id, 'group_id <' => 4, 'status' => 1], 'id asc', 0, 0, 'id,userid'); + foreach ($res_user as $k => $v) { + $str_uids = $str_uids ? $str_uids . ',' . $v['id'] : $v['id']; + } } + !$str_uids && $str_uids = '-1'; + $where["id in(select customer_id from lc_receiver_customer_oplogs where type={$oplogs_type} and uid in({$str_uids}) and c_time>={$s_c_time} and c_time<={$e_c_time})"] = null; $count = $this->customers_model->count($where); } } diff --git a/api/controllers/wxapp/licheb/User.php b/api/controllers/wxapp/licheb/User.php index 3fb60b49..a1e9700e 100644 --- a/api/controllers/wxapp/licheb/User.php +++ b/api/controllers/wxapp/licheb/User.php @@ -321,6 +321,19 @@ class User extends Wxapp ]; $wl_num = $this->mdCustomerVisitData->count_visit(array_merge($where_v, ['b.status<>' => 2])); //数据统计 + $str_uids = $str_userids = ''; + if ($group_id == 1) { + $str_uids = $uid; + $str_userids = $this->session['userid']; + } else { + $res_user = $this->app_user_model->select(['biz_id' => $biz_id, 'group_id <' => 4, 'status' => 1], 'id asc', 0, 0, 'id,userid'); + foreach ($res_user as $k => $v) { + $str_uids = $str_uids ? $str_uids . ',' . $v['id'] : $v['id']; + $v['userid'] && $str_userids = $str_userids ? $str_userids . "','" . $v['userid'] : $v['userid']; + } + } + !$str_uids && $str_uids = '-1'; + !$str_userids && $str_userids = '-1'; $this->load->model('receiver/receiver_customer_oplogs_model', 'mdCustomerOpLogs'); $s_today = date('Y-m-d') . ' 00:00:00'; $e_today = date('Y-m-d') . ' 23:59:59'; @@ -334,41 +347,27 @@ class User extends Wxapp $where_month_qy = ['change_type' => 'add_external_contact', 'c_time>=' => strtotime($s_month), 'c_time<=' => strtotime($e_month)]; //到店 $where_today_dd = ['biz_id' => $biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1, - "id in(select customer_id from lc_receiver_customer_oplogs where type=4 and c_time>=" . strtotime($s_today) . " and c_time<=" . strtotime($e_today) . ")" => null]; + "id in(select customer_id from lc_receiver_customer_oplogs where type=4 and uid in({$str_uids}) and c_time>=" . strtotime($s_today) . " and c_time<=" . strtotime($e_today) . ")" => null]; $where_month_dd = ['biz_id' => $biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1, - "id in(select customer_id from lc_receiver_customer_oplogs where type=4 and c_time>=" . strtotime($s_month) . " and c_time<=" . strtotime($e_month) . ")" => null]; + "id in(select customer_id from lc_receiver_customer_oplogs where type=4 and uid in({$str_uids}) and c_time>=" . strtotime($s_month) . " and c_time<=" . strtotime($e_month) . ")" => null]; //订单 $where_today_order = ['status>=' => 0, 'order_time>=' => $s_today, 'order_time<=' => $e_today]; $where_month_order = ['status>=' => 0, 'order_time>=' => $s_month, 'order_time<=' => $e_month]; //战败 $where_today_defeat = ['biz_id' => $biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1, - "id in(select customer_id from lc_receiver_customer_oplogs where type=7 and c_time>=" . strtotime($s_today) . " and c_time<=" . strtotime($e_today) . ")" => null]; + "id in(select customer_id from lc_receiver_customer_oplogs where type=7 and uid in({$str_uids}) and c_time>=" . strtotime($s_today) . " and c_time<=" . strtotime($e_today) . ")" => null]; $where_month_defeat = ['biz_id' => $biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1, - "id in(select customer_id from lc_receiver_customer_oplogs where type=7 and c_time>=" . strtotime($s_month) . " and c_time<=" . strtotime($e_month) . ")" => null]; + "id in(select customer_id from lc_receiver_customer_oplogs where type=7 and uid in({$str_uids}) and c_time>=" . strtotime($s_month) . " and c_time<=" . strtotime($e_month) . ")" => null]; //退订 $where_today_refund = ['status' => 2, 'refund_time>=' => $s_today, 'refund_time<=' => $e_today]; $where_month_refund = ['status' => 2, 'refund_time>=' => $s_month, 'refund_time<=' => $e_month]; if ($group_id == 1) { $where_today_xs['admin_id'] = $uid; $where_month_xs['admin_id'] = $uid; - $where_today_dd = ['biz_id' => $biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1, - "id in(select customer_id from lc_receiver_customer_oplogs where type=4 and uid={$uid} and c_time>=" . strtotime($s_today) . " and c_time<=" . strtotime($e_today) . ")" => null]; - $where_month_dd = ['biz_id' => $biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1, - "id in(select customer_id from lc_receiver_customer_oplogs where type=4 and uid={$uid} and c_time>=" . strtotime($s_month) . " and c_time<=" . strtotime($e_month) . ")" => null]; $where_today_order['admin_id'] = $uid; $where_month_order['admin_id'] = $uid; - $where_today_defeat = ['biz_id' => $biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1, - "id in(select customer_id from lc_receiver_customer_oplogs where type=7 and uid={$uid} and c_time>=" . strtotime($s_today) . " and c_time<=" . strtotime($e_today) . ")" => null]; - $where_month_defeat = ['biz_id' => $biz_id, 'status>=' => 0, 'cs_biz_id<>' => -1, - "id in(select customer_id from lc_receiver_customer_oplogs where type=7 and uid={$uid} and c_time>=" . strtotime($s_month) . " and c_time<=" . strtotime($e_month) . ")" => null]; $where_today_refund['admin_id'] = $uid; $where_month_refund['admin_id'] = $uid; - if ($this->session['userid']) { - $where_today_qy['userid'] = $this->session['userid']; - $where_month_qy['userid'] = $this->session['userid']; - } else { - $where_today_qy = ''; - } } else if ($group_id == 2 || $group_id == 3) {//店长/老板 $where_today_order["(biz_id = {$biz_id} OR admin_id = {$uid})"] = null; $where_month_order["(biz_id = {$biz_id} OR admin_id = {$uid})"] = null; @@ -386,18 +385,10 @@ class User extends Wxapp $where_month_refund['brand_id<>'] = 3; } } - if ($group_id != 1) { - $res_user = $this->app_user_model->select(['biz_id' => $biz_id, 'group_id <' => 4, 'status' => 1, 'userid<>' => ''], 'id asc', 0, 0, 'userid'); - if ($res_user) { - $str_userids = implode("','", array_column($res_user, 'userid')); - $where_today_qy["userid in('{$str_userids}')"] = null; - $where_month_qy["userid in('{$str_userids}')"] = null; - } else { - $where_today_qy = ''; - } - } $today_qy = $month_qy = 0; - if ($where_today_qy) { + if ($str_userids) { + $where_today_qy["userid in('{$str_userids}')"] = null; + $where_month_qy["userid in('{$str_userids}')"] = null; $re_biz = $this->biz_model->get(['id' => $biz_id]); if ($re_biz['type'] == 5) {//异业店 $this->load->model('app/app_different_qy_log_model', 'mdDifferentQyLog'); @@ -432,7 +423,8 @@ class User extends Wxapp 'customer_op_list' => $customer_op_list, 'levelSt' => $levelSt, 'where_today_qy' => $where_today_qy, - 'statistics' => $statistics + 'statistics' => $statistics, + 'str_uids' => $str_uids ]; return $data; }