/** * @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 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; } }
/** * @brief 处理curd动作 * @return String */ public function curd() { $action = $this->id; $controller = $this->controller; $curdinfo = $this->initinfo(); if (is_array($curdinfo)) { $modelName = $curdinfo['model']; $key = $curdinfo['key']; $actions = $curdinfo['actions']; switch ($action) { case 'add': case 'upd': if (method_exists($controller, 'getValidate')) { $validate = $controller->getValidate(); } else { $validate = null; } if ($validate != null) { $formValidate = new IFormValidation($validate); $data = $formValidate->run(); } $model = new IModel($modelName); if (isset($data) && $data !== null) { $model->setData($data[$modelName]); if ($action = 'add') { $flag = $model->add(); } else { $flag = $model->upd("{$key} = '" . IReq::get($key) . "'"); } } if (isset($flag) && $flag) { $_GET['action'] = $actions['success']; } else { $_GET['action'] = $actions['fail']; } $controller->run(); return true; case 'del': $model = new IModel($modelName); $flag = $model->del("{$key} = '" . IReq::get($key) . "'"); if ($flag) { $_GET['action'] = $actions['success']; } else { $_GET['action'] = $actions['fail']; } $controller->run(); return true; case 'get': $model = new IModel($modelName); $rs = $model->getObj("{$key} = '" . IReq::get($key) . "'"); echo JSON::encode($rs); return false; } } }
function spec_edit() { if ($id = IFilter::act(IReq::get('id'), 'int')) { $where = 'id = ' . $id; $obj = new IModel('spec'); $dataRow = $obj->getObj($where); } else { $dataRow = array('id' => null, 'name' => null, 'type' => null, 'value' => null, 'note' => null); } $this->setRenderData($dataRow); $this->redirect('spec_edit'); }
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 array checkrights里面的admin对象数据 */ public function __construct($admin) { $adminObj = new IModel('admin'); $adminRow = $adminObj->getObj('admin_name = "' . $admin['admin_name'] . '"'); if ($adminRow && $adminRow['password'] == $admin['admin_pwd'] && $adminRow['is_del'] == 0) { //根据角色分配权限 if ($adminRow['role_id'] == 0) { $this->adminRights = 'administrator'; } else { $roleObj = new IModel('admin_role'); $where = 'id = ' . $adminRow["role_id"] . ' and is_del = 0'; $roleRow = $roleObj->getObj($where); $this->adminRights = isset($roleRow['rights']) ? $roleRow['rights'] : ''; } } }
/** * 检测用户是否能够评论 * * @param int $comment_id 评论id * @param int $user_id 用户id * @return array() array(成功or失败,数据) */ public static function can_comment($comment_id, $user_id) { $comment_id = intval($comment_id); $user_id = intval($user_id); $tb_comment = new IModel("comment"); $comment = $tb_comment->getObj("id={$comment_id} AND user_id={$user_id}"); if (!$comment) { return array(-1, "没有这条数据"); } if ($comment['status'] != 0) { return array(-2, $comment); } $time = strtotime($comment['time']); if ($time < 3600 * 24 * 30 * 6) { return array(-3, $comment); } return array(1, $comment); }
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 getSellerInfo($id) { $query = new IModel('seller'); $info = $query->getObj("id=" . $id); return $info; }
/** * @brief 获取广告位置的信息 * @param $position mixed 广告位ID 或者 广告位名称 * @return array */ public static function getPositionInfo($position) { $adPositionDB = new IModel("ad_position"); if (is_int($position)) { return $adPositionDB->getObj("id={$position} AND `status`=1"); } else { return $adPositionDB->getObj("name='{$position}' AND `status`=1"); } }
/** * @brief 登录后的处理 * @param array $userRow 用户数组信息 */ public static function loginAfter($userRow) { //用户私密数据 ISafe::set('user_id', $userRow['id']); ISafe::set('username', $userRow['username']); ISafe::set('head_ico', $userRow['head_ico']); ISafe::set('user_pwd', $userRow['password']); ISafe::set('last_login', isset($userRow['last_login']) ? $userRow['last_login'] : ''); //更新最后一次登录时间 $memberObj = new IModel('member'); $dataArray = array('last_login' => ITime::getDateTime()); $memberObj->setData($dataArray); $where = 'user_id = ' . $userRow["id"]; $memberObj->update($where); $memberRow = $memberObj->getObj($where, 'exp'); //根据经验值分会员组 $groupObj = new IModel('user_group'); $groupRow = $groupObj->getObj($memberRow['exp'] . ' between minexp and maxexp and minexp > 0 and maxexp > 0', 'id', 'discount', 'desc'); if (!empty($groupRow)) { $dataArray = array('group_id' => $groupRow['id']); $memberObj->setData($dataArray); $memberObj->update('user_id = ' . $userRow["id"]); } }
/** * @brief 修改品牌 */ function brand_edit() { $brand_id = (int) IReq::get('bid'); //编辑品牌 读取品牌信息 if ($brand_id) { $obj_brand = new IModel('brand'); $brand_info = $obj_brand->getObj('id=' . $brand_id); if ($brand_info) { $this->data['brand'] = $brand_info; } else { $this->category_list(); Util::showMessage("没有找到相关品牌分类!"); return; } } $this->setRenderData($this->data); $this->redirect('brand_edit', false); }
/** * @brief 根据模型编号 获取模型详细信息 * * @param int $model_id 模型编号 * * @return array 数组格式 Array ( [id] => '',[name] => '', [model_attr] => Array ( ),[model_spec] => Array ( )) */ public function get_model_info($model_id) { $model_id = intval($model_id); //初始化model商品模型表类对象 $modelObj = new IModel('model'); //根据模型编号 获取商品模型详细信息 $model_info = $modelObj->getObj('id = ' . $model_id); if ($model_info) { //反序列化 商品模型规格数据 $model_info['model_spec'] = array(); if ($model_info['spec_ids']) { $specDB = new IModel('spec'); $model_info['model_spec'] = $specDB->query("id in (" . $model_info['spec_ids'] . ")"); } //初始化attribute商品模型属性表类对象 $attributeObj = new IModel('attribute'); //根据商品模型编号 获取商品模型扩展属性 $model_attr = $attributeObj->query("model_id = " . $model_id); $model_info['model_attr'] = $model_attr; } return $model_info; }
private function getOauthRow($id) { $oauthObj = new IModel('oauth'); $oauthRow = $oauthObj->getObj('id = ' . $id); return $oauthRow; }
function withdraw_detail() { $id = IFilter::act(IReq::get('id'), 'int'); if ($id) { $withdrawObj = new IModel('withdraw'); $where = 'id = ' . $id; $this->withdrawRow = $withdrawObj->getObj($where); $this->redirect('withdraw_detail', false); } else { $this->redirect('withdraw_list'); } }
/** * 设置管理员信息 * * @param int $admin_id * @return Object */ private function setAdmin($admin_id) { $admin_id = intval($admin_id); $tb_admin = new IModel("admin"); $admin = $tb_admin->getObj(" id = {$admin_id} "); if (!$admin) { $this->error[] = "没有id为{$admin_id}的用户"; } else { $this->admin = $admin; } return $this; }
public function conver($expressConfig, $order_id, $seller_id = 0) { $resultArray = array(); //函数返回数据 $wholeData = array(); //实际的数据 //获取订单信息 $id = intval($order_id); $orderObj = new IModel('order'); $orderRow = $orderObj->getObj('id = ' . $id . ' and seller_id = ' . $seller_id); if (empty($orderRow)) { return null; } //获取发货地址信息 $shipInfoObj = new IModel('merch_ship_info'); $shipList = $shipInfoObj->query('is_del = 1 and seller_id = ' . $seller_id, '*', 'is_default', 'desc', '1'); if (empty($shipList)) { $shipRow = array('ship_user_name' => '', 'address' => '', 'telphone' => '', 'mobile' => '', 'postcode' => '', 'province' => '', 'city' => '', 'area' => ''); } else { $shipRow = $shipList[0]; } //获取订单总重量和总数量 $orderGoodsObj = new IModel('order_goods'); $orderTotal = $orderGoodsObj->getObj('order_id = ' . $id, 'SUM(goods_nums) as num_total,SUM(goods_weight * goods_nums) as weight_total'); /*拼接实际数据 $wholeData*/ //查询area地域数据 $areaData = area::name($orderRow['province'], $orderRow['city'], $orderRow['area'], $shipRow['province'], $shipRow['city'], $shipRow['area']); //获取site_config配置信息 $site_config = new Config('site_config'); $site_config = $site_config->getInfo(); $wholeData['ship_name'] = $orderRow['accept_name']; $wholeData['ship_area_0'] = isset($areaData[$orderRow['province']]) ? $areaData[$orderRow['province']] : ''; $wholeData['ship_area_1'] = isset($areaData[$orderRow['city']]) ? $areaData[$orderRow['city']] : ''; $wholeData['ship_area_2'] = isset($areaData[$orderRow['area']]) ? $areaData[$orderRow['area']] : ''; $wholeData['ship_addr'] = $orderRow['address']; $wholeData['ship_tel'] = $orderRow['telphone']; $wholeData['ship_mobile'] = $orderRow['mobile']; $wholeData['ship_zip'] = $orderRow['postcode']; $wholeData['ship_detail_addr'] = $wholeData['ship_area_0'] . $wholeData['ship_area_1'] . $wholeData['ship_area_2'] . $orderRow['address']; $wholeData['dly_name'] = $shipRow['ship_user_name']; $wholeData['dly_area_0'] = isset($areaData[$shipRow['province']]) ? $areaData[$shipRow['province']] : ''; $wholeData['dly_area_1'] = isset($areaData[$shipRow['city']]) ? $areaData[$shipRow['city']] : ''; $wholeData['dly_area_2'] = isset($areaData[$shipRow['area']]) ? $areaData[$shipRow['area']] : ''; $wholeData['dly_address'] = $shipRow['address']; $wholeData['dly_tel'] = $shipRow['telphone']; $wholeData['dly_mobile'] = $shipRow['mobile']; $wholeData['dly_zip'] = $shipRow['postcode']; $wholeData['date_y'] = date('Y'); $wholeData['date_m'] = date('m'); $wholeData['date_d'] = date('d'); $wholeData['order_id'] = $orderRow['order_no']; $wholeData['order_price'] = $orderRow['order_amount']; $wholeData['order_weight'] = isset($orderTotal['weight_total']) ? $orderTotal['weight_total'] : ''; $wholeData['order_count'] = isset($orderTotal['num_total']) ? $orderTotal['num_total'] : ''; $wholeData['order_memo'] = $orderRow['note']; $wholeData['ship_time'] = $orderRow['accept_time']; $wholeData['shop_name'] = isset($site_config['name']) ? $site_config['name'] : ''; $wholeData['tick'] = '√'; //进行数据替换 foreach ($expressConfig as $key => $val) { $item_tmp = JSON::decode($val); $item_tmp['typeText'] = isset($wholeData[$item_tmp['typeId']]) ? $wholeData[$item_tmp['typeId']] : ''; $resultArray[] = JSON::encode($item_tmp); } return $resultArray; }
public function oauth_edit_act() { $id = IFilter::act(IReq::get('id')); if ($id == 0) { $this->redirect('oauth_list', false); Util::showMessage('请选择要修改的登录平台'); exit; } $oauthDBObj = new IModel('oauth'); $oauthRow = $oauthDBObj->getObj('id = ' . $id); if (empty($oauthRow)) { $this->redirect('oauth_list', false); Util::showMessage('请选择要修改的登录平台'); exit; } $dataArray = array('name' => IFilter::act(IReq::get('name')), 'is_close' => IFilter::act(IReq::get('is_close')), 'description' => IFilter::act(IReq::get('description')), 'config' => array()); //获取字段数据 $oauthObj = new Oauth($id); $oauthFields = $oauthObj->getFields(); if (!empty($oauthFields)) { $parmsArray = array_keys($oauthFields); foreach ($parmsArray as $val) { $dataArray['config'][$val] = IFilter::act(IReq::get($val)); } } $dataArray['config'] = serialize($dataArray['config']); $oauthDBObj->setData($dataArray); $oauthDBObj->update('id = ' . $id); $this->redirect('oauth_list'); }
/** * @brief 计算商品的价格区间 * @param $catId 商品分类id * @param $showPriceNum 展示分组最大数量 * @return array 价格区间分组 */ public static function getGoodsPrice($catId, $showPriceNum = 4) { $goodsObj = new IModel('category_extend as ca,goods as go'); $goodsPrice = $goodsObj->getObj('ca.category_id in (' . $catId . ') and ca.goods_id = go.id', 'MIN(sell_price) as min,MAX(sell_price) as max'); if ($goodsPrice['min'] <= 0) { return array(); } $minBit = strlen(intval($goodsPrice['min'])); if ($minBit <= 2) { $minPrice = 99; } else { $minPrice = substr(intval($goodsPrice['min']), 0, 1) . str_repeat('9', $minBit - 1); } //商品价格计算 $result = array('1-' . $minPrice); $perPrice = floor(($goodsPrice['max'] - $minPrice) / ($showPriceNum - 1)); if ($perPrice > 0) { for ($addPrice = $minPrice + 1; $addPrice < $goodsPrice['max'];) { $stepPrice = $addPrice + $perPrice; $stepPrice = substr(intval($stepPrice), 0, 1) . str_repeat('9', strlen(intval($stepPrice)) - 1); $result[] = $addPrice . '-' . $stepPrice; $addPrice = $stepPrice + 1; } } return $result; }
/** * @brief 获取订单基本数据资料 * @param $order_id int 订单的id * @return array() */ public function getOrderShow($order_id) { $data = array(); //获得对象 $tb_order = new IModel('order'); $data = $tb_order->getObj('id=' . $order_id); if ($data) { $data['order_id'] = $order_id; //获取配送方式 $tb_delivery = new IModel('delivery'); $delivery_info = $tb_delivery->getObj('id=' . $data['distribution']); if ($delivery_info) { $data['delivery'] = $delivery_info['name']; } //获取支付方式 $tb_payment = new IModel('payment'); $payment_info = $tb_payment->getObj('id=' . $data['pay_type']); if ($payment_info) { $data['payment'] = $payment_info['name']; } //获取商品总重量和总金额 $tb_order_goods = new IModel('order_goods'); $order_goods_info = $tb_order_goods->query('order_id=' . $order_id); $data['goods_amount'] = 0; $data['goods_weight'] = 0; if ($order_goods_info) { foreach ($order_goods_info as $value) { $data['goods_amount'] += $value['real_price'] * $value['goods_nums']; $data['goods_weight'] += $value['goods_weight'] * $value['goods_nums']; } } //获取用户信息 $query = new IQuery('user as u'); $query->join = ' left join member as m on u.id=m.user_id '; $query->fields = 'u.username,u.email,m.mobile,m.contact_addr,m.true_name'; $query->where = 'u.id=' . $data['user_id']; $user_info = $query->find(); if ($user_info) { $user_info = $user_info[0]; $data['username'] = $user_info['username']; $data['email'] = $user_info['email']; $data['u_mobile'] = $user_info['mobile']; $data['contact_addr'] = $user_info['contact_addr']; $data['true_name'] = $user_info['true_name']; } } return $data; }
/** * @brief 获取树形分类 * @param int $catId 分类ID * @return array */ public static function catTree($catId) { $result = array(); $catDB = new IModel('category'); $childList = $catDB->query("parent_id = '{$catId}'"); if (!$childList) { $catRow = $catDB->getObj("id = '{$catId}'"); $childList = $catDB->query('parent_id = ' . $catRow['parent_id']); } return $childList; }
/** * 余额付款 * T:支付失败; * F:支付成功; */ function payment_balance() { $urlStr = ''; $user_id = intval($this->user['user_id']); $return['attach'] = IReq::get('attach'); $return['total_fee'] = IReq::get('total_fee'); $return['order_no'] = IReq::get('order_no'); $return['return_url'] = IReq::get('return_url'); $sign = IReq::get('sign'); if (stripos($return['order_no'], 'recharge_') !== false) { IError::show(403, '余额支付方式不能用于在线充值'); exit; } if (floatval($return['total_fee']) <= 0 || $return['order_no'] == '' || $return['return_url'] == '') { IError::show(403, '支付参数不正确'); } else { $paymentDB = new IModel('payment'); $paymentRow = $paymentDB->getObj('class_name = "balance" '); $pkey = Payment::getConfigParam($paymentRow['id'], 'M_PartnerKey'); //md5校验 ksort($return); foreach ($return as $key => $val) { $urlStr .= $key . '=' . urlencode($val) . '&'; } $urlStr .= $user_id . $pkey; if ($sign != md5($urlStr)) { IError::show(403, '数据校验不正确'); } else { $memberObj = new IModel('member'); $memberRow = $memberObj->getObj('user_id = ' . $user_id); if (empty($memberRow)) { IError::show(403, '用户信息不存在'); exit; } else { if ($memberRow['balance'] < $return['total_fee']) { IError::show(403, '账户余额不足'); exit; } else { $orderObj = new IModel('order'); $orderRow = $orderObj->getObj('order_no = "' . IFilter::act($return['order_no']) . '" and pay_status = 0 and user_id = ' . $user_id); if (empty($orderRow)) { IError::show(403, '订单已经被处理过,请查看订单状态'); exit; } $dataArray = array('balance' => 'balance - ' . IFilter::act($return['total_fee'])); $memberObj->setData($dataArray); $is_success = $memberObj->update('user_id = ' . $user_id, 'balance'); if ($is_success) { $return['is_success'] = 'T'; } else { $return['is_success'] = 'F'; } ksort($return); //返还的URL地址 $responseUrl = ''; foreach ($return as $key => $val) { $responseUrl .= $key . '=' . urlencode($val) . '&'; } $nextUrl = urldecode($return['return_url']); if (stripos($nextUrl, '?') === false) { $return_url = $nextUrl . '?' . $responseUrl; } else { $return_url = $nextUrl . '&' . $responseUrl; } //计算要发送的md5校验 $urlStrMD5 = md5($responseUrl . $user_id . $pkey); //拼接进返还的URL中 $return_url .= 'sign=' . $urlStrMD5; header('location:' . $return_url); } } } } }
function member_save() { $user_id = IFilter::act(IReq::get('user_id'), 'int'); $email = IFilter::act(IReq::get('email')); $password = IFilter::act(IReq::get('password')); $repassword = IFilter::act(IReq::get('repassword')); $user_group = IFilter::act(IReq::get('user_group'), 'int'); $truename = IFilter::act(IReq::get('truename')); $sex = IFilter::act(IReq::get('sex'), 'int'); $telephone = IFilter::act(IReq::get('telephone')); $mobile = IFilter::act(IReq::get('mobile')); $province = IFilter::act(IReq::get('province'), 'int'); $city = IFilter::act(IReq::get('city'), 'int'); $area = IFilter::act(IReq::get('area'), 'int'); $address = IFilter::act(IReq::get('address')); $zip = IFilter::act(IReq::get('zip')); $qq = IFilter::act(IReq::get('qq')); $msn = IFilter::act(IReq::get('msn')); $exp = IFilter::act(IReq::get('exp'), 'int'); $point = IFilter::act(IReq::get('point'), 'int'); $data['member'] = array('email' => $email, 'user_group' => $user_group, 'truename' => $truename, 'sex' => $sex, 'telephone' => $telephone, 'mobile' => $mobile, 'address' => $address, 'zip' => $zip, 'exp' => $exp, 'point' => $point, 'qq' => $qq, 'msn' => $msn); $count = ''; if ($province) { $count = ',' . $province . ',' . $city . ',' . $area . ','; } $data['province'] = $province; $data['city'] = $city; $data['area'] = $area; if (empty($user_id)) { $user_name = IFilter::act(IReq::get('user_name')); $email = IFilter::act(IReq::get('email')); $data['member']['user_name'] = $user_name; $data['member']['email'] = $email; if ($password == '') { $errorMsg = '请输入密码!'; $tb_user_group = new IModel('user_group'); $group_info = $tb_user_group->query(); $data['group'] = $group_info; $this->setRenderData($data); $this->redirect('member_edit', false); Util::showMessage($errorMsg); } if ($password != $repassword) { $errorMsg = '两次输入的密码不一致!'; $tb_user_group = new IModel('user_group'); $group_info = $tb_user_group->query(); $data['group'] = $group_info; $this->setRenderData($data); $this->redirect('member_edit', false); Util::showMessage($errorMsg); } $tb_user = new IModel("user"); $user = array('username' => $user_name, 'password' => md5($password), 'email' => $email); $tb_user->setData($user); $uid = $tb_user->add(); if ($uid) { $tb_member = new IModel("member"); $member = array('user_id' => $uid, 'true_name' => $truename, 'telephone' => $telephone, 'mobile' => $mobile, 'area' => $count, 'contact_addr' => $address, 'qq' => $qq, 'msn' => $msn, 'sex' => $sex, 'zip' => $zip, 'exp' => $exp, 'point' => $point, 'group_id' => $user_group, 'time' => date('Y-m-d H:i:s')); $tb_member->setData($member); $tb_member->add(); $this->redirect('member_list'); Util::showMessage('添加用户成功!'); } else { $this->redirect('member_list'); Util::showMessage('添加用户失败!'); } } else { $tb_user = new IModel("user"); $user = array('id' => $user_id); if ($password != '') { if ($password != $repassword) { $errorMsg = '两次输入的密码不一致!'; $tb_user_group = new IModel('user_group'); $group_info = $tb_user_group->query(); $data['group'] = $group_info; $this->setRenderData($data); $this->redirect('member_edit', false); Util::showMessage($errorMsg); } $user['password'] = md5($password); } $tb_user->setData($user); $tb_user->update("id=" . $user_id); $tb_member = new IModel("member"); $member_info = $tb_member->getObj('user_id=' . $user_id); //修改积分 if ($point != $member_info['point']) { $pointObj = new Point(); $pointConfig = array('user_id' => $user_id, 'point' => $point, 'log' => '管理员' . $this->admin['admin_name'] . '将您的积分重置为' . $point . '积分'); $pointObj->update($pointConfig); } $member = array('true_name' => $truename, 'telephone' => $telephone, 'mobile' => $mobile, 'area' => $count, 'contact_addr' => $address, 'qq' => $qq, 'msn' => $msn, 'sex' => $sex, 'zip' => $zip, 'exp' => $exp, 'point' => $point, 'group_id' => $user_group, 'time' => date('Y-m-d H:i:s')); $tb_member->setData($member); $affected_rows = $tb_member->update("user_id=" . $user_id); if ($affected_rows) { $this->redirect('member_list'); Util::showMessage('更新用户成功!'); } else { $this->redirect('member_list'); Util::showMessage('更新用户失败!'); } } }
public static function getTicketCount($id) { $propObj = new IModel('prop'); $where = '`condition` = "' . $id . '"'; $propCount = $propObj->getObj($where, 'count(*) as count'); return $propCount['count']; }
function goods_copy() { $idArray = explode(',', IReq::get('id')); $idArray = IFilter::act($idArray, 'int'); $goodsDB = new IModel('goods'); $goodsAttrDB = new IModel('goods_attribute'); $goodsPhotoRelationDB = new IModel('goods_photo_relation'); $productsDB = new IModel('products'); $goodsData = $goodsDB->query('id in (' . join(',', $idArray) . ') and is_share = 1 and is_del = 0 and seller_id = 0', '*'); if ($goodsData) { foreach ($goodsData as $key => $val) { //判断是否重复 if ($goodsDB->getObj('seller_id = ' . $this->seller['seller_id'] . ' and name = "' . $val['name'] . '"')) { die('商品不能重复复制'); } $oldId = $val['id']; //商品数据 unset($val['id'], $val['visit'], $val['favorite'], $val['sort'], $val['comments'], $val['sale'], $val['grade'], $val['is_share']); $val['seller_id'] = $this->seller['seller_id']; $val['goods_no'] .= '-' . $this->seller['seller_id']; $goodsDB->setData($val); $goods_id = $goodsDB->add(); //商品属性 $attrData = $goodsAttrDB->query('goods_id = ' . $oldId); if ($attrData) { foreach ($attrData as $k => $v) { unset($v['id']); $v['goods_id'] = $goods_id; $goodsAttrDB->setData($v); $goodsAttrDB->add(); } } //商品图片 $photoData = $goodsPhotoRelationDB->query('goods_id = ' . $oldId); if ($photoData) { foreach ($photoData as $k => $v) { unset($v['id']); $v['goods_id'] = $goods_id; $goodsPhotoRelationDB->setData($v); $goodsPhotoRelationDB->add(); } } //货品 $productsData = $productsDB->query('goods_id = ' . $oldId); if ($productsData) { foreach ($productsData as $k => $v) { unset($v['id']); $v['products_no'] .= '-' . $this->seller['seller_id']; $v['goods_id'] = $goods_id; $productsDB->setData($v); $productsDB->add(); } } } die('success'); } else { die('复制的商品不存在'); } }
/** * 获取商品金额的支付费用 * @param $payment_id int 支付方式ID * @param $goodsSum float 商品总价格 * @return $goodsPayPrice */ public static function getGoodsPaymentPrice($payment_id, $goodsSum) { $paymentObj = new IModel('payment'); $paymentRow = $paymentObj->getObj('id = ' . $payment_id, 'poundage,poundage_type'); if ($paymentRow) { if ($paymentRow['poundage_type'] == 1) { //按照百分比 return $goodsSum * ($paymentRow['poundage'] * 0.01); } //按照固定金额 return $paymentRow['poundage']; } return 0; }
function keyword_hot() { $id = IFilter::act(IReq::get('id')); $keywordObj = new IModel('keyword'); $dataArray = array('hot' => 'abs(hot - 1)'); $keywordObj->setData($dataArray); $is_result = $keywordObj->update('word = "' . $id . '"', 'hot'); $keywordRow = $keywordObj->getObj('word = "' . $id . '"'); if ($is_result !== false) { echo JSON::encode(array('isError' => false, 'hot' => $keywordRow['hot'])); } else { echo JSON::encode(array('isError' => true, 'message' => '设置失败')); } }
/** * @brief 品牌分类排序 */ function brand_sort() { $brand_id = IFilter::act(IReq::get('id')); $sort = IFilter::act(IReq::get('sort')); $flag = 0; if ($brand_id) { $tb_brand = new IModel('brand'); $brand_info = $tb_brand->getObj('id=' . $brand_id); if (count($brand_info) > 0) { if ($brand_info['sort'] != $sort) { $tb_brand->setData(array('sort' => $sort)); if ($tb_brand->update('id=' . $brand_id)) { $flag = 1; } } } } echo $flag; }
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 address_add() { $accept_name = IFilter::act(IReq::get('accept_name')); $province = IFilter::act(IReq::get('province'), 'int'); $city = IFilter::act(IReq::get('city'), 'int'); $area = IFilter::act(IReq::get('area'), 'int'); $address = IFilter::act(IReq::get('address')); $zip = IFilter::act(IReq::get('zip')); $telphone = IFilter::act(IReq::get('telphone')); $mobile = IFilter::act(IReq::get('mobile')); $user_id = $this->user['user_id']; if (!$user_id) { die(JSON::encode(array('data' => null))); } //整合的数据,检查数据库中是否存在此收货地址 $sqlData = array('user_id' => $user_id, 'accept_name' => $accept_name, 'zip' => $zip, 'telphone' => $telphone, 'province' => $province, 'city' => $city, 'area' => $area, 'address' => $address, 'mobile' => $mobile); $sqlArray = array(); foreach ($sqlData as $key => $val) { $sqlArray[] = $key . '="' . $val . '"'; } $model = new IModel('address'); $addressRow = $model->getObj(join(' and ', $sqlArray)); if ($addressRow) { $result = array('data' => null); } else { //获取地区text $areaList = area::name($province, $city, $area); //执行insert $model->setData($sqlData); $id = $model->add(); $sqlData['id'] = $id; $sqlData['province_val'] = $areaList[$province]; $sqlData['city_val'] = $areaList[$city]; $sqlData['area_val'] = $areaList[$area]; $result = array('data' => $sqlData); } die(JSON::encode($result)); }