/** * */ public function index_action($id = null) { if ($id) { $c = $this->model('app\\contribute')->byId($id); /** * belong to channel */ $c->channels = $this->model('matter\\channel')->byMatter($id, 'contribute'); /** * 参与人 */ $c->initiator = $this->model('app\\contribute')->userAcls($this->mpid, $id, 'I'); $c->reviewer = $this->model('app\\contribute')->userAcls($this->mpid, $id, 'R'); $c->typesetter = $this->model('app\\contribute')->userAcls($this->mpid, $id, 'T'); /** * return */ $channels = \TMS_APP::model('matter\\channel')->byMpid($this->mpid); $params = array('mpid' => $this->mpid, 'app' => $c, 'channels' => $channels); \TPL::assign('params', $params); $this->view_action('/mp/app/contribute/edit'); } else { $this->view_action('/mp/app/contribute'); } }
public function exec() { $relay = \TMS_APP::model('mp\\relay')->byId($this->relayId); /** * 公众平台发过来的原始数据 */ $data = file_get_contents("php://input"); $headerArr[] = 'Content-Type: text/xml; charset=utf-8'; /** * 转发数据 */ $ch = curl_init($relay->url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArr); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); if (false === ($rsp = curl_exec($ch))) { $err = curl_error($ch); curl_close($ch); return array(false, $err); } curl_close($ch); die($rsp); }
/** * */ public function remove($pageId) { $page = $this->byId($pageId, array('cascaded' => 'N')); \TMS_APP::model('code/page')->remove($page->code_id); $rst = $this->delete('xxt_wall_page', "id={$pageId}"); return $rst; }
/** * */ protected function loadMatters() { $runningMpid = $this->call['mpid']; $openid = $this->call['from_user']; $news = \TMS_APP::model('matter\\news')->byId($this->set_id); $matters = \TMS_APP::model('matter\\news')->getMatters($this->set_id); $modelAcl = \TMS_APP::model('acl'); $members = \TMS_APP::model('user/member')->byOpenid($runningMpid, $openid); $matters2 = array(); foreach ($matters as $m) { if ($m->access_control === 'Y' && $news->filter_by_matter_acl === 'Y') { $inacl = false; foreach ($members as $member) { if ($modelAcl->canAccessMatter($m->mpid, $m->type, $m->id, $member, $m->authapis)) { $inacl = true; break; } } if (!$inacl) { continue; } } $m->url = \TMS_APP::model('matter\\' . $m->type)->getEntryUrl($runningMpid, $m->id, $openid); $matters2[] = $m; } if (count($matters2) === 0) { $m = \TMS_APP::model('matter\\base')->getCardInfoById($news->empty_reply_type, $news->empty_reply_id); return $m; } else { return $matters2; } }
/** * */ public function &byId($id, $cascaded = 'N') { $q = array('*', 'xxt_lottery_log', "id='{$id}'"); if ($log = $this->query_obj_ss($q)) { $log->award = \TMS_APP::M('app\\lottery\\award')->byId($log->aid); } return $log; }
protected function loadMatters() { $mpid = $this->call['mpid']; $page = 1; $limit = 5; $matters = \TMS_APP::model('matter\\article')->fullsearch_its($mpid, $this->keyword, $page, $limit); return $matters; }
/** * */ public function getEntryUrl($runningMpid, $id, $openid = null, $call = null) { if (isset($matter->urlsrc)) { /** * link */ switch ($matter->urlsrc) { case 0: // external link if ($matter->open_directly === 'Y') { $url = $matter->url; $q = array('pname,pvalue,authapi_id', 'xxt_link_param', "link_id={$matter->id}"); if ($params = $this->query_objs_ss($q)) { $url .= strpos($url, '?') === false ? '?' : '&'; $url .= $this->spliceParams($runningMpid, $params, null, $openid); } if (preg_match('/^(http:|https:)/', $url) === 0) { $url = 'http://' . $url; } return $url; } else { $url = "?mpid={$runningMpid}&id={$matter->id}&type=link"; } break; case 1: // news $url = "?mpid={$runningMpid}&type=news&id=" . $matter->url; break; case 2: // channel $url = "?mpid={$runningMpid}&type=channel&id=" . $matter->url; break; case 3: // inner $reply = TMS_APP::model('reply\\inner', $call, $matter->url); $url = $reply->exec(false); $q = array('pname,pvalue,authapi_id', 'xxt_link_param', "link_id={$matter->id}"); if ($params = $this->query_objs_ss($q)) { $url .= strpos($url, '?') === false ? '?' : '&'; $url .= $this->spliceParams($runningMpid, $params, null, $openid); } if (preg_match('/^(http:|https:)/', $url) === 0) { $url = 'http://' . $url; } return $url; default: die('unknown link urlsrc.'); } } else { $url = "http://" . $_SERVER['HTTP_HOST'] . "/rest/mi/matter"; $url .= "?mpid={$runningMpid}&id={$id}&type=" . $this->getTypeName(); if (!empty($openid)) { $url .= "&openid={$openid}"; } return $url; } }
public function __construct($mpid) { if (empty(self::$data)) { $mpa = \TMS_APP::M('mp\\mpaccount')->byId($mpid, 'wx_appid,wx_appsecret,wx_mchid'); self::$data['APPID'] = $mpa->wx_appid; self::$data['MCHID'] = $mpa->wx_mchid; self::$data['KEY'] = $mpid; self::$data['APPSECRET'] = $mpa->wx_appsecret; } }
/** * 如果频道设置了【固定标题】,要用固定标题替换掉第一个图文的标题 */ protected function loadMatters() { $mpid = $this->call['mpid']; $model = \TMS_APP::model('matter\\channel'); $matters = $model->getMatters($this->set_id, null, $mpid); $channel = $model->byId($this->set_id, 'fixed_title'); if (!empty($matters) && !empty($channel->fixed_title)) { $matters[0]->title = $channel->fixed_title; } return $matters; }
/** * * $call * $content 回复的内容 * $referred 指明$content是直接回复的内容,还是定义的文本素材 */ public function __construct($call, $content, $referred = true) { parent::__construct($call); if ($referred) { if ($txt = \TMS_APP::model('matter\\text')->byId($content, 'content')) { $content = $txt->content; } else { $content = "文本回复【{$content】不存在}"; } } $this->content = $content; }
/** * 返回进行推送的客服消息格式 * * $runningMpid * $id * */ public function &forCustomPush($runningMpid, $id) { $matters = $this->getMatters($id); $ma = array(); foreach ($matters as $m) { if (!empty($m->pic) && stripos($m->pic, 'http') === false) { $pic = 'http://' . $_SERVER['HTTP_HOST'] . $m->pic; } else { $pic = $m->pic; } $ma[] = array('title' => urlencode($m->title), 'description' => urlencode($m->summary), 'url' => \TMS_APP::model('matter\\' . $m->type)->getEntryUrl($runningMpid, $m->id), 'picurl' => urlencode($pic)); } $msg = array('msgtype' => 'news', 'news' => array('articles' => $ma)); return $msg; }
/** * */ public function handleRequest() { // init the destination file (format <filename.ext>.part<#chunk> // the file is stored in a temporary directory $temp_dir = $_POST['resumableIdentifier']; $dest_file = $temp_dir . '/' . $_POST['resumableFilename'] . '.part' . $_POST['resumableChunkNumber']; $content = base64_decode(preg_replace('/data:(.*?)base64\\,/', '', $_POST['resumableChunkContent'])); // move the temporary file $fs = \TMS_APP::M('fs/saestore', $this->mpid); if (!$fs->write($dest_file, $content)) { return array(false, 'Error saving (move_uploaded_file) chunk ' . $_POST['resumableChunkNumber'] . ' for file ' . $_POST['resumableFilename']); } else { // check if all the parts present, and create the final destination file $this->createFileFromChunks($temp_dir, $_POST['resumableFilename'], $_POST['resumableChunkSize'], $_POST['resumableTotalSize']); return array(true); } }
/** * 获得执行链接的结果 */ private function output($link, $openid) { $url = $link->url; if (preg_match('/^(http:|https:)/', $url) === 0) { $url = 'http://' . $url; } if (isset($link->params)) { $params = \TMS_APP::model('reply')->spliceParams($link->mpid, $link->params, null, $openid); } if ($link->method == 'GET' && isset($this->params)) { $url .= strpos($url, '?') === false ? '?' : '&'; $url .= $params; } $ch = curl_init(); //初始化curl curl_setopt($ch, CURLOPT_URL, $url); //设置链接 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //设置是否返回信息 //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_REFERER, 1); curl_setopt($ch, CURLOPT_HEADER, 1); //设置返回的信息是否包含http头 if ($link->method === 'POST') { curl_setopt($ch, CURLOPT_POST, 1); //设置为POST方式 if (!empty($params)) { $header = array("Content-type: application/x-www-form-urlencoded"); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_POSTFIELDS, $posted); } } $response = curl_exec($ch); if (curl_errno($ch)) { $output = curl_error($ch); } else { /** * 返回内容 */ $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $output = substr($response, $headerSize); } curl_close($ch); return $output; }
/** * 创建订单 * * @param string $mpid * @param object $user * @param object $info * * @return object $order */ public function &create($mpid, $user, $info) { //订单号 $trade_no = date('YmdHis') . mt_rand(100000, 999999); //库存信息 $productIds = array(); $skus = array(); $totalPrice = 0; $modelSku = \TMS_APP::M('app\\merchant\\sku'); foreach ($info->skus as $skuId => $skuInfo) { $sku = $modelSku->byId($skuId); $sku->__count = $skuInfo->count; $totalPrice += $skuInfo->count * $sku->price; $skus[] = $sku; $productIds[$sku->prod_id] = 1; } //商品信息 $products = array(); $modelProd = \TMS_APP::M('app\\merchant\\product'); foreach ($productIds as $prodId => $v) { $product = $modelProd->byId($prodId); $products[] = array('id' => $product->id, 'cate_id' => $product->cate_id, 'name' => urlencode($product->name), 'main_img' => $product->main_img); /*更新商品定义状态*/ if ($product->used === 'N') { $modelProd->refer($product->id); } } /*创建订单*/ if (empty($info->extPropValues)) { $info->extPropValues = new \stdClass(); } $epv = self::toJson($info->extPropValues); $order = array('trade_no' => $trade_no, 'mpid' => $mpid, 'sid' => $sku->sid, 'products' => urldecode(json_encode($products)), 'order_status' => 1, 'order_total_price' => $totalPrice, 'order_create_time' => time(), 'order_express_price' => 0, 'ext_prop_value' => $epv, 'buyer_openid' => $user->openid, 'buyer_nick' => $user->fan->nickname, 'receiver_name' => $info->receiver_name, 'receiver_mobile' => $info->receiver_mobile, 'receiver_email' => $info->receiver_email); $order['id'] = $this->insert('xxt_merchant_order', $order, true); $order['extPropValue'] = $info->extPropValues; $order = (object) $order; //订单包含的库存 foreach ($skus as $sku) { $orderSku = array('mpid' => $mpid, 'sid' => $sku->sid, 'oid' => $order->id, 'cate_id' => $sku->cate_id, 'cate_sku_id' => $sku->cate_sku_id, 'prod_id' => $sku->prod_id, 'sku_id' => $sku->id, 'sku_price' => $sku->price, 'sku_count' => $sku->__count); $orderSku['id'] = $this->insert('xxt_merchant_order_sku', $orderSku, true); /*更新商品sku状态*/ $modelSku->order($sku->id, $sku->__count); } return $order; }
/** * * $mpid * $id channel's id */ public function mattersGet_action($mpid, $id, $orderby = 'time', $page = null, $size = null) { $vid = $this->getVisitorId($mpid); $params = new \stdClass(); $params->orderby = $orderby; if ($page !== null && $size !== null) { $params->page = $page; $params->size = $size; } $matters = \TMS_APP::M('matter\\channel')->getMattersNoLimit($id, $vid, $params); $tagModel = $this->model('tag'); foreach ($matters as $m) { $matterModel = \TMS_APP::M('matter\\' . $m->type); $m->url = $matterModel->getEntryUrl($mpid, $m->id); $m->tags = $tagModel->tagsByRes($m->id, 'article'); } return new \ResponseData($matters); }
/** * $doResponse 是否执行相应。因为易信二维码需要通过推送客服消息的方式返回相应。 */ public function exec($doResponse = true) { /** * 当前用户加入活动 */ $wall = \TMS_APP::model('app\\wall'); $mpid = $this->call['mpid']; $openid = $this->call['from_user']; $desc = $wall->join($mpid, $this->wid, $openid, $this->remark); /** * 返回活动加入成功提示 */ if ($doResponse) { $r = $this->textResponse($desc); die($r); } else { return $desc; } }
/** * 获得定义的认证接口 * * $mpid * $valid [null|Y|N] */ public function &byMpid($mpid, $valid = null, $own = 'Y') { $where = "mpid='{$mpid}'"; !empty($valid) && ($where .= " and valid='{$valid}'"); $apis = $this->queryBy($where); if ($own === 'N') { $pmp = \TMS_APP::M('mp\\mpaccount')->byId($mpid); if (!empty($pmp->parent_mpid)) { $papis = $this->byMpid($pmp->parent_mpid, $valid); } if (!empty($papis)) { if (!empty($apis)) { $apis = array_merge($papis, $apis); } else { $apis = $papis; } } } return $apis; }
/** * error and exception handle */ function show_error($message) { require_once 'tms/tms_app.php'; header("HTTP/1.1 500 Internal Server Error"); header('Content-Type: text/plain; charset=utf-8'); if ($message instanceof Exception) { $msg = $message->getMessage() . "\n"; $trace = $message->getTrace(); foreach ($trace as $t) { foreach ($t as $k => $v) { $msg .= $k . ':' . json_encode($v) . "\n"; } } } else { $msg = $message; } echo $msg; TMS_APP::M('log')->log('error', 'error', $msg); exit; }
/** * */ public function get_action($mpid, $id) { $data = array(); $user = $this->getUser($mpid, array('verbose' => array('member' => true))); $data['user'] = $user; // $news = $this->model('matter\\news')->byId($id); if (isset($news->access_control) && $news->access_control === 'Y') { $this->accessControl($mpid, $id, $news->authapis, $user->openid, $news, false); } $matters = \TMS_APP::M('matter\\news')->getMatters($id); $modelAcl = \TMS_APP::M('acl'); $matters2 = array(); foreach ($matters as $m) { if ($m->access_control === 'Y' && $news->filter_by_matter_acl === 'Y') { $inacl = false; foreach ($user->members as $member) { if ($modelAcl->canAccessMatter($mpid, $m->type, $m->id, $member, $m->authapis)) { $inacl = true; break; } } if (!$inacl) { continue; } } $m->url = \TMS_APP::M('matter\\' . $m->type)->getEntryUrl($mpid, $m->id, $user->openid); $matters2[] = $m; } if (count($matters2) === 0 && !empty($news->empty_reply_type) && !empty($news->empty_reply_id)) { $modelMatter = \TMS_APP::M('matter\\' . $news->empty_reply_type); $matter = $modelMatter->byId($news->empty_reply_id); $matter->url = $modelMatter->getEntryUrl($mpid, $news->empty_reply_id, $user->openid); $news->matters = array($matter); } else { $news->matters = $matters2; } $data['news'] = $news; return new \ResponseData($data); }
/** * */ public function exec() { /** * 当前用户活动签到 */ $mpid = $this->call['mpid']; $openid = $this->call['from_user']; $model = \TMS_APP::model('app\\enroll'); $act = $model->byId($this->aid); $rst = $model->signin($mpid, $this->aid, $openid); /** * 回复 */ if ($rst) { if ($act->success_matter_type && $act->success_matter_id) { $cls = $act->success_matter_type; if ($this->directReply === true) { $r = \TMS_APP::model('reply\\' . $cls, $this->call, $act->success_matter_id); } else { return array('matter_type' => $act->success_matter_type, 'matter_id' => $act->success_matter_id); } } else { $r = \TMS_APP::model('reply\\text', $this->call, "活动【" . $act->title . "】已签到,已登记", false); } } else { if ($act->failure_matter_type && $act->failure_matter_id) { $cls = $act->failure_matter_type; if ($this->directReply === true) { $r = \TMS_APP::model('reply\\' . $cls, $this->call, $act->failure_matter_id); } else { return array('matter_type' => $act->failure_matter_type, 'matter_id' => $act->failure_matter_id); } } else { $r = \TMS_APP::model('reply\\text', $this->call, "活动【" . $act->title . "】已签到,未登记", false); } } $r->exec(); }
/** * 发送模板消息页面 * * $mpid * $authid 如果传递的消息中用户的ID需要翻译为openid,那么需要提供进行身份认证的接口 */ public function send_action($mpid, $auth_url = null) { $messages = $this->getPostJson(); !is_object($messages) && ($messages = array($messages)); $failed = array(); if (!empty($auth_url)) { if (!($authapi = $this->model('user/authapi')->byUrl($mpid, $auth_url, 'authid'))) { return new \ResponseError('没有定义身份认证接口,无法进行身份转换,消息发送失败!'); } $authid = $authapi->authid; } /** * */ $mpproxy = \TMS_APP::M('mpproxy/wx', $mpid); foreach ($messages as $msg) { $msg = (object) $msg; if (isset($authid)) { $authuser = $msg->touser; $q = array('openid', 'xxt_member m', "m.forbidden='N' and m.authed_identity='{$authuser}'"); if (!($openid = $this->model()->query_val_ss($q))) { $msg->errmsg = '无法获得openid'; $failed[] = $msg; } $msg->touser = $openid; } $rst = $mpproxy->messageTemplateSend($msg); if ($rst[0] === false) { $msg->errmsg = $rst[1]; $failed[] = $msg; } } if (empty($failed)) { return new \ResponseData('finish'); } else { return new \ResponseError($failed); } }
/** * 获得菜单按钮定义 * * 每个菜单按钮有两个状态,编辑状态和发布状态,缺省返回编辑状态 */ public function &getButtonById($mpid, $key, $published = 'N', $fields = '*', $cascade = array()) { /** * 获得最新版本号 */ if ($version = $this->getVersion($mpid, $published)) { $q = array($fields, 'xxt_call_menu', "mpid='{$mpid}' and menu_key='{$key}' and version={$version->v}"); if ($button = $this->query_obj_ss($q)) { /** * 回复素材 */ if (in_array('matter', $cascade) && $button->matter_id) { $button->matter = \TMS_APP::model('matter\\base')->getMatterInfoById($button->matter_type, $button->matter_id); } /** * 访问控制列表 */ if (in_array('acl', $cascade)) { /*$q = array( 'a.id,a.identity,a.idsrc,d.name dept', "xxt_call_acl a left join xxt_member_department d on a.idsrc='D' and a.mpid=d.mpid and a.identity=d.id", "a.mpid='$button->mpid' and a.call_type='Menu' and a.keyword='$key'"); $acl = $this->query_objs_ss($q); if (!empty($acl)) { $button->acl = $acl; } else { $button->acl = array(); }*/ $button->acl = \TMS_APP::model('acl')->menuCall($button->mpid, $key); } } } else { $button = array(); } return $button; }
/** * 获得openid */ public function getOAuthUser($code) { $mpa = TMS_APP::M('mp\\mpaccount')->byId($this->mpid, "yx_appid,yx_appsecret"); $cmd = "https://api.yixin.im/sns/oauth2/access_token"; $params["appid"] = $mpa->yx_appid; $params["secret"] = $mpa->yx_appsecret; $params["code"] = $code; $params["grant_type"] = "authorization_code"; $rst = $this->httpGet($cmd, $params, false, false); if ($rst[0] === false) { return $rst; } $openid = $rst[1]->openid; return array(true, $openid); }
/** * 获得model对象 * * $path */ public static function M($path) { return TMS_APP::model($path); }
/** * 审核记录 * * $mpid * $id article'id * $mid member's id * $phase */ public function forward($mpid, $id, $mid, $phase, $remark = '') { $q = array('*', 'xxt_article_review_log', "mpid='{$mpid}' and article_id='{$id}'"); $q2 = array('o' => 'seq desc', 'r' => array('o' => 0, 'l' => 1)); $last = $this->query_objs_ss($q, $q2); if (!empty($last)) { $last = $last[0]; $this->update('xxt_article_review_log', array('state' => 'F'), "id={$last->id}"); } $member = \TMS_APP::M('user/member')->byId($mid); if (!empty($meber->name)) { $disposerName = $member->name; } else { $fan = \TMS_APP::M('user/fans')->byId($member->fid); $disposerName = $fan->nickname; } $seq = empty($last) ? 1 : $last->seq + 1; $newlog = array('mpid' => $mpid, 'article_id' => $id, 'seq' => $seq, 'mid' => $mid, 'disposer_name' => $disposerName, 'send_at' => time(), 'state' => 'P', 'phase' => $phase, 'remark' => $remark); $newlog['id'] = $this->insert('xxt_article_review_log', $newlog, true); return (object) $newlog; }
/** * * $img */ public function storeImg($img) { if (empty($img->imgSrc) && !isset($img->serverId)) { return array(false, '数据为空'); } if (isset($img->imgSrc) && 0 === strpos($img->imgSrc, 'http')) { $rst = $this->storeUrl($img->imgSrc); } else { if (isset($img->imgSrc) && 1 === preg_match('/data:image(.+?);base64/', $img->imgSrc)) { /** * base64 */ $rst = $this->storeBase64Image($img->imgSrc); } else { if (isset($img->serverId)) { /** * wx jssdk */ $rst = TMS_APP::model('mpproxy/wx', $this->mpid)->mediaGetUrl($img->serverId); if ($rst[0] === false) { return $rst; } $rst = $this->storeUrl($rst[1]); } else { return array(false, '数据格式错误'); } } } return $rst; }
/** * 直接打开频道的情况下(不是返回信息卡片),忽略置顶和置底,返回频道中的所有条目 * * $channel_id int 频道的id * $channel 频道 * * return 频道包含的所有条目 */ public function &getMattersNoLimit($channel_id, $vid, $params) { /** * load channel. */ $channel = $this->byId($channel_id, 'matter_type'); /** * in channel */ if ($channel->matter_type === 'article') { $orderby = $params->orderby || $channel->orderby; $q1 = array(); $q1[] = "m.id,m.title,m.summary,m.pic,m.create_at,m.creater_name,cm.create_at add_at,'article' type,m.score,m.remark_num,s.score myscore"; $q1[] = "xxt_article m left join xxt_article_score s on m.id=s.article_id and s.vid='{$vid}',xxt_channel_matter cm"; $q1[] = "m.state=1 and m.approved='Y' and cm.channel_id={$channel_id} and m.id=cm.matter_id and cm.matter_type='article'"; $q2 = array(); $q2['o'] = $this->matterOrderby('article', $orderby, 'cm.create_at desc'); if (isset($params->page) && isset($params->size)) { $q2['r'] = array('o' => ($params->page - 1) * $params->size, 'l' => $params->size); } $matters = $this->query_objs_ss($q1, $q2); } else { $matters = array(); $q1 = array(); $q1[] = 'cm.create_at,cm.matter_type,cm.matter_id'; $q1[] = 'xxt_channel_matter cm'; $q1[] = "cm.channel_id='{$channel_id}'"; $q2['o'] = 'cm.create_at desc'; if (isset($params->page) && isset($params->size)) { $q2['r'] = array('o' => ($params->page - 1) * $params->size, 'l' => $params->size); } $simpleMatters = $this->query_objs_ss($q1, $q2); foreach ($simpleMatters as $sm) { $fullMatter = \TMS_APP::M('matter\\' . $sm->matter_type)->byId($sm->matter_id); $fullMatter->type = $sm->matter_type; $fullMatter->add_at = $sm->create_at; $matters[] = $fullMatter; } } return $matters; }
/** * */ public function test_action($mpid, $order) { $order = \TMS_APP::model('app\\merchant\\order')->byId($order); $this->notify($mpid, $order); return new \ResponseData('ok'); }
/** * 扫描二维码事件 * * 企业号目前不支持场景二维码 * 由于目前易信的场景二维码客户端无法收到回复信息,因此改为推动客户消息替代 */ private function qrcode_call($call) { $mpa = \TMS_APP::G('mp\\mpaccount'); $mpid = $call['mpid']; $openid = $call['from_user']; $data = json_decode($call['data']); if ($reply = $this->model('reply')->qrcode_call($mpid, $data[1])) { if ($reply->expire_at > 0) { /** * 一次性二维码,用完后就删除 */ $this->model()->delete('xxt_call_qrcode', "id={$reply->id}"); } if ($mpa->mpsrc === 'wx') { $r = $this->model('reply\\' . $reply->matter_type, $call, $reply->matter_id); $r->exec(); } else { $setting = $this->model('mp\\mpaccount')->getSetting($mpid, 'yx_custom_push'); if ($setting->yx_custom_push === 'N') { return; } switch ($reply->matter_type) { case 'enrollsignin': // 登记活动签到 $r = $this->model('reply\\enrollsignin', $call, $reply->matter_id, false); $r2 = $r->exec(); if ($r2['matter_type'] === 'enroll') { $message = $this->model("matternroll")->forCustomPush($mpid, $r2['matter_id']); } else { if ($r2['matter_type'] === 'joinwall') { $r = new $this->model('reply\\joinwall', $call, $r2['matter_id']); $tip = $r->exec(false); if (!empty($tip)) { $message = array("msgtype" => "text", "text" => array("content" => $tip)); } } else { $message = $this->model('matter\\' . $r2['matter_type'])->forCustomPush($mpid, $r2['matter_id']); } } break; case 'joinwall': // 加入信息墙 $r = $this->model('reply\\joinwall', $call, $reply->matter_id); $tip = $r->exec(false); if (!empty($tip)) { $message = array("msgtype" => "text", "text" => array("content" => $tip)); } break; default: $message = $this->model('matter\\' . $reply->matter_type)->forCustomPush($mpid, $reply->matter_id); } /** * 发送消息 */ if (isset($message)) { $rst = $this->sendByOpenid($mpid, $openid, $message); if (false === $rst[0]) { $err = is_array($rst[1]) ? implode(',', $rst[1]) : $rst[1]; $tr = $this->model('reply\\text', $call, $err, false); $tr->exec(); } } } } }
/** * 创建活动页面 */ public function add($mpid, $aid, $data = null) { $uid = \TMS_CLIENT::get_client_uid(); $code = \TMS_APP::model('code/page')->create($uid); if (empty($data['seq'])) { $q = array('max(seq)', 'xxt_enroll_page', "aid='{$aid}'"); $seq = $this->query_val_ss($q); $seq = empty($seq) ? 1 : $seq + 1; } else { $seq = $data['seq']; } $newPage = array('mpid' => $mpid, 'aid' => $aid, 'creater' => $uid, 'create_at' => time(), 'type' => isset($data['type']) ? $data['type'] : 'V', 'title' => isset($data['title']) ? $data['title'] : '新页面', 'name' => isset($data['name']) ? $data['name'] : 'z' . time(), 'code_id' => $code->id, 'seq' => $seq); $apid = $this->insert('xxt_enroll_page', $newPage, true); $newPage['id'] = $apid; $newPage['html'] = ''; $newPage['css'] = ''; $newPage['js'] = ''; return (object) $newPage; }