Пример #1
0
 /**
  * 处理订单
  */
 protected function _handelOrder()
 {
     $mid = cookie($this->cookie_prefix . 'mid');
     $table_id = cookie($this->cookie_prefix . 'table_id');
     /*if(empty($table_id)) {
     			$this->ajaxError(['msg' => '桌号失效,请重新扫描二维码']);
     		}*/
     $shop_id = intval(DomainController::instance()->get('shop_id'));
     $order = ['mid' => $mid, 'table_id' => empty($table_id) ? 0 : $table_id, 'platform_id' => 0, 'shop_id' => $shop_id, 'pay_type' => 1, 'created_at' => NOW_TIME];
     $spec = I('post.spec');
     foreach ($spec as $s) {
         $gid[] = $s['gid'];
     }
     $sGoods = GoodsModel::instance()->selectGoodsByIds($shop_id, $gid);
     $goods = [];
     foreach ($sGoods as $g) {
         foreach ($spec as $s) {
             if ($g['id'] == $s['gid']) {
                 $number = $s['number'];
                 $remark = isset($s['remark']) ? $s['remark'] : '';
                 break;
             }
         }
         $goods[] = ['order_id' => null, 'goods_id' => $g['id'], 'price' => $g['price'], 'number' => $number, 'mark' => $remark];
         $order['native_price'] += $g['price'] * $number;
     }
     $order['price'] = $order['native_price'];
     $order['sn'] = $this->createSn();
     if (!$goods) {
         $this->ajaxError(['msg' => '购物车为空']);
     }
     return [$order, $goods];
 }
Пример #2
0
 public function _initialize()
 {
     $this->_shop_id = intval(DomainController::instance()->get('shop_id'));
     if (empty($this->_shop_id)) {
         E('获取店铺ID失败!');
     }
     $this->_member = Member::instance();
     $this->_member->setShopId($this->_shop_id);
     $this->_member->_init();
 }
Пример #3
0
 /**
  * 获取点击分类下的商品列表
  */
 public function get_category_goods()
 {
     $id = I('get.id');
     $goods = [];
     $this->_shop_id = intval(DomainController::instance()->get('shop_id'));
     if (!empty($id) && ctype_digit($id)) {
         $goods = GoodsModel::instance()->goodsCategoryGoods($id, $this->_shop_id);
     } else {
         $category = GoodsModel::instance()->getDefaultCategoryId($this->_shop_id);
         if (!empty($category)) {
             $goods = GoodsModel::instance()->goodsCategoryGoods($category['id'], $this->_shop_id);
         }
     }
     $this->ajaxSuccess($goods);
 }