/** * 改变支付方式 */ public function select_payment() { $json = new EcsJson(); $result = array('error' => '', 'content' => '', 'need_insure' => 0, 'payment' => 1); /* 取得购物类型 */ $flow_type = isset($_SESSION['flow_type']) ? intval($_SESSION['flow_type']) : CART_GENERAL_GOODS; /* 获得收货人信息 */ $consignee = model('Order')->get_consignee($_SESSION['user_id']); /* 对商品信息赋值 */ $cart_goods = model('Order')->cart_goods($flow_type); // 取得商品列表,计算合计 if (empty($cart_goods) || !model('Order')->check_consignee_info($consignee, $flow_type)) { $result['error'] = L('no_goods_in_cart'); } else { /* 取得购物流程设置 */ $this->assign('config', C('CFG')); /* 取得订单信息 */ $order = model('Order')->flow_order_info(); $order['pay_id'] = intval($_REQUEST['payment']); $payment_info = model('Order')->payment_info($order['pay_id']); $result['pay_code'] = $payment_info['pay_code']; /* 保存 session */ $_SESSION['flow_order'] = $order; /* 计算订单的费用 */ $total = model('Users')->order_fee($order, $cart_goods, $consignee); $this->assign('total', $total); /* 取得可以得到的积分和红包 */ $this->assign('total_integral', model('Order')->cart_amount(false, $flow_type) - $total['integral_money']); $result['content'] = ECTouch::$view->fetch('library/order_total.lbi'); } echo $json->encode($result); exit; }
/** * 编辑专题 */ public function edit() { $id = I('id'); if (!$id) { $this->redirect(url('index')); } if (IS_POST) { $data = I('data'); /* 数据验证 */ $msg = Check::rule(array(array(Check::must($_POST['topic_name']), L('topic_name_empty')), array(Check::must($_POST['start_time']), L('start_time_empty')), array(Check::must($_POST['end_time']), L('end_time_empty')))); /* 提示信息 */ if ($msg !== true) { $this->message($msg, NULL, 'error'); } $topic_type = empty($data['topic_type']) ? 0 : intval($data['topic_type']); switch ($topic_type) { case '0': case '1': // 主图上传 if ($_FILES['topic_img']['name'] && $_FILES['topic_img']['size'] > 0) { $result = $this->ectouchUpload('topic_img', 'topic_image'); if ($result['error'] > 0) { $this->message($result['message'], NULL, 'error'); } /* 生成logo链接 */ $topic_img = substr($result['message']['topic_img']['savepath'], 2) . $result['message']['topic_img']['savename']; } else { if (!empty($_POST['url'])) { /* 来自互联网图片 不可以是服务器地址 */ if (strstr(I('post.url'), 'http') && !strstr(I('post.url'), $_SERVER['SERVER_NAME'])) { /* 取互联网图片至本地 */ $topic_img = get_url_image(I('post.url')); } else { sys_msg(L('web_url_no')); } } } $data['topic_img'] = empty($topic_img) ? I('post.img_url') : $topic_img; $htmls = ''; break; case '2': $htmls = I('post.content'); $data['topic_img'] = ''; break; } // 标题图上传 if ($_FILES['title_pic']['name'] && $_FILES['title_pic']['size'] > 0) { $result = $this->ectouchUpload('title_pic', 'topic_image'); if ($result['error'] > 0) { $this->message($result['message'], NULL, 'error'); } /* 生成logo链接 */ $data['title_pic'] = substr($result['message']['title_pic']['savepath'], 2) . $result['message']['title_pic']['savename']; } else { if (!empty($_REQUEST['title_url'])) { /* 来自互联网图片 不可以是服务器地址 */ if (strstr(I('post.title_url'), 'http') && !strstr(I('post.title_url'), $_SERVER['SERVER_NAME'])) { /* 取互联网图片至本地 */ $data['title_pic'] = get_url_image(I('post.title_url')); } else { sys_msg(L('web_url_no')); } } } unset($target); $data['title'] = I('post.topic_name'); $title_pic = empty($data['title_pic']) ? I('post.title_img_url') : $data['title_pic']; $data['template'] = I('post.topic_template_file') ? I('post.topic_template_file') : ''; $data['start_time'] = local_strtotime(I('post.start_time')); $data['end_time'] = local_strtotime(I('post.end_time')); $json = new EcsJson(); $tmp_data = $json->decode($_POST['topic_data']); $data['data'] = serialize($tmp_data); $data['intro'] = I('post.topic_intro'); $this->model->table('touch_topic')->data($data)->where('topic_id =' . $id)->update(); $this->message(L('succed'), url('index')); } /* 模板赋值 */ $topic = $this->model->table('touch_topic')->field('*')->where('topic_id =' . $id)->find(); $topic['start_time'] = local_date('Y-m-d', $topic['start_time']); $topic['end_time'] = local_date('Y-m-d', $topic['end_time']); $topic['topic_intro'] = html_out($topic['intro']); $topic['intro'] = html_out($topic['intro']); $json = new EcsJson(); if ($topic['data']) { $topic['data'] = addcslashes($topic['data'], "'"); $topic['data'] = $json->encode(@unserialize($topic['data'])); $topic['data'] = addcslashes($topic['data'], "'"); } if (empty($topic['topic_img']) && empty($topic['htmls'])) { $topic['topic_type'] = 0; } elseif ($topic['htmls'] != '') { $topic['topic_type'] = 2; } elseif (preg_match('/.swf$/i', $topic['topic_img'])) { $topic['topic_type'] = 1; } else { $topic['topic_type'] = ''; } $this->assign('topic', $topic); $this->assign('cat_list', cat_list(0, 1)); $this->assign('brand_list', model('BrandBase')->get_brand_list()); $this->assign('template_list', $this->get_topic_temp_list()); $this->assign('ur_here', L('09_topic')); $this->display(); }
/** * 用户出价处理 */ 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)); }