'待开方', self::PRESCRIPTION_STATUS_OPENED => '成功', self::PRESCRIPTION_STATUS_FAIL => '失败', ]; const AUDIT_STATUS_REJECTED = -1; // 审核不通过 const AUDIT_STATUS_PENDING = 0; // 待审核 const AUDIT_STATUS_TO_BE_REVIEWED = 1; // 待复核 const AUDIT_STATUS_ISSUED = 2; // 已核发 const AUDIT_STATUS_MAP = [ self::AUDIT_STATUS_REJECTED => '审核不通过', self::AUDIT_STATUS_PENDING => '待审核', self::AUDIT_STATUS_TO_BE_REVIEWED => '待复核', self::AUDIT_STATUS_ISSUED => '已核发', ]; /** * {@inheritdoc} */ public static function tableName() { return 'qimall_order_prescription_details'; } /** * {@inheritdoc} */ public function rules() { return [ [['mall_id', 'user_id', 'order_id', 'prescription_status', 'audit_status', 'status', 'created_at', 'updated_at'], 'integer'], [['symptom', 'medication_recipient'], 'safe'], [['prescription_err_msg'], 'string', 'max' => 100], [['img_url'], 'string', 'max' => 255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'user_id' => 'User ID', 'order_id' => 'Order ID', 'symptom' => 'Symptom', 'prescription_status' => 'Prescription Status', 'prescription_err_msg' => 'Prescription Err Msg', 'img_url' => 'Img Url', 'medication_recipient' => 'Medication Recipient', 'audit_status' => 'Audit Status', 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * @param array $params * * @return bool|self */ public static function setData(array $params) { try { if (!empty($params['id'])) { $model = static::findOne(['id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if (!$model) { throw new RuntimeException('数据不存在或已删除'); } if ($model->mall_id != $params['mall_id']) { throw new RuntimeException('不允许操作此数据'); } } else { $model = new static(); $model->loadDefaultValues(); } if (!$model->load($params, '')) { throw new RuntimeException($model->getErrorMessage()); } if (!$model->save()) { throw new RuntimeException($model->getErrorMessage()); } return $model; } catch (Exception $e) { static::$static_error = $e->getMessage(); return false; } } }