sjId; $shopId = $shop->id; $time = date('Ymd'); $stat = self::getByCondition(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $time], true); if (empty($stat)) { $stat = self::add(['shopId' => $shopId, 'sjId' => $sjId, 'time' => $time], true); } $id = $stat->id; $unique = self::getLockById($id); if (empty($unique)) { util::fail('没有记录'); } $currentAmount = bcadd($unique->amount, $amount, 2); $unique->amount = $currentAmount; $unique->totalAmount = $main->totalStockIn; $unique->save(); //当月 StatStockInMonthClass::replace($main, $shop, $amount); } }