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 articleIndex(Request $request) { $customer = \Helper::getCustomerOrNull(); if (!$customer) { if (!$customer->articleIndexNeedFeedBack()) { \Log::info('hongbao---111'); } else { \Log::info('hongbao---222'); } } else { \Log::info('hongbao---333'); } if (!$customer || !$customer->articleIndexNeedFeedBack()) { \Log::info('hongbao---不存在'); \Analyzer::updateBasicStatistics($customer->id, AnalyzerConstant::CUSTOMER_ARTICLE); return redirect("http://mp.weixin.qq.com/mp/homepage?__biz=MzI4NTAxMzc3Mw==&hid=1&sn=740141c97f60c8630a87a3f0c344a504#wechat_redirect"); } else { \Log::info('hongbao---存在'); $count = $customer->readArticleIndex(); \BeanRecharger::executeEducation($customer); \Analyzer::updateBasicStatistics($customer->id, AnalyzerConstant::CUSTOMER_ARTICLE); return view('education.hongbao')->with(['redirect_url' => "http://mp.weixin.qq.com/mp/homepage?__biz=MzI4NTAxMzc3Mw==&hid=1&sn=740141c97f60c8630a87a3f0c344a504#wechat_redirect", 'count' => $count]); } }
public function updateBean(Request $request) { $customer = \Helper::getCustomer(); if (!$customer) { return response()->json(['result' => '-1']); } /*if>*/ if (!$customer->is_registered) { return response()->json(['result' => '-1']); } /*if>*/ $article = Article::where('id', $request->input('id'))->first(); \Analyzer::updateArticleStatistics($customer->id, $article->type_id); \Analyzer::updateBasicStatistics($customer->id, AnalyzerConstant::CUSTOMER_ARTICLE); \EnterpriseAnalyzer::updateArticleStatistics($article->type_id); \EnterpriseAnalyzer::updateBasic(AnalyzerConstant::ENTERPRISE_ARTICLE); if (\DailyAnalyzer::getDailyItemCount($customer->id, AnalyzerConstant::CUSTOMER_DAILY_ARTICLE)) { \DailyAnalyzer::updateDailyItemCount($customer->id, AnalyzerConstant::CUSTOMER_DAILY_ARTICLE); return response()->json(['result' => '-1']); } \DailyAnalyzer::updateDailyItemCount($customer->id, AnalyzerConstant::CUSTOMER_DAILY_ARTICLE); \BeanRecharger::executeEducation($customer); return response()->json(['result' => '1']); }
/** * */ protected function updateStatistics() { foreach ($this->commodities()->get(['id'])->pluck('id') as $commodity_id) { \Analyzer::updateCommodityStatistics($this->customer_id, $commodity_id); \Analyzer::updateBasicStatistics($this->customer_id, AnalyzerConstant::CUSTOMER_COMMODITY); \EnterpriseAnalyzer::updateCommodityStatistics($commodity_id); } \Analyzer::updateBasicStatistics($this->customer_id, AnalyzerConstant::CUSTOMER_ORDER); \Analyzer::updateBasicStatistics($this->customer_id, AnalyzerConstant::CUSTOMER_MONEY_COST, $this->cash_payment); \EnterpriseAnalyzer::updateBasic(AnalyzerConstant::ENTERPRISE_ORDER); \EnterpriseAnalyzer::updateBasic(AnalyzerConstant::ENTERPRISE_COMMODITY, $this->commodities()->count()); \EnterpriseAnalyzer::updateBasic(AnalyzerConstant::ENTERPRISE_INCOME, $this->cash_payment); \EnterpriseAnalyzer::updateBasic(AnalyzerConstant::ENTERPRISE_BEAN, $this->beans_payment); }