| xqd
@@ -16,15 +16,15 @@ 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;
|
|
|
use App\Http\Controllers\Api\V2\CommonController as Commons;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use App\Models\Axb;
|
|
|
+use App\Models\SystemConfig;
|
|
|
use App\Models\CallPhone;
|
|
|
-
|
|
|
+use EasyWeChat\Factory;
|
|
|
/**
|
|
|
* 咨询订单用户类
|
|
|
* Class PatientController
|
| xqd
@@ -34,6 +34,7 @@ class PatientController extends AuthController
|
|
|
{
|
|
|
protected $relationSearch = true;
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* @return mixed
|
|
|
* 患者咨询列表
|
| xqd
@@ -46,58 +47,58 @@ class PatientController extends AuthController
|
|
|
'curPage' => 'required|integer',
|
|
|
'pageSize' => 'required|integer',
|
|
|
]);
|
|
|
- $pageSize = ($req['curPage']-1)*$req['pageSize'];
|
|
|
+ $pageSize = ($req['curPage'] - 1) * $req['pageSize'];
|
|
|
$user = $this->user;
|
|
|
$doctor_id = $user['id'];
|
|
|
$where = [];
|
|
|
- $order=['created_at','desc'];
|
|
|
+ $order = ['created_at', 'desc'];
|
|
|
|
|
|
$where['docter_id'] = $doctor_id;
|
|
|
- if (isset($req['appointment']) && $req['appointment']==1){
|
|
|
+ if (isset($req['appointment']) && $req['appointment'] == 1) {
|
|
|
// 门诊预约
|
|
|
$where['product_type'] = 3;
|
|
|
- if (isset($req['timeSort']) && $req['timeSort']=='0') {
|
|
|
- $order = ['order_patients.appoint_start_time','asc']; //预约时间正序
|
|
|
+ if (isset($req['timeSort']) && $req['timeSort'] == '0') {
|
|
|
+ $order = ['order_patients.appoint_start_time', 'asc']; //预约时间正序
|
|
|
}
|
|
|
- if (isset($req['timeSort']) && $req['timeSort']=='1') {
|
|
|
- $order= ['order_patients.appoint_start_time','desc']; //预约时间倒叙
|
|
|
+ if (isset($req['timeSort']) && $req['timeSort'] == '1') {
|
|
|
+ $order = ['order_patients.appoint_start_time', 'desc']; //预约时间倒叙
|
|
|
}
|
|
|
- if (isset($req['timeSort']) && $req['timeSort']=='2') {
|
|
|
- $order = ['created_at','asc']; //下单时间正序
|
|
|
+ if (isset($req['timeSort']) && $req['timeSort'] == '2') {
|
|
|
+ $order = ['created_at', 'asc']; //下单时间正序
|
|
|
}
|
|
|
- if (isset($req['timeSort']) && $req['timeSort']=='3') {
|
|
|
- $order = ['created_at','desc']; //下单时间倒叙
|
|
|
+ if (isset($req['timeSort']) && $req['timeSort'] == '3') {
|
|
|
+ $order = ['created_at', 'desc']; //下单时间倒叙
|
|
|
}
|
|
|
|
|
|
- if (isset($req['comStatus']) && $req['comStatus']=='0') {
|
|
|
- $comstatus = [1,2,3];
|
|
|
- $where[] = [function($query) use ($comstatus){
|
|
|
+ if (isset($req['comStatus']) && $req['comStatus'] == '0') {
|
|
|
+ $comstatus = [1, 2, 3];
|
|
|
+ $where[] = [function ($query) use ($comstatus) {
|
|
|
$query->whereIn('order_status', $comstatus);//处理中
|
|
|
}];
|
|
|
}
|
|
|
- if (isset($req['comStatus']) && $req['comStatus']=='1') {
|
|
|
+ if (isset($req['comStatus']) && $req['comStatus'] == '1') {
|
|
|
$where['order_status'] = 4; //已完成
|
|
|
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
// 图文和电话的
|
|
|
- $ids = [1,2];
|
|
|
- $where[] = [function($query) use ($ids){
|
|
|
+ $ids = [1, 2];
|
|
|
+ $where[] = [function ($query) use ($ids) {
|
|
|
$query->whereIn('product_type', $ids);
|
|
|
}];
|
|
|
- if(isset($req['typeAll']) && $req['typeAll']==1){
|
|
|
- $where['product_type']=2;//图文咨询
|
|
|
+ if (isset($req['typeAll']) && $req['typeAll'] == 1) {
|
|
|
+ $where['product_type'] = 2;//图文咨询
|
|
|
}
|
|
|
- if(isset($req['typeAll']) && $req['typeAll']==2){
|
|
|
- $where['product_type']=1;//电话咨询
|
|
|
+ if (isset($req['typeAll']) && $req['typeAll'] == 2) {
|
|
|
+ $where['product_type'] = 1;//电话咨询
|
|
|
}
|
|
|
- if(isset($req['processing']) && $req['processing']==0){
|
|
|
- $status = [1,2,3];
|
|
|
- $where[] = [function($query) use ($status){
|
|
|
+ if (isset($req['processing']) && $req['processing'] == 0) {
|
|
|
+ $status = [1, 2, 3];
|
|
|
+ $where[] = [function ($query) use ($status) {
|
|
|
$query->whereIn('order_status', $status);//处理中
|
|
|
}];
|
|
|
}
|
|
|
- if(isset($req['processing']) && $req['processing']==1){
|
|
|
+ if (isset($req['processing']) && $req['processing'] == 1) {
|
|
|
$where['order_status'] = 4; //历史记录,已完成订单
|
|
|
}
|
|
|
}
|
| xqd
@@ -107,31 +108,31 @@ class PatientController extends AuthController
|
|
|
// $query->orderBy($orders[0],$orders[1]);
|
|
|
// }])->where($where)->orderBy($order[0],$order[1])->skip($pageSize)->take($req['pageSize'])->groupBy('id')->get()->toArray();
|
|
|
$data = DB::table('orders')
|
|
|
- ->leftJoin('order_patients','order_patients.order_id','=','orders.id')
|
|
|
- ->select(['orders.*','order_patients.birthday as obirthday','order_patients.appoint_start_time','order_patients.name as oanme'])
|
|
|
- ->where($where)->orderBy($order[0],$order[1])
|
|
|
- ->skip($pageSize)->take($req['pageSize'])
|
|
|
- ->groupBy('id')
|
|
|
- ->get()->toArray();
|
|
|
+ ->leftJoin('order_patients', 'order_patients.order_id', '=', 'orders.id')
|
|
|
+ ->select(['orders.*', 'order_patients.birthday as obirthday', 'order_patients.appoint_start_time', 'order_patients.name as oanme'])
|
|
|
+ ->where($where)->orderBy($order[0], $order[1])
|
|
|
+ ->skip($pageSize)->take($req['pageSize'])
|
|
|
+ ->groupBy('id')
|
|
|
+ ->get()->toArray();
|
|
|
|
|
|
// $data = Order::with('orderPatient')->where($where)->skip($pageSize)->take($req['pageSize'])->groupBy('id')->toSql();
|
|
|
// $data = OrderPatient::with("order")->where('id', $user['id'])->orderBy('id', 'desc')->limit($pageSize,$req['pageSize'])->get()->toarray();
|
|
|
$list = [];
|
|
|
try {
|
|
|
|
|
|
- foreach ($data as $k=>$v){
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
$v = get_object_vars($v);
|
|
|
- if (!$v['obirthday']){
|
|
|
+ if (!$v['obirthday']) {
|
|
|
unset($list[$k]);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$list[$k]['id'] = $v['id'];
|
|
|
$list[$k]['user_id'] = $v['user_id'];
|
|
|
$list[$k]['order_sn'] = $v['order_sn'];
|
|
|
$list[$k]['zl'] = $v['product_type'];
|
|
|
$list[$k]['zt'] = $v['order_status'];
|
|
|
- unset($list[$k]['order_status'],$list[$k]['product_type']);
|
|
|
+ unset($list[$k]['order_status'], $list[$k]['product_type']);
|
|
|
$list[$k]['created_at'] = $v['created_at'];
|
|
|
- $list[$k]['appoint_time'] = empty($v['appoint_start_time'])?'---':date('Y-m-d H:i:s',$v['appoint_start_time']);
|
|
|
+ $list[$k]['appoint_time'] = empty($v['appoint_start_time']) ? '---' : date('Y-m-d H:i:s', $v['appoint_start_time']);
|
|
|
$list[$k]['name'] = $v['oanme'];
|
|
|
$list[$k]['birthday'] = numBirthday($v['obirthday']);
|
|
|
}
|
| xqd
@@ -139,16 +140,18 @@ class PatientController extends AuthController
|
|
|
}
|
|
|
|
|
|
return out($list);
|
|
|
- }catch (\Exception $e){
|
|
|
- return out($e->getFile().'中第 '.$e->getLine().'行发生了 '.$e->getMessage().'错误');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ return out($e->getFile() . '中第 ' . $e->getLine() . '行发生了 ' . $e->getMessage() . '错误');
|
|
|
}
|
|
|
return out($list);
|
|
|
}
|
|
|
|
|
|
|
|
|
- public function mzPutOrder(){
|
|
|
+ public function mzPutOrder()
|
|
|
+ {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* @return mixed
|
|
|
* 完成订单
|
| xqd
@@ -165,16 +168,16 @@ class PatientController extends AuthController
|
|
|
|
|
|
]);
|
|
|
$user = $this->user;
|
|
|
- $find = Order::where('id','=',$req['order_id'])->first()->toArray();
|
|
|
- if (!$find){
|
|
|
- return out('',500,'订单错误!');
|
|
|
+ $find = Order::where('id', '=', $req['order_id'])->first()->toArray();
|
|
|
+ if (!$find) {
|
|
|
+ return out('', 500, '订单错误!');
|
|
|
}
|
|
|
- if ($find['order_status']>3){
|
|
|
- return out('',500,'此订单不可操作!');
|
|
|
+ if ($find['order_status'] > 3) {
|
|
|
+ return out('', 500, '此订单不可操作!');
|
|
|
|
|
|
}
|
|
|
$lable = '';
|
|
|
- switch ($find['product_type']){
|
|
|
+ switch ($find['product_type']) {
|
|
|
case 1:
|
|
|
$lable = '电话咨询';
|
|
|
break;
|
| xqd
@@ -200,28 +203,28 @@ class PatientController extends AuthController
|
|
|
if ($find['product_type'] == 1 || $find['product_type'] == 2) {
|
|
|
// 需要有意见单的
|
|
|
$suggests = Suggest::create([
|
|
|
- 'order_id'=> $find['id'],
|
|
|
- 'user_id'=> $find['user_id'],
|
|
|
- 'symptoms'=> $req['symptoms'],
|
|
|
- 'pathogen'=> $req['pathogen'],
|
|
|
- 'suggest'=> $req['suggest'],
|
|
|
- 'patient_id'=> $req['patient_id']
|
|
|
+ 'order_id' => $find['id'],
|
|
|
+ 'user_id' => $find['user_id'],
|
|
|
+ 'symptoms' => $req['symptoms'],
|
|
|
+ 'pathogen' => $req['pathogen'],
|
|
|
+ 'suggest' => $req['suggest'],
|
|
|
+ 'patient_id' => $req['patient_id']
|
|
|
]);
|
|
|
$suggests = $suggests->toArray();
|
|
|
- $relation_id= $suggests['id'];
|
|
|
- }else{
|
|
|
- $relation_id= 0;
|
|
|
+ $relation_id = $suggests['id'];
|
|
|
+ } else {
|
|
|
+ $relation_id = 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
$status = $find['product_type'];
|
|
|
- $lab='';
|
|
|
+ $lab = '';
|
|
|
$mesid = $relation_id;
|
|
|
- if ($status==1){
|
|
|
+ if ($status == 1) {
|
|
|
$lab = '电话咨询';
|
|
|
- }else if ($status==2){
|
|
|
+ } else if ($status == 2) {
|
|
|
$lab = '图文咨询';
|
|
|
- }else if($status==3){
|
|
|
+ } else if ($status == 3) {
|
|
|
$mesid = $find['id'];
|
|
|
$lab = '门诊预约';
|
|
|
}
|
| xqd
@@ -235,29 +238,29 @@ class PatientController extends AuthController
|
|
|
Docter::where('id', '=', $user['id'])->increment('service_persons');
|
|
|
// 添加到用户记录中!
|
|
|
UserMessages::create([
|
|
|
- 'user_id'=>$find['user_id'],
|
|
|
- 'docter_id'=>$user['id'],
|
|
|
- 'status'=>1,
|
|
|
- 'type'=>2,
|
|
|
- 'relation_id'=>$mesid,
|
|
|
- 'content'=>"您的 ".$lab." 订单,订单号".$order_sn.",医生".$doctername."已经确认完成(点击查看意见单)",
|
|
|
+ 'user_id' => $find['user_id'],
|
|
|
+ 'docter_id' => $user['id'],
|
|
|
+ 'status' => 1,
|
|
|
+ 'type' => 2,
|
|
|
+ 'relation_id' => $mesid,
|
|
|
+ 'content' => "您的 " . $lab . " 订单,订单号" . $order_sn . ",医生" . $doctername . "已经确认完成(点击查看意见单)",
|
|
|
]);
|
|
|
DB::commit();
|
|
|
- }catch (\Exception $e){
|
|
|
+ } catch (\Exception $e) {
|
|
|
DB::rollBack();
|
|
|
- return out('',500,$e->getMessage());
|
|
|
- }catch (\PDOException $e){
|
|
|
+ return out('', 500, $e->getMessage());
|
|
|
+ } catch (\PDOException $e) {
|
|
|
DB::rollBack();
|
|
|
- return out('',500,$e->getMessage());
|
|
|
+ return out('', 500, $e->getMessage());
|
|
|
}
|
|
|
|
|
|
$axbwhere['docter_id'] = $user['id'];
|
|
|
$axbwhere['user_id'] = $req['user_id'];
|
|
|
- $finds = Axb::where($axbwhere)->orderBy('id','desc')->first();
|
|
|
+ $finds = Axb::where($axbwhere)->orderBy('id', 'desc')->first();
|
|
|
|
|
|
- if ($status==1 && $finds){
|
|
|
- $unlok = (new Commons())->unLokPhone($finds['xphone'],$finds['subs_id']);
|
|
|
- Axb::where(['subs_id'=>$finds['subs_id']])->delete();
|
|
|
+ if ($status == 1 && $finds) {
|
|
|
+ $unlok = (new Commons())->unLokPhone($finds['xphone'], $finds['subs_id']);
|
|
|
+ Axb::where(['subs_id' => $finds['subs_id']])->delete();
|
|
|
}
|
|
|
|
|
|
return out();
|
| xqd
@@ -277,16 +280,16 @@ class PatientController extends AuthController
|
|
|
'order_id|订单id' => 'required|integer',
|
|
|
]);
|
|
|
$user = $this->user;
|
|
|
- $find = Order::where('id','=',$req['order_id'])->first()->toArray();
|
|
|
- if (!$find){
|
|
|
- return out('',500,'订单错误!');
|
|
|
+ $find = Order::where('id', '=', $req['order_id'])->first()->toArray();
|
|
|
+ if (!$find) {
|
|
|
+ return out('', 500, '订单错误!');
|
|
|
}
|
|
|
- if ($find['order_status']>3){
|
|
|
- return out('',500,'此订单不可操作!');
|
|
|
+ if ($find['order_status'] > 3) {
|
|
|
+ return out('', 500, '此订单不可操作!');
|
|
|
|
|
|
}
|
|
|
$lable = '';
|
|
|
- switch ($find['product_type']){
|
|
|
+ switch ($find['product_type']) {
|
|
|
case 1:
|
|
|
$lable = '电话咨询';
|
|
|
break;
|
| xqd
@@ -306,17 +309,17 @@ class PatientController extends AuthController
|
|
|
$lable = '服务包';
|
|
|
break;
|
|
|
default:
|
|
|
- $lable ='参数错误!';
|
|
|
+ $lable = '参数错误!';
|
|
|
}
|
|
|
- $relation_id= 0;
|
|
|
+ $relation_id = 0;
|
|
|
$status = $find['product_type'];
|
|
|
- $lab='';
|
|
|
+ $lab = '';
|
|
|
$mesid = $relation_id;
|
|
|
- if ($status==1){
|
|
|
+ if ($status == 1) {
|
|
|
$lab = '电话咨询';
|
|
|
- }else if ($status==2){
|
|
|
+ } else if ($status == 2) {
|
|
|
$lab = '图文咨询';
|
|
|
- }else if($status==3){
|
|
|
+ } else if ($status == 3) {
|
|
|
$mesid = $find['id'];
|
|
|
$lab = '门诊预约';
|
|
|
}
|
| xqd
@@ -324,24 +327,24 @@ class PatientController extends AuthController
|
|
|
$doctername = $user['name'];
|
|
|
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'],
|
|
|
- 'docter_id'=>$user['id'],
|
|
|
- 'status'=>1,
|
|
|
- 'type'=>2,
|
|
|
- 'relation_id'=>$mesid,
|
|
|
- 'content'=>"您的 ".$lab." 订单,订单号".$order_sn.",医生".$doctername."已经确认完成(点击查看订单)",
|
|
|
+ 'user_id' => $find['user_id'],
|
|
|
+ 'docter_id' => $user['id'],
|
|
|
+ 'status' => 1,
|
|
|
+ 'type' => 2,
|
|
|
+ 'relation_id' => $mesid,
|
|
|
+ 'content' => "您的 " . $lab . " 订单,订单号" . $order_sn . ",医生" . $doctername . "已经确认完成(点击查看订单)",
|
|
|
]);
|
|
|
DB::commit();
|
|
|
- }catch (\Exception $e){
|
|
|
+ } catch (\Exception $e) {
|
|
|
DB::rollBack();
|
|
|
- return out('',500,$e->getMessage());
|
|
|
- }catch (\PDOException $e){
|
|
|
+ return out('', 500, $e->getMessage());
|
|
|
+ } catch (\PDOException $e) {
|
|
|
DB::rollBack();
|
|
|
- return out('',500,$e->getMessage());
|
|
|
+ return out('', 500, $e->getMessage());
|
|
|
}
|
|
|
|
|
|
return out();
|
| xqd
@@ -352,59 +355,59 @@ class PatientController extends AuthController
|
|
|
* 接单
|
|
|
* @author Yuanhang Liu & Xiaoyun Liu
|
|
|
*/
|
|
|
- public function putOrderPatient(){
|
|
|
+ public function putOrderPatient()
|
|
|
+ {
|
|
|
$req = request()->post();
|
|
|
$this->validate(request(), [
|
|
|
'order_id|订单id' => 'required|integer',
|
|
|
]);
|
|
|
$user = $this->user;
|
|
|
|
|
|
- $find = Order::where('id','=',$req['order_id'])->first()->toArray();
|
|
|
+ $find = Order::where('id', '=', $req['order_id'])->first()->toArray();
|
|
|
$status = $find['product_type'];
|
|
|
- $lab='';
|
|
|
- if ($status==1){
|
|
|
+ $lab = '';
|
|
|
+ if ($status == 1) {
|
|
|
$lab = '电话咨询';
|
|
|
- }else if ($status==2){
|
|
|
+ } else if ($status == 2) {
|
|
|
$lab = '图文咨询';
|
|
|
- }else if($status==3){
|
|
|
+ } else if ($status == 3) {
|
|
|
$lab = '门诊预约';
|
|
|
}
|
|
|
$order_sn = $find['order_sn'];
|
|
|
$order_id = $find['id'];
|
|
|
$doctername = $user['name'];
|
|
|
-// 1.电话咨询 2.图文咨询 3.门诊预约 4.疫苗接种预约 5.儿保预约 6.服务包 7.充值
|
|
|
-
|
|
|
- if (!$find){
|
|
|
- return out('',500,'订单错误!');
|
|
|
+ if (!$find) {
|
|
|
+ return out('', 500, '订单错误!');
|
|
|
}
|
|
|
- if ($find['order_status']!=2){
|
|
|
- return out('',500,'此订单已被接单或未付款!');
|
|
|
+ if ($find['order_status'] != 2) {
|
|
|
+ return out('', 500, '此订单已被接单或未付款!');
|
|
|
}
|
|
|
- if ($find['payment_status']>=4){
|
|
|
- return out('',500,'此订单可能已完成!');
|
|
|
+ if ($find['payment_status'] >= 4) {
|
|
|
+ return out('', 500, '此订单可能已完成!');
|
|
|
}
|
|
|
DB::beginTransaction();
|
|
|
try {
|
|
|
- Order::where('id','=',$req['order_id'])->update(['order_status'=>3,'updated_at'=>date('Y-m-d H:i:s',time()),'receiving_time'=>time()]);
|
|
|
+ Order::where('id', '=', $req['order_id'])->update(['order_status' => 3, 'updated_at' => date('Y-m-d H:i:s', time()), 'receiving_time' => time()]);
|
|
|
// 添加到用户记录中!
|
|
|
UserMessages::create([
|
|
|
- 'user_id'=>$find['user_id'],
|
|
|
- 'docter_id'=>$user['id'],
|
|
|
- 'status'=>1,
|
|
|
- 'type'=>1,
|
|
|
- 'relation_id'=>$order_id,
|
|
|
- 'content'=> "您的 ".$lab." 订单,订单号".$order_sn.",医生".$doctername."已经确认接单(点击查看订单详情)",
|
|
|
+ 'user_id' => $find['user_id'],
|
|
|
+ 'docter_id' => $user['id'],
|
|
|
+ 'status' => 1,
|
|
|
+ 'type' => 1,
|
|
|
+ 'relation_id' => $order_id,
|
|
|
+ 'content' => "您的 " . $lab . " 订单,订单号" . $order_sn . ",医生" . $doctername . "已经确认接单(点击查看订单详情)",
|
|
|
]);
|
|
|
DB::commit();
|
|
|
+ $this->ReceivingReminder($req['order_id']);
|
|
|
return out();
|
|
|
- }catch (\Exception $e){
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
|
DB::rollBack();
|
|
|
- return out('',500,$e->getMessage());
|
|
|
- }catch (\PDOException $e){
|
|
|
+ return out('', 500, $e->getMessage());
|
|
|
+ } catch (\PDOException $e) {
|
|
|
|
|
|
DB::rollBack();
|
|
|
- return out('',500,$e->getMessage());
|
|
|
+ return out('', 500, $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
| xqd
@@ -421,7 +424,7 @@ class PatientController extends AuthController
|
|
|
]);
|
|
|
$data = [];
|
|
|
// 订单查询
|
|
|
- $data = Order::with(['orderPatient','user','calllog'])->where('id', $req['patient_id'])->first()->toArray();
|
|
|
+ $data = Order::with(['orderPatient', 'user', 'calllog'])->where('id', $req['patient_id'])->first()->toArray();
|
|
|
|
|
|
// 通话记录查询
|
|
|
$datas = CallLog::where('order_id', $req['patient_id'])->get();
|
| xqd
@@ -431,39 +434,40 @@ class PatientController extends AuthController
|
|
|
$doctor_id = (new Commons)->getUserIdByDoctorId($user['phone']);
|
|
|
// 返回数组
|
|
|
$res_patient = [];
|
|
|
+
|
|
|
//电话咨询
|
|
|
|
|
|
- if($data['product_type']==1){
|
|
|
+ if ($data['product_type'] == 1) {
|
|
|
|
|
|
$res_patient['patient_id'] = $data['order_patient']['id'];
|
|
|
$res_patient['user_id'] = $data['user_id'];
|
|
|
$res_patient['order_sn'] = $data['order_sn'];
|
|
|
$res_patient['patient_id'] = $data['patient_id'];
|
|
|
$res_patient['product_type'] = $data['product_type'];
|
|
|
- $res_patient['name']=$data['order_patient']['name'];//患者姓名
|
|
|
- $res_patient['numbirthday']=numBirthday($data['order_patient']['birthday']);//年龄
|
|
|
- $res_patient['card_number']=$data['order_patient']['card_number'];//身份证号
|
|
|
- $res_patient['created_at']=$data['created_at'];//下单时间
|
|
|
- $res_patient['nickname']=$data['user']['nickname'];//下单用户
|
|
|
- $res_patient['receiving_time']=!empty($data['receiving_time'])?date('Y-m-d H:i:s',$data['receiving_time']):'---';//接单时间
|
|
|
- $res_patient['order_status']=$data['order_status'];//订单状态
|
|
|
- $res_patient['call_list']=[];//通话记录
|
|
|
+ $res_patient['name'] = $data['order_patient']['name'];//患者姓名
|
|
|
+ $res_patient['numbirthday'] = numBirthday($data['order_patient']['birthday']);//年龄
|
|
|
+ $res_patient['card_number'] = $data['order_patient']['card_number'];//身份证号
|
|
|
+ $res_patient['created_at'] = $data['created_at'];//下单时间
|
|
|
+ $res_patient['nickname'] = $data['user']['nickname'];//下单用户
|
|
|
+ $res_patient['receiving_time'] = !empty($data['receiving_time']) ? date('Y-m-d H:i:s', $data['receiving_time']) : '---';//接单时间
|
|
|
+ $res_patient['order_status'] = $data['order_status'];//订单状态
|
|
|
+ $res_patient['call_list'] = [];//通话记录
|
|
|
$res_patient['one_call'] = '';
|
|
|
- if ($data['calllog']){
|
|
|
+ if ($data['calllog']) {
|
|
|
$res_patient['one_call'] = $data['calllog'][0]['call_time'];
|
|
|
- $res_patient['secret_no']=$data['calllog'][count($data['calllog'])-1]['secret_no'];//X号码
|
|
|
- foreach ($data['calllog'] as $ks=>$vs){
|
|
|
- $res_patient['call_list'][$ks]['frequency']='通话'.($ks+=1);//拨打电话开始时间
|
|
|
- $res_patient['call_list'][$ks]['start']=$vs['call_time'];//拨打电话开始时间
|
|
|
- $res_patient['call_list'][$ks]['end']=$vs['ring_time'];//拨打电话结束时间
|
|
|
- $res_patient['call_list'][$ks]['duration']=gmdate('i:s',$vs['talk_time']);//拨打电话结束时间
|
|
|
+ $res_patient['secret_no'] = $data['calllog'][count($data['calllog']) - 1]['secret_no'];//X号码
|
|
|
+ foreach ($data['calllog'] as $ks => $vs) {
|
|
|
+ $res_patient['call_list'][$ks]['frequency'] = '通话' . ($ks += 1);//拨打电话开始时间
|
|
|
+ $res_patient['call_list'][$ks]['start'] = $vs['call_time'];//拨打电话开始时间
|
|
|
+ $res_patient['call_list'][$ks]['end'] = $vs['ring_time'];//拨打电话结束时间
|
|
|
+ $res_patient['call_list'][$ks]['duration'] = gmdate('i:s', $vs['talk_time']);//拨打电话结束时间
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//图文咨询
|
|
|
- if($data['product_type']==2){
|
|
|
+ if ($data['product_type'] == 2) {
|
|
|
$res_patient['order_sn'] = $data['order_sn'];
|
|
|
$res_patient['patient_id'] = $data['patient_id'];
|
|
|
$res_patient['user_id'] = $data['user_id'];
|
| xqd
@@ -471,38 +475,38 @@ class PatientController extends AuthController
|
|
|
$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']);
|
|
|
- $res_patient['card_number']=$data['order_patient']['card_number'];
|
|
|
- $res_patient['symptoms']=$data['order_patient']['symptoms'];//病情描述
|
|
|
- $res_patient['medical_imgs']=json_decode($data['order_patient']['medical_imgs'],true);//病情照片
|
|
|
- $res_patient['created_at']=$data['created_at'];//下单时间
|
|
|
- $res_patient['nickname']=$data['user']['nickname'];//下单用户
|
|
|
- $res_patient['receiving_time']=!empty($data['receiving_time'])?date('Y-m-d H:i:s',$data['receiving_time']):'---'; //接单时间
|
|
|
- $res_patient['order_status']=$data['order_status'];//接单时间
|
|
|
+ $res_patient['name'] = $data['order_patient']['name'];
|
|
|
+ $res_patient['numbirthday'] = numBirthday($data['order_patient']['birthday']);
|
|
|
+ $res_patient['card_number'] = $data['order_patient']['card_number'];
|
|
|
+ $res_patient['symptoms'] = $data['order_patient']['symptoms'];//病情描述
|
|
|
+ $res_patient['medical_imgs'] = json_decode($data['order_patient']['medical_imgs'], true);//病情照片
|
|
|
+ $res_patient['created_at'] = $data['created_at'];//下单时间
|
|
|
+ $res_patient['nickname'] = $data['user']['nickname'];//下单用户
|
|
|
+ $res_patient['receiving_time'] = !empty($data['receiving_time']) ? date('Y-m-d H:i:s', $data['receiving_time']) : '---'; //接单时间
|
|
|
+ $res_patient['order_status'] = $data['order_status'];//接单时间
|
|
|
}
|
|
|
|
|
|
//门诊预约
|
|
|
- if($data['product_type']==3){
|
|
|
+ if ($data['product_type'] == 3) {
|
|
|
$res_patient['order_sn'] = $data['order_sn'];
|
|
|
$res_patient['patient_id'] = $data['patient_id'];
|
|
|
- $res_patient['product_type'] =$data['product_type'];
|
|
|
- $res_patient['name']=$data['order_patient']['name']; // 患者
|
|
|
- $res_patient['numbirthday']=numBirthday($data['order_patient']['birthday']); //年龄
|
|
|
- $res_patient['card_number']=$data['order_patient']['card_number']; // 证件号
|
|
|
- $res_patient['appoint_time'] = date('Y年m月d日 H:i',$data['order_patient']['appoint_start_time']);// 预约时间
|
|
|
+ $res_patient['product_type'] = $data['product_type'];
|
|
|
+ $res_patient['name'] = $data['order_patient']['name']; // 患者
|
|
|
+ $res_patient['numbirthday'] = numBirthday($data['order_patient']['birthday']); //年龄
|
|
|
+ $res_patient['card_number'] = $data['order_patient']['card_number']; // 证件号
|
|
|
+ $res_patient['appoint_time'] = date('Y年m月d日 H:i', $data['order_patient']['appoint_start_time']);// 预约时间
|
|
|
$res_patient['order_status'] = $data['order_status'];// 订单状态
|
|
|
- $organization = Organization::where('id','=',$data['organization_id'])->first();
|
|
|
- if($organization){
|
|
|
+ $organization = Organization::where('id', '=', $data['organization_id'])->first();
|
|
|
+ if ($organization) {
|
|
|
$organization = $organization->toArray();
|
|
|
- $res_patient['organization']= $organization['name']; // 门诊机构
|
|
|
- }else{
|
|
|
- $res_patient['organization']= ''; // 门诊机构
|
|
|
+ $res_patient['organization'] = $organization['name']; // 门诊机构
|
|
|
+ } else {
|
|
|
+ $res_patient['organization'] = ''; // 门诊机构
|
|
|
|
|
|
}
|
|
|
- $res_patient['order_sn']=$data['order_sn'];//订单号
|
|
|
- $res_patient['created_at']=$data['created_at'];//下单时间
|
|
|
- $res_patient['nickname']=$data['user']['nickname'];//下单用户
|
|
|
+ $res_patient['order_sn'] = $data['order_sn'];//订单号
|
|
|
+ $res_patient['created_at'] = $data['created_at'];//下单时间
|
|
|
+ $res_patient['nickname'] = $data['user']['nickname'];//下单用户
|
|
|
}
|
|
|
|
|
|
return out($res_patient);
|
| xqd
@@ -515,7 +519,8 @@ class PatientController extends AuthController
|
|
|
* @author Liu-Yh
|
|
|
* Create By 2020/11/24 19:19
|
|
|
*/
|
|
|
- public function callPhones(){
|
|
|
+ public function callPhones()
|
|
|
+ {
|
|
|
$req = request()->post();
|
|
|
$user = $this->user;
|
|
|
$this->validate(request(), [
|
| xqd
@@ -524,62 +529,62 @@ class PatientController extends AuthController
|
|
|
]);
|
|
|
$docter_id = $user['id'];
|
|
|
$docter_phone = $user['phone'];
|
|
|
- if(!$docter_phone){
|
|
|
- return out('',500,'医生电话不存在!');
|
|
|
+ if (!$docter_phone) {
|
|
|
+ return out('', 500, '医生电话不存在!');
|
|
|
}
|
|
|
- $find = Order::with('orderPatient')->where('order_sn',$req['order_id'])->first()->toArray();
|
|
|
- if (empty($find['order_patient'])){
|
|
|
- return out('',500,'患者电话不存在');
|
|
|
+ $find = Order::with('orderPatient')->where('order_sn', $req['order_id'])->first()->toArray();
|
|
|
+ if (empty($find['order_patient'])) {
|
|
|
+ return out('', 500, '患者电话不存在');
|
|
|
}
|
|
|
$phone = $find['order_patient']['phone'];
|
|
|
- if($docter_phone==$phone){
|
|
|
- return out('',500,'医生和患者电话号不能一样!');
|
|
|
+ if ($docter_phone == $phone) {
|
|
|
+ return out('', 500, '医生和患者电话号不能一样!');
|
|
|
}
|
|
|
$wheres['docter_id'] = $docter_id;
|
|
|
$wheres['user_id'] = $req['user_id'];
|
|
|
$commons = new Commons();
|
|
|
- $finds = Axb::where($wheres)->orderBy('id','desc')->first();
|
|
|
- if ($finds){
|
|
|
+ $finds = Axb::where($wheres)->orderBy('id', 'desc')->first();
|
|
|
+ if ($finds) {
|
|
|
$querylok = $commons->QuerySubsId($finds['xphone']);
|
|
|
- if ($querylok['Code']=='OK'){
|
|
|
+ if ($querylok['Code'] == 'OK') {
|
|
|
// 可能是数组
|
|
|
- $new_arr = explode(',',$querylok['SubsId']);
|
|
|
- foreach ($new_arr as $v){
|
|
|
- $queryCallStatus = $commons->QuerySubscriptionDetail($finds['xphone'],$v);
|
|
|
- if ($queryCallStatus['Code']=="OK"){
|
|
|
- if ($queryCallStatus['SecretBindDetailDTO']['PhoneNoA']==$docter_phone&&$queryCallStatus['SecretBindDetailDTO']['PhoneNoB']==$phone){
|
|
|
+ $new_arr = explode(',', $querylok['SubsId']);
|
|
|
+ foreach ($new_arr as $v) {
|
|
|
+ $queryCallStatus = $commons->QuerySubscriptionDetail($finds['xphone'], $v);
|
|
|
+ if ($queryCallStatus['Code'] == "OK") {
|
|
|
+ if ($queryCallStatus['SecretBindDetailDTO']['PhoneNoA'] == $docter_phone && $queryCallStatus['SecretBindDetailDTO']['PhoneNoB'] == $phone) {
|
|
|
return out($finds['xphone']);
|
|
|
- }else{
|
|
|
- if ($phone){
|
|
|
- Axb::where('id',$finds['id'])->delete();
|
|
|
- return $this->createCall($phone,$docter_phone,$docter_id,$req['user_id']);
|
|
|
- }else{
|
|
|
- return out('',500,'患者电话不存在');
|
|
|
+ } else {
|
|
|
+ if ($phone) {
|
|
|
+ Axb::where('id', $finds['id'])->delete();
|
|
|
+ return $this->createCall($phone, $docter_phone, $docter_id, $req['user_id']);
|
|
|
+ } else {
|
|
|
+ return out('', 500, '患者电话不存在');
|
|
|
}
|
|
|
}
|
|
|
- }else{
|
|
|
- if ($phone){
|
|
|
- Axb::where('id',$finds['id'])->delete();
|
|
|
- return $this->createCall($phone,$docter_phone,$docter_id,$req['user_id']);
|
|
|
- }else{
|
|
|
- return out('',500,'患者电话不存在');
|
|
|
+ } else {
|
|
|
+ if ($phone) {
|
|
|
+ Axb::where('id', $finds['id'])->delete();
|
|
|
+ return $this->createCall($phone, $docter_phone, $docter_id, $req['user_id']);
|
|
|
+ } else {
|
|
|
+ return out('', 500, '患者电话不存在');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }else{
|
|
|
- if ($phone){
|
|
|
- Axb::where('id',$finds['id'])->delete();
|
|
|
- return $this->createCall($phone,$docter_phone,$docter_id,$req['user_id']);
|
|
|
- }else{
|
|
|
- return out('',500,'患者电话不存在');
|
|
|
+ } else {
|
|
|
+ if ($phone) {
|
|
|
+ Axb::where('id', $finds['id'])->delete();
|
|
|
+ return $this->createCall($phone, $docter_phone, $docter_id, $req['user_id']);
|
|
|
+ } else {
|
|
|
+ return out('', 500, '患者电话不存在');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- }else{
|
|
|
- if ($phone){
|
|
|
- return $this->createCall($phone,$docter_phone,$docter_id,$req['user_id']);
|
|
|
- }else{
|
|
|
- return out('',500,'患者电话不存在');
|
|
|
+ } else {
|
|
|
+ if ($phone) {
|
|
|
+ return $this->createCall($phone, $docter_phone, $docter_id, $req['user_id']);
|
|
|
+ } else {
|
|
|
+ return out('', 500, '患者电话不存在');
|
|
|
}
|
|
|
}
|
|
|
|
| xqd
@@ -593,33 +598,34 @@ class PatientController extends AuthController
|
|
|
* @param $user_id
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
*/
|
|
|
- protected function createCall($phone,$docter_phone,$docter_id,$user_id){
|
|
|
+ protected function createCall($phone, $docter_phone, $docter_id, $user_id)
|
|
|
+ {
|
|
|
$commons = new Commons();
|
|
|
- $callModel = $commons->BindAxb($docter_phone,$phone);
|
|
|
- if ($callModel['Code']=="OK"){
|
|
|
+ $callModel = $commons->BindAxb($docter_phone, $phone);
|
|
|
+ if ($callModel['Code'] == "OK") {
|
|
|
Axb::create([
|
|
|
- 'docter_id'=>$docter_id,
|
|
|
- 'user_id'=>$user_id,
|
|
|
- 'xphone'=>$callModel['SecretBindDTO']['SecretNo'],
|
|
|
- 'subs_id'=>$callModel['SecretBindDTO']['SubsId'],
|
|
|
- 'createtime'=>time(),
|
|
|
+ 'docter_id' => $docter_id,
|
|
|
+ 'user_id' => $user_id,
|
|
|
+ 'xphone' => $callModel['SecretBindDTO']['SecretNo'],
|
|
|
+ 'subs_id' => $callModel['SecretBindDTO']['SubsId'],
|
|
|
+ 'createtime' => time(),
|
|
|
]);
|
|
|
return out($callModel['SecretBindDTO']['SecretNo']);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return out($callModel);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 电话随访
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
* @author Liu-Yh
|
|
|
* Create By 2020/11/24 19:19
|
|
|
*/
|
|
|
- public function callPhoneSure(){
|
|
|
+ public function callPhoneSure()
|
|
|
+ {
|
|
|
$req = request()->post();
|
|
|
$user = $this->user;
|
|
|
$this->validate(request(), [
|
| xqd
@@ -627,16 +633,16 @@ class PatientController extends AuthController
|
|
|
]);
|
|
|
$docter_id = $user['id'];
|
|
|
$docter_phone = $user['phone'];
|
|
|
- if(!$docter_phone){
|
|
|
- return out('',500,'医生电话不存在!');
|
|
|
+ if (!$docter_phone) {
|
|
|
+ return out('', 500, '医生电话不存在!');
|
|
|
}
|
|
|
- $find = User::where('id',$req['user_id'])->first()->toArray();
|
|
|
+ $find = User::where('id', $req['user_id'])->first()->toArray();
|
|
|
$phone = $find['phone'];
|
|
|
$wheres['docter_id'] = $docter_id;
|
|
|
$wheres['user_id'] = $find['id'];
|
|
|
$commons = new Commons();
|
|
|
- $finds = Axb::where($wheres)->orderBy('id','desc')->first();
|
|
|
- if ($finds){
|
|
|
+ $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']);
|
| xqd
@@ -679,7 +685,6 @@ class PatientController extends AuthController
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 取消订单接口
|
|
|
* @throws \Illuminate\Validation\ValidationException
|
| xqd
@@ -704,6 +709,7 @@ class PatientController extends AuthController
|
|
|
Order::where('id', $req['order_id'])->update(['order_status' => 5, 'order_notes' => '医生拒绝接单', 'payment_status' => 4]);
|
|
|
}
|
|
|
DB::commit();
|
|
|
+ $this->CancelReminder($req['order_id']);
|
|
|
return out('', 200, '订单取消成功');
|
|
|
} catch (\Exception $e) {
|
|
|
DB::rollBack();
|
| xqd
@@ -722,8 +728,8 @@ class PatientController extends AuthController
|
|
|
* 订单超时自动完成(定时)
|
|
|
*/
|
|
|
public function overTimeOrers(){
|
|
|
- $user = $this->user;
|
|
|
- $docter_id = $user['id'];
|
|
|
+// $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');
|
|
|
|
| xqd
@@ -731,7 +737,7 @@ class PatientController extends AuthController
|
|
|
$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();
|
|
|
+ $inOrder = Order::with('orderPatient')->where(['order_status'=>3,'payment_status'=>2])->get();
|
|
|
$catNewIds = [];
|
|
|
$menNewIds = [];
|
|
|
foreach ($inOrder as $k=>$v){
|
| xqd
@@ -818,4 +824,235 @@ class PatientController extends AuthController
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改关闭状态
|
|
|
+ * $type 1=开启小程序,2=关闭小程序
|
|
|
+ * @return \Illuminate\Http\JsonResponse
|
|
|
+ * @throws \Illuminate\Validation\ValidationException
|
|
|
+ */
|
|
|
+ public function docter_open(){
|
|
|
+ $req = request()->post();
|
|
|
+ $this->validate(request(), [
|
|
|
+ 'type' => 'required|integer|in:1,2',
|
|
|
+ ]);
|
|
|
+ $user = $this->user;
|
|
|
+ $docter_id = $user['id'];
|
|
|
+ Docter::where('id',$docter_id)->update(['is_open'=>$req['type']]);
|
|
|
+ return out();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 确认超时提醒 当天的预约订单,医生还未点击完成的订单,23:00给医生发送提醒
|
|
|
+ */
|
|
|
+ public function AppointReminder(){
|
|
|
+
|
|
|
+ $beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));
|
|
|
+ $endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
|
|
|
+ $Order = Order::with(['orderPatient','docter','user'])->where(['order_status'=>3,'payment_status'=>2,'product_type'=>3])->whereBetween('receiving_time',[$beginToday,$endToday])->get();
|
|
|
+ foreach ($Order as $k=>$v){
|
|
|
+ if ($v['docter']){
|
|
|
+ if ($v['docter']['openid']){
|
|
|
+ $send = send_wechatSubscription_message('appoint_reminder',[$v['docter']['openid'],"https://easywechat.org",$v['order_sn'],$v['user']['nickname'],$v['user']['phone'],$v['created_at']]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 取消订单提醒
|
|
|
+ * @param $order_id
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
|
+ * @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
+ */
|
|
|
+ public function CancelReminder($order_id){
|
|
|
+ $Order = Order::with(['orderPatient','docter','user'])->where(['id'=>$order_id])->first();
|
|
|
+
|
|
|
+ $type = '';
|
|
|
+ if ($Order['product_type']==1){
|
|
|
+ $type = '电话咨询';
|
|
|
+ }elseif ($Order['product_type']==2){
|
|
|
+ $type = '图文咨询 ';
|
|
|
+ }elseif ($Order['product_type']==3){
|
|
|
+ $type = '门诊预约';
|
|
|
+ }
|
|
|
+ if ($Order){
|
|
|
+ if ($Order['docter']['openid']){
|
|
|
+ $send = send_wechatSubscription_message('cancel_reminder',[
|
|
|
+ $Order['docter']['openid'],
|
|
|
+ "https://easywechat.org",
|
|
|
+ $Order['docter']['name'],
|
|
|
+ $Order['order_sn'],
|
|
|
+ $type,
|
|
|
+ $Order['total_amount'],
|
|
|
+ $Order['created_at'],
|
|
|
+ '',
|
|
|
+ ]);
|
|
|
+ var_dump($send);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 咨询订单接单提醒
|
|
|
+ * @param $order_id
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
|
+ * @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
+ */
|
|
|
+ public function ReceivingReminder($order_id){
|
|
|
+ $Order = Order::with(['orderPatient','user'])->where(['id'=>$order_id])->first();
|
|
|
+ $type = '';
|
|
|
+ if ($Order['product_type']==1){
|
|
|
+ $type = '电话咨询';
|
|
|
+ }elseif ($Order['product_type']==2){
|
|
|
+ $type = '图文咨询 ';
|
|
|
+ }elseif ($Order['product_type']==3){
|
|
|
+ $type = '门诊预约';
|
|
|
+ }
|
|
|
+ if ($Order){
|
|
|
+ if ($Order['user']['openid']){
|
|
|
+ $send = send_wechatSubscription_message('receiving_reminder',[
|
|
|
+ $Order['user']['openid'],
|
|
|
+ "https://easywechat.org",
|
|
|
+ $Order['order_sn'],
|
|
|
+ $type,
|
|
|
+ date('Y-m-d H:i',$Order['receiving_time']),
|
|
|
+ $Order['order_patient']['phone'],
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 消息回复提醒(医生)
|
|
|
+ * @param $order_id
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
|
+ * @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
+ */
|
|
|
+ public function ReplyReminder($docter_id,$user_id){
|
|
|
+ $list = DocterOrganization::with(['docter','organization'])->where(['docter_id'=>$docter_id,'is_open'=>2])->first();
|
|
|
+ $user = User::where('id',$user_id)->first();
|
|
|
+ if ($list){
|
|
|
+ if ($user['openid']){
|
|
|
+ $send = send_wechatSubscription_message('reply_reminder',[
|
|
|
+ $user['openid'],
|
|
|
+ "https://easywechat.org",
|
|
|
+ $list['organization']['name'],
|
|
|
+ $list['docter']['name'],
|
|
|
+ $user['nickname'],
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 排班变更提醒
|
|
|
+ * @param $docter_id 医生id
|
|
|
+ * @param int $type 类型0=周排班 1=月排班
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
|
+ * @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
+ */
|
|
|
+ public function ScheduleReminder($docter_id=81,$type=0){
|
|
|
+ $list = Docter::where(['id'=>$docter_id])->first();
|
|
|
+ $type = '';
|
|
|
+ $openid = $list['openid'];
|
|
|
+ if ($type==0){
|
|
|
+ $type = '周排班变动';
|
|
|
+ }elseif ($type==1){
|
|
|
+ $type = '月排班变动 ';
|
|
|
+ }
|
|
|
+ if ($list){
|
|
|
+ if ($openid){
|
|
|
+ $send = send_wechatSubscription_message('schedule_reminder',[$openid, "https://easywechat.org", $type, 'A社区']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 审核认证提醒
|
|
|
+ * @param $docter_id 医生id
|
|
|
+ * @param int $msg 消息
|
|
|
+ * @param $time 时间
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
|
+ * @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
+ */
|
|
|
+ public function ThenReminder($docter_id,$msg='',$time){
|
|
|
+ $list = Docter::where(['id'=>$docter_id])->first();
|
|
|
+ $openid = $list['openid'];
|
|
|
+ if ($list){
|
|
|
+ if ($openid){
|
|
|
+ $send = send_wechatSubscription_message('then_reminder',[$openid, "https://easywechat.org", $list['name'],$msg,$time]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 认证到期提醒
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
|
+ * @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
+ */
|
|
|
+ public function OutThenReminder(){
|
|
|
+ $list = DocterOrganization::with('docter','organization')->get();
|
|
|
+ if($list){
|
|
|
+ foreach ($list as $k=>$v){
|
|
|
+ if ($v['docter']['openid']&& (strtotime($v['authentication_end_time'])-strtotime($v['authentication_time']))<=(1*60*60*24)){
|
|
|
+ $send = send_wechatSubscription_message('out_then_reminder',[$v['docter']['openid'], "https://easywechat.org", $v['organization']['name'],date('Y-m-d',strtotime($v['authentication_end_time']))]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 签约失效提醒
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
|
+ * @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
+ */
|
|
|
+ public function InvalidThenReminder(){
|
|
|
+ $list = DocterOrganization::with('docter','organization')->get();
|
|
|
+ if($list){
|
|
|
+ foreach ($list as $k=>$v){
|
|
|
+ if ($v['docter']['openid']&& time()>=strtotime($v['authentication_end_time'])){
|
|
|
+ $send = send_wechatSubscription_message('out_then_reminder',[$v['docter']['openid'], "https://easywechat.org", $v['organization']['name'],date('Y-m-d',strtotime($v['authentication_end_time']))]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 明日预约提醒(未完成)
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
|
+ * @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
+ */
|
|
|
+ public function TodayReminder(){
|
|
|
+ $list = DocterOrganization::with('docter','organization')->get();
|
|
|
+ if($list){
|
|
|
+ foreach ($list as $k=>$v){
|
|
|
+ if ($v['docter']['openid']&& time()>=strtotime($v['authentication_end_time'])){
|
|
|
+ $send = send_wechatSubscription_message('schedule_reminder', [
|
|
|
+ '医生id',
|
|
|
+ "https://easywechat.org",
|
|
|
+ '小刘',
|
|
|
+ '类型',
|
|
|
+ '人数',
|
|
|
+ '医院',
|
|
|
+ ]);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|