feat: 修改了统计逻辑以使用正确的日期字段

This commit is contained in:
mkm 2024-06-25 18:12:07 +08:00
parent c699abfd6f
commit b7f8c6ad42

View File

@ -9,20 +9,20 @@ class ProductLogic extends BaseLogic
{
public static function Count($where,$time)
{
$todayProductCount=StoreBranchProduct::where($where)->whereDay($time)->count();
$todayProductCount=StoreBranchProduct::where($where)->whereDay('create_time',$time)->count();
$yestertodayProductCount=StoreBranchProduct::where($where)->where('create_time', '<',strtotime($time)-1)->count();
if ($yestertodayProductCount == 0 ||$todayProductCount==0) {
$weeklyProductTotalGrowthRate = 0;
} else {
$weeklyProductTotalGrowthRate = ($todayProductCount - $yestertodayProductCount) / $yestertodayProductCount * 100;
$weeklyProductTotalGrowthRate =bcdiv(($todayProductCount - $yestertodayProductCount) ,$yestertodayProductCount) * 100;
}
$todayNewProductCount=StoreBranchProduct::where($where)->whereDay('create_time',$time)->count();
$yestertodayNewProductCount=StoreBranchProduct::where($where)->whereDay('create_time', date('Y-m-d',strtotime($time)-1))->count();
if ($yestertodayProductCount == 0 ||$todayProductCount==0) {
if ($todayNewProductCount == 0 ||$yestertodayNewProductCount==0) {
$weeklyNewProductTotalGrowthRate = 0;
} else {
$weeklyNewProductTotalGrowthRate = ($todayNewProductCount - $yestertodayNewProductCount) / $yestertodayNewProductCount * 100;
$weeklyNewProductTotalGrowthRate =bcdiv(($todayNewProductCount - $yestertodayNewProductCount),$yestertodayNewProductCount) * 100;
}
$data = [
"totalProductCounInfo" => [