<?php
namespace app\common\listener\serviceorder;
use app\common\model\dyqc\ManystoreShop;
use app\common\model\school\classes\Teacher;
use app\common\model\school\Message;
use app\common\model\school\MessageConfig;
use app\common\model\User;

class OrderHook
{



    // 订单创建成功后
    public function classesServiceorderCreateAfter(&$params)
    {
        ['serviceorder' => $serverorder,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;

        $detail = $serverorder->detail;
        $user = User::where("id",$serverorder["user_id"])->find();
        $teacher_user = \app\common\model\User::get($detail["user_id"]);
        $teacher = Teacher::get($detail["teacher_id"]);
        $shop = ManystoreShop::get($serverorder["shop_id"]);
        //记录订单日志

        $desc = "课程{$detail["title"]}订单已申请售后，等待机构处理";

        $title = "课程订单已提交售后";
        $mini_type = "aftercare";
        $to_type="user";
        $to_id = $serverorder["user_id"];
        $status ="classes";
        $platform="user";
        $oper_id=0;
        $oper_type="system";
        $params=[
            "event"=>"classes_serviceorder_create_after",
            "order_id"=>$serverorder["id"],
            "classes_order_id"=>$serverorder["classes_order_id"],
            "order_no"=>$serverorder["order_no"],
        ];



        $param = [
            "name" => $shop['name'],
            "realname"=> $user["realname"],
            "nickname"=> $user["nickname"],
            "mobile"=> $user["mobile"],


            "title" => $detail['title'],
            "teacher_name"=> $teacher["name"] ?? "课程负责人",
            "teacher_realname"=> $teacher_user["realname"] ?? "课程负责人真实姓名",
            "teacher_nickname"=> $teacher_user["nickname"] ?? "课程负责人昵称",
            "teacher_mobile"=> $teacher_user["mobile"] ?? "课程负责人电话",
            "address"=>$detail["address"]."(".$detail["address_detail"].")",
            "price" => $detail["price"],
            "start_time" => date("Y-m-d H:i",$detail["start_time"]), //格式化日期格式 $order["start_time"], //格式化日期格式
            "end_time" =>   date("Y-m-d H:i",$detail["end_time"]),
            "reason" => $serverorder['reason'],
            "reject_reason" => $serverorder['reject_reason'],
            "order_no" => $serverorder['order_no'],
            "tbc_price" => $serverorder['tbc_price'],
            "c_price" => $serverorder['c_price'],
            "real_refundprice" => $serverorder['real_refundprice'],
            "sub_refundprice" => $serverorder['sub_refundprice'],
        ];


        //发给用户
        (new MessageConfig)
            ->setTemplate($params["event"]."_user")
            ->setTemplateData($param)
            ->setToUid($to_id)
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();
        //发给机构负责人
        (new MessageConfig)
            ->setTemplate($params["event"]."_shop")
            ->setTemplateData($param)
            ->setToUid($shop["user_id"])
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();
        //发给机构老师
        (new MessageConfig)
            ->setTemplate($params["event"]."_teacher")
            ->setTemplateData($param)
            ->setToUid($teacher["user_id"])
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();

    }





    // 订单取消成功后
    public function classesServiceorderCancelAfter(&$params)
    {
        ['serviceorder' => $serviceorder,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;

        $detail = $serviceorder->detail;
        $user = User::where("id",$serviceorder["user_id"])->find();
        $teacher_user = \app\common\model\User::get($detail["user_id"]);
        $teacher = Teacher::get($detail["teacher_id"]);
        $shop = ManystoreShop::get($serviceorder["shop_id"]);
        //记录订单日志

        $desc = "课程{$detail["title"]}订单已取消售后，订单恢复原状态";

        $title = "课程订单已取消售后";
        $mini_type = "aftercare";
        $to_type="user";
        $to_id = $serviceorder["user_id"];
        $status ="classes";
        $platform="user";
        $oper_id=0;
        $oper_type="system";
        $params=[
            "event"=>"classes_serviceorder_cancel_after",
            "order_id"=>$serviceorder["id"],
            "classes_order_id"=>$serviceorder["classes_order_id"],
            "order_no"=>$serviceorder["order_no"],
        ];



        $param = [
            "name" => $shop['name'],
            "realname"=> $user["realname"],
            "nickname"=> $user["nickname"],
            "mobile"=> $user["mobile"],


            "title" => $detail['title'],
            "teacher_name"=> $teacher["name"] ?? "课程负责人",
            "teacher_realname"=> $teacher_user["realname"] ?? "课程负责人真实姓名",
            "teacher_nickname"=> $teacher_user["nickname"] ?? "课程负责人昵称",
            "teacher_mobile"=> $teacher_user["mobile"] ?? "课程负责人电话",
            "address"=>$detail["address"]."(".$detail["address_detail"].")",
            "price" => $detail["price"],
            "start_time" => date("Y-m-d H:i",$detail["start_time"]), //格式化日期格式 $order["start_time"], //格式化日期格式
            "end_time" =>   date("Y-m-d H:i",$detail["end_time"]),
            "reason" => $serviceorder['reason'],
            "reject_reason" => $serviceorder['reject_reason'],
            "order_no" => $serviceorder['order_no'],
            "tbc_price" => $serviceorder['tbc_price'],
            "c_price" => $serviceorder['c_price'],
            "real_refundprice" => $serviceorder['real_refundprice'],
            "sub_refundprice" => $serviceorder['sub_refundprice'],
        ];


        //发给用户
        (new MessageConfig)
            ->setTemplate($params["event"]."_user")
            ->setTemplateData($param)
            ->setToUid($to_id)
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();
        //发给机构负责人
        (new MessageConfig)
            ->setTemplate($params["event"]."_shop")
            ->setTemplateData($param)
            ->setToUid($shop["user_id"])
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();
        //发给机构老师
        (new MessageConfig)
            ->setTemplate($params["event"]."_teacher")
            ->setTemplateData($param)
            ->setToUid($teacher["user_id"])
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();


    }




    // 课程订单机构同意售后
    public function classesServiceorderShopConfirmAfter(&$params)
    {
        ['serviceorder' => $serviceorder,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;

        $detail = $serviceorder->detail;
        $user = User::where("id",$serviceorder["user_id"])->find();
        $teacher_user = \app\common\model\User::get($detail["user_id"]);
        $teacher = Teacher::get($detail["teacher_id"]);
        $shop = ManystoreShop::get($serviceorder["shop_id"]);
        //记录订单日志

        $desc = "课程{$detail["title"]}订单机构已同意售后，待您确认售后金额是否同意";

        $title = "课程订单机构同意售后";
        $mini_type = "aftercare";
        $to_type="user";
        $to_id = $serviceorder["user_id"];
        $status ="classes";
        $platform="user";
        $oper_id=0;
        $oper_type="system";
        $params=[
            "event"=>"classes_serviceorder_shop_confirm_after",
            "order_id"=>$serviceorder["id"],
            "classes_order_id"=>$serviceorder["classes_order_id"],
            "order_no"=>$serviceorder["order_no"],
        ];


        $param = [
            "name" => $shop['name'],
            "realname"=> $user["realname"],
            "nickname"=> $user["nickname"],
            "mobile"=> $user["mobile"],


            "title" => $detail['title'],
            "teacher_name"=> $teacher["name"] ?? "课程负责人",
            "teacher_realname"=> $teacher_user["realname"] ?? "课程负责人真实姓名",
            "teacher_nickname"=> $teacher_user["nickname"] ?? "课程负责人昵称",
            "teacher_mobile"=> $teacher_user["mobile"] ?? "课程负责人电话",
            "address"=>$detail["address"]."(".$detail["address_detail"].")",
            "price" => $detail["price"],
            "start_time" => date("Y-m-d H:i",$detail["start_time"]), //格式化日期格式 $order["start_time"], //格式化日期格式
            "end_time" =>   date("Y-m-d H:i",$detail["end_time"]),
            "reason" => $serviceorder['reason'],
            "reject_reason" => $serviceorder['reject_reason'],
            "order_no" => $serviceorder['order_no'],
            "tbc_price" => $serviceorder['tbc_price'],
            "c_price" => $serviceorder['c_price'],
            "real_refundprice" => $serviceorder['real_refundprice'],
            "sub_refundprice" => $serviceorder['sub_refundprice'],
        ];


        //发给用户
        (new MessageConfig)
            ->setTemplate($params["event"]."_user")
            ->setTemplateData($param)
            ->setToUid($to_id)
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();
        //发给机构负责人
        (new MessageConfig)
            ->setTemplate($params["event"]."_shop")
            ->setTemplateData($param)
            ->setToUid($shop["user_id"])
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();
        //发给机构老师
        (new MessageConfig)
            ->setTemplate($params["event"]."_teacher")
            ->setTemplateData($param)
            ->setToUid($teacher["user_id"])
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();


    }



        // 课程订单机构售后驳回
    public function classesServiceorderShopRejectAfter(&$params)
    {
        ['serviceorder' => $serviceorder,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;

        $detail = $serviceorder->detail;
        $user = User::where("id",$serviceorder["user_id"])->find();
        $teacher_user = \app\common\model\User::get($detail["user_id"]);
        $teacher = Teacher::get($detail["teacher_id"]);
        $shop = ManystoreShop::get($serviceorder["shop_id"]);
        //记录订单日志

        $desc = "课程{$detail["title"]}订单机构售后已驳回，原因：{$serviceorder["reject_reason"]}";

        $title = "课程订单机构售后驳回";
        $mini_type = "aftercare";
        $to_type="user";
        $to_id = $serviceorder["user_id"];
        $status ="classes";
        $platform="user";
        $oper_id=0;
        $oper_type="system";
        $params=[
            "event"=>"classes_serviceorder_shop_reject_after",
            "order_id"=>$serviceorder["id"],
            "classes_order_id"=>$serviceorder["classes_order_id"],
            "order_no"=>$serviceorder["order_no"],
        ];




        $param = [
            "name" => $shop['name'],
            "realname"=> $user["realname"],
            "nickname"=> $user["nickname"],
            "mobile"=> $user["mobile"],


            "title" => $detail['title'],
            "teacher_name"=> $teacher["name"] ?? "课程负责人",
            "teacher_realname"=> $teacher_user["realname"] ?? "课程负责人真实姓名",
            "teacher_nickname"=> $teacher_user["nickname"] ?? "课程负责人昵称",
            "teacher_mobile"=> $teacher_user["mobile"] ?? "课程负责人电话",
            "address"=>$detail["address"]."(".$detail["address_detail"].")",
            "price" => $detail["price"],
            "start_time" => date("Y-m-d H:i",$detail["start_time"]), //格式化日期格式 $order["start_time"], //格式化日期格式
            "end_time" =>   date("Y-m-d H:i",$detail["end_time"]),
            "reason" => $serviceorder['reason'],
            "reject_reason" => $serviceorder['reject_reason'],
            "order_no" => $serviceorder['order_no'],
            "tbc_price" => $serviceorder['tbc_price'],
            "c_price" => $serviceorder['c_price'],
            "real_refundprice" => $serviceorder['real_refundprice'],
            "sub_refundprice" => $serviceorder['sub_refundprice'],
        ];


        //发给用户
        (new MessageConfig)
            ->setTemplate($params["event"]."_user")
            ->setTemplateData($param)
            ->setToUid($to_id)
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();
        //发给机构负责人
        (new MessageConfig)
            ->setTemplate($params["event"]."_shop")
            ->setTemplateData($param)
            ->setToUid($shop["user_id"])
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();
        //发给机构老师
        (new MessageConfig)
            ->setTemplate($params["event"]."_teacher")
            ->setTemplateData($param)
            ->setToUid($teacher["user_id"])
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();


    }





    // 课程订单用户同意售后
    public function classesServiceorderUserConfirmAfter(&$params)
    {
        ['serviceorder' => $serviceorder,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;

        $detail = $serviceorder->detail;
        $user = User::where("id",$serviceorder["user_id"])->find();
        $teacher_user = \app\common\model\User::get($detail["user_id"]);
        $teacher = Teacher::get($detail["teacher_id"]);
        $shop = ManystoreShop::get($serviceorder["shop_id"]);
        //记录订单日志

        $desc = "课程{$detail["title"]}订单用户已同意售后，系统正在结算资金中，请耐心等待";

        $title = "课程订单用户售后已确认";
        $mini_type = "aftercare";
        $to_type="user";
        $to_id = $serviceorder["user_id"];
        $status ="classes";
        $platform="user";
        $oper_id=0;
        $oper_type="system";
        $params=[
            "event"=>"classes_serviceorder_user_confirm_after",
            "order_id"=>$serviceorder["id"],
            "classes_order_id"=>$serviceorder["classes_order_id"],
            "order_no"=>$serviceorder["order_no"],
        ];



        $param = [
            "name" => $shop['name'],
            "realname"=> $user["realname"],
            "nickname"=> $user["nickname"],
            "mobile"=> $user["mobile"],


            "title" => $detail['title'],
            "teacher_name"=> $teacher["name"] ?? "课程负责人",
            "teacher_realname"=> $teacher_user["realname"] ?? "课程负责人真实姓名",
            "teacher_nickname"=> $teacher_user["nickname"] ?? "课程负责人昵称",
            "teacher_mobile"=> $teacher_user["mobile"] ?? "课程负责人电话",
            "address"=>$detail["address"]."(".$detail["address_detail"].")",
            "price" => $detail["price"],
            "start_time" => date("Y-m-d H:i",$detail["start_time"]), //格式化日期格式 $order["start_time"], //格式化日期格式
            "end_time" =>   date("Y-m-d H:i",$detail["end_time"]),
            "reason" => $serviceorder['reason'],
            "reject_reason" => $serviceorder['reject_reason'],
            "order_no" => $serviceorder['order_no'],
            "tbc_price" => $serviceorder['tbc_price'],
            "c_price" => $serviceorder['c_price'],
            "real_refundprice" => $serviceorder['real_refundprice'],
            "sub_refundprice" => $serviceorder['sub_refundprice'],
        ];


        //发给用户
        (new MessageConfig)
            ->setTemplate($params["event"]."_user")
            ->setTemplateData($param)
            ->setToUid($to_id)
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();
        //发给机构负责人
        (new MessageConfig)
            ->setTemplate($params["event"]."_shop")
            ->setTemplateData($param)
            ->setToUid($shop["user_id"])
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();
        //发给机构老师
        (new MessageConfig)
            ->setTemplate($params["event"]."_teacher")
            ->setTemplateData($param)
            ->setToUid($teacher["user_id"])
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();

    }



        // 课程订单用户售后驳回
    public function classesServiceorderUserRejectAfter(&$params)
    {
        ['serviceorder' => $serviceorder,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;

        $detail = $serviceorder->detail;
        $user = User::where("id",$serviceorder["user_id"])->find();
        $teacher_user = \app\common\model\User::get($detail["user_id"]);
        $teacher = Teacher::get($detail["teacher_id"]);
        $shop = ManystoreShop::get($serviceorder["shop_id"]);
        //记录订单日志

        $desc = "课程{$detail["title"]}订单用户售后已驳回，原因：{$serviceorder["reject_reason"]}";

        $title = "课程订单用户售后驳回";
        $mini_type = "aftercare";
        $to_type="user";
        $to_id = $serviceorder["user_id"];
        $status ="classes";
        $platform="user";
        $oper_id=0;
        $oper_type="system";
        $params=[
            "event"=>"classes_serviceorder_user_reject_after",
            "order_id"=>$serviceorder["id"],
            "classes_order_id"=>$serviceorder["classes_order_id"],
            "order_no"=>$serviceorder["order_no"],
        ];




        $param = [
            "name" => $shop['name'],
            "realname"=> $user["realname"],
            "nickname"=> $user["nickname"],
            "mobile"=> $user["mobile"],


            "title" => $detail['title'],
            "teacher_name"=> $teacher["name"] ?? "课程负责人",
            "teacher_realname"=> $teacher_user["realname"] ?? "课程负责人真实姓名",
            "teacher_nickname"=> $teacher_user["nickname"] ?? "课程负责人昵称",
            "teacher_mobile"=> $teacher_user["mobile"] ?? "课程负责人电话",
            "address"=>$detail["address"]."(".$detail["address_detail"].")",
            "price" => $detail["price"],
            "start_time" => date("Y-m-d H:i",$detail["start_time"]), //格式化日期格式 $order["start_time"], //格式化日期格式
            "end_time" =>   date("Y-m-d H:i",$detail["end_time"]),
            "reason" => $serviceorder['reason'],
            "reject_reason" => $serviceorder['reject_reason'],
            "order_no" => $serviceorder['order_no'],
            "tbc_price" => $serviceorder['tbc_price'],
            "c_price" => $serviceorder['c_price'],
            "real_refundprice" => $serviceorder['real_refundprice'],
            "sub_refundprice" => $serviceorder['sub_refundprice'],
        ];


        //发给用户
        (new MessageConfig)
            ->setTemplate($params["event"]."_user")
            ->setTemplateData($param)
            ->setToUid($to_id)
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();
        //发给机构负责人
        (new MessageConfig)
            ->setTemplate($params["event"]."_shop")
            ->setTemplateData($param)
            ->setToUid($shop["user_id"])
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();
        //发给机构老师
        (new MessageConfig)
            ->setTemplate($params["event"]."_teacher")
            ->setTemplateData($param)
            ->setToUid($teacher["user_id"])
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();

    }




    // 课程订单用户同意售后
    public function classesServiceorderSystemConfirmAfter(&$params)
    {
        ['serviceorder' => $serviceorder,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;

        $detail = $serviceorder->detail;
        $user = User::where("id",$serviceorder["user_id"])->find();
        $teacher_user = \app\common\model\User::get($detail["user_id"]);
        $teacher = Teacher::get($detail["teacher_id"]);
        $shop = ManystoreShop::get($serviceorder["shop_id"]);
        //记录订单日志

        $desc = "课程{$detail["title"]}订单售后金额已原路退回到您的账户中{$serviceorder["real_refundprice"]}元，请注意查看";

        $title = "课程订单售后金额已退回";
        $mini_type = "aftercare";
        $to_type="user";
        $to_id = $serviceorder["user_id"];
        $status ="classes";
        $platform="user";
        $oper_id=0;
        $oper_type="system";
        $params=[
            "event"=>"classes_serviceorder_system_confirm_after",
            "order_id"=>$serviceorder["id"],
            "classes_order_id"=>$serviceorder["classes_order_id"],
            "order_no"=>$serviceorder["order_no"],
        ];


        $param = [
            "name" => $shop['name'],
            "realname"=> $user["realname"],
            "nickname"=> $user["nickname"],
            "mobile"=> $user["mobile"],


            "title" => $detail['title'],
            "teacher_name"=> $teacher["name"] ?? "课程负责人",
            "teacher_realname"=> $teacher_user["realname"] ?? "课程负责人真实姓名",
            "teacher_nickname"=> $teacher_user["nickname"] ?? "课程负责人昵称",
            "teacher_mobile"=> $teacher_user["mobile"] ?? "课程负责人电话",
            "address"=>$detail["address"]."(".$detail["address_detail"].")",
            "price" => $detail["price"],
            "start_time" => date("Y-m-d H:i",$detail["start_time"]), //格式化日期格式 $order["start_time"], //格式化日期格式
            "end_time" =>   date("Y-m-d H:i",$detail["end_time"]),
            "reason" => $serviceorder['reason'],
            "reject_reason" => $serviceorder['reject_reason'],
            "order_no" => $serviceorder['order_no'],
            "tbc_price" => $serviceorder['tbc_price'],
            "c_price" => $serviceorder['c_price'],
            "real_refundprice" => $serviceorder['real_refundprice'],
            "sub_refundprice" => $serviceorder['sub_refundprice'],
        ];


        //发给用户
        (new MessageConfig)
            ->setTemplate($params["event"]."_user")
            ->setTemplateData($param)
            ->setToUid($to_id)
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();
        //发给机构负责人
        (new MessageConfig)
            ->setTemplate($params["event"]."_shop")
            ->setTemplateData($param)
            ->setToUid($shop["user_id"])
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();
        //发给机构老师
        (new MessageConfig)
            ->setTemplate($params["event"]."_teacher")
            ->setTemplateData($param)
            ->setToUid($teacher["user_id"])
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();


    }



        // 课程订单用户售后驳回
    public function classesServiceorderSystemRejectAfter(&$params)
    {
        ['serviceorder' => $serviceorder,"user_id"=>$user_id,"oper_type"=>$oper_type,"oper_id"=>$oper_id] = $params;

        $detail = $serviceorder->detail;
        $user = User::where("id",$serviceorder["user_id"])->find();
        $teacher_user = \app\common\model\User::get($detail["user_id"]);
        $teacher = Teacher::get($detail["teacher_id"]);
        $shop = ManystoreShop::get($serviceorder["shop_id"]);
        //记录订单日志

        $desc = "课程{$detail["title"]}订单售后记录异常，系统已强制终止售后，原因：{$serviceorder["reject_reason"]}";

        $title = "课程订单异常系统终止售后";
        $mini_type = "aftercare";
        $to_type="user";
        $to_id = $serviceorder["user_id"];
        $status ="classes";
        $platform="user";
        $oper_id=0;
        $oper_type="system";
        $params=[
            "event"=>"classes_serviceorder_system_reject_after",
            "order_id"=>$serviceorder["id"],
            "classes_order_id"=>$serviceorder["classes_order_id"],
            "order_no"=>$serviceorder["order_no"],
        ];



        $param = [
            "name" => $shop['name'],
            "realname"=> $user["realname"],
            "nickname"=> $user["nickname"],
            "mobile"=> $user["mobile"],


            "title" => $detail['title'],
            "teacher_name"=> $teacher["name"] ?? "课程负责人",
            "teacher_realname"=> $teacher_user["realname"] ?? "课程负责人真实姓名",
            "teacher_nickname"=> $teacher_user["nickname"] ?? "课程负责人昵称",
            "teacher_mobile"=> $teacher_user["mobile"] ?? "课程负责人电话",
            "address"=>$detail["address"]."(".$detail["address_detail"].")",
            "price" => $detail["price"],
            "start_time" => date("Y-m-d H:i",$detail["start_time"]), //格式化日期格式 $order["start_time"], //格式化日期格式
            "end_time" =>   date("Y-m-d H:i",$detail["end_time"]),
            "reason" => $serviceorder['reason'],
            "reject_reason" => $serviceorder['reject_reason'],
            "order_no" => $serviceorder['order_no'],
            "tbc_price" => $serviceorder['tbc_price'],
            "c_price" => $serviceorder['c_price'],
            "real_refundprice" => $serviceorder['real_refundprice'],
            "sub_refundprice" => $serviceorder['sub_refundprice'],
        ];


        //发给用户
        (new MessageConfig)
            ->setTemplate($params["event"]."_user")
            ->setTemplateData($param)
            ->setToUid($to_id)
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();
        //发给机构负责人
        (new MessageConfig)
            ->setTemplate($params["event"]."_shop")
            ->setTemplateData($param)
            ->setToUid($shop["user_id"])
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();
        //发给机构老师
        (new MessageConfig)
            ->setTemplate($params["event"]."_teacher")
            ->setTemplateData($param)
            ->setToUid($teacher["user_id"])
            ->setMessageStatus($status)
            ->setMessageMiniType($mini_type)
            ->setMessageParams($params)
            ->sendMessage();


    }


}