validator; } /** * 复制金额记录 * * @param string $fromScene 源场景 * @param int $fromId 源对象ID * @param string $toScene 目标场景 * @param int $toId 目标对象ID * @return int 插入条数 * @throws BusinessException */ public function copyMoneyValues(string $fromScene, int $fromId, string $toScene, int $toId): int { // 1. 查询源数据 $rows = Db::table('veh_money_value') ->where('object_scene', $fromScene) ->where('object_id', $fromId) ->get() ->toArray(); if (empty($rows)) { return 0; } $now = time(); $insertData = []; foreach ($rows as $row) { $insertData[] = [ 'object_scene' => $toScene, 'object_id' => $toId, 'field' => $row->field, 'currency' => $row->currency, 'amount' => $row->amount, 'exchange_rate' => $row->exchange_rate, 'remark' => $row->remark, 'created_at' => $now, 'updated_at' => $now, ]; } // 2. 插入新数据 return Db::table('veh_money_value')->insert($insertData); } }