fail(OrderLogic::getError()); //获取错误信息并返回错误信息 } return $this->success('ok', ['dayPayPrice' => $res]); } public function user() { $today = strtotime(date('Y-m-d')); $dates=[]; // 循环输出前5天的日期 for ($i = 0; $i <= 4; $i++) { // 计算前第$i天的日期时间戳 $timestamp = $today - ($i * 86400); // 86400秒等于1天 // 将时间戳格式化为日期 $date = date('Y-m-d', $timestamp); $dates[]=$date; } $res = UserLogic::userCount(5,$dates); if (UserLogic::hasError()) { return $this->fail(UserLogic::getError()); //获取错误信息并返回错误信息 } return $this->success('ok', $res); } /** * 中间商品统计 */ public function product_count() { $res = ProductLogic::Count(5); if (ProductLogic::hasError()) { return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息 } return $this->success('ok', $res); } /** * 订单统计 */ public function order_user_num_count() { $res = OrderLogic::Count(5); if (ProductLogic::hasError()) { return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息 } return $this->success('ok', $res); } /** * 商品销量排行榜统计 */ public function sales_ranking() { $res = ProductLogic::sales(5); if (ProductLogic::hasError()) { return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息 } return $this->success('ok', $res); } /** * 成交用户数据 */ public function user_trade_count() { $dates = []; $today = new DateTime(); $thirtyDaysAgo = new DateTime($today->format('Y-m-d')); $thirtyDaysAgo->modify('-30 days'); for ($i = 0; $i < 31; $i++) { $date = new DateTime($thirtyDaysAgo->format('Y-m-d')); $date->modify('+' . $i . ' days'); $dates[] = $date->format('Y-m-d'); } $res = UserLogic::TradeCount(5, $dates); if (UserLogic::hasError()) { return $this->fail(UserLogic::getError()); //获取错误信息并返回错误信息 } return $this->success('ok', $res); } /** * 当日订单金额 */ public function street_currday_order_count() { $res = OrderLogic::Currday(5); if (ProductLogic::hasError()) { return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息 } return $this->success('ok', $res); } }