161 lines
7.2 KiB
PHP
Executable File
161 lines
7.2 KiB
PHP
Executable File
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace app\adminapi\validate\tcm;
|
||
|
||
use app\common\validate\BaseValidate;
|
||
|
||
class PrescriptionOrderValidate extends BaseValidate
|
||
{
|
||
protected $rule = [
|
||
'id' => 'require|integer',
|
||
'create_time' => 'require|string|dateFormat:Y-m-d H:i:s',
|
||
'diagnosis_id' => 'require|integer|gt:0',
|
||
'prescription_id' => 'require|integer',
|
||
'pay_order_ids' => 'array',
|
||
'recipient_name' => 'require|max:50',
|
||
'recipient_phone' => 'require|max:20',
|
||
'shipping_address' => 'require|max:500',
|
||
'is_follow_up' => 'in:0,1',
|
||
'prev_staff' => 'max:100',
|
||
'service_channel' => 'max:100',
|
||
'service_package' => 'max:100',
|
||
'tracking_number' => 'max:80',
|
||
'express_company' => 'max:20',
|
||
'ship_mode' => 'in:gancao,direct',
|
||
'resolution' => 'require|in:CONFIRM_SUCCESS,CONFIRM_NOT_CREATED',
|
||
'remote_order_no' => 'max:64',
|
||
'note' => 'require|max:1000',
|
||
'fee_type' => 'require|in:1,2,3,4,5,6,7,8',
|
||
'amount' => 'require|float',
|
||
'order_type' => 'require|in:1,2,3,4,5,6,7,8',
|
||
'pay_amount' => 'require|float|egt:0',
|
||
'pay_remark' => 'max:200',
|
||
'remark_extra' => 'max:500',
|
||
'remark_assistant' => 'max:500',
|
||
'action' => 'require|in:approve,reject',
|
||
'remark' => 'max:500',
|
||
'summary' => 'require|max:500',
|
||
'prescription_audit_status' => 'in:0,1,2',
|
||
'payment_slip_audit_status' => 'in:0,1,2',
|
||
'prescription_audit_remark' => 'max:500',
|
||
'payment_slip_audit_remark' => 'max:500',
|
||
'fulfillment_status' => 'require|integer|in:3,7,8,9,11,12',
|
||
'reason' => 'require|max:500',
|
||
'refund_amount' => 'float|egt:0',
|
||
'patient_name' => 'require|max:50',
|
||
'phone' => 'require|max:20',
|
||
'phone_tail' => 'max:20|regex:/^\\d*$/',
|
||
];
|
||
|
||
protected $message = [
|
||
'prescription_id.require' => '请选择处方',
|
||
'diagnosis_id.require' => '请选择诊单',
|
||
'recipient_name.require' => '请输入收货人',
|
||
'recipient_phone.require' => '请输入收货手机',
|
||
'shipping_address.require' => '请输入收货地址',
|
||
'fee_type.require' => '请选择费用类别',
|
||
'amount.require' => '请输入订单金额',
|
||
'action.require' => '请选择审核操作',
|
||
'patient_name.require' => '请输入患者姓名',
|
||
'phone.require' => '请输入手机号',
|
||
'tracking_number.require' => '请输入快递单号',
|
||
'phone_tail.regex' => '手机后四位仅支持数字',
|
||
'reason.require' => '请填写退款原因',
|
||
'create_time.require' => '创建时间必填',
|
||
'create_time.dateFormat' => '创建时间格式不正确',
|
||
];
|
||
|
||
protected $scene = [
|
||
'create' => [
|
||
'prescription_id', 'diagnosis_id', 'recipient_name', 'recipient_phone', 'shipping_address',
|
||
'is_follow_up', 'prev_staff', 'service_channel', 'service_package',
|
||
'tracking_number', 'express_company', 'ship_mode', 'fee_type', 'amount', 'remark_extra', 'remark_assistant', 'pay_order_ids',
|
||
],
|
||
'detail' => ['id'],
|
||
'editTime' => ['id', 'create_time'],
|
||
'edit' => [
|
||
'id', 'recipient_name', 'recipient_phone', 'shipping_address',
|
||
'is_follow_up', 'prev_staff', 'service_channel', 'service_package',
|
||
'tracking_number', 'express_company', 'fee_type', 'amount', 'remark_extra', 'remark_assistant', 'pay_order_ids',
|
||
],
|
||
'ddcode' => ['id', 'tracking_number', 'express_company'],
|
||
'logisticsTrace' => ['id', 'phone_tail'],
|
||
'logisticsJdUpdate' => ['id'],
|
||
'auditPrescription' => ['id', 'action', 'remark'],
|
||
'auditPayment' => ['id', 'action', 'remark'],
|
||
'withdraw' => ['id'],
|
||
'ship' => ['id', 'tracking_number', 'express_company', 'ship_mode'],
|
||
'logs' => ['id'],
|
||
'addLog' => ['id', 'summary'],
|
||
'paidPayOrders' => ['diagnosis_id'],
|
||
'addPayOrder' => ['id', 'order_type', 'pay_amount', 'pay_remark'],
|
||
'linkPayOrder' => ['id', 'pay_order_id'],
|
||
'unlinkPayOrder' => ['id', 'pay_order_id'],
|
||
'requestCompletion' => ['id'],
|
||
'complete' => ['id', 'fulfillment_status'],
|
||
'refund' => ['id', 'reason', 'refund_amount'],
|
||
'submitGancaoRecipel' => ['id'],
|
||
'uploadToPharmacy' => ['id'],
|
||
'previewGancaoRecipel' => ['id'],
|
||
'patchPrescriptionPatient' => ['id', 'patient_name', 'phone'],
|
||
'patchPrescriptionUsage' => ['id', 'times_per_day', 'usage_days', 'medication_days', 'dosage_bag_count', 'aux_times_per_day', 'aux_usage_days', 'aux_dosage_bag_count'],
|
||
'updateAmount' => ['id', 'amount'],
|
||
'setShipMode' => ['id', 'ship_mode'],
|
||
'confirmGancaoSubmission' => ['id', 'resolution', 'remote_order_no', 'note'],
|
||
];
|
||
|
||
public function sceneUnlinkPayOrder(): PrescriptionOrderValidate
|
||
{
|
||
return $this->only(['id', 'pay_order_id'])
|
||
->append('id', 'require|integer|gt:0')
|
||
->append('pay_order_id', 'require|integer|gt:0');
|
||
}
|
||
|
||
public function sceneEditTime(): PrescriptionOrderValidate
|
||
{
|
||
return $this->only(['id', 'create_time'])->append('id', 'require|integer|gt:0');
|
||
}
|
||
|
||
public function updateAmount(): PrescriptionOrderValidate
|
||
{
|
||
return $this->only(['id', 'amount'])
|
||
->append('id', 'require|integer|gt:0')
|
||
->append('amount', 'require|float|egt:0');
|
||
}
|
||
|
||
public function ddcode(): PrescriptionOrderValidate
|
||
{
|
||
return $this->only(['id', 'tracking_number', 'express_company'])
|
||
->append('id', 'require|integer|gt:0')
|
||
->append('tracking_number', 'require|max:80')
|
||
->append('express_company', 'max:20');
|
||
}
|
||
|
||
public function scenePatchPrescriptionUsage(): PrescriptionOrderValidate
|
||
{
|
||
$this->only(['id', 'times_per_day', 'usage_days', 'medication_days', 'dosage_bag_count', 'aux_times_per_day', 'aux_usage_days', 'aux_dosage_bag_count'])
|
||
->append('id', 'require|integer|gt:0')
|
||
->append('times_per_day', 'require|integer|between:1,6')
|
||
->append('usage_days', 'require|integer|between:1,999')
|
||
->append('medication_days', 'require|integer|between:1,999')
|
||
->append('aux_times_per_day', 'integer|between:1,6')
|
||
->append('aux_usage_days', 'integer|between:1,999');
|
||
|
||
foreach (['dosage_bag_count' => '主方', 'aux_dosage_bag_count' => '辅方'] as $field => $label) {
|
||
$this->append($field, [static function ($value, array $data) use ($field, $label) {
|
||
if (!array_key_exists($field, $data)) {
|
||
return true;
|
||
}
|
||
|
||
return (is_int($value) || is_string($value)) && preg_match('/^[1-5]$/D', (string) $value) === 1
|
||
? true
|
||
: $label . '袋数须为 1~5 的整数';
|
||
}]);
|
||
}
|
||
|
||
return $this;
|
||
}
|
||
}
|