Example #1
0
 public function index()
 {
     $page = isset($_REQUEST['page']) && $_REQUEST['page'] >= 1 ? $_REQUEST['page'] : 1;
     $pageLimit = 15;
     $auModel = D('AdminUsers');
     $arModel = D('AdminRole');
     $aurModel = D('AdminUserRole');
     $localTimeObj = LocalTime::getInstance();
     $params = array();
     $res = $auModel->getAdmins($params, array('begin' => ($page - 1) * $pageLimit, 'offset' => $pageLimit));
     $users = array();
     foreach ($res['data'] as $rs) {
         $roles = $aurModel->getUserRole($rs['user_id']);
         $rs['roles'] = array();
         if (is_array($roles)) {
             foreach ($roles as $r) {
                 $rs['roles'][] = $arModel->info($r);
             }
         }
         $rs['last_login'] = $rs['last_login'] ? $localTimeObj->local_date($this->_CFG['time_format'], $rs['last_login']) : '从未登陆';
         $users[] = $rs;
     }
     $this->assign('users', $users);
     $page_url = "?g=" . GROUP_NAME . "&m=" . MODULE_NAME . "&a=" . ACTION_NAME . "&page=[page]";
     foreach ($params as $key => $val) {
         $page_url .= "&{$key}={$val}";
     }
     $p = new Page($page, $pageLimit, $res['count'], $page_url, 5, 5);
     $pagelink = $p->showStyle(3);
     $this->assign('pagelink', $pagelink);
     $this->assign('ur_href', '管理员管理 > 管理员列表');
     $this->assign('_hash_', buildFormToken());
     $this->display();
 }
 public function index()
 {
     $localTimeObj = LocalTime::getInstance();
     $page = isset($_REQUEST['page']) && $_REQUEST['page'] >= 1 ? $_REQUEST['page'] : 1;
     $pageLimit = 15;
     $ccmModel = D('TaoShop');
     $params = array('cid' => isset($_REQUEST['cid']) && $_REQUEST['cid'] ? intval($_REQUEST['cid']) : 0, 'kw' => isset($_REQUEST['kw']) && $_REQUEST['kw'] ? $_REQUEST['kw'] : '', 'is_active' => $this->_is_active);
     $keys = array();
     $res = $ccmModel->getAll($keys, $params, array('begin' => ($page - 1) * $pageLimit, 'offset' => $pageLimit));
     $shops = array();
     foreach ($res['data'] as $rs) {
         $rs['updatetime'] = $rs['updatetime'] ? $localTimeObj->local_strtotime($rs['updatetime']) : '';
         $shops[] = $rs;
     }
     $this->assign('shops', $shops);
     $page_url = "?g=" . GROUP_NAME . "&m=" . MODULE_NAME . "&a=" . ACTION_NAME . "&page=[page]";
     unset($params['is_active']);
     foreach ($params as $key => $val) {
         $page_url .= "&{$key}={$val}";
     }
     $p = new Page($page, $pageLimit, $res['count'], $page_url, 5, 5);
     $pagelink = $p->showStyle(3);
     $this->assign('pagelink', $pagelink);
     $category = array();
     $cccService = service('TaoShopCategory');
     $data = $cccService->getTree();
     foreach ($data as $rs) {
         $category[$rs['id']] = $rs;
         $category[$rs['id']]['prefix'] = str_repeat("    ", $rs['level']);
     }
     $this->assign('category', $category);
     $this->assign('ur_href', '淘宝店铺管理 > 店铺列表');
     $this->assign('_hash_', buildFormToken());
     $this->display();
 }
 public function dopayment()
 {
     if ($this->isPost()) {
         C('TOKEN_ON', false);
         import('@.Com.payment.PaymentFactory');
         //订单号
         $out_trade_no = date('Ymdhis') . rand_string(4, 1);
         $subject = $this->_CFG['site_name'] . '会员充值';
         $body = '';
         $total_fee = floatval($_REQUEST['amount']);
         $show_url = 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__;
         if ($this->_CFG['alipay_type'] == 'direct') {
             $pay_type = 'alipay';
             $status = 103;
         } else {
             if ($this->_CFG['alipay_type'] == 'warrant') {
                 $pay_type = 'AlipayWarrant';
                 $status = 103;
             }
         }
         $params = array('out_trade_no' => $out_trade_no, 'subject' => $subject, 'body' => $body, 'total_fee' => $total_fee, 'show_url' => $show_url);
         $data = array('user_id' => $this->_user['user_id'], 'nick' => $this->_user['nick'], 'out_trade_no' => $out_trade_no, 'amount' => $total_fee, 'content' => '在线充值', 'addtime' => LocalTime::getInstance()->gmtime(), 'status' => $status);
         M('payment')->add($data);
         $payment = PaymentFactory::getPayment($pay_type);
         $html_text = $payment->buildForm($params);
         $this->assign('form_html', $html_text);
         $this->assign('page_title', '在线充值 - ');
         $this->display();
     }
 }
Example #4
0
 public function index()
 {
     $page = isset($_REQUEST['page']) && $_REQUEST['page'] >= 1 ? $_REQUEST['page'] : 1;
     $pageLimit = 15;
     $localTimeObj = LocalTime::getInstance();
     $uModel = D('User');
     $params = array('nick' => isset($_REQUEST['nick']) && $_REQUEST['nick'] ? $_REQUEST['nick'] : '');
     $res = $uModel->getAll($params, array('begin' => ($page - 1) * $pageLimit, 'offset' => $pageLimit));
     $users = array();
     foreach ($res['data'] as $rs) {
         $rs['last_login'] = $localTimeObj->local_date($this->_CFG['time_format'], $rs['last_login']);
         $users[] = $rs;
     }
     $this->assign('users', $users);
     $page_url = "?g=" . GROUP_NAME . "&m=" . MODULE_NAME . "&a=" . ACTION_NAME . "&page=[page]";
     foreach ($params as $key => $val) {
         $page_url .= "&{$key}={$val}";
     }
     $p = new Page($page, $pageLimit, $res['count'], $page_url, 5, 5);
     $pagelink = $p->showStyle(3);
     $this->assign('pagelink', $pagelink);
     $this->assign('_hash_', buildFormToken());
     $this->assign('ur_href', '会员管理 > 会员列表');
     $this->display();
 }
 public function index()
 {
     $nick = isset($_REQUEST['nick']) && $_REQUEST['nick'] ? $_REQUEST['nick'] : '';
     $page = isset($_REQUEST['page']) && $_REQUEST['page'] >= 1 ? $_REQUEST['page'] : 1;
     $pageLimit = 15;
     $localTimeObj = LocalTime::getInstance();
     $status_conf = PaymentConf::status_conf();
     $where = "1=1";
     if ($nick) {
         $where .= " AND nick LIKE '%{$_REQUEST['nick']}%'";
     }
     $res = array('count' => 0, 'data' => array());
     $res['count'] = M('payment')->where($where)->count();
     $res['data'] = M('payment')->where($where)->order('id DESC')->limit(($page - 1) * $pageLimit . ",{$pageLimit}")->select();
     $records = array();
     foreach ($res['data'] as $rs) {
         $rs['addtime'] = $localTimeObj->local_date($this->_CFG['time_format'], $rs['addtime']);
         $rs['status_type'] = $status_conf[$rs['status']];
         $records[] = $rs;
     }
     $this->assign('records', $records);
     $page_url = "?g=" . GROUP_NAME . "&m=" . MODULE_NAME . "&a=" . ACTION_NAME . "&page=[page]&nick={$nick}";
     $p = new Page($page, $pageLimit, $res['count'], $page_url, 5, 5);
     $pagelink = $p->showStyle(3);
     $this->assign('pagelink', $pagelink);
     $this->assign('_hash_', buildFormToken());
     $this->assign('ur_href', '充值管理 > 充值记录');
     $this->display();
 }
 /**
  * 清除今日以前的临时文件
  *
  */
 public function clean()
 {
     if ($this->isPost() && $this->isAjax()) {
         if (C('TOKEN_ON') && !checkFormToken($_POST)) {
             die('hack attemp.');
         }
         @set_time_limit(3600);
         if (function_exists('ini_set')) {
             ini_set('max_execution_time', 3600);
             ini_set("memory_limit", "256M");
         }
         $localTimeObj = LocalTime::getInstance();
         $today = $localTimeObj->local_strtotime(date('Y-m-d 00:00:00'));
         $upload_path = DOC_ROOT_PATH . get_upload_path();
         $dir = $upload_path . 'temp/';
         $dirhandle = opendir($dir);
         while (($file = readdir($dirhandle)) !== false) {
             if ($file != "." && $file != "..") {
                 if (filemtime($dir . $file) < $today) {
                     if (is_dir($dir . $file)) {
                         del_dir($dir . $file);
                     } else {
                         @unlink($dir . $file);
                     }
                 }
             }
         }
         @closedir($dirhandle);
         $this->ajaxReturn('', buildFormToken(), 1);
     }
 }
Example #7
0
 public function click()
 {
     $id = intval($_REQUEST['ad_id']);
     $adModel = D('Ad');
     $ad_info = $adModel->info($id);
     $nowtime = LocalTime::getInstance()->gmtime();
     if (!$ad_info || $ad_info['end_time'] < $nowtime || $ad_info['enabled'] == 0) {
         exit("document.writeln('The adv is timeout');");
     }
     $adModel->update($id, array('click_count' => $ad_info['click_count'] + 1));
     redirect($ad_info['ad_link']);
 }
Example #8
0
 /**
  * 增加
  * @param int		$amount			数量
  * @param string	$type			类型
  * @return bool
  *
  */
 public static function increase($user_id, $amount, $type)
 {
     if (!self::check_type_valid($type)) {
         return -1;
     }
     $userModel = D('User');
     $user = $userModel->info($user_id, array($type));
     //更新本地积分或金钱
     $userModel->update($user_id, array($type => $user[$type] + $amount));
     //记录日志
     $data = array('user_id' => $user_id, 'type' => 'increase', 'money_type' => $type, 'amount' => $amount, 'addtime' => LocalTime::getInstance()->gmtime());
     M('consume_records')->add($data);
     return 1;
 }
Example #9
0
 public function index()
 {
     $page = isset($_REQUEST['p']) && $_REQUEST['p'] >= 1 ? $_REQUEST['p'] : 1;
     $pageLimit = 15;
     $addtime = 0;
     $cid = isset($_REQUEST['cid']) ? intval($_REQUEST['cid']) : 0;
     $t_type = isset($_REQUEST['t_type']) ? intval($_REQUEST['t_type']) : 0;
     $localTimeObj = LocalTime::getInstance();
     //商家分类
     $cccService = service('ZhekouCategory');
     $categorys = $cccService->getAll();
     $params = array('cate_id' => $cid);
     switch ($t_type) {
         case 1:
             $addtime = $localTimeObj->local_strtotime(date('Y-m-d 00:00:00'));
             break;
         case 2:
             $addtime = $localTimeObj->local_strtotime(date('Y-m-d 00:00:00', strtotime('-3 day')));
             break;
         case 3:
             $addtime = $localTimeObj->local_strtotime(date('Y-m-d 00:00:00', strtotime('-7 day')));
             break;
         case 4:
             $addtime = $localTimeObj->local_strtotime(date('Y-m-d 00:00:00', strtotime('-30 day')));
             break;
     }
     $params['addtime'] = $addtime;
     $limit = array('begin' => ($page - 1) * $pageLimit, 'offset' => $pageLimit);
     $codeMallModel = D('MallZhekou');
     $keys = array();
     $res = $codeMallModel->front($keys, $params, $limit);
     $zhekous = $res['data'];
     $this->assign('zhekous', $zhekous);
     $page_url = reUrl(MODULE_NAME . "/" . ACTION_NAME . "?cid={$cid}&t_type={$t_type}&p=[page]");
     $page_url = str_replace('%5bpage%5d', '[page]', $page_url);
     $p = new Page($page, $pageLimit, $res['count'], $page_url, 5, 5);
     $pagelink = $p->showStyle(3);
     $this->assign('pagelink', $pagelink);
     $this->assign('categorys', $categorys);
     $this->assign('cid', $cid);
     $this->assign('t_type', $t_type);
     $this->assign('page_title', '超值折扣 - ');
     $this->assign('page_keywords', $this->_CFG['site_keywords']);
     $this->assign('page_description', $this->_CFG['site_description']);
     $this->display();
 }
Example #10
0
 public function after_logined(array $user, $save = false)
 {
     if (!$user['user_id'] || !$user['nick']) {
         exit;
     }
     $uModel = D('User');
     $data = array('last_login' => LocalTime::getInstance()->gmtime(), 'last_ip' => get_client_ip());
     $uModel->update($user['user_id'], $data);
     //$_SESSION[C('SESSION_PREFIX') . 'user_id'] = $user_id;
     //$_SESSION[C('SESSION_PREFIX') . 'nick'] = $user_name;
     $life = 0;
     if ($save) {
         $life = 3600 * 24 * 30;
     }
     cookie('auth', authcode($user['user_id'] . "\t" . $user['nick'], 'ENCODE', C('AUTH')), array('expire' => $life));
     cookie('avatar', $user['avatar'], array('expire' => $life));
 }
 public function detail()
 {
     $id = intval($_REQUEST['id']);
     $proModel = D('MallPromotion');
     $promotion = $proModel->info(array(), $id);
     $promotion or die('id invliad.');
     import('@.Com.Util.Ubb');
     $promotion['detail'] = Ubb::ubb2html($promotion['detail']);
     $promotion['expiry'] = LocalTime::getInstance()->local_date($this->_CFG['date_format'], $promotion['expiry']);
     //商家分类
     $cccService = service('CouponCodeCategory');
     $cates = $cccService->getTree();
     $this->assign('promotion', $promotion);
     $this->assign('cates', $cates);
     $this->assign('page_title', $promotion['title'] . ' - 促销活动 - ');
     $this->assign('page_keywords', $this->_CFG['site_keywords']);
     $this->assign('page_description', $this->_CFG['site_description']);
     $this->display();
 }
Example #12
0
 /**
  * 默认操作
  * 
  */
 public function index()
 {
     $page = isset($_REQUEST['p']) && $_REQUEST['p'] >= 1 ? intval($_REQUEST['p']) : 1;
     $pageLimit = 20;
     $localTimeObj = LocalTime::getInstance();
     $today = $localTimeObj->local_strtotime(date('Y-m-d 23:59:59'));
     $limit = array('begin' => ($page - 1) * $pageLimit, 'offset' => $pageLimit);
     $codeModel = D('CouponCode');
     $res = $codeModel->front(array(), $limit);
     $codes = array();
     foreach ($res['data'] as $rs) {
         if ($rs['expiry_type'] == 1) {
             $rs['expiry_timestamp'] = $rs['expiry'] + $this->_CFG['timezone'] * 3600;
             if ($rs['expiry'] - $today == 0) {
                 $rs['expiry'] = 1;
             } else {
                 $rs['expiry'] = $rs['expiry'] - $today > 0 ? ceil(($rs['expiry'] - $today) / (3600 * 24)) : 0;
             }
         }
         $codes[] = $rs;
     }
     $this->assign('codes', $codes);
     $page_url = reUrl("Index/index?p=[page]");
     $page_url = str_replace('%5bpage%5d', '[page]', $page_url);
     $p = new Page($page, $pageLimit, $res['count'], $page_url, 5, 5);
     $pagelink = $p->showStyle(3);
     $this->assign('pagelink', $pagelink);
     //友情链接
     $friendlinks = array();
     $flService = service('FriendLinks');
     $res = $flService->getAll();
     if (is_array($res[101])) {
         foreach ($res[101] as $r) {
             $friendlinks[] = $res['all'][$r];
         }
     }
     $this->assign('friendlinks', $friendlinks);
     $this->assign('page_title', ' - ' . $this->_CFG['site_title']);
     $this->assign('page_keywords', $this->_CFG['site_keywords']);
     $this->assign('page_description', $this->_CFG['site_description']);
     $this->display();
 }
 public function add()
 {
     if ($this->isPost()) {
         if (C('TOKEN_ON') && !checkFormToken($_REQUEST, 'hash')) {
             die('hack attemp.');
         }
         if (!$_REQUEST['title'] || !$_REQUEST['cate_id'] || !$_REQUEST['gourl'] || !$_REQUEST['m_id'] || !$_REQUEST['description'] || !$_REQUEST['sort_order']) {
             $this->error('请填写所有的必填项');
         }
         if ($_FILES['logo']['size'] <= 0 && $_FILES['logo']['error'] > 0) {
             $this->error('请上传LOGO');
         }
         $logo = '';
         if ($_FILES['logo']['size'] > 0 && $_FILES['logo']['error'] == 0) {
             $upfile = array();
             $upfile = upload_one_file($_FILES['logo']);
             if ($upfile['error']) {
                 $this->error($upfile['error']);
             }
             $logo = $upfile['file_name'];
         }
         $localTimeObj = LocalTime::getInstance();
         $addtime = $localTimeObj->gmtime();
         $data = array('cate_id' => intval($_REQUEST['cate_id']), 'title' => $_REQUEST['title'], 'gourl' => $_REQUEST['gourl'], 'price' => floatval($_REQUEST['price']), 'description' => $_REQUEST['description'], 'm_id' => intval($_REQUEST['m_id']), 'm_name' => $_REQUEST['m_name'], 'logo' => $logo, 'sort_order' => intval($_REQUEST['sort_order']), 'use_coupon' => intval($_REQUEST['use_coupon']), 'addtime' => $addtime);
         $ccmModel = D('MallZhekou');
         if ($ccmModel->_add($data)) {
             $this->assign('jumpUrl', '?g=' . GROUP_NAME . '&m=' . MODULE_NAME);
             $this->success('添加成功');
         } else {
             $this->error('添加失败');
         }
     }
     $categorys = array();
     $service = service('ZhekouCategory');
     $categorys = $service->getAll();
     $this->assign('categorys', $categorys);
     $this->assign('ur_href', '折扣商品管理 &gt; 添加折扣商品');
     $this->assign('hash', buildFormToken('hash'));
     $this->display('post');
 }
Example #14
0
 /**
  * 领取优惠券
  *
  */
 public function pull()
 {
     if ($this->isAjax()) {
         $this->_check_login();
         $localTimeObj = LocalTime::getInstance();
         $nowtime = $localTimeObj->gmtime();
         $today = $localTimeObj->local_strtotime(date('Y-m-d 23:59:59'));
         $cccModel = D('CouponCodeCodes');
         $ip = get_client_ip();
         //同一IP领取数量限制
         $begin_time = $localTimeObj->local_strtotime(date('Y-m-d 00:00:00'));
         if ($this->_CFG['ip_fetch_limit'] && $cccModel->where("fetch_time>='{$begin_time}' AND fetch_time<='{$today}' AND ip='{$ip}'")->count() >= intval($this->_CFG['ip_fetch_limit'])) {
             $this->ajaxReturn('', '您今天领取的优惠券数量已超过限制,请明天再来', 0);
         }
         $c_id = intval($_REQUEST['c_id']);
         $c_id or die('id invalid.');
         $ccModel = D('CouponCode');
         $detail = $ccModel->info($c_id);
         $detail or die('id invalid.');
         if ($detail['is_active'] == 0) {
             $this->ajaxReturn('', '该优惠券已下架,请选择商家其他的优惠券', 0);
         }
         //是否过期
         if ($detail['expiry_type'] == 1 && $detail['expiry'] < $today) {
             $this->ajaxReturn('', '该优惠券已过期,请选择商家其他的优惠券', 0);
         }
         //剩余数量
         if ($detail['fetched_amount'] >= $detail['amount']) {
             $this->ajaxReturn('', '该优惠券已发放完毕,请选择其他的优惠券', 0);
         }
         //领取帐号限制
         if ($detail['data']['fetch_account_limit'] != 200 && intval($_SESSION['login_type']) != $detail['data']['fetch_account_limit']) {
             $fetch_account_limit_conf = CouponCodeConf::fetch_account_limit_conf();
             $this->ajaxReturn('', $fetch_account_limit_conf[$detail['data']['fetch_account_limit']], 0);
         }
         //领取数量限制
         //每个账户一张
         if ($detail['data']['fetch_limit'] == 101) {
             if ($cccModel->getOneByUid($this->_user['user_id'], $c_id)) {
                 $this->ajaxReturn('', '您已领取过该优惠券,请选择其他的优惠券', 0);
             }
         } else {
             if ($detail['data']['fetch_limit'] == 102) {
                 $b_time = $localTimeObj->local_strtotime(date('Y-m-d 00:00:00'));
                 $e_time = $today;
                 $params = array('b_time' => $b_time, 'e_time' => $e_time);
                 if ($cccModel->getOneByUid($this->_user['user_id'], $c_id, $params)) {
                     $this->ajaxReturn('', '您今天已领取过该优惠券,请选择其他的优惠券', 0);
                 }
             }
         }
         //付费情况
         if ($detail['price_type'] != 1) {
             $userModel = D('User');
             $user = $userModel->info($this->_user['user_id'], array('money', 'credit'));
             //付费
             if ($detail['price_type'] == 2) {
                 if ($user['money'] < $detail['price']) {
                     $this->ajaxReturn('', '您的账户金额不足,请先到帐号中心充值再来购买。请点击<a href="' . reUrl('Payment/pay') . '" target="_blank">在线充值</a>', 0);
                 }
                 $spend = Consume::spend($this->_user['user_id'], $detail['price'], Consume::TYPE_MONEY);
             } else {
                 if ($detail['price_type'] == 3) {
                     if ($user['credit'] < $detail['price']) {
                         $this->ajaxReturn('', '您的账户积分不足,请选择其他的优惠券', 0);
                     }
                     $spend = Consume::spend($this->_user['user_id'], $detail['price'], Consume::TYPE_CREDIT);
                 }
             }
             if ($spend !== 1) {
                 $this->ajaxReturn('', '支付失败,请重试', 0);
             }
         }
         $code = $cccModel->pull($c_id, $this->_user['user_id'], $this->_user['nick'], $nowtime, $ip);
         if ($code) {
             //更新领取数量
             $ccModel->update($c_id, array('fetched_amount' => $detail['fetched_amount'] + 1));
             //更新昨日、今日、本周、本月等领取数量
             $yestoday = $nowtime - 24 * 3600;
             $ccdModel = D('CouponCodeData');
             $r = $ccdModel->info($c_id, array('yesterdayfetched', 'dayfetched', 'weekfetched', 'monthfetched', 'updatetime'));
             $yesterdayfetched = date('Ymd', $r['updatetime']) == date('Ymd', $yestoday) ? $r['dayfetched'] : $r['yesterdayfetched'];
             $dayfetched = date('Ymd', $r['updatetime']) == date('Ymd', $nowtime) ? $r['dayfetched'] + 1 : 1;
             $weekfetched = date('YW', $r['updatetime']) == date('YW', $nowtime) ? $r['weekfetched'] + 1 : 1;
             $monthfetched = date('Ym', $r['updatetime']) == date('Ym', $nowtime) ? $r['monthfetched'] + 1 : 1;
             $data = array('yesterdayfetched' => $yesterdayfetched, 'dayfetched' => $dayfetched, 'weekfetched' => $weekfetched, 'monthfetched' => $monthfetched, 'updatetime' => $nowtime);
             $ccdModel->update($c_id, $data);
             //发表一条微博
             if ($this->_CFG['sina_wb_open'] && $_SESSION['sina']['token']['access_token'] || $this->_CFG['qq_open'] && $_SESSION['qq']["access_token"]) {
                 $ccmService = service('CouponCodeMall');
                 $mall = $ccmService->info($detail['m_id']);
                 $title = '';
                 if ($detail['title']) {
                     $title .= $detail['title'];
                 } else {
                     $title .= $mall['name'];
                     if ($detail['c_type'] == 1) {
                         $title .= '满' . $detail['money_max'] . '减' . $detail['money_reduce'] . '元优惠券';
                     } else {
                         $title .= $detail['money_amount'] . '元代金券';
                     }
                 }
                 $url = 'http://' . $_SERVER['HTTP_HOST'] . reUrl('Code/view?id=' . $c_id);
                 $pic_path = 'http://' . $_SERVER['HTTP_HOST'] . FixedUploadedFileUrl($mall['figure_image']);
                 $text = '我刚刚在#' . $this->_CFG['site_name'] . '#领取了一张【' . $title . '】,数量有限,抢完为止,一般人我不告诉!' . $url;
                 if ($this->_CFG['sina_wb_open'] && $_SESSION['sina']['token']['access_token']) {
                     include_once DOC_ROOT_PATH . 'Addons/plugins/login/sina.class.php';
                     $sina = new sina();
                     $sina->upload($text, $pic_path);
                 } else {
                     if ($this->_CFG['qq_open'] && $_SESSION['qq']["access_token"]) {
                         include_once DOC_ROOT_PATH . 'Addons/plugins/login/qq.class.php';
                         $qq = new qq();
                         //发送微博
                         $qq->add_t($text);
                         //发送空间分享
                         $title = '我刚刚在' . $this->_CFG['site_name'] . '领取了一张【' . $title . '】,数量有限,抢完为止,一般人我不告诉!';
                         $site = $_SERVER['HTTP_HOST'];
                         $qq->add_share($title, $url, $site, $pic_path);
                     }
                 }
             }
             $this->ajaxReturn($code, '领取成功', 1);
         } else {
             $this->ajaxReturn('', '领取失败', 0);
         }
     }
 }
Example #15
0
 /**
  * 编辑
  *
  */
 public function edit()
 {
     $adModel = D('Ad');
     $ad_id = intval($_REQUEST['ad_id']);
     if ($this->isPost()) {
         if (C('TOKEN_ON') && !checkFormToken($_REQUEST)) {
             die('hack attemp.');
         }
         if (!$_REQUEST['ad_name'] || !$_REQUEST['start_time'] || !$_REQUEST['end_time']) {
             die('data invalid.');
         }
         $media_type = intval($_REQUEST['media_type']);
         $localTimeObj = LocalTime::getInstance();
         $start_time = $localTimeObj->local_strtotime($_REQUEST['start_time']);
         $end_time = $localTimeObj->local_strtotime($_REQUEST['end_time']);
         $upload_path = get_upload_path();
         $file_prefix = 'http://' . $_SERVER['HTTP_HOST'] . __ROOT__ . '/' . $upload_path;
         $adModel = D('Ad');
         $data = array('ad_name' => $_REQUEST['ad_name'], 'media_type' => $media_type, 'position_id' => intval($_REQUEST['position_id']), 'enabled' => intval($_REQUEST['enabled']), 'start_time' => $start_time, 'end_time' => $end_time);
         //图片广告
         if ($media_type == 101) {
             if (!$_REQUEST['ad_link'] || !$_REQUEST['img_url'] && (!$_FILES['ad_img'] || $_FILES['ad_img']['size'] == 0 || $_FILES['ad_img']['error'] != 0)) {
                 die('data invalid.');
             }
             $data['ad_link'] = $_REQUEST['ad_link'];
             if ($_REQUEST['img_url']) {
                 $data['ad_code'] = str_replace($file_prefix, '', $_REQUEST['img_url']);
             }
             if ($_FILES['ad_img'] && $_FILES['ad_img']['size'] > 0 && $_FILES['ad_img']['error'] == 0) {
                 $upfile = array();
                 $upfile = upload_one_file($_FILES['ad_img']);
                 if ($upfile['error']) {
                     $this->error($upfile['error']);
                 }
                 $data['ad_code'] = $upfile['file_name'];
             }
         } elseif ($media_type == 102) {
             if (!$_REQUEST['flash_url'] && (!$_FILES['upfile_flash'] || $_FILES['upfile_flash']['size'] == 0 || $_FILES['upfile_flash']['error'] != 0)) {
                 die('data invalid.');
             }
             if ($_REQUEST['flash_url']) {
                 $data['ad_code'] = str_replace($file_prefix, '', $_REQUEST['flash_url']);
             }
             if ($_FILES['upfile_flash'] && $_FILES['upfile_flash']['size'] > 0 && $_FILES['upfile_flash']['error'] == 0) {
                 $upfile = array();
                 $upfile = upload_one_file($_FILES['upfile_flash']);
                 if ($upfile['error']) {
                     $this->error($upfile['error']);
                 }
                 $data['ad_code'] = $upfile['file_name'];
             }
         } elseif ($media_type == 103) {
             if (!$_REQUEST['ad_code']) {
                 die('data invalid.');
             }
             $data['ad_code'] = htmlentities($_REQUEST['ad_code']);
         } elseif ($media_type == 104) {
             if (!$_REQUEST['ad_link2'] || !$_REQUEST['ad_text']) {
                 die('data invalid.');
             }
             $data['ad_link'] = $_REQUEST['ad_link2'];
             $data['ad_code'] = $_REQUEST['ad_text'];
         }
         if ($adModel->editAd($ad_id, $data)) {
             //更新缓存
             $params = array('ad_id' => $ad_id);
             B('Adv', $params);
             $this->assign('jumpUrl', '?g=' . GROUP_NAME . '&m=' . MODULE_NAME);
             $this->success('编辑成功');
         } else {
             $this->error('编辑失败');
         }
     }
     $localTimeObj = LocalTime::getInstance();
     $ad = $adModel->info($ad_id);
     $ad['start_time'] = $localTimeObj->local_date($this->_CFG['time_format'], $ad['start_time']);
     $ad['end_time'] = $localTimeObj->local_date($this->_CFG['time_format'], $ad['end_time']);
     $upload_path = get_upload_path();
     if (is_file(DOC_ROOT_PATH . $upload_path . $ad['ad_code'])) {
         //$upload_path = str_replace('./','/',$upload_path);
         $ad['ad_code'] = 'http://' . $_SERVER['HTTP_HOST'] . FixedUploadedFileUrl($ad['ad_code']);
     }
     $this->assign('ad', $ad);
     $apModel = D('AdPosition');
     $res = $apModel->getPositions();
     $positions = array();
     foreach ($res as $rs) {
         $position = $apModel->info($rs['position_id']);
         $positions[] = $position;
     }
     $this->assign('positions', $positions);
     $this->assign('ad_media_type_conf', $this->_ad_media_type_conf);
     $this->assign('ur_href', '广告管理 &gt; 编辑广告');
     $this->assign('_hash_', buildFormToken());
     $this->display('post');
 }
Example #16
0
 /**
  * 领取优惠券
  *
  */
 public function pull()
 {
     if ($this->isAjax()) {
         $this->_check_login();
         $c_id = intval($_REQUEST['c_id']);
         $c_id or die('id invalid.');
         $ccModel = D('TaoCoupon');
         $detail = $ccModel->info($c_id);
         $detail or die('id invalid.');
         if ($detail['is_active'] == 0) {
             $this->ajaxReturn('', '该优惠券已下架,请选择商家其他的优惠券', 0);
         }
         $localTimeObj = LocalTime::getInstance();
         $nowtime = $localTimeObj->gmtime();
         $today = $localTimeObj->local_strtotime(date('Y-m-d 23:59:59'));
         //是否过期
         if ($detail['expiry_type'] == 1 && $detail['expiry'] < $today) {
             $this->ajaxReturn('', '该优惠券已过期,请选择商家其他的优惠券', 0);
         }
         //剩余数量
         /*
         if($detail['fetched_amount'] >= $detail['amount']){
         	$this->ajaxReturn('', '该优惠券已发放完毕,请选择其他的优惠券', 0);
         }
         */
         //领取限制
         $ccrModel = M('TaoCouponRecords');
         //每个账户一张
         if ($detail['data']['fetch_limit'] == 101) {
             if ($ccrModel->field('id')->where("c_id='{$c_id}' AND user_id='" . $this->_user['user_id'] . "'")->find()) {
                 $this->ajaxReturn('', '您已领取过该优惠券,请选择其他的优惠券', 0);
             }
         } else {
             if ($detail['data']['fetch_limit'] == 102) {
                 $b_time = $localTimeObj->local_strtotime(date('Y-m-d 00:00:00'));
                 $e_time = $today;
                 $where = "c_id='{$c_id}' AND user_id='" . $this->_user['user_id'] . "'";
                 $where .= " AND fetch_time>='{$b_time}' AND fetch_time<='{$e_time}'";
                 if ($ccrModel->field('id')->where($where)->find()) {
                     $this->ajaxReturn('', '您今天已领取过该优惠券,请选择其他的优惠券', 0);
                 }
             }
         }
         //付费情况
         if ($detail['price_type'] != 1) {
             $userModel = D('User');
             $user = $userModel->info($this->_user['user_id'], array('money', 'credit'));
             //付费
             if ($detail['price_type'] == 2) {
                 if ($user['money'] < $detail['price']) {
                     $this->ajaxReturn('', '您的账户金额不足,请先到帐号中心充值再来购买。请点击<a href="' . reUrl('Payment/pay') . '" target="_blank">在线充值</a>', 0);
                 }
                 $spend = Consume::spend($this->_user['user_id'], $detail['price'], Consume::TYPE_MONEY);
             } else {
                 if ($detail['price_type'] == 3) {
                     if ($user['credit'] < $detail['price']) {
                         $this->ajaxReturn('', '您的账户积分不足,请选择其他的优惠券', 0);
                     }
                     $spend = Consume::spend($this->_user['user_id'], $detail['price'], Consume::TYPE_CREDIT);
                 }
             }
             if ($spend !== 1) {
                 $this->ajaxReturn('', '支付失败,请重试', 0);
             }
         }
         $data = array('c_id' => $c_id, 'user_id' => $this->_user['user_id'], 'nick' => $this->_user['nick'], 'fetch_time' => $nowtime);
         $result = $ccrModel->add($data);
         if ($result) {
             $ccmService = service('TaoShop');
             $shop = $ccmService->info($detail['s_id']);
             //更新领取数量
             $ccModel->update($c_id, array('fetched_amount' => $detail['fetched_amount'] + 1));
             //更新昨日、今日、本周、本月等领取数量
             $yestoday = $nowtime - 24 * 3600;
             $ccdModel = D('TaoCouponData');
             $r = $ccdModel->info($c_id, array('yesterdayfetched', 'dayfetched', 'weekfetched', 'monthfetched', 'updatetime'));
             $yesterdayfetched = date('Ymd', $r['updatetime']) == date('Ymd', $yestoday) ? $r['dayfetched'] : $r['yesterdayfetched'];
             $dayfetched = date('Ymd', $r['updatetime']) == date('Ymd', $nowtime) ? $r['dayfetched'] + 1 : 1;
             $weekfetched = date('YW', $r['updatetime']) == date('YW', $nowtime) ? $r['weekfetched'] + 1 : 1;
             $monthfetched = date('Ym', $r['updatetime']) == date('Ym', $nowtime) ? $r['monthfetched'] + 1 : 1;
             $data = array('yesterdayfetched' => $yesterdayfetched, 'dayfetched' => $dayfetched, 'weekfetched' => $weekfetched, 'monthfetched' => $monthfetched, 'updatetime' => $nowtime);
             $ccdModel->update($c_id, $data);
             //发表一条微博
             if ($this->_CFG['sina_wb_open'] && $_SESSION['sina']['token']['access_token'] || $this->_CFG['qq_open'] && $_SESSION['qq']["access_token"]) {
                 $title = '';
                 if ($detail['title']) {
                     $title .= $detail['title'];
                 } else {
                     $title .= $detail['s_title'];
                     if ($detail['c_type'] == 1) {
                         $title .= '满' . $detail['money_max'] . '减' . $detail['money_reduce'] . '元优惠券';
                     } else {
                         $title .= $detail['money_amount'] . '元代金券';
                     }
                 }
                 $url = 'http://' . $_SERVER['HTTP_HOST'] . reUrl('Tao/show?id=' . $c_id);
                 $pic_path = tao_shop_logo($shop['pic_path']);
                 $text = '我刚刚在#' . $this->_CFG['site_name'] . '#领取了一张【' . $title . '】,数量有限,抢完为止,一般人我不告诉!' . $url;
                 if ($this->_CFG['sina_wb_open'] && $_SESSION['sina']['token']['access_token']) {
                     include_once DOC_ROOT_PATH . 'Addons/plugins/login/sina.class.php';
                     $sina = new sina();
                     $sina->upload($text, $pic_path);
                 } else {
                     if ($this->_CFG['qq_open'] && $_SESSION['qq']["access_token"]) {
                         include_once DOC_ROOT_PATH . 'Addons/plugins/login/qq.class.php';
                         $qq = new qq();
                         //发送微博
                         $qq->add_t($text);
                         //发送空间分享
                         $title = '我刚刚在' . $this->_CFG['site_name'] . '领取了一张【' . $title . '】,数量有限,抢完为止,一般人我不告诉!';
                         $site = $_SERVER['HTTP_HOST'];
                         $qq->add_share($title, $url, $site, $pic_path);
                     }
                 }
             }
             if ($detail['data']['fetch_link']) {
                 $coupon_url = $detail['data']['fetch_link'];
             } else {
                 $coupon_url = 'http://ecrm.taobao.com/shopbonusapply/buyer_apply.htm?activity_id=' . $detail['data']['activity_id'] . '&seller_id=' . $detail['data']['seller_id'];
             }
             $data = array('shop_click_url' => $shop['shop_click_url'], 'coupon_url' => $coupon_url);
             $this->ajaxReturn($data, '领取成功', 1);
         } else {
             $this->ajaxReturn('', '领取失败', 0);
         }
     }
 }
 private function _import_coupons_101_handler($m_id, $m_name, $file)
 {
     ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . LIB_PATH . "ORG/phpExcel/");
     ini_set('zend.ze1_compatibility_mode', 0);
     /** PHPExcel */
     include "PHPExcel.php";
     require_once 'PHPExcel/IOFactory.php';
     /**默认用excel2007读取excel,若格式不对,则用之前的版本进行读取*/
     require_once 'PHPExcel/Reader/Excel2007.php';
     $objReader = PHPExcel_IOFactory::createReader('Excel2007');
     //use excel2007 for 2007 format
     if (!$objReader->canRead($file)) {
         require_once 'PHPExcel/Reader/Excel5.php';
         $objReader = PHPExcel_IOFactory::createReader('Excel5');
         if (!$objReader->canRead($file)) {
             exit('no Excel');
         }
     }
     $objReader->setReadDataOnly(true);
     $objPHPExcel = $objReader->load($file);
     $codes = $objPHPExcel->getSheet(0)->toArray();
     $localTimeobj = LocalTime::getInstance();
     $coupons = array();
     for ($k = 0; $k < count($codes); $k++) {
         if ($k == 0) {
             continue;
         }
         $data = $extra = array();
         //类型
         //辅食满300元减100元无限制
         $mode = "/(.*)满([0-9]+)元减([0-9]+)(元|代金券)(.*)/is";
         if (preg_match($mode, $codes[$k][3], $arr)) {
             $data['c_type'] = 1;
             $data['money_max'] = $arr[2];
             $data['money_reduce'] = $arr[3];
             $data['title'] = $arr[0];
         }
         //满88减8代金券
         $mode = "/(.*)满([0-9]+)减([0-9]+)(元|代金券)(.*)/is";
         if (preg_match($mode, $codes[$k][3], $arr)) {
             $data['c_type'] = 1;
             $data['money_max'] = $arr[2];
             $data['money_reduce'] = $arr[3];
             $data['title'] = $arr[0];
         }
         //699-100,1000-200所有童装
         $mode = "/^([0-9]+)-([0-9]+)(.*)/is";
         if (preg_match($mode, $codes[$k][3], $arr)) {
             $data['c_type'] = 1;
             $data['money_max'] = $arr[1];
             $data['money_reduce'] = $arr[2];
             $data['title'] = $arr[0];
         }
         //通用1000-200所有童装
         $mode = "/^([A-Za-z\\x{4e00}-\\x{9fa5}]+)([0-9]+)-([0-9]+)(.*)/uis";
         if (preg_match($mode, $codes[$k][3], $arr)) {
             $data['c_type'] = 1;
             $data['money_max'] = $arr[2];
             $data['money_reduce'] = $arr[3];
             $data['title'] = $arr[0];
         }
         //100元无限制
         $mode = "/^([0-9]+)元(.*)/is";
         if (preg_match($mode, $codes[$k][3], $arr)) {
             $data['c_type'] = 2;
             $data['money_amount'] = $arr[1];
             $data['title'] = $arr[0];
         }
         //通用100元无限制
         $mode1 = "/(.*)满([0-9]+)元减([0-9]+)(元|代金券)(.*)/is";
         $mode = "/^([A-Za-z\\x{4e00}-\\x{9fa5}]+)([0-9]+)元(.*)/uis";
         if (!preg_match($mode1, $codes[$k][3], $arr) && preg_match($mode, $codes[$k][3], $arr)) {
             $data['c_type'] = 2;
             $data['money_amount'] = $arr[2];
             $data['title'] = $arr[0];
         }
         if (!isset($data['c_type'])) {
             continue;
         }
         //商家
         $data['m_id'] = $m_id;
         $data['m_name'] = $m_name;
         //领取限制
         $extra['fetch_limit'] = 101;
         //付费
         $data['price_type'] = 1;
         //有效期
         if ($codes[$k][6]) {
             $data['expiry_type'] = 1;
             $data['expiry'] = $localTimeobj->local_strtotime($codes[$k][6] . ' 23:59:59');
         } else {
             $data['expiry_type'] = 2;
             $data['expiry'] = $localTimeObj->local_strtotime('2029-12-31 23:59:59');
         }
         //使用说明
         $extra['directions'] = $codes[$k][4];
         if (!isset($coupons[$codes[$k][1]])) {
             $coupons[$codes[$k][1]] = array('info' => array(), 'extra' => array(), 'codes' => array());
         }
         $coupons[$codes[$k][1]]['info'] = $data;
         $coupons[$codes[$k][1]]['extra'] = $extra;
         $coupons[$codes[$k][1]]['codes'][] = $codes[$k][8];
         $coupons[$codes[$k][1]]['password'][] = $codes[$k][9];
     }
     $ccModel = D('CouponCode');
     $ccdModel = D('CouponCodeData');
     $codesModel = D('CouponCodeCodes');
     $nowtime = $localTimeobj->gmtime();
     foreach ($coupons as $c) {
         $c_id = 0;
         $c['info']['amount'] = count($c['codes']);
         $c['info']['addtime'] = $nowtime;
         $c['info']['is_active'] = 0;
         if ($c_id = $ccModel->_add($c['info'])) {
             //插入附属表数据
             $_data = array('c_id' => $c_id, 'fetch_limit' => $c['extra']['fetch_limit'], 'directions' => $c['extra']['directions']);
             $ccdModel->_add($_data);
             //添加优惠代码
             for ($kk = 0; $kk < count($c['codes']); $kk++) {
                 $_data = array('c_id' => $c_id, 'code' => $c['codes'][$kk], 'password' => $c['password'][$kk]);
                 $codesModel->_add($_data);
             }
         }
     }
 }
Example #18
0
 public function search()
 {
     $kw = $_REQUEST['kw'];
     if (empty($kw)) {
         redirect(reUrl('Mall/lists'));
     }
     $mallModel = D('CouponCodeMall');
     $mall = $mallModel->search($kw);
     //只有一个结果符合,直接跳转到商家信息页
     if (count($mall) == 1) {
         $mall = current($mall);
         $localTimeObj = LocalTime::getInstance();
         $nowtime = $localTimeObj->gmtime();
         $yestoday = $nowtime - 24 * 3600;
         $yesterdaysearched = date('Ymd', $mall['updatetime']) == date('Ymd', $yestoday) ? $mall['daysearched'] : $mall['yesterdaysearched'];
         $daysearched = date('Ymd', $mall['updatetime']) == date('Ymd', $nowtime) ? $mall['daysearched'] + 1 : 1;
         $weeksearched = date('YW', $mall['updatetime']) == date('YW', $nowtime) ? $mall['weeksearched'] + 1 : 1;
         $monthsearched = date('Ym', $mall['updatetime']) == date('Ym', $nowtime) ? $mall['monthsearched'] + 1 : 1;
         $data = array('yesterdaysearched' => $yesterdaysearched, 'daysearched' => $daysearched, 'weeksearched' => $weeksearched, 'monthsearched' => $monthsearched, 'updatetime' => $nowtime);
         $mallModel->update($mall['id'], $data);
         redirect(reUrl('Mall/view?id=' . $mall['id']));
     } else {
         if (count($mall) > 1) {
             $localTimeObj = LocalTime::getInstance();
             $nowtime = $localTimeObj->gmtime();
             $yestoday = $nowtime - 24 * 3600;
             foreach ($mall as $m) {
                 $yesterdaysearched = date('Ymd', $m['updatetime']) == date('Ymd', $yestoday) ? $m['daysearched'] : $m['yesterdaysearched'];
                 $daysearched = date('Ymd', $m['updatetime']) == date('Ymd', $nowtime) ? $m['daysearched'] + 1 : 1;
                 $weeksearched = date('YW', $m['updatetime']) == date('YW', $nowtime) ? $m['weeksearched'] + 1 : 1;
                 $monthsearched = date('Ym', $m['updatetime']) == date('Ym', $nowtime) ? $m['monthsearched'] + 1 : 1;
                 $data = array('yesterdaysearched' => $yesterdaysearched, 'daysearched' => $daysearched, 'weeksearched' => $weeksearched, 'monthsearched' => $monthsearched, 'updatetime' => $nowtime);
                 $mallModel->update($m['id'], $data);
             }
             $this->assign('malls', $mall);
             $this->assign('kw', $kw);
             $this->assign('page_title', $kw . '搜索结果 - ');
             $this->assign('page_keywords', $this->_CFG['site_keywords']);
             $this->assign('page_description', $this->_CFG['site_description']);
             $this->display();
         } else {
             $this->error('没有找到您要搜索的商家');
         }
     }
 }
 public function edit()
 {
     $id = intval($_REQUEST['id']);
     $ccmModel = D('MallPromotion');
     $promotion = $ccmModel->info(array(), $id);
     $promotion or die('id invalid');
     if ($this->isPost()) {
         if (C('TOKEN_ON') && !checkFormToken($_REQUEST, 'hash')) {
             die('hack attemp.');
         }
         if (!$_REQUEST['title'] || !$_REQUEST['cate_id'] || !$_REQUEST['gourl'] || !$_REQUEST['expiry'] || !$_REQUEST['m_id'] || !$_REQUEST['description'] || !$_REQUEST['sort_order']) {
             $this->error('请填写所有的必填项');
         }
         $logo = '';
         if ($_FILES['logo']['size'] > 0 && $_FILES['logo']['error'] == 0) {
             $upfile = array();
             $upfile = upload_one_file($_FILES['logo']);
             if ($upfile['error']) {
                 $this->error($upfile['error']);
             }
             $logo = $upfile['file_name'];
         }
         $localTimeObj = LocalTime::getInstance();
         $addtime = $localTimeObj->gmtime();
         $_REQUEST['expiry'] = $localTimeObj->local_strtotime($_REQUEST['expiry'] . ' 23:59:59');
         $data = array('cate_id' => intval($_REQUEST['cate_id']), 'title' => $_REQUEST['title'], 'gourl' => $_REQUEST['gourl'], 'expiry' => $_REQUEST['expiry'], 'description' => $_REQUEST['description'], 'm_id' => intval($_REQUEST['m_id']), 'm_name' => $_REQUEST['m_name'], 'sort_order' => intval($_REQUEST['sort_order']), 'detail' => $_REQUEST['detail']);
         if ($logo) {
             $data['logo'] = $logo;
         }
         if ($ccmModel->update($id, $data)) {
             $this->assign('jumpUrl', '?g=' . GROUP_NAME . '&m=' . MODULE_NAME);
             $this->success('编辑成功');
         } else {
             $this->error('编辑失败');
         }
     }
     $promotion['expiry'] = LocalTime::getInstance()->local_date($this->_CFG['date_format'], $promotion['expiry']);
     $this->assign('promotion', $promotion);
     $categorys = array();
     $cccService = service('CouponCodeCategory');
     $data = $cccService->getTree();
     foreach ($data as $rs) {
         $categorys[$rs['id']] = $rs;
         $categorys[$rs['id']]['prefix'] = str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;", $rs['level']);
     }
     $this->assign('categorys', $categorys);
     $this->assign('ur_href', '促销活动管理 &gt; 编辑活动');
     $this->assign('hash', buildFormToken('hash'));
     $this->display('post');
 }
 /**
  * 随机优惠券
  *
  * @param unknown_type $limit
  */
 public function randoms($limit = 10)
 {
     $today = LocalTime::getInstance()->local_strtotime(date('Y-m-d 23:59:59'));
     $fields = 'c.*, m.logo';
     $sql = " FROM " . $this->getTableName() . " AS c LEFT JOIN " . M('coupon_code_mall')->getTableName() . " AS m ON m.id=c.m_id";
     $sql .= " WHERE c.is_active=1 AND c.amount>c.fetched_amount AND c.expiry>={$today}";
     $sql .= " ORDER BY RAND() DESC LIMIT {$limit}";
     $res = $this->query("SELECT {$fields}" . $sql);
     return $res;
 }
 /**
  * 随机优惠券
  *
  * @param unknown_type $limit
  */
 public function randoms($limit = 10)
 {
     $today = LocalTime::getInstance()->local_strtotime(date('Y-m-d 23:59:59'));
     $fields = 'c.*, m.pic_path';
     $sql = " FROM " . $this->getTableName() . " AS c LEFT JOIN " . M('tao_shop')->getTableName() . " AS m ON m.id=c.s_id";
     $sql .= " WHERE c.is_active=1 AND c.expiry>={$today}";
     $sql .= " ORDER BY RAND() DESC LIMIT {$limit}";
     $res = $this->query("SELECT {$fields}" . $sql);
     return $res;
 }
Example #22
0
 public function myinvite()
 {
     $page = isset($_REQUEST['p']) && $_REQUEST['p'] >= 1 ? $_REQUEST['p'] : 1;
     $pageLimit = 15;
     $localTimeObj = LocalTime::getInstance();
     $c_count = M('user')->where("invite='" . $this->_user['user_id'] . "'")->count();
     $res = M('user')->field('user_id,nick,addtime')->where("invite='" . $this->_user['user_id'] . "'")->order("user_id DESC")->limit(($page - 1) * $pageLimit . ", " . $pageLimit)->select();
     $users = array();
     foreach ($res as $rs) {
         $rs['addtime'] = $localTimeObj->local_date($this->_CFG['time_format'], $rs['addtime']);
         $users[] = $rs;
     }
     $this->assign('users', $users);
     $page_url = reUrl(MODULE_NAME . "/" . ACTION_NAME . "?p=[page]");
     $page_url = str_replace('%5bpage%5d', '[page]', $page_url);
     $p = new Page($page, $pageLimit, $c_count, $page_url, 5, 5);
     $pagelink = $p->showStyle(3);
     $this->assign('pagelink', $pagelink);
     $this->assign('page_title', '我的邀请记录 - ');
     $this->assign('page_keywords', $this->_CFG['site_keywords']);
     $this->assign('page_description', $this->_CFG['site_description']);
     $this->display();
 }
Example #23
0
 /**
  * 添加店铺
  *
  * @param string $nick
  * @return array
  */
 public function createShopByNick($nick)
 {
     $tao_shop = $this->getShopInfo($nick);
     $taoke_shop = $this->convertShops($tao_shop['sid']);
     $tao_user = $this->getUserInfo($nick);
     $return = array();
     $return['nick'] = $nick;
     $return['uid'] = $tao_user['uid'];
     $return['seller_id'] = $tao_user['user_id'];
     $return['cid'] = $tao_shop['cid'];
     $return['consumer_protection'] = $tao_user['consumer_protection'] ? 1 : 0;
     $return['level'] = $tao_user['seller_credit']['level'];
     $return['score'] = $tao_user['seller_credit']['score'];
     $return['total_num'] = $tao_user['seller_credit']['total_num'];
     $return['good_num'] = $tao_user['seller_credit']['good_num'];
     $return['city'] = $tao_user['location']['city'];
     $return['state'] = $tao_user['location']['state'];
     $return['sid'] = $tao_shop['sid'];
     $return['title'] = $tao_shop['title'];
     $return['pic_path'] = $tao_shop['pic_path'];
     $return['desc'] = $tao_shop['desc'];
     $return['bulletin'] = $tao_shop['bulletin'];
     $return['created'] = LocalTime::getInstance()->local_strtotime($tao_shop['created']);
     $return['shop_click_url'] = $taoke_shop['click_url'];
     $return['type'] = $tao_user['type'];
     $return['item_score'] = $tao_shop['shop_score']['item_score'];
     $return['service_score'] = $tao_shop['shop_score']['service_score'];
     $return['delivery_score'] = $tao_shop['shop_score']['delivery_score'];
     $return['commission_rate'] = $taoke_shop['commission_rate'];
     $return['good'] = $return['good_num'] / $return['total_num'] * 100;
     $return['addtime'] = LocalTime::getInstance()->gmtime();
     return $return;
 }
 public function gather_handler()
 {
     $page = intval($_REQUEST['page']);
     $snoopy = new Snoopy();
     $snoopy->referer = "http://www.taobao.com";
     $URI = 'http://taoquan.taobao.com/coupon/coupon_list.htm?startFee=-1.0&category=-1&keyWord=&order=order&desc=true&currentPage=' . $page;
     $snoopy->fetch($URI);
     $html = $snoopy->results;
     unset($snoopy);
     $html = iconv('gbk', 'utf-8', $html);
     preg_match_all('/<li class="coupon-item J_CouponItem">(.*)<\\/li>/isU', $html, $tt);
     $temp = $tt[1];
     $coupon = array();
     $localTimeObj = LocalTime::getInstance();
     $taoShopModel = D('TaoShop');
     $ccModel = D('TaoCoupon');
     $tcdModel = D('TaoCouponData');
     foreach ($temp as $c) {
         $coupon = $this->_queryCoupon($c);
         if (!$coupon['money_reduce'] || !$coupon['activity_id'] || !$coupon['seller_id']) {
             continue;
         }
         if ($tcdModel->field("c_id")->where("activity_id='{$coupon['activity_id']}' AND seller_id='{$coupon['seller_id']}'")->find()) {
             continue;
         }
         $shop = $taoShopModel->getInfoBySid($coupon['sid']);
         if (!$shop) {
             continue;
         }
         $data = array('s_id' => $shop['id'], 's_title' => $shop['title'], 'c_type' => 1, 'expiry_type' => 1, 'price_type' => 1, 'money_max' => $coupon['money_max'], 'money_reduce' => $coupon['money_reduce'], 'expiry' => $localTimeObj->local_strtotime($coupon['expiry']), 'addtime' => $localTimeObj->gmtime());
         $c_id = 0;
         if ($c_id = $ccModel->_add($data)) {
             //插入附属表数据
             $data = array('c_id' => $c_id, 'activity_id' => $coupon['activity_id'], 'seller_id' => $coupon['seller_id'], 'fetch_limit' => 101);
             $tcdModel->_add($data);
         }
     }
     $this->ajaxReturn('', '', 1);
 }
Example #25
0
 /**
  * 编辑
  *
  */
 public function edit()
 {
     $aModel = D('Article');
     $article_id = intval($_REQUEST['article_id']);
     if ($this->isPost()) {
         if (C('TOKEN_ON') && !checkFormToken($_REQUEST)) {
             die('hack attemp.');
         }
         if (!$_REQUEST['title'] || !$_REQUEST['cate_id'] || !$_REQUEST['content']) {
             die('data invalid.');
         }
         $localTimeObj = LocalTime::getInstance();
         if ($aModel->_edit($article_id, $_REQUEST)) {
             //生成静态文章
             $this->_buildHtml($article_id);
             $this->assign('jumpUrl', '?g=' . GROUP_NAME . '&m=' . MODULE_NAME);
             $this->success('编辑成功');
         } else {
             $this->error('编辑失败');
         }
     }
     $article = $aModel->info($article_id);
     $this->assign('article', $article);
     $category = D('ArticleCategory')->getAll();
     $this->assign('category', $category);
     $this->assign('ur_href', '文章管理 &gt; 编辑文章');
     $this->assign('_hash_', buildFormToken());
     $this->display('post');
 }
Example #26
0
 private function _doLogin()
 {
     $enabled_captcha = false;
     $captcha = intval($this->_CFG['captcha']);
     if ($captcha & CAPTCHA_ADMIN && (!($captcha & CAPTCHA_LOGIN_FAIL) || $captcha & CAPTCHA_LOGIN_FAIL && $_SESSION['login_fail'] > 2) > 0) {
         $enabled_captcha = true;
     }
     if ($enabled_captcha && isset($_SESSION[CAPTCHA_CODE]) && !empty($_SESSION[CAPTCHA_CODE])) {
         /* 检查验证码是否正确 */
         if (empty($_REQUEST['verify']) || !SeccodeUtil::check_word(CAPTCHA_CODE, $_REQUEST['verify'])) {
             $this->ajaxReturn('', '验证码输入错误', 0);
         }
     }
     $userObj = D('AdminUsers');
     $user_name = $_REQUEST['admin_name'];
     $password = $_REQUEST['admin_pwd'];
     $password = md5(md5($password));
     $userInfo = $userObj->infoByUserName($user_name);
     if (!isset($_SESSION['login_fail'])) {
         $_SESSION['login_fail'] = 0;
     }
     //用户名不存在
     if (!$userInfo || !$userInfo['user_id']) {
         $_SESSION['login_fail'] += 1;
         $this->ajaxReturn('', '用户名不存在', 0);
     }
     //密码不正确
     if ($userInfo['password'] != $password) {
         $_SESSION['login_fail'] += 1;
         $this->ajaxReturn('', '密码不正确', 0);
     }
     //已被锁定
     if ($userInfo['is_locked']) {
         $this->ajaxReturn('', '帐号已被锁定', 0);
     }
     $lastLogin = LocalTime::getInstance()->gmtime();
     $userObj->edit_user($userInfo['user_id'], array('last_login' => $lastLogin, 'last_ip' => get_client_ip()));
     $_SESSION[C('SESSION_PREFIX') . 'user_id'] = $userInfo['user_id'];
     $_SESSION[C('SESSION_PREFIX') . 'user_name'] = $userInfo['user_name'];
     //是否超级管理员
     $_SESSION[C('SESSION_PREFIX') . 'is_super'] = $userInfo['is_super'];
     $_SESSION[C('SESSION_PREFIX') . 'name'] = $userInfo['name'];
     //用户的角色
     $aurModel = D('AdminUserRole');
     $_SESSION[C('SESSION_PREFIX') . 'user_roles'] = $aurModel->getUserRole($userInfo['user_id']);
     unset($_SESSION['login_fail']);
     $this->ajaxReturn('', '', 1);
 }
Example #27
0
 protected function _initialize()
 {
     parent::_initialize();
     $nowtime = LocalTime::getInstance()->gmtime();
     $this->_link['Coupons']['condition'] .= ' AND expiry>=' . $nowtime;
 }
Example #28
0
/**
 * 获取分类优惠券
 *
 * @param int $cate_id			分类ID
 * @param int $limit
 * @return array
 */
function coupon_codes_cate($cate_id, $limit)
{
    static $ccModel = null, $cates = null, $cates = null, $cfg = null, $localTimeObj = null;
    if ($ccModel === null) {
        $ccModel = D('CouponCode');
    }
    if ($cates === null) {
        $cates = get_mall_category_tree();
    }
    if ($all_cates === null) {
        $all_cates = get_mall_category();
    }
    if ($cfg === null) {
        $cfg = load_config();
    }
    if ($localTimeObj === null) {
        $localTimeObj = LocalTime::getInstance();
    }
    $today = $localTimeObj->local_strtotime(date('Y-m-d 23:59:59'));
    $coupons = array();
    $c = $all_cates[$cate_id];
    $cate_ids = is_array($cates[$c['id']]['childs']) ? $cates[$c['id']]['childs'] : array();
    $cate_ids[] = $c['id'];
    $cate_ids = implode(',', $cate_ids);
    $res = $ccModel->coupons4cate($cate_ids, $limit);
    foreach ($res as $rs) {
        if ($rs['expiry_type'] == 1) {
            $rs['expiry_timestamp'] = $rs['expiry'] + $cfg['timezone'] * 3600;
            if ($rs['expiry'] - $today == 0) {
                $rs['expiry'] = 1;
            } else {
                $rs['expiry'] = $rs['expiry'] - $today > 0 ? ceil(($rs['expiry'] - $today) / (3600 * 24)) : 0;
            }
        }
        $coupons[] = $rs;
    }
    return $coupons;
}