2020-11-22 11:09:33 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\manager\controller;
|
|
|
|
|
|
2020-11-23 17:00:11 +08:00
|
|
|
use app\manager\model\Manager;
|
2020-11-22 11:09:33 +08:00
|
|
|
use app\manager\model\ProductOrder;
|
|
|
|
|
use app\manager\model\User;
|
|
|
|
|
use fastphp\base\Controller;
|
2024-03-22 11:17:35 +08:00
|
|
|
use app\manager\model\FollowRecord;
|
2020-11-22 11:09:33 +08:00
|
|
|
|
|
|
|
|
class SellInfo extends Controller
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @description: 获取单个客户经理的销售信息
|
|
|
|
|
* @param {*}
|
|
|
|
|
* @return {*}
|
|
|
|
|
*/
|
|
|
|
|
public function getOne()
|
|
|
|
|
{
|
2023-08-26 14:07:30 +08:00
|
|
|
ini_set('display_errors', 'Off');
|
2020-11-22 11:09:33 +08:00
|
|
|
$user_model = new User;
|
|
|
|
|
$manager_model = new Manager;
|
|
|
|
|
$product_order_model = new ProductOrder;
|
2024-03-22 11:17:35 +08:00
|
|
|
$follow_record_model = new FollowRecord;
|
2020-11-22 11:09:33 +08:00
|
|
|
$manager_info = $manager_model->getOne(['id' => $this->userinfo['OperaterID']]);
|
|
|
|
|
$where = [];
|
2024-03-25 10:40:07 +08:00
|
|
|
$sell_follow_where = [];
|
2020-11-22 11:09:33 +08:00
|
|
|
if (!$manager_info['IsRoot']) {
|
|
|
|
|
$where['ManagerId'] = $this->userinfo['OperaterID'];
|
2024-03-25 10:40:07 +08:00
|
|
|
$sell_follow_where['op_user'] = $this->userinfo['OperaterID'];
|
2023-08-10 17:34:39 +08:00
|
|
|
} else {
|
|
|
|
|
if (!empty($_GET['manager_id'])) {
|
|
|
|
|
$where['ManagerId'] = $_GET['manager_id'];
|
2024-03-25 10:40:07 +08:00
|
|
|
$sell_follow_where['op_user'] = $_GET['manager_id'];
|
2023-08-10 17:34:39 +08:00
|
|
|
}
|
2020-11-22 11:09:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$user_id_list = [];
|
|
|
|
|
$register_id_list = [];
|
|
|
|
|
$today_register_id_list = [];
|
|
|
|
|
$data = [];
|
|
|
|
|
$time_where1 = '';
|
|
|
|
|
$time_where2 = '';
|
|
|
|
|
$time_where_today = '';
|
|
|
|
|
$time_where2_today = '';
|
|
|
|
|
|
|
|
|
|
$date1 = date("Y-m-01", time());
|
|
|
|
|
$date2 = date("Y-m-d H:i:s", time());
|
|
|
|
|
$flag = date("d", time()) == date("t", time());
|
|
|
|
|
$date3 = date("Y-m-01", strtotime("-1 month"));
|
|
|
|
|
$date4 = $flag ? date("Y-m-t H:i:s", strtotime("-1 month")) : date("Y-m-d H:i:s", strtotime("-1 month"));
|
|
|
|
|
|
2020-11-23 17:00:11 +08:00
|
|
|
if (isset($_GET['sell_month'])) {
|
2020-11-22 11:09:33 +08:00
|
|
|
$date1 = date('Y-m-01', strtotime($_GET['sell_month']));
|
|
|
|
|
$date2 = date("Y-m-t 23:59:59", strtotime($_GET['sell_month']));
|
2020-11-23 17:00:11 +08:00
|
|
|
$date3 = date("Y-m-01", strtotime($_GET['sell_month'] . " -1 month"));
|
|
|
|
|
$date4 = date("Y-m-t 23:59:59", strtotime($_GET['sell_month'] . " -1 month"));
|
2020-11-22 11:09:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//本月
|
|
|
|
|
$time_where1 .= " UpdateTime>='" . $date1 . "' and UpdateTime<='" . $date2 . "' ";
|
|
|
|
|
$time_where2 .= " UpdateTime>='" . $date3 . "' and UpdateTime<='" . $date4 . "' ";
|
|
|
|
|
$time_where_today .= " UpdateTime>='" . date("Y-m-d") . "' and UpdateTime<='" . $date2 . "' ";
|
|
|
|
|
|
2024-03-22 11:17:35 +08:00
|
|
|
//跟进记录时间
|
|
|
|
|
$follow_time_where = " create_time>='" . $date1 . "' and create_time<='" . $date2 . "' ";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取用户列表
|
|
|
|
|
$user_list = $user_model->getAllManagerUser($where);
|
|
|
|
|
foreach ($user_list as $info) {
|
|
|
|
|
$user_id_list[] = $info['Id'];
|
|
|
|
|
//本月注册用户
|
|
|
|
|
if (strtotime($info['CreateTime']) >= strtotime($date1) && strtotime($info['CreateTime']) <= strtotime($date2)) {
|
|
|
|
|
$register_id_list[] = $info['Id'];
|
|
|
|
|
}
|
|
|
|
|
if (strtotime($info['CreateTime']) >= strtotime(date("Y-m-d")) && strtotime($info['CreateTime']) <= strtotime($date2)) {
|
|
|
|
|
$today_register_id_list[] = $info['Id'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$user_where = ['UserId' => ['in', $user_id_list]];
|
|
|
|
|
$register_where = ['UserId' => ['in', $register_id_list]];
|
|
|
|
|
//获取所有产品的营业额
|
2024-03-25 10:40:07 +08:00
|
|
|
$all_sell_money = $follow_record_model->getSellInfo($sell_follow_where,$follow_time_where);
|
2024-03-22 11:17:35 +08:00
|
|
|
|
|
|
|
|
$sell_money_list = [];
|
|
|
|
|
foreach ($all_sell_money as $sell_info) {
|
|
|
|
|
$sell_money_list[$sell_info['product_type'].'_'.$sell_info['sell_type']] += $sell_info['sell_money'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//蘑菇条件单独摘出来
|
|
|
|
|
$mogu_time_where1 = $time_where1.' AND `ProductId`=18';
|
|
|
|
|
//获取本月蘑菇消费额
|
|
|
|
|
// $cost_mogu = $product_order_model->getAllMoney($mogu_time_where1, $user_where);
|
|
|
|
|
//获取本月蘑菇总退款
|
|
|
|
|
// $refund_cost_mogu = $product_order_model->getRefund($mogu_time_where1, $user_where);
|
|
|
|
|
//获取所有消费额
|
|
|
|
|
$cost_data = $product_order_model->getAllMoney('', $user_where);
|
|
|
|
|
//获取本月所有消费额
|
|
|
|
|
// $all_cost_data = $product_order_model->getAllMoney($time_where1);
|
|
|
|
|
//获取本月该客户经理所有的消费额
|
|
|
|
|
$user_cost_data = $product_order_model->getAllMoney($time_where1, $user_where);
|
|
|
|
|
//获取上月该客户经理所有的消费额
|
|
|
|
|
// $user_last_month_cost_data = $product_order_model->getAllMoney($time_where2, $user_where);
|
|
|
|
|
//获取今天该客户经理所有的消费额
|
|
|
|
|
$user_today_cost_data = $product_order_model->getAllMoney($time_where2_today, ['UserId' => ['in', $today_register_id_list]]);
|
|
|
|
|
//获取本月该客户经理所有新注册的消费额
|
|
|
|
|
$register_cost_data = $product_order_model->getAllMoney($time_where1, $register_where);
|
|
|
|
|
//获取本月总退款
|
|
|
|
|
// $refund_cost_data = $product_order_model->getRefund($time_where1, $user_where);
|
|
|
|
|
//总消费营业额
|
|
|
|
|
// $all_cost = $all_cost_data['money'] ?? 0;
|
|
|
|
|
$user_cost = $user_cost_data['money'] ?? 0;
|
|
|
|
|
$all_cost_num = $all_cost_data['num'] ?? 0;
|
|
|
|
|
$user_cost_num = $user_cost_data['num'] ?? 0;
|
|
|
|
|
// $mogu_cost = $cost_mogu['money']??0;
|
|
|
|
|
// $mogu_refund_cost = $refund_cost_mogu['money']??0;
|
|
|
|
|
//上月
|
|
|
|
|
$user_last_month_cost = $user_last_month_cost_data['money'] ?? 0;
|
|
|
|
|
//注册
|
|
|
|
|
$user_register_count = count($register_id_list);
|
|
|
|
|
$user_register_cost_count = $register_cost_data ? $register_cost_data['num'] : 0;
|
|
|
|
|
|
|
|
|
|
// $sell_percent = ($all_cost ? round($user_cost / $all_cost * 100, 2) : 0);
|
|
|
|
|
$cost_percent = ($all_cost_num ? round($user_cost_num / $all_cost_num * 100, 2) : 0);
|
|
|
|
|
$cost_register = ($user_register_count ? round($user_register_cost_count / $user_register_count * 100, 2) : 0);
|
|
|
|
|
$cost_old_user = (($all_cost_num - $user_register_count) ? round(($user_cost_num - $user_register_cost_count) / ($cost_data['num'] - $user_register_cost_count) * 100, 2) : 0);
|
|
|
|
|
// $com_cost = round(($user_cost - $user_last_month_cost), 2);
|
|
|
|
|
$com_percent = ($user_last_month_cost ? round(($user_cost - $user_last_month_cost) / $user_last_month_cost * 100, 2) : 0);
|
|
|
|
|
$today_new_user = ($user_today_cost_data ? $user_today_cost_data['num'] : 0) . "/" . count($today_register_id_list);
|
|
|
|
|
// $refund = ($refund_cost_data ? $refund_cost_data['money'] : 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//蘑菇
|
|
|
|
|
// $cost_mogu_data = round($mogu_cost-$mogu_refund_cost,2);
|
|
|
|
|
//其他营业额
|
|
|
|
|
// $cost_not_mogu_data = round($user_cost-$cost_mogu_data-$refund,2);
|
|
|
|
|
|
|
|
|
|
// $data['cost_mogu'] = "蘑菇营业额($cost_mogu_data)";
|
|
|
|
|
// $data['cost_not_mogu'] = "其他营业额($cost_not_mogu_data)";
|
|
|
|
|
|
|
|
|
|
// $data['sell_percent'] = "我的营业额($user_cost)/总营业额($all_cost)=" . $sell_percent . '%';
|
|
|
|
|
$data['other_order_active'] = "其他IP产品:" . $sell_money_list['other_order_1'];
|
|
|
|
|
$data['mogu_order_active'] = "蘑菇IP产品:" . $sell_money_list['mogu_order_1'];
|
|
|
|
|
$data['recharge_active'] = "IP充值:" . $sell_money_list['recharge_1'];
|
|
|
|
|
$data['http_active'] = "HTTP充值:" . $sell_money_list['http_1'];
|
|
|
|
|
$data['ros_active'] = "ROS订单:" . $sell_money_list['ros_1'];
|
|
|
|
|
$data['jinqiao_active'] = "金桥订单:" . $sell_money_list['jinqiao_1'];
|
|
|
|
|
$data['other_order_not_active'] = "其他IP产品:" . $sell_money_list['other_order_0'];
|
|
|
|
|
$data['mogu_order_not_active'] = "蘑菇IP产品:" . $sell_money_list['mogu_order_0'];
|
|
|
|
|
$data['recharge_not_active'] = "IP充值:" . $sell_money_list['recharge_0'];
|
|
|
|
|
$data['http_not_active'] = "HTTP充值:" . $sell_money_list['http_0'];
|
|
|
|
|
$data['ros_not_active'] = "ROS订单:" . $sell_money_list['ros_0'];
|
|
|
|
|
$data['jinqiao_not_active'] = "金桥订单:" . $sell_money_list['jinqiao_0'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data['cost_percent'] = "需维护的已消费客户($user_cost_num)/总的已消费客户($all_cost_num)=" . $cost_percent . '%';
|
|
|
|
|
$data['cost_register'] = "新注册客户购买率$user_register_cost_count/$user_register_count=" . $cost_register . '%';
|
|
|
|
|
$data['cost_old_user'] = "老客户购买率" . ($user_cost_num - $user_register_cost_count) . "/" . ($cost_data['num'] - $user_register_cost_count) . '=' . $cost_old_user . '%';
|
|
|
|
|
// $data['com_cost'] = "同比增加金额=" . $com_cost;
|
|
|
|
|
$data['com_percent'] = "同比增加百分比=" . $com_percent . '%';
|
|
|
|
|
$data['today_new_user'] = "今日新赠客户" . $today_new_user;
|
|
|
|
|
// $data['refund'] = "总退款金额" . $refund;
|
|
|
|
|
|
|
|
|
|
\result($data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description: 获取单个客户经理的销售信息
|
|
|
|
|
* @param {*}
|
|
|
|
|
* @return {*}
|
|
|
|
|
*/
|
|
|
|
|
public function getOneManager()
|
|
|
|
|
{
|
|
|
|
|
ini_set('display_errors', 'Off');
|
|
|
|
|
$user_model = new User;
|
|
|
|
|
$manager_model = new Manager;
|
|
|
|
|
$product_order_model = new ProductOrder;
|
|
|
|
|
$follow_record_model = new FollowRecord;
|
|
|
|
|
$manager_info = $manager_model->getOne(['id' => $this->userinfo['OperaterID']]);
|
|
|
|
|
$where = [];
|
2024-03-25 10:40:07 +08:00
|
|
|
$sell_follow_where = [];
|
2024-03-22 11:17:35 +08:00
|
|
|
if (!$manager_info['IsRoot']) {
|
|
|
|
|
$where['ManagerId'] = $this->userinfo['OperaterID'];
|
2024-03-25 10:40:07 +08:00
|
|
|
$sell_follow_where['op_user'] = $this->userinfo['OperaterID'];
|
2024-03-22 11:17:35 +08:00
|
|
|
} else {
|
|
|
|
|
if (!empty($_GET['manager_id'])) {
|
|
|
|
|
$where['ManagerId'] = $_GET['manager_id'];
|
2024-03-25 10:40:07 +08:00
|
|
|
$sell_follow_where['op_user'] = $_GET['manager_id'];
|
2024-03-22 11:17:35 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$user_id_list = [];
|
|
|
|
|
$register_id_list = [];
|
|
|
|
|
$today_register_id_list = [];
|
|
|
|
|
$data = [];
|
|
|
|
|
$time_where1 = '';
|
|
|
|
|
$time_where2 = '';
|
|
|
|
|
$time_where_today = '';
|
|
|
|
|
$time_where2_today = '';
|
|
|
|
|
|
|
|
|
|
$date1 = date("Y-m-01", time());
|
|
|
|
|
$date2 = date("Y-m-d H:i:s", time());
|
|
|
|
|
$flag = date("d", time()) == date("t", time());
|
|
|
|
|
$date3 = date("Y-m-01", strtotime("-1 month"));
|
|
|
|
|
$date4 = $flag ? date("Y-m-t H:i:s", strtotime("-1 month")) : date("Y-m-d H:i:s", strtotime("-1 month"));
|
|
|
|
|
|
|
|
|
|
if (isset($_GET['sell_month'])) {
|
|
|
|
|
$date1 = date('Y-m-01', strtotime($_GET['sell_month']));
|
|
|
|
|
$date2 = date("Y-m-t 23:59:59", strtotime($_GET['sell_month']));
|
|
|
|
|
$date3 = date("Y-m-01", strtotime($_GET['sell_month'] . " -1 month"));
|
|
|
|
|
$date4 = date("Y-m-t 23:59:59", strtotime($_GET['sell_month'] . " -1 month"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//本月
|
|
|
|
|
$time_where1 .= " UpdateTime>='" . $date1 . "' and UpdateTime<='" . $date2 . "' ";
|
|
|
|
|
$time_where2 .= " UpdateTime>='" . $date3 . "' and UpdateTime<='" . $date4 . "' ";
|
|
|
|
|
$time_where_today .= " UpdateTime>='" . date("Y-m-d") . "' and UpdateTime<='" . $date2 . "' ";
|
|
|
|
|
|
|
|
|
|
//跟进记录时间
|
|
|
|
|
$follow_time_where = " create_time>='" . $date1 . "' and create_time<='" . $date2 . "' ";
|
|
|
|
|
|
|
|
|
|
|
2020-11-22 11:09:33 +08:00
|
|
|
//获取用户列表
|
|
|
|
|
$user_list = $user_model->getAllManagerUser($where);
|
|
|
|
|
foreach ($user_list as $info) {
|
|
|
|
|
$user_id_list[] = $info['Id'];
|
|
|
|
|
//本月注册用户
|
|
|
|
|
if (strtotime($info['CreateTime']) >= strtotime($date1) && strtotime($info['CreateTime']) <= strtotime($date2)) {
|
|
|
|
|
$register_id_list[] = $info['Id'];
|
|
|
|
|
}
|
|
|
|
|
if (strtotime($info['CreateTime']) >= strtotime(date("Y-m-d")) && strtotime($info['CreateTime']) <= strtotime($date2)) {
|
|
|
|
|
$today_register_id_list[] = $info['Id'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$user_where = ['UserId' => ['in', $user_id_list]];
|
|
|
|
|
$register_where = ['UserId' => ['in', $register_id_list]];
|
2024-03-22 11:17:35 +08:00
|
|
|
//获取所有产品的营业额
|
2024-03-25 10:40:07 +08:00
|
|
|
$all_sell_money = $follow_record_model->getSellInfo($sell_follow_where,$follow_time_where);
|
2024-03-22 11:17:35 +08:00
|
|
|
|
|
|
|
|
$sell_money_list = [];
|
|
|
|
|
foreach ($all_sell_money as $sell_info) {
|
|
|
|
|
$sell_money_list[$sell_info['product_type'].'_'.$sell_info['sell_type']] += $sell_info['sell_money'];
|
|
|
|
|
}
|
2023-08-10 17:34:39 +08:00
|
|
|
//蘑菇条件单独摘出来
|
|
|
|
|
$mogu_time_where1 = $time_where1.' AND `ProductId`=18';
|
|
|
|
|
//获取本月蘑菇消费额
|
|
|
|
|
$cost_mogu = $product_order_model->getAllMoney($mogu_time_where1, $user_where);
|
|
|
|
|
//获取本月蘑菇总退款
|
|
|
|
|
$refund_cost_mogu = $product_order_model->getRefund($mogu_time_where1, $user_where);
|
2020-11-24 15:56:59 +08:00
|
|
|
//获取所有消费额
|
2020-11-24 16:31:25 +08:00
|
|
|
$cost_data = $product_order_model->getAllMoney('', $user_where);
|
2020-11-22 11:09:33 +08:00
|
|
|
//获取本月所有消费额
|
|
|
|
|
$all_cost_data = $product_order_model->getAllMoney($time_where1);
|
|
|
|
|
//获取本月该客户经理所有的消费额
|
|
|
|
|
$user_cost_data = $product_order_model->getAllMoney($time_where1, $user_where);
|
|
|
|
|
//获取上月该客户经理所有的消费额
|
|
|
|
|
$user_last_month_cost_data = $product_order_model->getAllMoney($time_where2, $user_where);
|
|
|
|
|
//获取今天该客户经理所有的消费额
|
|
|
|
|
$user_today_cost_data = $product_order_model->getAllMoney($time_where2_today, ['UserId' => ['in', $today_register_id_list]]);
|
|
|
|
|
//获取本月该客户经理所有新注册的消费额
|
|
|
|
|
$register_cost_data = $product_order_model->getAllMoney($time_where1, $register_where);
|
|
|
|
|
//获取本月总退款
|
|
|
|
|
$refund_cost_data = $product_order_model->getRefund($time_where1, $user_where);
|
|
|
|
|
//总消费营业额
|
2020-11-23 17:00:11 +08:00
|
|
|
$all_cost = $all_cost_data['money'] ?? 0;
|
|
|
|
|
$user_cost = $user_cost_data['money'] ?? 0;
|
|
|
|
|
$all_cost_num = $all_cost_data['num'] ?? 0;
|
|
|
|
|
$user_cost_num = $user_cost_data['num'] ?? 0;
|
2023-08-10 17:34:39 +08:00
|
|
|
$mogu_cost = $cost_mogu['money']??0;
|
|
|
|
|
$mogu_refund_cost = $refund_cost_mogu['money']??0;
|
2020-11-22 11:09:33 +08:00
|
|
|
//上月
|
2020-11-23 17:00:11 +08:00
|
|
|
$user_last_month_cost = $user_last_month_cost_data['money'] ?? 0;
|
2020-11-22 11:09:33 +08:00
|
|
|
//注册
|
|
|
|
|
$user_register_count = count($register_id_list);
|
2020-11-23 17:00:11 +08:00
|
|
|
$user_register_cost_count = $register_cost_data ? $register_cost_data['num'] : 0;
|
2020-11-22 11:09:33 +08:00
|
|
|
|
2020-11-23 17:00:11 +08:00
|
|
|
$sell_percent = ($all_cost ? round($user_cost / $all_cost * 100, 2) : 0);
|
|
|
|
|
$cost_percent = ($all_cost_num ? round($user_cost_num / $all_cost_num * 100, 2) : 0);
|
|
|
|
|
$cost_register = ($user_register_count ? round($user_register_cost_count / $user_register_count * 100, 2) : 0);
|
2020-11-24 16:25:05 +08:00
|
|
|
$cost_old_user = (($all_cost_num - $user_register_count) ? round(($user_cost_num - $user_register_cost_count) / ($cost_data['num'] - $user_register_cost_count) * 100, 2) : 0);
|
2020-11-23 17:00:11 +08:00
|
|
|
$com_cost = round(($user_cost - $user_last_month_cost), 2);
|
|
|
|
|
$com_percent = ($user_last_month_cost ? round(($user_cost - $user_last_month_cost) / $user_last_month_cost * 100, 2) : 0);
|
|
|
|
|
$today_new_user = ($user_today_cost_data ? $user_today_cost_data['num'] : 0) . "/" . count($today_register_id_list);
|
|
|
|
|
$refund = ($refund_cost_data ? $refund_cost_data['money'] : 0);
|
2020-11-22 11:09:33 +08:00
|
|
|
|
2023-08-10 17:34:39 +08:00
|
|
|
|
|
|
|
|
//蘑菇
|
|
|
|
|
$cost_mogu_data = round($mogu_cost-$mogu_refund_cost,2);
|
|
|
|
|
//其他营业额
|
2023-08-10 19:14:36 +08:00
|
|
|
$cost_not_mogu_data = round($user_cost-$cost_mogu_data-$refund,2);
|
2024-03-22 11:17:35 +08:00
|
|
|
$data['other_order_active'] = "其他IP产品:" . $sell_money_list['other_order_1'];
|
|
|
|
|
$data['mogu_order_active'] = "蘑菇IP产品:" . $sell_money_list['mogu_order_1'];
|
|
|
|
|
$data['recharge_active'] = "IP充值:" . $sell_money_list['recharge_1'];
|
|
|
|
|
$data['http_active'] = "HTTP充值:" . $sell_money_list['http_1'];
|
|
|
|
|
$data['ros_active'] = "ROS订单:" . $sell_money_list['ros_1'];
|
|
|
|
|
$data['jinqiao_active'] = "金桥订单:" . $sell_money_list['jinqiao_1'];
|
|
|
|
|
$data['other_order_not_active'] = "其他IP产品:" . $sell_money_list['other_order_0'];
|
|
|
|
|
$data['mogu_order_not_active'] = "蘑菇IP产品:" . $sell_money_list['mogu_order_0'];
|
|
|
|
|
$data['recharge_not_active'] = "IP充值:" . $sell_money_list['recharge_0'];
|
|
|
|
|
$data['http_not_active'] = "HTTP充值:" . $sell_money_list['http_0'];
|
|
|
|
|
$data['ros_not_active'] = "ROS订单:" . $sell_money_list['ros_0'];
|
|
|
|
|
$data['jinqiao_not_active'] = "金桥订单:" . $sell_money_list['jinqiao_0'];
|
2023-08-10 17:34:39 +08:00
|
|
|
|
|
|
|
|
$data['cost_mogu'] = "蘑菇营业额($cost_mogu_data)";
|
|
|
|
|
$data['cost_not_mogu'] = "其他营业额($cost_not_mogu_data)";
|
|
|
|
|
|
2020-11-22 11:09:33 +08:00
|
|
|
$data['sell_percent'] = "我的营业额($user_cost)/总营业额($all_cost)=" . $sell_percent . '%';
|
2021-11-18 16:38:47 +08:00
|
|
|
$data['cost_percent'] = "需维护的已消费客户($user_cost_num)/总的已消费客户($all_cost_num)=" . $cost_percent . '%';
|
|
|
|
|
$data['cost_register'] = "新注册客户购买率$user_register_cost_count/$user_register_count=" . $cost_register . '%';
|
|
|
|
|
$data['cost_old_user'] = "老客户购买率" . ($user_cost_num - $user_register_cost_count) . "/" . ($cost_data['num'] - $user_register_cost_count) . '=' . $cost_old_user . '%';
|
2020-11-22 11:09:33 +08:00
|
|
|
$data['com_cost'] = "同比增加金额=" . $com_cost;
|
2020-11-23 17:00:11 +08:00
|
|
|
$data['com_percent'] = "同比增加百分比=" . $com_percent . '%';
|
|
|
|
|
$data['today_new_user'] = "今日新赠客户" . $today_new_user;
|
|
|
|
|
$data['refund'] = "总退款金额" . $refund;
|
2020-11-22 11:09:33 +08:00
|
|
|
|
|
|
|
|
\result($data);
|
|
|
|
|
}
|
2023-08-10 17:34:39 +08:00
|
|
|
/**
|
|
|
|
|
* @description: 获取所有销售管理信息
|
|
|
|
|
* @param {*}
|
|
|
|
|
* @return {*}
|
|
|
|
|
*/
|
|
|
|
|
public function getManagerList() {
|
|
|
|
|
$manager_model = new Manager;
|
|
|
|
|
$manager_list = $manager_model->getAllList();
|
|
|
|
|
$temp = [];
|
|
|
|
|
$temp[] = [
|
|
|
|
|
'value' => 0,
|
|
|
|
|
'label' => '全部',
|
|
|
|
|
];
|
|
|
|
|
foreach ($manager_list as $info) {
|
|
|
|
|
$t['value'] = $info['id'];
|
|
|
|
|
$t['label'] = $info['RealName'];
|
|
|
|
|
$temp[] = $t;
|
|
|
|
|
}
|
|
|
|
|
\result($temp);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-22 11:09:33 +08:00
|
|
|
/**
|
|
|
|
|
* @description: 获取所有客户销售信息
|
|
|
|
|
* @param {*}
|
|
|
|
|
* @return {*}
|
|
|
|
|
*/
|
|
|
|
|
public function getAll()
|
|
|
|
|
{
|
|
|
|
|
$manager_model = new Manager;
|
|
|
|
|
$manager_list = $manager_model->getAllList();
|
|
|
|
|
$list = [];
|
2020-11-23 17:00:11 +08:00
|
|
|
foreach ($manager_list as $info) {
|
2020-11-22 11:09:33 +08:00
|
|
|
$temp = $this->getInfo($info['id']);
|
|
|
|
|
$temp['name'] = $info['RealName'];
|
|
|
|
|
$list[] = $temp;
|
|
|
|
|
}
|
|
|
|
|
\result($list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getInfo($manager_id)
|
|
|
|
|
{
|
|
|
|
|
$user_model = new User;
|
|
|
|
|
$product_order_model = new ProductOrder;
|
|
|
|
|
$where['ManagerId'] = $manager_id;
|
2020-11-23 17:00:11 +08:00
|
|
|
|
2020-11-22 11:09:33 +08:00
|
|
|
$user_id_list = [];
|
|
|
|
|
$register_id_list = [];
|
|
|
|
|
$today_register_id_list = [];
|
|
|
|
|
$data = [];
|
|
|
|
|
$time_where1 = '';
|
|
|
|
|
$time_where2 = '';
|
|
|
|
|
$time_where_today = '';
|
|
|
|
|
$time_where2_today = '';
|
|
|
|
|
$data = [];
|
|
|
|
|
|
|
|
|
|
$date1 = date("Y-m-01", time());
|
|
|
|
|
$date2 = date("Y-m-d H:i:s", time());
|
|
|
|
|
$flag = date("d", time()) == date("t", time());
|
|
|
|
|
$date3 = date("Y-m-01", strtotime("-1 month"));
|
|
|
|
|
$date4 = $flag ? date("Y-m-t H:i:s", strtotime("-1 month")) : date("Y-m-d H:i:s", strtotime("-1 month"));
|
|
|
|
|
|
2020-11-23 17:00:11 +08:00
|
|
|
if (isset($_GET['sell_month'])) {
|
2020-11-22 11:09:33 +08:00
|
|
|
$date1 = date('Y-m-01', strtotime($_GET['sell_month']));
|
|
|
|
|
$date2 = date("Y-m-t 23:59:59", strtotime($_GET['sell_month']));
|
2020-11-23 17:00:11 +08:00
|
|
|
$date3 = date("Y-m-01", strtotime($_GET['sell_month'] . " -1 month"));
|
|
|
|
|
$date4 = date("Y-m-t 23:59:59", strtotime($_GET['sell_month'] . " -1 month"));
|
2020-11-22 11:09:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//本月
|
|
|
|
|
$time_where1 .= " UpdateTime>='" . $date1 . "' and UpdateTime<='" . $date2 . "' ";
|
|
|
|
|
$time_where2 .= " UpdateTime>='" . $date3 . "' and UpdateTime<='" . $date4 . "' ";
|
|
|
|
|
$time_where_today .= " UpdateTime>='" . date("Y-m-d") . "' and UpdateTime<='" . $date2 . "' ";
|
|
|
|
|
|
|
|
|
|
//获取用户列表
|
|
|
|
|
$user_list = $user_model->getAllManagerUser($where);
|
|
|
|
|
foreach ($user_list as $info) {
|
|
|
|
|
$user_id_list[] = $info['Id'];
|
|
|
|
|
//本月注册用户
|
|
|
|
|
if (strtotime($info['CreateTime']) >= strtotime($date1) && strtotime($info['CreateTime']) <= strtotime($date2)) {
|
|
|
|
|
$register_id_list[] = $info['Id'];
|
|
|
|
|
}
|
|
|
|
|
if (strtotime($info['CreateTime']) >= strtotime(date("Y-m-d")) && strtotime($info['CreateTime']) <= strtotime($date2)) {
|
|
|
|
|
$today_register_id_list[] = $info['Id'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$user_where = ['UserId' => ['in', $user_id_list]];
|
2020-11-24 16:31:25 +08:00
|
|
|
$register_where = ['UserId' => ['in', $register_id_list]];
|
|
|
|
|
//获取所有消费额
|
|
|
|
|
$cost_data = $product_order_model->getAllMoney('', $user_where);
|
2020-11-22 11:09:33 +08:00
|
|
|
//获取本月所有消费额
|
|
|
|
|
$all_cost_data = $product_order_model->getAllMoney($time_where1);
|
|
|
|
|
//获取本月该客户经理所有的消费额
|
|
|
|
|
$user_cost_data = $product_order_model->getAllMoney($time_where1, $user_where);
|
|
|
|
|
//获取上月该客户经理所有的消费额
|
|
|
|
|
$user_last_month_cost_data = $product_order_model->getAllMoney($time_where2, $user_where);
|
|
|
|
|
//获取今天该客户经理所有的消费额
|
|
|
|
|
$user_today_cost_data = $product_order_model->getAllMoney($time_where2_today, ['UserId' => ['in', $today_register_id_list]]);
|
|
|
|
|
//获取本月该客户经理所有新注册的消费额
|
|
|
|
|
$register_cost_data = $product_order_model->getAllMoney($time_where1, $register_where);
|
|
|
|
|
//获取本月总退款
|
|
|
|
|
$refund_cost_data = $product_order_model->getRefund($time_where1, $user_where);
|
|
|
|
|
//总消费营业额
|
2020-11-23 17:00:11 +08:00
|
|
|
$all_cost = $all_cost_data['money'] ?? 0;
|
|
|
|
|
$user_cost = $user_cost_data['money'] ?? 0;
|
|
|
|
|
$all_cost_num = $all_cost_data['num'] ?? 0;
|
|
|
|
|
$user_cost_num = $user_cost_data['num'] ?? 0;
|
2020-11-22 11:09:33 +08:00
|
|
|
//上月
|
2020-11-23 17:00:11 +08:00
|
|
|
$user_last_month_cost = $user_last_month_cost_data['money'] ?? 0;
|
2020-11-22 11:09:33 +08:00
|
|
|
//注册
|
|
|
|
|
$user_register_count = count($register_id_list);
|
2020-11-23 17:00:11 +08:00
|
|
|
$user_register_cost_count = $register_cost_data ? $register_cost_data['num'] : 0;
|
|
|
|
|
|
2020-11-24 16:46:29 +08:00
|
|
|
$data['sell_percent'] = ($all_cost ? $user_cost .'/'. $all_cost.'='.round($user_cost / $all_cost * 100, 2) : 0) . '%';
|
|
|
|
|
$data['cost_percent'] = ($all_cost_num ? $user_cost_num .'/'. $all_cost_num.'='.round($user_cost_num / $all_cost_num * 100, 2) : 0) . '%';
|
|
|
|
|
$data['cost_register'] = ($user_register_count ? $user_register_cost_count .'/'. $user_register_count.'='.round($user_register_cost_count / $user_register_count * 100, 2) : 0) . '%';
|
|
|
|
|
$data['cost_old_user'] = (($all_cost_num - $user_register_cost_count) ? ($user_cost_num - $user_register_cost_count) .'/'. ($cost_data['num'] - $user_register_cost_count).'='.round(($user_cost_num - $user_register_cost_count) / ($cost_data['num'] - $user_register_cost_count) * 100, 2) : 0) . '%';
|
2020-11-23 17:00:11 +08:00
|
|
|
$data['com_cost'] = round(($user_cost - $user_last_month_cost), 2);
|
2020-11-24 16:46:29 +08:00
|
|
|
$data['com_percent'] = ($user_last_month_cost ? ($user_cost - $user_last_month_cost) .'/'. $user_last_month_cost.'='.round(($user_cost - $user_last_month_cost) / $user_last_month_cost * 100, 2) : 0) . '%';
|
2020-11-23 17:00:11 +08:00
|
|
|
$data['today_new_user'] = ($user_today_cost_data ? $user_today_cost_data['num'] : 0) . "/" . count($today_register_id_list);
|
|
|
|
|
$data['refund'] = ($refund_cost_data ? $refund_cost_data['money'] : 0);
|
2020-11-22 11:09:33 +08:00
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
}
|