sjId ?? 0; $mainId = $main->id ?? 0; $month = isset($month) ? $month : date("Ym"); $stat = self::getByCondition(['sjId' => $sjId, 'mainId' => $mainId, 'time' => $month], true); if (empty($stat)) { $stat = self::add(['sjId' => $sjId, 'time' => $month, 'mainId' => $mainId, 'shopAdminId' => $shopAdminId], true); } $stat->num += 1; $stat->totalNum += 1; $stat->amount = bcadd($amount, $stat->amount, 2); $stat->totalAmount = bcadd($amount, $stat->totalAmount, 2); $stat->save(); $stat->save(); } }