Example #1
0
 /**
  * 创建抽奖页面
  *
  * @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);
 }
Example #2
0
 /**
  * 创建页面
  */
 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;
 }
Example #3
0
 /**
  * 创建页面
  */
 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;
 }
Example #4
0
 /**
  *
  */
 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);
 }
Example #5
0
 /**
  * 填加自定义认证接口
  * 自定义认证接口只有在本地部署版本中才有效
  */
 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);
 }
Example #6
0
 /**
  * 创建菜单
  */
 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;
 }
Example #7
0
 /**
  * 当前用户可见的所有公众号
  */
 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);
 }
Example #8
0
 /**
  * 创建新商店
  */
 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);
 }
Example #9
0
 /**
  * 创建模板消息
  */
 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);
 }
Example #10
0
 /**
  *
  * $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;
 }
Example #11
0
 /**
  * 是否为账号管理员
  */
 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;
 }
Example #12
0
 /**
  * 获得当前用户的ID
  *
  * 先通过session获得uid
  * 若取不到再通过cookie获得uid
  */
 public static function get_client_uid()
 {
     if (isset($_SESSION['account_info'])) {
         return $_SESSION['account_info']->uid;
     } else {
         if (isset($_COOKIE[G_COOKIE_PREFIX . "_user_login"])) {
             $sso = TMS_CLIENT::decode_hash($_COOKIE[G_COOKIE_PREFIX . "_user_login"]);
             if ($sso['uid'] && $_SERVER['HTTP_USER_AGENT'] == $sso['UA']) {
                 return $sso['uid'];
             }
         }
     }
     return false;
 }
Example #13
0
 /**
  * 创建一个讨论组
  */
 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);
 }
Example #14
0
 /** 
  * 创建文本素材
  */
 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);
 }
Example #15
0
 /**
  * 记录所有发送给用户的消息
  */
 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;
 }
Example #16
0
 /**
  * 创建一个投稿活动
  */
 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);
 }
Example #17
0
 /**
  * 验证通过后的回调页面 
  */
 public function passed_action($uid)
 {
     $fromip = $this->client_ip();
     $this->model('account')->update_last_login($uid, $fromip);
     /**
      * record account into session and cookie.
      */
     $act = $this->model('account')->byId($uid);
     /**
      * 记录客户端登陆状态
      */
     \TMS_CLIENT::account($act);
     /**
      * 跳转到缺省页
      */
     $this->redirect(TMS_APP_AUTHED);
 }
Example #18
0
 /**
  * 获得符合条件的资源对象
  *
  * $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;
 }
Example #19
0
 /**
  * 修改当前用户的口令
  */
 public function changePwd_action()
 {
     $account = \TMS_CLIENT::account();
     if ($account === false) {
         return new \ResponseError('长时间未操作,请重新登陆!');
     }
     $data = $this->getPostJson();
     /**
      * check old password
      */
     $old_pwd = $data->opwd;
     $result = $this->model('account')->validate($account->email, $old_pwd);
     if ($result->err_code != 0) {
         return $result;
     }
     /**
      * set new password
      */
     $new_pwd = $data->npwd;
     $this->model('account')->change_password($account->email, $new_pwd, $account->salt);
     return new \ResponseData($account->uid);
 }
Example #20
0
 /**
  * 添加轮次
  *
  * $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);
 }
Example #21
0
 /**
  *
  */
 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);
 }
Example #22
0
 /**
  *
  * return 32bit
  */
 protected static function uuid($prefix)
 {
     !$prefix && ($prefix = TMS_CLIENT::get_client_uid());
     return md5(uniqid($prefix) . mt_rand());
 }
Example #23
0
 /**
  * 更新分类的基础信息
  *
  * @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);
 }
Example #24
0
 /**
  *
  */
 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');
 }
Example #25
0
 /**
  * 是否已经登录?
  *
  * 允许通过http_auth登录
  *
  */
 private static function _login()
 {
     // directly visit, no login process.
     // analyze the PHP_AUTH_DIGEST variable
     // user exist?
     if (isset($_SERVER['PHP_AUTH_DIGEST'])) {
         if ($data = self::http_digest_parse($_SERVER['PHP_AUTH_DIGEST'])) {
             $email = $data['username'];
             $account = self::model('account')->get_account_by_email($email);
             if (!$account) {
                 return false;
             }
             session_destroy();
             TMS_CLIENT::account($account);
             return true;
         }
     }
     return false;
 }
Example #26
0
 /**
  * 复制一个登记活动
  */
 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);
 }
Example #27
0
 /**
  * 创建活动页面
  */
 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;
 }
Example #28
0
 /**
  * 添加系统管理员
  */
 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));
 }
Example #29
0
 /**
  * 定义分类下的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;
 }
Example #30
0
 /**
  * 创建一个多图文素材
  */
 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);
 }