Beispiel #1
0
 public function addItems($shopId)
 {
     $input = Input::only('item-code');
     $itemCode = $input['item-code'];
     $shop = $this->shopService->getShopById($shopId);
     if (!$shop) {
         abort(404);
     }
     $item = $this->itemService->getItemsByCode($itemCode);
     if (!$item or $item->shelf_status == Item::SHELF_STATUS_NO or $this->shopService->checkShopItemExist($shopId, $item->id)) {
         return redirect()->back()->with('error_tips', "增加失败");
     }
     if ($shop->is_direct_sale != Shop::IS_DIRECT_SALE_YES and $item->is_direct_sale == Item::IS_DIRECT_SALE_YES) {
         return redirect()->back()->with('error_tips', "增加失败:该商品为官方直营商品不允许上架。");
     }
     $shopItem = new ShopItem();
     $shopItem->shop_id = $shopId;
     $shopItem->item_id = $item->id;
     $shopItem->status = ShopItem::STATUS_YES;
     $shopItem->stock = 0;
     //TODO
     $shopItem->sort = 1;
     //TODO
     $shopItem->save();
     return redirect()->back()->with('success_tips', "增加成功");
 }