Example #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;
 }
Example #2
0
 public function addPost()
 {
     $input = Input::all();
     $validator = Validator::make($input, ['mobile' => 'required', 'realname' => 'required']);
     if ($validator->fails()) {
         return redirect()->back()->with('error_tips', "参数错误: " . $validator->messages()->first());
     }
     $mobile = trim($input['mobile']);
     $realname = trim($input['realname']);
     $sellerByMobile = Seller::where('mobile', $mobile)->first();
     if (count($sellerByMobile) > 0) {
         return redirect()->back()->with('error_tips', "手机号已存在")->withInput();
     }
     // add weixin user
     //        $wxUser = new WxUser();
     //        $wxUser->subscribe = 1;
     //        $wxUser->openid = Uuid::v4(false); //TODO
     //        $wxUser->nickname = $input['nickname'];
     //        $wxUser->sex = 1;
     //        $wxUser->city = '苏州';
     //        $wxUser->country = '中国';
     //        $wxUser->province = '江苏';
     //        $wxUser->language = 'zh_CN';
     //        $wxUser->headimgurl = '';
     //        $wxUser->role = WxUser::ROLE_SELLER;
     //        $wxUser->status = 1;
     //        $wxUser->save();
     //        $wxUserId = $wxUser->id;
     // add seller
     $seller = new Seller();
     //$seller->wx_user_id = $wxUserId;
     $seller->mobile = $mobile;
     $seller->status = 1;
     $seller->parent_id = 0;
     $seller->realname = $realname;
     $seller->save();
     // add shop
     $shopService = new ShopService();
     $shopService->createShop($seller, Shop::TYPE_DIRECT, Shop::MODE_NORMAL, '丫摇小店', '丫摇小店', '', 'images/logo_160.png', '/images/banner_' . rand(1, 9) . '.jpg');
     return redirect()->route('sellers')->with('success_tips', "操作成功");
 }