1. 挂号绑定挂号id
This commit is contained in:
@@ -26,11 +26,12 @@ class RegisterForm extends BaseModel
|
||||
public $service_user_id;
|
||||
public $register_id;
|
||||
public $register_type;
|
||||
public $origin_store_id;
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['store_id', 'user_id','register_id'], 'integer'],
|
||||
[['store_id', 'user_id', 'register_id', 'origin_store_id'], 'integer'],
|
||||
[['user_patient_id', 'service_user_id', 'register_type'], 'required']
|
||||
];
|
||||
}
|
||||
@@ -117,26 +118,35 @@ class RegisterForm extends BaseModel
|
||||
|
||||
$t = \Yii::$app->db->beginTransaction();
|
||||
try {
|
||||
// 确定实际使用的门店ID
|
||||
// 如果是购药(register_type=3)且当前门店(药店)配置了委托诊所,则使用委托诊所ID
|
||||
// 如果是诊所在线复诊(register_type=2),需要确保是诊所(store.type=0)
|
||||
$actualStoreId = \Yii::$app->store;
|
||||
// 确定实际使用的门店ID(履约诊所)
|
||||
// 在线场景优先使用前端传入的 store_id(如委托诊所);药店复诊再按配置覆盖为委托诊所
|
||||
$actualStoreId = (int) ($this->store_id ?: \Yii::$app->store);
|
||||
if ($this->register_type == 3) {
|
||||
$currentStore = Store::findOne($actualStoreId);
|
||||
$currentStore = Store::findOne(\Yii::$app->store);
|
||||
if ($currentStore && !empty($currentStore->delegate_store_id)) {
|
||||
$actualStoreId = $currentStore->delegate_store_id;
|
||||
$actualStoreId = (int) $currentStore->delegate_store_id;
|
||||
}
|
||||
} elseif ($this->register_type == 2) {
|
||||
// 诊所在线复诊:确保是诊所(store.type=0)
|
||||
$currentStore = Store::findOne($actualStoreId);
|
||||
// 诊所在线复诊:发起方诊所校验(会话门店须为诊所)
|
||||
$currentStore = Store::findOne(\Yii::$app->store);
|
||||
if ($currentStore && $currentStore->type != 0) {
|
||||
throw new Exception('诊所在线复诊只能在诊所进行');
|
||||
}
|
||||
}
|
||||
|
||||
$originStoreId = (int) ($this->origin_store_id ?: \Yii::$app->store);
|
||||
$shouldPersistOrigin = in_array((int) $this->register_type, [2, 3], true)
|
||||
|| ((int) $this->register_type === 1 && (int) $this->origin_store_id > 0);
|
||||
if (!$shouldPersistOrigin) {
|
||||
$originStoreId = 0;
|
||||
}
|
||||
|
||||
$UserRegister = new Register();
|
||||
$UserRegister->user_id = \Yii::$app->user->id;
|
||||
$UserRegister->store_id = $actualStoreId;
|
||||
if ($UserRegister->hasAttribute('origin_store_id')) {
|
||||
$UserRegister->origin_store_id = $originStoreId;
|
||||
}
|
||||
$UserRegister->order_no = FuncHelper::generate_order_no('SN');
|
||||
$UserRegister->user_patient_id = $this->user_patient_id;
|
||||
$UserRegister->service_user_id = $this->service_user_id;
|
||||
|
||||
Reference in New Issue
Block a user