function smarty_function_load_data($params, &$smarty) { (!isset($params['table']) || empty($params['table'])) && exit('`table` is empty!'); // $Mconfig = include(hopedir."config/hopeconfig.php"); // print_r($Mconfig); $type = isset($params['type']) ? $params['type'] : 'list'; //total 总数量 one list 3个分类 $fileds = isset($params['fileds']) ? $params['fileds'] : '*'; $where = isset($params['where']) ? $params['where'] : ''; $where = empty($where) ? '' : ' where ' . $where; $orderby = isset($params['orderby']) ? 'order by ' . $params['orderby'] : ''; $limit = isset($params['limit']) ? 'LIMIT 0,' . $params['limit'] : 'LIMIT 0,1'; if (!class_exists('mysql_class')) { include hopedir . "lib/core/extend/mysql_class.php"; //core\extend $mysql = new mysql_class(); } else { $mysql = new mysql_class(); } $page = intval(IFilter::act(IReq::get('page'))); $pagesize = intval(IFilter::act(IReq::get('pagesize'))); $pagesize = isset($params['pagesize']) ? $params['pagesize'] : $pagesize; $pagesize = empty($pagesize) ? 10 : $pagesize; // $db = $class::factory(array('table' => $params['table'])); //var_dump($params); if (!empty($params['assign'])) { //把数据赋值给变量$params['assign'],这样前端就可以使用这个变量了(例如可以结合foreach输出一个列表等) // $smarty->assign($params['assign'], $db->get_block_list(array($params['where']), $params['limit'])); if ($type == 'total') { $result = $mysql->counts("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . " " . $where . " " . $orderby . " " . $limit . ""); } elseif ($type == 'one') { $result = $mysql->select_one("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . " " . $where . " " . $orderby . " " . $limit . ""); } else { if (isset($params['showpage']) && $params['showpage'] == true) { if (!class_exists('page')) { include hopedir . "lib/core/extend/page.php"; //core\extend $pageclass = new page(); } else { $pageclass = new page(); } $pageclass->setpage($page, $pagesize); $result['list'] = $mysql->getarr("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . " " . $where . " " . $orderby . " limit " . $pageclass->startnum() . ", " . $pageclass->getsize() . ""); $shuliang = $mysql->counts("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . " " . $where . " "); $pageclass->setnum($shuliang); if (isset($params['pagetype'])) { $result['pagecontent'] = $pageclass->ajaxbar($params['pagetype']); } else { $result['pagecontent'] = $pageclass->getpagebar(); } } else { $result['list'] = $mysql->getarr("select " . $fileds . " from " . Mysite::$app->config['tablepre'] . $params['table'] . " " . $where . " " . $orderby . " " . $limit . ""); } } /* $result['list'] = array(); $result['pagecontent'] = ''; */ $smarty->assign($params['assign'], $result); } }
/** * @see paymentplugin::getSendData() */ public function getSendData($payment) { $defaultbank = IFilter::act(IReq::get('defaultbank')); $return = array(); //基本参数 $return['service'] = 'create_direct_pay_by_user'; $return['partner'] = $payment['M_PartnerId']; $return['seller_email'] = $payment['M_Email']; $return['_input_charset'] = 'utf-8'; $return['payment_type'] = 1; $return['return_url'] = $this->callbackUrl; $return['notify_url'] = $this->serverCallbackUrl; $return['defaultbank'] = $defaultbank; $return['paymethod'] = 'bankPay'; //业务参数 $return['subject'] = $payment['R_Name']; $return['out_trade_no'] = $payment['M_OrderNO']; $return['total_fee'] = number_format($payment['M_Amount'], 2, '.', ''); //除去待签名参数数组中的空值和签名参数 $para_filter = $this->paraFilter($return); //对待签名参数数组排序 $para_sort = $this->argSort($para_filter); //生成签名结果 $mysign = $this->buildMysign($para_sort, $payment['M_PartnerKey']); //签名结果与签名方式加入请求提交参数组中 $return['sign'] = $mysign; $return['sign_type'] = 'MD5'; return $return; }
function savesingle() { $id = IReq::get('uid'); $data['addtime'] = strtotime(IReq::get('addtime') . ' 00:00:00'); $data['title'] = IReq::get('title'); $data['content'] = IReq::get('content'); $data['code'] = IReq::get('code'); $data['seo_key'] = IFilter::act(IReq::get('seo_key')); $data['seo_content'] = IFilter::act(IReq::get('seo_content')); if (empty($id)) { $link = IUrl::creatUrl('adminpage/single/module/addsingle'); if (empty($data['content'])) { $this->message('单页内容不能为空', $link); } if (empty($data['title'])) { $this->message('单页标题不能为空', $link); } $this->mysql->insert(Mysite::$app->config['tablepre'] . 'single', $data); } else { $link = IUrl::creatUrl('single/addsingle/id/' . $id); if (empty($data['content'])) { $this->message('单页内容不能为空', $link); } if (empty($data['title'])) { $this->message('单页标题不能为空', $link); } $this->mysql->update(Mysite::$app->config['tablepre'] . 'single', $data, "id='" . $id . "'"); } $link = IUrl::creatUrl('adminpage/single/module/singlelist'); $this->success('操作成功', $link); }
public function adminupload() { $func = IFilter::act(IReq::get('func')); $obj = IReq::get('obj'); $uploaddir = IFilter::act(IReq::get('dir')); if (is_array($_FILES) && isset($_FILES['imgFile'])) { $uploaddir = empty($uploaddir) ? 'goods' : $uploaddir; $json = new Services_JSON(); $uploadpath = 'upload/' . $uploaddir . '/'; $filepath = '/upload/' . $uploaddir . '/'; $upload = new upload($uploadpath, array('gif', 'jpg', 'jpge', 'doc', 'png')); //upload 自动生成压缩图片 $file = $upload->getfile(); if ($upload->errno != 15 && $upload->errno != 0) { echo "<script>parent." . $func . "(true,'" . $obj . "','" . json_encode($upload->errmsg()) . "');</script>"; } else { echo "<script>parent." . $func . "(false,'" . $obj . "','" . $filepath . $file[0]['saveName'] . "');</script>"; } exit; } $data['obj'] = $obj; $data['uploaddir'] = $uploaddir; $data['func'] = $func; Mysite::$app->setdata($data); }
/** * @brief 商家登录动作 */ public function login() { $seller_name = IFilter::act(IReq::get('username')); $password = IReq::get('password'); $message = ''; if ($seller_name == '') { $message = '登录名不能为空'; } else { if ($password == '') { $message = '密码不能为空'; } else { $sellerObj = new IModel('seller'); $sellerRow = $sellerObj->getObj('seller_name = "' . $seller_name . '" and is_del = 0 and is_lock = 0'); if ($sellerRow && $sellerRow['password'] == md5($password)) { $dataArray = array('login_time' => ITime::getDateTime()); $sellerObj->setData($dataArray); $where = 'id = ' . $sellerRow["id"]; $sellerObj->update($where); //存入私密数据 ISafe::set('seller_id', $sellerRow['id']); ISafe::set('seller_name', $sellerRow['seller_name']); ISafe::set('seller_pwd', $sellerRow['password']); $this->redirect('/seller/index'); } else { $message = '用户名与密码不匹配'; } } } if ($message != '') { $this->redirect('index', false); Util::showMessage($message); } }
/** * @brief 商品属性添加/修改 * @param array $attribute 表字段 数组格式,如Array ([name] => Array ( [0] => '' ) * [show_type] => Array ( [0] => '' ) * [value] => Array ( [0] => '' ) * [is_seach] => Array ( [0] => 1 )) * @param int $model_id 模型编号 */ public function _attribute_update($attribute, $model_id) { //初始化attribute商品模型属性表类对象 $attributeObj = new IModel('attribute'); $len = count($attribute['name']); $ids = ""; for ($i = 0; $i < $len; $i++) { if (IValidate::required($attribute['name'][$i]) && IValidate::required($attribute['value'][$i])) { $options = str_replace(',', ',', $attribute['value'][$i]); $type = isset($attribute['is_search'][$i]) ? $attribute['is_search'][$i] : 0; //设置商品模型扩展属性 字段赋值 $filedData = array("model_id" => intval($model_id), "type" => IFilter::act($attribute['show_type'][$i]), "name" => IFilter::act($attribute['name'][$i]), "value" => rtrim(IFilter::act($options), ','), "search" => IFilter::act($type)); $attributeObj->setData($filedData); $id = intval($attribute['id'][$i]); if ($id) { //更新商品模型扩展属性 $attributeObj->update("id = " . $id); } else { //新增商品模型扩展属性 $id = $attributeObj->add(); } $ids .= $id . ','; } } if ($ids) { $ids = trim($ids, ','); //删除商品模型扩展属性 $where = "model_id = {$model_id} and id not in (" . $ids . ") "; $attributeObj->del($where); } }
/** * @brief 保存品牌 */ function brand_save() { $brand_id = IFilter::act(IReq::get('brand_id'), 'int'); $name = IFilter::act(IReq::get('name')); $sort = IFilter::act(IReq::get('sort'), 'int'); $url = IFilter::act(IReq::get('url')); $description = IFilter::act(IReq::get('description'), 'text'); $tb_brand = new IModel('brand'); $brand = array('name' => $name, 'sort' => $sort, 'url' => $url, 'description' => $description); if (isset($_FILES['logo']['name']) && $_FILES['logo']['name'] != '') { $uploadObj = new PhotoUpload(); $uploadObj->setIterance(false); $photoInfo = $uploadObj->run(); if (isset($photoInfo['logo']['img']) && file_exists($photoInfo['logo']['img'])) { $brand['logo'] = $photoInfo['logo']['img']; } } $tb_brand->setData($brand); if ($brand_id) { $where = "id=" . $brand_id; $tb_brand->update($where); } else { $tb_brand->add(); } $this->brand_list(); }
/** * @brief 解析视图路径 * @param string $viewPath 视图名称 */ public function resolveView($viewPath) { $viewPath = IFilter::act($viewPath, 'filename'); //分割模板目录的层次 $view = strtr($viewPath, '-', '/'); $this->view = $this->basePath = $this->getController()->getViewFile($view); }
function exchangcard() { $this->checkmemberlogin(); $card = trim(IFilter::act(IReq::get('card'))); $password = trim(IFilter::act(IReq::get('password'))); if (empty($card)) { $this->message('充值卡号不能为空'); } if (empty($password)) { $this->message('充值卡密码不能为空'); } $checkinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "card where card ='" . $card . "' and card_password = '******' and uid =0 and status = 0"); if (empty($checkinfo)) { $this->message('充值卡不存在或者已使用'); } $arr['uid'] = $this->member['uid']; $arr['status'] = 1; $arr['username'] = $this->member['username']; $this->mysql->update(Mysite::$app->config['tablepre'] . 'card', $arr, "card ='" . $card . "' and card_password = '******' and uid =0 and status = 0"); //`$key` $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', '`cost`=`cost`+' . $checkinfo['cost'], "uid ='" . $this->member['uid'] . "' "); $allcost = $this->member['cost'] + $checkinfo['cost']; $this->memberCls->addlog($this->member['uid'], 2, 1, $checkinfo['cost'], '充值卡充值', '使用充值卡' . $checkinfo['card'] . '充值' . $checkinfo['cost'] . '元', $allcost); $this->success('兑换成功'); }
public function getNoticeList() { $page = IReq::get('page') ? IFilter::act(IReq::get('page'), 'int') : 1; $query = new IQuery('announcement'); $query->order = 'id desc'; $query->page = $page; return $query; }
public function getHelpListByCatId($catId) { $page = IReq::get('page') ? IFilter::act(IReq::get('page'), 'int') : 1; $query = new IQuery('help'); $query->where = "cat_id = " . $catId; $query->order = 'sort desc,id desc'; $query->page = $page; return $query; }
public function getArticleListByCatid($category_id) { $page = IReq::get('page') ? IFilter::act(IReq::get('page'), 'int') : 1; $query = new IQuery('article'); $query->where = 'category_id = ' . $category_id . ' and visibility = 1'; $query->order = 'id desc'; $query->page = $page; return $query; }
public function getSellerList() { $page = IReq::get('page') ? IFilter::act(IReq::get('page'), 'int') : 1; $query = new IQuery('seller'); $query->where = 'is_del = 0'; $query->order = 'id desc'; $query->page = $page; return $query; }
/** * @brief form提交事件 * @param array 订单的详细信息 × @return array 返回支付需提交的详细信息 */ function toSubmit($payment) { //合作者身份(parterID)-帐号 $merId = $this->getConf($payment['M_Paymentid'], 'member_id'); //交易安全校验码(key) $pKey = $this->getConf($payment['M_Paymentid'], 'PrivateKey'); $key = $pKey == '' ? 'afsvq2mqwc7j0i69uzvukqexrzd0jq6h' : $pKey; //订单总价 $amount = number_format($payment['M_Amount'], 2, ".", ""); //商店名称 $shopName = IFilter::act($payment['R_Name']); //标题 $subject = $shopName . '订单'; //初始化返回值 $return = array(); //交易接口名称 $real_method = $this->getConf($payment['M_Paymentid'], 'real_method'); switch ($real_method) { case '0': $return['service'] = 'trade_create_by_buyer'; break; case '1': $return['service'] = 'create_direct_pay_by_user'; break; case '2': $return['service'] = 'create_partner_trade_by_buyer'; break; } //付完款后跳转的页面 要用 http://格式的完整路径,不允许加?id=123这类自定义参数 $return['return_url'] = $this->callbackUrl; //交易过程中服务器通知的页面 要用 http://格式的完整路径,不允许加?id=123这类自定义参数 $return['notify_url'] = $this->serverCallbackUrl; $return['payment_type'] = 1; $return['partner'] = $merId; $return['subject'] = $subject; $return['body'] = '网店订单'; $return['out_trade_no'] = $payment['M_OrderNO']; $return['total_fee'] = $amount; $return['seller_id'] = $merId; $return['_input_charset'] = 'utf-8'; ksort($return); reset($return); $mac = ""; foreach ($return as $k => $v) { $mac .= '&' . $k . '=' . $v; } $mac = substr($mac, 1); $return['sign'] = md5($mac . $key); //验证信息 $return['sign_type'] = 'MD5'; //验证信息 unset($return['_input_charset']); return $return; }
public static function help_del($id) { if (!is_array($id)) { $id = array($id); } $id = IFilter::act($id, 'int'); $id = implode(",", $id); $tb_help = new IModel("help"); $tb_help->del("id IN ({$id})"); return array('flag' => true, 'data' => 'success'); }
function delask() { $id = IFilter::act(IReq::get('id')); if (empty($id)) { $this->message('留言ID不能为空'); } $ids = is_array($id) ? join(',', $id) : $id; $adminuid = ICookie::get('adminuid'); $where = " id in({$ids})"; $this->mysql->delete(Mysite::$app->config['tablepre'] . 'ask', $where); $this->success('操作成功'); }
function login_act() { $admin_name = IFilter::act(IReq::get('admin_name')); $password = IReq::get('password'); $captcha = IReq::get('captcha', 'post'); $message = ''; if ($admin_name == '') { $message = '登录名不能为空'; } else { if ($password == '') { $message = '密码不能为空'; } else { if ($captcha != ISafe::get('Captcha')) { $message = '验证码输入不正确'; } else { $adminObj = new IModel('admin'); $adminRow = $adminObj->getObj('admin_name = "' . $admin_name . '"'); if (!empty($adminRow) && $adminRow['password'] == md5($password) && $adminRow['is_del'] == 0) { $dataArray = array('last_ip' => IClient::getIp(), 'last_time' => ITime::getDateTime()); $adminObj->setData($dataArray); $where = 'id = ' . $adminRow["id"]; $adminObj->update($where); //根据角色分配权限 if ($adminRow['role_id'] == 0) { ISafe::set('admin_right', 'administrator'); ISafe::set('admin_role_name', '超级管理员'); } else { $roleObj = new IModel('admin_role'); $where = 'id = ' . $adminRow["role_id"] . ' and is_del = 0'; $roleRow = $roleObj->getObj($where); ISafe::set('admin_right', $roleRow['rights']); ISafe::set('admin_role_name', $roleRow['name']); } ISafe::set('admin_id', $adminRow['id']); ISafe::set('admin_name', $adminRow['admin_name']); ISafe::set('admin_pwd', $adminRow['password']); $this->redirect('/system/default'); } else { $message = '用户名与密码不匹配'; } } } } if ($message != '') { $this->admin_name = $admin_name; $this->redirect('index', false); Util::showMessage($message); } }
/** * @brief 校验用户的合法性 * @param string $login_info 用户名或者email * @param string $password 用户名的md5密码 * @return false or array 如果合法则返回用户数据;不合法返回false */ public static function isValidUser($login_info, $password) { $login_info = IFilter::act($login_info); $password = IFilter::act($password); $userObj = new IModel('user as u,member as m'); $where = 'u.username = "******" and m.status = 1 and u.id = m.user_id'; $userRow = $userObj->getObj($where); if (empty($userRow)) { $where = 'email = "' . $login_info . '" and m.status = 1 and u.id = m.user_id'; $userRow = $userObj->getObj($where); } if (empty($userRow) || $userRow['password'] != $password) { return false; } else { return $userRow; } }
function user() { //店铺统计 $selecttype = intval(IFilter::act(IReq::get('selecttype'))); $tempselecttype = in_array($selecttype, array(0, 1, 2, 3)) ? $selecttype : 0; $wherearray = array('0' => '', '1' => ' where addtime > ' . strtotime('-1 month'), '2' => ' where addtime > ' . strtotime('-7 day'), '3' => ' where addtime > ' . strtotime(date('Y-m-d', time()))); $tempdata = $this->mysql->getarr("select count(id) as shuliang ,DATE_FORMAT(FROM_UNIXTIME(`addtime`),'%k') as month from " . Mysite::$app->config['tablepre'] . "order " . $wherearray[$tempselecttype] . " group by month order by month desc limit 0,10"); $list = array(); if (is_array($tempdata)) { foreach ($tempdata as $key => $value) { $list[$value['month']] = $value['shuliang']; } } $data['list'] = $list; $data['selecttype'] = $selecttype; Mysite::$app->setdata($data); }
public static function count($word) { if (empty($word)) { return false; } else { if (is_array($word)) { $wordArray = $word; } else { $wordArray = explode(',', $word); } $keywordObj = new IModel('keyword'); $goodsObj = new IModel('goods'); $result = array(); foreach ($wordArray as $val) { $val_sql = IFilter::act($val); $countNum = $goodsObj->getObj('name like "%' . $val_sql . '%" AND is_del=0 ', 'count(*) as num'); $result[$val] = $countNum['num']; } return $result; } }
public function userupload() { $link = IUrl::creatUrl('member/login'); if ($this->member['uid'] == 0 && $this->admin['uid'] == 0) { $this->message('未登陆', $link); } $_FILES['imgFile'] = $_FILES['head']; $type = IFilter::act(IReq::get('type')); if (empty($type)) { $this->message('未定义的操作'); } $json = new Services_JSON(); $uploadpath = 'upload/user/'; $filepath = '/upload/user/'; $upload = new upload($uploadpath, array('gif', 'jpg', 'jpge', 'png')); //upload $file = $upload->getfile(); if ($upload->errno != 15 && $upload->errno != 0) { $this->message($upload->errmsg()); } else { if ($type == 'userlogo') { $arr['logo'] = $filepath . $file[0]['saveName']; $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', $arr, 'uid = ' . $this->member['uid'] . ' '); } elseif ($type == 'goods') { $shopid = ICookie::get('adminshopid'); $gid = intval(IFilter::act(IReq::get('gid'))); $data['img'] = $filepath . $file[0]['saveName']; $this->mysql->update(Mysite::$app->config['tablepre'] . 'goods', $data, "id='" . $gid . "' and shopid='" . $shopid . "'"); } elseif ($type == 'shoplogo') { $shopid = ICookie::get('adminshopid'); if (!empty($shopid)) { $data['shoplogo'] = $filepath . $file[0]['saveName']; $this->mysql->update(Mysite::$app->config['tablepre'] . 'shop', $data, "id='" . $shopid . "'"); } } $this->success($filepath . $file[0]['saveName']); } }
public function savesingle() { $this->checkshoplogin(); $shopid = ICookie::get('adminshopid'); if ($shopid <= 0) { $this->message('获取失败'); } $id = IReq::get('uid'); $data['addtime'] = strtotime(IReq::get('addtime') . ' 00:00:00'); $data['title'] = IReq::get('title'); $data['content'] = IReq::get('content'); $data['code'] = IReq::get('code'); $data['seo_key'] = IFilter::act(IReq::get('seo_key')); $data['seo_content'] = IFilter::act(IReq::get('seo_content')); $data['shop_id'] = $shopid; if (empty($id)) { $link = IUrl::creatUrl('single/addsingle'); if (empty($data['content'])) { $this->message('单页内容不能为空', $link); } if (empty($data['title'])) { $this->message('单页标题不能为空', $link); } $this->mysql->insert(Mysite::$app->config['tablepre'] . 'shop_single', $data); } else { $link = IUrl::creatUrl('single/addsingle/id/' . $id); if (empty($data['content'])) { $this->message('单页内容不能为空', $link); } if (empty($data['title'])) { $this->message('单页标题不能为空', $link); } $this->mysql->update(Mysite::$app->config['tablepre'] . 'shop_single', $data, "single_id='" . $id . "' and shop_id={$shopid}"); } $link = IUrl::creatUrl('single/singlelist'); $this->success('操作成功', $link); }
function goods_list() { //商品检索条件 $show_num = IFilter::act(IReq::get('show_num', 'post'), 'int'); $keywords = IFilter::act(IReq::get('keywords', 'post')); $cat_id = IFilter::act(IReq::get('category_id', 'post'), 'int'); $min_price = IFilter::act(IReq::get('min_price', 'post'), 'float'); $max_price = IFilter::act(IReq::get('max_price', 'post'), 'float'); //查询条件 $where = 'go.is_del = 0'; if ($cat_id) { $table_name = 'goods as go,category_extend as ca'; $where .= " and ca.category_id = {$cat_id} and go.id = ca.goods_id "; } else { $table_name = 'goods as go'; } $where .= $keywords ? ' and go.name like "%' . $keywords . '%"' : ''; $where .= $min_price ? ' and go.sell_price >= ' . $min_price : ''; $where .= $max_price ? ' and go.sell_price <= ' . $max_price : ''; $obj = new IModel($table_name); $this->data = $obj->query($where, 'go.id,go.name,go.list_img', 'go.id', 'desc', $show_num); $this->type = IReq::get('type', 'get'); $this->redirect('goods_list'); }
</dl> <?php } ?> </div> </div> <?php echo IFilter::stripSlash($siteConfig->site_footer_code); ?> </div> <script type='text/javascript'> $(function() { <?php $word = IReq::get('word') ? IFilter::act(IReq::get('word'), 'text') : '输入关键字...'; ?> $('input:text[name="word"]').val("<?php echo isset($word) ? $word : ""; ?> "); $('input:text[name="word"]').bind({ keyup:function(){autoComplete('<?php echo IUrl::creatUrl("/site/autoComplete"); ?> ','<?php echo IUrl::creatUrl("/site/search_list/word/@word@"); ?> ','<?php echo isset($siteConfig->auto_finish) ? $siteConfig->auto_finish : "";
?> </span> </div> <div id="admin_left"> <ul class="submenu"></ul> <div id="copyright"></div> </div> <div id="admin_right"> <script type="text/javascript" charset="UTF-8" src="<?php echo BASE_URL; ?> /runtime/_systemjs/my97date/wdatepicker.js"></script> <?php $search = IReq::get('search') ? IFilter::act(IReq::get('search'), 'strict') : array(); ?> <div class="headbar"> <div class="position"><span>统计</span><span>></span><span>商户数据统计</span><span>></span><span>货款结算列表</span></div> <div class="operating"> <div class="search f_l"> <form name="searchBill" action="<?php echo IUrl::creatUrl("/"); ?> " method="get"> <input type='hidden' name='controller' value='market' /> <input type='hidden' name='action' value='bill_list' /> <span> 申请时间
/** * @brief 商品检索,可以直接读取 $_GET 全局变量:attr,order,brand,min_price,max_price * 在检索商品过程中计算商品结果中的进一步属性和规格的筛选 * @param mixed $defaultWhere string(条件) or array('search' => '模糊查找','category_extend' => '商品分类ID','字段' => 对应数据) * @param int $limit 读取数量 * @param bool $isCondition 是否筛选出商品的属性,价格等数据 * @return IQuery */ public static function find($defaultWhere = '', $limit = 21, $isCondition = true) { //获取配置信息 $siteConfigObj = new Config("site_config"); $site_config = $siteConfigObj->getInfo(); $orderArray = array(); //排序 //开始查询 $goodsObj = new IQuery("goods as go"); $goodsObj->page = isset($_GET['page']) ? intval($_GET['page']) : 1; $goodsObj->fields = ' go.* '; $goodsObj->pagesize = $limit; /*where条件拼接*/ //(1),当前产品分类 $where = ' go.is_del = 0 '; //(2),商品属性,规格筛选 $attrCond = array(); $childSql = ''; $attrArray = IReq::get('attr') ? IFilter::act(IReq::get('attr')) : array(); foreach ($attrArray as $key => $val) { if ($key && $val) { $attrCond[] = ' attribute_id = ' . intval($key) . ' and FIND_IN_SET("' . $val . '",attribute_value)'; } } //合并规格与属性的值,并且生成SQL查询语句 $GoodsId = null; if ($attrCond) { $tempArray = array(); foreach ($attrCond as $key => $cond) { $tempArray[] = '(' . $cond . ')'; } $childSql = join(' or ', $tempArray); $goodsAttrObj = new IQuery('goods_attribute'); $goodsAttrObj->fields = 'goods_id'; $goodsAttrObj->where = $childSql; $goodsAttrObj->group = 'goods_id'; $goodsAttrObj->having = 'count(goods_id) >= ' . count($attrCond); //每个子条件都有一条记录,则存在几个count(条件)必须包含count(goods_id)条数量 $goodsIdArray = $goodsAttrObj->find(); $goodsIds = array(); foreach ($goodsIdArray as $key => $val) { $goodsIds[] = $val['goods_id']; } $GoodsId = $GoodsId === null ? array_unique($goodsIds) : array_unique(array_intersect($goodsIds, $GoodsId)); } //(3),处理defaultWhere条件 goods, category_extend if ($defaultWhere) { //兼容array 和 string 数据类型的goods条件筛选 $goodsCondArray = array(); if (is_string($defaultWhere)) { $goodsCondArray[] = $defaultWhere; } else { if (is_array($defaultWhere)) { foreach ($defaultWhere as $key => $val) { if (!$val) { continue; } //商品分类检索 if ($key == 'category_extend') { $currentCatGoods = array(); $categoryExtendObj = new IModel('category_extend'); $categoryExtendList = $categoryExtendObj->query("category_id in (" . $val . ")", 'goods_id', 'id', 'desc'); foreach ($categoryExtendList as $key => $val) { $currentCatGoods[] = $val['goods_id']; } $GoodsId = $GoodsId === null ? array_unique($currentCatGoods) : array_unique(array_intersect($currentCatGoods, $GoodsId)); } else { if ($key == 'search') { $wordWhere = array(); $wordLikeOrder = array(); //检查输入的内容是否为分词形式 if (preg_match("#\\s+#", $defaultWhere['search']) == false) { $wordWhere[] = ' name like "%' . $defaultWhere['search'] . '%" or find_in_set("' . $defaultWhere['search'] . '",search_words) '; $wordLikeOrder[] = $defaultWhere['search']; } //进行分词 if (IString::getStrLen($defaultWhere['search']) >= 4 || IString::getStrLen($defaultWhere['search']) <= 100) { $wordData = words_facade::run($defaultWhere['search']); if (isset($wordData['data']) && count($wordData['data']) >= 2) { foreach ($wordData['data'] as $word) { $wordWhere[] = ' name like "%' . $word . '%" '; $wordLikeOrder[] = $word; } } } //分词排序 if (count($wordLikeOrder) > 1) { $orderTempArray = array(); foreach ($wordLikeOrder as $key => $val) { $orderTempArray[] = "(CASE WHEN name LIKE '%" . $val . "%' THEN " . $key . " ELSE 100 END)"; } $orderArray[] = " (" . join('+', $orderTempArray) . ") asc "; } $goodsCondArray[] = join(' or ', $wordWhere); } else { $goodsCondArray[] = $key . ' = "' . $val . '"'; } } } } } //goods 条件 if ($goodsCondArray) { $goodsDB = new IModel('goods as go'); $goodsCondData = $goodsDB->query(join(" and ", $goodsCondArray), "id"); $goodsCondId = array(); foreach ($goodsCondData as $key => $val) { $goodsCondId[] = $val['id']; } $GoodsId = $GoodsId === null ? array_unique($goodsCondId) : array_unique(array_intersect($goodsCondId, $GoodsId)); } } //过滤商品ID被删除的情况 if ($GoodsId) { if (!isset($goodsDB)) { $goodsDB = new IModel("goods as go"); } $goodsCondData = $goodsDB->query("go.id in (" . join(',', $GoodsId) . ") and go.is_del = 0 ", "id"); $GoodsId = array(); foreach ($goodsCondData as $key => $val) { $GoodsId[] = $val['id']; } } $GoodsId = $GoodsId === array() || $GoodsId === null ? array(0) : array_unique($GoodsId); //存在商品ID数据 if ($GoodsId) { $GoodsId = array_slice($GoodsId, 0, search_goods::MAX_GOODSID); $where .= " and go.id in (" . join(',', $GoodsId) . ") "; //商品属性进行检索 if ($isCondition == true) { /******属性 开始******/ $attrTemp = array(); $goodsAttrDB = new IModel('goods_attribute'); $attrData = $goodsAttrDB->query("goods_id in (" . join(',', $GoodsId) . ")"); foreach ($attrData as $key => $val) { //属性 if ($val['attribute_id']) { if (!isset($attrTemp[$val['attribute_id']])) { $attrTemp[$val['attribute_id']] = array(); } $checkSelectedArray = explode(",", $val['attribute_value']); foreach ($checkSelectedArray as $k => $v) { if (!in_array($v, $attrTemp[$val['attribute_id']])) { $attrTemp[$val['attribute_id']][] = $v; } } } } //属性的数据拼接 if ($attrTemp) { $attrDB = new IModel('attribute'); $attrData = $attrDB->query("id in (" . join(',', array_keys($attrTemp)) . ") and search = 1", "*", "id", "asc", 8); foreach ($attrData as $key => $val) { self::$attrSearch[] = array('id' => $val['id'], 'name' => $val['name'], 'value' => $attrTemp[$val['id']]); } } /******属性 结束******/ /******品牌 开始******/ $brandQuery = new IModel('brand as b,goods as go'); self::$brandSearch = $brandQuery->query("go.brand_id = b.id and go.id in (" . join(',', $GoodsId) . ")", "distinct b.id,b.name", "b.sort", "asc", 10); /******品牌 结束******/ /******价格 开始******/ self::$priceSearch = goods_class::getGoodsPrice(join(',', $GoodsId)); /******价格 结束******/ } } //(4),商品价格 $where .= floatval(IReq::get('min_price')) ? ' and go.sell_price >= ' . floatval(IReq::get('min_price')) : ''; $where .= floatval(IReq::get('max_price')) ? ' and go.sell_price <= ' . floatval(IReq::get('max_price')) : ''; //(5),商品品牌 $where .= intval(IReq::get('brand')) ? ' and go.brand_id = ' . intval(IReq::get('brand')) : ''; //排序类别 $order = IFilter::act(IReq::get('order'), 'url'); if ($order == null) { $order = isset($site_config['order_by']) ? $site_config['order_by'] : 'new'; $asc = isset($site_config['order_type']) ? $site_config['order_type'] : 'desc'; } else { if (stripos($order, '_toggle')) { $order = str_replace('_toggle', '', $order); $asc = 'asc'; } else { $asc = 'desc'; } } switch ($order) { //销售量 case "sale": $orderArray[] = ' go.sale ' . $asc; break; //评分 //评分 case "cpoint": $orderArray[] = ' go.grade ' . $asc; break; //最新上架 //最新上架 case "new": $orderArray[] = ' go.id ' . $asc; break; //价格 //价格 case "price": $orderArray[] = ' go.sell_price ' . $asc; break; //根据排序字段 //根据排序字段 default: $orderArray[] = ' go.sort asc '; } //设置IQuery类的各个属性 $goodsObj->where = $where; $goodsObj->order = join(',', $orderArray); return $goodsObj; }
<script type="text/javascript" charset="UTF-8" src="<?php echo BASE_URL; ?> /runtime/_systemjs/artdialog/artDialog.js"></script><script type="text/javascript" charset="UTF-8" src="<?php echo BASE_URL; ?> /runtime/_systemjs/artdialog/plugins/iframeTools.js"></script><link rel="stylesheet" type="text/css" href="<?php echo BASE_URL; ?> /runtime/_systemjs/artdialog/skins/default.css" /> </head> <body style='width:420px;min-height:120px;'> <div class="pop_win"> <div class="content"> <form action="<?php echo IFilter::act(IReq::get('callback'), 'url'); ?> " method='post' enctype='multipart/form-data'> <table class='form_table'> <colgroup> <col width="120px" /> <col /> </colgroup> <tr> <td class="t_r">选择图片文件:</td> <td><input type='file' class='file' name='attach' /></td> </tr> </table> </form> </div>
function add_download_ticket() { $isError = true; $ticket_num = IFilter::act(IReq::get('ticket_num')); $ticket_pwd = IFilter::act(IReq::get('ticket_pwd')); $propObj = new IModel('prop'); $propRow = $propObj->getObj('card_name = "' . $ticket_num . '" and card_pwd = "' . $ticket_pwd . '" and type = 0 and is_userd = 0 and is_send = 1 and is_close = 0 and NOW() between start_time and end_time'); if (empty($propRow)) { $message = '代金券不可用,请确认代金券的卡号密码并且此代金券从未被使用过'; } else { //登录用户 if ($this->user['user_id']) { $memberObj = new IModel('member'); $memberRow = $memberObj->getObj('user_id = ' . $this->user['user_id'], 'prop'); if (stripos($memberRow['prop'], ',' . $propRow['id'] . ',') !== false) { $message = '代金券已经存在,不能重复添加'; } else { $isError = false; $message = '添加成功'; if ($memberRow['prop'] == '') { $propUpdate = ',' . $propRow['id'] . ','; } else { $propUpdate = $memberRow['prop'] . $propRow['id'] . ','; } $dataArray = array('prop' => $propUpdate); $memberObj->setData($dataArray); $memberObj->update('user_id = ' . $this->user['user_id']); } } else { $isError = false; $message = '添加成功'; ISafe::set("ticket_" . $propRow['id'], $propRow['id']); } } $result = array('isError' => $isError, 'data' => $propRow, 'message' => $message); echo JSON::encode($result); }
/** * 查询删除 */ function search_del() { $id = IFilter::act(IReq::get('id'), 'int'); //生成search对象 $tb_search = new IModel('search'); if (!empty($id)) { if (is_array($id) && isset($id[0]) && $id[0] != '') { $id_str = join(',', $id); $where = ' id in (' . $id_str . ')'; } else { $where = 'id = ' . $id; } $tb_search->del($where); } else { Util::showMessage('请选择要删除的数据'); } $this->redirect("search_list"); }
<?php $siteConfig = new Config("site_config"); $callback = IReq::get('callback') ? urlencode(IFilter::act(IReq::get('callback'), 'url')) : ''; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo $siteConfig->name; ?> </title> <link type="image/x-icon" href="favicon.ico" rel="icon"> <link rel="stylesheet" href="<?php echo IUrl::creatUrl("") . "views/" . $this->theme . "/skin/" . $this->skin . "/css/index.css"; ?> " /> <script type="text/javascript" charset="UTF-8" src="<?php echo BASE_URL; ?> /runtime/_systemjs/jquery/jquery-1.11.3.min.js"></script><script type="text/javascript" charset="UTF-8" src="<?php echo BASE_URL; ?> /runtime/_systemjs/jquery/jquery-migrate-1.2.1.min.js"></script> <script type="text/javascript" charset="UTF-8" src="<?php echo BASE_URL; ?> /runtime/_systemjs/autovalidate/validate.js"></script><link rel="stylesheet" type="text/css" href="<?php echo BASE_URL;