$this->repo->getPaymentMethods(), 'buybackPolicy' => $this->repo->getBuybackPolicy(), ]; } public function updateBuybackPolicy(array $input, int $actorAdminId, string $ip, string $ua): array { try { $before = $this->repo->getBuybackPolicy(); $data = [ 'customer_fee_rate' => (float)$input['customer_fee_rate'], 'bank_fee_type' => $input['bank_fee_type'], 'bank_fee_value' => (float)$input['bank_fee_value'], ]; $this->repo->updateBuybackPolicy($data); $this->audit->log( actorAdminId: $actorAdminId, action: 'admin.fee.buyback.update', targetType: 'buyback_policy', targetId: 1, before: (array)$before, after: array_merge((array)$before, $data), ip: $ip, ua: $ua, ); return ['ok' => true, 'message' => '매입(출금) 정책이 업데이트되었습니다.']; } catch (\Throwable $e) { return ['ok' => false, 'message' => '출금 정책 저장 중 오류가 발생했습니다.']; } } public function storePaymentMethod(array $input, int $actorAdminId, string $ip, string $ua): array { try { return DB::transaction(function () use ($input, $actorAdminId, $ip, $ua) { $data = [ 'code' => strtoupper(trim($input['code'])), 'name' => trim($input['name']), 'display_name' => trim($input['display_name']), 'customer_fee_rate' => (float)$input['customer_fee_rate'], 'pg_fee_rate' => (float)$input['pg_fee_rate'], 'is_active' => (int)$input['is_active'], 'sort_order' => 0, // 기본값 ]; $newId = $this->repo->insertPaymentMethod($data); $this->audit->log($actorAdminId, 'admin.fee.payment.create', 'payment_method', $newId, null, $data, $ip, $ua); return ['ok' => true, 'message' => '결제 수단이 등록되었습니다.']; }); } catch (\Throwable $e) { return ['ok' => false, 'message' => '결제수단 코드가 중복되거나 저장 오류가 발생했습니다.']; } } public function updatePaymentMethod(int $id, array $input, int $actorAdminId, string $ip, string $ua): array { try { return DB::transaction(function () use ($id, $input, $actorAdminId, $ip, $ua) { $before = $this->repo->findPaymentMethod($id); if (!$before) return ['ok' => false, 'message' => '결제 수단을 찾을 수 없습니다.']; $data = [ 'name' => trim($input['name']), 'display_name' => trim($input['display_name']), 'customer_fee_rate' => (float)$input['customer_fee_rate'], 'pg_fee_rate' => (float)$input['pg_fee_rate'], 'is_active' => (int)$input['is_active'], ]; $this->repo->updatePaymentMethod($id, $data); $this->audit->log($actorAdminId, 'admin.fee.payment.update', 'payment_method', $id, (array)$before, array_merge((array)$before, $data), $ip, $ua); return ['ok' => true, 'message' => '결제 수단이 수정되었습니다.']; }); } catch (\Throwable $e) { return ['ok' => false, 'message' => '수정 중 오류가 발생했습니다.']; } } public function updatePaymentSort(array $ids, int $actorAdminId): array { try { DB::transaction(function () use ($ids) { foreach ($ids as $index => $id) { $this->repo->updatePaymentSortOrder((int)$id, $index + 1); } }); return ['ok' => true]; } catch (\Throwable $e) { return ['ok' => false, 'message' => '정렬 중 오류가 발생했습니다.']; } } public function deletePaymentMethod(int $id, int $actorAdminId, string $ip, string $ua): array { $before = $this->repo->findPaymentMethod($id); if (!$before) return ['ok' => false, 'message' => '결제 수단을 찾을 수 없습니다.']; $this->repo->deletePaymentMethod($id); $this->audit->log($actorAdminId, 'admin.fee.payment.delete', 'payment_method', $id, (array)$before, null, $ip, $ua); return ['ok' => true, 'message' => '삭제되었습니다.']; } }