sjId; $shopId = $shop->id; $month = isset($month) ? $month : date("Ym"); $stat = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $month], true); if (empty($stat)) { $stat = self::add(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $month], true); } $stat->riseNum += 1; $stat->totalNum = $shop['totalStudent'] + 1; $stat->save(); } }