预约上门系统对接微信公众号二次开发 实现消息推送功能

下单通知模板ID 和 取消预约通知模板ID
在这里插入图片描述在这里插入图片描述

 /**
     * @author 
     * @DataTime: 2024-07-27 09:51
     * @功能说明:公众号用户端订单支付通知
     */
    public function paySendMsgWeb($order)
    {

        $cap_model = new Coach();

        $cap_id = $order['coach_id'];

        $uniacid = $order['uniacid'];

        $config_model = new SendMsgConfig();

        $config_model->initData($uniacid);

        $x_config = $config_model->dataInfo(['uniacid'=>$uniacid]);

        if (empty($x_config['gzh_appid']) || empty($x_config['order_tmp_id'])) {

            return false;
        }
        //获取楼长openid
        $openid = $cap_model->capOpenid($cap_id, 2);

        $store_name = $cap_model->where(['id' => $cap_id])->value('coach_name');

        $wx_setting = new WxSetting($uniacid);

        $access_token = $wx_setting->getGzhToken();

        $user_model = new User();

        $mobile = $user_model->where(['id' => $order['user_id']])->value('phone');

        $virtual_config_model = new \app\virtual\model\Config();

        $mobile_auth = $virtual_config_model->getVirtualAuth($uniacid);

        $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={$access_token}";

        $data = [
            //用户小程序openid
            'touser' => $openid,
            //公众号appid
            'appid' => $x_config['gzh_appid'],

            "url" => 'https://' . $_SERVER['HTTP_HOST'] . '/h5/?#/technician/pages/order/detail?id=' . $order['id'],
            //公众号模版id
            'template_id' => $x_config['order_tmp_id'],

            'data' => array(

                'first' => array(

                    'value' => $store_name . '您有一笔新的订单',

                    'color' => '#93c47d',
                ),
                //服务名称
                'keyword1' => array(

                    'value' => implode(',', array_column($order['order_goods'], 'goods_name')),

                    'color' => '#93c47d',
                ),
                //下单人
                'keyword2' => array(
                    //内容
                    'value' => $order['address_info']['user_name'],

                    'color' => '#0000ff',
                ),
                'keyword3' => array(
                    //内容
                    'value' => $mobile_auth==false?$order['address_info']['mobile']:'',

                    'color' => '#0000ff',
                ),
                //客户电话
                'keyword4' => array(
                    //内容
                    'value' => $mobile_auth==false?$mobile:'',

                    'color' => '#0000ff',
                ),
                'keyword5' => array(
                    //内容
                    'value' => $order['address_info']['address'],

                    'color' => '#0000ff',
                ),

            )

        ];

        $data = json_encode($data);

        $tmp = [

            'url' => $url,

            'data' => $data,
        ];
        $rest = lbCurlPost($tmp['url'], $tmp['data']);

        $rest = json_decode($rest, true);

        return $rest;

    }

客户正常下单后,手机上会收到公众号推送过来的消息,同时对应的技师人员手机也会收到客户下单的提醒:
在这里插入图片描述
技师端收到客户新下单的消息:
在这里插入图片描述在后台配置公众号通知模版ID信息:
在这里插入图片描述
更多的微信公众号消息模版信息需要进一步二次开发来实现:

在这里插入图片描述
技师端的功能界面效果、个人可以设置接单时间
在这里插入图片描述在这里插入图片描述

/**
     * 获取不接单的技师
     * @param $uniacid
     * @return array
     */
    public function getCancelCoach($uniacid)
    {
        return $this->where(['is_work' => 0, 'uniacid' => $uniacid])->column('id');
    }

在这里插入图片描述

 /**
     * @author chenniang
     * @DataTime: 2021-08-23 23:57
     * @功能说明:获取正在进行中的技师
     */
    public function getWorkingCoach($uniacid,$time=0)
    {

        $time = !empty($time)?$time:time();

        $dis[] = ['uniacid', '=', $uniacid];

        $dis[] = ['pay_type', 'in', [2, 3, 4, 5, 6,8]];

        $dis[] = ['start_time', '<=', $time];

        $dis[] = ['end_time', '>=', $time];

        $order = new Order();

        $data = $order->where($dis)->column('coach_id');

        return $data;
    }
  • 8
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值