$sjId, 'time' => $month], true); if (empty($stat)) { $stat = self::add(['sjId' => $sjId, 'time' => $month], true); } $stat->riseNum += 1; $stat->save(); } //月订单+1 public static function updateOrInsert($main, $shop) { $time = date('Ym'); $mainId = $shop->mainId ?? 0; $where = ['mainId' => $mainId, 'time' => $time]; $model = self::getByCondition($where, true); if (empty($model)) { $model = self::add(['mainId' => $mainId, 'time' => $time, 'riseNum' => 0, 'totalNum' => $main->totalOrderNum], true); } $id = $model->id; //查id行级锁 $stat = StatOrderMonthClass::getLockById($id); $stat->riseNum += 1; $stat->totalNum += 1; $stat->save(); } }