0) { $todayProductCount = Db::connect('demo')->name('store_branch_product')->where($where)->whereDay('create_time', $time)->count(); $yestertodayProductCount = Db::connect('demo')->name('store_branch_product')->where($where)->where('create_time', '<', strtotime($time) - 1)->count(); $todayNewProductCount = Db::connect('demo')->name('store_branch_product')->where($where)->whereDay('create_time', $time)->count(); $yestertodayNewProductCount = Db::connect('demo')->name('store_branch_product')->where($where)->whereDay('create_time', date('Y-m-d', strtotime($time) - 1))->count(); $where['id']=$where['store_id']; unset($where['store_id']); } else { $todayProductCount = Db::connect('demo')->name('store_product')->whereDay('create_time', $time)->count(); $yestertodayProductCount = Db::connect('demo')->name('store_product')->count(); $todayNewProductCount = Db::connect('demo')->name('store_product')->whereDay('create_time', $time)->count(); $yestertodayNewProductCount = Db::connect('demo')->name('store_product')->whereDay('create_time', date('Y-m-d', strtotime($time) - 1))->count(); } if ($yestertodayProductCount == 0 || $todayProductCount == 0) { $weeklyProductTotalGrowthRate = 0; } else { $weeklyProductTotalGrowthRate = bcdiv(($todayProductCount - $yestertodayProductCount), $yestertodayProductCount) * 100; } if ($todayNewProductCount == 0 || $yestertodayNewProductCount == 0) { $weeklyNewProductTotalGrowthRate = 0; } else { $weeklyNewProductTotalGrowthRate = bcdiv(($todayNewProductCount - $yestertodayNewProductCount), $yestertodayNewProductCount) * 100; } $todayMerchantCount = SystemStore::where($where)->whereDay('create_time', $time)->count(); $where['is_show'] = 1; $yestertodayMerchantCount = SystemStore::where($where)->count(); $data = [ "totalProductCounInfo" => [ "todayProductCount" => $todayProductCount, "yestertodayProductCount" => $yestertodayProductCount, "weeklyProductTotalGrowthRate" => $weeklyProductTotalGrowthRate ], "newProductCountInfo" => [ "todayNewProductCount" => 0, "yestertodayNewProductCount" => 0, "weeklyNewProductTotalGrowthRate" => $weeklyNewProductTotalGrowthRate ], "merchantCountInfo" => [ "todayMerchantCount" => $todayMerchantCount, "yestertodayMerchantCount" => $yestertodayMerchantCount, "weeklyMerchantGrowthRate" => 0 ] ]; return $data; } public static function sales($where) { $select = Db::connect('demo')->name('store_branch_product')->where($where)->limit(10)->order('sales desc')->field('id,store_name,image,sales')->select(); return $select?->toArray(); } }