예제 #1
0
 function admin()
 {
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'message', roleModel::POWER_ALL)) {
         $this->view = new view(config('view'), 'admin/message.html');
         $this->view->assign('role', $roleModel->get($this->session->role));
         $systemModel = $this->model('system');
         $system = $systemModel->fetch('system');
         $system = $systemModel->toArray($system, 'system');
         $this->view->assign('system', $system);
         $messageModel = $this->model('message');
         $start = filter::int($this->get->start);
         $length = filter::int($this->get->length);
         $start = empty($start) ? 0 : $start;
         $length = empty($length) ? 10 : $length;
         $this->get->start = $start;
         $this->get->length = $length;
         $count = $messageModel->select('count(*)');
         $count = $count[0]['count(*)'];
         $this->view->assign('count', $count);
         $message = $messageModel->fetchAll($start, $length);
         $this->view->assign('message', $message);
         return $this->view->display();
     } else {
         $this->response->setCode(302);
         $this->response->addHeader('Location', $this->http->url('admin', 'index'));
     }
 }
예제 #2
0
 /**
  * 删除产品图像信息
  */
 function remove()
 {
     $this->response->addHeader('Content-Type', 'application/json');
     $id = filter::int($this->post->id);
     if (!empty($id)) {
         $productimgModel = $this->model('productimg');
         if ($productimgModel->remove($id)) {
             return json_encode(array('code' => 1, 'result' => 'ok'));
         }
     }
     return json_encode(array('code' => 0, 'result' => 'failed'));
 }
예제 #3
0
 /**
  * 从满减优惠中移除商品
  */
 function remove()
 {
     $this->response->addHeader('Content-Type', 'application/json');
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'fullcut', roleModel::POWER_UPDATE)) {
         $pid = filter::int($this->post->pid);
         $fid = filter::int($this->post->fid);
         $fullcutdetailModel = $this->model('fullcutdetail');
         if ($fullcutdetailModel->remove($fid, $pid)) {
             return json_encode(array('code' => 1, 'result' => 'ok'));
         }
         return json_encode(array('code' => 0, 'result' => '移除失败'));
     }
     return json_encode(array('code' => 2, 'result' => '没有权限'));
 }
예제 #4
0
 /**
  * 获取一个活动页的信息
  */
 function information()
 {
     $id = filter::int($this->get->id);
     if (!empty($id)) {
         $registerModel = $this->model('register');
         $result = $registerModel->get($id);
         if ($this->get->type == 'code') {
             $this->response->addHeader('Content-Type', 'text/html');
             return $result['content'];
         } else {
             return new json(json::OK, NULL, $result);
         }
     }
     return new json(json::PARAMETER_ERROR);
 }
예제 #5
0
 /**
  * 移除收藏
  */
 function remove()
 {
     if (!login::user()) {
         return json_encode(array('code' => 2, 'result' => '尚未登陆'));
     }
     $id = filter::int($this->post->id);
     $pid = filter::int($this->post->pid);
     if (empty($pid) && empty($id)) {
         return json_encode(array('code' => 3, 'result' => '参数不全'));
     }
     if ($this->model('favourite')->remove($id, $pid, $this->session->id)) {
         return json_encode(array('code' => 1, 'result' => 'ok'));
     }
     return json_encode(array('code' => 0, 'result' => 'failed'));
 }
예제 #6
0
 /**
  * 根据商品pid,属性关系表,查询价格库存和编码
  */
 function find()
 {
     $pid = filter::int($this->get->pid);
     $array = array();
     $a = explode(',', $this->get->content);
     foreach ($a as $b) {
         list($c, $d) = explode(':', $b);
         $array[$c] = $d;
     }
     if (!empty($array)) {
         $collectionModel = $this->model('collection');
         $result = $collectionModel->find($pid, $array);
         return json_encode(array('code' => 1, 'result' => 'ok', 'body' => $result));
     }
     return json_encode(array('code' => 0, 'result' => 'failed'));
 }
예제 #7
0
 /**
  * 移除商品的额外属性
  * @return string
  */
 function remove()
 {
     $id = filter::int($this->post->id);
     if (!empty($id)) {
         $prototypeModel = $this->model('prototype');
         $prototype = $prototypeModel->get($id);
         if ($prototypeModel->remove($id)) {
             if ($prototype['type'] == 'radio') {
                 $collectionModel = $this->model('collection');
                 $collectionModel->remove($prototype['pid']);
             }
             return json_encode(array('code' => 1, 'result' => 'ok'));
         }
         return json_encode(array('code' => 0, 'result' => '删除失败'));
     }
     return json_encode(array('code' => 2, 'result' => '参数错误'));
 }
예제 #8
0
파일: sale.php 프로젝트: jin123456bat/home
 /**
  * 把商品从限时折扣中移除
  */
 function remove()
 {
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'sale', roleModel::POWER_DELETE)) {
         $id = filter::int($this->get->id);
         if (!empty($id)) {
             $saleModel = $this->model('sale');
             $sale = $saleModel->get($id);
             if (isset($sale['pid'])) {
                 $saleModel->remove($id);
                 $productModel = $this->model('product');
                 $productModel->setActivity($sale['pid']);
             }
         }
     }
     $this->response->setCode(302);
     $this->response->addHeader('Location', $this->http->url('sale', 'admin'));
 }
예제 #9
0
 /**
  * 获得满减规则信息
  */
 function information()
 {
     $this->response->addHeader('Cache-Control', 'nocache');
     $id = filter::int($this->get->id);
     if (!empty($id)) {
         $fullcutModel = $this->model('fullcut');
         $fullcut = $fullcutModel->get($id);
         return json_encode(array('code' => 1, 'result' => 'ok', 'body' => $fullcut));
     }
     return json_encode(array('code' => 0, 'result' => '参数错误'));
 }
예제 #10
0
 /**
  * 复制或者剪切的ajax请求
  * @return string
  */
 function paste()
 {
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'category', roleModel::POWER_UPDATE)) {
         $id = json_decode($this->post->id);
         $mode = $this->post->mode;
         $parent = $this->post->parent == '#' ? 0 : filter::int($this->post->parent);
         if (empty($id) || empty($mode) || empty($parent)) {
             return json_encode(array('code' => 0, 'result' => '参数错误'));
         }
         $categoryModel = $this->model('category');
         if ($categoryModel->paste($id, $mode, $parent)) {
             return new json(json::OK);
         }
         return new json(json::PARAMETER_ERROR, '失败了');
     }
     return new json(json::NOT_LOGIN);
 }
예제 #11
0
 /**
  * 用户删除配送地址
  * @return string
  */
 function remove()
 {
     $id = filter::int($this->post->id);
     if (!empty($id)) {
         $addressModel = $this->model('address');
         if ($addressModel->remove($id)) {
             return new json(json::OK);
         }
         return new json(4, '删除失败');
     }
     return new json(json::PARAMETER_ERROR);
 }
예제 #12
0
 /**
  * 关闭退款申请
  */
 function remove()
 {
     //订单id
     $id = filter::int($this->post->id);
     if (login::user()) {
         $refundModel = $this->model('refund');
         if ($refundModel->close($id)) {
             return json_encode(array('code' => 1, 'result' => 'ok'));
         }
         return json_encode(array('code' => 0, 'result' => '取消失败'));
     }
     return json_encode(array('code' => 2, 'result' => '尚未登陆'));
 }
예제 #13
0
파일: order.php 프로젝트: jin123456bat/home
 /**
  * 获取指定用户的订单信息
  */
 function user()
 {
     $roleModel = $this->model('role');
     if ($roleModel->checkPower($this->session->role, 'orderlist', roleModel::POWER_SELECT)) {
         $this->response->addHeader('Content-Type', 'application/json');
         $uid = filter::int($this->get->uid);
         if (!empty($uid)) {
             $orderModel = $this->model('orderlist');
             $result = $orderModel->fetchAll($uid);
             foreach ($result as &$order) {
                 $order['orderdetail'] = $orderModel->getOrderDetail($order['id']);
             }
             return json_encode(array('code' => 1, 'result' => 'ok', 'body' => $result));
         }
         return json_encode(array('code' => 0, 'result' => 'no user'));
     }
     return json_encode(array('code' => 3, 'result' => '没有权限'));
 }
예제 #14
0
파일: theme.php 프로젝트: jin123456bat/home
 /**
  * 移除主题下面的商品
  */
 function reproduct()
 {
     $this->response->addHeader('Content-Type', 'application/json');
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'theme', roleModel::POWER_UPDATE)) {
         $tid = filter::int($this->post->tid);
         $pid = filter::int($this->post->pid);
         $themeModel = $this->model('theme');
         if ($themeModel->removeProduct($tid, $pid)) {
             return json_encode(array('code' => 1, 'result' => 'ok'));
         }
         return json_encode(array('code' => 0, 'result' => 'failed'));
     } else {
         return json_encode(array('code' => 2, 'result' => '权限不足'));
     }
 }
예제 #15
0
파일: user.php 프로젝트: jin123456bat/home
 /**
  * 根据用户名或手机号前3位搜索匹配的用户
  */
 function search()
 {
     $search = $this->get->telephone_or_username;
     $length = filter::int($this->get->length);
     $userModel = $this->model('user');
     $user = $userModel->search($search, $length);
     foreach ($user as &$userinfo) {
         $userinfo['gravatar'] = file::realpathToUrl($userinfo['gravatar']);
     }
     return json_encode($user);
 }
예제 #16
0
 /**
  * 移除设定中的国旗
  * @return string
  */
 function removeflag()
 {
     $this->response->addHeader('Content-Type', 'application/json');
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'system', roleModel::POWER_UPDATE)) {
         $id = filter::int($this->post->id);
         if (empty($id)) {
             return json_encode(array('code' => 3, 'result' => '参数错误'));
         }
         $flagModel = $this->model('flag');
         if ($flagModel->remove($id)) {
             return json_encode(array('code' => 1, 'result' => 'ok'));
         }
     }
     return json_encode(array('code' => 2, 'result' => '权限不足'));
 }
예제 #17
0
파일: o2o.php 프로젝트: jin123456bat/home
 /**
  * 管理员添加o2o账户
  * @param post uid 不得为空
  */
 function create()
 {
     $this->response->addHeader('Content-Type', 'application/json');
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'o2ouser', roleModel::POWER_INSERT)) {
         $uid = filter::int($this->post->uid);
         $rate = filter::number($this->post->rate);
         $name = $this->post->name;
         $address = $this->post->address;
         $qq = $this->post->qq;
         if (empty($name) || empty($address) || empty($qq) || empty($rate)) {
             return json_encode(array('code' => 2, 'result' => '数据不全'));
         }
         $o2oModel = $this->model('o2ouser');
         if ($o2oModel->create($uid, $name, $qq, $address, $rate)) {
             return json_encode(array('code' => 1, 'result' => 'ok'));
         }
         return json_encode(array('code' => '3', 'result' => '添加失败'));
     } else {
         return json_encode(array('code' => 0, 'result' => '没有权限'));
     }
 }
예제 #18
0
파일: cart.php 프로젝트: jin123456bat/home
 /**
  * 将购物车中的物品生成订单
  */
 function order()
 {
     $this->response->addHeader('Content-Type', 'application/json');
     if (!login::user()) {
         return json_encode(array('code' => 3, 'result' => '尚未登陆'));
     }
     $preorder = $this->post->preorder;
     //优惠前的价格
     //订单货款
     $ordergoodsamount = 0;
     //购物车中的商品
     $cartModel = $this->model('cart');
     $uid = $this->session->id;
     $cart = $cartModel->getByUid($uid);
     //订单详情
     $orderdetail = array();
     $collectionModel = $this->model('collection');
     $prototypeModel = $this->model('prototype');
     //优惠金额
     $discount = 0;
     $couponModel = $this->model('coupon');
     //要使用的优惠卷信息
     $coupon = empty($this->post->coupon) ? '' : $this->post->coupon;
     //存储满减商品
     $fullcut_temp = array();
     //存储没有参加活动商品信息
     $coupon_temp = array();
     foreach ($cart as $product) {
         $pricestocksku = $collectionModel->find($product['pid'], unserialize($product['content']));
         $prototype = $prototypeModel->getByPid($product['pid']);
         $prototype = (new prototype())->format($prototype, $product['content']);
         if (!empty($pricestocksku)) {
             $product['price'] = $pricestocksku['price'];
             $product['sku'] = $pricestocksku['sku'];
         }
         $t_orderdetail = array('sku' => $product['sku'], 'pid' => $product['pid'], 'productname' => $product['name'], 'brand' => $this->model('brand')->get($product['bid'], 'name'), 'unitprice' => $product['price'], 'content' => $product['content'], 'prototype' => $prototype, 'origin' => $product['origin'], 'score' => $product['score'], 'num' => $product['num']);
         //商品详情加入到数组
         $orderdetail[] = $t_orderdetail;
         switch ($product['activity']) {
             case 'seckill':
                 $seckillModel = $this->model('seckill');
                 $price = $seckillModel->getPrice($product['pid']);
                 if ($price !== NULL) {
                     $discount += ($product['price'] - $price) * $product['num'];
                     $ordergoodsamount += $price * $product['num'];
                 } else {
                     $ordergoodsamount += $product['price'] * $product['num'];
                 }
                 break;
             case 'sale':
                 $saleModel = $this->model('sale');
                 $price = $saleModel->getPrice($product['pid']);
                 if ($price !== NULL) {
                     $discount += ($product['price'] - $price) * $product['num'];
                     $ordergoodsamount += $price * $product['num'];
                 } else {
                     $ordergoodsamount += $product['price'] * $product['num'];
                 }
                 break;
             case 'fullcut':
                 //取出所有满减规则的商品
                 $fullcut_temp[] = $product;
                 break;
             default:
                 $coupon_temp[] = $product;
         }
     }
     //单独计算不同的满减规则
     $fullcutHelper = new fullcut($this->model('fullcutdetail'), $fullcut_temp);
     //最终价格
     $ordergoodsamount += $fullcutHelper->getPrice();
     //免去价格
     $discount += $fullcutHelper->getMinus();
     //计算优惠
     $couponHelper = new coupon($coupon, $uid, $this->model('coupon'), $coupon_temp);
     $ordergoodsamount += $couponHelper->getPrice();
     $discount += $couponHelper->getMinus();
     //是否减少优惠券使用次数
     if ($couponHelper->getMinus() > 0 && !$preorder) {
         $couponModel->increaseTimes($coupon, -1);
     }
     //支付方式
     $paytype = $this->post->paytype;
     if (empty($paytype)) {
         return json_encode(array('code' => 4, 'result' => '没有支付方式'));
     }
     //支付单号
     $paynumber = '';
     //运费  根据订单金额计算运费
     $shipid = filter::int($this->post->shipid);
     if (empty($shipid)) {
         return json_encode(array('code' => 5, 'result' => '错误的配送方案'));
     }
     $shipModel = $this->model('ship');
     $ship = $shipModel->get($shipid);
     if (empty($ship)) {
         return json_encode(array('code' => 5, 'result' => '错误的配送方案'));
     }
     $feeamount = $shipModel->getPrice($shipid, $ordergoodsamount);
     //订单编号
     $orderno = (new order())->swift($this->session->id);
     //订单税款 免税
     $ordertaxamount = 0;
     //订单生成时间
     $createtime = $_SERVER['REQUEST_TIME'];
     //交易时间
     $tradetime = 0;
     //订单总金额
     $ordertotalamount = $feeamount + $ordertaxamount + $ordergoodsamount;
     //成交总价  已经支付的价格
     $totalamount = 0;
     //收件人
     $addressid = filter::int($this->post->addressid);
     $address_parameter = 'city.name as city,province.name as province,address.county,address.address,address.zcode,address.name,address.telephone';
     $address = $this->model('address')->get($addressid, $address_parameter);
     if (empty($address)) {
         if (empty($preorder)) {
             return json_encode(array('code' => 6, 'result' => '错误的配送地址'));
         } else {
             $address = array('name' => '', 'telephone' => '', 'address' => '', 'province' => '', 'city' => '', 'county' => '', 'zcode' => '');
         }
     }
     $consignee = $address['name'];
     $consigneetel = $address['telephone'];
     $consigneeaddress = $address['address'];
     $consigneeprovince = $address['province'];
     $consigneecity = $address['city'];
     $consigneecounty = $address['county'];
     $zipcode = $address['zcode'];
     //物流方式
     $postmode = $ship['code'];
     //运单号
     $waybills = '';
     //发件人
     $sendername = $this->model('system')->get('sendername', 'system');
     //公司名称
     $companyname = $this->model('system')->get('companyname', 'system');
     //备注信息
     $note = '';
     //订单状态
     $status = 0;
     //订单来源
     $client = $this->post->client;
     /**
      * 财付通专用,标注是否已经报过报过接口  1没有 2已经报过
      */
     $action_type = '1';
     $money = 0;
     //余额支付
     /* $extra_money = $this->model('user')->get($uid,'money');
     		if ($extra_money >= $ordertotalamount)
     		{
     			//余额足够支付订单
     			$extra_money -= $ordertotalamount;
     			$ordertotalamount = 0;
     			$money = $ordertotalamount;
     			$status = 1;
     		}
     		else
     		{
     			$ordertotalamount -= $extra_money;
     			$money = $extra_money;
     		}
     		
     		if (!$preorder)
     		{
     			//更改用户余额
     			$this->model('user')->money($uid,-$money);
     		} */
     $data = array(NULL, $uid, $paytype, $paynumber, $ordertotalamount, $money, $orderno, $ordertaxamount, $ordergoodsamount, $feeamount, $tradetime, $createtime, $totalamount, $consignee, $consigneetel, $consigneeaddress, $consigneeprovince, $consigneecity, $consigneecounty, $postmode, $waybills, $sendername, $companyname, $zipcode, $note, $status, $discount, $client, $action_type);
     if ($preorder) {
         $order = array('id' => NULL, 'uid' => $uid, 'paytype' => $paytype, 'paynumber' => $paynumber, 'ordertotalamount' => $ordertotalamount, 'money' => $money, 'orderno' => $orderno, 'ordertaxamount' => $ordertaxamount, 'ordergoodsamount' => $ordergoodsamount, 'feeamount' => $feeamount, 'tradetime' => $tradetime, 'createtime' => $createtime, 'totalamount' => $totalamount, 'consignee' => $consignee, 'consigneetel' => $consigneetel, 'consigneeaddress' => $consigneeaddress, 'consigneeprovince' => $consigneeprovince, 'consigneecity' => $consigneecity, 'consigneecounty' => $consigneecounty, 'postmode' => $postmode, 'waybills' => $waybills, 'sendername' => $sendername, 'companyname' => $companyname, 'zipcode' => $zipcode, 'note' => $note, 'status' => $status, 'discount' => $discount, 'client' => $client, 'action_type' => $action_type);
         $order['orderdetail'] = $orderdetail;
         return json_encode(array('code' => 1, 'result' => 'ok', 'body' => $order));
     } else {
         $orderModel = $this->model('orderlist');
         $oid = $orderModel->create($data, $orderdetail);
         if ($oid) {
             $cartModel->clear($uid);
             //用户订单数量+1
             $this->model('user')->where('id=?', array($uid))->increase('ordernum', 1);
             //商品订单数量+1
             foreach ($orderdetail as $ordergoods) {
                 $this->model('product')->where('id=?', array($ordergoods['pid']))->increase('ordernum', 1);
             }
             $order = $orderModel->get($oid);
             $order['orderdetail'] = $orderModel->getOrderDetail($oid);
             return json_encode(array('code' => 1, 'result' => 'ok', 'body' => $order));
         }
         return json_encode(array('code' => 2, 'result' => '创建订单失败'));
     }
 }
예제 #19
0
 /**
  * 删除评论
  */
 function del()
 {
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'comment', roleModel::POWER_DELETE)) {
         $id = filter::int($this->post->id);
         if (!empty($id)) {
             $commentModel = $this->model('comment');
             if ($commentModel->remove($id)) {
                 //删除磁盘图片
                 $comment_picModel = $this->model('comment_pic');
                 $comment_pic = $comment_picModel->getByCid($id, 'path');
                 foreach ($comment_pic as $pic) {
                     filesystem::unlink($pic);
                 }
                 $this->model('log')->write($this->session->username, '删除了一条评论');
                 //删除图片记录
                 $comment_picModel->removeByCid($id);
                 return json_encode(array('code' => 1, 'result' => 'ok'));
             }
             return json_encode(array('code' => 0, 'result' => 'failed'));
         }
         return json_encode(array('code' => 2, 'result' => '参数错误'));
     }
     return json_encode(array('code' => 3, 'result' => '没有权限'));
 }
예제 #20
0
 /**
  * 创建秒杀活动
  */
 function create()
 {
     $this->response->addHeader('Content-Type', 'application/json');
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'seckill', roleModel::POWER_INSERT)) {
         $sname = $this->post->sname;
         $pid = filter::int($this->post->pid);
         $starttime = $this->post->starttime;
         $endtime = $this->post->endtime;
         $price = filter::number($this->post->price);
         $orderby = filter::int($this->post->orderby);
         $logo = $this->post->logo;
         if (!empty($pid)) {
             $productModel = $this->model('product');
             $product = $productModel->get($pid);
             if (empty($product) || !empty($product['activity'])) {
                 switch ($product['activity']) {
                     case 'sale':
                         $result = '限时优惠';
                         break;
                     case 'seckill':
                         $result = '秒杀';
                         break;
                     case 'fullcut':
                         $result = '满减';
                         break;
                 }
                 return json_encode(array('code' => 4, 'result' => '商品已经参加了' . $result . ',请先移除原活动在来添加'));
             }
             $seckillModel = $this->model('seckill');
             if ($seckillModel->create($sname, $pid, $starttime, $endtime, $price, $orderby, $logo)) {
                 $productModel->setActivity($pid, 'seckill');
                 return json_encode(array('code' => 1, 'result' => '推送成功'));
             } else {
                 return json_encode(array('code' => 2, 'result' => '推送失败'));
             }
         }
         return json_encode(array('code' => 0, 'result' => '参数错误'));
     }
     return json_encode(array('code' => 3, 'result' => '权限不足'));
 }
예제 #21
0
 /**
  * 获得某一个分类下所有商品信息  包括子分类
  */
 function category()
 {
     $this->response->addHeader('Content-Type', 'application/json');
     $cid = empty(filter::int($this->get->cid)) ? 0 : filter::int($this->get->cid);
     $start = empty(filter::int($this->get->start)) ? 0 : filter::int($this->get->start);
     $length = empty(filter::int($this->get->length)) ? 5 : filter::int($this->get->length);
     $array = array($cid);
     //获得子分类信息
     $categoryModel = $this->model('category');
     while (current($array) !== false) {
         $result = $categoryModel->fetchChild(current($array));
         foreach ($result as $category) {
             if (!in_array($category['id'], $array)) {
                 //将子分类id加入数组
                 $array[] = $category['id'];
             }
         }
         next($array);
     }
     $productModel = $this->model('product');
     $brandModel = $this->model('brand');
     $prototypeModel = $this->model('prototype');
     $productimgModel = $this->model('productimg');
     $filter = array('start' => $start, 'length' => $length, 'status' => 1, 'stock' => 0, 'category' => $array, 'time' => $_SERVER['REQUEST_TIME']);
     $product = $productModel->fetchAll($filter);
     foreach ($product as &$goods) {
         $goods['category'] = $categoryModel->get($goods['category'], 'name');
         $goods['brand'] = $brandModel->get($goods['bid'], 'name');
         unset($product['bid']);
         $goods['prototype'] = $prototypeModel->getByPid($goods['id']);
         $goods['img'] = $productimgModel->getByPid($goods['id']);
         switch ($goods['activity']) {
             case 'sale':
                 $goods['activity_description'] = $this->model('sale')->getByPid($goods['id']);
                 break;
             case 'seckill':
                 $goods['activity_description'] = $this->model('seckill')->getByPid($goods['id']);
                 break;
             case 'fullcut':
                 $goods['activity_description'] = $this->model('fullcutdetail')->getByPid($goods['id']);
                 break;
             default:
                 break;
         }
         $goods['favourite'] = $this->model('favourite')->checkProduct($this->session->id, $goods['id']);
         $goods['origin'] = $this->model('flag')->getOrigin($goods['origin']);
     }
     return json_encode(array('code' => 1, 'result' => 'ok', 'body' => $product));
 }
예제 #22
0
 /**
  * 移除滚动图
  */
 function remove()
 {
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'carousel', roleModel::POWER_DELETE)) {
         $id = filter::int($this->post->id);
         $carouselModel = $this->model('carousel');
         if ($carouselModel->remove($id)) {
             return new json(json::OK);
         }
         return new json(json::PARAMETER_ERROR, '删除失败');
     } else {
         return new json(json::NO_POWER);
     }
 }
예제 #23
0
파일: admin.php 프로젝트: jin123456bat/home
 /**
  * 添加管理员 接口
  */
 function register()
 {
     if (!login::admin()) {
         return new json(json::NOT_LOGIN);
     }
     $roleModel = $this->model('role');
     if ($roleModel->checkPower($this->session->role, 'admin', roleModel::POWER_INSERT)) {
         $username = filter::string($this->post->username, 16);
         $password = filter::string($this->post->password, 16);
         $adminModel = $this->model('admin');
         if ($adminModel->register($username, $password)) {
             $this->model('log')->write($this->session->username, '添加了一个管理员账号' . $username);
             return new json(json::OK);
         }
         return new json(4, '用户名已经存在');
     }
     return new json(json::NO_POWER);
 }
예제 #24
0
파일: brand.php 프로젝트: jin123456bat/home
 /**
  * 品牌管理页面
  */
 function manager()
 {
     $roleModel = $this->model('role');
     $start = empty(filter::int($this->get->start)) ? 0 : filter::int($this->get->start);
     $length = empty(filter::int($this->get->length)) ? 10 : filter::int($this->get->length);
     if (login::admin() && $roleModel->checkPower($this->session->role, 'brand', roleModel::POWER_SELECT)) {
         $this->view = new view(config('view'), 'admin/brand_manager.html');
         $this->view->assign('role', $roleModel->get($this->session->role));
         $systemModel = $this->model('system');
         $system = $systemModel->fetch('system');
         $system = $systemModel->toArray($system, 'system');
         $this->view->assign('system', $system);
         $brandModel = $this->model('brand');
         $result = $brandModel->fetchByProduct($start, $length);
         $this->view->assign('brand', $result);
         $this->response->setBody($this->view->display());
     } else {
         $this->http->jump($this->http->url('index', '__404'));
     }
 }
예제 #25
0
 /**
  * 更改全球热销的排序
  */
 function orderby()
 {
     $this->response->addHeader('Content-Type', 'application/json');
     $orderby = $this->post->orderby;
     $pid = filter::int($this->post->pid);
     $hotorderModel = $this->model('hotorder');
     if ($hotorderModel->order($pid, $orderby)) {
         return json_encode(array('code' => 1, 'result' => 'ok'));
     }
     return json_encode(array('code' => 0, 'result' => 'failed'));
 }
예제 #26
0
 /**
  * 删除优惠券
  * @return string
  */
 function remove()
 {
     $this->response->addHeader('Content-Type', 'appication/json');
     $roleModel = $this->model('role');
     if (login::admin() && $roleModel->checkPower($this->session->role, 'coupon', roleModel::POWER_DELETE)) {
         $id = filter::int($this->post->id);
         if (!empty($id)) {
             $couponModel = $this->model('coupon');
             if ($couponModel->remove($id)) {
                 return json_encode(array('code' => 1, 'result' => '删除成功'));
             }
             return json_encode(array('code' => 3, 'result' => '删除失败'));
         }
         return json_encode(array('code' => 0, 'result' => '参数错误'));
     }
     return json_encode(array('code' => 2, 'result' => '没有权限'));
 }
예제 #27
0
 /**
  * 映射
  * @param unknown $name
  * @param unknown $args
  */
 function __call($name, $args)
 {
     if (!empty($args)) {
         return $this->call('index', '__404');
     }
     if ($name != 'login') {
         if (!login::o2o()) {
             $this->response->setCode(302);
             $this->response->addHeader('Location', $this->http->url('o2ocenter', 'login'));
             return false;
         }
     }
     $action = array('index', 'search', 'profile');
     $template = $this->_template_dir . $name . '.html';
     $http = http::getInstance();
     $base_template = ROOT . '/application/template/' . $template;
     if (file_exists($base_template)) {
         $this->view = new view($this->_config, $template);
         if (in_array($name, $action)) {
             //加载系统配置
             $systemModel = $this->model('system');
             $system = $systemModel->fetch(array('system'));
             $temp = array();
             foreach ($system as $key => $value) {
                 $temp[$value['name'] . '_' . $value['type']] = $value['value'];
             }
             $this->view->assign('system', $temp);
             //载入用户的o2o配置
             $o2oModel = $this->model('o2ouser');
             $o2o = $o2oModel->get($this->session->id);
             if (empty($o2o)) {
                 return $this->call('index', '__404');
             }
             //载入用户的基本信息
             $userModel = $this->model('user');
             $user = $userModel->get($this->session->id);
             $this->view->assign('user', $user);
             switch ($name) {
                 case 'search':
                     $start = empty(filter::int($this->get->start)) ? 0 : filter::int($this->get->start);
                     $length = empty(filter::int($this->get->length)) ? 10 : filter::int($this->get->length);
                     $this->view->assign('start', $start);
                     $this->view->assign('length', $length);
                     $query = str_replace(' ', '%', str_replace('  ', ' ', $this->get->query));
                     $userModel = $this->model('user');
                     $userModel->where('user.oid=?', array($this->session->id));
                     if (!empty($query)) {
                         $userModel->where('(username like ? or telephone like ? or email like ?)', array('%' . $query . '%', '%' . $query . '%', '%' . $query . '%'));
                     }
                     $userModel->limit($start, $length);
                     $search = $userModel->select();
                     $this->view->assign('search', $search);
                     break;
                 default:
             }
             $this->view->assign('o2o', $o2o);
         }
         return $this->view->display();
     } else {
         return $this->call('index', '__404');
     }
 }