Пример #1
0
 /**
  * @brief 积分更新
  * @param int $user_id 用户ID
  * @param int $point   积分数(正,负)
  */
 private function editPoint($user_id, $point)
 {
     $memberObj = new IModel('member');
     $memberArray = array('point' => 'point + ' . $point);
     $memberObj->setData($memberArray);
     return $memberObj->update('user_id = ' . $user_id, 'point');
 }
Пример #2
0
 /**
  * @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);
     }
 }
Пример #3
0
 /**
  * @param $province string 省份的id
  * @param $weight int 货物的重量
  * @param $goodsSum float 商品总价格
  * @return array()
  * @brief 配送方式计算管理模块
  */
 public static function getDelivery($province, $weight = 0, $goodsSum = 0)
 {
     $data = array();
     //获得配送方式表的对象
     $delivery = new IModel('delivery');
     //获取配送方式列表
     $where = 'is_delete = 0 and status = 1';
     $list = $delivery->query($where, '*', 'sort', 'asc');
     //循环各个配送方式
     foreach ($list as $value) {
         //设置首重和次重
         self::$firstWeight = $value['first_weight'];
         self::$secondWeight = $value['second_weight'];
         $data[$value['id']]['id'] = $value['id'];
         $data[$value['id']]['name'] = $value['name'];
         $data[$value['id']]['type'] = $value['type'];
         $data[$value['id']]['description'] = $value['description'];
         $data[$value['id']]['if_delivery'] = '0';
         //当配送方式是统一配置的时候,不进行区分地区价格
         if ($value['price_type'] == 0) {
             $data[$value['id']]['price'] = self::getFeeByWeight($weight, $value['first_price'], $value['second_price']);
         } else {
             $matchKey = '';
             $flag = false;
             //每项都是以';'隔开的省份ID
             $area_groupid = unserialize($value['area_groupid']);
             foreach ($area_groupid as $key => $result) {
                 //匹配到了特殊的省份运费价格
                 if (strpos($result, ';' . $province . ';') !== false) {
                     $matchKey = $key;
                     $flag = true;
                     break;
                 }
             }
             //匹配到了特殊的省份运费价格
             if ($flag) {
                 //获取当前省份特殊的运费价格
                 $firstprice = unserialize($value['firstprice']);
                 $secondprice = unserialize($value['secondprice']);
                 $data[$value['id']]['price'] = self::getFeeByWeight($weight, $firstprice[$matchKey], $secondprice[$matchKey]);
             } else {
                 //判断是否设置默认费用了
                 if ($value['open_default'] == 1) {
                     $data[$value['id']]['price'] = self::getFeeByWeight($weight, $value['first_price'], $value['second_price']);
                 } else {
                     $data[$value['id']]['price'] = '0';
                     $data[$value['id']]['if_delivery'] = '1';
                 }
             }
         }
         //计算保价
         if ($value['is_save_price'] == 1) {
             $tempProtectPrice = $goodsSum * ($value['save_rate'] * 0.01);
             $data[$value['id']]['protect_price'] = $tempProtectPrice <= $value['low_price'] ? $value['low_price'] : $tempProtectPrice;
         } else {
             $data[$value['id']]['protect_price'] = 0;
         }
     }
     return $data;
 }
Пример #4
0
 /**
  * @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;
         }
     }
 }
Пример #5
0
 /**
  * @brief 根据传入的地域ID获取地域名称,获取的名称是根据ID依次获取的
  * @param int 地域ID 匿名参数可以多个id
  * @return array
  */
 public static function name()
 {
     $result = array();
     $paramArray = func_get_args();
     $areaDB = new IModel('areas');
     $areaData = $areaDB->query("area_id in (" . trim(join(',', $paramArray), ",") . ")");
     foreach ($areaData as $key => $value) {
         $result[$value['area_id']] = $value['area_name'];
     }
     return $result;
 }
Пример #6
0
 public static function getAuth(IModel $player, $password)
 {
     if ($player->exists()) {
         if (password_verify(trim($password), $player->getPlayer()['password'])) {
             $_SESSION['id'] = $player->getPlayer()['id'];
             $_SESSION['name'] = $player->getPlayer()['name'];
             $_SESSION['auth'] = 1;
             return true;
         }
         return false;
     }
     return false;
 }
Пример #7
0
 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);
     }
 }
Пример #8
0
 /**
  * @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'] : '';
         }
     }
 }
Пример #9
0
 /**
  * @brief 向数据库写入log
  * @param array  log数据
  * @return bool  操作结果
  */
 public function write($logs = array())
 {
     if (!is_array($logs) || empty($logs)) {
         throw new IException('the $logs parms must be array');
     }
     if ($this->tableName == '') {
         throw new IException('the tableName is undefined');
     }
     $logObj = new IModel($this->tableName);
     $logObj->setData($logs);
     $result = $logObj->add();
     if ($result) {
         return true;
     } else {
         return false;
     }
 }
Пример #10
0
 /**
  * @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;
     }
 }
Пример #11
0
 /**
  * 退订,并记录退订理由
  * @param string $email 
  * @param string $content 退订理由
  * @static
  */
 public static function unsubscribe($email, $content)
 {
     $email = addslashes($email);
     $tb = new IModel("email_registry");
     $re = $tb->query("email = '{$email}' AND flag=1");
     if (!$re) {
         return array('flag' => false, 'data' => '你还没有订阅');
     }
     $re = end($re);
     /*
     $re['content'] = htmlspecialchars($content,ENT_QUOTES);
     $re['flag'] = 0;
     $tb->setData($re);
     $tb->update("id={$re['id']}");
     */
     $tb->del("id={$re['id']}");
     return array('flag' => true, 'data' => 'success');
 }
Пример #12
0
 function __construct(Agent $model = null, Database $db = null)
 {
     parent::__construct();
     $this->agent = $model;
     $this->db = $db;
     if ($this->db == null) {
         $this->db = new Database();
     }
 }
Пример #13
0
 static function showCat($selectName = 'category_id', $selectedValue = null, $defaultValue = array())
 {
     //取得文章分类信息
     $catObj = new IModel('article_category');
     $data = $catObj->query('', 'id,name,path', 'path', 'asc');
     $str = '<select class="auto" name="' . $selectName . '" pattern="required" alt="请选择分类值">';
     //默认option值
     if (!empty($defaultValue)) {
         $str .= '<option value="' . current($defaultValue) . '">' . key($defaultValue) . '</option>';
     }
     //拼接分类信息
     foreach ($data as $val) {
         $isSelect = $val['id'] == $selectedValue ? 'selected=selected' : null;
         $str .= '<option value="' . $val['id'] . '" ' . $isSelect . '>' . str_repeat("&nbsp;&nbsp;", substr_count($val['path'], ",") - 2) . '└' . $val['name'] . '</option>';
     }
     $str .= '</select>';
     return $str;
 }
Пример #14
0
 /**
  * 检测用户是否能够评论
  *
  * @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);
 }
Пример #15
0
 function __construct(Flight $flight = null, Database $db = null)
 {
     parent::__construct();
     $this->flight = $flight;
     if ($db == null) {
         $this->db = new Database();
     } else {
         $this->db = $db;
     }
 }
Пример #16
0
 public static function ucenter_order()
 {
     $siteConfig = new Config('site_config');
     $order_cancel_time = $siteConfig->order_cancel_time !== "" ? intval($siteConfig->order_cancel_time) : 7;
     $order_finish_time = $siteConfig->order_finish_time !== "" ? intval($siteConfig->order_finish_time) : 20;
     $orderModel = new IModel('order');
     $orderCancelData = $order_cancel_time >= 0 ? $orderModel->query(" if_del = 0 and pay_type != 0 and status in(1) and datediff(NOW(),create_time) >= {$order_cancel_time} ", "id,order_no,4 as type_data") : array();
     $orderCreateData = $order_finish_time >= 0 ? $orderModel->query(" if_del = 0 and distribution_status = 1 and status in(1,2) and datediff(NOW(),send_time) >= {$order_finish_time} ", "id,order_no,5 as type_data") : array();
     $resultData = array_merge($orderCreateData, $orderCancelData);
     if ($resultData) {
         foreach ($resultData as $key => $val) {
             $type = $val['type_data'];
             $order_id = $val['id'];
             $order_no = $val['order_no'];
             //oerder表的对象
             $tb_order = new IModel('order');
             $tb_order->setData(array('status' => $type, 'completion_time' => ITime::getDateTime()));
             $tb_order->update('id=' . $order_id);
             //生成订单日志
             $tb_order_log = new IModel('order_log');
             //订单自动完成
             if ($type == '5') {
                 $action = '完成';
                 $note = '订单【' . $order_no . '】完成成功';
                 //完成订单并且进行支付
                 Order_Class::updateOrderStatus($order_no);
                 //增加用户评论商品机会
                 Order_Class::addGoodsCommentChange($order_id);
                 $logObj = new log('db');
                 $logObj->write('operation', array("系统自动", "订单更新为完成", '订单号:' . $order_no));
             } else {
                 $action = '作废';
                 $note = '订单【' . $order_no . '】作废成功';
                 //订单重置取消
                 Order_class::resetOrderProp($order_id);
                 $logObj = new log('db');
                 $logObj->write('operation', array("系统自动", "订单更新为作废", '订单号:' . $order_no));
             }
             $tb_order_log->setData(array('order_id' => $order_id, 'user' => "系统自动", 'action' => $action, 'result' => '成功', 'note' => $note, 'addtime' => ITime::getDateTime()));
             $tb_order_log->add();
         }
     }
 }
Пример #17
0
 /**
  * @brief 删除品牌
  */
 function brand_del()
 {
     $brand_id = (int) IReq::get('bid');
     if ($brand_id) {
         $tb_brand = new IModel('brand');
         $where = "id=" . $brand_id;
         if ($tb_brand->del($where)) {
             $this->brand_list();
         } else {
             $this->brand_list();
             $msg = "没有找到相关分类记录!";
             Util::showMessage($msg);
         }
     } else {
         $this->brand_list();
         $msg = "没有找到相关品牌记录!";
         Util::showMessage($msg);
     }
 }
Пример #18
0
 public function __construct($flight_id = NULL, $ticket_cat = NULL, $ticket_type = NULL, $adult = 0, $child = 0, $price = 0.0)
 {
     parent::__construct();
     $this->flight_id = $flight_id;
     $this->children_no = $child;
     $this->adult_no = $adult;
     $this->ticket_cat = $ticket_cat;
     $this->ticket_type = $ticket_type;
     $this->ticket_adult_price = $price;
     $this->id = Validator::UniqueKey();
 }
Пример #19
0
 public function getPaymentListByOnline()
 {
     $where = " type = 1 and status = 0 and class_name not in ('balance','offline') ";
     switch (IClient::getDevice()) {
         //移动支付
         case IClient::MOBILE:
             $where .= ' and client_type in(2,3) ';
             //如果不是微信客户端,去掉微信专用支付
             if (IClient::isWechat() == false) {
                 $where .= " and class_name != 'wap_wechat'";
             }
             break;
             //pc支付
         //pc支付
         case IClient::PC:
             $where .= ' and client_type in(1,3) ';
             break;
     }
     $paymentDB = new IModel('payment');
     return $paymentDB->query($where);
 }
Пример #20
0
 public function getBrandListByGoodsCategoryId($id, $limit = 14)
 {
     $result = array();
     $tb_brand_category = new IModel('brand_category');
     $info = $tb_brand_category->query("goods_category_id=" . $id);
     if ($info) {
         $query = new IQuery('brand');
         foreach ($info as $key => $val) {
             $query->where = " FIND_IN_SET(" . $val['id'] . ",category_ids) ";
             $query->order = 'sort asc';
             $query->limit = $limit;
             $list = $query->find();
             $result = array_merge($result, $list);
             if (count($result) >= $limit) {
                 $result = array_slice($result, 0, $limit);
                 break;
             }
         }
     }
     return $result;
 }
Пример #21
0
 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;
     }
 }
Пример #22
0
 /**
  * @brief 发送到货通知邮件
  */
 function notify_send()
 {
     $smtp = new SendMail();
     $error = $smtp->getError();
     if ($error) {
         $return = array('isError' => true, 'message' => $error);
         echo JSON::encode($return);
         exit;
     }
     $notify_ids = IFilter::act(IReq::get('notifyid'));
     $message = '';
     if ($notify_ids && is_array($notify_ids)) {
         $ids = join(',', $notify_ids);
         $query = new IQuery("notify_registry as notify");
         $query->join = "right join goods as goods on notify.goods_id=goods.id left join user as u on notify.user_id = u.id";
         $query->fields = "notify.*,u.username,goods.name as goods_name,goods.store_nums";
         $query->where = "notify.id in(" . $ids . ")";
         $items = $query->find();
         //库存大于0,且处于未发送状态的 发送通知
         $succeed = 0;
         $failed = 0;
         $tb_notify_registry = new IModel('notify_registry');
         foreach ($items as $value) {
             $body = mailTemplate::notify(array('{goodsName}' => $value['goods_name'], '{url}' => IUrl::getHost() . IUrl::creatUrl('/site/products/id/' . $value['goods_id'])));
             $status = $smtp->send($value['email'], "到货通知", $body);
             if ($status) {
                 //发送成功
                 $succeed++;
                 $data = array('notify_time' => ITime::getDateTime(), 'notify_status' => '1');
                 $tb_notify_registry->setData($data);
                 $tb_notify_registry->update('id=' . $value['id']);
             } else {
                 //发送失败
                 $failed++;
             }
         }
     }
     $return = array('isError' => false, 'count' => count($items), 'succeed' => $succeed, 'failed' => $failed);
     echo JSON::encode($return);
 }
Пример #23
0
 /**
  * @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;
 }
Пример #24
0
 /**
  * 查询删除
  */
 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");
 }
Пример #25
0
 private function getOauthRow($id)
 {
     $oauthObj = new IModel('oauth');
     $oauthRow = $oauthObj->getObj('id = ' . $id);
     return $oauthRow;
 }
Пример #26
0
 /**
  * @brief 记录支付平台的交易号
  * @param $orderNo string 订单编号
  * @param $tradeNo string 交易流水号
  * @return boolean
  */
 protected function recordTradeNo($orderNo, $tradeNo)
 {
     $orderDB = new IModel('order');
     $orderDB->setData(array('trade_no' => $tradeNo));
     return $orderDB->update('order_no = "' . $orderNo . '"');
 }
Пример #27
0
 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('复制的商品不存在');
     }
 }
Пример #28
0
 static function getCategroy($category_id)
 {
     $sub_category = '';
     if ($category_id) {
         $tb_category = new IModel('category');
         $category_info = $tb_category->query('parent_id=' . $category_id);
         if (count($category_info) > 0) {
             foreach ($category_info as $value) {
                 $sub_category .= $value['id'] . ',';
                 $sub_category .= self::getCategroy($value['id']);
             }
         }
     }
     return $sub_category;
 }
Пример #29
0
 /**
  * @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;
 }
Пример #30
0
 function withdraw_status()
 {
     $id = IFilter::act(IReq::get('id'), 'int');
     $re_note = IFilter::act(IReq::get('re_note'), 'string');
     if ($id) {
         $withdrawObj = new IModel('withdraw');
         $dataArray = array('re_note' => $re_note);
         if (IReq::get('status') !== NULL) {
             $dataArray['status'] = IFilter::act(IReq::get('status'), 'int');
         }
         $withdrawObj->setData($dataArray);
         $where = "`id`= {$id} AND `status` = 0";
         $re = $withdrawObj->update($where);
         $this->withdraw_detail(true);
         if ($re != 0) {
             $logObj = new log('db');
             $logObj->write('operation', array("管理员:" . $this->admin['admin_name'], "修改了提现申请", "ID值为:" . $id));
         }
         Util::showMessage("更新成功");
     } else {
         $this->redirect('withdraw_list');
     }
 }