public function persist() { $filename = $this->moveToLocalStorage($this->file('doctor-information')); \Excel::load(storage_path('app/doctor-information/' . $filename), function (LaravelExcelReader $reader) { $result = $reader->get(); foreach ($result as $row) { $param = ['name' => $row['姓名'], 'type' => substr(trim($row['等级']), 0, 1), 'level' => 5, 'hospital' => $row['所属医院'], 'hospital_level' => $row['医院级别'], 'department' => $row['科室'], 'phone' => strval(intval($row['注册电话'])), 'referred_name' => $row['推荐代表'], 'referred_phone' => strval(intval($row['代表电话'])), 'region' => $row['区域9大区'], 'region_level' => $row['销售大区级别'], 'responsible' => $row['销售地区级别']]; if ($customer = Customer::where('phone', strval(intval($row['注册电话'])))->first()) { $param['customer_id'] = $customer->id; } if ($customer_info = CustomerInformation::where('phone', strval(intval($row['注册电话'])))->first()) { $customer_info->update($param); return; } CustomerInformation::create($param); } }); }
public function a() { $p = 0; for ($i = 87; $i <= CustomerInformation::orderBy('id', 'desc')->first()->id; $i++) { $info = CustomerInformation::find($i); if (!$info) { continue; } if ($info->type == 'A' && ($customer_id = $info->customer_id)) { $customer = Customer::find($customer_id); $counter = new CustomerInvitationCounter($customer); print $info->name; print ' '; print $counter->getMonthlyCount(); print '<br>'; $p++; } } print '共' . $p . '人'; }
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'); }
public function store(Request $request) { $customerInformation = CustomerInformation::create(['name' => $request->input('name'), 'hospital' => $request->input('hospital'), 'province' => $request->input('province'), 'city' => $request->input('city'), 'district' => $request->input('district'), 'department' => $request->input('department'), 'remark' => $request->input('remark'), 'type' => $request->input('type'), 'referred_name' => $request->input('referred_name'), 'referred_phone' => $request->input('referred_phone'), 'region' => $request->input('region'), 'region_level' => $request->input('region_level'), 'responsible' => $request->input('responsible'), 'hospital_level' => $request->input('hospital_level'), 'phone' => $request->input('phone')]); $inputPhone = $request->input('phone'); if ($inputPhone) { $customer = Customer::where('phone', $inputPhone)->first(); if ($customer) { $customerInformation->update(['customer_id' => $customer->id]); } else { $customerInformation->update(['customer_id' => null]); } } if ($request->has('beans_total') && $customer) { $customer->update(['beans_total' => $request->input('beans_total')]); } if ($request->has('type_id') && $customer) { $customer->update(['type_id' => $request->input('type_id')]); } if ($customer) { return response()->json(['success' => true, 'data' => ['customer' => $customer->with('information')]]); } else { return response()->json(['success' => true, 'data' => ['customer' => null]]); } }