public function cost_detail() { // 默认渲染数据 $render_data = ['previous_input' => ['date' => '', 'cost_type' => '10'], 'results' => []]; $params = Input::all(); // 参数非空,且指定查询的消费类型,且指定的消费类型有效 if (!empty($params)) { // 默认第一页 if (!Input::has('page')) { $params['page'] = 1; } if (!Input::has('date')) { $params['date'] = date('Y-m'); } Input::merge($params); $render_data['previous_input'] = array_merge($render_data['previous_input'], $params); // 查询充值记录 if ($params['cost_type'] == '10') { // 先查询费用类型 $fee_type = FeeType::select('id', 'category', 'item')->where('category', '10')->first(); // 查询费用明细所必须条件 $render_data['results'] = CostDetail::select('cost_id', 'created_at', 'fee_type_id', 'number')->where('user_id', Sentry::getUser()->user_id)->where('fee_type_id', $fee_type->id)->where('created_at', 'like', $params['date'] . '%')->orderBy('created_at', 'desc')->get(); } else { if ($params['cost_type'] == '20') { $date = Carbon::parse(Input::get('date')); $date_start = $date->timestamp * 1000; $date->addMonth(); $date_end = $date->timestamp * 1000; $render_data['results'] = BusinessController::count(Sentry::getUser()->user_id, $date_start, $date_end); } } } return View::make('pages.finance-center.cost-manage.cost-detail', $render_data); }
public function car() { $user = Sentry::getUser(); if ($user->is_common_user()) { return View::make('404'); } $account = BusinessController::accountInfo($user->user_id); $account['unit'] = $account['carUnit']; return View::make('pages.serve-center.data.cars', ['account' => $account]); }
protected function buildRefineUri($businessType, $formData) { if (strtolower($formData['cat2']) == strtolower('Any')) { $formData['cat2name'] = 'Any'; } else { $refcat2 = new Refcategory(); $formData['cat2name'] = $refcat2->getCatNameById($formData['cat2']); } return parent::buildRefineUri($businessType, $formData); }
public function search_violation() { $user = Sentry::getUser(); // 普通用户每天只能查询两次 if ($user->is_common_user()) { $account_to_render = ['remain_search' => SearchController::get_search_count_remain($user->user_id, 'violation')]; } else { if ($user->is_business_user()) { $account = BusinessController::accountInfo($user->user_id); $account_to_render = ['unit' => $account['violationUnit'], 'balance' => $account['balance']]; } else { return View::make('Unkown error'); } } return View::make('pages.serve-center.business.vio', ['account' => $account_to_render]); }
public function BusinessSearchForm() { $controller = new BusinessController(); $form = $controller->BusinessSearchForm(); return $form; }
public function car() { if (Sentry::getUser()->is_common_user()) { return Response::json(['errCode' => 2, '无权限']); } $params = Input::all(); $rules = ['engineCode' => 'required|size:6', 'licensePlate' => 'required|size:7', 'licenseType' => 'required|size:2']; $messages = ['required' => '请输入:attribute', 'size' => ':attribute位数不正确']; $attributes = ['engineCode' => '发动机号后6位', 'licensePlate' => '车牌号码', 'licenseType' => '车辆类型']; $validator = Validator::make($params, $rules, $messages, $attributes); // 格式不对,将返回第一个错误 if ($validator->fails()) { return Response::json(['errCode' => 1, 'message' => $validator->messages()->first()]); } try { $search_result = BusinessController::car(TokenController::getAccessToken(Sentry::getUser()), $params['engineCode'], $params['licensePlate'], $params['licenseType']); $account = ['unit' => $search_result['account']['carUnit'], 'balance' => $search_result['account']['balance']]; if ($search_result['data']['returnCode'] != 1) { throw new OperationException('查询失败', 32); } } catch (OperationException $e) { $message = static::process_error($e->getCode(), $e->getMessage()); if ($e->getCode() < 50 & isset($account)) { $message['account'] = $account; } return Response::json($message); } catch (\Exception $e) { return Response::json(static::process_error($e->getCode(), $e->getMessage())); } return Response::json(['errCode' => 0, 'car' => $search_result['data']['body'][0], 'account' => $account]); }
public function authBeeCloud() { // return 'success'; $appId = Config::get('beeCloud.app_id'); $appSecret = Config::get('beeCloud.app_secret'); $jsonStr = file_get_contents("php://input"); $msg = json_decode($jsonStr, true); Log::info($msg); Log::info($msg['transactionId']); $info = OrderAuthInfo::where('transactionId', $msg['transactionId'])->first(); if (!isset($info)) { Log::info('无此数据'); return 'false'; } Log::info($info); //验证签名 $sign = md5($appId . $appSecret . $msg['timestamp']); if ($sign != $msg['sign']) { Log::info('签名有错'); return Response::json(array('errCode' => 21, 'message' => '验证码不正确')); } //订单号 if ($info->transactionId != $msg['transactionId']) { Log::info('订单号有错'); return Response::json(array('errCode' => 22, 'message' => '订单号')); } if ($msg['transactionType'] == "PAY") { $message_detail = $msg['messageDetail']; //订单金额 if ($info->transactionFee != $msg['transactionFee']) { Log::info('金额有错有错'); return Response::json(array('errCode' => 23, 'message' => '金额不不正确')); } if ($message_detail['total_fee'] != $info->transactionFee) { Log::info('messageDetail中金额有错'); return Response::json(array('errCode' => 24, 'message' => '金额不不正确')); } //判断是代办还是充值,有user_id为充值 if (isset($msg['optional']['user_id'])) { try { DB::transaction(function () use($info, $msg) { $cost_detail = new CostDetail(); $cost_detail->user_id = $msg['optional']['user_id']; $cost_detail->cost_id = $info->transactionId; $cost_detail->fee_type_id = FeeType::where('category', FeeType::get_recharge_code())->where('item', FeeType::get_recharge_subitem())->first()->id; $cost_detail->number = $info->transactionFee / 100; $cost_detail->save(); Log::info($info->transactionFee); Log::info($msg['optional']['user_id']); $result = BusinessController::recharge($info->transactionFee / 100, $msg['optional']['user_id']); if (!$result) { throw new Exception(); } }); } catch (\Exception $e) { Log::info($e->getMessage()); return 'false'; } $info->delete(); return 'success'; } else { $order = AgencyOrder::find($info->transactionId); if ($msg['channelType'] == 'WX') { $order->pay_trade_no = $message_detail['transaction_id']; //交易流水号 $order->pay_platform = 0; //支付平台 } else { $order->pay_trade_no = $message_detail['trade_no']; $order->pay_platform = 1; } $order->trade_status = 1; //已付款 $order->process_status = 1; //已受理 if (!$order->save()) { return 'false'; } $info->delete(); return 'success'; } } //退款逻辑 if ($msg['transactionType'] == "REFUND") { //退款 if ($info->transactionFee != $msg['transactionFee']) { Log::info('退款金额有错'); return Response::json(array('errCode' => 25, 'message' => '退款金额有错')); } //更改状态 $refund_id = $msg['optional']['refund_id']; $refund = RefundRecord::find($refund); $order = AgencyOrder::find($info->transactionId); try { DB::transaction(function () use($refund, $order) { $refund->status = 2; $refund->save(); $order->trade_status = 3; $order->process_status = 3; $order->save(); }); } catch (Exception $e) { Log::info($e->getMessage()); return 'false'; } $info->delete(); return 'success'; } }
public function changeQueryUnivalence() { $userId = Input::get("userId"); $params = Input::get("params"); try { $result = BusinessController::modify_business_user_univalence($userId, $params); } catch (Exception $e) { return Response::json(array('errCode' => 1, "errMsg" => "[数据库错误]修改失败")); } return Response::json(array('errCode' => 0)); }
public function changeDefaultQueryUnivalence() { try { $result = BusinessController::get_default_univalence(); } catch (Exception $e) { return View::make('errors.page-error'); } return View::make('pages.admin.business-center.change-default-query-univalence', ["violationUnivalence" => $result["violation"], "licenseUnivalence" => $result["license"], "carUnivalence" => $result["car"]]); }
public function index() { return View::make('pages.finance-center.recharge.index', ['account_info' => BusinessController::accountInfo()]); }
public function moneyRemarkCode() { $user = Sentry::getUser(); $remark_code = Input::get('remark_code'); if ($remark_code == null) { return Response::json(array('errCode' => 21, 'message' => '请输入打款码')); } $database_remark_code = Sentry::getUser()->remark_code; if ($remark_code != $database_remark_code) { if ($user->status == 30) { //先判断其是否已被锁定 return Response::json(array('errCode' => 30, 'message' => '帐号已锁定')); } //计算输入错误次数 if (Session::get('remain_time') != null) { $remain_time = Session::get('remain_time'); if ($remain_time != 0) { Session::put('remain_time', $remain_time - 1); if (Session::get('remain_time') == 0) { //连续超过5次,锁定帐号 $user->status = 30; if (!$user->save()) { return Response::json(array('errCode' => 30, 'message' => '数据库错误,保存失败')); } return Response::json(array('errCode' => 24, 'message' => '错误次数超过5次,账号已锁定')); } return Response::json(array('errCode' => 25, 'message' => '打款码不正确,你还有' . Session::get('remain_time') . '次机会输入打款码')); } } //首次输入错误 Session::put('remain_time', 4); return Response::json(array('errCode' => 25, 'message' => '打款码不正确,你还有' . Session::get('remain_time') . '次机会输入打款码')); } try { DB::transaction(function () use($user) { try { $app_config = BusinessController::get_appkey_appsecret_from_remote($user->user_id); $business_user = BusinessUser::find($user->user_id); $business_user->app_key = $app_config['appkey']; $business_user->app_secret = $app_config['secretkey']; $business_user->save(); } catch (Exception $e) { throw $e; } $user->status = 22; $user->save(); }); } catch (Exception $e) { return Response::json(array('errCode' => 26, 'message' => $e->getMessage())); } return Response::json(array('errCode' => 0, 'message' => '账号已激活')); }
/** * 从远程服务器获取access token * * @return string */ public static function getAccessTokenFromRemote($appkey, $secretkey) { return BusinessController::send_request(['method' => 'POST', 'uri' => '/token', 'query' => ['appkey' => $appkey, 'secretkey' => $secretkey]], 'token'); }