Exemplo n.º 1
0
<?php

include_once "../../includes/config.inc.php";
include_once "../../includes/login_check.php";
//var
$customer_id = (int) $_SESSION['customer_id'];
$carerecordModel = new Model_CareRecord();
$messageModel = new Model_Message();
$today = date("Y-m-d");
$start_date = date('Y-m-d', strtotime('-29 day'));
//最近30天关注量
$filter['where'] = "customer_id='{$customer_id}' and is_care='1' and left(create_date,10)>'{$start_date}'";
$filter['group'] = " left(create_date,10) ";
$sql = $carerecordModel->select($filter, 'count(id) as count_num,left(create_date,10) as count_date');
$carearray = $carerecordModel->fetchAll($sql);
foreach ($carearray as $key => $row) {
    $countinfo[$row['count_date']] = $row['count_num'];
    if ($row['count_date'] == $today) {
        $count['today_carenum'] = $row['count_num'];
    }
}
//取消量
$filter['where'] = "customer_id='{$customer_id}' and is_care='0' and left(create_date,10)>'{$start_date}'";
$filter['group'] = " left(create_date,10) ";
$sql = $carerecordModel->select($filter, 'count(id) as count_num,left(create_date,10) as count_date');
$uncarearray = $carerecordModel->fetchAll($sql);
foreach ($uncarearray as $key => $row) {
    $countinfob[$row['count_date']] = $row['count_num'];
    if ($row['count_date'] == $today) {
        $count['today_uncarenum'] = $row['count_num'];
    }
Exemplo n.º 2
0
 public function responseMsg()
 {
     $this->post_data = $this->getPostData();
     $this->post_data['timesign'] = time() . rand(1000, 9999);
     //语音信息
     if ($this->post_data['FromMsgType'] == 'voice') {
         $this->post_data['Keyword'] = $this->post_data['Recognition'];
     }
     //图片信息
     if ($this->post_data['FromMsgType'] == 'image') {
         $this->post_data['Keyword'] = '[发送图片]';
     }
     //位置
     if ($this->post_data['FromMsgType'] == 'location') {
         /* $this->post_data['Keyword']='[发送位置]'.$this->post_data['Label'];
         			//include "base_info.php";
         			//$infoobj = new base_info();
         			$result['customer_id']	= $this->customer_id;
         			$result['info_type']	= 'location';
         			$result['location_x']	= $this->post_data['Location_X'];
         			$result['location_y']	= $this->post_data['Location_Y'];
         			$result['fromwhere']	= $this->post_data['Label'];
         			$result['fromuser']		= $this->post_data['FromUserName'];
         			$result['timesign']		= $this->post_data['timesign'];
         			//$data= $infoobj->getData($result);
         			//return $this->create_xmlcontent($data['msgtype'], $data['content'], $data['title'], $data['description'], $data['picurl'], $data['url'], $data['bodystr']);
         			$memberLocationModel=new Model_Subtable('member_location');
         			$locationArr['info'][fromuser]=$this->post_data['FromUserName'];
         			$locationArr['info'][locate_x]=$this->post_data['Location_X'];
         			$locationArr['info'][locate_y]=$this->post_data['Location_Y'];
         			$memberLocationModel->add($locationArr); */
         $xmlcontent = " <xml>\n\t\t\t <ToUserName><![CDATA[" . $this->post_data['FromUserName'] . "]]></ToUserName>\n\t\t\t <FromUserName><![CDATA[" . $this->post_data['ToUserName'] . "]]></FromUserName>\n\t\t\t <CreateTime>" . time() . "</CreateTime>\n\t\t\t <MsgType><![CDATA[text]]></MsgType>\n\t\t\t <Content><![CDATA[" . $this->post_data['Location_X'] . "|" . $this->post_data['Location_Y'] . "|" . $this->post_data['Label'] . "]]></Content>\n\t\t\t </xml> ";
         return $xmlcontent;
     }
     //菜单点击
     if ($this->post_data['Event'] != '' and $this->post_data['Event'] != 'CLICK') {
         $this->post_data['Keyword'] = $this->post_data['EventKey'];
     }
     $this->addMessage();
     //关注+取消关注
     if (strtolower($this->post_data['Event']) == 'subscribe' or strtolower($this->post_data['Event']) == 'unsubscribe') {
         /*插入关注记录*/
         $carerecordModel = new Model_CareRecord();
         $row['is_care'] = strtolower($this->post_data['Event']) == 'subscribe' ? '1' : '0';
         $row['customer_id'] = $this->customer_id;
         $row['fromuser'] = $this->post_data['FromUserName'];
         $row['create_date'] = date("Y-m-d H:i:s");
         $carerecordModel->insert($row);
         /*更新会员表*/
         $memberModel = new Model_Member();
         $rowMem = $this->getMemDetail();
         //获取用户详细信息
         $rowMem['customer_id'] = $this->customer_id;
         $rowMem['fromuser'] = $this->post_data['FromUserName'];
         $rowMem['status'] = strtolower($this->post_data['Event']) == 'subscribe' ? '1' : '0';
         if ($rowMem['status'] == '1') {
             $rowMem['subscribe_time'] = time();
             $rowMem['create_date'] = date("Y-m-d H:i:s");
         } else {
             $rowMem['unsubscribe_time'] = time();
         }
         $rowMem['timesign'] = $this->post_data['timesign'];
         $memberModel->upsert($rowMem);
         /*关注自动回复*/
         $replyModel = new Model_AutoReply();
         $replyRow = $replyModel->findByCustomerId($this->customer_id, '1');
         if (!$replyRow['id'] or $replyRow['state'] != '1') {
             return false;
         } else {
             if ($replyRow['is_keyword'] == '1') {
                 $this->post_data['Keyword'] = $replyRow['reply_keyword'];
             } else {
                 return $this->create_xmlcontent('text', $replyRow['reply_content']);
             }
         }
     }
     $returnxml = $this->getInfo();
     //file_put_contents('c.txt',$returnxml);
     return $returnxml;
 }