public function byfilter($openId)
 {
     \Home\Common\Common::setrep();
     $accessToken = $_SESSION["tokens"];
     //获取access_token
     $xjson = '
    {  
     }
      ';
     $PostUrl = "https://api.weixin.qq.com/merchant/order/getbyfilter?access_token=" . $accessToken;
     //POST的url
     $value = \Home\Common\Common::PData($PostUrl, $xjson);
     $datas = json_decode($value, ture);
     $isnull = true;
     //        $openId = "ou9X8tl0p-rfJcmRriSrj2QP144s";
     //        $openId = "ou9X8tmgcfDo8PRv_kOQlaXsTE1U";
     //        $openId = "ou9X8tsAIKJfcy86ynM9tXUKorbg";
     $arr = array();
     foreach ($datas['order_list'] as $tableName => $table) {
         if ($table['buyer_openid'] == $openId) {
             $arr[] = $table;
         }
     }
     $result = json_encode($arr);
     return $result;
 }
Ejemplo n.º 2
0
 public function checkGZ($openid)
 {
     \Home\Common\Common::setrep();
     $url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $_SESSION['tokens'] . "&openid=" . $openid . "&lang=zh_CN";
     $value = \Home\Common\Common::PData($url);
     return $value;
 }
Ejemplo n.º 3
0
 private function receiveEvent($object)
 {
     $content = "";
     $contents = "";
     $openid = $object->FromUserName;
     $this->logger("object->order: " . $object);
     switch ($object->Event) {
         case "subscribe":
             $this->logger("user" . $openid);
             $content = $this->getYMassage();
             //                $content .= (!empty($object->EventKey)) ? ("\n来自二维码场景 " . str_replace("qrscene_", "", $object->EventKey)) : "";
             switch (str_replace("qrscene_", "", $object->EventKey)) {
                 case "cork-down":
                     $map['openid'] = $object->FromUserName . "";
                     $map['eventkey'] = $object->EventKey . "";
                     $map['time'] = $object->CreateTime . "";
                     //                        $content = json_encode($object);
                     $message .= \Home\Common\Common::savescaninfo($map);
                     sendMessage($openid, $message);
                     break;
             }
             break;
         case "merchant_order":
             $arr = array('ou9X8tl0p-rfJcmRriSrj2QP144s', 'ou9X8tsfPcvMkI5ZQO3sF7C6Rqfk', 'ou9X8tmgcfDo8PRv_kOQlaXsTE1U', 'ou9X8tu0XbdM4eg_x4T_fBKCFqB4', 'ou9X8tpSlTLlRDrn3poEBV2lOc6o', 'ou9X8trvxCTbI8_vNImSPaUOi3C4', 'ou9X8ti7n_EM55j9zY1aekeRRPsw', 'ou9X8tvqWzg16EhbYeBDJGyYLPU0');
             $this->setrep();
             $url = "http://weixin.vynfields.cn/Home/GetByfilter/index/openId/{$object->FromUserName}";
             $jsonData = $this->orderData($_SESSION['token'], $object->OrderId);
             $_SESSION["jsonData"] = $jsonData;
             foreach ($arr as $v) {
                 $this->sendMessage($_SESSION['token'], $v, $_SESSION["jsonData"]);
             }
             $this->send_template_message($_SESSION['token'], $jsonData, $object->FromUserName, $url);
             break;
         case "unsubscribe":
             $this->userDefriend($openid);
             $content = "取消关注";
             break;
         case "SCAN":
             //                $content = "扫描场景 " . $object->EventKey;
             switch ($object->EventKey) {
                 case "cork-down":
                     $map['openid'] = $object->FromUserName . "";
                     $map['eventkey'] = $object->EventKey . "";
                     $map['time'] = $object->CreateTime . "";
                     //                        $content = json_encode($map);
                     $content = \Home\Common\Common::savescaninfo($map);
                     break;
                 default:
                     $content = "";
                     break;
             }
             break;
         case "CLICK":
             switch ($object->EventKey) {
                 case "V1001_CONN_CUSTOM":
                     $content = $this->getYMassage();
                     break;
                 case "VINEYARD":
                     $content = array();
                     $content[] = array("Title" => "维尼菲尔德(VYNFIELDS)酒庄", "Description" => "维尼菲尔德酒庄坐落于马尔堡的梯田上,拥有5.3公顷有机葡萄园,园区内古老的碎石土壤表层覆盖着薄薄一层粉砂壤土,具有良好的排水性。气候适宜,降雨少,夏季炎热干燥,秋季夜间凉爽,这为黑皮诺和雷司令的生长创造了理想的条件。", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/cNQxibw2z3wRebFKV8CObsmC4lYA9A9KEleUWicF6X4iblEMkovkOxns6bTf8mfVwvqgx64Ll9pcshbCMXTw9Cuzg/0", "Url" => "http://mp.weixin.qq.com/s?__biz=MzA3MDAyMzA5OQ==&mid=203156234&idx=1&sn=0e564ec19e82cebd4b50873883fcd07d#rd");
                     break;
                 case "WINE":
                     $content = array();
                     $content[] = array("Title" => "维尼菲尔德(VYNFIELDS)葡萄酒", "Description" => "维尼菲尔德酒庄精心酿造的2003 Pinot Noir及2004 Classic Riesling蜚声国际", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/cNQxibw2z3wQIVfMACB4WT2uatjWh1n4iaTvftmicBmQCmvjicXxONShcnM9FtIZ8ugoeayRlcIURXFa4ohl3ByLIw/0", "Url" => "http://mp.weixin.qq.com/s?__biz=MzA3MDAyMzA5OQ==&mid=203156559&idx=1&sn=99f1c22cb4357bb9811a151af3b44ae6#rd");
                     break;
                 case "Suggestions":
                     $content = array();
                     $this->setrep();
                     $this->logger("object->contents: " . $_SESSION['token']);
                     break;
                 case "Contact":
                     $content = "维尼菲尔德葡萄酒代理请点击:http://m.9928.tv/vip8_yzrc/\n\n热线:400-888-2232\n\n邮箱:info@vynfields.cn\n\n维尼菲尔德期待与您的合作! ";
                     break;
                 case "Orders":
                     $content = array();
                     $content[] = array("Title" => "Vynfields商城订单查询", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/cNQxibw2z3wQOpSx9cia1ib4DDNEpmWJWUA7d286ENzq81BDOjwtrl6ibibDmhXPKAFD4e2NA0xA9HLeUSshvgZxlGw/0", "Url" => "http://weixin.vynfields.cn//Home/GetByfilter/index/openId/{$object->FromUserName}");
                     break;
                 default:
                     $content = "";
                     break;
             }
             break;
         case "LOCATION":
             //	$content = "上传位置:纬度 " . $object->Latitude . ";经度 " . $object->Longitude;
             $content = "";
             break;
         case "VIEW":
             $content = "跳转链接 " . $object->EventKey;
             break;
         default:
             $content = "receive a new event: " . $object->Event;
             break;
     }
     if (is_array($content)) {
         if (isset($content[0])) {
             $result = $this->transmitNews($object, $content);
         } else {
             if (isset($content['MusicUrl'])) {
                 $result = $this->transmitMusic($object, $content);
             }
         }
     } else {
         if (is_array($contents)) {
             if (isset($contents[0])) {
                 $this->logger("array->contents: " . $contents);
                 $result = $this->transmitOrder($object, $contents);
             }
         } else {
             $result = $this->transmitText($object, $content);
         }
     }
     return $result;
 }
Ejemplo n.º 4
0
/**
 * send message to openid
 * @param type $openid openid
 * @param type $content content
 * @return type
 */
function sendMessage($openid, $content)
{
    \Home\Common\Common::setrep();
    $accessToken = $_SESSION["tokens"];
    //获取access_token
    $xjson = '
     {
    "touser":"******",
    "msgtype":"text",
    "text":
    {
         "content":"' . $content . '"
    }
}
         ';
    $PostUrl = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" . $accessToken;
    //POST的url
    $value = \Home\Common\Common::PData($PostUrl, $xjson);
    $datas = json_decode($value, ture);
    return $value;
}