Пример #1
0
 protected function _check_login()
 {
     if (in_array(MODULE_NAME, C('LOGIN_MODULES')) && !in_array(MODULE_NAME . '.' . strtolower(ACTION_NAME), C('NOT_LOGIN_ACTIONS')) && !$this->_user['user_id']) {
         if ($this->isAjax()) {
             $this->ajaxReturn('', '未登录', 0);
         } else {
             redirect(reUrl('User/login'));
         }
     }
 }
Пример #2
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();
 }
Пример #3
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();
 }
Пример #4
0
 public function index()
 {
     $page = isset($_REQUEST['p']) && $_REQUEST['p'] >= 1 ? $_REQUEST['p'] : 1;
     $pageLimit = 30;
     $cid = isset($_REQUEST['cid']) ? intval($_REQUEST['cid']) : 0;
     $localTimeObj = LocalTime::getInstance();
     //商家分类
     $cccService = service('CouponCodeCategory');
     $cates = $cccService->getTree();
     //商家子分类
     $cate_ids = array();
     $cate_ids = is_array($cates[$cid]['childs']) ? $cates[$cid]['childs'] : array();
     $cate_ids[] = $cid;
     $cate_ids = implode(',', $cate_ids);
     $params = array('cate_id' => $cate_ids);
     $limit = array('begin' => ($page - 1) * $pageLimit, 'offset' => $pageLimit);
     $codeMallModel = D('MallPromotion');
     $keys = array();
     $res = $codeMallModel->front($keys, $params, $limit);
     $promotions = array();
     foreach ($res['data'] as $rs) {
         $rs['expiry_timestamp'] = $rs['expiry'] + $this->_CFG['timezone'] * 3600;
         $rs['expiry'] = $localTimeObj->local_date($this->_CFG['date_format'], $rs['expiry']);
         $promotions[] = $rs;
     }
     $this->assign('promotions', $promotions);
     $page_url = reUrl(MODULE_NAME . "/" . ACTION_NAME . "?cid={$cid}&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('cates', $cates);
     $this->assign('cid', $cid);
     $this->assign('page_title', '促销活动 - ');
     $this->assign('page_keywords', $this->_CFG['site_keywords']);
     $this->assign('page_description', $this->_CFG['site_description']);
     $this->display();
 }
Пример #5
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);
         }
     }
 }
Пример #6
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('没有找到您要搜索的商家');
         }
     }
 }
Пример #7
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();
 }
Пример #8
0
 private function _pay_callback_alipay_warrant()
 {
     import('@.Com.payment.PaymentFactory');
     $payment = PaymentFactory::getPayment('AlipayWarrant');
     $result = $payment->verifyReturn();
     if ($result !== false) {
         $result['trade_status'] = trim($result['trade_status']);
         //等待发货
         if ($result['trade_status'] == 'WAIT_SELLER_SEND_GOODS') {
             $record = M('payment')->where("out_trade_no='{$result['out_trade_no']}'")->find();
             if ($record['status'] == 104) {
                 $this->assign('jumpUrl', reUrl('User/consume_records'));
                 $this->success('支付成功');
             }
             if ($record && $record['amount'] == $result['total_fee']) {
                 //自动发货
                 $response = $payment->send_goods(array('trade_no' => $result['trade_no']));
                 if ($response) {
                     M('payment')->where("out_trade_no='{$result['out_trade_no']}'")->save(array('status' => 105, 'trade_no' => $result['trade_no']));
                     $this->assign('jumpUrl', reUrl('User/consume_records'));
                     $this->success('请登录支付宝确认收货.<br />支付宝交易号:' . $result['trade_no']);
                 } else {
                     M('payment')->where("out_trade_no='{$result['out_trade_no']}'")->save(array('status' => '102', 'trade_no' => $result['trade_no']));
                     $this->assign('jumpUrl', reUrl('User/consume_records'));
                     $this->error('发生错误,请联系客服.');
                 }
             } else {
                 $this->assign('jumpUrl', reUrl('User/consume_records'));
                 $this->error('支付失败<br />支付记录不存在或支付金额错误');
             }
         } else {
             if ($result['trade_status'] == 'WAIT_BUYER_CONFIRM_GOODS') {
                 $this->assign('jumpUrl', reUrl('User/consume_records'));
                 $this->success('请登录支付宝确认收货.<br />支付宝交易号:' . $result['trade_no']);
             } else {
                 $this->assign('jumpUrl', reUrl('User/consume_records'));
                 $this->error('支付失败<br />' . $result['trade_status']);
             }
         }
     } else {
         $this->assign('jumpUrl', reUrl('User/consume_records'));
         $this->error('支付失败');
     }
 }
Пример #9
0
/**
 * Smarty {fixedUrl} function plugin
 *
 * Type:     function<br>
 * Name:     mailto<br>
 * Date:     2012-01-30
 * Author:	 anqiu xiao
 *
 * Examples:
 * <pre>
 * {fixedUrl url="Hotel/hall?id=`$item.hall_id`"}
 * </pre>
 * @param    array
 * @param    Smarty
 * @return   string
 */
function smarty_function_fixedUrl($params, &$smarty)
{
    return reUrl($params['url']);
}
Пример #10
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);
         }
     }
 }