示例#1
0
 public static function orderTradeStatus()
 {
     $order_id = Input::get('order_id');
     $order = AgencyOrder::find($order_id);
     if (!isset($order)) {
         return Response::json(array('errCode' => 21, 'message' => '该订单不存在'));
     }
     return Response::json(array('errCode' => 0, 'trade_status' => $order->trade_status));
 }
 public function pay()
 {
     $agency_order = AgencyOrder::find(Input::get('order_id'));
     if (!isset($agency_order)) {
         return Response::make('无效参数');
     }
     if ($agency_order->trade_status != '0') {
         return Response::make('该订单已付款');
     }
     return View::make('pages.serve-center.business.pay', ['order' => $agency_order]);
 }
 public function success()
 {
     $order_id = Input::get('order_id');
     $order = AgencyOrder::find($order_id);
     if (!isset($order)) {
         return Response::make('Invalid order');
     }
     if ($order->user_id != Sentry::getUser()->user_id) {
         return Response::make('Invalid order');
     }
     if ($order->trade_status == '2' || $order->trade_status == '3') {
         return Response::make('Invalid order');
     }
     return View::make('pages.serve-center.pay.success')->with(array('order' => $order));
 }
示例#4
0
 public function submit_order()
 {
     if (!Session::has('violations')) {
         return Response::json(['errCode' => 2, 'message' => '请先查询并确认代办']);
     }
     $violations = Session::get('violations');
     $sign = Input::get('sign');
     if (!array_key_exists($sign, $violations)) {
         return Response::json(['errCode' => 3, 'message' => '参数错误']);
     }
     if ($violations[$sign]['info']['status'] != static::$AGENCY_STATUS_CONFIRMED) {
         return Response::json(['errCode' => 2, 'message' => '请先确认']);
     }
     $is_delivered = (int) Input::get('is_delivered');
     if ($is_delivered == 1) {
         $params = Input::all();
         $rules = ['recipient_name' => 'required', 'recipient_addr' => 'required', 'recipient_phone' => 'required|telephone'];
         $message = ['required' => '请输入:attribute', 'telephone' => ':attribute格式不正确'];
         $attributes = ['recipient_name' => '收件人姓名', 'recipient_addr' => '收件人地址', 'recipient_phone' => '收件人手机'];
         $validator = Validator::make($params, $rules, $message, $attributes);
         if ($validator->fails()) {
             return Response::json(['errCode' => 4, 'message' => $validator->messages()->first()]);
         }
     }
     $violation = $violations[$sign];
     try {
         DB::beginTransaction();
         $order_id = AgencyOrder::get_unique_id();
         $agency_order = new AgencyOrder();
         $agency_order->order_id = $order_id;
         $agency_order->user_id = Sentry::getUser()->user_id;
         $agency_order->agency_no = $violation['info']['count'];
         $agency_order->capital_sum = $violation['info']['total_fee'];
         $agency_order->car_type_no = $violation['info']['car_type_no'];
         $agency_order->car_plate_no = $violation['info']['car_plate_no'];
         $agency_order->car_engine_no = $violation['info']['car_engine_no'];
         $agency_order->car_frame_no = $violation['info']['car_frame_no'];
         $agency_order->service_charge_sum = $violation['info']['service_fee'] * $violation['info']['count'];
         $agency_order->late_fee_sum = 0.0;
         $agency_order->trade_status = 0;
         $agency_order->process_status = 0;
         if ($is_delivered == 1) {
             $agency_order->is_delivered = true;
             $agency_order->express_fee = $violation['info']['express_fee'];
             $agency_order->recipient_name = $params['recipient_name'];
             $agency_order->recipient_addr = $params['recipient_addr'];
             $agency_order->recipient_phone = $params['recipient_phone'];
         }
         $agency_order->save();
         foreach ($violation['results'] as $violation_result) {
             $violation_info = new TrafficViolationInfo();
             $violation_info->order_id = $order_id;
             $violation_info->req_car_frame_no = '';
             $violation_info->req_car_plate_no = $violation_result['hphm'];
             //车牌号码
             $violation_info->req_car_engine_no = $violation_result['fdjh'];
             //发动机号后六位
             $violation_info->car_type_no = $violation_result['hpzl'];
             //号牌种类
             $violation_info->rep_sequence_num = $violation_result['xh'];
             $violation_info->rep_event_time = $violation_result['wfsj'];
             //违法时间
             $violation_info->rep_event_city = $violation_result['wfcs'];
             //违法城市
             $violation_info->rep_event_addr = $violation_result['wfdz'];
             //违法地址
             $violation_info->rep_violation_behavior = $violation_result['wfxwzt'] . '[' . $violation_result['wfxw'] . ']';
             //违法行为
             $violation_info->rep_point_no = $violation_result['wfjfs'];
             //违法记分数
             $violation_info->rep_priciple_balance = $violation_result['fkje'];
             //罚款金额
             $violation_info->rep_service_charge = $violation['info']['service_fee'];
             $violation_info->save();
         }
         DB::commit();
     } catch (Exception $e) {
         DB::rollback();
         throw $e;
         return Response::json(['errCode' => 1, 'message' => '订单处理失败']);
     }
     unset($violations[$sign]);
     Session::put('violations', $violations);
     return Response::json(['errCode' => 0, 'message' => 'ok', 'order_id' => $order_id]);
 }
 public static function refund($order_id, $channel = 'WX')
 {
     $data = static::returnDataArray();
     $refund = RefundRecord::where('order_id', $order_id)->first();
     if (!isset($refund)) {
         return array('errCode' => 21, 'message' => '该订单不存在');
     }
     $order = AgencyOrder::find($order_id);
     $data["bill_no"] = $order->order_id;
     $data["refund_no"] = date('Ymd', time()) . time();
     $data["refund_fee"] = (int) (($order->capital_sum + $order->service_charge_sum + $order->express_fee) * 100);
     $data["channel"] = $channel;
     $data["optional"] = json_decode(json_encode(array("refund_id" => $refund->refund_id), true), true);
     try {
         DB::transaction(function () use($refund, $data) {
             $order_auth_info = new OrderAuthInfo();
             $order_auth_info->transactionId = $data["refund_no"];
             //交易单号
             $order_auth_info->transactionFee = $data["refund_fee"];
             //费用
             $order_auth_info->save();
             $refund->refund_no = $data["refund_no"];
             $refund->save();
         });
     } catch (Exception $e) {
         return array('errCode' => 21, 'message' => $e->getMessage());
     }
     try {
         $result = BCRESTApi::refund($data);
         if ($result->result_code != 0 || $result->result_msg != "OK") {
             return array('errCode' => 22, 'message' => $result->err_detail);
         }
     } catch (Exception $e) {
         return array('errCode' => 23, 'message' => $e->getMessage());
     }
     return array('errCode' => 0, 'message' => '退款已提交');
 }
示例#6
0
 public function getIndents()
 {
     $type = Input::get("type");
     $indents = [];
     if ($type == "id") {
         $indentId = Input::get("indentId");
         $indents = AgencyOrder::where("order_id", "=", $indentId)->with("traffic_violation_info")->get();
     } else {
         $licensePlate = Input::get("licensePlate");
         $startDate = Input::get("startDate");
         $endDate = Input::get("endDate");
         $status = Input::get("status", "all");
         $query = AgencyOrder::where("car_plate_no", "=", $licensePlate)->where("created_at", ">", $startDate)->where("created_at", "<", $endDate);
         if ($status != "all") {
             $query = $query->where("process_status", "=", $status);
         }
         $indents = $query->with("traffic_violation_info")->get();
     }
     return Response::json(array("errCode" => 0, "indents" => $indents));
 }
 public function approveRefundApplication()
 {
     $indentId = Input::get("indent_id");
     $indent = AgencyOrder::where("order_id", "=", $indentId)->with("refund_record", "traffic_violation_info")->first();
     if (!isset($indent)) {
         return View::make('errors.page-error', ["errMsg" => "订单未找到,请检查订单号是否正确"]);
     }
     return View::make('pages.admin.business-center.approve-refund-application', ["indent" => $indent]);
 }
示例#8
0
 /**
  * 插入随机数据
  */
 protected function create_refund_records($total = 50)
 {
     echo 'Creating refund_records...';
     $orders = AgencyOrder::all();
     foreach ($orders as $order) {
         if ($order->process_status == "1" && $order->trade_status == "2") {
             // 已受理且申请退款
             $refund_record = new RefundRecord();
             $refund_record->order_id = $order->order_id;
             $refund_record->user_id = $order->user_id;
             $flag = rand(0, 1);
             if ($flag == 0) {
                 $refund_record->status = '0';
                 // 审核中
                 $refund_record->approval_at = $this->get_random_datetime();
             } else {
                 $refund_record->status = '3';
                 // 审核不通过
                 $refund_record->approval_at = $this->get_random_datetime();
             }
             $refund_record->save();
         } else {
             if ($order->process_status == "4") {
                 // 已关闭
                 $refund_record = new RefundRecord();
                 $refund_record->order_id = $order->order_id;
                 $refund_record->user_id = $order->user_id;
                 $refund_flag = rand(0, 2);
                 if ($refund_flag == 0) {
                     $refund_record->status = '1';
                     // 审核退款通过
                     $refund_record->approval_at = $this->get_random_datetime();
                 } else {
                     if ($refund_flag == 1) {
                         $refund_record->status = '2';
                         // 退款成功
                         $refund_record->approval_at = $this->get_random_datetime();
                     } else {
                         $refund_record->status = '4';
                         // 退款失败
                         $refund_record->approval_at = $this->get_random_datetime();
                     }
                 }
                 $refund_record->save();
             }
         }
     }
     echo 'Done' . PHP_EOL;
 }