Просмотр исходного кода

Merge branch 'master' of ssh://git.9026.com:2212/swdz-WangHaijun/BaoMa

zilong 4 лет назад
Родитель
Сommit
4136809a9f

+ 14 - 16
app/Admin/Actions/Community/Docter/Failed.php

xqd
@@ -17,31 +17,29 @@ class Failed extends RowAction
     public $name = '驳回';
     public function handle()
     {
-        $openid = 'oflME5eixHMij2TIVyy52WbfaQvA';
+        $openid = $this->row->docter->openid;
 
         $data = [
-              $openid,
-              '很抱歉,你的医生身份认证失败!',
-              $this->row->docter->name,
-              $this->row->organization->name,
-              $this->row->qualification->name,
-              $this->row->office->name,
+            $openid,
+            '',
+            '很抱歉,你的医生身份认证失败!',
+            $this->row->docter->name,
+            $this->row->organization->name,
+            $this->row->qualification->name,
+            $this->row->office->name,
+            '点击进入小程序查看详情,有疑问请联系管理员!'
         ];
+
         DB::beginTransaction();
         try {
 
             DocterOrganization::where('id',$this->row->id)->update(['state'=>2]);
-            $docter_id = $this->row->docter_id;
-            $ret = send_wechatSubscription_message('then_reminder',$data);
-            dd($ret);
-
-//            Docter::where(['id'=>$docter_id])->update(['is_then'=
-//            ewWm59p1oVpHw7vt3LlkQTWpYgOZ_h6rfINUiTc4GbM
-              $data = [
-
-              ];
+            if(!empty($openid)){
+                admin_send_docter_message('then_result',$data);
+            }
             DB::commit();
         } catch (Exception $e){
+            dd($e->getMessage());
             DB::rollBack();
             return $this->response()->error('操作失败');
         }

+ 20 - 1
app/Admin/Actions/backstage/Pass.php

xqd xqd
@@ -18,6 +18,7 @@ class Pass extends RowAction
 //         $model ...
 //        dd($model);
         //判定通过认证的数量
+
         $is_pass_num = 0;
         //查询认证表里有多少条记录
         $docter_approve_num = DocterOrganization::where('docter_id',$model->docter_id)->get();
@@ -67,7 +68,25 @@ class Pass extends RowAction
                 Serviceapplys::insert($total_arr);
             }
         }
+
+        //发送认证结果提示
+        $openid = $this->row->docter->openid;
+
+        $data = [
+            $openid,
+            '',
+            '恭喜你,你的医生身份认证已通过',
+            $this->row->docter->name,
+            $this->row->organization->name,
+            $this->row->qualification->name,
+            $this->row->office->name,
+            '点击进入小程序查看详情'
+        ];
+        if(!empty($openid)){
+            admin_send_docter_message('then_result',$data);
+        }
+
         return $this->response()->success('审核通过')->refresh();
     }
 
-}
+}

+ 17 - 1
app/Admin/Actions/backstage/Refuse.php

xqd
@@ -14,7 +14,23 @@ class Refuse extends RowAction
         // $model ...
         DocterOrganization::where('id',$model->id)->update(['state'=>2,'authentication_time'=>0,'authentication_end_time'=>0]);
 
+        $openid = $this->row->docter->openid;
+
+        $data = [
+            $openid,
+            '',
+            '很抱歉,你的医生身份认证失败!',
+            $this->row->docter->name,
+            $this->row->organization->name,
+            $this->row->qualification->name,
+            $this->row->office->name,
+            '点击进入小程序查看详情,有疑问请联系管理员!'
+        ];
+        if(!empty($openid)){
+            admin_send_docter_message('then_result',$data);
+        }
+
         return $this->response()->success('审核驳回')->refresh();
     }
 
-}
+}

+ 14 - 1
app/Admin/Actions/backstage/Revoke.php

xqd
@@ -35,7 +35,20 @@ class Revoke extends RowAction
             DocterOrganization::where('id',$model->id)->update(['state'=>0,'authentication_time'=>0,'authentication_end_time'=>0]);
             Docter::where('id',$model->docter_id)->update(['is_then'=>0]);
         }
+
+        $openid = $this->row->docter->openid;
+
+        //发送消息
+        $data = [
+            $openid,
+            $this->row->organization->name,
+            date('Y-m-d H:i:s',time())
+        ];
+        if(!empty($openid)){
+           $ret =  admin_send_docter_message('out_then_reminder',$data);
+        }
+
         return $this->response()->success('审核撤销成功')->refresh();
     }
 
-}
+}

+ 2 - 2
app/Admin/Controllers/OrdersManagement/ServicePackDetailsController.php

xqd
@@ -43,8 +43,8 @@ class ServicePackDetailsController extends AdminController
         $grid->column('phone_minutes', __('剩余电话分钟数'));
         $grid->column('chat_num', __('剩余图文咨询次数'));
         $grid->column('appoint_num', __('剩余门诊预约次数'));
-        $grid->column('vaccine_limit_amount', __('剩余疫苗金额'));
-        $grid->column('nurses_limit_amount', __('剩余儿保金额'));
+        $grid->column('vaccine_limit_amount', __('剩余疫苗次数'));
+        $grid->column('nurses_limit_amount', __('剩余儿保次数'));
         $grid->column('effective_days', __('有效天数'));
         $grid->column('start_time', __('开始时间'))->display(function ($time){
             return date('Y-m-d H:i:s',$time);

+ 2 - 2
app/Admin/Controllers/ServicePacksManagment/ServicePacksController.php

xqd
@@ -125,10 +125,10 @@ class ServicePacksController extends AdminController
             })->when('has',3,function (Form $form){
                 $form->number('appoint_num', __('门诊次数'))->default(0);
             })->when('has',4,function (Form $form){
-                $form->number('vaccine_limit_amount', __('儿保金额'))->default(0);
+                $form->number('vaccine_limit_amount', __('儿保次数'))->default(0);
             })->when('has',5,function (Form $form){
                 //暂未完成,这里展示所有的自费的儿保项目
-                $form->number('nurses_limit_amount', __('计免金额'))->default(0);
+                $form->number('nurses_limit_amount', __('计免次数'))->default(0);
 //                $form->select('product', __('儿保项目'))->options(Nurse::where('type',2)->pluck('name','id'));
             })->rules('required',['required'=>'请选择服务类型']);
         $form->text('effective_days', __('服务时长(天)'))->default(0);

+ 2 - 2
app/Admin/Controllers/UserManagement/BmUser/UserServiceController.php

xqd
@@ -108,10 +108,10 @@ class UserServiceController extends AdminController
         $show->field('orderPack.phone_minutes', __('	电话分钟数'));
         $show->field('orderPack.chat_num', __('图文咨询次数'));
         $show->field('orderPack.appoint_num', __('门诊预约次数'));
-        $show->field('orderPack.vaccine_limit_amount', __('疫苗总金额限制'))->as(function ($price){
+        $show->field('orderPack.vaccine_limit_amount', __('疫苗次数'))->as(function ($price){
             return $price/100;
         });
-        $show->field('orderPack.nurses_limit_amount', __('儿保总金额限制'))->as(function ($price){
+        $show->field('orderPack.nurses_limit_amount', __('儿保次数'))->as(function ($price){
             return $price/100;
         });
         $show->field('orderPack.effective_days', __('	有效天数'));

+ 14 - 5
app/Community/Actions/Clinc/OrderCancel.php

xqd
@@ -16,20 +16,29 @@ class OrderCancel extends RowAction
         $id = $this->row->id;
         $sn = $this->row->order_sn;
         $openid = $this->row->orderUser->openid;
+//        $openid = 'oYmUA5A1OIqtpA1XSrw35tbjtv1w';
         if(empty($openid)) return true;
-        //$openid = 'oYmUA5A1OIqtpA1XSrw35tbjtv1w';
         $time = $this->row->created_at;
-        $price = (intval($this->row->price) / 100).'元';
+        $price = (intval($this->row->total_amount) / 100);
+        $pantient = $this->row->orderPatient->name;
+        $organization = $this->row->organization->name;
+        $paystatus = Order::getPayStatus()[$this->row->payment_status];
+
         DB::beginTransaction();
         try {
             //退还余额
-            $res = Order::orderCancel($id);
+            $res = Order::orderCancel($id,'社区取消');
             $msg = [
-                $openid,'/pages/index/index','您有一个订单已取消',$sn,'门诊订单',$price,$time,'社区取消','如有疑问请联系客服'
+                $openid,$sn,'门诊预约',$price,$time,$pantient,$organization,'社区取消',$paystatus
+            ];
+            $miniMsg = [
+                $openid,$sn,'社区取消','门诊预约',$paystatus
             ];
-            $ret = send_wechat_message(9,$msg,'','');
+            //发送消息
+            $ret = admin_send_wechat_message(1,$msg,$miniMsg);
             DB::commit();
         } catch ( \Exception $e){
+            dd($e->getMessage());
             DB::rollBack();
             return $this->response()->error('操作失败!');
         }

+ 13 - 5
app/Community/Actions/Nurse/OrderCance.php

xqd xqd
@@ -3,6 +3,7 @@
 namespace App\Community\Actions\Nurse;
 
 use App\Models\Order;
+use App\Models\Organization;
 use App\Models\User;
 use Encore\Admin\Actions\RowAction;
 use Illuminate\Database\Eloquent\Model;
@@ -19,19 +20,26 @@ class OrderCance extends RowAction
         $sn = $order->order_sn;
         if(empty($order->orderUser) || empty($order->orderUser->openid) ) return true;
         $openid = $order->orderUser->openid;
-        //$openid = 'oYmUA5A1OIqtpA1XSrw35tbjtv1w';
+//        $openid = 'oYmUA5A1OIqtpA1XSrw35tbjtv1w';
         $time = $this->row->created_at;
-        $price = (intval($this->row->price) / 100).'元';
+        $price = ($this->row->total_amount / 100);
+
+        $pantient = $this->row->patients->name;
+        $organization = Organization::where(['id'=>$this->row->orders->organization_id])->value('name');
+        $paystatus = Order::getPayStatus()[$this->row->orders->payment_status];
 
         DB::beginTransaction();
         try {
             //退还余额
             $res = Order::orderCancel($id,'社区取消');
             $msg = [
-                $openid,'/pages/index/index','您有一个订单已取消',$sn,'儿保订单',$price,$time,'社区取消','如有疑问请联系客服'
+                $openid,$sn,'儿保预约',$price,$time,$pantient,$organization,'社区取消',$paystatus
             ];
-            $ret = send_wechat_message(9,$msg,'','');
-
+            $miniMsg = [
+                $openid,$sn,'社区取消','儿保预约',$paystatus
+            ];
+            //用户和医生都要发
+            $ret = admin_send_wechat_message(1,$msg,$miniMsg);
             DB::commit();
         } catch ( \Exception $e){
             dump($e->getMessage());

+ 14 - 5
app/Community/Actions/Vaccine/OrderCance.php

xqd
@@ -17,21 +17,30 @@ class OrderCance extends RowAction
         $id = $this->row->id;
         $sn = $this->row->order_sn;
         $openid = $this->row->orderUser->openid;
+//        $openid = 'oYmUA5A1OIqtpA1XSrw35tbjtv1w';
         if(empty($openid)) return true;
-        //$openid = 'oYmUA5A1OIqtpA1XSrw35tbjtv1w';
         $time = $this->row->created_at;
-        $price = (intval($this->row->price) / 100).'元';
+        $price = (intval($this->row->total_amount) / 100);
+        $pantient = $this->row->orderPatient->name;
+        $organization = $this->row->organization->name;
+        $paystatus = Order::getPayStatus()[$this->row->payment_status];
 
         DB::beginTransaction();
         try {
             //退还余额
-            $res = Order::orderCancel($id);
+            $res = Order::orderCancel($id,'社区取消');
             $msg = [
-                $openid,'/pages/index/index','您有一个订单已取消',$sn,'疫苗接种订单',$price,$time,'社区取消','如有疑问请联系客服'
+                $openid,$sn,'疫苗接种预约',$price,$time,$pantient,$organization,'社区取消',$paystatus
             ];
-            $ret = send_wechat_message(9,$msg,'','');
+            $miniMsg = [
+                $openid,$sn,'社区取消','疫苗接种预约',$paystatus
+            ];
+            //发送消息
+            $ret = admin_send_wechat_message(1,$msg,$miniMsg);
+
             DB::commit();
         } catch ( \Exception $e){
+            dd($e->getMessage());
             DB::rollBack();
             return $this->response()->error('操作失败!');
         }

+ 6 - 6
app/Community/Controllers/OrderController.php

xqd xqd xqd
@@ -64,7 +64,7 @@ class OrderController extends AdminController
         });;
         $grid->column('docter.name', __('预约医生'));
 //        $grid->column('order_status', __('订单状态'))->using([1=>'未支付',2=>'待接单',3=>'进行中',4=>'已完成',5=>'已取消']);
-        $grid->column('order_status','订单状态')->using(Order::getStatus())->label([1=>'info',2=>'warring',3=>'info',4=>'success',5=>'error']);
+        $grid->column('order_status','订单状态')->using(Order::getStatus())->label([1=>'info',2=>'warring',3=>'info',4=>'success',5=>'danger']);
         $grid->column('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
         //查询
         $grid->quickSearch(function ($model, $query) {
@@ -73,9 +73,9 @@ class OrderController extends AdminController
             });
         })->placeholder('请输入用户姓名');
         $grid->actions(function ($actions) {
-            if(!empty($actions->row->order_status) && $actions->row->order_status < 2){
-                $actions->add(new Reserved());
-            }
+//            if(!empty($actions->row->order_status) && $actions->row->order_status < 2){
+//                $actions->add(new Reserved());
+//            }
             if(!empty($actions->row->order_status) && $actions->row->order_status<= 3){
                 $actions->add(new OrderCancel());
                 $actions->add(new Finished());
@@ -114,8 +114,8 @@ class OrderController extends AdminController
         $show->field('orderPatient.appoint_end_time', __('结束时间'));
         $show->field('orderPatient.birthday', __('患者年龄'));
         $show->field('docter.name', __('预约医生'));
-        $show->field('order_status', __('订单状态'))->using(Order::getStatus());
-        $show->field('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款']);
+        $show->field('order_status', __('订单状态'))->using(Order::getStatus())->label('info');
+        $show->field('payment_status', __('支付状态'))->using([1=>'待付款',2=>'已付款',3=>'退款中',4=>'已退款'])->label('info');
         $show->panel()->tools(function ($tools) {
                 $tools->disableEdit();
                 $tools->disableDelete();

+ 3 - 3
app/Community/Controllers/OrderNurseController.php

xqd
@@ -96,9 +96,9 @@ class OrderNurseController extends AdminController
         });
 
         $grid->actions(function ($actions) {
-            if(!empty($actions->row->orders) && $actions->row->orders->order_status < 2){
-                $actions->add(new Reserved());
-            }
+//            if(!empty($actions->row->orders) && $actions->row->orders->order_status < 2){
+//                $actions->add(new Reserved());
+//            }
             if(!empty($actions->row->orders) && $actions->row->orders->order_status<= 3){
                 $actions->add(new OrderCance());
                 $actions->add(new Finished());

+ 3 - 5
app/Community/Controllers/OrderVaccinesController.php

xqd
@@ -86,11 +86,9 @@ class OrderVaccinesController extends AdminController
             $tools->append(new FasteOrder());
         });
         $grid->actions(function ($actions) {
-//            $actions->add(new AddOrder());
-            if( $actions->row->order_status<= 2 ){
-                $actions->add(new Reserved());
-                $actions->add(new OrderCance());
-            }
+//            if( $actions->row->order_status<= 2){
+//                $actions->add(new Reserved());
+//            }
 
             if(!empty($actions->row->order_status) &&  $actions->row->order_status<= 3 ){
                 $actions->add(new Finished());

+ 5 - 3
app/Console/Commands/ScheduleNotice.php

xqd xqd xqd
@@ -22,7 +22,7 @@ class ScheduleNotice extends Command
      *
      * @var string
      */
-    protected $description = '排班提醒';
+    protected $description = '排班提醒 每周六18:00 提醒一次';
 
     /**
      * Create a new command instance.
@@ -41,7 +41,7 @@ class ScheduleNotice extends Command
      */
     public function handle()
     {
-        //门诊医生排班
+        //门诊医生排班提醒
         $docters = Docter::where(['type'=>1])->get();
         $nowDay = intval(date('N',time()));
         $endDay = (7-$nowDay)*86400 +time();
@@ -49,8 +49,10 @@ class ScheduleNotice extends Command
         foreach ($docters as $d){
             if(empty($d->openid)) continue;
             $teams = get_docter_organization($d->id);
+            //$openid = 'oflME5eixHMij2TIVyy52WbfaQvA';
             $data = [$d->openid,'',$d->name,$time, $teams];
-            $ret = send_wechatSubscription_message('schedule_notice',$data);
+            $ret = admin_send_docter_message('schedule_notice',$data);
+            dd($ret);
         }
 
     }

+ 79 - 4
app/Console/Commands/overTimeOrder.php

xqd xqd xqd xqd
@@ -2,6 +2,7 @@
 
 namespace App\Console\Commands;
 
+use App\Models\DocterOrganization;
 use App\Models\Order;
 use App\Models\SystemConfig;
 use Illuminate\Console\Command;
@@ -14,7 +15,7 @@ class overTimeOrder extends Command
      *
      * @var string
      */
-    protected $signature = 'overOrder';
+    protected $signature = 'order {type}';
 
     /**
      * The console command description.
@@ -40,7 +41,83 @@ class overTimeOrder extends Command
      */
     public function handle()
     {
-        Log::info('超时命令'.date('Y-m-d H:is',time()).PHP_EOL);
+        $type = $this->argument('type');
+        if(!in_array($type,['orderOut','appiontOut','thenOut','thenLose'])){
+            dd('请输入正确的参数');
+        }
+        if($type == 'orderOut'){
+            //订单超时
+            $this->overTimeOrers();
+        } else if($type == 'appiontOut'){
+            //预约超时
+            $this->AppointReminder();
+        }else if($type == 'thenOut'){
+            //认证到期
+            $this->OutThenReminder();
+        }else if($type == 'thenLose'){
+            //认证失效
+            $this->InvalidThenReminder();
+        }
+        dd('ok');
+    }
+
+    /**
+    * 	确认超时提醒 当天的预约订单,医生还未点击完成的订单,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'], "pages/index/index",$v['order_sn'],$v['user']['nickname'],$v['user']['phone'],$v['created_at']]);
+                }
+            }
+        }
+    }
+
+    /**
+     * 签约失效提醒
+     * @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'],  "pages/index/index", $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 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'],  "pages/index/index", $v['organization']['name'],date('Y-m-d',strtotime($v['authentication_end_time']))]);
+                }
+            }
+        }
+    }
+
+    /**
+     * 订单超时自动完成(定时)
+     */
+    public function overTimeOrers(){
         $config_chat =  SystemConfig::get('docter_config','chat_complete_time');
         $config_phone =  SystemConfig::get('docter_config','phone_complete_time');
 
@@ -67,13 +144,11 @@ class overTimeOrder extends Command
             }
 
         }
-
         if ($catNewIds || $menNewIds){
             // 操作图文和电话订单为已完成
             Order::whereIn('id',$catNewIds)->update(['order_status'=>4]);
             // 操作门诊订单为已超时
             Order::whereIn('id',$menNewIds)->update(['order_status'=>6]);
         }
-
     }
 }

+ 3 - 1
app/Console/Kernel.php

xqd xqd
@@ -3,6 +3,7 @@
 namespace App\Console;
 
 use App\Console\Commands\overTimeOrder;
+use App\Console\Commands\packExpiredCheck;
 use Illuminate\Console\Scheduling\Schedule;
 use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
 
@@ -15,8 +16,9 @@ class Kernel extends ConsoleKernel
      */
     protected $commands = [
         //
-        'overOrder'=>overTimeOrder::class,
+        'order'=>overTimeOrder::class,
         'scheduleNotice'=>overTimeOrder::class,
+        'packExpiredCheck'=>packExpiredCheck::class,
     ];
 
     /**

+ 49 - 0
app/Helpers/functions.php

xqd
@@ -590,3 +590,52 @@ if (!function_exists('get_docter_organization')) {
         return implode(',',$name);
     }
 }
+
+//后台发送微信消息
+if (!function_exists('admin_send_wechat_message')) {
+    function admin_send_wechat_message($type, $official_arr, $subscribe_arr = [])
+    {
+        try {
+            $app = Factory::miniProgram(config('config.wechat_small_program'));
+            //先发送模板消息
+            $data = config('notice.wechat_official_message_template')[$type];
+            $json = json_encode($data, JSON_UNESCAPED_UNICODE);
+            $json = vsprintf($json, $official_arr);
+            $data = json_decode($json, true);
+            $ret = $app->uniform_message->send($data);
+            //如果模板消息发送失败(可能因用户没有关注公众号而失败)再发送订阅消息
+            if (!empty($subscribe_arr) && isset($ret['errcode']) && $ret['errcode'] != 0) {
+                $data = config('notice.wechat_subscribe_message_template')[$type];
+                $json = json_encode($data, JSON_UNESCAPED_UNICODE);
+                $json = vsprintf($json, $subscribe_arr);
+                $data = json_decode($json, true);
+                $ret = $app->subscribe_message->send($data);
+                if (isset($ret['errcode']) && $ret['errcode'] != 0) {
+                    trace(['发送微信订阅消息失败,请求参数' => $data ?? '', '返回数据' => $ret ?? ''], 'error');
+                }
+            }
+        } catch (Exception $e) {
+            trace(['发送微信消息失败' => $e->getMessage(), '请求参数' => $data ?? '', '返回数据' => $ret ?? ''], 'error');
+        }
+
+        return $ret ?? false;
+    }
+}
+
+// 后台医生端发送公众号模板消息方法
+if (!function_exists('admin_send_docter_message')) {
+    function admin_send_docter_message($type, $arr)
+    {
+        try {
+            $app = Factory::miniProgram(config('notice.docter_wechat_small_program'));
+            $data = config('notice.wechatSubscription_template')[$type];
+            $json = json_encode($data, JSON_UNESCAPED_UNICODE);
+            $json = vsprintf($json, $arr);
+            $data = json_decode($json, true);
+            $result = $app->uniform_message->send($data);
+        } catch (Exception $e) {
+            trace(['发送微信模板消息失败' => $e->getMessage(), '请求参数' => $data ?? '', '返回数据' => $result ?? ''], 'error');
+        }
+        return $result ?? false;
+    }
+}

+ 13 - 11
app/Http/Controllers/Api/V2/DoctorController.php

xqd xqd xqd xqd xqd
@@ -1324,11 +1324,9 @@ class DoctorController extends AuthController
         $patientsArr = [];
         $ws['user_id'] = $req['user_id'];
         $ws['product_type'] = 6;
-        $fuw_order = Order::with('orderPack')->where($ws)->orderBy('created_at', 'desc')->get();
+        $fuw_order = Order::with('orderPack')->where($ws)->whereIn('order_status',[3,4])->orderBy('created_at', 'desc')->get();
         if ($fuw_order) {
             $fuw_order = $fuw_order->toArray();
-//            var_dump($fuw_order);
-
             foreach ($fuw_order as $kk => $vv) {
                 $fuwArr[$kk]['order_id'] = $vv['id'];
                 if ($vv['order_pack']) {
@@ -1398,20 +1396,15 @@ class DoctorController extends AuthController
 
         // 拼接服务消息
         $wh['user_id'] = $req['user_id'];
-        $wh['order_status'] = ['>', 3];
         $wh['product_type'] = 6;
         $fuwuList = [];
-        $fuwuInfo = Order::where($wh)->get();
+        $fuwuInfo = Order::where($wh)->whereIn('order_status',[3,4])->get();
         $fuwuList['fuwu_num'] = count($fuwuInfo);
         $whs['user_id'] = $req['user_id'];
-        $whs['order_status'] = ['>', 3];
-        $order_nums = Order::where($whs)->get();
-
+        $order_nums = Order::where($whs)->whereIn('order_status',[3,4])->get();
         $fuwuList['order_num'] = count($order_nums);
         $pati_nums = Patient::where('user_id', '=', $req['user_id'])->get();
         $fuwuList['pati_num'] = count($pati_nums);
-
-
         $returnArr = [
             'user_arr' => $userArr,
             'patients_arr' => $patientsArr,//患者档案
@@ -1441,7 +1434,7 @@ class DoctorController extends AuthController
             $finds = $finds->toArray();
         }
         if ($finds['sex'] == 0) {
-            $finds['sex'] = '中性';
+            $finds['sex'] = '未知';
         } elseif ($finds['sex'] == 1) {
             $finds['sex'] = '男';
         } else {
@@ -1502,6 +1495,9 @@ class DoctorController extends AuthController
                     case 7:
                         $patient_arr[$k]['product_type'] = '充值';
                         break;
+                    case 8:
+                        $patient_arr[$k]['product_type'] = '快速预约';
+                        break;
                     default:
                         $patient_arr[$k]['product_type'] = '错误';
                 }
@@ -1521,6 +1517,12 @@ class DoctorController extends AuthController
                     case 5:
                         $patient_arr[$k]['order_status'] = '已取消';
                         break;
+                    case 6:
+                        $patient_arr[$k]['order_status'] = '已超时';
+                        break;
+                    case 7:
+                        $patient_arr[$k]['order_status'] = '已预约';
+                        break;
                     default:
                         $patient_arr[$k]['order_status'] = '未知';
                 }

+ 6 - 2
app/Http/Controllers/Api/V2/PatientController.php

xqd xqd xqd
@@ -255,7 +255,7 @@ class PatientController extends AuthController
         }
 
         $axbwhere['docter_id'] = $user['id'];
-        $axbwhere['user_id'] = $req['user_id'];
+        $axbwhere['user_id'] = $find['user_id'];
         $finds = Axb::where($axbwhere)->orderBy('id', 'desc')->first();
 
         if ($status == 1 && $finds) {
@@ -424,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();
 
         // 通话记录查询
         $datas = CallLog::where('order_id', $req['patient_id'])->get();
@@ -436,6 +436,10 @@ class PatientController extends AuthController
         $res_patient = [];
 
         //电话咨询
+        //电话咨询
+        if ($data){
+            $data=$data->toArray();
+        }
 
         if ($data['product_type'] == 1) {
 

+ 15 - 0
app/Models/Order.php

xqd
@@ -22,12 +22,27 @@ class Order extends BaseModel
         self::ISOUT=>'已超时'
     ];
 
+
     //获取订单状态
     public static  function getStatus()
     {
         return self::$_order_status;
     }
 
+    // 支付状态(1.待付款 2.已付款 3.退款中 4.已退款  5.待退款)
+    public static $_order_pay_status = [
+        1=>'待支付',
+        2=>'已付款',
+        3=>'退款中',
+        4=>'已退款',
+        5=>'待退款',
+    ];
+
+    public static  function getPayStatus()
+    {
+        return self::$_order_pay_status;
+    }
+
     public function docter()
     {
         return $this->belongsTo(Docter::class);

+ 5 - 0
app/Models/Patient.php

xqd
@@ -52,4 +52,9 @@ class Patient extends BaseModel
     public function order(){
         return $this->hasMany(Order::class);
     }
+
+    public function user(){
+        return $this->hasOne(User::class,'id','user_id');
+    }
+    
 }

+ 422 - 0
config/notice.php

xqd
@@ -0,0 +1,422 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 20-9-23
+ * Time: 上午11:41
+ */
+
+return [
+
+    'wechat_small_program' => [
+        'app_id' => env('WECHAT_APPID', 'wx6131f74e623bf6bf'),
+        'secret' => env('WECHAT_APPSECRET', 'b703596ab6cbcad5b74eb51fec2aeb0b'),
+    ],
+
+    'docter_wechat_small_program' => [
+        'app_id' => env('DOCTOR_WECHAT_APPID', 'wx92066f7587c34617'),
+        'secret' => env('DOCTOR_WECHAT_APPSECRET', 'bd7849c5259b79c41ec158173c5fb1d6'),
+    ],
+
+
+
+    'wechat_official_program' => [
+        'app_id' => env('OFFICIAL_WECHAT_APPID'),
+        'secret' => env('OFFICIAL_WECHAT_APPSECRET'),
+    ],
+
+
+    //公众号模板消息
+    'wechat_official_message_template' => [
+        //订单取消提醒
+        1 => [
+            'touser' => '%s',
+            'mp_template_msg' => [
+                'appid' => env('OFFICIAL_WECHAT_APPID'),
+                'template_id' => 'xYAvY_xez7Ou_qflGuPV7L277FCPpj3K-zFdRcUYaBI',
+                'url' => '',
+                'miniprogram' => [
+                    'appid' => env('WECHAT_APPID', 'wx6131f74e623bf6bf'),
+                    'page' => '',
+                ],
+                'data' => [
+                    'first' => [
+                        'value' => '尊敬的用户,你有一笔订单已取消!',
+                    ],
+                    'keyword1' => [
+                        'value' => '%s',
+                    ],
+                    'keyword2' => [
+                        'value' => '%s',
+                    ],
+                    'keyword3' => [
+                        'value' => '%s元',
+                    ],
+                    'keyword4' => [
+                        'value' => '%s',
+                    ],
+                    'keyword5' => [
+                        'value' => '%s患者在%s的服务终止',
+                    ],
+                    'remark' => [
+                        'value' => '订单备注:%s; 支付状态:%s; 点击进入小程序查看相关详情,如有疑问,请联系我们',
+                    ],
+                ],
+            ],
+        ],
+        //服务包续费(即将到期)提醒
+        2 => [
+            'touser' => '%s',
+            'mp_template_msg' => [
+                'appid' => env('OFFICIAL_WECHAT_APPID'),
+                'template_id' => 'aqfqUZtxj8jrRQe5_rhjaoHCmtDUeDLRgVYVdTMTH2k',
+                'url' => '',
+                'miniprogram' => [
+                    'appid' => env('WECHAT_APPID', 'wx6131f74e623bf6bf'),
+                    'page' => '',
+                ],
+                'data' => [
+                    'first' => [
+                        'value' => '尊敬的用户,您有一个服务包即将到期!',
+                    ],
+                    'keyword1' => [
+                        'value' => '%s',
+                    ],
+                    'keyword2' => [
+                        'value' => '%s',
+                    ],
+                    'keyword3' => [
+                        'value' => '%s',
+                    ],
+                    'remark' => [
+                        'value' => '点击进入小程序查看详情',
+                    ],
+                ],
+            ],
+        ],
+        //服务包失效提醒
+        3 => [
+            'touser' => '%s',
+            'mp_template_msg' => [
+                'appid' => env('OFFICIAL_WECHAT_APPID'),
+                'template_id' => 'aqfqUZtxj8jrRQe5_rhjaoHCmtDUeDLRgVYVdTMTH2k',
+                'url' => '',
+                'miniprogram' => [
+                    'appid' => env('WECHAT_APPID', 'wx6131f74e623bf6bf'),
+                    'page' => '',
+                ],
+                'data' => [
+                    'first' => [
+                        'value' => '尊敬的用户,您有一个服务包已到期!',
+                    ],
+                    'keyword1' => [
+                        'value' => '%s',
+                    ],
+                    'keyword2' => [
+                        'value' => '%s',
+                    ],
+                    'keyword3' => [
+                        'value' => '%s',
+                    ],
+                    'remark' => [
+                        'value' => '点击进入小程序查看详情',
+                    ],
+                ],
+            ],
+        ],
+    ],
+
+    //小程序订阅消息
+    'wechat_subscribe_message_template' => [
+        //订单取消提醒
+        1 => [
+            'template_id' => 'bjZ-r79i8sl7zEtdttAtcCPZLkCgFSYHTNWnNVd1cG0',
+            'touser' => '%s',
+            'page' => '',
+            'data' => [
+                'character_string1' => [
+                    'value' => '%s',
+                ],
+                'name5' => [
+                    'value' => '社区管理员',
+                ],
+                'thing4' => [
+                    'value' => '%s',
+                ],
+                'thing7' => [
+                    'value' => '%s订单,支付状态:%s,有任何疑问,请联系管理员',
+                ],
+            ],
+        ],
+        //服务包续费(即将到期)提醒
+        2 => [
+            'template_id' => 'obCFv2gAnl_RaW-OlnZkjCfi6teT3LUaHxxInUkwLbw',
+            'touser' => '%s',
+            'page' => '',
+            'data' => [
+                'thing1' => [
+                    'value' => '%s',
+                ],
+                'date2' => [
+                    'value' => '%s',
+                ],
+                'thing4' => [
+                    'value' => '亲爱的%s,你的服务包即将失效',
+                ],
+                'phrase5' => [
+                    'value' => '已开通',
+                ],
+                'thing3' => [
+                    'value' => '点击“详情”进入小程序查看服务包详情信息',
+                ],
+            ],
+        ],
+        //服务包失效提醒
+        3 => [
+            'template_id' => 'obCFv2gAnl_RaW-OlnZkjCfi6teT3LUaHxxInUkwLbw',
+            'touser' => '%s',
+            'page' => '',
+            'data' => [
+                'thing1' => [
+                    'value' => '%s',
+                ],
+                'date2' => [
+                    'value' => '%s',
+                ],
+                'thing4' => [
+                    'value' => '亲爱的%s,你的服务包已失效',
+                ],
+                'phrase5' => [
+                    'value' => '已失效',
+                ],
+                'thing3' => [
+                    'value' => '点击“详情”进入小程序查看服务包详情信息
+',
+                ],
+            ],
+        ],
+    ],
+
+    // 线上公众号
+    'docter_wechat_officialAccount' => [
+        'app_id' => env('DOCTOR_OFFICIAL_WECHAT_APPID', 'wx6df68b725662f8a3'),
+        'secret' => env('DOCTOR_OFFICIAL_WECHAT_APPSECRET', '4f91ff06530833577eedcb0c0e111a57'),
+    ],
+
+    'wechatSubscription_template' => [
+        //认证结果
+        'then_result'=>[
+            'touser' => '%s',
+            'mp_template_msg' => [
+                'appid' => env('DOCTOR_OFFICIAL_WECHAT_APPID'),
+                'template_id' => 'ewWm59p1oVpHw7vt3LlkQTWpYgOZ_h6rfINUiTc4GbM',
+                'url' => '',
+                'miniprogram' => [
+                    'appid' => env('DOCTOR_WECHAT_APPID'),
+                    'page' => '%s',
+                ],
+                'data' => [
+                    'first' => [
+                        'value' => '%s',
+                    ]
+                    ,'keyword1' => [
+                        'value' => '%s',
+                    ],
+                    'keyword2' => [
+                        'value' => '%s',
+                    ],
+                    'keyword3' => [
+                        'value' => '%s',
+                    ],
+                    'keyword4' => [
+                        'value' => '%s',
+                    ],
+                    'remark' => [
+                        'value' => '%s',
+                    ],
+                ]
+            ],
+        ],
+
+        // 排班变更提醒
+        'schedule_reminder'=>[
+            'touser' => '%s',
+            'mp_template_msg' => [
+                'appid' => env('DOCTOR_OFFICIAL_WECHAT_APPID'),
+                'template_id' => 'OmNx3Tiu83KwMriLeYsWRbuLfIk1O5JZM1S_K8hdwN4',
+                'url' => '',
+                'miniprogram' => [
+                    'appid' => env('DOCTOR_WECHAT_APPID'),
+                    'page' => '%s',
+                ],
+                'data' => [
+                    'first' => [
+                        'value' => '您好,你的排班情况有所变动,请及时查看',
+                    ]
+                    ,'keyword1' => [
+                        'value' => '%s',
+                    ],
+                    'keyword2' => [
+                        'value' => '%s',
+                    ],
+                    'remark' => [
+                        'value' => '点击进入小程序查看详情,有疑问请联系客服',
+                    ],
+                ]
+            ],
+
+        ],
+        //排班提醒
+        'schedule_notice'=>[
+            'touser' => '%s',
+            'mp_template_msg' => [
+                'appid' => env('DOCTOR_OFFICIAL_WECHAT_APPID'),
+                'template_id' => 'Bd12nbwEtcrsN2IsVA2URiPH1qVGk3uyCemLyxBa-4U',
+                'url' => '',
+                'miniprogram' => [
+                    'appid' => env('DOCTOR_WECHAT_APPID'),
+                    'page' => '%s',
+                ],
+                'data' => [
+                    'first' => [
+                        'value' => '尊敬的%s,你下周的排班已经完成,具体如下!',
+                    ]
+                    ,'keyword1' => [
+                        'value' => '%s',
+                    ],
+                    'keyword2' => [
+                        'value' => '%s',
+                    ],
+                    'keyword3'=> [
+                        'value' => '总后台',
+                    ],
+                    'remark' => [
+                        'value' => '点击进入小程序查看详情,有疑问请联系客服',
+                    ]
+                ]
+            ],
+
+        ],
+
+        // 认证到期
+        'out_then_reminder'=>[
+            'touser' => '%s',
+            'mp_template_msg' => [
+                'appid' => env('DOCTOR_OFFICIAL_WECHAT_APPID'),
+                'template_id' => 'RhvT7gFJcFpUDAImkXIovBTOWZUYA7DirkMrwL0EzE0',
+                'url' => '',
+                'miniprogram' => [
+                    'appid' => env('DOCTOR_WECHAT_APPID'),
+                    'page' => '',
+                ],
+                'data' => [
+                    'first' => [
+                        'value' => '很抱歉,你在%s社区的认证已被撤销,请重新认证!',
+                    ]
+                    ,'keyword1' => [
+                        'value' => '认证撤销',
+                    ],
+                    'keyword2' => [
+                        'value' => '%s',
+                    ],
+                    'remark' => [
+                        'value' => '点击进入小程序查看详情,有疑问请联系管理员!',
+                    ],
+                ]
+            ],
+        ],
+        // 医生接单提醒
+        'receiving_reminder'=>[
+            'touser' => '%s',
+            'mp_template_msg' => [
+                'appid' => env('OFFICIAL_WECHAT_APPID'),
+                'template_id' => 'grtzjXaIQNMTI-UoxY8cakzVna4q65s6qqZFbW67rIk',
+                'url' => '',
+                'miniprogram' => [
+                    'appid' => env('WECHAT_APPID', 'wx6131f74e623bf6bf'),
+                    'page' => '%s',
+                ],
+                'data' => [
+                    'first' => [
+                        'value' => '尊敬的用户,你的咨询订单已被医生接单!',
+                    ]
+                    ,'keyword1' => [
+                        'value' => '%s',
+                    ],
+                    'keyword2' => [
+                        'value' => '%s',
+                    ],
+                    'keyword3' => [
+                        'value' => '%s',
+                    ],
+                    'keyword4' => [
+                        'value' => '%s',
+                    ],
+                    'remark' => [
+                        'value' => '点击进入小程序查看详情!',
+                    ],
+                ]
+            ],
+        ],
+        // 消息回复提醒
+        'reply_reminder'=>[
+            'touser' => '%s',
+            'mp_template_msg' => [
+                'appid' => env('OFFICIAL_WECHAT_APPID'),
+                'template_id' => '0T33vX4zLYSUbFH4NxEe_6Yt4b6m1AoanjpwvBbsRgE',
+                'url' => '',
+                'miniprogram' => [
+                    'appid' => env('WECHAT_APPID', 'wx6131f74e623bf6bf'),
+                    'page' => '%s',
+                ],
+                'data' => [
+                    'first' => [
+                        'value' => '你的咨询订单已被医生回复,请及时查看!',
+                    ]
+                    ,'keyword1' => [
+                        'value' => '%s',
+                    ],
+                    'keyword2' => [
+                        'value' => '%s',
+                    ],
+                    'keyword3' => [
+                        'value' => '%s',
+                    ],
+                    'remark' => [
+                        'value' => '点击进入小程序查看详情!',
+                    ],
+                ]
+            ],
+        ],
+        // 明日预约提醒
+        'today_reminder'=>[
+            'touser' => '%s',
+            'mp_template_msg' => [
+                'appid' => env('DOCTOR_OFFICIAL_WECHAT_APPID'),
+                'template_id' => 'sqRXeqYDHyzxQMu_mO7EroNPhVWUCs2wpbZMRdrrIYc',
+                'url' => '',
+                'miniprogram' => [
+                    'appid' => env('DOCTOR_WECHAT_APPID'),
+                    'page' => '%s',
+                ],
+                'data' => [
+                    'first' => [
+                        'value' => '尊敬的%s,您明天有新的门诊预约订单待处理!',
+                    ]
+                    ,'keyword1' => [
+                        'value' => '签约失效提醒',
+                    ],
+                    'keyword2' => [
+                        'value' => '%s',
+                    ],
+                    'keyword3' => [
+                        'value' => '就诊人数:%s个,就诊地点:%s医院',
+                    ],
+                    'remark' => [
+                        'value' => '点击进入小程序查看相关详情',
+                    ],
+                ]
+            ],
+        ],
+    ],
+];