Esempio n. 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->info('Start to create a shop, please wait...');
     $shop = Shop::where('seller_id', 1)->first();
     if (count($shop) > 0) {
         $this->info('A shop exist, seller_id = 1');
         return;
     }
     $seller = Seller::find(1);
     $shopService = new ShopService();
     $shopService->createShop($seller, 1, 1, '测试小店', '测试小店', 'test', 'http://mmbiz.qpic.cn/mmbiz/4atXZMyxUkdTkThhj8icicfHpd07oaflgJpwwLficHRaLZQzYU8C7A3gWpua4dogmUefNln5K4ChSU9LeCanib6vEw/0?wx_fmt=png');
     $this->info('Finished');
     return;
 }
 /**
  * @param $shortId
  * @return string
  * @author zhengqian@dajiayao.cc
  */
 public function index($shortId)
 {
     if (!$shortId) {
         return "shop id is required";
     }
     $shop = Shop::where("short_id", $shortId)->first();
     if (!$shop) {
         return "shop is not found";
     }
     try {
         $jsFileHash = ['vendor' => hash_file('md2', public_path('assets/scripts/vendor.js')), 'shop' => hash_file('md2', public_path('assets/scripts/shop.js')), 'shop_css' => hash_file('md2', public_path('assets/stylesheets/shop.css')), 'app' => hash_file('md2', public_path('assets/stylesheets/app.css'))];
     } catch (\Exception $e) {
         $jsFileHash = [];
     }
     return view('shop.index')->with('shop_short_id', $shortId)->with('hash_file', $jsFileHash);
 }
Esempio n. 3
0
 /**
  * 获取4位店铺短网址
  * 生成一个 $l 位的36进制随机字符串,其第一位字符不为数字
  * @author Hanxiang
  * @param $l
  * @return string
  */
 public function getShortId($l = 4)
 {
     $c = 'abcdefghijklmnopqrstuvwxyz1234567890';
     $letters = 'abcdefghijklmnopqrstuvwxyz';
     for ($s = '', $cl = strlen($c) - 1, $i = 0; $i < $l; $s .= $c[mt_rand(0, $cl)], ++$i) {
     }
     $s[0] = is_numeric($s[0]) ? $letters[mt_rand(0, strlen($letters) - 1)] : $s[0];
     $shop = Shop::where('short_id', $s)->first();
     if (count($shop) > 0) {
         return $this->getShortId();
     }
     return $s;
 }
Esempio n. 4
0
 /**
  * 店铺详情
  * @param $id
  * @return string
  * @author zhengqian@dajiayao.cc
  */
 public function detail($short_id)
 {
     if (!$short_id) {
         return RestHelp::parametersIllegal("shop id is requird");
     }
     $objShop = Shop::where('short_id', $short_id)->first();
     if (!$objShop) {
         return RestHelp::encodeResult(21000, "shop is not found in db");
     }
     $buyerId = $this->buyerId;
     $favShop = FavoriteShop::where("shop_id", $objShop->id)->where("buyer_id", $buyerId)->first();
     $favorite = $favShop ? 1 : 0;
     $seller = $objShop->seller;
     $arrSeller = array();
     $arrSeller['id'] = $seller->id;
     $arrSeller['name'] = $seller->wxUser ? $seller->wxUser->nickname : $seller->realname;
     $arrSeller['mobile'] = $seller->mobile;
     $banner = "";
     $arrShop = array();
     $arrShop['shortId'] = $objShop->short_id;
     $arrShop['name'] = $objShop->subtitle;
     $arrShop['banner'] = $banner;
     $arrShop['ad'] = "/1.png";
     $arrShop['avatar'] = $objShop->thumbnail;
     $arrShop['type'] = $objShop->type;
     $arrShop['banner'] = $objShop->banner ? ImageUtil::getRuleImgSize($objShop->banner, 750, 246) : '';
     $arrShop['region']['provinceId'] = $objShop->province_id;
     $arrShop['region']['cityId'] = $objShop->city_id;
     $arrShop['region']['countyId'] = $objShop->county_id;
     $items = array_values($objShop->getItemsOnShelf());
     $arrItem = array();
     foreach ($items as $k => $item) {
         $arrItem[$k]['id'] = $item->id;
         $arrItem[$k]['title'] = $item->title;
         $arrItem[$k]['name'] = $item->name;
         $objImage = $item->image->first();
         $imagUrl = $objImage ? ImageUtil::getRuleImgSize($objImage->url, 260, 260) : "";
         $arrItem[$k]['image'] = $imagUrl;
         $arrItem[$k]['code'] = $item->code;
         $arrItem[$k]['supplier'] = $item->supplier->title;
         $arrItem[$k]['spec'] = $item->spec;
         $arrItem[$k]['weight'] = $item->weight;
         $arrItem[$k]['volume'] = $item->volume;
         $arrItem[$k]['price'] = $item->price;
         $arrItem[$k]['marketPrice'] = $item->market_price;
         //总计售出
         $sellsCount = $this->redis->get("dajiayao:mall:item:sellcount:" . $item->id);
         $arrItem[$k]['sales'] = $sellsCount ? (int) $sellsCount : 0;
         $arrItem[$k]['comment'] = $item->comment;
         //以前购买人数
         $arrRedisBuyers = $this->redis->smembers("dajiayao:mall:item:buyers:" . $item->id);
         $arrBuyers = array();
         foreach ($arrRedisBuyers as $b => $buyers) {
             if ($b < 4) {
                 //最多五个
                 array_push($arrBuyers, json_decode($buyers));
             }
         }
         $arrItem[$k]['buyers'] = $arrBuyers;
     }
     //TODO 支付方式
     $arrPayment = ['alipay'];
     //TODO 广告位,推广
     $arrPromotions = [["title" => "星巴克", "link" => "#", "image" => ImageUtil::getRuleImgSize("/shopimages/starbucks_promotion.jpg", 1176, 210)]];
     return RestHelp::success(['favorite' => $favorite, 'shop' => $arrShop, 'promotions' => $arrPromotions, 'owner' => $arrSeller, "availablePayments" => $arrPayment, 'items' => $arrItem, 'visitorCount' => rand(100000, 105000)]);
 }