当前位置: 首页>>代码示例>>PHP>>正文


PHP Import::json方法代码示例

本文整理汇总了PHP中Import::json方法的典型用法代码示例。如果您正苦于以下问题:PHP Import::json方法的具体用法?PHP Import::json怎么用?PHP Import::json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Import的用法示例。


在下文中一共展示了Import::json方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 function index($id = 0)
 {
     $this->css("top.css");
     $this->js('time.js');
     if (!($id > 0)) {
         $id = 6;
     }
     if (!($id > 0)) {
         $this->action('common', 'show404tpl');
     }
     $json = Import::json();
     $rt = $this->Cache->read(3600);
     if (is_null($rt)) {
         $time = mktime();
         $sql = "SELECT * FROM `{$this->App->prefix()}topic` WHERE topic_id='{$id}' AND end_time > '{$time}' LIMIT 1";
         $rt['info'] = $this->App->findrow($sql);
         if (empty($rt['info'])) {
             $this->jump(SITE_URL, '', "该专题已经超过有效期!");
         }
         $rt['info']['goods_ids'] = addcslashes($rt['info']['goods_ids'], "'");
         $tmp = @unserialize($rt['info']["goods_ids"]);
         $arr = (array) $tmp;
         $goods_id = array();
         foreach ($arr as $key => $value) {
             foreach ($value as $k => $val) {
                 $opt = explode('|', $val);
                 $arr[$key][$k] = $opt[1];
                 $goods_id[] = $opt[1];
             }
         }
         $sql = "SELECT goods_id,goods_name,goods_thumb,goods_img,shop_price,pifa_price FROM `{$this->App->prefix()}goods` WHERE goods_id IN(" . implode(',', $goods_id) . ")";
         $rts = $this->App->find($sql);
         foreach ($rts as $rows) {
             foreach ($arr as $key => $value) {
                 foreach ($value as $val) {
                     if ($val == $rows['goods_id']) {
                         $key = $key == 'default' ? 'default' : $key;
                         $sort_goods_arr[$key][] = $rows;
                     }
                 }
             }
         }
         $rt['goodslist'] = $sort_goods_arr;
         unset($sort_goods_arr, $tts);
         //预告
         $t1 = date('Y-m-d', mktime() + 24 * 3600);
         //$t2 = date('Y-m-d',mktime()-24*3600);
         $rt['yugao'] = array();
         $sql = "SELECT tb1.article_title,tb1.article_img,tb2.cat_name,tb2.cat_title AS date1 FROM `{$this->App->prefix()}article` AS tb1 LEFT JOIN `{$this->App->prefix()}article_cate` AS tb2 ON tb1.cat_id = tb2.cat_id WHERE tb2.type='case' AND tb2.cat_name ='{$t1}'  ORDER BY tb2.cat_title DESC";
         $rt['yugao'] = $this->App->find($sql);
         $this->Cache->write($rt);
     }
     $title = $rt['info']['topic_name'];
     $this->title($title . ' - ' . $GLOBALS['LANG']['site_name']);
     $this->meta("title", $title);
     $this->meta("keywords", htmlspecialchars($rt['info']['meta_keys']));
     $this->meta("description", htmlspecialchars($rt['info']['meta_desc']));
     $this->set('rt', $rt);
     $this->template('topgoods');
 }
开发者ID:jasonhzy,项目名称:fx_demo,代码行数:60,代码来源:controller.php

示例2: ajax_searchGoods

 function ajax_searchGoods($data = "")
 {
     $err = 0;
     $result = array('error' => $err, 'message' => '');
     $json = Import::json();
     if (empty($data)) {
         $result['error'] = 2;
         $result['message'] = '传送的数据为空!';
         die($json->encode($result));
     }
     $art = $json->decode($data);
     //反json
     $cat_id = $art->cat_id;
     $brand_id = $art->brand_id;
     $keyword = $art->keyword;
     $comd = array();
     if (intval($cat_id) > 0) {
         $cids = $this->action('common', 'get_goods_sub_cat_ids', $cat_id);
         $comd[] = 'cat_id IN(' . implode(",", $cids) . ')';
     }
     if (intval($brand_id) > 0) {
         $comd[] = "brand='{$brand_id}'";
     }
     if (!empty($keyword)) {
         $comd[] = "goods_name LIKE '%{$keyword}%'";
     }
     if (empty($comd)) {
         $result['error'] = 2;
         $result['message'] = '';
         die($json->encode($result));
     }
     $sql = "SELECT goods_id,goods_name FROM `{$this->App->prefix()}goods` WHERE " . implode(' AND ', $comd) . " ORDER BY goods_id DESC LIMIT 20";
     $rt = $this->App->find($sql);
     $result['error'] = 1;
     $result['message'] = $rt;
     die($json->encode($result));
 }
开发者ID:zhaoshengloveqingqing,项目名称:fenxiao,代码行数:37,代码来源:controller.php

示例3: ajax_getcategoodslist

 function ajax_getcategoodslist($w = array())
 {
     $err = 0;
     $json = Import::json();
     $result = array('error' => $err, 'message' => '');
     if (empty($w)) {
         $result['error'] = 2;
         $result['message'] = '传送的数据为空!';
         die($json->encode($result));
     }
     $wobj = $json->decode($w);
     //反json ,返回值为对象
     $page = $wobj->page;
     if (!$page) {
         $page = 1;
     }
     $cid = $wobj->cid;
     if (!$cid) {
         $cid = 0;
     }
     $bid = $wobj->bid;
     if (!$bid) {
         $bid = 0;
     }
     $price = $wobj->price;
     if (!$price) {
         $price = "";
     }
     $order_type = $wobj->order;
     if (!$order_type) {
         $order_type = "goods_id";
     }
     $keyword = $wobj->keyword;
     if (!$keyword) {
         $keyword = "";
     }
     $sort_type = $wobj->sorts;
     if (empty($sort_type)) {
         $sort_type = "DESC";
     }
     $list = $wobj->limit;
     if (!$list) {
         $list = 40;
     }
     if (!empty($keyword) && !(preg_match('/^.*$/u', $keyword) > 0)) {
         $keyword = Import::gz_iconv()->ec_iconv('GB2312', 'UTF8', $keyword);
         //编码转换
     }
     $rt['thiscid'] = $cid;
     $rt['thisbid'] = $bid;
     $rt['price'] = $price;
     $rt['page'] = $page;
     $rt['sort'] = $sort_type;
     $rt['order'] = $order_type;
     $rt['limit'] = $list;
     //当前分类的基本信息
     if ($cid > 0) {
         $sql = "SELECT * FROM `{$this->App->prefix()}goods_cate` WHERE cat_id='{$cid}' LIMIT 1";
         $rt['cateinfo'] = $this->App->findrow($sql);
     } else {
         $rt['cateinfo'] = array();
         //查找时没有cid
     }
     //品牌信息
     if ($bid > 0) {
         $sql = "SELECT brand_name FROM `{$this->App->prefix()}brand` WHERE brand_id='{$bid}' LIMIT 1";
         $rt['brandinfo']['brand_name'] = $this->App->findvar($sql);
     } else {
         $rt['brandinfo']['brand_name'] = "";
     }
     //显示方式
     if (!isset($_COOKIE['DISPLAY_TYPE']) || empty($_COOKIE['DISPLAY_TYPE']) || !in_array($_COOKIE['DISPLAY_TYPE'], array('list', 'text'))) {
         $rt['display'] = 'text';
     } else {
         $rt['display'] = $_COOKIE['DISPLAY_TYPE'];
     }
     //start 当前位置
     $rt['hear'] = array();
     $perend_id = 0;
     $hear[] = '<a href="' . SITE_URL . '">首页</a>';
     $hear[] = '<a href="' . get_url('商品中心', 0, SITE_URL . "costume.php", 'goodscate', array('catalog', 'index')) . '">商品中心</a>';
     if ($cid > 0) {
         $rts_ = $this->get_goods_parent_cats($cid);
         //父类ID
         $rts = Import::basic()->array_sort($rts_, 'cat_id');
         //根据cat_id排序
         if (!empty($rts)) {
             $perend_id = $rts[count($rts) - 1]['cat_id'];
             foreach ($rts as $rows) {
                 $hear[] = '<a href="' . get_url($rows['cat_name'], $rows['cat_id'], "costume.php?cid=" . $rows["cat_id"], 'goodscate', array('catalog', 'index', $row['cat_id'])) . '">' . $rows['cat_name'] . '</a>';
             }
         }
         unset($rts, $rts_);
     } elseif ($bid > 0) {
         //品牌
         $hear[] = '<a href="' . SITEURL . 'brand/">品牌中心</a>';
         $hear[] = '<a href="' . get_url($rt['brandinfo']['brand_name'], $rt['brandinfo']['brand_id'], "costume.php?bid=" . $rt['brandinfo']['brand_id'], 'brand') . '">' . $rt['brandinfo']['brand_name'] . '</a>';
     } elseif (!empty($keyword)) {
         $perend_id = -1;
         switch ($keyword) {
//.........这里部分代码省略.........
开发者ID:zhaoshengloveqingqing,项目名称:fenxiao,代码行数:101,代码来源:controller.php

示例4: ajax_save_and_caijigoods

 function ajax_save_and_caijigoods()
 {
     $data = $_GET['message'];
     $err = 0;
     $result = array('error' => $err, 'message' => '');
     $json = Import::json();
     if (empty($data)) {
         $result['error'] = 2;
         $result['message'] = '传送的数据为空!';
         die($json->encode($result));
     }
     $mesobj = $json->decode($data);
     //反json ,返回值为对象
     //以下字段对应评论的表单页面 一定要一致
     $goods_name = $mesobj->goods_name;
     !empty($goods_name) ? $datas['goods_name'] = $goods_name : "";
     $cat_id = $mesobj->cat_id;
     !empty($cat_id) ? $datas['cat_id'] = $cat_id : "";
     $brand_id = $mesobj->brand_id;
     !empty($brand_id) ? $datas['brand_id'] = $brand_id : "";
     $goods_bianhao = $mesobj->goods_bianhao;
     !empty($goods_bianhao) ? $datas['goods_bianhao'] = $goods_bianhao : "";
     $goods_sn = $mesobj->goods_sn;
     !empty($goods_sn) ? $datas['goods_sn'] = $goods_sn : "";
     $goods_unit = $mesobj->goods_unit;
     !empty($goods_unit) ? $datas['goods_unit'] = $goods_unit : "";
     $goods_brief = $mesobj->goods_brief;
     !empty($goods_brief) ? $datas['goods_brief'] = $goods_brief : "";
     $shop_price = $mesobj->shop_price;
     $shop_price > 0 ? $datas['shop_price'] = $shop_price : "";
     $pifa_price = $mesobj->pifa_price;
     if (intval($pifa_price) > 0) {
         $datas['pifa_price'] = intval($pifa_price);
         $datas['market_price'] = $datas['pifa_price'];
     } else {
         $datas['pifa_price'] = $shop_price;
         $datas['market_price'] = $shop_price;
     }
     $goods_number = $mesobj->goods_number;
     intval($goods_number) > 0 ? $datas['goods_number'] = intval($goods_number) : "";
     $warn_number = $mesobj->warn_number;
     intval($warn_number) > 0 ? $datas['warn_number'] = intval($warn_number) : "";
     $meta_keys = $mesobj->meta_keys;
     !empty($meta_keys) ? $datas['meta_keys'] = $meta_keys : "";
     $meta_desc = $mesobj->meta_desc;
     !empty($meta_desc) ? $datas['meta_desc'] = $meta_desc : "";
     $original_img = $mesobj->original_img;
     if (!empty($original_img)) {
         $datas['original_img'] = $original_img;
         $pa = dirname($original_img);
         $thumb = basename($original_img);
         $datas['goods_img'] = $pa . '/thumb_b/' . $thumb;
         $datas['goods_thumb'] = $pa . '/thumb_s/' . $thumb;
     }
     $gid = $mesobj->goods_id;
     if (empty($datas['goods_bianhao'])) {
         $gids = $this->App->findvar("SELECT MAX(goods_id) + 1 FROM `{$this->App->prefix()}goods`");
         $gids = empty($gids) ? 1 : $gids;
         $datas['goods_bianhao'] = '2EJ' . str_repeat('0', 6 - strlen($gids)) . $gids . '-' . $gid;
     }
     //检查是否已经存在
     if (empty($datas['goods_sn'])) {
         $datas['goods_sn'] = $datas['goods_bianhao'];
     }
     $uid = 50;
     $this->App->update('goods_cache_list', $datas, 'goods_id', $gid);
     //更新
     //转移
     $dd = array();
     $dd['goods_number'] = $datas['goods_number'] > 0 ? $datas['goods_number'] : 1000;
     $dd['warn_number'] = $datas['warn_number'] > 0 ? $datas['warn_number'] : 10;
     if ($datas['market_price'] > 0) {
         $dd['market_price'] = $datas['market_price'];
     }
     if ($datas['pifa_price'] > 0) {
         $dd['pifa_price'] = $datas['pifa_price'];
     }
     if ($datas['shop_price'] > 0) {
         $dd['shop_price'] = $datas['shop_price'];
     }
     $sql = "SELECT add_time FROM `{$this->App->prefix()}goods_cache_list` WHERE goods_id='{$gid}'";
     $ad = $this->App->findvar($sql);
     if (empty($ad)) {
         $datas['add_time'] = mktime();
         $this->App->insert('goods', $datas);
         $lastid = $this->App->iid();
         $this->App->update('goods_cache_list', array('add_time' => $datas['add_time'], 'is_zhuanyi' => '1'), 'goods_id', $gid);
         //添加到供应商商品表
         $sql = "SELECT sgid FROM `{$this->App->prefix()}suppliers_goods` WHERE goods_id='{$lastid}' AND suppliers_id='{$uid}'";
         $sgid = $this->App->findvar($sql);
         $dd['is_check'] = 1;
         $dd['is_on_sale'] = 1;
         $dd['goods_id'] = $lastid;
         $dd['suppliers_id'] = $uid;
         $dd['addtime'] = mktime();
         $this->App->insert('suppliers_goods', $dd);
         $result['message'] = '保存并转移成功';
     } else {
         $sql = "SELECT goods_id FROM `{$this->App->prefix()}goods` WHERE add_time='{$ad}'";
         $goodid = $this->App->findvar($sql);
//.........这里部分代码省略.........
开发者ID:zhaoshengloveqingqing,项目名称:fenxiao,代码行数:101,代码来源:controller.php

示例5: ajax_ressinfoop

 function ajax_ressinfoop($data = array())
 {
     $uid = $this->Session->read('User.uid');
     if (isset($data['attrbul']) && !empty($data['attrbul'])) {
         $err = 0;
         $result = array('error' => $err, 'message' => '');
         $json = Import::json();
         $attrbul = $json->decode($data['attrbul']);
         //反json
         if (empty($attrbul)) {
             $result['error'] = 1;
             $result['message'] = "传送的数据为空!";
             die($json->encode($result));
         }
         $id = $attrbul->id;
         $dd = array();
         $type = $attrbul->type;
         $dd['user_id'] = $uid;
         $dd['consignee'] = $attrbul->consignee;
         if (empty($dd['consignee'])) {
             $result['error'] = 1;
             $result['message'] = "收货人姓名不能为空!";
             die($json->encode($result));
         }
         $dd['country'] = 1;
         $dd['province'] = $attrbul->province;
         $dd['city'] = $attrbul->city;
         $dd['district'] = $attrbul->district;
         $dd['address'] = $attrbul->address;
         /*$dd['shoppingname'] = $attrbul->shoppingname;
         		$dd['shoppingtime'] = $attrbul->shoppingtime;*/
         if (empty($dd['province']) || empty($dd['city']) || empty($dd['district']) || empty($dd['address'])) {
             $result['error'] = 1;
             $result['message'] = "收货地址不能为空!";
             die($json->encode($result));
         }
         $dd['sex'] = $attrbul->sex;
         $dd['email'] = $attrbul->email;
         $dd['zipcode'] = $attrbul->zipcode;
         $dd['mobile'] = $attrbul->mobile;
         $dd['tel'] = $attrbul->tel;
         if (empty($dd['mobile']) && empty($dd['tel'])) {
             $result['error'] = 1;
             $result['message'] = "电话或者手机必须填写一个!";
             die($json->encode($result));
         }
         $dd['is_default'] = '1';
         if (!($id > 0) && $type == 'add') {
             //添加
             $this->App->update('user_address', array('is_default' => '0'), 'user_id', $uid);
             $this->App->insert('user_address', $dd);
         } elseif ($type == 'update') {
             //编辑
             $this->App->update('user_address', $dd, 'address_id', $id);
         }
         unset($dd);
         if (empty($dd['mobile']) && empty($dd['tel'])) {
             $result['error'] = 0;
             $result['message'] = "操作成功!";
             die($json->encode($result));
         }
         exit;
     }
     $id = $data['id'];
     $type = $data['type'];
     if (!empty($id) && !empty($type)) {
         switch ($type) {
             case 'delete':
                 //删除收货地址
                 $this->App->delete('user_address', 'address_id', $id);
                 break;
             case 'setdefaut':
                 //设为默认收货地址
                 if (!empty($uid)) {
                     $this->App->update('user_address', array('is_default' => '0'), 'user_id', $uid);
                     $this->App->update('user_address', array('is_default' => '1'), 'address_id', $id);
                 }
                 break;
             case 'quxiao':
                 //取消收货地址
                 $this->App->update('user_address', array('is_default' => '0'), 'address_id', $id);
                 break;
             case 'showupdate':
                 //当前用户的收货地址
                 $sql = "SELECT * FROM `{$this->App->prefix()}user_address` WHERE user_id='{$uid}' AND address_id='{$id}'";
                 $rt['userress'] = $this->App->findrow($sql);
                 $rt['province'] = $this->get_regions(1);
                 //获取省列表
                 $rt['city'] = $this->get_regions(2, $rt['userress']['province']);
                 //城市
                 $rt['district'] = $this->get_regions(3, $rt['userress']['city']);
                 //区
                 $this->set('rt', $rt);
                 $con = $this->fetch('ajax_show_updateressbox', true);
                 die($con);
                 break;
         }
     }
 }
开发者ID:jasonhzy,项目名称:fx_demo,代码行数:99,代码来源:controller.php

示例6: ajax_comment

 function ajax_comment($data = array(), $page = 0)
 {
     $err = 0;
     $result = array('error' => $err, 'message' => '');
     $json = Import::json();
     if (!($page > 0)) {
         $page = 1;
         if (empty($data['comments'])) {
             $result['error'] = 1;
             $result['message'] = '意外错误,传送的数据为空!';
             die($json->encode($result));
         }
         $comments = $json->decode($data['comments']);
         //反json ,返回值为对象
         $goods_id = $comments->goods_id;
         if (!(intval($goods_id) > 0)) {
             $result['error'] = 1;
             $result['message'] = '意外错误,传送的数据为空!';
             die($json->encode($result));
         }
         //以下字段对应评论的表单页面 一定要一致
         $datas['id_value'] = $goods_id;
         //$datas['email'] = $comments->email;
         $username = $this->Session->read('User.username');
         $uid = $this->Session->read('User.uid');
         $error2 = false;
         $datas['user_name'] = !empty($username) ? $username : "";
         if (empty($datas['user_name']) || !($uid > 0)) {
             //需要登录
             $result['error'] = 4;
             $result['message'] = '你还没有登录!请你先登录!';
             die($json->encode($result));
         }
         //检查是否已经存在购买商品
         $sql = "SELECT tb1.rec_id FROM `{$this->App->prefix()}goods_order` AS tb1";
         $sql .= " LEFT JOIN `{$this->App->prefix()}goods_order_info` AS tb2 ON tb1.order_id=tb2.order_id";
         $sql .= " WHERE tb1.goods_id='{$goods_id}' AND tb2.user_id='{$uid}' AND tb2.order_status='2' AND tb2.pay_status='1'";
         $re_id = $this->App->findvar($sql);
         if (!($re_id > 0)) {
             //不存在该记录!
             $result['error'] = 1;
             $result['message'] = '抱歉,你还没有购买当前商品,不能评论哦!';
             die($json->encode($result));
         }
         //检查该商品是否已经评论过
         $sql = "SELECT comment_id FROM `{$this->App->prefix()}comment` WHERE id_value='{$goods_id}' AND user_id='{$uid}' LIMIT 1";
         $comment_id = $this->App->findvar($sql);
         if ($comment_id > 0) {
             //存在该记录!
             $result['error'] = 1;
             $result['message'] = '抱歉,你已经评论过该商品,不能再评论哦!';
             die($json->encode($result));
         }
         $datas['content'] = $comments->comment;
         if (empty($datas['content'])) {
             $result['error'] = 1;
             $result['message'] = '请填写评论内容!';
             die($json->encode($result));
         }
         if (strlen($datas['content']) < 12) {
             $result['error'] = 1;
             $result['message'] = '评论内容不能太少!';
             die($json->encode($result));
         }
         //限制用户不能重复提交评论,需要等待三分钟后才能评论
         $read_time = $this->Session->read("Comment.{$goods_id}");
         if (!empty($read_time)) {
             if (mktime() - $read_time < 200) {
                 $result['error'] = 3;
                 $result['message'] = '你刚才已经发表了评论,请你稍等下再发表!';
                 die($json->encode($result));
             }
         }
         $this->Session->write("Comment.{$goods_id}", mktime());
         $datas['comment_rank'] = $comments->comment_rank;
         $datas['goods_rand'] = $comments->goods_rand;
         $datas['goods_rand'] = empty($datas['goods_rand']) ? 5 : $datas['goods_rand'];
         $datas['shopping_rand'] = $comments->shopping_rand;
         $datas['shopping_rand'] = empty($datas['shopping_rand']) ? 5 : $datas['shopping_rand'];
         $datas['saleafter_rand'] = $comments->saleafter_rand;
         $datas['saleafter_rand'] = empty($datas['saleafter_rand']) ? 5 : $datas['saleafter_rand'];
         $datas['status'] = '1';
         $datas['add_time'] = mktime();
         $ip = Import::basic()->getip();
         $datas['ip_address'] = $ip ? $ip : '0.0.0.0';
         $datas['ip_form'] = Import::ip()->ipCity($ip);
         $datas['user_id'] = intval($uid) > 0 ? intval($uid) : 0;
         $this->App->insert('comment', $datas);
         unset($datas, $data);
     }
     //查询评论
     $list = 2;
     $start = ($page - 1) * $list;
     $tt = $this->get_comment_count($goods_id);
     $rt['comment_count'] = $tt;
     $rt['commentlist'] = $this->get_comment_list($goods_id, $start, $list);
     $rt['commentpage'] = Import::basic()->ajax_page($tt, $list, $page, 'get_comment_page', array($goods_id));
     $this->set('rt', $rt);
     $result['message'] = $this->fetch('ajax_comment', true);
     die($json->encode($result));
//.........这里部分代码省略.........
开发者ID:jasonhzy,项目名称:wxfx,代码行数:101,代码来源:controller.php

示例7: zhuanyi_goods

 function zhuanyi_goods()
 {
     if (isset($_GET['kk']) && isset($_GET['maxpage'])) {
         $imgobj = Import::img();
         $kk = $_GET['kk'];
         $list = 20;
         if ($kk == 0) {
             $tt = $this->App->findvar("SELECT COUNT(goods_id) FROM `{$this->App->prefix()}goods`");
             $maxpage = ceil($tt / $list);
         } else {
             $maxpage = $_GET['maxpage'];
         }
         $start = $kk * $list;
         $sql = "SELECT g.*,u.user_name FROM `{$this->App->prefix()}goods` AS g LEFT JOIN `{$this->App->prefix()}user` AS u ON u.user_id = g.uid LIMIT {$start},{$list}";
         $rt = $this->App->find($sql);
         $str = "";
         if (!empty($rt)) {
             foreach ($rt as $row) {
                 //检查是否已经存在该记录
                 if ($row['uid'] > 0) {
                     $sgid = $this->App->findvar("SELECT sgid FROM `{$this->App->prefix()}suppliers_goods` WHERE suppliers_id='{$row['uid']}' AND goods_id='{$row['goods_id']}'");
                     if (empty($sgid)) {
                         $this->App->insert('suppliers_goods', array('suppliers_id' => $row['uid'], 'goods_id' => $row['goods_id'], 'market_price' => $row['market_price'], 'shop_price' => $row['shop_price'], 'pifa_price' => $row['pifa_price'], 'is_on_sale' => $row['is_on_sale'], 'is_delete' => $row['is_delete'], 'is_check' => $row['is_check'], 'addtime' => mktime()));
                         $str .= '转移=>供应商[' . $row['user_name'] . '] goods_id[' . $row['goods_id'] . '] 供应价[' . $row['market_price'] . '] 零售价[' . $row['shop_price'] . '] 批发价[' . $row['pifa_price'] . ']' . "<br/>";
                     } else {
                         //$this->App->update('suppliers_goods',array('suppliers_id'=>$row['uid'],'goods_id'=>$row['goods_id'],'market_price'=>$row['market_price'],'shop_price'=>$row['shop_price'],'pifa_price'=>$row['pifa_price'],'is_on_sale'=>$row['is_on_sale'],'is_delete'=>$row['is_delete'],'addtime'=>mktime()),array("goods_id='$row[goods_id]'","suppliers_id='$row[uid]'"));
                         $str .= "该商品已经存在=goods_id:" . $row['goods_id'] . ",正在更新!<br/>";
                     }
                 } else {
                     $str .= "没有指定供应商!<br/>";
                 }
             }
         }
         $kk = $kk + 1;
         $str .= "<font color=red>==============Load.....page(" . $kk . ")================</font><br />";
         if ($kk > $maxpage) {
             $kk = "";
         }
         sleep(2);
         $rts = array('kk' => $kk, 'url' => $str, 'maxpage' => $maxpage);
         die(Import::json()->encode($rts));
     }
     $this->template('zhuanyi_goods');
 }
开发者ID:zhaoshengloveqingqing,项目名称:fenxiao,代码行数:44,代码来源:controller.php

示例8: ajax_feedback

 function ajax_feedback($data = array())
 {
     $err = 0;
     $result = array('error' => $err, 'message' => '');
     $json = Import::json();
     if (empty($data)) {
         $result['error'] = 2;
         $result['message'] = '传送的数据为空!';
         die($json->encode($result));
     }
     $mesobj = $json->decode($data);
     //反json ,返回值为对象
     //以下字段对应评论的表单页面 一定要一致
     $datas['comment_title'] = $mesobj->comment_title;
     $datas['goods_id'] = $mesobj->goods_id;
     $goods_id = $datas['goods_id'];
     $uid = $this->Session->read('User.uid');
     $datas['user_id'] = !empty($uid) ? $uid : 0;
     $datas['status'] = 2;
     if (strlen($datas['comment_title']) < 12) {
         $result['error'] = 2;
         $result['message'] = '评论内容不能太少!';
         die($json->encode($result));
     }
     //检查需要超过24小时候才能再次提问
     //if(!empty($goods_id)){
     $t = mktime() + 24 * 3600;
     $sql = "SELECT addtime FROM `{$this->App->prefix()}message` WHERE user_id='{$uid}' AND goods_id='{$goods_id}' ORDER BY addtime DESC LIMIT 1";
     $dt = $this->App->findvar($sql);
     if (!empty($dt)) {
         if ($dt + 3600 * 24 > mktime()) {
             $result['error'] = 1;
             $result['message'] = '今天你已经发表过提问了,请你<font color=red>' . intval(($dt + 3600 * 24 - mktime()) / 3600) . '</font>小时之后再次提问吧!';
             die($json->encode($result));
         }
     }
     //}
     /*$datas['content'] = $mesobj->content;goods_id
     		$datas['user_name'] = $mesobj->user_name;
     		$datas['sex'] = $mesobj->sex;
     		$datas['mobile'] = $mesobj->mobile;
     		$datas['telephone'] = $mesobj->telephone;
     		$datas['email'] = $mesobj->email;
     		$datas['companyname'] = $mesobj->companyname;
     		$datas['address'] = $mesobj->address;
     		$datas['companyurl'] = $mesobj->companyurl;
     		*/
     $datas['addtime'] = mktime();
     $ip = Import::basic()->getip();
     $datas['ip_address'] = $ip ? $ip : '0.0.0.0';
     $datas['ip_from'] = Import::ip()->ipCity($ip);
     if ($this->App->insert('message', $datas)) {
         $rl = $this->action('user', 'add_user_jifen', 'comment');
         $result['error'] = 0;
         $result['message'] = '提问成功,我们会很快回答你的问题!<br />恭喜你,本次提问所得积分:' . $rl['points'] . '分!';
     } else {
         $result['error'] = 1;
         $result['message'] = '提问失败,请通过在线联系客服吧!';
     }
     unset($datas, $data);
     //查询评论
     if (!$page) {
         $page = 1;
     }
     $list = 2;
     $start = ($page - 1) * $list;
     $tt = $this->__get_message_count($goods_id);
     $rt['message_count'] = $tt;
     $rt['messagelist'] = $this->__get_message($goods_id, $start, $list);
     $rt['messagepage'] = Import::basic()->ajax_page($tt, $list, $page, 'get_message_page', array($goods_id));
     $rt['goodsinfo']['goods_id'] = $goods_id;
     $this->set('rt', $rt);
     $result['message'] = $this->fetch('ajax_message', true);
     die($json->encode($result));
 }
开发者ID:zhaoshengloveqingqing,项目名称:fenxiao,代码行数:75,代码来源:controller.php

示例9: ajax_get_freecatalog

 function ajax_get_freecatalog($data = array())
 {
     $err = 0;
     $result = array('error' => $err, 'message' => '');
     $json = Import::json();
     if (empty($data)) {
         $result['error'] = 2;
         echo $result['message'] = '传送的数据为空!';
         exit;
         //die($json->encode($result));
     }
     $mesobj = $json->decode($data);
     //反json ,返回值为对象
     $is_freecatalog_time = $this->Session->read("User.is_freecatalog_time");
     if (!empty($is_freecatalog_time) && mktime() - $is_freecatalog_time < 1000) {
         $result['error'] = 2;
         echo $result['message'] = '你已经提交过了,请歇歇吧 !';
         exit;
         //die($json->encode($result));
     }
     //以下字段对应评论的表单页面 一定要一致
     $dir_ids = $mesobj->dir_ids;
     //$s = str_replace('++',"",$dir_ids);
     if (empty($dir_ids)) {
         $result['error'] = 2;
         echo $result['message'] = '请选择您想索取的目录 !';
         exit;
         //die($json->encode($result));
     }
     $fn = SYS_PATH . 'data/freecatalogdata.php';
     file_exists($fn) ? require_once $fn : ($freecatalog = array());
     if (empty($freecatalog)) {
         $result['error'] = 2;
         echo $result['message'] = '管理需要现在后台设置好提取目录在执行!';
         exit;
         //die($json->encode($result));
     }
     $dir_ids_rt = explode("--", $dir_ids);
     $dbids = array();
     foreach ($dir_ids_rt as $k => $hh) {
         $hh = intval($hh) - 1;
         $dbids[] = $freecatalog[$hh];
     }
     $datas['dir_ids'] = !empty($dbids) ? implode('、&nbsp;', $dbids) : "";
     unset($dir_ids_rt, $dbids);
     $datas['user_name'] = $mesobj->username;
     if (empty($datas['user_name'])) {
         $result['error'] = 2;
         echo $result['message'] = '姓名不能为空 !';
         exit;
         //die($json->encode($result));
     }
     $datas['birthday'] = $mesobj->birthday;
     $datas['user_id'] = $mesobj->user_no;
     //顾客号
     $datas['sex'] = $mesobj->sex;
     $datas['province'] = $mesobj->province;
     $datas['city'] = $mesobj->city;
     $datas['district'] = $mesobj->district;
     $datas['address'] = $mesobj->address;
     if (empty($datas['province']) || empty($datas['city']) || empty($datas['district']) || empty($datas['address'])) {
         $result['error'] = 2;
         echo $result['message'] = '请填写好完整的地址 !';
         exit;
         //die($json->encode($result));
     }
     $datas['postcode'] = $mesobj->postcode;
     $datas['dayphone'] = $mesobj->dayphone;
     $datas['nightphone'] = $mesobj->nightphone;
     $datas['mobile'] = $mesobj->mobile;
     if (empty($datas['mobile'])) {
         $result['error'] = 2;
         echo $result['message'] = '手机不能为空 !';
         exit;
         //die($json->encode($result));
     }
     $datas['email'] = $mesobj->email;
     $datas['addtime'] = mktime();
     $ip = Import::basic()->getip();
     $datas['ip_address'] = $ip ? $ip : '0.0.0.0';
     $datas['ip_from'] = Import::ip()->ipCity($ip);
     if ($this->App->insert('freecatalog', $datas)) {
         $result['error'] = 0;
         $result['message'] = '你已经提交,我们很快会联系你!';
         $this->Session->write("User.is_freecatalog_time", mktime());
     } else {
         $result['error'] = 1;
         $result['message'] = '提交失败,请通过在线联系客服吧!';
     }
     unset($datas, $data);
     echo $result['message'];
     exit;
     die($json->encode($result));
 }
开发者ID:zhaoshengloveqingqing,项目名称:fenxiao,代码行数:94,代码来源:controller.php

示例10: ajax_change_price

 function ajax_change_price($data = array())
 {
     $id = $data['id'];
     $number = $data['number'];
     $maxnumber = $this->Session->read("cart.{$id}.goods_number");
     if ($number > $maxnumber) {
         die("购买数量已经超过了库存,你最大只能购买:" . $maxnumber);
     }
     //是否是赠品,如果是赠品,那么只能添加一件,不能重复添加
     $is_alone_sale = $this->Session->read("cart.{$id}.is_alone_sale");
     if (!empty($is_alone_sale)) {
         $this->Session->write("cart.{$id}.number", $number);
     }
     //end 赠品
     $uid = $this->Session->read('User.uid');
     $active = $this->Session->read('User.active');
     //用户等级折扣
     $discount = 100;
     $rank = $this->Session->read('User.rank');
     if ($rank > 0) {
         $sql = "SELECT discount FROM `{$this->App->prefix()}user_level` WHERE lid='{$rank}' LIMIT 1";
         $discount = $this->App->findvar($sql);
     }
     $json = Import::json();
     $cartlist = $this->Session->read('cart');
     $total = 0;
     if (!empty($cartlist)) {
         foreach ($cartlist as $row) {
             $comd = array();
             if (!empty($uid) && $active == '1') {
                 if ($discount > 0) {
                     $comd[] = $discount / 100 * $row['shop_price'];
                 }
                 if ($row['shop_price'] > 0 && $rank == 1) {
                     //个人会员价格
                     $comd[] = $row['shop_price'];
                     //个人会员价格
                 }
                 if ($row['pifa_price'] > 0 && $rank != '1') {
                     //高级会员价格
                     $comd[] = $row['pifa_price'];
                     //高级会员价格
                 }
             } else {
                 $comd[] = $row['shop_price'];
             }
             if ($row['is_promote'] == '1' && $row['promote_start_date'] < mktime() && $row['promote_end_date'] > mktime() && $row['promote_price'] > 0) {
                 //促销价格
                 $comd[] = $row['promote_price'];
             }
             if ($row['is_qianggou'] == '1' && $row['qianggou_start_date'] < mktime() && $row['qianggou_end_date'] > mktime() && $row['qianggou_price'] > 0) {
                 //抢购价格
                 $comd[] = $row['qianggou_price'];
             }
             $onetotal = min($comd);
             $total += $row['number'] * $onetotal;
             //是否赠品,如:买10送1
             $gifts = array();
             $gift2 = array();
             if (!empty($row['buy_more_best']) && $row['goods_id'] == $id) {
                 if (preg_match_all('/1\\d{1,2}|2[01][0-9]|22[0-7]|[1-9][0-9]|[1-9]/', $row['buy_more_best'], $buyrt)) {
                     $num1 = isset($buyrt[0][0]) ? $buyrt[0][0] : 0;
                     $num2 = isset($buyrt[0][1]) ? $buyrt[0][1] : 0;
                     $gift2 = $this->Session->read("cart.{$id}.gifts");
                     if ($number >= $num1 && $num2 > 0) {
                         //允许赠品
                         $mb = mb_substr(trim($row['buy_more_best']), -1, 1, 'utf-8');
                         if (!empty($mb)) {
                             if ($mb > 0) {
                                 $gifts['goods_unit'] = $row['goods_unit'];
                             } else {
                                 $gifts['goods_unit'] = $mb;
                             }
                         } else {
                             $gifts['goods_unit'] = $row['goods_unit'];
                         }
                         $gifts['number'] = $num2;
                         $gifts['goods_id'] = $row['goods_id'];
                         $gifts['goods_sn'] = $row['goods_sn'];
                         $gifts['goods_bianhao'] = $row['goods_bianhao'];
                         $gifts['goods_key'] = $row['goods_id'] . '__' . mktime();
                         $gifts['goods_name'] = $row['goods_name'];
                         $gifts['shop_price'] = 0.0;
                         $gifts['pifa_price'] = 0.0;
                         $gifts['goods_brief'] = $row['goods_brief'];
                     }
                     //end if
                 }
                 //end if
                 $gift = $this->Session->read("cart.{$id}.gifts");
                 $this->Session->write("cart.{$id}.gifts", $gifts);
                 if (!empty($gift2) && $number <= $num1 || empty($gift) && $number >= $num1) {
                     $cartlist = $this->Session->read('cart');
                     $rt['goodslist'] = array();
                     if (!empty($cartlist)) {
                         foreach ($cartlist as $k => $row) {
                             $rt['goodslist'][$k] = $row;
                             $rt['goodslist'][$k]['url'] = get_url($row['goods_name'], $row['goods_id'], 'product.php?id=' . $row['goods_id'], 'goods', array('product', 'index', $row['goods_id']));
                             $rt['goodslist'][$k]['goods_thumb'] = is_file(SYS_PATH . $row['goods_thumb']) ? SITE_URL . $row['goods_thumb'] : SITE_URL . 'theme/images/no_picture.gif';
                             $rt['goodslist'][$k]['goods_img'] = is_file(SYS_PATH . $row['goods_img']) ? SITE_URL . $row['goods_img'] : SITE_URL . 'theme/images/no_picture.gif';
//.........这里部分代码省略.........
开发者ID:zhaoshengloveqingqing,项目名称:fenxiao,代码行数:101,代码来源:controller.php

示例11: ajax_markall

 function ajax_markall($kk = 0, $type = 'nav')
 {
     //必须已开启静态方式才可以生成静态页面
     if (empty($GLOBALS['LANG']['is_static'])) {
         $rts = array('kk' => '', 'url' => '请你先开启静态方式再生成静态页面', 'type' => 'cache');
         die(Import::json()->encode($rts));
     }
     $nav = array();
     $cate = array();
     $art = array();
     $rts = array('kk' => '', 'url' => '', 'type' => 'end');
     if ($type == 'nav') {
         $nav = $this->get_nav_var($kk);
         if (empty($nav)) {
             $rts = array('kk' => '', 'url' => '', 'type' => 'cate');
         } else {
             Import::fileop()->markhtml($nav['url'], $nav['path']);
             $kk = $kk + 1;
             $rts = array('kk' => $kk, 'url' => '<a href="' . $nav['returnurl'] . '" target="_blank">' . $nav['returnurl'] . '</a><br />', 'type' => 'nav');
         }
         die(Import::json()->encode($rts));
     }
     if (empty($nav) && $type == 'cate') {
         $cate = $this->get_category_var($kk);
         if (empty($cate)) {
             $rts = array('kk' => '', 'url' => '', 'type' => 'art');
         } else {
             Import::fileop()->markhtml($cate['url'], $cate['path']);
             $kk = $kk + 1;
             $rts = array('kk' => $kk, 'url' => '<a href="' . $cate['returnurl'] . '" target="_blank">' . $cate['returnurl'] . '</a><br />', 'type' => 'cate');
         }
         die(Import::json()->encode($rts));
     }
     if (empty($cate) && $type == 'art') {
         $art = $this->get_article_var($kk);
         if (empty($art)) {
             $rts = array('kk' => '', 'url' => '', 'type' => 'index');
         } else {
             Import::fileop()->markhtml($art['url'], $art['path']);
             $kk = $kk + 1;
             $rts = array('kk' => $kk, 'url' => '<a href="' . $art['returnurl'] . '" target="_blank">' . $art['returnurl'] . '</a><br />', 'type' => 'art');
         }
         die(Import::json()->encode($rts));
     }
     if (empty($art) && $type == 'index') {
         Import::fileop()->markhtml(SITE_URL, SYS_PATH . 'index.html');
         $rts = array('kk' => '', 'url' => '<a href="' . SITE_URL . '/" target="_blank">' . SITE_URL . '/</a><br />', 'type' => 'end');
         die(Import::json()->encode($rts));
     }
     die(Import::json()->encode($rts));
 }
开发者ID:zhaoshengloveqingqing,项目名称:fenxiao,代码行数:51,代码来源:controller.php

示例12: ajax_daili_login

 function ajax_daili_login($data = array())
 {
     $uid = $this->Session->read('Agent.uid');
     $json = Import::json();
     $result = array('error' => 2, 'message' => '传送的数据为空!');
     if (empty($data['fromAttr'])) {
         die($json->encode($result));
     }
     $fromAttr = $json->decode($data['fromAttr']);
     //反json ,返回值为对象
     unset($data);
     $mobile_phone = $fromAttr->mobile_phone;
     $password = $fromAttr->password;
     if (empty($mobile_phone) || empty($password)) {
         $result = array('error' => 2, 'message' => '请输入完整信息!');
         die($json->encode($result));
     }
     $sql = "SELECT mobile_phone,password,user_id,active,last_login,last_ip FROM `{$this->App->prefix()}user` WHERE mobile_phone='{$mobile_phone}' AND user_rank!='1' LIMIT 1";
     $rt = $this->App->findrow($sql);
     $pass = isset($rt['password']) ? $rt['password'] : '';
     $uid = isset($rt['user_id']) ? $rt['user_id'] : '';
     if (empty($pass)) {
         $result = array('error' => 2, 'message' => '该账户不存在!');
         die($json->encode($result));
     }
     if ($pass == md5(trim($password))) {
         $this->Session->write('Agent.uid', $uid);
         $this->Session->write('Agent.username', $rt['mobile_phone']);
         $this->Session->write('Agent.active', $rt['active']);
         $this->Session->write('Agent.lasttime', $rt['last_login']);
         $this->Session->write('Agent.lastip', $rt['last_ip']);
         $datas = array();
         $ip = Import::basic()->getip();
         $datas['last_ip'] = empty($ip) ? '0.0.0.0' : $ip;
         $datas['last_login'] = mktime();
         $datas['visit_count'] = '`visit_count`+1';
         $this->App->update('user', $datas, 'user_id', $uid);
         //更新
         $result = array('error' => 0, 'message' => '登录成功!');
         die($json->encode($result));
     } else {
         $result = array('error' => 2, 'message' => '密码错误!');
         die($json->encode($result));
     }
 }
开发者ID:zhaoshengloveqingqing,项目名称:fenxiao,代码行数:45,代码来源:controller.php

示例13: ajax_getuser

 function ajax_getuser($data = array())
 {
     $err = 0;
     $json = Import::json();
     $result = array('error' => $err, 'message' => '');
     if (empty($data)) {
         $result['error'] = 2;
         $result['message'] = '传送的数据为空!';
         die($json->encode($result));
     }
     $wobj = $json->decode($data);
     //反json ,返回值为对象
     $page = $wobj->page;
     $returnw = $wobj->returnw;
     if (!empty($returnw)) {
         unset($wobj, $data);
         $wobj = $json->decode(base64_decode($returnw));
         //反json ,返回值为对象
         $data = base64_decode($returnw);
     }
     $keyword = $wobj->keys;
     $province = $wobj->province;
     $city = $wobj->city;
     $district = $wobj->district;
     $user_rank = $wobj->user_rank;
     $sex = $wobj->sex;
     $start_birthday = $wobj->start_birthday;
     $end_birthday = $wobj->end_birthday;
     $start_reg_date = $wobj->start_reg_date;
     $end_reg_date = $wobj->end_reg_date;
     $reg_date = $wobj->reg_date;
     $type = $wobj->type;
     $types = array('salerank', 'poitsrank', 'logincount');
     $type = in_array($type, $types) ? $type : "";
     $comd = array();
     if (intval($province) > 0) {
         $comd[] = "ua.province='{$province}'";
     }
     if (intval($city) > 0) {
         $comd[] = "ua.city='{$city}'";
     }
     if (intval($district) > 0) {
         $comd[] = "ua.district='{$district}'";
     }
     if (intval($user_rank) > 0) {
         $comd[] = "u.user_rank='{$user_rank}'";
     }
     if (intval($sex) > 0) {
         $sex = $sex - 1;
         $comd[] = "(u.sex='{$sex}' OR ua.sex='{$sex}')";
     }
     if ($end_birthday > $start_birthday) {
         $comd[] = "u.birthday BETWEEN '{$start_birthday}' AND '{$end_birthday}'";
     }
     if ($end_reg_date > $start_reg_date) {
         $end_reg_date = strtotime($end_reg_date);
         $start_reg_date = strtotime($start_reg_date);
         $comd[] = "u.reg_time BETWEEN '{$start_reg_date}' AND '{$end_reg_date}'";
     }
     $orderby = " ORDER BY u.user_id DESC";
     switch ($type) {
         case 'salerank':
             $orderby = " ORDER BY salerank DESC, u.user_id ASC";
             break;
         case 'poitsrank':
             $orderby = " ORDER BY pointrank DESC, u.user_id ASC";
             break;
         case 'logincount':
             $orderby = " ORDER BY visit_count DESC, u.user_id ASC";
             break;
     }
     if (!empty($keyword)) {
         $comd[] = "(u.user_name LIKE '%{$keyword}%' OR u.email LIKE '%{$keyword}%' OR u.nickname LIKE '%{$keyword}%' OR ua.consignee LIKE '%{$keyword}%' OR ua.email LIKE '%{$keyword}%')";
     }
     if (!($page > 0)) {
         $page = 1;
     }
     $list = 10;
     $start = ($page - 1) * $list;
     $sql = "SELECT distinct u.user_id FROM `{$this->App->prefix()}user` AS u";
     $sql .= " LEFT JOIN `{$this->App->prefix()}user_address` AS ua ON u.user_id=ua.user_id AND ua.is_own='1'";
     $sql .= " LEFT JOIN `{$this->App->prefix()}goods_order_info` AS goi ON u.user_id=goi.user_id AND goi.pay_status='2'";
     $sql .= " LEFT JOIN `{$this->App->prefix()}user_point_change` AS upc ON u.user_id=upc.uid";
     $sql .= !empty($comd) ? " WHERE " . implode(' AND ', $comd) . " GROUP BY u.user_id" : " GROUP BY u.user_id";
     $tts = $this->App->findcol($sql);
     $tt = count($tts);
     $getuserpage = Import::basic()->ajax_page($tt, $list, $page, 'ajax_getuser', array(base64_encode($data)));
     $this->set('getuserpage', $getuserpage);
     $sql = "SELECT distinct u.user_id,u.user_name,u.birthday,u.reg_time,u.visit_count,ua.sex,ua.email,SUM(goi.goods_amount+goi.shipping_fee) AS salerank,SUM(upc.points) AS pointrank FROM `{$this->App->prefix()}user` AS u";
     $sql .= " LEFT JOIN `{$this->App->prefix()}user_address` AS ua ON u.user_id=ua.user_id AND ua.is_own='1'";
     $sql .= " LEFT JOIN `{$this->App->prefix()}goods_order_info` AS goi ON u.user_id=goi.user_id AND goi.pay_status='2'";
     $sql .= " LEFT JOIN `{$this->App->prefix()}user_point_change` AS upc ON u.user_id=upc.uid";
     $sql .= !empty($comd) ? " WHERE " . implode(' AND ', $comd) . " GROUP BY u.user_id" : " GROUP BY u.user_id";
     $sql .= "{$orderby} LIMIT {$start},{$list}";
     $rt = $this->App->find($sql);
     $this->set('rt_user', $rt);
     echo $result = $this->fetch('ajax_need_send_user', true);
     unset($rt);
     exit;
 }
开发者ID:jasonhzy,项目名称:fx_demo,代码行数:100,代码来源:controller.php

示例14: ajax_add_cart

 function ajax_add_cart($data = array())
 {
     /*
      *error:可以的值
      *0:无任何错误提示
      *1:购买数量操作库存
      *2:错误提示,提示内容为message值
      */
     $err = 0;
     $result = array('error' => $err, 'message' => '');
     $json = Import::json();
     if (empty($data['goods'])) {
         $result['error'] = 2;
         $result['message'] = '传送的数据为空!';
         die($json->encode($result));
     }
     $goods = $json->decode($data['goods']);
     //反json
     $optype = $goods->optype;
     $spec = $goods->spec;
     $number = $goods->number;
     if (!($number > 0)) {
         $number = 1;
     }
     $goods_id = $goods->goods_id;
     //处理搭配购买的商品 传送的goods_id例子:12:11|22|44
     $dapei_ids = array();
     if (strpos($goods_id, ':')) {
         //
         $dapei_ar = explode(":", $goods_id);
         $goods_id = $dapei_ar[0];
         $dapei_ids = !empty($dapei_ar[1]) ? explode("|", $dapei_ar[1]) : array();
         unset($dapei_ar);
     }
     $sql = "SELECT * FROM `{$this->App->prefix()}goods` WHERE goods_id='{$goods_id}' LIMIT 1";
     $cart = array();
     $cart = $this->App->findrow($sql);
     $is_alone_sale = $cart['is_alone_sale'];
     if (empty($cart)) {
         //空信息处理
         $result['error'] = 2;
         $result['message'] = '该商品的记录信息为空!';
         die($json->encode($result));
     }
     ###############################
     //验证是否是兑换积分===>相应减少积分
     $is_pay_jifen = false;
     $cart['is_jifen_session'] = 0;
     //默认积分兑换
     if ($cart['is_jifen'] == '1') {
         //检查用户的目前的积分
         $uid = $this->Session->read('User.uid');
         if (!($uid > 0)) {
             //需要先登录
             $result['error'] = 3;
             $result['message'] = '请你先登录后再操作!';
             die($json->encode($result));
         }
         $need_jifen = $cart['need_jifen'];
         if ($need_jifen > 0) {
             $sql = "SELECT SUM(points) FROM `{$this->App->prefix()}user_point_change` WHERE uid='{$uid}'";
             $points = $this->App->findvar($sql);
             $points = empty($points) ? 0 : $points;
             $sql = "SELECT points_ucount FROM `{$this->App->prefix()}user` WHERE user_id='{$uid}'";
             $points2 = $this->App->findvar($sql);
             if ($points > 0 && $points >= $need_jifen && $points2 > 0 && $points2 >= $need_jifen) {
                 //满足兑换积分的条件
                 $is_pay_jifen = true;
                 $cart['is_jifen_session'] = 1;
             } else {
                 $result['error'] = 2;
                 $result['message'] = '当前积分为:<font color=red>' . $points . '</font>积分!<br />很抱歉,无法满足兑换该商品的条件!';
                 die($json->encode($result));
             }
         } else {
             $result['error'] = 2;
             $result['message'] = '意外错误,你暂时不能兑换商品!';
             die($json->encode($result));
         }
         $pri = $cart['pifa_price'];
         if ($pri > 0) {
             $sql = "SELECT SUM(money) FROM `{$this->App->prefix()}user_money_change` WHERE uid='{$uid}'";
             $moneys = $this->App->findvar($sql);
             $moneys = empty($moneys) ? 0 : $moneys;
             if ($moneys > 0 && $moneys >= $pri) {
                 //满足兑换积分的条件
                 $is_pay_jifen = true;
                 $cart['is_jifen_session'] = 1;
             } else {
                 //$result['error'] = 2;
                 //$result['message'] = '当前资金为:<font color=red>'.$moneys.'</font>元!<br />很抱歉,你的资金不足,请才充值!';
                 //die($json->encode($result));
             }
         }
     }
     #############################
     if ($cart['goods_number'] < $number) {
         //不能购买大于库存数量
         $result['error'] = 1;
         $result['message'] = '购买数量不能大于库存数量!';
//.........这里部分代码省略.........
开发者ID:jasonhzy,项目名称:fx_demo,代码行数:101,代码来源:controller.php

示例15: ajax_change_price

 function ajax_change_price($data = array())
 {
     $json = Import::json();
     $id = $data['id'];
     $number = $data['number'];
     $shipping_id = $data['shipping_id'];
     $userress_id = $data['userress_id'];
     $maxnumber = $this->Session->read("cart.{$id}.goods_number");
     if ($number > $maxnumber) {
         $result = array('error' => 2, 'message' => "购买数量已经超过了库存,你最大只能购买:" . $maxnumber);
         die($json->encode($result));
     }
     //是否是赠品,如果是赠品,那么只能添加一件,不能重复添加
     $is_alone_sale = $this->Session->read("cart.{$id}.is_alone_sale");
     if (!empty($is_alone_sale)) {
         $this->Session->write("cart.{$id}.number", $number);
     }
     //end 赠品
     $uid = $this->Session->read('User.uid');
     $cartlist = $this->Session->read('cart');
     //返回总价
     $sql = "SELECT * FROM `{$this->App->prefix()}userconfig` LIMIT 1";
     //配置信息
     $rts = $this->App->findrow($sql);
     $sql = "SELECT is_subscribe FROM `{$this->App->prefix()}user` WHERE user_id='{$uid}' LIMIT 1";
     $issubscribe = $this->App->findvar($sql);
     $guanzhuoff = $rts['guanzhuoff'];
     $address3off = $rts['address3off'];
     $address2off = $rts['address2off'];
     $prices = 0;
     $thisprice = 0;
     foreach ($cartlist as $k => $row) {
         $counts = $row['number'];
         $off = 1;
         if ($issubscribe == '1' && $guanzhuoff < 101 && $guanzhuoff > 0) {
             $off = $guanzhuoff / 100;
         }
         if ($issubscribe == '1' && $counts >= 2 && $address2off < 101 && $address2off > 0) {
             $off = $address2off / 100;
         }
         if ($issubscribe == '1' && $counts >= 3 && $address3off < 101 && $address3off > 0) {
             $off = $address3off / 100 * $off;
         }
         $price = format_price($row['pifa_price'] * $off);
         if ($id == $k) {
             $thisprice = $price;
         }
         $prices += $price * $row['number'];
     }
     $prices = format_price($prices);
     unset($cartlist);
     //邮费
     $f = $this->ajax_jisuan_shopping(array('shopping_id' => $shipping_id, 'userress_id' => $userress_id), 'cart');
     $f = empty($f) ? '0' : $f;
     unset($cartlist);
     $result = array('error' => 0, 'message' => '1', 'prices' => $prices, 'thisprice' => $thisprice, 'freemoney' => $f);
     die($json->encode($result));
 }
开发者ID:jasonhzy,项目名称:wxfx,代码行数:58,代码来源:controller.php


注:本文中的Import::json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。