/** * 创建抽奖页面 * * @param string $aid * @param string $type */ public function pageCreate_action($aid, $type = 'carousel') { $uid = \TMS_CLIENT::get_client_uid(); $modelCode = $this->model('code/page'); $code = $modelCode->create($uid); $this->model()->update('xxt_enroll', array('lottery_page_id' => $code->id), "id='{$aid}'"); $module = dirname(__FILE__) . '/module/lottery/' . $type; /*page*/ $data = array('html' => file_get_contents($module . '.html'), 'css' => file_get_contents($module . '.css'), 'js' => file_get_contents($module . '.js')); $modelCode->modify($code->id, $data); /*config*/ $config = file_get_contents($module . '.json'); $config = preg_replace('/\\t|\\r|\\n/', '', $config); $config = json_decode($config); if (!empty($config->extjs)) { foreach ($config->extjs as $js) { $modelCode->insert('xxt_code_external', array('code_id' => $code->id, 'type' => 'J', 'url' => $js), false); } } if (!empty($config->extcss)) { foreach ($config->extcss as $css) { $modelCode->insert('xxt_code_external', array('code_id' => $code->id, 'type' => 'C', 'url' => $css), false); } } return new \ResponseData($code->id); }
/** * 填加自定义认证接口 * 自定义认证接口只有在本地部署版本中才有效 */ public function create_action() { $uid = \TMS_CLIENT::get_client_uid(); $i = array('mpid' => $this->mpid, 'name' => '', 'type' => 'cus', 'valid' => 'N', 'creater' => $uid, 'create_at' => time(), 'entry_statement' => '无法确认您是否有权限进行该操作,请先完成【<a href="{{authapi}}">用户身份确认</a>】。', 'acl_statement' => '您的身份识别信息没有放入白名单中,请与系统管理员联系。', 'notpass_statement' => '您的邮箱还没有验证通过,若未收到验证邮件请联系系统管理员。若需要重发验证邮件,请先完成【<a href="{{authapi}}">用户身份确认</a>】。', 'url' => ''); $id = $this->model()->insert('xxt_member_authapi', $i, true); $q = array('*', 'xxt_member_authapi', "mpid='{$this->mpid}' and authid='{$id}'"); $api = $this->model()->query_obj_ss($q); return new \ResponseData($api); }
/** * 创建页面 */ public function add($mpid, $data, $wallId) { $uid = \TMS_CLIENT::get_client_uid(); $code = \TMS_APP::model('code/page')->create($uid); $newPage = array('mpid' => $mpid, 'wid' => $wallId, 'creater' => $uid, 'create_at' => time(), 'type' => $data['type'], 'name' => isset($data['name']) ? $data['name'] : '新页面', 'title' => isset($data['title']) ? $data['title'] : '新页面', 'seq' => $data['seq'], 'code_id' => $code->id); $pid = $this->insert('xxt_wall_page', $newPage, true); $newPage['id'] = $pid; return (object) $newPage; }
/** * */ public function update_action($id) { $reviser = \TMS_CLIENT::get_client_uid(); $nv = $this->getPostJson(); $nv->reviser = $reviser; $nv->modify_at = time(); $rst = $this->model()->update('xxt_merchant_group', (array) $nv, "id='{$id}'"); return new \ResponseData($rst); }
/** * 创建页面 */ public function add($mpid, $data, $shopId, $catelogId = 0, $productId = 0) { $uid = \TMS_CLIENT::get_client_uid(); $code = \TMS_APP::model('code/page')->create($uid); $newPage = array('mpid' => $mpid, 'sid' => $shopId, 'cate_id' => $catelogId, 'prod_id' => $productId, 'creater' => $uid, 'create_at' => time(), 'type' => $data['type'], 'name' => isset($data['name']) ? $data['name'] : '新页面', 'title' => isset($data['title']) ? $data['title'] : '新页面', 'seq' => $data['seq'], 'code_id' => $code->id); $apid = $this->insert('xxt_merchant_page', $newPage, true); $newPage['id'] = $apid; return (object) $newPage; }
/** * 创建菜单 */ public function &createButton($data) { $uid = \TMS_CLIENT::get_client_uid(); $data['creater'] = $uid; $data['create_at'] = time(); if ($rst = $this->insert('xxt_call_menu', $data, false)) { $rst = $this->getButtonById($data['mpid'], $data['menu_key']); } return $rst; }
/** * 创建新商店 */ public function create_action() { $account = \TMS_CLIENT::account(); if ($account === false) { return new \ResponseError('长时间未操作,请重新登陆!'); } $creater = \TMS_CLIENT::get_client_uid(); $creater_name = $account->nickname; $shop = array('mpid' => $this->mpid, 'create_at' => time(), 'creater' => $creater, 'creater_name' => $creater_name, 'title' => '新商店', 'pic' => '', 'summary' => '新商店'); $shopId = $this->model()->insert('xxt_merchant_shop', $shop, true); return new \ResponseData($shopId); }
/** * 创建模板消息 */ public function create_action($title = '新模板消息') { $uid = \TMS_CLIENT::get_client_uid(); $d['mpid'] = $this->mpid; $d['creater'] = $uid; $d['create_at'] = time(); $d['title'] = $title; $id = $this->model()->insert('xxt_tmplmsg', $d, true); $q = array("t.*,a.nickname creater_name,'{$uid}' uid", 'xxt_tmplmsg t,account a', "t.id={$id} and t.creater=a.uid"); $tmplmsg = $this->model()->query_obj_ss($q); return new \ResponseData($tmplmsg); }
/** * 当前用户可见的所有公众号 */ public function mpaccounts_action($pmpid = null, $asparent = 'N') { /** * 当前用户是公众号的创建人或者被授权人 */ $uid = \TMS_CLIENT::get_client_uid(); $w = "a.asparent='{$asparent}' and a.state=1 and (a.creater='{$uid}' \n or exists(\n select 1\n from xxt_mpadministrator ma\n where a.mpid=ma.mpid and ma.uid='{$uid}'\n )\n or exists(\n select 1\n from xxt_mppermission p\n where a.mpid=p.mpid and p.uid='{$uid}'\n ))" . (empty($pmpid) ? '' : " and parent_mpid='{$pmpid}'"); $q = array('parent_mpid,mpid,asparent,name,create_at,yx_joined,wx_joined,qy_joined', 'xxt_mpaccount a', $w); $q2 = array('o' => 'create_at desc'); $mps = $this->model()->query_objs_ss($q, $q2); return new \ResponseData($mps); }
/** * * $mpid * $matterId * $matterType */ public function putMatter($mpid, $matter) { if ($item = $this->byMatter($matter->matter_id, $matter->matter_type)) { return false; } $uid = \TMS_CLIENT::get_client_uid(); $uname = \TMS_CLIENT::account()->nickname; $current = time(); $item = array('creater' => $uid, 'creater_name' => $uname, 'put_at' => $current, 'mpid' => $mpid, 'matter_type' => $matter->matter_type, 'matter_id' => $matter->matter_id, 'title' => $matter->title, 'pic' => $matter->pic, 'summary' => $matter->summary); $id = $this->insert('xxt_shop_matter', $item, true); $item = $this->byId($id); return $item; }
/** * 是否为账号管理员 */ public function isCreater($mpid = null, $uid = null) { empty($mpid) && ($mpid = \TMS_APP::S('mpid')); empty($uid) && ($uid = \TMS_CLIENT::get_client_uid()); /** * 账号的创建人 */ $mpcreater = $this->query_value('creater', 'xxt_mpaccount', "mpid='{$mpid}'"); if ($uid === $mpcreater) { return true; } return false; }
/** * 创建文本素材 */ public function create_action() { $uid = \TMS_CLIENT::get_client_uid(); $text = $this->getPostJson(); $d = array(); $d['mpid'] = $this->mpid; $d['creater'] = $uid; $d['create_at'] = time(); $d['content'] = $this->model()->escape($text->content); $id = $this->model()->insert('xxt_text', $d, true); $q = array("t.*,a.nickname creater_name,'{$uid}' uid", 'xxt_text t,account a', "id='{$id}' and t.creater=a.uid"); $text = $this->model()->query_obj_ss($q); return new \ResponseData($text); }
/** * 创建一个讨论组 */ public function create_action() { $wid = uniqid(); $newone['id'] = $wid; $newone['mpid'] = $this->mpid; $newone['title'] = '新信息墙'; $newone['creater'] = \TMS_CLIENT::get_client_uid(); $newone['create_at'] = time(); $newone['quit_cmd'] = 'q'; $newone['join_reply'] = '欢迎加入'; $newone['quit_reply'] = '已经退出'; $this->model()->insert('xxt_wall', $newone, false); return new \ResponseData($wid); }
/** * 记录所有发送给用户的消息 */ public function send($mpid, $openid, $groupid, $content, $matter) { $i['mpid'] = $mpid; $i['creater'] = TMS_CLIENT::get_client_uid(); $i['create_at'] = time(); !empty($openid) && ($i['openid'] = $openid); !empty($groupid) && ($i['groupid'] = $groupid); !empty($content) && ($i['content'] = $this->escape($content)); if (!empty($matter)) { $i['matter_id'] = $matter->id; $i['matter_type'] = $matter->type; } $this->insert('xxt_log_mpsend', $i, false); return true; }
/** * 创建一个投稿活动 */ public function create_action() { $uid = \TMS_CLIENT::get_client_uid(); /** * 获得的基本信息 */ $cid = uniqid(); $newone['mpid'] = $this->mpid; $newone['id'] = $cid; $newone['title'] = '新投稿活动'; $newone['creater'] = $uid; $newone['create_at'] = time(); $this->model()->insert('xxt_contribute', $newone, false); $c = $this->model('app\\contribute')->byId($cid); return new \ResponseData($c); }
/** * 获得符合条件的资源对象 * * $res_type * $tag_ids the res has at least one of the tag. * $offset * $limit * */ public function get_res($res_type, $tag_ids, $offset = 0, $limit = 25) { $begin = round(microtime(true) * 1000); $user_id = TMS_CLIENT::get_client_uid(); is_array($tag_ids) && ($tag_ids = explode(',', $tag_ids)); $sql = 'select SQL_CALC_FOUND_ROWS res_id'; $sql .= ',count(distinct tag_id) matched'; $sql .= ',count(distinct creater) weight'; $sql .= ' from mail_tag2res'; $sql .= " where tag_id in ({$tag_ids})"; $sql .= " and res_type={$res_type}"; $sql .= ' group by res_id'; $sql .= ' order by matched desc, weight desc, max(create_time) desc'; $sql .= " limit {$offset},{$limit}"; $result['res'] = parent::query_objs($sql); $result['foundRows'] = parent::found_rows(); $end = round(microtime(true) * 1000); AppLog('mail_tag::get_res - time:' . ($end - $begin) . 'ms.'); AppLog('mail_tag::get_res - sql:' . $sql); return $result; }
/** * 添加轮次 * * $aid */ public function add_action($aid) { if ($lastRound = $this->model('app\\enroll\\round')->getLast($this->mpid, $aid)) { /** * 检查或更新上一轮状态 */ if ((int) $lastRound->state === 0) { return new \ResponseError("最近一个轮次({$lastRound->title)是新建状态,不允许创建新轮次}"); } if ((int) $lastRound->state === 1) { $this->model()->update('xxt_enroll_round', array('state' => 2), "mpid='{$this->mpid}' and aid='{$aid}' and rid='{$lastRound->rid}'"); } } $posted = $this->getPostJson(); $roundId = uniqid(); $round = array('mpid' => $this->mpid, 'aid' => $aid, 'rid' => $roundId, 'creater' => \TMS_CLIENT::get_client_uid(), 'create_at' => time(), 'title' => $posted->title, 'state' => $posted->state); $this->model()->insert('xxt_enroll_round', $round, false); if ($lastRound === false) { $this->model()->update('xxt_enroll', array('multi_rounds' => 'Y'), "mpid='{$this->mpid}' and id='{$aid}'"); } $q = array('*', 'xxt_enroll_round', "mpid='{$this->mpid}' and aid='{$aid}' and rid='{$roundId}'"); $round = $this->model()->query_obj_ss($q); return new \ResponseData($round); }
/** * 创建通讯录 */ public function create_action($title = '新通讯录') { $uid = \TMS_CLIENT::get_client_uid(); $abid = $this->model('matter\\addressbook')->insert_ab($this->mpid, $uid, $title); return new \ResponseData($abid); }
/** * 群发消息到子公众号 * 需要开通高级接口 * * 开通了群发接口的微信和易信公众号 * 微信企业号 * 开通了点对点认证接口的易信公众号 */ public function mass2mps_action() { $matter = $this->getPostJson(); if (empty($matter->mps)) { return new \ResponseError('请指定接收消息的公众号'); } $uid = \TMS_CLIENT::get_client_uid(); $rst = $this->model('mp\\mpaccount')->mass2mps($uid, $matter->id, $matter->type, $matter->mps); return new \ResponseData($rst[1]); }
/** * */ private function update($id, $nv) { $account = \TMS_CLIENT::account(); if ($account === false) { return new \ResponseError('长时间未操作,请重新登陆!'); } $pmpid = $this->getParentMpid(); $nv['modifier'] = \TMS_CLIENT::get_client_uid(); $nv['modifier_src'] = 'A'; $nv['modifier_name'] = $account->nickname; $nv['modify_at'] = time(); $rst = $this->model()->update('xxt_article', $nv, "(mpid='{$this->mpid}' or mpid='{$pmpid}') and id='{$id}'"); return $rst; }
/** * 更改sku基本信息 * * @param int $sku product sku's id * @param object $data */ private function _skuUpdate($sku, $data) { $reviser = \TMS_CLIENT::get_client_uid(); $data->reviser = $reviser; $data->modify_at = time(); $rst = $this->model()->update('xxt_merchant_product_sku', (array) $data, "id={$sku}"); return new \ResponseData($rst); }
/** * 复制一个登记活动 */ public function copy_action($aid = null, $shopid = null) { $account = \TMS_CLIENT::account(); if ($account === false) { return new \ResponseError('长时间未操作,请重新登陆!'); } $uid = \TMS_CLIENT::get_client_uid(); $uname = $account->nickname; $current = time(); $enrollModel = $this->model('app\\enroll'); $codeModel = $this->model('code/page'); if (!empty($aid)) { $copied = $enrollModel->byId($aid); } else { if (!empty($shopid)) { $shopItem = $this->model('shop\\shelf')->byId($shopid); $aid = $shopItem->matter_id; $copied = $enrollModel->byId($aid); $copied->title = $shopItem->title; $copied->summary = $shopItem->summary; $copied->pic = $shopItem->pic; } else { return new \ResponseError('没有指定要复制登记活动id'); } } /** * 获得的基本信息 */ $newaid = uniqid(); $newact['mpid'] = $this->mpid; $newact['id'] = $newaid; $newact['creater'] = $uid; $newact['creater_src'] = 'A'; $newact['creater_name'] = $uname; $newact['create_at'] = $current; $newact['title'] = $copied->title . '(副本)'; $newact['pic'] = $copied->pic; $newact['summary'] = $copied->summary; $newact['public_visible'] = $copied->public_visible; $newact['open_lastroll'] = $copied->open_lastroll; $newact['can_signin'] = $copied->can_signin; $newact['can_lottery'] = $copied->can_lottery; $newact['tags'] = $copied->tags; $newact['enrolled_entry_page'] = $copied->enrolled_entry_page; $newact['receiver_page'] = $copied->receiver_page; $newact['entry_rule'] = json_encode($copied->entry_rule); if ($copied->mpid === $this->mpid) { $newact['access_control'] = $copied->access_control; $newact['authapis'] = $copied->authapis; $newact['success_matter_type'] = $copied->success_matter_type; $newact['success_matter_id'] = $copied->success_matter_id; $newact['failure_matter_type'] = $copied->failure_matter_type; $newact['failure_matter_id'] = $copied->failure_matter_id; } $this->model()->insert('xxt_enroll', $newact, false); /** * 复制自定义页面 */ if ($copied->pages) { $modelPage = $this->model('app\\enroll\\page'); foreach ($copied->pages as $ep) { $newPage = $modelPage->add($this->mpid, $newaid); $rst = $modelPage->update('xxt_enroll_page', array('title' => $ep->title, 'name' => $ep->name), "aid='{$newaid}' and id={$newPage->id}"); $data = array('title' => $ep->title, 'html' => $ep->html, 'css' => $ep->css, 'js' => $ep->js); $codeModel->modify($newPage->code_id, $data); } } if ($copied->mpid === $this->mpid) { /** * 复制所属频道 */ $sql = 'insert into xxt_channel_matter(channel_id,matter_id,matter_type,creater,creater_src,creater_name,create_at)'; $sql .= " select channel_id,'{$newaid}','enroll','{$uid}','A','{$uname}',{$current}"; $sql .= ' from xxt_channel_matter'; $sql .= " where matter_id='{$aid}' and matter_type='enroll'"; $this->model()->insert($sql, '', false); /** * 复制登记事件接收人 */ $sql = 'insert into xxt_enroll_receiver(mpid,aid,identity,idsrc)'; $sql .= " select '{$this->mpid}','{$newaid}',identity,idsrc"; $sql .= ' from xxt_enroll_receiver'; $sql .= " where aid='{$aid}'"; $this->model()->insert($sql, '', false); /** * 复制ACL */ $sql = 'insert into xxt_matter_acl(mpid,matter_type,matter_id,identity,idsrc,label)'; $sql .= " select '{$this->mpid}',matter_type,'{$newaid}',identity,idsrc,label"; $sql .= ' from xxt_matter_acl'; $sql .= " where matter_id='{$aid}'"; $this->model()->insert($sql, '', false); } $act = $enrollModel->byId($newaid); return new \ResponseData($act); }
/** * */ public function addMatter_action() { $account = \TMS_CLIENT::account(); if ($account === false) { return new \ResponseError('长时间未操作,请重新登陆!'); } $relations = $this->getPostJson(); $creater = \TMS_CLIENT::get_client_uid(); $createrName = $account->nickname; $channels = $relations->channels; $matter = $relations->matter; $model = $this->model('matter\\channel'); foreach ($channels as $channel) { $model->addMatter($channel->id, $matter, $creater, $createrName); } return new \ResponseData('success'); }
/** * 添加系统管理员 */ public function addAdmin_action($authedid = null, $authapp = '', $autoreg = 'N') { if (empty($authedid) && defined('TMS_APP_ADDON_EXTERNAL_ORG')) { return new \ResponseData(array('externalOrg' => TMS_APP_ADDON_EXTERNAL_ORG)); } $model = $this->model('account'); $account = $model->getAccountByAuthedId($authedid); if (!$account) { if ($autoreg !== 'Y') { return new \ResponseError('指定的账号不是注册账号,请先注册!'); } else { $account = $model->authed_from($authedid, $authapp, '0.0.0.0', $authedid); } } /** * exist? */ $q = array('count(*)', 'xxt_mpadministrator', "mpid='{$this->mpid}' and uid='{$account->uid}'"); if ((int) $this->model()->query_val_ss($q) > 0) { return new \ResponseError('该账号已经是系统管理员,不能重复添加!'); } $uid = \TMS_CLIENT::get_client_uid(); $this->model()->insert('xxt_mpadministrator', array('mpid' => $this->mpid, 'uid' => $account->uid, 'creater' => $uid, 'create_at' => time()), false); return new \ResponseData(array('uid' => $account->uid, 'authed_id' => $authedid)); }
/** * 创建活动页面 */ 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; }
/** * */ public function pageSet_action($lid, $pageid, $pattern) { $codeModel = $this->model('code/page'); if ($pageid) { $page = $codeModel->byId($pageid); } else { /** * 创建定制页 */ $uid = \TMS_CLIENT::get_client_uid(); $page = $codeModel->create($uid); $this->model()->update('xxt_lottery', array('page_id' => $page->id), "id='{$lid}'"); } $data = array('html' => file_get_contents(dirname(__FILE__) . '/pattern/' . $pattern . '.html'), 'css' => file_get_contents(dirname(__FILE__) . '/pattern/' . $pattern . '.css'), 'js' => file_get_contents(dirname(__FILE__) . '/pattern/' . $pattern . '.js')); $rst = $codeModel->modify($page->id, $data); return new \ResponseData($rst); }
/** * * return 32bit */ protected static function uuid($prefix) { !$prefix && ($prefix = TMS_CLIENT::get_client_uid()); return md5(uniqid($prefix) . mt_rand()); }
/** * 创建一个多图文素材 */ public function create_action() { $account = \TMS_CLIENT::account(); if ($account === false) { return new \ResponseError('长时间未操作,请重新登陆!'); } $uid = \TMS_CLIENT::get_client_uid(); $news = $this->getPostJson(); $d = array(); $d['mpid'] = $this->mpid; $d['creater'] = $uid; $d['create_at'] = time(); $d['creater_src'] = 'A'; $d['creater_name'] = $account->nickname; $d['title'] = isset($news->title) ? $news->title : '新多图文'; $id = $this->model()->insert('xxt_news', $d, true); /** * matters */ isset($news->matters) && $this->assign_news_matter($id, $news->matters); $news = $this->model('matter\\news')->byId($id); return new \ResponseData($news); }
/** * 更新分类的基础信息 * * @param int $catelog * @param object $data */ private function _update($catelogId, $data) { $reviser = \TMS_CLIENT::get_client_uid(); $data->reviser = $reviser; $data->modify_at = time(); $rst = $this->model()->update('xxt_merchant_catelog', (array) $data, "id={$catelogId}"); return new \ResponseData($rst); }
/** * 定义分类下的sku * * @param string @mpid * @param string @shopId * @param string @catelogId * @param object @data */ public function &defineSku($mpid, $shopId, $catelogId, $data) { $sku = new \stdClass(); $current = time(); $uid = \TMS_CLIENT::get_client_uid(); $lastSeq = $this->getSkuLastSeq($catelogId); empty($lastSeq) && ($lastSeq = -1); $sku->mpid = $mpid; $sku->sid = $shopId; $sku->cate_id = $catelogId; $sku->creater = $uid; $sku->create_at = $current; $sku->reviser = $uid; $sku->modify_at = $current; $sku->name = $data->name; $sku->has_validity = isset($data->has_validity) ? $data->has_validity : 'N'; $sku->require_pay = isset($data->require_pay) ? $data->require_pay : 'N'; $sku->seq = $lastSeq + 1; $sku->id = $this->insert('xxt_merchant_catelog_sku', (array) $sku, true); return $sku; }