[ [ 'mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'user_id' => $this->user_id ] ], 'select' => 'id, name, mobile, id_card, sex, age', 'order' => 'id desc' ]); } /** * 用药人详情 * * @param int $id * * @return array */ public function detail(int $id): array { $find = MedicationRecipient::find(); $select = 'id, name, mobile, id_card, sex, age, is_allergy_history, allergy_history_details, is_medical_history, ' . 'sickness_detail, liver_function_status, kidney_function_status, pregnancy_breastfeeding_status'; MedicationRecipient::paramPack([ 'where' => [ [ 'mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'user_id' => $this->user_id, 'id' => $id ] ], 'select' => $select, ], $find); return $find->asArray()->one() ?: []; } /** * 编辑/保存 用药人 * * @param array $data * * @return bool */ public function edit(array $data): bool { if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_REAL_AUTH)) { $config = Yii::$app->services->setting->addons->get($this->mall_id, AddonsEnum::ADDONS_NAME_REAL_AUTH, 'basic'); if (!empty($config['status'])) { try { if (!(new AuthLogic)->auth([ 'user_id' => $this->user_id, 'mall_id' => $this->mall_id, 'real_name' => $data['name'], 'id_no' => $data['id_card'], 'auth_type' => RealAuthUser::USER, 'check_pass_mode' => 1 ])) { $this->error = '实名验证失败'; return false; } }catch (Exception $e) { if ($e->getMessage() !== '您已通过实名认证') { $this->error = $e->getMessage(); return false; } } } } $data['user_id'] = $this->user_id; $data['mall_id'] = $this->mall_id; if (MedicationRecipient::setData($data) === false) { $this->error = MedicationRecipient::getStaticError(); return false; } return true; } /** * 删除用药人 * * @param int $id * * @return void */ public function del(int $id): bool { return (bool)MedicationRecipient::updateAll( [ 'updated_at' => time(), 'status' => StatusEnum::DELETE ], [ 'id' => $id, 'mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'user_id' => $this->user_id ] ); } }