Esempio n. 1
0
 public function sendCustomMsg()
 {
     $companyInfo = $this->getCompanyInfo();
     $options = array('appid' => $companyInfo['weixin_AppId'], 'appsecret' => $companyInfo['weixin_AppSecret'], 'partnerid' => $companyInfo['weixin_PartnerID'], 'partnerkey' => $companyInfo['weixin_PartnerKey'], 'paysignkey' => $companyInfo['weixin_PaySignKey']);
     $data = array('touser' => 'ooKmYt8VGB2V3l3ZXolpFbTukE58', 'template_id' => '9vrZ54E2usz08SVYjManqdUlHlI--x3eMqWdXKBMwpI', 'url' => 'http://www.icalex.com', 'topcolor' => '#000000', 'data' => array('first' => array('value' => "您好,你的订单已成功提交", "color" => "#173177"), 'keyword1' => array('value' => "2015-01-06 12:12:11", "color" => "#173177"), 'keyword2' => array('value' => '158元', "color" => "#173177"), 'keyword3' => array('value' => '香草口味*8', "color" => "#173177"), 'keyword4' => array('value' => 'XX街XX小区XX楼XX室', "color" => "#173177"), 'remark' => array('value' => "你的订单已成功支付,如有疑问,请拨打客服电话!", "color" => "#173177")));
     $wechat = new \Org\Weixin\Wechat($options);
     dump($wechat->sendTemplateMessage($data));
 }
Esempio n. 2
0
 private function getQrPicUrl($ecid, $sceneId)
 {
     $m = M("Company_info");
     $opt['company_ecid'] = $ecid;
     $token = $m->where($opt)->find();
     //如果接口信息不完整,直接返回
     if ($token['weixin_AppId'] == '' || $token['weixin_AppSecret'] == '') {
         return;
     }
     $weObj = new \Org\Weixin\Wechat();
     if ($weObj->checkAuth($token['weixin_AppId'], $token['weixin_AppSecret'])) {
         $qrCode = $weObj->getQRCode($sceneId, 0);
         if ($qrCode) {
             return $weObj->getQRUrl($qrCode['ticket']);
         }
     }
 }
 public function qrcode()
 {
     $payQrcodeId = I('get.id');
     $m = M('Company_pay_qrcode');
     $result = $m->find($payQrcodeId);
     if ($result) {
         $companyInfo = $this->getCompanyInfo();
         if ($companyInfo) {
             $options = array('appid' => $companyInfo['weixin_AppId'], 'appsecret' => $companyInfo['weixin_AppSecret'], 'partnerid' => $companyInfo['weixin_PartnerID'], 'partnerkey' => $companyInfo['weixin_PartnerKey'], 'paysignkey' => $companyInfo['weixin_PaySignKey']);
             $wechat = new \Org\Weixin\Wechat($options);
             $url = $wechat->createNativeUrl('pay_' . $payQrcodeId);
             Vendor('phpQrcode.phpqrcode');
             $errorCorrectionLevel = "L";
             $matrixPointSize = "4";
             \QRcode::png($url, false, $errorCorrectionLevel, $matrixPointSize);
         }
     }
 }
 private function sendOrderMsg($orderInfo)
 {
     $userInfo = session('userInfo');
     $goods = unserialize($orderInfo['goods']);
     for ($i = 0; $i < count($goods); $i++) {
         if ($i > 0) {
             $goodsText .= ',';
         }
         $goodsText .= $goods[$i]['name'] . '*' . $goods[$i]['num'];
     }
     $address = unserialize($orderInfo['address']);
     if ($orderInfo['sign'] == 1) {
         $title = "您好,你的订单【{$orderInfo['orderNo']}】已成功提交,我们将尽快处理。";
     } else {
         $title = "您好,你的订单【{$orderInfo['orderNo']}】已成功提交,我们将尽快处理。";
     }
     if ($userInfo) {
         $companyInfo = $this->getCompanyInfo();
         $options = array('appid' => $companyInfo['weixin_AppId'], 'appsecret' => $companyInfo['weixin_AppSecret'], 'partnerid' => $companyInfo['weixin_PartnerID'], 'partnerkey' => $companyInfo['weixin_PartnerKey'], 'paysignkey' => $companyInfo['weixin_PaySignKey']);
         $data = array('touser' => $userInfo['openId'], 'template_id' => 'ffjlR69y7HeuQj1JsuGbZGDfNCOACC9q1LglPHLfduc', 'url' => '', 'topcolor' => '#000000', 'data' => array('first' => array('value' => $title, "color" => "#173177"), 'keyword1' => array('value' => date('Y-m-d H:i:s'), "color" => "#173177"), 'keyword2' => array('value' => $orderInfo['payPrice'] . '元', "color" => "#173177"), 'keyword3' => array('value' => $goodsText, "color" => "#173177"), 'keyword4' => array('value' => $address['tel'], "color" => "#173177"), 'keyword5' => array('value' => $address['address'], "color" => "#173177"), 'remark' => array('value' => "请确认收件人电话、地址是否正确,如有疑问请拨打客服电话4009908355或添加微信客服icalexsz。", "color" => "#173177")));
         $wechat = new \Org\Weixin\Wechat($options);
         $wechat->sendTemplateMessage($data);
     }
 }
Esempio n. 5
0
 private function sendCustomMsg($id)
 {
     $m = M('Company_order');
     $orderInfo = $m->find($id);
     $userInfo = $this->getUserInfo($orderInfo['uId']);
     $goods = unserialize($orderInfo['goods']);
     $sendUser = json_decode($orderInfo['allocationInfo'], true);
     for ($i = 0; $i < count($goods); $i++) {
         if ($i > 0) {
             $goodsText .= ',';
         }
         $goodsText .= $goods[$i]['name'] . '*' . $goods[$i]['num'];
     }
     $address = unserialize($orderInfo['address']);
     $title = "您好,你的订单【{$orderInfo['orderNo']}】已配送,请注意查收。";
     if ($userInfo) {
         $companyInfo = $this->getCompanyInfo();
         $options = array('appid' => $companyInfo['weixin_AppId'], 'appsecret' => $companyInfo['weixin_AppSecret'], 'partnerid' => $companyInfo['weixin_PartnerID'], 'partnerkey' => $companyInfo['weixin_PartnerKey'], 'paysignkey' => $companyInfo['weixin_PaySignKey']);
         $sendMsg = "配送人员:{$sendUser['name']};联系电话:{$sendUser['tel']}";
         $data = array('touser' => $userInfo['openId'], 'template_id' => 'vjn3tEx2CteT39U5fylZd4oZGr3y606bcm-q_HS02iY', 'url' => 'http://www.icalex.com', 'topcolor' => '#000000', 'data' => array('first' => array('value' => $title, "color" => "#173177"), 'keyword1' => array('value' => $orderInfo['orderNo'], "color" => "#173177"), 'keyword2' => array('value' => $orderInfo['addTime'], "color" => "#173177"), 'keyword3' => array('value' => $orderInfo['payPrice'] . '元', "color" => "#173177"), 'keyword4' => array('value' => $address['name'], "color" => "#173177"), 'keyword5' => array('value' => $address['address'], "color" => "#173177"), 'remark' => array('value' => $sendMsg, "color" => "#173177")));
         $wechat = new \Org\Weixin\Wechat($options);
         $wechat->sendTemplateMessage($data);
     }
 }
Esempio n. 6
0
 private function getQrPicUrl($ecid, $sceneId)
 {
     $token = $this->getAppToken($ecid);
     //如果接口信息不完整,直接返回
     if ($token['weixin_AppId'] == '' || $token['weixin_AppSecret'] == '') {
         return;
     }
     $weObj = new \Org\Weixin\Wechat();
     if ($weObj->checkAuth($token['weixin_AppId'], $token['weixin_AppSecret'])) {
         $qrCode = $weObj->getQRCode($sceneId, 1);
         if ($qrCode) {
             return $weObj->getQRUrl($qrCode['ticket']);
         }
     }
 }
Esempio n. 7
0
 public function sendCustomMessage()
 {
     $token = $this->getAppToken(session($this->_userCfg['ECID']));
     //如果接口信息不完整,直接返回
     if ($token['weixin_AppId'] == '' || $token['weixin_AppSecret'] == '') {
         $this->ajaxReturn(Error::ERROR_MENU_TOKEN_EMPTY, Error::getErrMsg(Error::ERROR_MENU_TOKEN_EMPTY), 0);
     }
     $data['touser'] = I('post.touser');
     $data['msgtype'] = I('post.msgtype');
     $data['text'] = I('post.text', '', '');
     $weObj = new \Org\Weixin\Wechat();
     if ($weObj->checkAuth($token['weixin_AppId'], $token['weixin_AppSecret'])) {
         $result = $weObj->sendCustomMessage($data);
         if ($result['errcode'] == 0) {
             $opt['ecid'] = session($this->_userCfg['ECID']);
             $opt['openId'] = $data['touser'];
             $opt['responseType'] = 'text';
             $opt['content'] = $data['text']['content'];
             $opt['time'] = date("Y-m-d H:i:s");
             M('Company_response')->add($opt);
         }
         $this->ajaxReturn($result);
     }
 }
Esempio n. 8
0
 public function releaseMenuHandle()
 {
     $token = $this->getAppToken(session('ecid'));
     //如果接口信息不完整,直接返回
     if ($token['weixin_AppId'] == '' || $token['weixin_AppSecret'] == '') {
         $this->ajaxReturn(Error::ERROR_MENU_TOKEN_EMPTY, Error::getErrMsg(Error::ERROR_MENU_TOKEN_EMPTY), 0);
     }
     $menu = $this->getMenuSet(session('ecid'));
     $menu_weixin = array('button' => '');
     for ($i = 0; $i < count($menu); $i++) {
         $menu_weixin['button'][$i] = $this->changeWeixinArray($menu[$i], $token);
         if ($menu[$i]['hasSub'] == 1) {
             for ($j = 0; $j < count($menu[$i]['subitem']); $j++) {
                 if (($menu[$i]['subitem'][$j]['responseType'] == null || $menu[$i]['subitem'][$j]['responseType'] == "text") && $menu[$i]['subitem'][$j]['responseText'] == "") {
                     $data['data'] = ERROR::ERROR_MENU_REPLY_EMPTY;
                     $data['info'] = $menu[$i]['subitem'][$j]['name'] . ":" . Error::getErrMsg(Error::ERROR_MENU_REPLY_EMPTY);
                     $this->ajaxReturn($data, "JSON");
                 }
             }
         } else {
             if (($menu[$i]['responseType'] == "text" || $menu[$i]['responseType'] == null) && $menu[$i]['responseText'] == "") {
                 $data['data'] = ERROR::ERROR_MENU_REPLY_EMPTY;
                 $data['info'] = $menu[$i]['name'] . ":" . Error::getErrMsg(Error::ERROR_MENU_REPLY_EMPTY);
                 $this->ajaxReturn($data, "JSON");
             }
         }
     }
     $weObj = new \Org\Weixin\Wechat();
     if ($weObj->checkAuth($token['weixin_AppId'], $token['weixin_AppSecret'])) {
         if ($tmp = $weObj->createMenu($menu_weixin)) {
             $data['data'] = Error::SUCCESS_OK;
             $data['info'] = Error::getErrMsg(Error::SUCCESS_OK);
             $this->ajaxReturn($data, 'JSON');
         }
     }
 }