<?php

declare(strict_types=1);

namespace App\Request;

use App\Constants\HttpEnumCode;
use Hyperf\Validation\Request\FormRequest;

class PatientOrderRequest extends FormRequest
{
    protected array $scenes = [
        'getPatientInquiryOrderList' => [ // 获取患者问诊订单列表
            'inquiry_status',// 问诊订单状态（0:全部 1:待支付 2:待接诊 3:问诊中 4:完成/取消
            'family_id',// 家庭成员id（就诊用户）
        ],
        'getPatientProductOrderList' => [ // 获取药品订单列表
            'order_product_status',// 订单状态（0：全部 1:待支付 2:待发货 3:已发货 4:已签收 5:已取消）
            'family_id',// 家庭成员id（就诊用户）
        ],
        'getPatientOrderPayInfo' => [ // 获取患者订单支付数据
            "order_type", // 订单类型（1：问诊订单 2：药品订单）
            "order_no"// 订单编号
        ],
        'addPatientOrderPay' => [ // 模拟支付成功-金额为0时使用
            "order_no"// 订单编号
        ],
        'addPatientProductOrder' => [ // 创建药品订单
            "order_prescription_id",
            "address_id",
            "product_ids",
            "client_type",
        ],
        'getPatientPrescriptionOrderList' => [ // 获取处方订单列表
        ],
    ];

    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'inquiry_type' => 'required|integer|min:1|max:4',
            'inquiry_mode' => 'required|integer|min:1|max:5',
            'patient_id' => 'required',
            'family_id' => 'required',
            'disease_class_id' => 'required',
            'diagnosis_date' => 'date',
            'disease_desc' => 'required',
            'is_allergy_history' => ['sometimes','numeric','min:0','max:1'],
            'is_family_history' => ['sometimes','numeric','min:0','max:1'],
            'is_pregnant' => ['sometimes','numeric','min:0','max:1'],
            'client_type' => 'required|integer|min:1|max:2',

            'doctor_id' => 'required',
            'order_inquiry_id' => 'required',
            'reply_quality' => 'required|integer|min:0|max:5',
            'service_attitude' => 'required|integer|min:0|max:5',
            'reply_progress' => 'required|integer|min:0|max:5',//

            'inquiry_status' => 'required|integer|min:0|max:4',

            'order_type' => 'required|integer|min:1|max:2',
            'order_no' => 'required',

            'order_prescription_id' => 'required',
            'address_id' => 'required',
            'product_ids' => 'required|array|min:1',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息.
     */
    public function messages(): array
    {
        return [
            'inquiry_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_mode.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_mode.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_mode.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_mode.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),

            'patient_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'family_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'disease_class_id.required' => "请您选择疾病",
            'diagnosis_date.date' => HttpEnumCode::getMessage(HttpEnumCode::DATE_FORMAT_ERROR),
            'disease_desc.required' => "请您输入病情主诉",
            'is_allergy_history.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_allergy_history.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_allergy_history.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_family_history.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_family_history.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_family_history.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_pregnant.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_pregnant.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_pregnant.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'client_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'client_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'client_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'client_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),

            'inquiry_status.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_status.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),

            'order_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'order_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'order_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'order_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'order_no.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'order_prescription_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'address_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'product_ids.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'product_ids.array' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'product_ids.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
        ];
    }
}
