Пример #1
0
 /**
  * 向词库中添加词
  * @param $word  string 多个词以','分隔
  * @param $hot   int    0:否;1:是
  * @param $order int    排序
  */
 public static function add($word, $hot = 0, $order = 99)
 {
     $word = IFilter::act($word);
     $hot = intval($hot);
     $order = intval($order);
     if ($word != '') {
         $keywordObj = new IModel('keyword');
         $wordArray = explode(',', $word);
         $wordArray = array_unique($wordArray);
         //获取各个关键词的管理商品数量
         $resultCount = self::count($wordArray);
         foreach ($wordArray as $word) {
             if (IString::getStrLen($word) >= 15) {
                 continue;
             }
             $is_exists = $keywordObj->getObj('word = "' . $word . '"', 'hot');
             if (empty($is_exists)) {
                 $dataArray = array('hot' => $hot, 'word' => $word, 'goods_nums' => $resultCount[$word], 'order' => $order);
                 $keywordObj->setData($dataArray);
                 $keywordObj->add();
             } else {
                 $dataArray = array('hot' => $hot, 'order' => $order);
                 $keywordObj->setData($dataArray);
                 $keywordObj->update("word = '" . $word . "'");
             }
         }
         return array('flag' => true);
     }
     return array('flag' => false, 'data' => '请填写关键词');
 }
Пример #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
 /**
  * @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();
 }
Пример #4
0
 /**
  * @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);
     }
 }
Пример #5
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');
 }
Пример #6
0
 /**
  * @brief 回复建议
  */
 function suggestion_edit_act()
 {
     $id = intval(IReq::get('id', 'post'));
     $re_content = IFilter::act(IReq::get('re_content', 'post'), 'string');
     $tb = new IModel("suggestion");
     $data = array('admin_id' => $this->admin['admin_id'], 're_content' => $re_content, 're_time' => date('Y-m-d H:i:s'));
     $tb->setData($data);
     $tb->update("id={$id}");
     $this->redirect("/comment/suggestion_list");
 }
Пример #7
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;
         }
     }
 }
Пример #8
0
 /**
  * @brief 保存模板修改
  */
 function tpl_save()
 {
     $tid = intval(IReq::get('tpl_id', 'post'));
     if ($tid) {
         $title = IFilter::act(IReq::get('title'), 'string');
         $content = IFilter::act(IReq::get('content'), 'text');
         $tb_msg_template = new IModel('msg_template');
         $tb_msg_template->setData(array('title' => $title, 'content' => $content));
         $tb_msg_template->update('id=' . $tid);
     }
     $this->redirect('tpl_list');
 }
Пример #9
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);
     }
 }
Пример #10
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;
     }
 }
Пример #11
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();
         }
     }
 }
Пример #12
0
 /**
  * 写入日志并且更新账户余额
  * @param array $config config数据类型
  * @return string|bool
  */
 public function write($config)
 {
     if (isset($config['user_id'])) {
         $this->setUser($config['user_id']);
     } else {
         throw new IException("用户信息不存在");
     }
     isset($config['seller_id']) ? $this->setSeller($config['seller_id']) : "";
     isset($config['admin_id']) ? $this->setAdmin($config['admin_id']) : "";
     isset($config['event']) ? $this->setEvent($config['event']) : "";
     if (isset($config['num']) && is_numeric($config['num'])) {
         $this->amount = abs(round($config['num'], 2));
         //金额正负值处理
         if (in_array($this->allow_event[$this->event], array(2, 3))) {
             $this->amount = '-' . abs($this->amount);
         }
     } else {
         throw new IException("金额必须大于0元");
     }
     $this->config = $config;
     $this->noteData = isset($config['note']) ? $config['note'] : $this->note();
     //写入数据库
     $finnalAmount = $this->user['balance'] + $this->amount;
     if ($finnalAmount < 0) {
         throw new IException("用户余额不足");
     }
     $memberDB = new IModel('member');
     $memberDB->setData(array("balance" => $finnalAmount));
     $memberDB->update("user_id = " . $this->user['id']);
     $tb_account_log = new IModel("account_log");
     $insertData = array('admin_id' => $this->admin ? $this->admin['id'] : 0, 'user_id' => $this->user['id'], 'event' => $this->allow_event[$this->event], 'note' => $this->noteData, 'amount' => $this->amount, 'amount_log' => $finnalAmount, 'type' => $this->amount >= 0 ? 0 : 1, 'time' => ITime::getDateTime());
     $tb_account_log->setData($insertData);
     $result = $tb_account_log->add();
     //后台管理员操作记录
     if ($insertData['admin_id']) {
         $logObj = new log('db');
         $logObj->write('operation', array("管理员:" . $this->admin['admin_name'], "对账户金额进行了修改", $insertData['note']));
     }
     return $result;
 }
Пример #13
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);
 }
Пример #14
0
 function upload()
 {
     //图片上传
     $upObj = new IUpload();
     //目录散列
     $dir = IWeb::$app->config['upload'] . '/' . date('Y') . "/" . date('m') . "/" . date('d');
     $upObj->setDir($dir);
     $upState = $upObj->execute();
     //实例化
     $obj = new IModel('spec_photo');
     //检查上传状态
     foreach ($upState['attach'] as $val) {
         if ($val['flag'] == 1) {
             $insertData = array('address' => $val['dir'] . $val['name'], 'name' => $val['ininame'], 'create_time' => ITime::getDateTime());
             $obj->setData($insertData);
             $obj->add();
         }
     }
     if (count($upState['attach']) == 1) {
         return $upState['attach'][0];
     } else {
         return $upState['attach'];
     }
 }
Пример #15
0
 /**
  * @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;
 }
Пример #16
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('复制的商品不存在');
     }
 }
Пример #17
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');
     }
 }
Пример #18
0
 public static function mod_cat_position($id, $position, $value)
 {
     $id = intval($id);
     $value = intval($value) == 1 ? 1 : 0;
     if ($position != 'left' && $position != 'foot') {
         return array('flag' => false, 'data' => '错误的位置');
     }
     $tb_help_category = new IModel("help_category");
     $tb_help_category->setData(array("position_{$position}" => $value));
     $tb_help_category->update("id={$id}");
     return array('flag' => true);
 }
Пример #19
0
 /**
  * @brief 从回收站还原会员
  */
 function member_restore()
 {
     $user_ids = IReq::get('check');
     $user_ids = is_array($user_ids) ? $user_ids : array($user_ids);
     if ($user_ids) {
         $user_ids = IFilter::act($user_ids, 'int');
         $ids = implode(',', $user_ids);
         if ($ids) {
             $tb_member = new IModel('member');
             $tb_member->setData(array('status' => '1'));
             $where = "user_id in (" . $ids . ")";
             $tb_member->update($where);
         }
     }
     $this->redirect('recycling');
 }
Пример #20
0
 /**
  * 直接发站内信到用户
  * 这个地方直接调用了Mysql的操作类
  * @param $userIds string 用户Id的串
  * @param $content 信件内容 array('title' => '标题','content' => '内容')
  */
 public static function sendToUser($userIds, $content)
 {
     set_time_limit(0);
     //插入$content
     $data = array('title' => IFilter::act($content['title']), 'content' => IFilter::act($content['content'], 'text'), 'time' => date('Y-m-d H:i:s'));
     $msgDB = new IModel("message");
     $msgDB->setData($data);
     $id = $msgDB->add();
     if ($id === false) {
         return false;
     } else {
         $db = IDBFactory::getDB();
         $tableName = IWeb::$app->config['DB']['tablePre'] . "member";
         if ($userIds) {
             $sql = "UPDATE `{$tableName}` SET message_ids = CONCAT( IFNULL(message_ids,'') ,'{$id},') WHERE user_id in ({$userIds})";
         } else {
             $sql = "UPDATE `{$tableName}` SET message_ids = CONCAT( IFNULL(message_ids,'') ,'{$id},')";
         }
         return $db->query($sql);
     }
 }
Пример #21
0
 /**
  * @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"]);
     }
 }
Пример #22
0
 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));
 }
Пример #23
0
 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');
 }
Пример #24
0
 /**
  * 操作数据库
  *
  * @param float $num 操作金额
  * @return bool|array 返回true代表成功,返回array代表着本次操作的错误信息
  */
 private function log($num)
 {
     if (!is_numeric($num)) {
         $this->error[] = "错误的操作金额:{$num}";
         return $this->error;
     }
     $num = sprintf("%.2f", $num);
     $this->num = $num;
     if ($this->_note === null) {
         $this->note();
     }
     if ($this->error) {
         return $this->error;
     }
     $tb_account_log = new IModel("account_log");
     $arr = array();
     $arr['admin_id'] = $this->admin['id'];
     $arr['user_id'] = $this->user['id'];
     $arr['event'] = $this->allow_event[$this->event];
     $arr['note'] = addslashes($this->_note);
     $arr['amount'] = $num;
     $arr['amount_log'] = $this->user['balance'];
     $arr['type'] = $num >= 0 ? 0 : 1;
     $arr['time'] = $this->time;
     $tb_account_log->setData($arr);
     $tb_account_log->add();
     //后台管理员操作记录
     if ($arr['admin_id']) {
         $logObj = new Log();
         $logObj->write('operation', array("管理员:" . ISafe::get('admin_name'), "对账户金额进行了修改", $arr['note']));
     }
     return true;
 }
Пример #25
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 . '"');
 }
Пример #26
0
 public function goods_share()
 {
     $idArray = explode(',', IReq::get('id'));
     $id = IFilter::act($idArray, 'int');
     $goodsDB = new IModel('goods');
     $goodsData = $goodsDB->query('id in (' . join(',', $id) . ')');
     foreach ($goodsData as $key => $val) {
         $is_share = $val['is_share'] == 1 ? 0 : 1;
         $goodsDB->setData(array('is_share' => $is_share));
         $goodsDB->update('id = ' . $val['id'] . ' and seller_id = 0');
     }
 }
Пример #27
0
 function keyword_order()
 {
     $word = IFilter::act(IReq::get('id'));
     $order = IReq::get('order') ? intval(IReq::get('order')) : 99;
     $keywordObj = new IModel('keyword');
     $dataArray = array('order' => $order);
     $keywordObj->setData($dataArray);
     $is_success = $keywordObj->update('word = "' . $word . '"');
     if ($is_success === false) {
         $result = array('isError' => true, 'message' => '更新排序失败');
     } else {
         $result = array('isError' => false);
     }
     echo JSON::encode($result);
 }
Пример #28
0
 static function get_order_pri_num_del($ogid)
 {
     $total = 0;
     $goods_id = '';
     $p_id = '';
     $number = '';
     //先根据ogid查询出order_goods单价和数量,然后从order表总价格中删除
     $query = new IQuery('order_goods');
     $query->where = 'id = ' . $ogid;
     $order_goods_info = $query->find();
     if (count($order_goods_info) > 0) {
         $order_id = $order_goods_info[0]['order_id'];
         $goods_price = $order_goods_info[0]['goods_price'];
         $real_price = $order_goods_info[0]['real_price'];
         $goods_nums = $order_goods_info[0]['goods_nums'];
         $number = $goods_nums;
         $goods_id = $order_goods_info[0]['goods_id'];
         $p_id = $order_goods_info[0]['product_id'];
         $tb_order = new IModel('order');
         $tb_order->setData(array('payable_amount' => 'payable_amount-' . $goods_price * $goods_nums, 'real_amount' => 'real_amount-' . $real_price * $goods_nums, 'order_amount' => 'order_amount-' . $real_price * $goods_nums));
         $arr = array('payable_amount', 'real_amount', 'order_amount');
         $tb_order->update('id=' . $order_id, $arr);
     }
     $islog = 0;
     $tb_order_goods = new IModel('order_goods');
     if ($tb_order_goods->del('id=' . $ogid)) {
         $islog = 1;
     }
     //修改goods表中数量,获得goods表的对象
     $tb_goods = new IModel('goods');
     $tb_goods->setData(array('store_nums' => 'store_nums+' . $number));
     $grr = array('store_nums');
     $tb_goods->update('id=' . $goods_id, $grr);
     //判断p_id是否有值如果有则修改products中的数量
     if ($p_id != 0) {
         $tb_products = new IModel('products');
         $tb_products->setData(array('store_nums' => 'store_nums+' . $number));
         $prr = array('store_nums');
         $tb_products->update('id=' . $p_id, $prr);
     }
     return $islog;
 }
Пример #29
0
 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);
 }
Пример #30
0
<?php

if ($picname) {
    // 如果有名字则上传成功
    $user_id = $this->user['user_id'];
    $user_obj = new IModel('user');
    $data = array('head_ico' => $picname);
    $user_obj->setData($data);
    $where = 'id = ' . $user_id;
    $res = $user_id->update($where);
    echo json_encode($res);
}
// 如果有名字则上传成功
$user_id = $this->user['user_id'];
$user_obj = new IModel('user');
$data = array('head_ico' => $picname);
$user_obj->setData($data);
$where = 'id = ' . $user_id;
$res = $user_id->update($where);
if ($res) {
    $msg = '上传成功';
} else {
    $msg = '上传失败';
}
// PHP上传失败 ---> 获取错误信息
if (!empty($_FILES[$img]['error'])) {
    $error = $this->getUploadError($_FILES[$img]['error']);
}