model = new \app\agent\model\finance\Stats(); } /** * 显示资源列表 * * @return \think\Response * @throws \Lettered\Support\Exceptions\FailedException */ public function index() { $area_id = $this->auth->user()['area_id']; $TaxiOrder = new TaxiOrder(); // $GoodsOrder = new GoodsOrder(); // $SkillOrder = new SkillOrder(); // $MissionOrder = new MissionOrder(); $modelArray = [$TaxiOrder]; // 消费总额包含 商品、接单、技能、摩的 $where = [ 'area_id' => $area_id, 'status' => [0,2,3,4] ]; // 直接读取支付记录表吧 $count = [ 'total' => $TaxiOrder->where($where)->sum('price'), 'today' => $TaxiOrder->where($where)->whereTime('created_at', 'd')->sum('price'), 'month' => $TaxiOrder->where($where)->whereTime('created_at', 'm')->sum('price'), 'year' => $TaxiOrder->where($where)->whereTime('created_at', 'y')->sum('price') ]; // 订单统计 $order = [ 'total' => $TaxiOrder->where($where)->count(), 'today' => $TaxiOrder->where($where)->whereTime('created_at', 'd')->count(), 'month' => $TaxiOrder->where($where)->whereTime('created_at', 'm')->count(), 'year' => $TaxiOrder->where($where)->whereTime('created_at', 'y')->count() ]; /*foreach ($modelArray as $key => $item) { $row = $this->model->getStats( $item, $key ? 'pay_price' : 'price', 'id', [ 'area_id' => $area_id, 'status' => [0,2,3,4] ], [ 'paylog' ] ); foreach ($row as $index => $value) { $count[$index] += array_sum($row[$index]); $order[$index] += count($row[$index]); } }*/ // 统计图 $res = []; for ($month = 1; $month <=12 ; $month ++){ $res[] = model('common/GoodsOrder')->whereTime('created_at', 'between', $this->model->getMonthTime($month)) ->count('*');; } $data['coun'] = $count; $data['chart'] = $res; $data['order'] = $order; return IResponse::success($data,"加载数据成功"); } /** * 显示创建资源表单页. * * @return \think\Response */ public function create() { // } /** * 保存新建的资源 * * @param \think\Request $request * @return \think\Response */ public function save(Request $request) { // } /** * 显示指定的资源 * * @param int $id * @return \think\Response */ public function read($id) { // } /** * 显示编辑资源表单页. * * @param int $id * @return \think\Response */ public function edit($id) { // } /** * 保存更新的资源 * * @param \think\Request $request * @param int $id * @return \think\Response */ public function update(Request $request, $id) { // } /** * 删除指定资源 * * @param int $id * @return \think\Response */ public function delete($id) { // } }