<?php

declare(strict_types=1);

namespace App\Request;

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

class UserDoctorRequest extends FormRequest
{
    protected array $scenes = [
        'getInquiryConfig' => [ // 获取医生问诊配置
            'inquiry_type',
            'inquiry_mode',
        ],
        'putInquiryOpen' => [ // 医生问诊开关
            'inquiry_type',
            'inquiry_mode',
            'is_open',
        ],
        'putInquiryConfig' => [ // 修改医生问诊配置
            'inquiry_type',
            'inquiry_mode',
            'inquiry_price',
            'work_num_day',
        ],
        'addDoctorBankCard' => [ // 新增绑定医生银行卡
            'bank_id',
            'bank_card_code',
            'province_id',
            'city_id',
            'county_id',
        ],
        'putDoctorBankCard' => [ // 更换医生银行卡
            'bank_id',
            'bank_card_code',
            'province_id',
            'city_id',
            'county_id',
        ],
        'getPrescriptionList' => [ // 获取处方列表
            'pharmacist_audit_status' // 药师审核状态（0:审核中 1:审核成功 2:审核驳回）
        ],
        'getDoctorWords' => [ // 获取常用语列表
            'words_type'
        ],
        'addDoctorWords' => [ // 新增常用语列表
            'words',
            'words_type'
        ],
        'getDoctorEvaluationList' => [ // 获取医生评价
            'doctor_id',
            'evaluation_type',
        ],
        'getPrescriptionInfo' => [ // 获取处方详情
            'order_inquiry_id',
        ],
        'putPrescription' => [ // 修改处方
            'order_prescription_id',
            'prescription_icd',// 诊断疾病
//            'doctor_advice', // 医嘱
            'prescription_product',// 处方药品
        ],
        'addPrescription' => [ // 新增处方
            'order_inquiry_id',// 订单-问诊id
            'prescription_icd',// 诊断疾病[]
//            'doctor_advice', // 医嘱
            'prescription_product',// 处方药品[]
        ],
        'getDoctorMessageList' => [ // 获取医生问诊消息列表
            'message_inquiry_type',// 消息订单类型（1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:结束）
        ],
    ];

    /**
     * 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:3',
            'inquiry_mode' => 'required|integer|min:1|max:5',
            'is_open' => "required|boolean",
            'inquiry_price' => "required|min:0|numeric",
            'work_num_day' => "required|min:0|numeric",
            'bank_id' => "required",
            'bank_card_code' => ['required'],
            'province_id' => 'required|required_with:city_id,county_id',
            'city_id' => 'required|required_with:county_id',
            'county_id' => 'required',
            'pharmacist_audit_status' => 'required|integer|min:0|max:3',
            'words_type' => 'required|integer|min:1|max:3',
            'words' => 'required',
            'doctor_id' => 'required',
            'evaluation_type' => 'required|integer|min:1|max:3',
            'order_inquiry_id' => 'required',

            'order_prescription_id' => 'required',
            'prescription_icd' => 'required|array|min:1',
            'doctor_advice' => 'required',
            'prescription_product' => 'required|array|min:1',
            'message_inquiry_type' => 'required|integer|min:1|max:5',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息.
     */
    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),
            'is_open.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_open.boolean' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_price.required' => "请填写价格",
            'inquiry_price.min' => "价格填写错误",
            'inquiry_price.numeric' => "价格填写错误",
            'inquiry_mode.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'work_num_day.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'work_num_day.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'work_num_day.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),

            'bank_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'bank_card_code.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'bank_card_code.regex' => "银行卡号填写错误",
            'province_id.required_with' => "请选择省份",
            'province_id.required' => "请选择省份",
            'city_id.required_with' => "请选择城市",
            'city_id.required' => "请选择城市",
            'county_id.required' => "请选择区县",
            'pharmacist_audit_status.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'pharmacist_audit_status.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'pharmacist_audit_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'pharmacist_audit_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'words_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'words_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'words_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'words_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'words.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'doctor_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'evaluation_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'evaluation_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'evaluation_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'evaluation_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'order_inquiry_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),

            'order_prescription_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'prescription_icd.required' => "请填写诊断疾病",
            'prescription_icd.array' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'prescription_icd.min' => "请填写诊断疾病",
            'doctor_advice.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'prescription_product.required' => "请开具药品",
            'prescription_product.array' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'prescription_product.min' => "请开具药品",

            'message_inquiry_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'message_inquiry_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'message_inquiry_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'message_inquiry_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
        ];
    }
}
