diff --git a/server/app/admin/controller/Statistics.php b/server/app/admin/controller/Statistics.php index 2e2f6148..1b0d55a9 100644 --- a/server/app/admin/controller/Statistics.php +++ b/server/app/admin/controller/Statistics.php @@ -20,6 +20,7 @@ namespace app\admin\controller; +use app\admin\logic\user\BusinessTeamLogic; use app\common\basics\AdminBase; use app\common\server\JsonServer; use app\admin\logic\StatisticsLogic; @@ -51,10 +52,11 @@ class Statistics extends AdminBase $res = StatisticsLogic::trading($post); return JsonServer::success('',$res); } - return view(); + + return view('', ['teamList' => BusinessTeamLogic::getBusinessTeamList()]); } - - + + //会员分析 public function member() { diff --git a/server/app/admin/logic/StatisticsLogic.php b/server/app/admin/logic/StatisticsLogic.php index aeaddb46..701b7f30 100644 --- a/server/app/admin/logic/StatisticsLogic.php +++ b/server/app/admin/logic/StatisticsLogic.php @@ -38,7 +38,7 @@ class StatisticsLogic extends Logic */ public static function visit($post) { - //获取今天的时间戳 + //获取今天的时间戳 $today = strtotime('today'); //近七天的开始日期 $start_time = $today - 86400 * 7; @@ -52,7 +52,7 @@ class StatisticsLogic extends Logic $user_count = Db::name('stat') ->where([['create_time', 'between', [$start_time, $end_time]]]) ->count('id'); - + //当前时间戳 $start_t = time(); //echarts图表数据 @@ -90,7 +90,7 @@ class StatisticsLogic extends Logic */ public static function member($post) { - //获取今天的时间戳 + //获取今天的时间戳 $today = strtotime('today'); //近七天的开始日期 $start_time = $today - 86400 * 7; @@ -146,7 +146,7 @@ class StatisticsLogic extends Logic */ public static function trading($post) { - //获取今天的时间戳 + //获取今天的时间戳 $today = strtotime('today'); //近七天的开始日期 $start_time = $today - 86400 * 7; @@ -157,10 +157,18 @@ class StatisticsLogic extends Logic $start_time = strtotime($post['start_time']); $end_time = strtotime($post['end_time']); } + + $where = []; + if (isset($post['team_id']) && $post['team_id'] != '') { + $where[] = ['team_id', '=', $post['team_id']]; + } + $order_num = Db::name('order') + ->where($where) ->where([['create_time', 'between', [$start_time, $end_time]], ['pay_status', '>', PayEnum::UNPAID]]) ->count('id'); $order_amount = Db::name('order') + ->where($where) ->where([['create_time', 'between', [$start_time, $end_time]], ['pay_status', '>', PayEnum::UNPAID]]) ->sum('order_amount'); @@ -177,9 +185,11 @@ class StatisticsLogic extends Logic $start_now = strtotime(date('Y-m-d', $where_start)); $end_now = strtotime(date('Y-m-d 23:59:59', $where_start)); $order_num_add = Db::name('order') + ->where($where) ->where([['create_time', 'between', [$start_now, $end_now]], ['pay_status', '>', PayEnum::UNPAID]]) ->count('id'); $order_amount_add = Db::name('order') + ->where($where) ->where([['create_time', 'between', [$start_now, $end_now]], ['pay_status', '>', PayEnum::UNPAID]]) ->sum('order_amount'); @@ -274,7 +284,7 @@ class StatisticsLogic extends Logic $get['search_key'] = 'sales_volume'; } - // 商品列表 + // 商品列表 $goods_count = Db::name('order')->alias('o') ->join('order_goods og', 'og.order_id = o.id') ->join('shop s', 's.id = o.shop_id') diff --git a/server/app/admin/logic/user/BusinessTeamLogic.php b/server/app/admin/logic/user/BusinessTeamLogic.php index 5e0c21bd..aab75ec5 100644 --- a/server/app/admin/logic/user/BusinessTeamLogic.php +++ b/server/app/admin/logic/user/BusinessTeamLogic.php @@ -70,17 +70,12 @@ class BusinessTeamLogic extends Logic } } - public static function getBusinessTeamList($selected = []) + public static function getBusinessTeamList() { $levelArr = BusinessTeam::field('id,name,phone') ->order('id desc') ->select() ->toArray(); - foreach ($levelArr as &$item) { - if (in_array($item['id'], $selected)) { - $item['selected'] = true; - } - } return $levelArr; } diff --git a/server/app/admin/view/statistics/trading.html b/server/app/admin/view/statistics/trading.html index 641f87ff..50d38016 100644 --- a/server/app/admin/view/statistics/trading.html +++ b/server/app/admin/view/statistics/trading.html @@ -22,6 +22,17 @@ +