user['agent_id'])) { $param['agent_id'] = $request->user['agent_id']; } $total = ['t0' => [ 'num' => 0, 'money' => 0, ], 't1' => [ 'num' => 0, 'money' => 0, ], 't2' => [ 'num' => 0, 'money' => 0, ], 't3' => [ 'num' => 0, 'money' => 0, ], 't4' => [ 'num' => 0, 'money' => 0, ], 'ta' => 0]; foreach ((new HxOrderLife)->where($param)->whereDay("create_at")->field('status,count(1) total,sum(pay_amount) as money')->group('status')->cursor() as $item) { [$total['t'.$item['status']] = [ 'num' => $item['total'], 'money' => $item['money'] ],$total['ta'] += $item['total']]; } // 今日核销金额 // 今日退款金额 // 商品总数量 $goods = (new HxGoods)->where($param)->count(); // POI数量 $poi = (new HxStorePoi)->where($param)->count(); // 累计付款金额 (元) // 核销金额 (元) // 待核销金额 (元) // 核销订单数 $moneys = $orders = []; $fields = ['ROUND(sum(pay_amount)/100,2)' => 'total','substr(create_at,1,10)' => 'mday']; $orderMoney = (new HxOrderLife)->field($fields)->where($param)->where("status","in",[1,4])->whereTime('create_at', '-15 days')->group('mday')->select()->column(null, 'mday'); for ($i = 15; $i >= 0; $i--) { $date = date('Y-m-d', strtotime("-{$i}days")); $moneys[] = [ '当天日期' => date('Y-m-d', strtotime("-{$i}days")), '订单金额' => ($orderMoney[$date] ?? [])['total'] ?? 0, ]; } $field = ['count(1)' => 'count', 'substr(create_at,1,10)' => 'mday']; $orderNum = (new HxOrderLife)->field($field)->where($param)->where("status","in",[1,4])->whereTime('create_at', '-15 days')->group('mday')->select()->column(null, 'mday'); for ($i = 15; $i >= 0; $i--) { $date = date('Y-m-d', strtotime("-{$i}days")); $orders[] = [ '当天日期' => date('Y-m-d', strtotime("-{$i}days")), '订单数量' => ($orderNum[$date] ?? [])['count'] ?? 0, ]; } $info = [ "order" => '' ]; return success("ok",compact("total","moneys","orders","info","poi","goods")); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } }