findByPk($orderid); if (!$orderModel) { LewaimaiDebug::Log("no this order"); return false; } } $admin_id = $orderModel->admin_id; $templateModel = Template::model()->find("admin_id='$admin_id'"); if (!$templateModel) { LewaimaiDebug::Log("no template"); return false; } if (!$templateModel->is_used) { return false; } if (!$templateModel->confirm_template_id) { return false; } $adminModel = Admin::model()->findByPk($admin_id); if (!$adminModel) { LewaimaiDebug::Log("adminModel is null"); return false; } if ($adminModel->is_weixinauth) { $access_token = LewaimaiWeixinauth::getAuthorizerAccessToken($admin_id); } else { $access_token = LewaimaiUtility::GetAccessToken($admin_id); } if (!$access_token) { LewaimaiDebug::Log("get access_token failed!"); return false; } $openid = LewaimaiUtility::getWeixinOpenid($orderModel->admin_id, $orderModel->lewaimai_customer_id); if (!$openid) { return false; } $shopModel = Config::model()->findByPk($orderModel->shop_id); if (!$shopModel) { LewaimaiDebug::Log("shopModel is null"); return false; } $shopName = $shopModel->shopname; if ($adminModel->order_num_type == 0) { $orderNo = $orderModel->admin_num; } else { $orderNo = $shopModel->order_prefix . $orderModel->shop_num; } $money = $orderModel->total_price; $detail = ''; $fooditemlist = LewaimaiOrderItem::model()->findAll("lewaimai_order_id = " . $orderid); foreach($fooditemlist as $fooditem){ $detail .= $fooditem->food_name . ' ' . $fooditem->quantity . '份 '; } $array = array( 'touser' => $openid, 'template_id' => $templateModel->confirm_template_id, 'url' => LewaimaiUrl::createWeixinUrl("lewaimaiuser/orderinfo", array("order_id"=>$orderid, "adminId"=>$orderModel->admin_id)), 'topcolor' => '#00FF00', 'data' => array( 'first' => array('value'=>"您的订单商家已确认"), 'keyword1' => array('value'=>$orderNo), 'keyword2' => array('value'=>$orderModel->init_date), 'keyword3' => array('value'=>$detail), 'keyword4' => array('value'=>'¥'.$money,"color"=>"#ff0000"), 'remark' => array('value'=>$templateModel->confirm_remark), ), ); $url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='.$access_token; $json = json_encode($array); $ret = LewaimaiHttp::POSTJSON($url, $json); } public static function SendOrderCourierTemplate($orderid, $orderModel = null) { if (!$orderModel) { $orderModel = LewaimaiOrder::model()->findByPk($orderid); if (!$orderModel) { LewaimaiDebug::Log("no this order"); return false; } } $admin_id = $orderModel->admin_id; $templateModel = Template::model()->find("admin_id='$admin_id'"); if (!$templateModel) { LewaimaiDebug::Log("no template"); return false; } if (!$templateModel->is_used) { return false; } if (!$templateModel->courier_template_id) { return false; } $adminModel = Admin::model()->findByPk($admin_id); if (!$adminModel) { LewaimaiDebug::Log("adminModel is null"); return false; } if ($adminModel->is_weixinauth) { $access_token = LewaimaiWeixinauth::getAuthorizerAccessToken($admin_id); } else { $access_token = LewaimaiUtility::GetAccessToken($admin_id); } if (!$access_token) { LewaimaiDebug::Log("get access_token failed!"); return false; } $openid = LewaimaiUtility::getWeixinOpenid($orderModel->admin_id, $orderModel->lewaimai_customer_id); if (!$openid) { return false; } $shopModel = Config::model()->findByPk($orderModel->shop_id); if (!$shopModel) { LewaimaiDebug::Log("shopModel is null"); return false; } $shopName = $shopModel->shopname; if ($adminModel->order_num_type == 0) { $orderNo = $orderModel->admin_num; } else { $orderNo = $shopModel->order_prefix . $orderModel->shop_num; } $money = $orderModel->total_price; $detail = ''; $fooditemlist = LewaimaiOrderItem::model()->findAll("lewaimai_order_id = " . $orderid); foreach($fooditemlist as $fooditem){ $detail .= $fooditem->food_name . ' ' . $fooditem->quantity . '份 '; } if($orderModel->charge_type == 1) { $charge_type = '货到付款'; } elseif($orderModel->charge_type == 2) { $charge_type = '余额支付'; } else { $charge_type = '在线支付'; } $courier_id = $orderModel->courier_id; $courier = Courier::model()->findByPk($courier_id); if (!$courier) { return false; } $array = array( 'touser' => $openid, 'template_id' => $templateModel->courier_template_id, 'url' => LewaimaiUrl::createWeixinUrl("lewaimaiuser/orderinfo", array("order_id"=>$orderid, "adminId"=>$orderModel->admin_id)), 'topcolor' => '#00FF00', 'data' => array( 'first' => array('value'=>"您的订单商家已开始配送"), 'keyword1' => array('value'=>$shopName), 'keyword2' => array('value'=>$orderNo), 'keyword3' => array('value'=>$detail), 'keyword4' => array('value'=>$charge_type), 'keyword5' => array('value'=>$courier->name.",".$courier->phone), 'remark' => array('value'=>$templateModel->courier_remark), ), ); LewaimaiDebug::LogArray($array); $url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='.$access_token; $json = json_encode($array); $ret = LewaimaiHttp::POSTJSON($url, $json); } public static function SendOrderSuccessTemplate($orderid, $orderModel = null) { if (!$orderModel) { $orderModel = LewaimaiOrder::model()->findByPk($orderid); if (!$orderModel) { LewaimaiDebug::Log("no this order"); return false; } } $admin_id = $orderModel->admin_id; $templateModel = Template::model()->find("admin_id='$admin_id'"); if (!$templateModel) { LewaimaiDebug::Log("no template"); return false; } if (!$templateModel->is_used) { return false; } if (!$templateModel->success_template_id) { return false; } $adminModel = Admin::model()->findByPk($admin_id); if (!$adminModel) { LewaimaiDebug::Log("adminModel is null"); return false; } if ($adminModel->is_weixinauth) { $access_token = LewaimaiWeixinauth::getAuthorizerAccessToken($admin_id); } else { $access_token = LewaimaiUtility::GetAccessToken($admin_id); } if (!$access_token) { LewaimaiDebug::Log("get access_token failed!"); return false; } $openid = LewaimaiUtility::getWeixinOpenid($orderModel->admin_id, $orderModel->lewaimai_customer_id); if (!$openid) { return false; } $shopModel = Config::model()->findByPk($orderModel->shop_id); if (!$shopModel) { LewaimaiDebug::Log("shopModel is null"); return false; } $shopName = $shopModel->shopname; if ($adminModel->order_num_type == 0) { $orderNo = $orderModel->admin_num; } else { $orderNo = $shopModel->order_prefix . $orderModel->shop_num; } $array = array( 'touser' => $openid, 'template_id' => $templateModel->success_template_id, 'url' => LewaimaiUrl::createWeixinUrl("lewaimaiuser/orderinfo", array("order_id"=>$orderid, "adminId"=>$orderModel->admin_id)), 'topcolor' => '#00FF00', 'data' => array( 'first' => array('value'=>"您的订单已完成。"), 'keyword1' => array('value'=>$orderNo), 'keyword2' => array('value'=>$orderModel->complete_date), 'remark' => array('value'=>$templateModel->success_remark), ), ); LewaimaiDebug::LogArray($array); $url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='.$access_token; $json = json_encode($array); $ret = LewaimaiHttp::POSTJSON($url, $json); } public static function SendOrderCancelTemplate($orderid, $orderModel = null) { if (!$orderModel) { $orderModel = LewaimaiOrder::model()->findByPk($orderid); if (!$orderModel) { LewaimaiDebug::Log("no this order"); return false; } } $admin_id = $orderModel->admin_id; $templateModel = Template::model()->find("admin_id='$admin_id'"); if (!$templateModel) { LewaimaiDebug::Log("no template"); return false; } if (!$templateModel->is_used) { return false; } if (!$templateModel->cancel_template_id) { return false; } $adminModel = Admin::model()->findByPk($admin_id); if (!$adminModel) { LewaimaiDebug::Log("adminModel is null"); return false; } if ($adminModel->is_weixinauth) { $access_token = LewaimaiWeixinauth::getAuthorizerAccessToken($admin_id); } else { $access_token = LewaimaiUtility::GetAccessToken($admin_id); } if (!$access_token) { LewaimaiDebug::Log("get access_token failed!"); return false; } $openid = LewaimaiUtility::getWeixinOpenid($orderModel->admin_id, $orderModel->lewaimai_customer_id); if (!$openid) { return false; } $shopModel = Config::model()->findByPk($orderModel->shop_id); if (!$shopModel) { LewaimaiDebug::Log("shopModel is null"); return false; } $shopName = $shopModel->shopname; if ($adminModel->order_num_type == 0) { $orderNo = $orderModel->admin_num; } else { $orderNo = $shopModel->order_prefix . $orderModel->shop_num; } $array = array( 'touser' => $openid, 'template_id' => $templateModel->cancel_template_id, 'url' => LewaimaiUrl::createWeixinUrl("lewaimaiuser/orderinfo", array("order_id"=>$orderid, "adminId"=>$orderModel->admin_id)), 'topcolor' => '#00FF00', 'data' => array( 'first' => array('value'=>"您的订单已取消。"), 'keyword1' => array('value'=>$orderNo), 'keyword2' => array('value'=>$orderModel->complete_date), 'remark' => array('value'=>$templateModel->cancel_remark), ), ); LewaimaiDebug::LogArray($array); $url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='.$access_token; $json = json_encode($array); $ret = LewaimaiHttp::POSTJSON($url, $json); } //在商家有新订单的时候,通过乐外卖的微信公众号给商家发模板消息提醒 public static function SendNewOrderTemplate($orderid, $orderModel = NULL, $shopModel = NULL) { if (!$orderModel) { $orderModel = LewaimaiOrder::model()->findByPk($orderid); if (!$orderModel) { LewaimaiDebug::Log("no this order"); return false; } } if (!$shopModel) { $shopModel = Config::model()->findByPk($orderModel->shop_id); if (!$shopModel) { LewaimaiDebug::Log("shopModel is null"); return false; } } //接受微信订单提醒的商家的顾客ID $lewaimai_customer_id = $shopModel->lewaimai_customerid; $lewaimaicustomerModel = LewaimaiCustomer::model()->findByPk($lewaimai_customer_id); if (!$lewaimaicustomerModel) { LewaimaiDebug::Log("no this lewaimaicustomer"); return false; } $openid = $lewaimaicustomerModel->openid; $order_id = $orderModel->id; $admin_id = $orderModel->admin_id; $shop_id = $orderModel->shop_id; $init_date = $orderModel->init_date; $charge_type = $orderModel->charge_type; $lewaimai_customer_id = $orderModel->lewaimai_customer_id; $is_discount = $orderModel->is_discount; //为了防止猜到别人的订单,这里加个密 $strsign = $init_date.$admin_id.$shop_id.$charge_type.$order_id.$lewaimai_customer_id.$is_discount; $md5 = md5($strsign); $shopname = $shopModel->shopname; $detail = ''; $fooditemlist = LewaimaiOrderItem::model()->findAll("lewaimai_order_id = " . $orderid); foreach($fooditemlist as $fooditem){ $detail .= $fooditem->food_name . ' ' . $fooditem->quantity . '份 '; } $arr_charge_type = array('1'=>'货到付款', '2'=>'余额支付(已付款)','3'=>'在线支付'); $order_status = isset($arr_charge_type[$orderModel->charge_type]) ? $arr_charge_type[$orderModel->charge_type] : '未知'; $access_token = LewaimaiUtility::GetLewaimaiAccessToken(); if($access_token) { $array = array( 'touser' => $openid, 'template_id' => LEWAIMAI_NEWORDER_TEMPLATE_ID, 'url'=>LewaimaiUrl::createWeixinUrl("site/orderinfo", array("m"=>$order_id, "a_id"=>$md5)), 'topcolor' => '#00FF00', 'data' => array( 'first' => array('value'=>'您有一笔新的乐外卖订单'), 'keyword1' => array('value'=>$shopname), 'keyword2' => array('value'=>$detail), 'keyword3' => array('value'=>$orderModel->init_date), 'keyword4' => array('value'=>$orderModel->total_price), 'keyword5' => array('value'=>$order_status), 'remark' => array('value'=>"点击查看订单详情 ↓↓↓") ), ); $url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='.$access_token; $json = json_encode($array); LewaimaiHttp::POSTJSON($url, $json); } } //发送取消订单模板消息通知商家 public static function SendCancelOrderTemplate($orderid, $orderModel = NULL, $shopModel = NULL) { if (!$orderModel) { $orderModel = LewaimaiOrder::model()->findByPk($orderid); if (!$orderModel) { LewaimaiDebug::Log("no this order"); return false; } } if (!$shopModel) { $shopModel = Config::model()->findByPk($orderModel->shop_id); if (!$shopModel) { LewaimaiDebug::Log("shopModel is null"); return false; } } //接受微信订单提醒的商家的顾客ID $lewaimai_customer_id = $shopModel->lewaimai_customerid; $lewaimaicustomerModel = LewaimaiCustomer::model()->findByPk($lewaimai_customer_id); if (!$lewaimaicustomerModel) { LewaimaiDebug::Log("no this lewaimaicustomer"); return false; } $openid = $lewaimaicustomerModel->openid; $order_id = $orderModel->id; $admin_id = $orderModel->admin_id; $shop_id = $orderModel->shop_id; $init_date = $orderModel->init_date; $charge_type = $orderModel->charge_type; $lewaimai_customer_id = $orderModel->lewaimai_customer_id; $is_discount = $orderModel->is_discount; //为了防止猜到别人的订单,这里加个密 $strsign = $init_date.$admin_id.$shop_id.$charge_type.$order_id.$lewaimai_customer_id.$is_discount; $md5 = md5($strsign); $shopname = $shopModel->shopname; $arr_charge_type = array('1'=>'货到付款', '2'=>'余额支付(已付款)','3'=>'在线支付'); $order_status = isset($arr_charge_type[$orderModel->charge_type]) ? $arr_charge_type[$orderModel->charge_type] : '未知'; $adminModel = Admin::model()->findByPk($admin_id); if ($adminModel->order_num_type == 0) { $orderNo = $orderModel->admin_num; } else { $orderNo = $shopModel->order_prefix . $orderModel->shop_num; } $access_token = LewaimaiUtility::GetLewaimaiAccessToken(); if($access_token) { $array = array( 'touser' => $openid, 'template_id' => LEWAIMAI_CANCELORDER_TEMPLATE_ID, 'url'=>LewaimaiUrl::createWeixinUrl("site/orderinfo", array("m"=>$order_id, "a_id"=>$md5)), 'topcolor' => '#FF0000', 'data' => array( 'first' => array('value'=>'您有一笔乐外卖订单被用户取消。'), 'OrderSn' => array('value'=>$orderNo), 'OrderStatus' => array('value'=>'已取消',"color"=>"#FF0000"), 'remark' => array('value'=>"点击查看订单详情 ↓↓↓") ), ); $url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='.$access_token; $json = json_encode($array); LewaimaiHttp::POSTJSON($url, $json); } } //这个是用来发送顾客进行积分兑换的时候,给商家发送微信消息提醒 public static function SendPointPrizeOrderTemplate($orderid, $orderModel, $pointsetModel, $remark) { $lewaimai_customer_id = $pointsetModel->lewaimai_customerid; $lewaimaicustomerModel = LewaimaiCustomer::model()->findByPk($lewaimai_customer_id); if (!$lewaimaicustomerModel) { LewaimaiDebug::Log("no this lewaimaicustomer"); return false; } $openid = $lewaimaicustomerModel->openid; $lewaimaiordercustomerModel = LewaimaiOrderCustomer::model()->find("admin_id = " . $orderModel->admin_id . " AND lewaimai_customer_id = " . $orderModel->lewaimai_customer_id); if ($lewaimaiordercustomerModel) { $new_point = $lewaimaiordercustomerModel->point; } else { $new_point = '未知'; } $admin_id = $orderModel->admin_id; $init_date = strtotime($orderModel->init_time); $strsign = $admin_id.$orderid.$init_date.$lewaimai_customer_id; $md5 = md5($strsign); $access_token = LewaimaiUtility::GetLewaimaiAccessToken(); if($access_token) { $array = array( 'touser' => $openid, 'template_id' => LEWAIMAI_POINTPRIZEORDER_TEMPLATE_ID, 'url'=>LewaimaiUrl::createWeixinUrl("site/pointorderinfo", array("m"=>$orderid, "a_id"=>$md5)), 'topcolor' => '#00FF00', 'data' => array( 'first' => array('value'=>'您有顾客进行积分兑换奖品啦!'), 'FieldName' => array('value'=>'兑换日期'), 'Account' => array('value'=>$orderModel->init_time), 'change' => array('value'=>'消费积分'), 'change' => array('value'=>$orderModel->total_point), 'CreditTotal' => array('value'=>$new_point), 'Remark' => array('value'=>$remark), ), ); $url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='.$access_token; $json = json_encode($array); LewaimaiHttp::POSTJSON($url, $json); } } //跑腿订单的模板消息提醒 public static function SendErrandOrderTemplate($orderid, $type="ybq") { $statusName = array( 'ybq' => '已被抢', 'ycs' => '已超时', 'yqh' => '已取货', 'ysb' => '已失败', 'ycg' => '已成功', ); if(!isset($statusName[$type])){ return ; } $errandsModel = ErrandsOrder::model()->findByPk($orderid); if(!$errandsModel){ Yii::log("no this errandorder"); return ; } $adminId = $errandsModel->admin_id; $adminModel = Admin::model()->findByPk($adminId); if (!$adminModel) { Yii::log("adminModel is null"); return ; } $lewaimaicustomerModel = LewaimaiCustomer::model()->findByPk($errandsModel->lewaimai_customer_id); if (!$lewaimaicustomerModel) { Yii::log("no this lewaimaicustomermodel"); return ; } if ($adminModel->wx_type == 3) { //这种情况使用商家自己的微信公众号来推送模板消息 $openid = LewaimaiUtility::getWeixinOpenid($adminId, $errandsModel->lewaimai_customer_id); if (!$openid) { Yii::log("not this openid"); return false; } $tmp_admin_id = $adminId; $templateModel = Template::model()->find("admin_id = " . $adminId); if (!$templateModel) { Yii::log("no templateModel!"); return ; } $template_id = $templateModel->paotui_template_id; if ($adminModel->is_weixinauth) { $access_token = LewaimaiWeixinauth::getAuthorizerAccessToken($adminId); } else { $access_token = LewaimaiUtility::GetAccessToken($adminId); } } else { $openid = $lewaimaicustomerModel->openid; $tmp_admin_id = 19; $template_id = LEWAIMAI_ERRANDORDER_TEMPLATE_ID; $access_token = LewaimaiUtility::GetLewaimaiAccessToken(); } if($access_token) { $init_time = $errandsModel->init_time; $lewaimai_customer_id = $errandsModel->lewaimai_customer_id; $strsign = $orderid.$init_time.$lewaimai_customer_id; $md5 = md5($strsign); //计算订单编号 $orderNo = $errandsModel->trade_no; $remark = ''; if($type == 'ybq' || $type == 'yqh') { //这两种状态要去先获取当前的配送员信息 $url = constant("LEKUAISONG_ORDERINFO"); $post = LewaimaiAboutLekuaisong::CreateErrandRequest(); $post['trade_no'] = $errandsModel->trade_no; $post_json = json_encode($post); $post_array['param'] = $post_json; $result = LewaimaiHttp::POST($url, $post_array); $res = json_decode($result, true); $courier_name = isset($res['data']['d_name']) ? $res['data']['d_name'] : ''; $courier_phone = isset($res['data']['d_phone']) ? $res['data']['d_phone'] : ''; $courier_lat = isset($res['data']['d_lat']) ? $res['data']['d_lat'] : ''; $courier_lng = isset($res['data']['d_lng']) ? $res['data']['d_lng'] : ''; $customer_lat = $lewaimaicustomerModel -> coordinate_x; $customer_lng = $lewaimaicustomerModel -> coordinate_y; if($courier_name) { $remark .= '快送骑士姓名'.$courier_name.','; } if($courier_phone) { $remark .= '电话'.$courier_phone.','; } if($courier_lat > 0 and $courier_lng > 0 and $customer_lat > 0 and $customer_lng > 0) { $range = LewaimaiUtility::GetDistance($customer_lat, $customer_lng, $courier_lat, $courier_lng); if ($range < 1) { $remark .= '距离您'. ($range * 1000) . " 米 点击可查看订单详情"; } elseif ($range >= 100000) { } else { $range = sprintf("%.1f", $range); $remark .= '距离您'. $range*1 . "千米 点击可查看订单详情"; } } } if($remark == '') { $remark = ' 点击可查看订单详情'; } $array = array( 'touser' => $openid, 'template_id' => $template_id, 'url'=>LewaimaiUrl::createWeixinUrl("site/errandsorderinfo", array("m"=>$orderid, "a_id"=>$md5)), 'topcolor' => '#00FF00', 'data' => array( 'first' => array('value'=>'您有一笔乐外卖跑腿订单'.$statusName[$type]), 'OrderSn' => array('value'=>$orderNo), 'OrderStatus' => array('value'=>$statusName[$type]), 'remark' => array('value'=>$remark) ), ); $url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='.$access_token; $json = json_encode($array); $res = LewaimaiHttp::POSTJSON($url, $json); }else{ Yii::log('errandserroraccess_token:'.$access_token); } } //发送乐快送模式接单(代购模式)的模板消息 public static function SendLekuaisongTemplate($orderid, $type="ybq", $trade_no="") { $statusName = array( 'ybq' => '已被抢', 'ycs' => '已超时', 'yqh' => '已取货', 'ysb' => '已失败', 'ycg' => '已成功', ); if(!isset($statusName[$type])){ return; } $orderModel = LewaimaiOrder::model()->findByPk($orderid); if(!$orderModel){ return; } $lewaimaicustomerModel = LewaimaiCustomer::model()->findByPk($orderModel->lewaimai_customer_id); if(!$lewaimaicustomerModel){ return; } $tmp_admin_id = 19; $openid = $lewaimaicustomerModel->openid; $init_time = $orderModel->init_date; $lewaimai_customer_id = $orderModel->lewaimai_customer_id; $strsign = $orderid.$init_time.$lewaimai_customer_id; $md5 = md5($strsign); $access_token = LewaimaiWeixinauth::getAuthorizerAccessToken($tmp_admin_id); if($access_token) { //计算订单编号 $orderNo = $trade_no; $remark = ''; if($type == 'ybq' || $type == 'yqh'){ $url = constant("LEKUAISONG_ORDERINFO"); $post = LewaimaiAboutLekuaisong::CreateRequest(); $post['trade_no'] = $trade_no; $post_json = json_encode($post); $post_array['param'] = $post_json; $result = LewaimaiHttp::POST($url, $post_array); $res = json_decode($result, true); $courier_name = isset($res['data']['d_name']) ? $res['data']['d_name'] : ''; $courier_phone = isset($res['data']['d_phone']) ? $res['data']['d_phone'] : ''; $courier_lat = isset($res['data']['d_lat']) ? $res['data']['d_lat'] : ''; $courier_lng = isset($res['data']['d_lng']) ? $res['data']['d_lng'] : ''; $customer_lat = $lewaimaicustomerModel -> coordinate_x; $customer_lng = $lewaimaicustomerModel -> coordinate_y; if($courier_name) { $remark .= '快送骑士姓名'.$courier_name.','; } if($courier_phone) { $remark .= '电话'.$courier_phone.','; } if($courier_lat > 0 and $courier_lng > 0 and $customer_lat > 0 and $customer_lng > 0) { $range = LewaimaiUtility::GetDistance($customer_lat, $customer_lng, $courier_lat, $courier_lng); if ($range < 1) { $remark .= '距离您'. ($range * 1000) . " 米 点击可查看订单详情"; } elseif ($range >= 100000) { } else { $range = sprintf("%.1f", $range); $remark .= '距离您'. $range*1 . "千米 点击可查看订单详情"; } } } if($remark == '') { $remark = ' 点击可查看订单详情'; } $array = array( 'touser' => $openid, 'template_id' => LEWAIMAI_ERRANDORDER_TEMPLATE_ID, 'url'=>LewaimaiUrl::createWeixinUrl("site/lekuaisongorderinfo", array("m"=>$orderid, "a_id"=>$md5)), 'topcolor' => '#00FF00', 'data' => array( 'first' => array('value'=>'您有一笔乐外卖订单'.$statusName[$type]), 'OrderSn' => array('value'=>$orderNo), 'OrderStatus' => array('value'=>$statusName[$type]), 'remark' => array('value'=>$remark) ), ); $url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='.$access_token; $json = json_encode($array); $res = LewaimaiHttp::POSTJSON($url, $json); }else{ Yii::log('lekuaisongapierroraccess_token:'.$access_token); } } }