更新数据库加密相关操作

This commit is contained in:
2025-01-15 13:16:48 +08:00
parent 81069274be
commit 262ecc4f5e
12 changed files with 383 additions and 90 deletions

View File

@@ -40,105 +40,116 @@ class DoctorWorkController extends BaseAppController
*/
public function actionInfo()
{
$post= \Yii::$app->request->post();
$store = Store::findOne(\Yii::$app->store);
if(!$store)throw new Exception('门店不存在');
try {
$post= \Yii::$app->request->post();
$store = Store::findOne(\Yii::$app->store);
if(!$store)throw new Exception('门店不存在');
$DoctorInfo= DoctorInfo::find()
->where(['su_id' => \Yii::$app->user->identity->id])
->with(['title', 'hospital','depart','user'])
->one();
$DoctorIdentity= DoctorIdentity::find()
->where(['su_id' => \Yii::$app->user->identity->id])
->one();
$DoctorPracticing= DoctorPracticing::find()
->where(['su_id' => \Yii::$app->user->identity->id])
->one();
if(!$DoctorInfo || !$DoctorIdentity || !$DoctorPracticing){
throw new Exception('医生信息错误');
}
$storeDoctor = StoreDoctor::find()->where([
'su_id' => \Yii::$app->user->identity->getId(),
'store_id' => \Yii::$app->store
])->one();
if(!$storeDoctor)throw new Exception('非该门店医生');
$DoctorInfo= DoctorInfo::find()
->where(['su_id' => \Yii::$app->user->identity->id])
->with(['title', 'hospital','depart','user'])
->one();
$DoctorIdentity= DoctorIdentity::find()
->where(['su_id' => \Yii::$app->user->identity->id])
->one();
$DoctorPracticing= DoctorPracticing::find()
->where(['su_id' => \Yii::$app->user->identity->id])
->one();
if(!$DoctorInfo || !$DoctorIdentity || !$DoctorPracticing){
throw new Exception('医生信息错误');
}
$storeDoctor = StoreDoctor::find()->where([
'su_id' => \Yii::$app->user->identity->getId(),
'store_id' => \Yii::$app->store
])->one();
if(!$storeDoctor)throw new Exception('非该门店医生');
//门店医生小程序码
if(!$storeDoctor->qr_code){
$response = WechatService::getInstance()->app->app_code->getUnlimit('su_id='.\Yii::$app->user->identity->getId().'&store_id='.\Yii::$app->store, [
'page' => 'subPackages/doctor/doctor-detail',
'check_path' => false,
]);
if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
$path = 'uploads/doctor_code/' . date('Ymd');
$filename = $response->save('uploads/doctor_code/' . date('Ymd'), 'doctor_code_' . $DoctorInfo->su_id.\Yii::$app->store);
$realpath = FuncHelper::getRealFilepath('service', $path . '/' . $filename);
$uploadService = new UploadService();
$url = $uploadService->saveFile($realpath);
$storeDoctor->qr_code = $url;
//门店医生小程序码
if(!$storeDoctor->qr_code){
$response = WechatService::getInstance()->app->app_code->getUnlimit('su_id='.\Yii::$app->user->identity->getId().'&store_id='.\Yii::$app->store, [
'page' => 'subPackages/doctor/doctor-detail',
'check_path' => false,
]);
if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
$path = 'uploads/doctor_code/' . date('Ymd');
$filename = $response->save('uploads/doctor_code/' . date('Ymd'), 'doctor_code_' . $DoctorInfo->su_id.\Yii::$app->store);
$realpath = FuncHelper::getRealFilepath('service', $path . '/' . $filename);
$uploadService = new UploadService();
$url = $uploadService->saveFile($realpath);
$storeDoctor->qr_code = $url;
$storeDoctor->save();
}
}
//门店医生在线状态
if($storeDoctor->is_online != 1){
StoreDoctor::updateAll(['is_online' => 0],['su_id' => \Yii::$app->user->identity->getId(), 'is_online' => 1]);
$storeDoctor->is_online = 1;
$storeDoctor->last_login_time = time();
$storeDoctor->save();
}
}
//门店医生在线状态
if($storeDoctor->is_online != 1){
StoreDoctor::updateAll(['is_online' => 0],['su_id' => \Yii::$app->user->identity->getId(), 'is_online' => 1]);
$storeDoctor->is_online = 1;
$storeDoctor->last_login_time = time();
$storeDoctor->save();
}
$relates = $DoctorInfo->getRelatedRecords();
$DoctorInfo = $DoctorInfo->toArray();
$DoctorInfo = array_merge($DoctorInfo, $relates);
$wait_accept=Register::find()->where([
'service_user_id'=> \Yii::$app->user->identity->id,
'store_id'=> $post['store_id'],
'status'=>RegisterEnum::WAIT,
'is_pay'=>1,
'is_cancel'=>0,
'is_delete'=>0
])->count();
$relates = $DoctorInfo->getRelatedRecords();
$DoctorInfo = $DoctorInfo->toArray();
$DoctorInfo = array_merge($DoctorInfo, $relates);
$accepting = Register::find()->where([
'service_user_id'=> \Yii::$app->user->identity->id,
'store_id'=> $post['store_id'],
'status'=>RegisterEnum::ACCEPTING,
'is_pay'=>1,
'is_cancel'=>0,
'is_delete'=>0
])->count();
$wait_accept=Register::find()->where([
'service_user_id'=> \Yii::$app->user->identity->id,
'store_id'=> $post['store_id'],
'status'=>RegisterEnum::WAIT,
'is_pay'=>1,
'is_cancel'=>0,
'is_delete'=>0
])->count();
$idcard= DoctorInfo::find()->select(['idcard'])->where(['su_id'=>\Yii::$app->user->id])->one();
$number = substr($idcard['idcard'], strlen($idcard['idcard']) - 2, 1);
$sex=$number % 2 == 0?'女':'男';
$accepting = Register::find()->where([
'service_user_id'=> \Yii::$app->user->identity->id,
'store_id'=> $post['store_id'],
'status'=>RegisterEnum::ACCEPTING,
'is_pay'=>1,
'is_cancel'=>0,
'is_delete'=>0
])->count();
#医生开通的服务
$doctor_service = DoctorService::find()->where(['su_id' => \Yii::$app->user->identity->id])->asArray()->one();
$DoctorInfo['qr_code'] = $storeDoctor->qr_code;
// TODO 这里
$idcard= DoctorInfo::find()->select(['idcard'])->where(['su_id'=>\Yii::$app->user->id])->one();
$number = substr($idcard['idcard'], strlen($idcard['idcard']) - 2, 1);
$sex=$number % 2 == 0?'女':'男';
$ServiceUser=ServiceUser::find()->select(['reason','status'])->where(['id'=>\Yii::$app->user->identity->id])->one();
#医生开通的服务
$doctor_service = DoctorService::find()->where(['su_id' => \Yii::$app->user->identity->id])->asArray()->one();
$DoctorInfo['qr_code'] = $storeDoctor->qr_code;
return [
'store'=>[
'store_id' => $store->id,
'store' => [
'id' => $store->id,
'name' => $store->name,
'see_rate'=>$store->see_rate,
$ServiceUser=ServiceUser::find()->select(['reason','status'])->where(['id'=>\Yii::$app->user->identity->id])->one();
return [
'store'=>[
'store_id' => $store->id,
'store' => [
'id' => $store->id,
'name' => $store->name,
'see_rate'=>$store->see_rate,
]
],
'DoctorInfo'=>$DoctorInfo,
'doctor_service'=>$doctor_service,
'DoctorIdentity'=>$DoctorIdentity,
'DoctorPracticing'=>$DoctorPracticing,
'wait_accept'=>$wait_accept,
'accepting'=>$accepting,
'sex'=>$sex,
'ServiceUser'=>$ServiceUser
];
} catch (\Exception $e) {
return [
'code' => 1,
'msg' => $e->getMessage(),
'data' => [
'line' => $e->getLine(),
]
],
'DoctorInfo'=>$DoctorInfo,
'doctor_service'=>$doctor_service,
'DoctorIdentity'=>$DoctorIdentity,
'DoctorPracticing'=>$DoctorPracticing,
'wait_accept'=>$wait_accept,
'accepting'=>$accepting,
'sex'=>$sex,
'ServiceUser'=>$ServiceUser
];
];
}
}
/**