Esempio n. 1
0
 public function store(Request $request)
 {
     $user = \Helper::getUser();
     $customer = \Helper::getCustomer();
     if ($customer->is_registered) {
         return '请勿重复注册';
     }
     $validator = \Validator::make($request->all(), ['phone' => 'required|digits:11|unique:customers,phone,' . $customer->id, 'code' => 'required|digits:6']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     if ($request->input('code') != $customer->auth_code || $request->input('code') == '000000') {
         return redirect()->back()->with('error_message', '验证码不匹配!')->withInput();
     }
     if (Carbon::now()->diffInMinutes($customer->auth_code_expire) > 0) {
         return redirect()->back()->with('error_message', '验证码过期!')->withInput();
     }
     $beans_total_update = 0;
     if ($customer->beans_total > 0) {
         $beans_total_update = $customer->beans_total;
     }
     $customer->update(['phone' => $request->input('phone'), 'is_registered' => true, 'beans_total' => $beans_total_update, 'nickname' => $user['nickname'], 'head_image_url' => $user['headimgurl'], 'qr_code' => \Wechat::getForeverQrCodeUrl($customer->id)]);
     if ($ci = CustomerInformation::where('phone', '=', $request->input('phone'))->first()) {
         $ci->customer_id = $customer->id;
         $ci->save();
     }
     //        $ret = $customer->register();
     if ($customer->referrer_id) {
         //            \BeanRecharger::invite($customer->getReferrer());
         \Analyzer::updateBasicStatistics($customer->referrer_id, AnalyzerConstant::CUSTOMER_FRIEND);
     }
     \EnterpriseAnalyzer::updateBasic(AnalyzerConstant::ENTERPRISE_REGISTER);
     event(new Register($customer));
     if (\Session::has('register_next_url')) {
         return redirect(\Session::get('register_next_url'));
     }
     return redirect('register/success');
 }
Esempio n. 2
0
 public function friend()
 {
     $customer = \Helper::getCustomer();
     if (!$customer->qr_code) {
         $customer->qr_code = \Wechat::getForeverQrCodeUrl($customer->id);
         $customer->save();
     }
     $data['qrCode'] = $customer->qr_code;
     return view('personal.friend', ['data' => $data]);
 }