下单通知模板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;
}