// // OrderDialogControllers.swift // suixinkan // import UIKit enum OrderRefundAlertController { static func present( from presenter: UIViewController, order: OrderEntity, onConfirm: @escaping (OrderRefundRequest) -> Void ) { let alert = UIAlertController(title: "订单退款", message: order.orderNumber, preferredStyle: .alert) alert.addTextField { $0.placeholder = "退款金额"; $0.text = order.actualPayAmount } alert.addTextField { $0.placeholder = "退款原因" } alert.addAction(UIAlertAction(title: "取消", style: .cancel)) alert.addAction(UIAlertAction(title: "确认退款", style: .destructive) { _ in let amount = alert.textFields?.first?.text ?? order.actualPayAmount let reason = alert.textFields?.last?.text ?? "" onConfirm(OrderRefundRequest(orderNumber: order.orderNumber, refundType: 1, refundAmount: amount, refundReason: reason)) }) presenter.present(alert, animated: true) } } enum DepositOrderRefundAlertController { static func present( from presenter: UIViewController, orderNumber: String, amount: String, refundType: Int, onConfirm: @escaping (String, String) -> Void ) { let title = refundType == 3 ? "部分退款" : "全额退款" let alert = UIAlertController(title: title, message: orderNumber, preferredStyle: .alert) alert.addTextField { $0.placeholder = "退款金额"; $0.text = amount } alert.addTextField { $0.placeholder = "退款原因" } alert.addAction(UIAlertAction(title: "取消", style: .cancel)) alert.addAction(UIAlertAction(title: "确认", style: .destructive) { _ in let refundAmount = alert.textFields?.first?.text ?? amount let reason = alert.textFields?.last?.text ?? "" onConfirm(refundAmount, reason) }) presenter.present(alert, animated: true) } } enum OrderSignInAlertController { static func present(from presenter: UIViewController, response: OrderSignInResponse) { let message = """ 项目:\(response.projectName) 景区:\(response.scenicName) 金额:¥\(response.orderAmount) 手机号:\(response.userPhone) """ let alert = UIAlertController(title: response.checkIn ? "签到成功" : "核销结果", message: message, preferredStyle: .alert) alert.addAction(UIAlertAction(title: "确定", style: .default)) presenter.present(alert, animated: true) } } enum WriteOffResultAlertController { static func present(from presenter: UIViewController, response: WriteOffOrderResponse) { let message = """ 项目:\(response.projectName) 景区:\(response.scenicName) 金额:¥\(response.orderAmount) 手机号:\(response.userPhone) """ let alert = UIAlertController(title: response.orderVerify ? "核销成功" : "核销结果", message: message, preferredStyle: .alert) alert.addAction(UIAlertAction(title: "确定", style: .default)) presenter.present(alert, animated: true) } } enum SendGiftAlertController { static func present( from presenter: UIViewController, photoNum: Int, videoNum: Int, onConfirm: @escaping (Int, Int) -> Void ) { let alert = UIAlertController(title: "赠送修图", message: nil, preferredStyle: .alert) alert.addTextField { $0.placeholder = "赠送照片数"; $0.keyboardType = .numberPad; $0.text = "\(photoNum)" } alert.addTextField { $0.placeholder = "赠送视频数"; $0.keyboardType = .numberPad; $0.text = "\(videoNum)" } alert.addAction(UIAlertAction(title: "取消", style: .cancel)) alert.addAction(UIAlertAction(title: "确认", style: .default) { _ in let photo = Int(alert.textFields?.first?.text ?? "0") ?? 0 let video = Int(alert.textFields?.last?.text ?? "0") ?? 0 onConfirm(photo, video) }) presenter.present(alert, animated: true) } }