select('id,store_id,prescription_no,online_prescription_no,is_online,prescription_type,type,is_dispense,valid_hours,content,doctor_order,status,pharmacist_id,su_id,process_rule_id,process_rule,process_rule_note,doctor_second_sign')->where([ 'prescription_no' => $prescriptionNo ])->with('pharmacistInfo')->asArray()->one(); } else { $prescription = Prescription::find()->select('id,store_id,prescription_no,online_prescription_no,is_online,prescription_type,type,is_dispense,valid_hours,content,doctor_order,status,pharmacist_id,su_id,process_rule_id,process_rule,process_rule_note,doctor_second_sign')->where([ 'id' => $presciptionId ])->with('pharmacistInfo')->asArray()->one(); } if(!$prescription){ throw new Exception('处方不存在'); } $store = Store::find()->select('name, offical_seal')->where(['id' => $prescription['store_id']])->one(); if(!$store) throw new Exception('门店不存在'); $productOrder = ProductOrder::find()->where(['p_id' => $prescription['id']])->one(); $content = Json::decode($prescription['content']); foreach($content['repice'] as $k=>$v){ $content['repice'][$k]['content'] = Json::decode($v['content']); } $prescription['content'] = $content; $prescription['doctor_order'] = explode('|',$prescription['doctor_order']); $prescription['is_pay'] = $productOrder->is_pay; $prescription['cancel_status'] = $productOrder->cancel_status; $prescription['refund_status'] = $productOrder->refund_status; $prescription['store'] = $store; $DoctorIdentity= DoctorIdentity::find()->where(['su_id'=>$prescription['su_id']])->asArray()->one(); $PharmacistIdentity= PharmacistIdentity::find()->where(['su_id'=>$prescription['pharmacist_id']])->asArray()->one(); $prescription['doctor_sign_image']=$DoctorIdentity['sign_image']; $prescription['doctor_sign_type']=$DoctorIdentity['sign_type']; // TODO 有些错误 $prescription['Pharmacist_sign_image']=$PharmacistIdentity['sign_image']?? ''; $prescription['Pharmacist_sign_type']=$PharmacistIdentity['sign_type']?? ''; return $prescription; } catch (Exception $e) { throw new Exception($e->getMessage(). json_encode($e->getLine())); } } }