| xqd
@@ -14,7 +14,9 @@ use App\Models\Patient;
|
|
|
use App\Models\CallLog;
|
|
|
use App\Models\OrderPatient;
|
|
|
use App\Models\DocterOrganization;
|
|
|
+use App\Models\SchedulePeriod;
|
|
|
use App\Models\Suggest;
|
|
|
+use App\Models\SystemConfig;
|
|
|
use App\Models\User;
|
|
|
use App\Models\UserMessages;
|
|
|
use App\Models\Organization;
|
| xqd
@@ -31,6 +33,7 @@ use App\Models\CallPhone;
|
|
|
class PatientController extends AuthController
|
|
|
{
|
|
|
protected $relationSearch = true;
|
|
|
+
|
|
|
/**
|
|
|
* @return mixed
|
|
|
* 患者咨询列表
|
| xqd
@@ -151,7 +154,8 @@ class PatientController extends AuthController
|
|
|
* 完成订单
|
|
|
* @author Yuanhang Liu & Xiaoyun Liu
|
|
|
*/
|
|
|
- public function orderPatientok(){
|
|
|
+ public function orderPatientok()
|
|
|
+ {
|
|
|
$req = request()->post();
|
|
|
$this->validate(request(), [
|
|
|
'order_id|订单id' => 'required|integer',
|
| xqd
@@ -190,10 +194,10 @@ class PatientController extends AuthController
|
|
|
$lable = '服务包';
|
|
|
break;
|
|
|
default:
|
|
|
- $lable ='参数错误!';
|
|
|
+ $lable = '参数错误!';
|
|
|
}
|
|
|
$relation_id = '';
|
|
|
- if ($find['product_type']==1 || $find['product_type']==2){
|
|
|
+ if ($find['product_type'] == 1 || $find['product_type'] == 2) {
|
|
|
// 需要有意见单的
|
|
|
$suggests = Suggest::create([
|
|
|
'order_id'=> $find['id'],
|
| xqd
@@ -227,8 +231,8 @@ class PatientController extends AuthController
|
|
|
|
|
|
DB::beginTransaction();
|
|
|
try {
|
|
|
- Order::where('id','=',$req['order_id'])->update(['order_status'=>4,'updated_at'=>date('Y-m-d H:i:s',time()),'end_time'=>time()]);
|
|
|
- Docter::where('id','=',$user['id'])->increment('service_persons');
|
|
|
+ Order::where('id', '=', $req['order_id'])->update(['order_status' => 4, 'updated_at' => date('Y-m-d H:i:s', time()), 'end_time' => time()]);
|
|
|
+ Docter::where('id', '=', $user['id'])->increment('service_persons');
|
|
|
// 添加到用户记录中!
|
|
|
UserMessages::create([
|
|
|
'user_id'=>$find['user_id'],
|
| xqd
@@ -266,7 +270,8 @@ class PatientController extends AuthController
|
|
|
* @return mixed
|
|
|
* @throws \Exception
|
|
|
*/
|
|
|
- public function mzPatientok(){
|
|
|
+ public function mzPatientok()
|
|
|
+ {
|
|
|
$req = request()->post();
|
|
|
$this->validate(request(), [
|
|
|
'order_id|订单id' => 'required|integer',
|
| xqd
@@ -464,6 +469,7 @@ class PatientController extends AuthController
|
|
|
$res_patient['user_id'] = $data['user_id'];
|
|
|
$res_patient['user_name'] = $data['user']['nickname'];
|
|
|
$res_patient['user_avatar'] = $data['user']['avatar'];
|
|
|
+ $res_patient['sex'] = $data['order_patient']['sex'];
|
|
|
$res_patient['product_type'] = $data['product_type'];
|
|
|
$res_patient['name']=$data['order_patient']['name'];
|
|
|
$res_patient['numbirthday']=numBirthday($data['order_patient']['birthday']);
|
| xqd
@@ -632,44 +638,184 @@ class PatientController extends AuthController
|
|
|
$finds = Axb::where($wheres)->orderBy('id','desc')->first();
|
|
|
if ($finds){
|
|
|
$querylok = $commons->QuerySubsId($finds['xphone']);
|
|
|
- if ($querylok['Code']=='OK'){
|
|
|
- $queryCallStatus = $commons->QueryCallStatus($phone,$querylok['SubsId']);
|
|
|
- if ($queryCallStatus['Code']=='OK'){
|
|
|
- if ($queryCallStatus['SecretCallStatusDTO']!=4){
|
|
|
+ if ($querylok['Code'] == 'OK') {
|
|
|
+ $queryCallStatus = $commons->QueryCallStatus($phone, $querylok['SubsId']);
|
|
|
+ if ($queryCallStatus['Code'] == 'OK') {
|
|
|
+ if ($queryCallStatus['SecretCallStatusDTO'] != 4) {
|
|
|
return out($finds['xphone']);
|
|
|
- }else{
|
|
|
- if ($phone){
|
|
|
- $callModel = $commons->BindAxb($docter_phone,$phone);
|
|
|
- if ($callModel['Code']=="OK"){
|
|
|
+ } else {
|
|
|
+ if ($phone) {
|
|
|
+ $callModel = $commons->BindAxb($docter_phone, $phone);
|
|
|
+ if ($callModel['Code'] == "OK") {
|
|
|
return out($callModel['SecretBindDTO']['SecretNo']);
|
|
|
}
|
|
|
- }else{
|
|
|
- return out('',500,'患者电话不存在');
|
|
|
+ } else {
|
|
|
+ return out('', 500, '患者电话不存在');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- }else{
|
|
|
- if ($phone){
|
|
|
- $callModel = $commons->BindAxb($docter_phone,$phone);
|
|
|
- if ($callModel['Code']=="OK"){
|
|
|
+ } else {
|
|
|
+ if ($phone) {
|
|
|
+ $callModel = $commons->BindAxb($docter_phone, $phone);
|
|
|
+ if ($callModel['Code'] == "OK") {
|
|
|
Axb::create([
|
|
|
- 'docter_id'=>$docter_id,
|
|
|
- 'user_id'=>$req['user_id'],
|
|
|
- 'xphone'=>$callModel['SecretBindDTO']['SecretNo'],
|
|
|
- 'createtime'=>time(),
|
|
|
+ 'docter_id' => $docter_id,
|
|
|
+ 'user_id' => $req['user_id'],
|
|
|
+ 'xphone' => $callModel['SecretBindDTO']['SecretNo'],
|
|
|
+ 'createtime' => time(),
|
|
|
]);
|
|
|
return out($callModel['SecretBindDTO']['SecretNo']);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return out($callModel);
|
|
|
}
|
|
|
- }else{
|
|
|
- return out('',500,'患者电话不存在');
|
|
|
+ } else {
|
|
|
+ return out('', 500, '患者电话不存在');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 取消订单接口
|
|
|
+ * @throws \Illuminate\Validation\ValidationException
|
|
|
+ */
|
|
|
+ public function cancelOrder()
|
|
|
+ {
|
|
|
+ $req = request()->post();
|
|
|
+ $this->validate(request(), [
|
|
|
+ 'order_id' => 'required|integer',
|
|
|
+ ]);
|
|
|
+ $order = Order::with(['orderPatient'])->where('id', $req['order_id'])->first();
|
|
|
+ if ($order['order_status'] == 2 && $order['payment_status'] == 2) {
|
|
|
+ DB::beginTransaction();
|
|
|
+ try {
|
|
|
+ if ($order['product_type'] == 3) {
|
|
|
+ Order::where('id',$req['order_id'])->update(['order_status'=>5,'payment_status'=>5,'order_notes'=>'医生拒绝接单']);
|
|
|
+ }else{
|
|
|
+ //退钱到余额
|
|
|
+ if (!empty($order['payment_amount'])) {
|
|
|
+ User::changeBalance($order['user_id'], $order['payment_amount'], 4, $order['id'], '医生拒绝接单');
|
|
|
+ }
|
|
|
+ Order::where('id', $req['order_id'])->update(['order_status' => 5, 'order_notes' => '医生拒绝接单', 'payment_status' => 4]);
|
|
|
+ }
|
|
|
+ DB::commit();
|
|
|
+ return out('', 200, '订单取消成功');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ DB::rollBack();
|
|
|
+ return out('', 500, $e->getMessage());
|
|
|
+
|
|
|
+ } catch (\PDOException $e) {
|
|
|
+ DB::rollBack();
|
|
|
+ return out('', 500, $e->getMessage());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return out('', 500, '订单不可取消');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单超时自动完成(定时)
|
|
|
+ */
|
|
|
+ public function overTimeOrers(){
|
|
|
+ $user = $this->user;
|
|
|
+ $docter_id = $user['id'];
|
|
|
+ $config_chat = SystemConfig::get('docter_config','chat_complete_time');
|
|
|
+ $config_phone = SystemConfig::get('docter_config','phone_complete_time');
|
|
|
+
|
|
|
+ // 换算为秒
|
|
|
+ $config_chat = $config_chat*60;
|
|
|
+ $config_phone = $config_phone*60;
|
|
|
+
|
|
|
+ $inOrder = Order::with('orderPatient')->where(['docter_id'=>$docter_id,'order_status'=>3,'payment_status'=>2])->get();
|
|
|
+ $catNewIds = [];
|
|
|
+ $menNewIds = [];
|
|
|
+ foreach ($inOrder as $k=>$v){
|
|
|
+ if ($v['product_type']==1){
|
|
|
+ if ((time()-$v['receiving_time'])>=$config_chat){
|
|
|
+ $catNewIds[$k] = $v['id'];
|
|
|
+ }
|
|
|
+ }else if($v['product_type']==2){
|
|
|
+ if ((time()-$v['receiving_time'])>=$config_phone){
|
|
|
+ $catNewIds[$k] = $v['id'];
|
|
|
+ }
|
|
|
+ }else if($v['product_type']==3){
|
|
|
+ if ((time()-$v['receiving_time'])>=(1*60*60*24)){
|
|
|
+ $menNewIds[$k] = $v['id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if ($catNewIds || $menNewIds){
|
|
|
+ // 操作图文和电话订单为已完成
|
|
|
+ Order::whereIn('id',$catNewIds)->update(['order_status'=>4]);
|
|
|
+ // 操作门诊订单为已超时
|
|
|
+ Order::whereIn('id',$menNewIds)->update(['order_status'=>6]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取病例信息接口!
|
|
|
+ * @author Liu
|
|
|
+ * @return \Illuminate\Http\JsonResponse
|
|
|
+ * @throws \Illuminate\Validation\ValidationException
|
|
|
+ */
|
|
|
+ public function CaseAcquisition()
|
|
|
+ {
|
|
|
+ $req = request()->post();
|
|
|
+ $this->validate(request(), [
|
|
|
+ 'user_id' => 'required|integer',
|
|
|
+ 'order_id',
|
|
|
+ 'is_showAll'=>'required|integer'
|
|
|
+ ]);
|
|
|
+ $user = $this->user;
|
|
|
+ $docter_id = $user['id'];
|
|
|
+
|
|
|
+ // 订单内点击
|
|
|
+ if (isset($req['order_id'])&&!empty($req['order_id'])){
|
|
|
+ $data = Order::with(['orderPatient','user'])->where('id',$req['order_id'])->first();
|
|
|
+ }else{
|
|
|
+ $data = Order::with(['orderPatient','user'])->where(['user_id'=>$req['user_id'],'docter_id'=>$docter_id,'product_type'=>2,'order_status'=>3])->orderBy('id','desc')->first();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 返回数组
|
|
|
+ $res_patient = [];
|
|
|
+ if ($req['is_showAll']==1){
|
|
|
+ $list = Order::with(['orderPatient','user'])->where(['user_id'=>$req['user_id'],'docter_id'=>$docter_id,'product_type'=>2])->orderBy('id','asc')->get();
|
|
|
+ if ($list){
|
|
|
+ $list = $list->toArray();
|
|
|
+ foreach ($list as $k=>$v){
|
|
|
+ $res_patient['list'][$k]['order_sn'] = $v['order_sn'];
|
|
|
+ $res_patient['list'][$k]['user_id'] = $v['user_id'];
|
|
|
+ $res_patient['list'][$k]['user_name'] = $v['user']['nickname'];
|
|
|
+ $res_patient['list'][$k]['user_avatar'] = $v['user']['avatar'];
|
|
|
+ $res_patient['list'][$k]['sex'] = $v['order_patient']['sex'];
|
|
|
+ $res_patient['list'][$k]['name'] = $v['order_patient']['name'];
|
|
|
+ $res_patient['list'][$k]['numbirthday'] = numBirthday($v['order_patient']['birthday']);
|
|
|
+ $res_patient['list'][$k]['symptoms'] = $v['order_patient']['symptoms'];//病情描述
|
|
|
+ $res_patient['list'][$k]['medical_imgs'] = json_decode($v['order_patient']['medical_imgs'], true);//病情照片
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($data) {
|
|
|
+ $data = $data->toArray();
|
|
|
+ $res_patient['data']['order_sn'] = $data['order_sn'];
|
|
|
+ $res_patient['data']['user_id'] = $data['user_id'];
|
|
|
+ $res_patient['data']['user_name'] = $data['user']['nickname'];
|
|
|
+ $res_patient['data']['user_avatar'] = $data['user']['avatar'];
|
|
|
+ $res_patient['data']['sex'] = $data['order_patient']['sex'];
|
|
|
+ $res_patient['data']['name'] = $data['order_patient']['name'];
|
|
|
+ $res_patient['data']['numbirthday'] = numBirthday($data['order_patient']['birthday']);
|
|
|
+ $res_patient['data']['symptoms'] = $data['order_patient']['symptoms'];//病情描述
|
|
|
+ $res_patient['data']['medical_imgs'] = json_decode($data['order_patient']['medical_imgs'], true);//病情照片
|
|
|
+ }
|
|
|
+ return out($res_patient);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|