/** * 插入数据方法 * @param $good_id * @param $good_name * @param $mall_id * @param $category_id * @param $good_price * @param $good_bar_price * @param $good_url * @param $good_image */ function insert_data($good_id, $good_name, $mall_id, $category_id, $good_price, $good_bar_price, $good_url, $good_image) { echo 'insert1'; $g = new Goods(); $g->test(); // $goods->insertGoods($good_id,$good_name,$mall_id,$category_id,$good_price,$good_bar_price,$good_url,$good_image); echo 'insert2'; }
public function beforeSave() { $in = intval($this->getAttribute('in')); $out = intval($this->getAttribute('out')); $goods_id = $this->getAttribute('goods_id'); $stock = intval(Goods::model()->findByPk($goods_id)->stock); //echo $stock; if ($stock >= 0) { //echo '1'; if ($this->isNewRecord) { $balance_history = $stock + $in - $out; } else { $model = $this->findByPk($this->id); $ms = intval($model->in); $mk = intval($model->out); //echo "$stok - $ms + $mk + $in - $out ="; //echo $balance_history = $stock - $ms + $mk + $in - $out; } if ($balance_history < 0) { $this->addError('out', "Proses gagal, sisa stok tidak boleh kurang dari 0"); $return = false; } else { $this->setAttribute('balance_history', $balance_history); $return = true; } } else { echo '1'; $return = false; } return $return; }
public function replaceGoodsToCart($goods_id) { $user_id = $_SESSION['user_id']; //判断购物车里是否有该商品 if ($cartGoods = $this->getCartGoodsByUserIdAndGoodsId($goods_id)) { $c_number = $cartGoods['c_number'] + 1; } else { $c_number = 1; } //购物车里面没有该商品 //获取商品信息 $goods = new Goods(); $oneGoods = $goods->getGoodsById($goods_id); $sessionID = session_id(); $c_name = $oneGoods['g_name']; $c_price = $oneGoods['g_price']; $g_code = $oneGoods['g_code']; $sql = "replace into {$this->getTableName()} values('{$user_id}',{$goods_id},'{$sessionID}','{$c_name}','{$c_price}','{$c_number}','{$g_code}')"; return $this->db_insert($sql); }
public function actionView($id) { $goods = Goods::model()->findByPk(intval($id)); if (false == $goods || $goods->status == 'N') { throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.')); } // seo信息 $this->_seoTitle = empty($goods->seo_title) ? $goods->goods_name : $goods->seo_title; //更新浏览次数 $goods->updateCounters(array('views' => 1), 'id=:id', array('id' => $id)); $this->render('view', array('goods' => $goods)); }
public function actionSearch() { $keyword = $_POST['keyword']; //最新商品 $criteria = new CDbCriteria(); if ($keyword) { $criteria->compare('goods_name', $keyword, true); } $criteria->order = 't.id DESC'; $data = Goods::model()->findAll($criteria); Yii::app()->session['keyword'] = $keyword; $this->render('search', array('goods' => $data, 'keyword' => $keyword)); }
public function actionAddtrans() { if (isset($_POST['goods_id'])) { //print_r($_POST['id']); /* $criteria = new CDbCriteria(); $criteria->join = "JOIN angkutan on(angkutan.id_angkutan = t.id_angkutan)"; $criteria->condition = "id_detail = ".$_POST['id'][0]; */ $goods = Goods::model()->findByPk($_POST['goods_id']); //{"id_detail":"1","nama":"Boeng 757 Jakarta - Surabaya","harga":"350","id_angkutan":"1"} $data["goods_id"] = $goods->id; echo CJSON::encode($data); } }
public function actionCekgoods() { if (strpos($_GET['term'], "(") === false) { $condition = $_GET['term']; $criteria = new CDbCriteria(); $criteria->condition = " goods_name like '%{$condition}%'"; $criteria->limit = 7; $info = Goods::model()->findAll($criteria); $arModels = array(); foreach ($info as $model) { $arModels[] = array('id' => $model->id, 'label' => $model->goods_name, 'value' => $model->goods_name); } echo CJSON::encode($arModels); } }
/** * 添加一个商品到订单商品明细表中 * @param $goods 商品ActiveRecord 或 商品id * @param $number 商品数量 * @param $orderid 订单id * @return OrderItem|bool */ public function addOne($goods = 0, $number = 1, $orderid = null) { $orderItem = new OrderItem(); if (is_integer($goods)) { $goods = Goods::findOne(['goods_id' => $goods]); } $orderItem->item_name = $goods['goods_name']; $orderItem->item_price = $goods['goods_price']; $orderItem->item_unit = $goods['goods_unit']; $orderItem->goods_id = $goods['goods_id']; $orderItem->item_number = $number; $orderItem->subtotal = $goods['goods_price'] * $number; $orderItem->order_id = $orderid; return $orderItem->save() ? $orderItem : false; }
function actionCategory() { //渲染视图 //render() 带布局渲染 //renderPartial() 部分渲染 error_reporting(E_ALL || ~E_NOTICE); $goods_model = Goods::model(); $total = $goods_model->count(); $per = 8; $page = new Pagination($total, $per); $sql = "select * from {{goods}} {$page->limit}"; $goods_infos = $goods_model->findAllBySql($sql); $page_list = $page->fpage(); $this->render('category', array('goods_infos' => $goods_infos, 'page_list' => $page_list)); }
/** * 添加活动订单 * @param $au_id * @param $user_id * @param array $pay_items * @return bool|array 成功返回 array($order_id, $order_no, $total_fee) * 失败返回 false */ public static function addActivityOrder($au_id, $user_id, array $pay_items) { $connection = self::_getConnection(); $connection->begin(); $goods_number_map = array(); $goods_price_map = array(); foreach ($pay_items as $pay_item) { $goods_number_map[$pay_item['id']] = $pay_item['number']; } $goods = Goods::getGoodsByIds(array_keys($goods_number_map)); $total_fee = 0; foreach ($goods as $one_goods) { $goods_price_map[$one_goods['id']] = $one_goods['price']; $total_fee += $one_goods['price'] * $goods_number_map[$one_goods['id']]; } $add_order_sql = "insert into PayList (orderNo, orderName, money, userId, orderType, relId) values (:order_no, '活动收费', :total_fee, :user_id, 'activity', :au_id)"; $add_order_bind = array('total_fee' => $total_fee, 'user_id' => $user_id, 'au_id' => $au_id); do { $order_no = self::_genOrderNo(); $add_order_bind['order_no'] = $order_no; $add_order_success = $connection->execute($add_order_sql, $add_order_bind); $err_info = $connection->getInternalHandler()->errorInfo(); } while ($err_info[1] == '2627'); if (!$add_order_success) { $connection->rollback(); return false; } $new_order_id = $connection->lastInsertId(); $order_detail_values_str = ''; foreach ($goods_price_map as $goods_id => $goods_price) { $goods_number = $goods_number_map[$goods_id]; $order_detail_values_str .= "({$goods_id}, {$new_order_id}, {$goods_number}, {$goods_price}), "; } $order_detail_values_str = rtrim($order_detail_values_str, ', '); $add_order_detail_sql = "insert into OrderToGoods (goods_id, order_id, number, price) values {$order_detail_values_str}"; $add_order_detail_success = $connection->execute($add_order_detail_sql); if (!$add_order_detail_success) { $connection->rollback(); return false; } $success = $connection->commit(); if (!$success) { return false; } return array($new_order_id, $order_no, $total_fee); }
/** * 新增数据 * */ public function actionCreate() { $model = new GoodsPlan(); if (isset($_POST['GoodsPlan'])) { $model->attributes = $_POST['GoodsPlan']; //添加时间 $model->create_time = time(); if ($model->save()) { $this->message('success', Yii::t('admin', 'Add Success'), $this->createUrl('index')); } } //判断有无商品栏目 $goods = Goods::model()->find(); if (!$goods) { $this->message('error', '请先添加商品信息', $this->createUrl('index')); } $this->render('update', array('model' => $model)); }
/** * 取消订单 * * @param integer $order_id * @return boolean */ static function cancel($order_id) { if (!$order_id) { return false; } D()->update(ectable('order_info'), ['order_status' => OS_CANCELED], ['order_id' => $order_id], true); if (D()->affected_rows() == 1) { //还要将对应的库存加回去 $order_goods = Goods::getOrderGoods($order_id); if (!empty($order_goods)) { foreach ($order_goods as $g) { Goods::changeGoodsStock($g['goods_id'], $g['goods_number']); } } //写order_action的日志 self::order_action_log($order_id, ['action_note' => '用户取消']); return true; } return false; }
public function actionBuy($id) { $goods = Goods::model()->findByPk(intval($id)); if (false == $goods) { throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.')); } // seo信息 $this->_seoTitle = $goods->goods_name; $goodsplan = GoodsPlan::model()->findAll('goods_id=:goods_id', array('goods_id' => $id)); $criteria = new CDbCriteria(); $criteria->select = '*'; // only select the 'title' column $criteria->condition = 'goods_id=:goods_id'; $criteria->params = array(':goods_id' => $id); $criteria->order = 'plan_price asc'; $goodsplan = GoodsPlan::model()->findAll($criteria); // $params is not needed //print_r($goodsplan); $this->render('buy', array('goods' => $goods, 'goodsplan' => $goodsplan, 'uid' => $uid, 'username' => $username)); }
public static function edit(array $args) { $arrName = ['username' => $args['username']]; $arrColl = ['college' => $args['college'], 'address' => $args['address']]; $user = User::find($args['id']); $info = $user->hasInfo; $allGoods = Goods::where('username', $user->username)->get(); if ($user->update($arrName) && $info->update($arrColl)) { if ($allGoods) { foreach ($allGoods as $aGoods) { $aGoods->update($arrName); } } $user = User::find($args['id']); $info = $user->hasInfo; $data = ['id' => $user->id, 'name' => $user->username, 'college' => $info->college, 'address' => $info->address]; return self::success($data); } return self::fail(); }
/** * 商品详情 * @param unknown $id * @throws CHttpException */ public function actionView($id) { $good = Goods::model()->findByPk(intval($id)); if (false == $good || $good->status == 'N') { throw new CHttpException(404, Yii::t('common', 'The requested page does not exist.')); } // seo信息 $this->_seoTitle = empty($good->seo_title) ? $good->goods_name . ' - ' . $this->_setting['site_name'] : $good->seo_title; $this->_seoKeywords = empty($good->seo_keywords) ? $this->_seoKeywords : $good->seo_keywords; $this->_seoDescription = empty($good->seo_description) ? $this->_seoDescription : $good->seo_description; $catalogArr = Catalog::model()->findByPk($good->catalog_id); //更新浏览次数 $good->updateCounters(array('views' => 1), 'id=:id', array('id' => $id)); // 加载css,js Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/view.css"); Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js"); // 最近的商品 $last_goods = Goods::model()->findAll(array('condition' => 'catalog_id = ' . $good->catalog_id, 'order' => 'id DESC', 'limit' => 10)); // nav $navs = array(); $navs[] = array('url' => $this->createUrl('goods/view', array('id' => $id)), 'name' => $good->goods_name); $tplVar = array('good' => $good, 'navs' => $navs, 'last_goods' => $last_goods); $this->render('view', $tplVar); }
?> <div id="sidebar"> <?php $parent_path = $category->getParentPath($id_category); $main_category = $parent_path[0]; $child_categories = $category->getAllChildCategories($id_category); $main_child_categories = $category->getChildCategories($main_category); drawMenu($main_category, $category, $parent_path); ?> </div> <div id="content"> <?php $good = new Goods(); $all_goods = $good->getGoodsFromCategories($child_categories); foreach ($all_goods as $array => $each) { if ($each['is_showed'] == 1) { echo "<div class='good'>"; echo "<a href='" . PATHSITE . "/good/" . $each['id'] . "'><p class='good-name'>" . $each['name'] . "</p>"; if ($each['img_link'] == "") { $each['img_link'] = "none-link.jpg"; } echo "<img class='good_img' src='" . PATHSITE . "/img/" . $each['img_link'] . "' width='200px' height='200px'><br>"; echo "<p>" . $each['price'] . " руб.</p>"; echo "</a></div>"; } } ?> </div>
<?php if (isset($_POST['log']) && !empty($_POST['log'])) { $authObj = new Goods(); $log = $_POST['log']; $pass = $_POST['pass']; $result = $authObj->auth($log, $pass); }
public static function add(array $args) { $args['receiver_id'] = $args['receiver_id'] ? $args['receiver_id'] : 0; $comment = ['parent_id' => $args['parent_id'], 'pro_id' => $args['pro_id'], 'sender_id' => $args['sender_id'], 'receiver_id' => $args['receiver_id'], 'content' => $args['content'], 'status' => 0, 'reg_time' => time()]; $comm = self::create($comment); $goods = Goods::find($comm->pro_id); $info = Info::where('user_id', $comm->sender_id)->first(); $sender = User::find($comm->sender_id); $receiver = User::find($comm->receiver_id); $comm->sender_author = $sender->username; $comm->receiver_author = $receiver->usernmae; $comm->pro_name = $goods->pro_name; $comm->src = 'uploads/' . $info->head_photo; $comm->comments = []; return self::success($comm->toArray()); }
public function collect_cancel(Request $request, Response $response) { if ($request->is_post()) { $res = ['flag' => 'FAIL', 'msg' => '取消失败']; $ec_user_id = $GLOBALS['user']->ec_user_id; if (!$ec_user_id) { $res['msg'] = '未登录, 请登录'; $response->sendJSON($res); } $rec_id = $request->post('rec_id', 0); if (!$rec_id) { $res['msg'] = '记录id为空'; $response->sendJSON($res); } $b = Goods::goodsCollectCancel($rec_id); if ($b) { $res = ['flag' => 'SUC', 'msg' => '取消成功']; } $response->sendJSON($res); } }
<?php /** * [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved. * The contents of this file are subject to the License; you may not use this file except in compliance with the License. * * @version $Revision: 2186 $ */ define('CURSCRIPT', 'upgrade'); require "libraries/common.inc.php"; require "share.inc.php"; session_start(); uses("member", "order", "good", "payment"); $member = new Members(); $goods = new Goods(); $order = new Orders(); $payment_controller = new Payment(); $adzones = $pdb->GetArray("SELECT id,name,price FROM {$tb_prefix}adzones"); $payment = $pdb->GetArray("SELECT id,title,description FROM {$tb_prefix}payments WHERE available=1"); if (!empty($pb_userinfo['pb_userid'])) { $member_info = $pdb->GetRow("SELECT m.*,mf.tel,mf.first_name,mf.last_name FROM {$tb_prefix}members m LEFT JOIN {$tb_prefix}memberfields mf ON m.id=mf.member_id WHERE m.id=" . $pb_userinfo['pb_userid']); setvar("MemberInfo", $member_info); } else { flash("please_login_first", URL . "logging.php"); } /* get payment code, local extra param sended to remote server */ $pay_code = ''; $pay_code = !empty($_REQUEST['code']) ? trim($_REQUEST['code']) : ''; if (!empty($pay_code)) { $payment_controller->setPay($pay_code); $payer = $payment_controller->getPay();
<?php $objGoods = new Goods(); $selected = array(); if (isset($_POST['menu'][0]) && $_POST['menu'][0] === 'notebook') { $goodsArr = $objGoods->getGoods($cat = 5); $selected['notebook'] = 'selected'; } elseif (isset($_POST['menu'][0]) && $_POST['menu'][0] === 'smartphone') { $goodsArr = $objGoods->getGoods($cat = 10); $selected['smartphone'] = 'selected'; } else { //если ничего не выбрано из меню - выводим все товары из всех категорий $objGoods = new Goods(); $goodsArr = $objGoods->getGoods($cat = 0); $selected['all'] = 'selected'; }
//获取分类ID $c_id = $_GET['id']; //接受商品列表显示页码 $page = isset($_GET['page']) ? $_GET['page'] : 1; $pagecount = $config['pagecount']; //var_dump($pagecount); //获取该类商品的总记录数 $goods = new Goods(); $counts = $goods->getCartGoodsCounts($c_id)['c']; //var_dump($counts); $pages = ceil($counts / $pagecount); //var_dump($pages);exit; //对用户传递$page进行判断 if (!is_numeric($page) || $page > $pages || $page < 1) { $page = 1; } $cartGoods = $goods->getGoodsByCartId($c_id, $page, $pagecount); //var_dump($cartGoods);exit; //分页显示 //分页链接字符串 $pageString = Page::getPageStr('index.php', 'display', $counts, $page, $pagecount, $c_id); //加载显示某一类商品模板 include_once YIMAI_TEMP . 'goods_display.html'; } elseif ($act == 'view') { $id = $_GET['id']; $goods = new Goods(); $oneGoods = $goods->getGoodsById($id); $_SESSION['uri'] = $_SERVER['REQUEST_URI']; //加载商品细节模板 include_once YIMAI_TEMP . 'goods_view.html'; }
public function actionOnsale() { $id = $_POST['crowid']; $result = Goods::model()->updateAll(array('IsSale' => 'Y'), "id in ({$id})"); if ($result) { Yii::app()->user->setFlash('success', '商品上架成功'); } else { Yii::app()->user->setFlash('failed', '商品上架失败'); } echo json_encode($result); }
public function actionEmpgoods() { //内容查询 $pageNo = !empty($_GET['page']) ? $_GET['page'] : 1; if (isset($_GET['search'])) { $params = $_GET['search']; $result = Goods::getGoodsByDearID($_GET['dealer'], $params, $pageNo, 10); } else { $result = Goods::getGoodsByDearID($_GET['dealer'], null, $pageNo, 10); } //搜索中的适用品牌 $brand = $this->getbrand(0); //类别 $category = $this->getcategory(); $this->render("empgoods", array('search' => $params, 'models' => $result[0], 'pages' => $result[1], 'brand' => $brand, 'category' => $category)); }
public function order_info() { $id = Filter::int(Req::args('id')); $pids = Req::args('pid'); $type = Req::args("type"); $ship_id = 0; $num = Req::args('num'); if ($num == NULL || $num == "") { $num = 1; } if ($this->checkOnline()) { if ($type == 'bundbuy') { $ship_id = NULL; //确认捆绑存在有效且所有的商品都在其中包括个数完全正确 $pids = trim($pids, "-"); $product_id_array = explode("-", $pids); foreach ($product_id_array as $key => $val) { $product_id_array[$key] = Filter::int($val); } $product_ids = implode(',', $product_id_array); $product_id = implode('-', $product_id_array); $model = new Model("bundling"); $bundling = $model->where("id={$id}")->find(); if ($bundling) { $goods_id_array = explode(',', $bundling['goods_id']); $goods_inst = new Goods(); $ret = $goods_inst->getGoodsProducts($product_ids); if (isset($ret['status']) && $ret['status'] == 1) { $products = $ret['data']; } //检测库存与防偷梁换柱 // $tax_account = 0; $store_nums = 10; // 初始化为10 foreach ($products as $key => $value) { // 处理products的ship_id 取第一个产品的ship_id if ($key == 0 && isset($value["ship_id"]) && $value["ship_id"] != NULL) { $ship_id = $value["ship_id"]; } if ($value['store_nums'] <= 0 || !in_array($value['goods_id'], $goods_id_array)) { $this->redirect("/index/bundbuy/id/{$id}"); } if ($store_nums > $value['store_nums']) { $store_nums = $value['store_nums']; } // $tax_account += $value['sell_price'] * $value['tax_type_percent']; } $max_nums = $store_nums; if ($ship_id == NULL) { Tiny::log(__FILE__ . __LINE__ . "ship_id 不存在!"); } $this->assign("ship_id", $ship_id); $products_inst = new Products(); if (count($goods_id_array) == count($products)) { $product = $products_inst->packBundbuyProducts($products); $this->assign("product", $product); $this->assign("bund", $bundling); } else { $this->redirect("/index/bundbuy/id/{$id}"); } $goods_info = array(); $goods_info["bundling_id"] = $id; $goods_info["products_ids"] = $pids; $goods_info["bundling"] = $bundling; $goods_info["ship_id"] = $ship_id; $goods_info["products"] = $products; // 套餐总数量 允许最多买的数量 store_nums , max_num 存放在 bundling中 $goods_info['store_nums'] = $store_nums; $goods_info['max_nums'] = $max_nums; $this->cart_inst = Cart::getCart(); //Tiny::log(__FILE__.__LINE__."--before bundling to cart---".var_export($cart, true)); $this->cart_inst->addBundling($goods_info, $num); // Tiny::log(__FILE__.__LINE__."--add bundling to cart---".var_export($cart, true)); } else { $this->redirect("/index/msg", true, array('msg' => '你提交的套餐不存在!', 'type' => 'error')); } } $this->assign("id", $id); $this->assign("order_type", $type); $this->assign("pid", $product_id); $this->parserOrder($ship_id); $this->redirect("/simple/cart"); } else { $this->redirect("login"); } }
//没有选择商城,则默认全部商城被选中 $mallStr .= "<a href=\"./index.php?id=" . $c_id . "\" class=\"curcateitem\"><span class=\"curcateitemword\">全部</span></a>"; } else { $mallStr .= "<a href=\"./index.php?id=" . $c_id . "\" class=\"cateitem\"><span class=\"cateitemword\">全部</span></a>"; } for ($i = 0; $i < count($sources); $i++) { if ($mall_id == $i + 1) { //商城id对应则显示该分类被选中 $mallStr .= "<a href=\"./index.php?id=" . $c_id . "&mall_id=" . ($i + 1) . "\" class=\"curcateitem\"><span class=\"curcateitemword\">" . $sources[$i]['mallName'] . "</span></a>"; } else { $mallStr .= "<a href=\"./index.php?id=" . $c_id . "&mall_id=" . ($i + 1) . "\" class=\"cateitem\"><span class=\"cateitemword\">" . $sources[$i]['mallName'] . "</span></a>"; } } $_SESSION['uri'] = $_SERVER['REQUEST_URI']; //接受商品列表显示页码 $page = isset($_GET['page']) ? $_GET['page'] : 1; $pagecount = $config['pagecount']; //获取该类商品的总记录数 $goods = new Goods(); $counts = $goods->getCartGoodsCounts($c_id)['c']; $pages = ceil($counts / $pagecount); //对用户传递$page进行判断 if (!is_numeric($page) || $page > $pages || $page < 1) { $page = 1; } $cartGoods = $goods->getGoodsByCartId($c_id, $page, $pagecount); //分页显示 //分页链接字符串 $pageString = Page::getPageStr('index.php', 'index', $counts, $page, $pagecount, $c_id); //加载首页显示模板 include_once YIMAI_TEMP . 'index.html';
//商品名称为空 admin_redirect('goods.php?act=add', '商品名称不能为空!', 3); } if (strlen($goodsinfo['g_name']) > 60) { //超长 admin_redirect('goods.php?act=add', '商品名称过长,只能最多输入20个字符!', 3); } //商品分类id验证 if ($goodsinfo['c_id'] == 0) { //没有选择分类 admin_redirect('goods.php?act=add', '没有选择商品分类!', 3); } //应该对所有传进来的数据类型进行验证,尤其是数值类型。 //验证数据有效性。 //货号验证 $goods = new Goods(); if ($goodsinfo['g_sn']) { //货号存在,验证货号是否唯一 if ($goods->checkSn($goodsinfo['g_sn'])) { //货号存在 admin_redirect('goods.php?act=add', "当前货号 {$goodsinfo['g_sn']} 已经存在!", 3); } } else { //货号不存在,自动增长货号 $goodsinfo['g_sn'] = $goods->createAutoSn(); } //接收图片并处理,不管图片是否上传成功,都不会影响整个商品记录的插入 //var_dump($_FILES);exit; if ($path = Upload::uploadSingle($_FILES['goods_img'], $config['goods_img_upload'], $config['goods_img_upload_max'])) { //上传成功,将上传文件的相对路径存放到数据对应的字段下 $goodsinfo['g_img'] = $path;
public function actionList() { $organID = Commonmodel::getOrganID(); $cpname = DealerCpname::model()->find('OrganID=' . $organID); $_GET['params']['standardid'] = isset($_GET['params']['standardid']) ? $_GET['params']['standardid'] : $cpname['CpNameID']; if (isset($_GET['params']) && !empty($_GET['params'])) { $params = $_GET['params']; $goodsno = isset($params['goodsno']) ? trim($params['goodsno']) : ''; $goodsname = isset($params['goodsname']) ? trim($params['goodsname']) : ''; $oenum = isset($params['oe']) ? trim($params['oe']) : ''; $issale = isset($params['issale']) ? trim($params['issale']) : ''; $moreparams = $this->makeMoreParams(); if (is_array($moreparams)) { $params = array_merge($params, $moreparams); } } $page = isset($_GET['page']) ? $_GET['page'] : null; $limit = isset($_GET['rows']) ? $_GET['rows'] : null; $result = Goods::GetGoodsByMakeID($organID, $params, $page, $limit); echo json_encode($result); // $criteria = new CDbCriteria(); // $sql = "select distinct a.id as goodsID ,b.goods_category as category_id,b.goods_oe as OE,b.goods_brand as brand,b.organID, // a.NewVersion as version_name,b.goods_no as goodsno,b.goods_name as goodsname, // b.benchmarking_brand,b.benchmarking_sn,b.marketprice,b.salesprice,b.discountprice,a.create_time," // . " b.inventory as inventory,b.senddays,b.description,a.IsSale,b.maincategory,b.subcategory,b.standard_id" // . " from tbl_make_goods a ,tbl_make_goods_version b ,tbl_make_goods_vehicle c" // . ' where a.id=b.goods_id and a.NewVersion=b.version_name' // . " and a.ISdelete='0' and b.ISdelete=0" // . " and a.organID='$organID' "; // //第一个配件品类 // $cpname = DealerCpname::model()->find('OrganID=' . $organID); // $_GET['params']['standardid'] = isset($_GET['params']['standardid']) ? $_GET['params']['standardid'] : $cpname['CpNameID']; // if (isset($_GET['params'])&&!empty ($_GET['params'])) { // $params = $_GET['params']; // $goodsno = isset($params['goodsno']) ? trim($params['goodsno']) : ''; // $goodsname = isset($params['goodsname']) ? trim($params['goodsname']) : ''; // $oenum = isset($params['oe']) ? trim($params['oe']) : ''; // $issale = isset($params['issale']) ? trim($params['issale']) : ''; // if (!empty($goodsname)) { // $sql.=" and b.goods_name like'%$goodsname%'"; // } // //OE号搜索 // if (!empty($oenum)) { // $sql.=" and b.goods_oe like'%$oenum%'"; // } // //商品编号搜索 // if (!empty($goodsno)) { // $sql.=" and b.goods_no like '%$goodsno%'"; // } // //配件品类搜索 // if (!empty($params['standardid'])) { // $sql.=' and b.standard_id=' . $params['standardid']; // } // // elseif (!empty($params['subcategory'])) { // // $sql.=' and b.standard_id in( select id from tbl_gcategory where parent_id=' . $params['subcategory'] . ')'; // // } elseif (!empty($params['maincategory'])) { // // $sql.=' and b.standard_id in( select id from `tbl_gcategory` where parent_id in(SELECT id FROM `tbl_gcategory` where parent_id=' . $params['maincategory'] . '))'; // // } // // //添加时间查询 // // if (!empty($params['begintime'])) { // // $sql.=' and a.create_time>=' . strtotime($params['begintime']); // // } // // if (!empty($params['endtime'])) { // // $endtime = strtotime($params['endtime']) + 3600 * 24 - 1; // // $sql.=' and a.create_time<=' . $endtime; // // } // //商品类别搜索 // if (!empty($params['goodscategory'])) { // $sql.=' and b.goods_category=' . $params['goodscategory']; // } // //品牌搜索 // if (!empty($params['goodsbrand'])) { // $sql.=' and b.goods_brand=' . $params['goodsbrand']; // } // //是否上架查询 // if (is_numeric($issale)) { // $sql.=" && a.IsSale='$issale'"; // } // //适用车型搜索 // if(!empty($params['carmodel'])) // { // $sql.=' and a.id=c.GoodsID and c.Name like "%'.$params['carmodel'].'%" '; // } // } // //高级筛选 // if(isset($_GET['expertparams'])&&!empty($_GET['expertparams'])) // { // $arr= explode('/',$_GET['expertparams']); // foreach($arr as $key=>$v) // { // $sql_w.=" and exists( // SELECT DISTINCT(f.goods_id) FROM `tbl_make_goods_values` f,`tbl_make_goods_template` g where // g.id=f.template_id and a.id=f.goods_id // and g.organID=".$organID.' and g.standard_id='.$_GET['params']['standardid']; // $a=explode(',',$v); // $sql_wx=1; // $sql_w.=' and (g.name="'.$a[0].'" and f.value between '.$a[1].' and '.$a[2].')) '; // } // } // //echo $sql_w;die; // //规格进出水口高级筛选 // if(isset($_GET['standparams'])&&!empty($_GET['standparams'])) // { // $arr= explode('/',$_GET['standparams']); // foreach($arr as $key=>$v) // { // $sql_n.= " and exists( // SELECT DISTINCT(f.goods_id) FROM `tbl_make_goods_values` f,`tbl_make_goods_template` g where // g.id=f.template_id and a.id=f.goods_id // and g.organID=".$organID.' and g.standard_id='.$_GET['params']['standardid']; // $a=explode(',',$v); // if($a[1]) // { // $sql_nx=1; // $sql_n.=' and (g.name="'.$a[0].'" and f.value ="'.$a[1].'"))'; // } // } // } // //安装方式 // if(isset($_GET['installparams'])&&!empty($_GET['installparams'])) // { // $sql_i.= " and exists( // SELECT DISTINCT(f.goods_id) FROM `tbl_make_goods_values` f,`tbl_make_goods_template` g where // g.id=f.template_id and a.id=f.goods_id // and g.organID=".$organID.' and g.standard_id='.$_GET['params']['standardid']; // $arr= explode('/',$_GET['installparams']); // $a=explode(',',$arr[0]); // if($a[1]) // { // $sql_ix=1; // $sql_i.=' and g.name="'.$a[0].'" and (f.value ="'.$a[1].'" or f.value="'.$a[2].'"))'; // } // } // if($sql_wx==1) // $sql.=$sql_w; // if($sql_nx==1) // $sql.=$sql_n; // if($sql_ix==1) // $sql.= $sql_i; // $sql.=" group by a.id order by a.id desc"; // $result = Yii::app()->db->createCommand($sql)->queryAll(); // $count = count($result); // $pages = new CPagination($count); // //设置分页页数 // $pages->pageSize = isset($_GET['rows']) ? intval($_GET['rows']) : 10; // $pages->applyLimit($criteria); // $result = Yii::app()->db->createCommand($sql . " LIMIT :offset,:limit"); // //绑定分页参数 // $result->bindValue(':offset', $pages->currentPage * $pages->pageSize); // $result->bindValue(':limit', $pages->pageSize); // $result = $result->queryAll(); // $datas = array(); // foreach ($result as $key => $val) { // $datas[$key] = $val; // //查询商品类别 // if (!empty($val[category_id])) { // $re = MakeGoodsCategory::model()->findByPk($val[category_id]); // $datas[$key]['category'] = $re['name']; // } // //查询商品类别 // if (!empty($val['brand'])) { // $brand = MakeGoodsBrand::model()->findByPK($val['brand']); // $datas[$key]['brandname'] = $brand['BrandName']; // } // //查询标准名称 // if (!empty($val['standard_id'])) { // $stand = Gcategory::model()->findByPk($val['standard_id']); // $datas[$key]['cp_name'] = $stand['name']; // } // //查询车型 // $cmodel= MakeGoodsVehicle::model()->find('GoodsID=' . $val['goodsID'] . ' and VersionName="' . $val['version_name'] . '"'); // if($cmodel) // $datas[$key]['carmodel']=$cmodel->Name; // $datas[$key]['GoodsID'] = $val['goodsID']; // $datas[$key]['OE'] = $val['OE']; // $datas[$key]['Brand'] = $val['brand']; // $datas[$key]['version_name'] = $val['version_name']; // $datas[$key]['GoodsNo'] = $val['goodsno']; // $datas[$key]['GoodsName'] = $val['goodsname']; // $datas[$key]['BenchBrand'] = $val['benchmarking_brand']; // $datas[$key]['BenchNo'] = $val['benchmarking_sn']; // $datas[$key]['GoodsBrand'] = $val['brand']; // $datas[$key]['BrandName'] = $val['brandname']; // $datas[$key]['GoodsCategory'] = $val['category_id']; // // $datas[$key]['CategoryName']=$val['category']; // $datas[$key]['MarkPrice'] = $val['marketprice']; // $datas[$key]['SalePrice'] = $val['salesprice']; // $datas[$key]['DiscountPrice'] = $val['discountprice']; // $datas[$key]['inventory'] = $val['inventory']; // $datas[$key]['Days'] = $val['senddays']; // $datas[$key]['Desc'] = $val['description']; // //b.maincategory,b.subcategory,b.standard_id // $datas[$key]['mainCategory'] = $val['maincategory']; // $datas[$key]['subCategory'] = $val['subcategory']; // $datas[$key]['standard_id'] = $val['standard_id']; // $datas[$key]['create_time'] = date('Y-m-d H:i:s', $val['create_time']); // //获取标准名称参数值 // if (!empty($val['standard_id'])) { // $params = MakeGoodsValues::model()->findAll('standard_id=' . $val['standard_id'] . ' and goods_id=' . $val['goodsID'] . ' and version_name="' . $val['version_name'] . '"'); // $value = array(); // foreach ($params as $param) { // $k = $param['template_id']; // $value[$k] = $param['value']; // $datas[$key][$k] = $param['value']; // } // $datas[$key]['paramsvalue'] = $value; // } // if ($val['IsSale'] == 0) { // $datas[$key]['IsSale'] = '已上架'; // } else { // $datas[$key]['IsSale'] = '已下架'; // } // } // echo json_encode(array('rows' => $datas, 'total' => $pages->itemCount)); //} }
<?php /** * [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved. * The contents of this file are subject to the License; you may not use this file except in compliance with the License. * * @version $Revision: 2075 $ */ require "../libraries/common.inc.php"; require LIB_PATH . 'page.class.php'; require "session_cp.inc.php"; uses("good"); $goods = new Goods(); $tpl_file = "goods"; $page = new Pages(); if (isset($_POST['save'])) { $vals = $_POST['goods']; $id = $_POST['id']; if (!empty($id)) { $vals['modified'] = $time_stamp; $result = $goods->save($vals, "update", $id); } else { $vals['created'] = $vals['modified'] = $time_stamp; $result = $goods->save($vals); } if (!$result) { flash(); } } if (isset($_POST['del']) && !empty($_POST['id'])) { $result = $goods->del($_POST['id']);
public function geneSummary() { $base = parent::geneSummary(); $base .= $this->getPlayTime(); return $base; }