예제 #1
0
파일: goods.php 프로젝트: elmoy/wenheyou
 public static function get_stores()
 {
     $result = array();
     $sql = 'select s.store_name, s.store_id from vs_mall_goods as g join vs_card_store as s on g.store_id = s.store_id group by g.store_id';
     $rows = \DB\Mall\Goods::database()->fetch($sql);
     foreach ($rows as $row) {
         $result[$row->store_id] = $row->store_name;
     }
     return $result;
 }
예제 #2
0
파일: trade.php 프로젝트: elmoy/wenheyou
 /**
  * 提交订单
  */
 public function confirm()
 {
     //\Core\View::$title = '确认订单';
     $this->user = \Model\Authorize\Oauth::login_user();
     $v = new \Model\Validation();
     $v->required($this->user)->message('用户未登录', 1000);
     if (!$v->has_error()) {
         $address_id = \Core\URI::kv('address_id');
         $pay_type = \Core\URI::kv('pay_type', 0);
         $pick_time = \Core\URI::kv('pick_time');
         $order_remark = \Core\URI::kv('order_remark');
         if (empty($pick_time)) {
             $pick_time = W_START_TIME;
         } else {
             $pick_time = strtotime($pick_time);
         }
         $goods_id = \Core\URI::kv('id');
         $nums = \Core\URI::kv('nums');
         $nums = abs(intval($nums));
         if (!empty($goods_id)) {
             $cart = array();
             $goods = \DB\Mall\Goods::row(array('goods_id' => $goods_id));
             $v->required($goods)->message('商品不存在', 1000);
             $v->min_val($nums, 1)->message('数量不能小于1', 1000);
             if (!$v->has_error()) {
                 $row = new \Db\Trade\Cart();
                 $row->user_id = $this->user->user_id;
                 $row->goods_id = $goods->goods_id;
                 $row->goods_nums = $nums;
                 $row->goods_discount_price = $goods->goods_discount_price;
                 $row->goods_original_price = $goods->goods_original_price;
                 $row->cart_status = 1;
                 $row->create_time = W_START_TIME;
                 $row->goods = $goods;
                 $cart[] = $row;
                 //dump($cart);exit();
             }
         } else {
             $cart = \Db\Trade\Cart::fetch(array('user_id' => $this->user->user_id, 'cart_status' => 1));
             foreach ($cart as $c) {
                 $c->goods->load();
             }
             $v->filter_var(!empty($cart))->message('购物车为空', 1000);
         }
         $address = \DB\Account\Address::row(array('user_id' => $this->user->user_id, 'address_id' => $address_id));
         $v->filter_var(!empty($address))->message('配送地址不存在', 1000);
         if (!$v->has_error()) {
             $order = new \Db\Trade\Order();
             $order_id = $order->create_from_cart($cart, $pay_type, $pick_time, $address->user_name, $address->user_mobile, $address->address_province, $address->address_city, $address->address_area, $address->address_street, $order_remark);
             $v->set_data($order_id);
         }
     }
     $v->send();
 }
예제 #3
0
파일: goods.php 프로젝트: elmoy/wenheyou
 /**
  * 列表
  */
 public function index()
 {
     \Core\View::css('/manage/tablescroll/css/style.css');
     \Core\View::script('/manage/tablescroll/js/jquery.tablescroll.js');
     $this->view->content = view('goods/index.php');
     $rows = \DB\Mall\Goods::fetch(null, 0, 0, array('goods_order' => 'desc'));
     $data = array();
     foreach ($rows as $row) {
         $data[$row->store_id][] = $row;
     }
     $this->view->content->data = $data;
     //dump($data);exit();
 }
예제 #4
0
파일: cart.php 프로젝트: elmoy/wenheyou
 /**
  * 保存
  */
 public function save()
 {
     $goods_id = \Core\URI::kv('id');
     $goods_nums = \Core\URI::kv('nums', 1);
     $cart_status = \Core\URI::kv('status', 1);
     $v = new \Model\Validation();
     $v->required($goods_id)->message('商品编号不能为空', 1000);
     $goods_nums = abs(intval($goods_nums));
     $v->filter_var($goods_nums > 0)->message('商品数量不能小于1', 1000);
     if (!$v->has_error()) {
         $goods = \DB\Mall\Goods::row(array('goods_id' => $goods_id, 'goods_status' => 1));
         $v->required($goods)->message('商品不存在', 1000);
         if (!$v->has_error()) {
             $model = \DB\Trade\Cart::row(array('user_id' => $this->user->user_id, 'goods_id' => $goods_id));
             if ($model) {
                 $model->goods_nums = $goods_nums;
                 $model->goods_discount_price = $goods->goods_discount_price;
                 $model->goods_original_price = $goods->goods_original_price;
                 $model->create_time = W_START_TIME;
                 $model->cart_status = $cart_status;
                 $model->update();
             } else {
                 $model = new \Db\Trade\Cart();
                 $model->user_id = $this->user->user_id;
                 $model->create_time = W_START_TIME;
                 $model->goods_id = $goods_id;
                 $model->goods_discount_price = $goods->goods_discount_price;
                 $model->goods_original_price = $goods->goods_original_price;
                 $model->goods_nums = $goods_nums;
                 $model->cart_status = $cart_status;
                 $model->insert();
             }
             $v->set_data(\Db\Trade\Cart::count_cart($this->user->user_id));
         }
     }
     $v->send();
 }
예제 #5
0
파일: goods.php 프로젝트: elmoy/wenheyou
 /**
  * 更改商品状态
  */
 public function status()
 {
     $ids = \Core\URI::kv('ids');
     $status = \Core\URI::kv('status', 0);
     $v = new \Core\Validation();
     $v->required($ids)->message('参数不合法');
     if (!$v->has_error()) {
         $id_arr = explode('-', $ids);
         foreach ($id_arr as $id) {
             $item = \Db\Mall\Goods::row(array('goods_id' => $id));
             if (!empty($item)) {
                 $item->goods_status = $status;
                 $item->update();
             }
         }
     }
     echo json_encode($v->get_error());
     exit;
 }
예제 #6
0
파일: main.php 프로젝트: elmoy/wenheyou
 public function tab3_part()
 {
     $limit = 5;
     $page = \Core\URI::kv('page', 1);
     $start = ($page - 1) * $limit;
     $rows = \DB\Mall\Goods::fetch(array('goods_status' => 1, 'category_id' => 3), $limit, $start, array('goods_order' => 'desc'));
     $v = new \Model\Validation();
     if (!empty($rows)) {
         $view = view('main/tab3_part.php');
         $view->rows = $rows;
         $view->user = $this->user;
         $rs = $view->__toString();
         $v->set_data($rs);
     } else {
         $v->required(false)->message('没有更多了...');
     }
     $v->send();
 }