diff --git a/app/admin/controller/Statistics.php b/app/admin/controller/Statistics.php index bf58937..20a2a92 100644 --- a/app/admin/controller/Statistics.php +++ b/app/admin/controller/Statistics.php @@ -29,27 +29,63 @@ class Statistics extends Base $status = trim(input('get.status')); $type = trim(input('get.type')); $addtime = trim(input('get.addtime')); - + $whe3 = array(); + $whe4 = array(); $whe = array(); if ($title) { $whe[] = ['title', 'like', '%' . $title . '%']; } if ($id) { - $whe[] = ['id', 'like', '%' . $id . '%']; + $whe[] = ['id', '=', $id]; + } if ($status) { $whe[] = ['status', '=', $status]; } if ($type) { $whe[] = ['type', '=', $type]; - } else { - $whe[] = ['type', 'notIn', [4, 7]]; + } + + if ($addtime) { + $time = explode(' - ', $addtime); + $start_time = strtotime($time[0]); + $end_time = strtotime($time[1]) - 1; + if ($start_time > $end_time) { + $this->err('开始时间不能大于结束时间'); + } + $whe3[] = ['addtime', 'BETWEEN', array($start_time, $end_time)]; + $whe4[] = ['addtime', 'BETWEEN', array($start_time, $end_time)]; + } + $goodList = GoodsModel::where($whe)->field('id')->select(); $field = "*"; $order = "id desc"; $data = GoodsModel::getList($whe, $field, $order, 20); $userList = User::where('istest', '=', 1)->field('id')->select(); $userArray = array_column($userList->toArray(), 'id'); + $goodArray = array_column($goodList->toArray(), 'id'); + $whe3[] = ['user_id', 'not in', $userArray]; + $whe3[] = ['status', '=', 1]; + $whe3[] = ['goods_id', 'in', $goodArray]; + + $whe4[] = ['user_id', 'not in', $userArray]; + $whe4[] = ['goods_id', 'in', $goodArray]; + + $order_total_all = OrderModel::where($whe3)->sum('order_total'); + $order_zhe_total_all = OrderModel::where($whe3)->sum('order_zhe_total'); + $goodslist_money_all = OrderList::where($whe4)->sum('goodslist_money'); + $price_all = OrderModel::where($whe3)->sum('price'); + $use_money_all = OrderModel::where($whe3)->sum('use_money'); + // $value['lirulv'] = round(($order_zhe_total - $goodslist_price1) / $goodslist_price1 * 100, 2); + + View::assign('sum_dingdan', $order_total_all); + View::assign('sum_shiji', $order_zhe_total_all); + View::assign('sum_chuhuo', $goodslist_money_all); + View::assign('price_all', $price_all); + View::assign('sum_shijilirun', round(($order_zhe_total_all - $goodslist_money_all), 2)); + View::assign('sum_dingdanlirun', round(($order_total_all - $goodslist_money_all), 2)); + View::assign('use_money_all', $use_money_all); + View::assign('order_total_all', $order_total_all); //订单收入:实际收入:出货价值:实际利润率:订单利润率: $sum_dingdan = 0; $sum_shiji = 0; @@ -156,11 +192,11 @@ class Statistics extends Base View::assign('count', $data['count']); View::assign('page', $data['page']); - View::assign('sum_dingdan', $sum_dingdan); - View::assign('sum_shiji', $sum_shiji); - View::assign('sum_chuhuo', $sum_chuhuo); - View::assign('sum_shijilirun', $sum_shijilirun); - View::assign('sum_dingdanlirun', $sum_dingdanlirun); + // View::assign('sum_dingdan', $sum_dingdan); + // View::assign('sum_shiji', $sum_shiji); + // View::assign('sum_chuhuo', $sum_chuhuo); + // View::assign('sum_shijilirun', $sum_shijilirun); + // View::assign('sum_dingdanlirun', $sum_dingdanlirun); return View::fetch("Statistics/profit"); } @@ -315,11 +351,11 @@ class Statistics extends Base View::assign('order_goodslist_count', $order_goodslist_count); View::assign('order_count', $order_count); View::assign('order_lirun', round($order_zhe_total + $profit_rvenue - $order_goodslist_money - $profit_expenses, 2)); - View::assign('order_lirun_yester',round($order_zhe_total_yester + $profit_rvenue_yester - $order_goodslist_money_yester - $profit_expenses_yester, 2) . " ($order_zhe_total_yester + $profit_rvenue_yester - $order_goodslist_money_yester - $profit_expenses_yester)"); + View::assign('order_lirun_yester', round($order_zhe_total_yester + $profit_rvenue_yester - $order_goodslist_money_yester - $profit_expenses_yester, 2) . " ($order_zhe_total_yester + $profit_rvenue_yester - $order_goodslist_money_yester - $profit_expenses_yester)"); View::assign('order_lirun_week', round($order_zhe_total_week + $profit_rvenue_week - $order_goodslist_money_week - $profit_expenses_week, 2) . " ({$order_zhe_total_week} + $profit_rvenue_week - $order_goodslist_money_week - $profit_expenses_week)"); - View::assign('order_lirun_last_week',round($order_zhe_total_last_week +$profit_rvenue_last_week - $order_goodslist_money__last_week - $profit_expenses_last_week, 2) . " ($order_zhe_total_last_week +$profit_rvenue_last_week - $order_goodslist_money__last_week - $profit_expenses_last_week)"); - View::assign('order_zhe_total_month',round($order_zhe_total_month +$profit_rvenue_money - $order_goodslist_money_month - $profit_expenses_money, 2) . " ($order_zhe_total_month + $profit_rvenue_money - $order_goodslist_money_month - $profit_expenses_money)"); - View::assign('order_lirun_last_month',round($order_zhe_total_last_month +$profit_rvenue_last_money - $order_goodslist_money__last_month - $profit_expenses_last_money, 2) . " ($order_zhe_total_last_month + $profit_rvenue_last_money - $order_goodslist_money__last_month- $profit_expenses_last_money)"); + View::assign('order_lirun_last_week', round($order_zhe_total_last_week + $profit_rvenue_last_week - $order_goodslist_money__last_week - $profit_expenses_last_week, 2) . " ($order_zhe_total_last_week +$profit_rvenue_last_week - $order_goodslist_money__last_week - $profit_expenses_last_week)"); + View::assign('order_zhe_total_month', round($order_zhe_total_month + $profit_rvenue_money - $order_goodslist_money_month - $profit_expenses_money, 2) . " ($order_zhe_total_month + $profit_rvenue_money - $order_goodslist_money_month - $profit_expenses_money)"); + View::assign('order_lirun_last_month', round($order_zhe_total_last_month + $profit_rvenue_last_money - $order_goodslist_money__last_month - $profit_expenses_last_money, 2) . " ($order_zhe_total_last_month + $profit_rvenue_last_money - $order_goodslist_money__last_month- $profit_expenses_last_money)"); // 赋值给模板 View::assign('userCount', $userCount); diff --git a/app/admin/view/Statistics/profit.html b/app/admin/view/Statistics/profit.html index 920f988..fd64c9a 100755 --- a/app/admin/view/Statistics/profit.html +++ b/app/admin/view/Statistics/profit.html @@ -63,6 +63,9 @@
订单收入:{$sum_dingdan} 实际收入:{$sum_shiji} + 微信收入:{$price_all} + 余额收入:{$use_money_all} + 出货价值:{$sum_chuhuo} 订单利润:{if condition="$sum_dingdanlirun < 0"} {$sum_dingdanlirun}