Beispiel #1
0
 public function index()
 {
     //\Core\View::$title = '我的订单';
     $this->user = \Model\Authorize\Oauth::login_user();
     if (empty($this->user)) {
         redirect(\Core\URI::a2p(array('main' => 'home')));
     }
     $this->view->content = view('trade/index.php');
     $this->view->content->address = \DB\Account\Address::fetch(array('user_id' => $this->user->user_id));
     $goods_id = \Core\URI::kv('id');
     $nums = \Core\URI::kv('nums');
     $nums = abs(intval($nums));
     if (!empty($goods_id)) {
         $goods = \DB\Mall\Goods::row(array('goods_id' => $goods_id));
         if (empty($goods) || $nums < 1) {
             redirect(\Core\URI::a2p(array('main' => 'index')));
         } else {
             $this->view->content->count = array('total_fee' => $goods->goods_discount_price * $nums, 'total_nums' => $nums);
         }
     } else {
         $this->view->content->count = \Db\Trade\Cart::count_cart($this->user->user_id);
         if ($this->view->content->count['total_nums'] < 1) {
             redirect(\Core\URI::a2p(array('main' => 'index')));
         }
     }
 }
Beispiel #2
0
 /**
  * 删除商品
  */
 public function delete()
 {
     $ids = \Core\URI::kv('ids');
     $v = new \Model\Validation();
     $v->required($ids)->message('参数错误', 1000);
     if (!$v->has_error()) {
         $id_arr = explode('-', $ids);
         foreach ($id_arr as $id) {
             $model = \DB\Trade\Cart::row(array('user_id' => $this->user->user_id, 'goods_id' => $id));
             if ($model) {
                 $model->delete();
             }
         }
         $v->set_data(\Db\Trade\Cart::count_cart($this->user->user_id));
     }
     $v->send();
 }
Beispiel #3
0
 public function get()
 {
     $this->view->content = view('main/get.php');
     $id = \Core\URI::kv('id');
     $this->view->content->row = new \DB\Mall\Goods($id);
     $this->view->content->user_id = $this->user->user_id;
     $this->view->content->count = \Db\Trade\Cart::count_cart($this->user->user_id);
 }