예제 #1
0
 /**
  * 获得指定页面的动态内容
  *
  * @access  public
  * @param   string  $tmp    模板名称
  * @return  void
  */
 function assign_dynamic($tmp)
 {
     $sql = 'SELECT id, number, type FROM ' . $this->pre . "template WHERE filename = '{$tmp}' AND type > 0 AND remarks ='' AND theme='" . C('template') . "'";
     $res = $this->query($sql);
     foreach ($res as $row) {
         switch ($row['type']) {
             case 1:
                 /* 分类下的商品 */
                 ECTouch::view()->assign('goods_cat_' . $row['id'], model('Goods')->assign_cat_goods($row['id'], $row['number']));
                 break;
             case 2:
                 /* 品牌的商品 */
                 $brand_goods = model('Goods')->assign_brand_goods($row['id'], $row['number']);
                 ECTouch::view()->assign('brand_goods_' . $row['id'], $brand_goods['goods']);
                 ECTouch::view()->assign('goods_brand_' . $row['id'], $brand_goods['brand']);
                 break;
             case 3:
                 /* 文章列表 */
                 $cat_articles = model('Article')->assign_articles($row['id'], $row['number']);
                 ECTouch::view()->assign('articles_cat_' . $row['id'], $cat_articles['cat']);
                 ECTouch::view()->assign('articles_' . $row['id'], $cat_articles['arr']);
                 break;
         }
     }
 }
예제 #2
0
 /**
  * 文章列表异步加载
  */
 public function asynclist()
 {
     $this->parameter();
     $asyn_last = intval(I('post.last')) + 1;
     $this->size = I('post.amount');
     $this->page = $asyn_last > 0 ? ceil($asyn_last / $this->size) : 1;
     $list = model('ArticleBase')->get_cat_articles($this->cat_id, $this->page, $this->size, $this->keywords);
     foreach ($list as $key => $value) {
         $this->assign('article', $value);
         $sayList[] = array('single_item' => ECTouch::view()->fetch('library/asynclist_info.lbi'));
     }
     die(json_encode($sayList));
     exit;
 }
 public function asynclist()
 {
     $this->parameter();
     $asyn_last = intval(I('post.last')) + 1;
     $this->size = I('post.amount');
     $this->page = $asyn_last > 0 ? ceil($asyn_last / $this->size) : 1;
     $gb_list = model('Groupbuy')->group_buy_list($this->size, $this->page, $this->sort, $this->order);
     foreach ($gb_list as $key => $value) {
         $this->assign('groupbuy', $value);
         $sayList[] = array('single_item' => ECTouch::view()->fetch('library/asynclist_info.lbi'));
     }
     die(json_encode($sayList));
     exit;
 }
예제 #4
0
 public function asynclist_list()
 {
     $this->parameter();
     $asyn_last = intval(I('post.last')) + 1;
     $this->size = I('post.amount');
     $this->page = $asyn_last > 0 ? ceil($asyn_last / $this->size) : 1;
     $list = model('Exchange')->exchange_get_goods($this->children, $this->integral_min, $this->integral_max, $this->ext, $this->size, $this->page, $this->sort, $this->order);
     foreach ($list as $key => $value) {
         $this->assign('exchange', $value);
         $sayList[] = array('single_item' => ECTouch::view()->fetch('library/asynclist_info.lbi'));
     }
     die(json_encode($sayList));
     exit;
 }
예제 #5
0
 /**
  * ajax获取商品
  */
 public function ajax_goods()
 {
     if (IS_AJAX) {
         $type = I('get.type');
         $start = $_POST['last'];
         $limit = $_POST['amount'];
         $hot_goods = model('Index')->goods_list($type, $limit, $start);
         $list = array();
         // 热卖商品
         if ($hot_goods) {
             foreach ($hot_goods as $key => $value) {
                 $this->assign('hot_goods', $value);
                 $list[] = array('single_item' => ECTouch::view()->fetch('library/asynclist_index.lbi'));
             }
         }
         echo json_encode($list);
         exit;
     } else {
         $this->redirect(url('index'));
     }
 }
예제 #6
0
 /**
  * 获取分类信息
  * 只获取二级分类当没有参数时获取最高的二级分类
  */
 public function all()
 {
     $cat_id = I('get.id');
     /* 页面的缓存ID */
     $cache_id = sprintf('%X', crc32($_SERVER['REQUEST_URI'] . C('lang')));
     if (!ECTouch::view()->is_cached('category_all.dwt', $cache_id)) {
         // 获得请求的分类 ID
         if ($cat_id > 0) {
             $category = model('CategoryBase')->get_child_tree($cat_id);
         } else {
             //顶级分类
             ecs_header("Location: " . url('category/top_all') . "\n");
         }
         $this->assign('title', L('catalog'));
         $this->assign('category', $category);
         /* 页面标题 */
         $page_info = get_page_title($cat_id);
         $this->assign('ur_here', $page_info['ur_here']);
         $this->assign('page_title', $cat_id > 0 ? $page_info['title'] : L('catalog') . '_' . $page_info['title']);
     }
     $this->display('category_all.dwt', $cache_id);
 }
 /**
  * 提交订单
  */
 public function submit_order()
 {
     /* 检查购物车中是否有商品 */
     if (count($_SESSION['wholesale_goods']) == 0) {
         show_message(L('no_goods_in_cart'));
     }
     /* 检查备注信息 */
     if (empty($_POST['remark'])) {
         show_message(L('ws_remark'));
     }
     /* 计算商品总额 */
     $goods_amount = 0;
     foreach ($_SESSION['wholesale_goods'] as $goods) {
         $goods_amount += $goods['subtotal'];
     }
     $order = array('postscript' => htmlspecialchars($_POST['remark']), 'user_id' => $_SESSION['user_id'], 'add_time' => gmtime(), 'order_status' => OS_UNCONFIRMED, 'shipping_status' => SS_UNSHIPPED, 'pay_status' => PS_UNPAYED, 'goods_amount' => $goods_amount, 'order_amount' => $goods_amount);
     /* 插入订单表 */
     $error_no = 0;
     do {
         $order['order_sn'] = get_order_sn();
         //获取新订单号
         $this->model->table('order_info')->data($order)->insert();
         $error_no = $this->model->errno();
         if ($error_no > 0 && $error_no != 1062) {
             die($this->model->errorMsg());
         }
     } while ($error_no == 1062);
     //如果是订单号重复则重新提交数据
     $new_order_id = $this->model->insert_id();
     $order['order_id'] = $new_order_id;
     /* 插入订单商品 */
     foreach ($_SESSION['wholesale_goods'] as $goods) {
         //如果存在货品
         $product_id = 0;
         if (!empty($goods['goods_attr_id'])) {
             $goods_attr_id = array();
             foreach ($goods['goods_attr_id'] as $value) {
                 $goods_attr_id[$value['attr_id']] = $value['attr_val_id'];
             }
             ksort($goods_attr_id);
             $goods_attr = implode('|', $goods_attr_id);
             $res = $this->model->table('products')->field('product_id')->where("goods_attr = '{$goods_attr}' AND goods_id = '" . $goods['goods_id'] . "'")->find();
             $product_id = $res['product_id'];
         }
         $sql = "INSERT INTO " . $this->model->pre . "order_goods( " . "order_id, goods_id, goods_name, goods_sn, product_id, goods_number, market_price, " . "goods_price, goods_attr, is_real, extension_code, parent_id, is_gift) " . " SELECT '{$new_order_id}', goods_id, goods_name, goods_sn, '{$product_id}','{$goods['goods_number']}', market_price, " . "'{$goods['goods_price']}', '{$goods['goods_attr']}', is_real, extension_code, 0, 0 " . " FROM " . $this->model->pre . "goods WHERE goods_id = '{$goods['goods_id']}'";
         $this->model->query($sql);
     }
     /* 给商家发邮件 */
     if (C('service_email') != '') {
         $tpl = get_mail_template('remind_of_new_order');
         $this->assign('order', $order);
         $this->assign('shop_name', C('shop_name'));
         $this->assign('send_date', date(C('time_format')));
         $content = ECTouch::view()->fetch('str:' . $tpl['template_content']);
         send_mail(C('shop_name'), C('service_email'), $tpl['template_subject'], $content, $tpl['is_html']);
     }
     /* 如果需要,发短信 */
     if (C('sms_order_placed') == '1' && C('sms_shop_mobile') != '') {
         $sms = new EcsSms();
         $msg = L('order_placed_sms');
         $sms->send(C('sms_shop_mobile'), sprintf($msg, $order['consignee'], $order['mobile']), '', 13, 1);
     }
     /* 清空购物车 */
     unset($_SESSION['wholesale_goods']);
     /* 提示 */
     show_message(sprintf(L('ws_order_submitted'), $order['order_sn']), L('ws_return_home'), url('index'));
 }
예제 #8
0
/**
 * 调用在线调查信息
 *
 * @access  public
 * @return  string
 */
function insert_vote()
{
    $vote = get_vote();
    if (!empty($vote)) {
        ECTouch::view()->assign('vote_id', $vote['id']);
        ECTouch::view()->assign('vote', $vote['content']);
    }
    $val = ECTouch::view()->fetch('library/vote.lbi');
    return $val;
}
예제 #9
0
 /**
  * 用户出价处理
  */
 public function bid()
 {
     $json = new EcsJson();
     $result = array('error' => 0, 'content' => '');
     $price = isset($_POST['price']) ? floatval($_POST['price']) : 0;
     $price = round($price, 2);
     $id = isset($_POST['id']) ? intval($_POST['id']) : 0;
     /* 测试是否登陆 */
     if (empty($_SESSION['user_id'])) {
         $result['error'] = 1;
         $result['content'] = L('not_login');
         die($json->encode($result));
     }
     /* 获取活动基本信息用于校验 */
     $row = $this->model->table('goods_activity')->field('act_name,end_time,ext_info')->where('act_id =' . $id)->find();
     if ($row) {
         $info = unserialize($row['ext_info']);
         if ($info) {
             foreach ($info as $key => $val) {
                 $row[$key] = $val;
             }
         }
     }
     if (empty($row)) {
         $result['error'] = 1;
         $result['content'] = L('now_not_snatch');
         die($json->encode($result));
     }
     if ($row['end_time'] < gmtime()) {
         $result['error'] = 1;
         $result['content'] = L('snatch_is_end');
         die($json->encode($result));
     }
     /* 检查出价是否合理 */
     if ($price < $row['start_price'] || $price > $row['end_price']) {
         $result['error'] = 1;
         $result['content'] = sprintf($GLOBALS['_LANG']['not_in_range'], $row['start_price'], $row['end_price']);
         die($json->encode($result));
     }
     /* 检查用户是否已经出同一价格 */
     $count = $this->model->table('snatch_log')->where("snatch_id = '" . $id . "' AND user_id = '{$_SESSION['user_id']}' AND bid_price = '.{$price}.'")->count();
     if ($count > 0) {
         $result['error'] = 1;
         $result['content'] = sprintf(L('also_bid'), price_format($price, false));
         die($json->encode($result));
     }
     /* 检查用户积分是否足够 */
     $pay_points = $this->model->table('users')->field('pay_points')->where("user_id = '{$_SESSION['user_id']}'")->find();
     if ($row['cost_points'] > $pay_points['pay_points']) {
         $result['error'] = 1;
         $result['content'] = L('lack_pay_points');
         die($json->encode($result));
     }
     model('ClipsBase')->log_account_change($_SESSION['user_id'], 0, 0, 0, 0 - $row['cost_points'], sprintf(L('snatch_log'), $row['snatch_name']));
     //扣除用户积分
     $snatch_log['snatch_id'] = $id;
     $snatch_log['user_id'] = $_SESSION['user_id'];
     $snatch_log['bid_price'] = $price;
     $snatch_log['bid_time'] = gmtime();
     $this->model->table('snatch_log')->data($snatch_log)->insert();
     $this->assign('myprice', model('Snatch')->get_myprice($id));
     $this->assign('id', $id);
     $result['content'] = ECTouch::view()->fetch('library/snatch.lbi');
     die($json->encode($result));
 }
예제 #10
0
 /**
  * 修改订单的支付状态
  *
  * @access  public
  * @param   string  $log_id     支付编号
  * @param   integer $pay_status 状态
  * @param   string  $note       备注
  * @return  void
  */
 function order_paid($log_id, $pay_status = PS_PAYED, $note = '')
 {
     /* 取得支付编号 */
     $log_id = intval($log_id);
     if ($log_id > 0) {
         /* 取得要修改的支付记录信息 */
         $sql = "SELECT * FROM " . $this->pre . "pay_log WHERE log_id = '{$log_id}'";
         $pay_log = $this->row($sql);
         if ($pay_log && $pay_log['is_paid'] == 0) {
             /* 修改此次支付操作的状态为已付款 */
             $sql = 'UPDATE ' . $this->pre . "pay_log SET is_paid = '1' WHERE log_id = '{$log_id}'";
             $this->query($sql);
             /* 根据记录类型做相应处理 */
             if ($pay_log['order_type'] == PAY_ORDER) {
                 /* 取得订单信息 */
                 $sql = 'SELECT order_id, user_id, order_sn, consignee, address, mobile, shipping_id, extension_code, extension_id, goods_amount ' . 'FROM ' . $this->pre . "order_info WHERE order_id = '{$pay_log['order_id']}'";
                 $order = $this->row($sql);
                 $order_id = $order['order_id'];
                 $order_sn = $order['order_sn'];
                 /* 修改订单状态为已付款 */
                 $sql = 'UPDATE ' . $this->pre . "order_info SET order_status = '" . OS_CONFIRMED . "', " . " confirm_time = '" . gmtime() . "', " . " pay_status = '{$pay_status}', " . " pay_time = '" . gmtime() . "', " . " money_paid = order_amount," . " order_amount = 0 " . "WHERE order_id = '{$order_id}'";
                 $this->query($sql);
                 /* 记录订单操作记录 */
                 model('OrderBase')->order_action($order_sn, OS_CONFIRMED, SS_UNSHIPPED, $pay_status, $note, L('buyer'));
                 /* 如果需要,发短信 */
                 if (C('sms_order_payed') == '1' && C('sms_shop_mobile') != '') {
                     $sms = new EcsSms();
                     $sms->send(C('sms_shop_mobile'), sprintf(L('order_payed_sms'), $order_sn, $order['consignee'], $order['mobile']), '', 13, 1);
                 }
                 /* 对虚拟商品的支持 */
                 $virtual_goods = model('OrderBase')->get_virtual_goods($order_id);
                 if (!empty($virtual_goods)) {
                     $msg = '';
                     if (!model('OrderBase')->virtual_goods_ship($virtual_goods, $msg, $order_sn, true)) {
                         $pay_success = L('pay_success') . '<div style="color:red;">' . $msg . '</div>' . L('virtual_goods_ship_fail');
                         L('pay_success', $pay_success);
                     }
                     /* 如果订单没有配送方式,自动完成发货操作 */
                     if ($order['shipping_id'] == -1) {
                         /* 将订单标识为已发货状态,并记录发货记录 */
                         $sql = 'UPDATE ' . $this->pre . "order_info SET shipping_status = '" . SS_SHIPPED . "', shipping_time = '" . gmtime() . "'" . " WHERE order_id = '{$order_id}'";
                         $this->query($sql);
                         /* 记录订单操作记录 */
                         model('OrderBase')->order_action($order_sn, OS_CONFIRMED, SS_SHIPPED, $pay_status, $note, L('buyer'));
                         $integral = model('Order')->integral_to_give($order);
                         model('ClipsBase')->log_account_change($order['user_id'], 0, 0, intval($integral['rank_points']), intval($integral['custom_points']), sprintf(L('order_gift_integral'), $order['order_sn']));
                     }
                 }
             } elseif ($pay_log['order_type'] == PAY_SURPLUS) {
                 $sql = 'SELECT `id` FROM ' . $this->pre . "user_account WHERE `id` = '{$pay_log['order_id']}' AND `is_paid` = 1  LIMIT 1";
                 $res = $this->row($sql);
                 $res_id = $res['id'];
                 if (empty($res_id)) {
                     /* 更新会员预付款的到款状态 */
                     $sql = 'UPDATE ' . $this->pre . "user_account SET paid_time = '" . gmtime() . "', is_paid = 1" . " WHERE id = '{$pay_log['order_id']}' LIMIT 1";
                     $this->query($sql);
                     /* 取得添加预付款的用户以及金额 */
                     $sql = "SELECT user_id, amount FROM " . $this->pre . "user_account WHERE id = '{$pay_log['order_id']}'";
                     $arr = $this->row($sql);
                     /* 修改会员帐户金额 */
                     $_LANG = array();
                     include_once ROOT_PATH . 'languages/' . C('lang') . '/user.php';
                     model('ClipsBase')->log_account_change($arr['user_id'], $arr['amount'], 0, 0, 0, $_LANG['surplus_type_0'], ACT_SAVING);
                 }
             }
         } else {
             /* 取得已发货的虚拟商品信息 */
             $post_virtual_goods = model('OrderBase')->get_virtual_goods($pay_log['order_id'], true);
             /* 有已发货的虚拟商品 */
             if (!empty($post_virtual_goods)) {
                 $msg = '';
                 /* 检查两次刷新时间有无超过12小时 */
                 $sql = 'SELECT pay_time, order_sn FROM ' . $this->pre . "order_info WHERE order_id = '{$pay_log['order_id']}'";
                 $row = $this->row($sql);
                 $intval_time = gmtime() - $row['pay_time'];
                 if ($intval_time >= 0 && $intval_time < 3600 * 12) {
                     $virtual_card = array();
                     foreach ($post_virtual_goods as $code => $goods_list) {
                         /* 只处理虚拟卡 */
                         if ($code == 'virtual_card') {
                             foreach ($goods_list as $goods) {
                                 if ($info = model('OrderBase')->virtual_card_result($row['order_sn'], $goods)) {
                                     $virtual_card[] = array('goods_id' => $goods['goods_id'], 'goods_name' => $goods['goods_name'], 'info' => $info);
                                 }
                             }
                             ECTouch::view()->assign('virtual_card', $virtual_card);
                         }
                     }
                 } else {
                     $msg = '<div>' . L('please_view_order_detail') . '</div>';
                 }
                 $pay_success = L('pay_success') . $msg;
                 L('pay_success', $pay_success);
             }
             /* 取得未发货虚拟商品 */
             $virtual_goods = model('OrderBase')->get_virtual_goods($pay_log['order_id'], false);
             if (!empty($virtual_goods)) {
                 $pay_success = L('pay_success') . '<br />' . L('virtual_goods_ship_fail');
                 L('pay_success', $pay_success);
             }
         }
     }
 }
예제 #11
0
 /**
  *  发送激活验证邮件
  *
  * @access  public
  * @param   int     $user_id        用户ID
  *
  * @return boolen
  */
 function send_regiter_hash($user_id)
 {
     /* 设置验证邮件模板所需要的内容信息 */
     $template = model('Base')->get_mail_template('register_validate');
     $hash = model('Users')->register_hash('encode', $user_id);
     $validate_email = __HOST__ . url('user/validate_email', array('hash' => $hash));
     //ECTouch::ecs()->url() . 'user.php?act=validate_email&hash=' . $hash;
     $sql = "SELECT user_name, email FROM " . $this->pre . "users WHERE user_id = '{$user_id}'";
     $row = $this->row($sql);
     ECTouch::view()->assign('user_name', $row['user_name']);
     ECTouch::view()->assign('validate_email', $validate_email);
     ECTouch::view()->assign('shop_name', C('shop_name'));
     ECTouch::view()->assign('send_date', date(C('date_format')));
     $content = ECTouch::view()->fetch('str:' . $template['template_content']);
     /* 发送激活验证邮件 */
     if (send_mail($row['user_name'], $row['email'], $template['template_subject'], $content, $template['is_html'])) {
         return true;
     } else {
         return false;
     }
 }
예제 #12
0
/**
 * 获得查询时间和次数,并赋值给smarty
 *
 * @access  public
 * @return  void
 */
function assign_query_info() {
    if (M()->queryTime == '') {
        $query_time = 0;
    } else {
        $query_time = number_format(microtime(true) - M()->queryTime, 6);
    }
    ECTouch::view()->assign('query_info', sprintf(L('query_info'), M()->queryCount, $query_time));

    /* 内存占用情况 */
    if (L('memory_info') && function_exists('memory_get_usage')) {
        ECTouch::view()->assign('memory_info', sprintf(L('memory_info'), memory_get_usage() / 1048576));
    }

    /* 是否启用了 gzip */
    $gzip_enabled = gzip_enabled() ? L('gzip_enabled') : L('gzip_disabled');
    ECTouch::view()->assign('gzip_enabled', $gzip_enabled);
}
 /**
  * ajax获取推荐列表
  * 最新团拼 热门品牌 护肤 彩妆 个人护理 香氛 男士专区 家庭护理 母婴专区
  */
 public function ajax_recommend()
 {
     if (IS_AJAX) {
         $list = array();
         //  获得首页推荐的团拼
         $groupbuy_list = model('Groupbuy')->group_buy_list(2, 1, 'act_id', 'DESC');
         if ($groupbuy_list) {
             $this->assign('cate', ['name' => 'group_buy_last', 'url' => '/default/group_buy/index']);
             $list[] = ['single_item' => ECTouch::view()->fetch('library/cate_header.lbi')];
             foreach ($groupbuy_list as $key => $value) {
                 $value['url'] = '/index.php?m=default&c=goods&a=index&id=' . $value['goods_id'];
                 $value['group_remain'] = $value['end_time'] - time();
                 $this->assign('groupbuy', $value);
                 $list[] = array('single_item' => ECTouch::view()->fetch('library/async_groupbuy_index.lbi'));
             }
         }
         //  获取热门品牌列表
         $brand_list = model('Brand')->get_brands('brand', 6, 1);
         if ($brand_list) {
             $this->assign('cate', ['name' => 'hot_brand', 'url' => '/default/brand/index']);
             $list[] = ['single_item' => ECTouch::view()->fetch('library/cate_header.lbi')];
             $this->assign('brand_list', $brand_list);
             $list[] = array('single_item' => ECTouch::view()->fetch('library/brand_index.lbi'));
         }
         //  获取分类下最热的商品,暂不设价格区间
         $category_list = model('Category')->get_cat_list(0);
         if ($category_list) {
             foreach ($category_list as $category) {
                 $subcate_list = model('Category')->get_cat_list($category['cat_id']);
                 if ($category['style'] && $subcate_list) {
                     //  分类的banner
                     $position_id = model('Adposition')->getPositionId($category['style']);
                     if ($position_id) {
                         $ads = model('Ad')->getAds($position_id);
                         if ($ads) {
                             $this->assign('ads', $ads);
                             $this->assign('id', $category['style'] . '-banner');
                             $list[] = ['single_item' => ECTouch::view()->fetch('library/cate_banner.lbi')];
                         }
                     }
                     //  分类名称
                     $this->assign('cate', ['name' => 'cate_' . $category['style'], 'style' => $category['style'], 'url' => '/index.php?m=default&c=category&a=index&id=' . $category['cat_id']]);
                     $list[] = ['single_item' => ECTouch::view()->fetch('library/cate_header.lbi')];
                     $this->assign('subcate_list', $subcate_list);
                     $this->assign('valid_count', count($subcate_list));
                     $list[] = array('single_item' => ECTouch::view()->fetch('library/async_catelist_index.lbi'));
                 }
             }
         }
         echo json_encode($list);
         exit;
     } else {
         $this->redirect(url('index'));
     }
 }
예제 #14
0
    /**
     * 发红包:发货时发红包
     * @param   int     $order_id   订单号
     * @return  bool
     */
    function send_order_bonus($order_id) {
        /* 取得订单应该发放的红包 */
        $bonus_list = model('Order')->order_bonus($order_id);

        /* 如果有红包,统计并发送 */
        if ($bonus_list) {
            /* 用户信息 */
            $sql = "SELECT u.user_id, u.user_name, u.email " .
                    "FROM " . $this->pre . "order_info AS o, " .
                    $this->pre . "users AS u " .
                    "WHERE o.order_id = '$order_id' " .
                    "AND o.user_id = u.user_id ";
            $user = $this->row($sql);

            /* 统计 */
            $count = 0;
            $money = '';
            foreach ($bonus_list AS $bonus) {
                $count += $bonus['number'];
                $money .= price_format($bonus['type_money']) . ' [' . $bonus['number'] . '], ';

                /* 修改用户红包 */
                $sql = "INSERT INTO " . $this->pre . "user_bonus (bonus_type_id, user_id) " .
                        "VALUES('$bonus[type_id]', '$user[user_id]')";
                for ($i = 0; $i < $bonus['number']; $i++) {
                    if (!$this->query($sql)) {
                        return M()->errorMsg();
                    }
                }
            }

            /* 如果有红包,发送邮件 */
            if ($count > 0) {
                $tpl = model('Base')->get_mail_template('send_bonus');
                ECTouch::view()->assign('user_name', $user['user_name']);
                ECTouch::view()->assign('count', $count);
                ECTouch::view()->assign('money', $money);
                ECTouch::view()->assign('shop_name', C('shop_name'));
                ECTouch::view()->assign('send_date', local_date(C('date_format')));
                ECTouch::view()->assign('sent_date', local_date(C('date_format')));
                $content = ECTouch::view()->fetch('str:' . $tpl['template_content']);
                send_mail($user['user_name'], $user['email'], $tpl['template_subject'], $content, $tpl['is_html']);
            }
        }

        return true;
    }
    /**
     * 优惠活动 - 活动商品列表 -异步加载
     */
    public function asynclist_list() {
        $this->parameter();
        $id = intval(I('request.id'));
        if (!$id) {
            $url = url('activity/index');
            ecs_header("Location: $url\n");
        }
        $res = $this->model->table('favourable_activity')->field()->where("act_id = '$id'")->order('sort_order ASC')->find();
        $list = array();

        if ($res['act_range'] != FAR_ALL && !empty($res['act_range_ext'])) {
            if ($res['act_range'] == FAR_CATEGORY) {
                $this->children = " cat_id " . db_create_in(get_children_cat($res['act_range_ext']));
            } elseif ($res['act_range'] == FAR_BRAND) {
                $this->brand = "g.brand_id " . db_create_in($res['act_range_ext']);
            } else {
                $this->goods = " AND g.goods_id " . db_create_in($res['act_range_ext']);
            }
        }
        $this->assign('id', $id);
        $asyn_last = intval(I('post.last')) + 1;
        $this->size = I('post.amount');
        $this->page = ($asyn_last > 0) ? ceil($asyn_last / $this->size) : 1;
        $goodslist = model('Activity')->category_get_goods($this->children, $this->brand, $this->goods, $this->price_min, $this->price_max, $this->ext, $this->size, $this->page, $this->sort, $this->order);
        foreach ($goodslist as $key => $value) {
            $this->assign('act_goods', $value);
            $sayList [] = array(
                'single_item' => ECTouch::view()->fetch('library/asynclist_info.lbi')
            );
        }
        die(json_encode($sayList));
        exit();
    }
예제 #16
0
 /**
  *  虚拟卡发货
  *
  * @access  public
  * @param   string      $goods      商品详情数组
  * @param   string      $order_sn   本次操作的订单
  * @param   string      $msg        返回信息
  * @param   string      $process    设定当前流程:split,发货分单流程;other,其他,默认。
  *
  * @return  boolen
  */
 function virtual_card_shipping($goods, $order_sn, &$msg, $process = 'other')
 {
     /* 检查有没有缺货 */
     $sql = "SELECT COUNT(*) as count FROM " . $this->pre . "virtual_card WHERE goods_id = '{$goods['goods_id']}' AND is_saled = 0 ";
     $result = $this->row($sql);
     $num = $result['count'];
     if ($num < $goods['num']) {
         $msg .= sprintf(L('virtual_card_oos'), $goods['goods_name']);
         return false;
     }
     /* 取出卡片信息 */
     $sql = "SELECT card_id, card_sn, card_password, end_date, crc32 FROM " . $this->pre . "virtual_card WHERE goods_id = '{$goods['goods_id']}' AND is_saled = 0  LIMIT " . $goods['num'];
     $arr = $this->query($sql);
     $card_ids = array();
     $cards = array();
     foreach ($arr as $virtual_card) {
         $card_info = array();
         /* 卡号和密码解密 */
         if ($virtual_card['crc32'] == 0 || $virtual_card['crc32'] == crc32(AUTH_KEY)) {
             $card_info['card_sn'] = decrypt($virtual_card['card_sn']);
             $card_info['card_password'] = decrypt($virtual_card['card_password']);
         } elseif ($virtual_card['crc32'] == crc32(OLD_AUTH_KEY)) {
             $card_info['card_sn'] = decrypt($virtual_card['card_sn'], OLD_AUTH_KEY);
             $card_info['card_password'] = decrypt($virtual_card['card_password'], OLD_AUTH_KEY);
         } else {
             $msg .= 'error key';
             return false;
         }
         $card_info['end_date'] = date(C('date_format'), $virtual_card['end_date']);
         $card_ids[] = $virtual_card['card_id'];
         $cards[] = $card_info;
     }
     /* 标记已经取出的卡片 */
     $sql = "UPDATE " . $this->pre . "virtual_card SET " . "is_saled = 1 ," . "order_sn = '{$order_sn}' " . "WHERE " . db_create_in($card_ids, 'card_id');
     if (!$this->query($sql)) {
         $msg .= M()->error();
         return false;
     }
     /* 更新库存 */
     $sql = "UPDATE " . $this->pre . "goods SET goods_number = goods_number - '{$goods['num']}' WHERE goods_id = '{$goods['goods_id']}'";
     $this->query($sql);
     if (true) {
         /* 获取订单信息 */
         $sql = "SELECT order_id, order_sn, consignee, email FROM " . $this->pre . "order_info WHERE order_sn = '{$order_sn}'";
         $order = M()->GetRow($sql);
         /* 更新订单信息 */
         if ($process == 'split') {
             $sql = "UPDATE " . $this->pre . "order_goods SET send_number = send_number + '" . $goods['num'] . "'\r\n                    WHERE order_id = '" . $order['order_id'] . "'\r\n                    AND goods_id = '" . $goods['goods_id'] . "' ";
         } else {
             $sql = "UPDATE " . $this->pre . "order_goods SET send_number = '" . $goods['num'] . "'\r\n                    WHERE order_id = '" . $order['order_id'] . "'\r\n                    AND goods_id = '" . $goods['goods_id'] . "' ";
         }
         if (!$this->query($sql)) {
             $msg .= M()->error();
             return false;
         }
     }
     /* 发送邮件 */
     ECTouch::view()->assign('virtual_card', $cards);
     ECTouch::view()->assign('order', $order);
     ECTouch::view()->assign('goods', $goods);
     ECTouch::view()->assign('send_time', date('Y-m-d H:i:s'));
     ECTouch::view()->assign('shop_name', C('shop_name'));
     ECTouch::view()->assign('send_date', date('Y-m-d'));
     ECTouch::view()->assign('sent_date', date('Y-m-d'));
     $tpl = model('Base')->get_mail_template('virtual_card');
     $content = ECTouch::view()->fetch('str:' . $tpl['template_content']);
     send_mail($order['consignee'], $order['email'], $tpl['template_subject'], $content, $tpl['is_html']);
     return true;
 }
예제 #17
0
 /**
  * 获取配送地址列表
  */
 public function consignee_list()
 {
     if (IS_AJAX) {
         $start = $_POST['last'];
         $limit = $_POST['amount'];
         // 获得用户所有的收货人信息
         $consignee_list = model('Users')->get_consignee_list($_SESSION['user_id'], 0, $limit, $start);
         if ($consignee_list) {
             foreach ($consignee_list as $k => $v) {
                 $address = '';
                 if ($v['province']) {
                     $address .= model('RegionBase')->get_region_name($v['province']);
                 }
                 if ($v['city']) {
                     $address .= model('RegionBase')->get_region_name($v['city']);
                 }
                 if ($v['district']) {
                     $address .= model('RegionBase')->get_region_name($v['district']);
                 }
                 $v['address'] = $address . ' ' . $v['address'];
                 $v['url'] = url('flow/consignee', array('id' => $v['address_id']));
                 $this->assign('consignee', $v);
                 $sayList[] = array('single_item' => ECTouch::view()->fetch('library/asynclist_info.lbi'));
             }
         }
         die(json_encode($sayList));
         exit;
     }
     // 赋值于模板
     $this->assign('title', L('consignee_info'));
     // 加载user语言包
     require APP_PATH . C('_APP_NAME') . '/language/' . C('LANG') . '/user.php';
     $_LANG = array_merge(L(), $_LANG);
     $this->assign('lang', $_LANG);
     $this->display('flow_consignee_list.dwt');
 }
예제 #18
0
 /**
  * 获得指定分类下的商品
  *
  * @access  public
  * @param   integer     $cat_id     分类ID
  * @param   integer     $num        数量
  * @param   string      $from       来自web/wap的调用
  * @param   string      $order_rule 指定商品排序规则
  * @return  array
  */
 function assign_cat_goods($cat_id, $num = 0, $from = 'web', $order_rule = '')
 {
     $children = get_children($cat_id);
     $sql = 'SELECT g.goods_id, g.goods_name, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'g.promote_price, promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img ' . "FROM " . $this->pre . 'goods AS g ' . "LEFT JOIN " . $this->pre . "member_price AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . 'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ' . 'g.is_delete = 0 AND (' . $children . 'OR ' . model('Goods')->get_extension_goods($children) . ') ';
     $order_rule = empty($order_rule) ? 'ORDER BY g.sort_order, g.goods_id DESC' : $order_rule;
     $sql .= $order_rule;
     if ($num > 0) {
         $sql .= ' LIMIT ' . $num;
     }
     $res = $this->query($sql);
     $goods = array();
     foreach ($res as $idx => $row) {
         if ($row['promote_price'] > 0) {
             $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
             $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
         } else {
             $goods[$idx]['promote_price'] = '';
         }
         $goods[$idx]['id'] = $row['goods_id'];
         $goods[$idx]['name'] = $row['goods_name'];
         $goods[$idx]['brief'] = $row['goods_brief'];
         $goods[$idx]['market_price'] = price_format($row['market_price']);
         $goods[$idx]['short_name'] = C('goods_name_length') > 0 ? sub_str($row['goods_name'], C('goods_name_length')) : $row['goods_name'];
         $goods[$idx]['shop_price'] = price_format($row['shop_price']);
         $goods[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
         $goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
         $goods[$idx]['url'] = build_uri('goods/index', array('id' => $row['goods_id']));
     }
     if ($from == 'web') {
         ECTouch::view()->assign('cat_goods_' . $cat_id, $goods);
     } elseif ($from == 'wap') {
         $cat['goods'] = $goods;
     }
     /* 分类信息 */
     $sql = 'SELECT cat_name FROM ' . $this->pre . "category WHERE cat_id = '{$cat_id}'";
     $result = $this->row($sql);
     $cat['name'] = $result['cat_name'];
     $cat['url'] = build_uri('category/index', array('id' => $cat_id));
     $cat['id'] = $cat_id;
     return $cat;
 }
예제 #19
0
 /**
  * 异步加载品牌列表
  */
 public function list_asynclist()
 {
     $this->parameter();
     $this->assign('show_marketprice', C('show_marketprice'));
     $brand_id = I('request.brand');
     $brand_info = model('BrandBase')->get_brand_info($brand_id);
     if (empty($brand_info)) {
         ecs_header("Location: ./\n");
         exit;
     }
     $asyn_last = intval(I('post.last')) + 1;
     $this->size = I('post.amount');
     $this->page = $asyn_last > 0 ? ceil($asyn_last / $this->size) : 1;
     $list = model('Brand')->brand_get_goods($brand_id, '', $this->sort, $this->order, $this->size, $this->page);
     foreach ($list as $key => $value) {
         $this->assign('brand_goods', $value);
         $sayList[] = array('single_item' => ECTouch::view()->fetch('library/asynclist_info.lbi'));
     }
     die(json_encode($sayList));
     exit;
 }
예제 #20
0
파일: function.php 프로젝트: m7720647/demo
/**
 *  用户进行密码找回操作时,发送一封确认邮件
 *
 * @access  public
 * @param   string  $uid          用户ID
 * @param   string  $user_name    用户帐号
 * @param   string  $email        用户Email
 * @param   string  $code         key
 *
 * @return  boolen  $result;
 */
function send_pwd_email($uid, $user_name, $email, $code)
{
    if (empty($uid) || empty($user_name) || empty($email) || empty($code)) {
        ecs_header("Location: " . url('user/get_password_phone') . "\n");
        exit;
    }
    /* 设置重置邮件模板所需要的内容信息 */
    $template = model('Base')->get_mail_template('send_password');
    $reset_email = __HOST__ . url('user/get_password_email', array('uid' => $uid, 'code' => $code));
    ECTouch::view()->assign('user_name', $user_name);
    ECTouch::view()->assign('reset_email', $reset_email);
    ECTouch::view()->assign('shop_name', C('shop_name'));
    ECTouch::view()->assign('send_date', date('Y-m-d'));
    ECTouch::view()->assign('sent_date', date('Y-m-d'));
    $content = ECTouch::view()->fetch('str:' . $template['template_content']);
    /* 发送确认重置密码的确认邮件 */
    if (send_mail($user_name, $email, $template['template_subject'], $content, $template['is_html'])) {
        return true;
    } else {
        return false;
    }
}
예제 #21
0
 /**
  * 显示错误信息
  *
  * @access  public
  * @param   string  $link
  * @param   string  $href
  * @return  void
  */
 function show($link = '', $href = '')
 {
     if ($this->error_no > 0) {
         $message = array();
         $link = empty($link) ? L('back_up_page') : $link;
         $href = empty($href) ? 'javascript:history.back();' : $href;
         $message['url_info'][$link] = $href;
         $message['back_url'] = $href;
         foreach ($this->_message as $msg) {
             $message['content'] = htmlspecialchars($msg);
         }
         $view = ECTouch::view();
         if (isset($view)) {
             assign_template();
             ECTouch::view()->assign('title', L('tips_message'));
             ECTouch::view()->assign('auto_redirect', true);
             ECTouch::view()->assign('message', $message);
             ECTouch::view()->display($this->_template);
         } else {
             die($message['content']);
         }
         exit;
     }
 }
예제 #22
0
 /**
  *  获取指订单的详情
  *
  * @access  public
  * @param   int         $order_id       订单ID
  * @param   int         $user_id        用户ID
  *
  * @return   arr        $order          订单所有信息的数组
  */
 function get_order_detail($order_id, $user_id = 0)
 {
     $order_id = intval($order_id);
     if ($order_id <= 0) {
         ECTouch::err()->add(L('invalid_order_id'));
         return false;
     }
     $order = model('Order')->order_info($order_id);
     //切换手机订单的关联的支付方式
     if ($order['mobile_pay'] <= 0) {
         //查询手机版支付方式的配置参数
         $sql = "SELECT pay_id, pay_config FROM " . $this->pre . 'touch_payment';
         $touch_payment_list = $this->query($sql);
         if (is_array($touch_payment_list)) {
             foreach ($touch_payment_list as $vo) {
                 $touch_store = unserialize($vo['pay_config']);
                 /* 取出已经设置属性的code */
                 $touch_code_list = array();
                 foreach ($touch_store as $key => $value) {
                     if ($value['name'] == 'relate_pay' && $value['value'] == $order['pay_id']) {
                         $touch_pay_id = $vo['pay_id'];
                     }
                 }
             }
         }
         // 默认没有设置关联支付方式的
         if ($touch_pay_id <= 0) {
             $payment_list = model('Order')->available_payment_list(false, 0, true);
             /* 过滤掉余额支付方式 */
             if (is_array($payment_list)) {
                 foreach ($payment_list as $key => $payment) {
                     if ($payment['pay_code'] != 'balance') {
                         $touch_pay_id = $payment['pay_id'];
                         break;
                     }
                 }
             }
         }
         /* 检查订单是否未付款和未发货 以及订单金额是否为0 和支付id是否为改变 */
         if ($touch_pay_id > 0 && $order['pay_status'] == PS_UNPAYED && $order['shipping_status'] == SS_UNSHIPPED && $order['goods_amount'] > 0) {
             //查询电脑版支付方式
             $touch_payment_info = model('Order')->payment_info($touch_pay_id);
             $order['pay_id'] = $touch_payment_info['pay_id'];
             $order['pay_name'] = $touch_payment_info['pay_name'];
             $order_amount = $order['order_amount'] - $order['pay_fee'];
             $pay_fee = pay_fee($touch_pay_id, $order_amount);
             $order_amount += $pay_fee;
             $sql = "UPDATE " . $this->pre . "order_info SET pay_id='{$touch_pay_id}', pay_name='{$touch_payment_info['pay_name']}', pay_fee='{$pay_fee}', order_amount='{$order_amount}', `mobile_pay` = '1'" . " WHERE order_id = '{$order_id}'";
             $this->query($sql);
         }
     }
     //检查订单是否属于该用户
     if ($user_id > 0 && $user_id != $order['user_id']) {
         ECTouch::err()->add(L('no_priv'));
         return false;
     }
     /* 对发货号处理 */
     if (!empty($order['invoice_no'])) {
         $sql = "SELECT shipping_code FROM " . $this->pre . "shipping WHERE shipping_id = '{$order['shipping_id']}'";
         $res = $this->row($sql);
         $shipping_code = $res['shipping_code'];
         $plugin = ROOT_PATH . 'includes/modules/shipping/' . $shipping_code . '.php';
         if (file_exists($plugin)) {
             include_once $plugin;
             $shipping = new $shipping_code();
             $order['invoice_no'] = $shipping->query($order['invoice_no']);
         }
     }
     /* 只有未确认才允许用户修改订单地址 */
     if ($order['order_status'] == OS_UNCONFIRMED) {
         $order['allow_update_address'] = 1;
         //允许修改收货地址
     } else {
         $order['allow_update_address'] = 0;
     }
     /* 获取订单中实体商品数量 */
     $order['exist_real_goods'] = model('Order')->exist_real_goods($order_id);
     /* 如果是未付款状态,生成支付按钮 */
     if ($order['pay_status'] == PS_UNPAYED && ($order['order_status'] == OS_UNCONFIRMED || $order['order_status'] == OS_CONFIRMED)) {
         /*
          * 在线支付按钮
          */
         //支付方式信息
         $payment_info = array();
         $payment_info = Model('Order')->payment_info($order['pay_id']);
         //无效支付方式
         if ($payment_info === false) {
             $order['pay_online'] = '';
         } else {
             //取得支付信息,生成支付代码
             $payment = unserialize_config($payment_info['pay_config']);
             //获取需要支付的log_id
             $order['log_id'] = model('ClipsBase')->get_paylog_id($order['order_id'], $pay_type = PAY_ORDER);
             $order['user_name'] = $_SESSION['user_name'];
             $order['pay_desc'] = $payment_info['pay_desc'];
             /* 调用相应的支付方式文件 */
             include_once ROOT_PATH . 'plugins/payment/' . $payment_info['pay_code'] . '.php';
             /* 取得在线支付方式的支付按钮 */
             $pay_obj = new $payment_info['pay_code']();
             $order['pay_online'] = $pay_obj->get_code($order, $payment);
         }
     } else {
         $order['pay_online'] = '';
     }
     /* 无配送时的处理 */
     $order['shipping_id'] == -1 and $order['shipping_name'] = L('shipping_not_need');
     /* 其他信息初始化 */
     $order['how_oos_name'] = $order['how_oos'];
     $order['how_surplus_name'] = $order['how_surplus'];
     /* 虚拟商品付款后处理 */
     if ($order['pay_status'] != PS_UNPAYED) {
         /* 取得已发货的虚拟商品信息 */
         $virtual_goods = model('OrderBase')->get_virtual_goods($order_id, true);
         $virtual_card = array();
         foreach ($virtual_goods as $code => $goods_list) {
             /* 只处理虚拟卡 */
             if ($code == 'virtual_card') {
                 foreach ($goods_list as $goods) {
                     if ($info = model('OrderBase')->virtual_card_result($order['order_sn'], $goods)) {
                         $virtual_card[] = array('goods_id' => $goods['goods_id'], 'goods_name' => $goods['goods_name'], 'info' => $info);
                     }
                 }
             }
             /* 处理超值礼包里面的虚拟卡 */
             if ($code == 'package_buy') {
                 foreach ($goods_list as $goods) {
                     $sql = 'SELECT g.goods_id FROM ' . $this->pre . 'package_goods AS pg, ' . $this->pre . 'goods AS g ' . "WHERE pg.goods_id = g.goods_id AND pg.package_id = '" . $goods['goods_id'] . "' AND extension_code = 'virtual_card'";
                     $vcard_arr = $this->query($sql);
                     foreach ($vcard_arr as $val) {
                         if ($info = model('OrderBase')->virtual_card_result($order['order_sn'], $val)) {
                             $virtual_card[] = array('goods_id' => $goods['goods_id'], 'goods_name' => $goods['goods_name'], 'info' => $info);
                         }
                     }
                 }
             }
         }
         $var_card = deleteRepeat($virtual_card);
         ECTouch::view()->assign('virtual_card', $var_card);
     }
     /* 确认时间 支付时间 发货时间 */
     if ($order['confirm_time'] > 0 && ($order['order_status'] == OS_CONFIRMED || $order['order_status'] == OS_SPLITED || $order['order_status'] == OS_SPLITING_PART)) {
         $order['confirm_time'] = sprintf(L('confirm_time'), local_date(C('time_format'), $order['confirm_time']));
     } else {
         $order['confirm_time'] = '';
     }
     if ($order['pay_time'] > 0 && $order['pay_status'] != PS_UNPAYED) {
         $order['pay_time'] = sprintf(L('pay_time'), local_date(C('time_format'), $order['pay_time']));
     } else {
         $order['pay_time'] = '';
     }
     if ($order['shipping_time'] > 0 && in_array($order['shipping_status'], array(SS_SHIPPED, SS_RECEIVED))) {
         $order['shipping_time'] = sprintf(L('shipping_time'), local_date(C('time_format'), $order['shipping_time']));
     } else {
         $order['shipping_time'] = '';
     }
     return $order;
 }
예제 #23
0
 /**
  * 拍卖 详情
  */
 public function info()
 {
     /* 取得参数:拍卖活动id */
     $id = isset($_REQUEST['id']) ? intval(I('request.id')) : 0;
     if ($id <= 0) {
         $this->redirect(url('Auction/index'));
         exit;
     }
     /* 取得拍卖活动信息 */
     $auction = model('Auction')->auction_info($id);
     if (empty($auction)) {
         $this->redirect(url('Auction/index'));
         exit;
     }
     /* 缓存id:语言,拍卖活动id,状态,如果是进行中,还要最后出价的时间(如果有的话) */
     $cache_id = C('lang') . '-' . $id . '-' . $auction['status_no'];
     if ($auction['status_no'] == UNDER_WAY) {
         if (isset($auction['last_bid'])) {
             $cache_id = $cache_id . '-' . $auction['last_bid']['bid_time'];
         }
     } elseif ($auction['status_no'] == FINISHED && $auction['last_bid']['bid_user'] == $_SESSION['user_id'] && $auction['order_count'] == 0) {
         $auction['is_winner'] = 1;
         $cache_id = $cache_id . '-' . $auction['last_bid']['bid_time'] . '-1';
     }
     $cache_id = sprintf('%X', crc32($cache_id));
     /* 如果没有缓存,生成缓存 */
     if (!ECTouch::view()->is_cached('auction.dwt', $cache_id)) {
         //取货品信息
         if ($auction['product_id'] > 0) {
             $goods_specifications = model('goodsBase')->get_specifications_list($auction['goods_id']);
             $good_products = model('ProductsBase')->get_good_products($auction['goods_id'], 'AND product_id = ' . $auction['product_id']);
             $_good_products = explode('|', $good_products[0]['goods_attr']);
             $products_info = '';
             foreach ($_good_products as $value) {
                 $products_info .= ' ' . $goods_specifications[$value]['attr_name'] . ':' . $goods_specifications[$value]['attr_value'];
             }
             $this->assign('products_info', $products_info);
             unset($goods_specifications, $good_products, $_good_products, $products_info);
         }
         $auction['gmt_end_time'] = local_strtotime($auction['end_time']);
         $this->assign('auction', $auction);
         //print_r($auction );
         /* 取得拍卖商品信息 */
         $goods_id = $auction['goods_id'];
         $goods = model('Goods')->goods_info($goods_id);
         if (empty($goods)) {
             $this->redirect(url('Auction/index'));
             exit;
         }
         $goods['url'] = url('goods/index', array('id' => $goods_id));
         $this->assign('auction_goods', $goods);
         // 商品相册
         $this->assign('pictures', model('GoodsBase')->get_goods_gallery($goods_id));
         // print_r($goods );
     }
     //更新商品点击次数
     $sql = 'UPDATE ' . $this->model->pre . 'goods SET click_count = click_count + 1 ' . "WHERE goods_id = '" . $auction['goods_id'] . "'";
     $this->model->query($sql);
     $this->assign('now_time', gmtime());
     // 当前系统时间
     $this->assign('title', L('auction_goods_info'));
     $this->display('aution.dwt');
 }
예제 #24
0
 /**
  * 信息中心
  */
 public function msg_list()
 {
     if (IS_AJAX) {
         $order_id = I('get.order_id', 0);
         $start = $_POST['last'];
         $limit = $_POST['amount'];
         // 获取信息
         $message_list = model('ClipsBase')->get_message_list($this->user_id, $_SESSION['user_name'], $limit, $start, $order_id);
         if (is_array($message_list)) {
             // 修改信息状态
             $sql = 'SELECT parent_id FROM ' . $this->model->pre . 'feedback WHERE parent_id in (SELECT f.msg_id FROM ' . $this->model->pre . 'feedback f LEFT JOIN ' . $this->model->pre . 'touch_feedback t ON f.msg_id = t.msg_id WHERE f.parent_id = 0 AND f.user_id = ' . $this->user_id . ' AND t.msg_read = 0 ORDER BY msg_time DESC) ORDER BY msg_time DESC';
             $rs = $this->model->query($sql);
             if ($rs) {
                 foreach ($rs as $v) {
                     $where['msg_id'] = $v['parent_id'];
                     $data['msg_read'] = 1;
                     $this->model->table('touch_feedback')->data($data)->where($where)->update();
                 }
             }
             foreach ($message_list as $key => $vo) {
                 $this->assign('msg', $vo);
                 $sayList[] = array('single_item' => ECTouch::view()->fetch('library/asynclist_info.lbi'));
             }
         }
         echo json_encode($sayList);
         exit;
     } else {
         $order_id = I('request.order_id') ? intval(I('request.order_id')) : 0;
         /* 获取用户留言的数量 */
         if ($order_id) {
             $sql = "SELECT COUNT(*) as count FROM " . $this->model->pre . "feedback WHERE parent_id = 0 AND order_id = '{$order_id}' AND user_id = '{$this->user_id}'";
             $order_info = $this->row("SELECT * FROM " . $this->model->pre . "order_info WHERE order_id = '{$order_id}' AND user_id = '{$this->user_id}'");
             $order_info['url'] = url('user/order_detail', array('order_id' => $order_id));
         } else {
             $sql = "SELECT COUNT(*) as count FROM " . $this->model->pre . "feedback WHERE parent_id = 0 AND user_id = '{$this->user_id}' AND user_name = '" . $_SESSION['user_name'] . "' AND order_id=0";
         }
         $count = $this->model->getRow($sql);
         $filter['page'] = '{page}';
         $offset = $this->pageLimit(url('msg_list', $filter), 5);
         $offset_page = explode(',', $offset);
         // 获取信息
         $message_list = model('ClipsBase')->get_message_list($this->user_id, $_SESSION['user_name'], $offset_page[1], $offset_page[0], $order_id);
         $this->assign('pager', $this->pageShow($count['count']));
         $this->assign('message_list', $message_list);
     }
     $this->assign('title', L('user_service_list'));
     $this->display('user_msg_list.dwt');
 }
 /**
  * 信息中心
  */
 public function msg_list()
 {
     if (IS_AJAX) {
         $order_id = I('get.order_id', 0);
         $start = $_POST['last'];
         $limit = $_POST['amount'];
         
         // 获取信息
         $message_list = model('ClipsBase')->get_message_list($this->user_id, $_SESSION['user_name'], $limit, $start, $order_id);
         if (is_array($message_list)) {
             // 修改信息状态
             $sql = 'SELECT parent_id FROM ' . $this->model->pre . 'feedback WHERE parent_id in (SELECT f.msg_id FROM ' . $this->model->pre . 'feedback f LEFT JOIN ' . $this->model->pre . 'touch_feedback t ON f.msg_id = t.msg_id WHERE f.parent_id = 0 AND f.user_id = ' . $this->user_id . ' AND t.msg_read = 0 ORDER BY msg_time DESC) ORDER BY msg_time DESC';
             $rs = $this->model->query($sql);
             if ($rs) {
                 foreach ($rs as $v) {
                     $where['msg_id'] = $v['parent_id'];
                     $data['msg_read'] = 1;
                     $this->model->table('touch_feedback')
                         ->data($data)
                         ->where($where)
                         ->update();
                 }
             }
             foreach ($message_list as $key => $vo) {
                 $this->assign('msg', $vo);
                 $sayList[] = array(
                     'single_item' => ECTouch::view()->fetch('library/asynclist_info.lbi')
                 );
             }
         }
         echo json_encode($sayList);
         exit();
     }
     $this->assign('title', L('user_service_list'));
     $this->display('user_msg_list.dwt');
 }