Пример #1
0
 public function requestRefund()
 {
     $order_id = Input::get('order_id');
     $order = AgencyOrder::find($order_id);
     if (!isset($order)) {
         return Response::json(array('errCode' => 21, 'message' => '该订单不存在'));
     }
     $refund_record = RefundRecord::where('order_id', '=', $order_id)->get();
     if (count($refund_record) != 0) {
         return Response::json(array('errCode' => 22, 'message' => '申请已提交'));
     }
     if ($order->trade_status != 1 || $order->process_status != 1) {
         return Response::json(array('errCode' => 23, 'message' => '该订单不可申请退款'));
     }
     try {
         DB::transaction(function () use($order) {
             $order->trade_status = 2;
             $order->save();
             $refund_record = new RefundRecord();
             $refund_record->order_id = $order->order_id;
             $refund_record->user_id = Sentry::getUser()->user_id;
             $refund_record->save();
         });
     } catch (Exception $e) {
         return Response::json(array('errCode' => 24, 'message' => '退款申请失败,请重新申请'));
     }
     return Response::json(array('errCode' => 0, 'message' => '申请成功'));
 }
Пример #2
0
 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' => '退款已提交');
 }
 public function refundApplicationList()
 {
     $type = Input::get("type", "all");
     $perPage = 15;
     if ($type == "approving") {
         $refundIndents = RefundRecord::where("status", "=", "0")->orderBy("updated_at", "desc")->with(["order", "user_info"])->paginate($perPage);
     } else {
         if ($type == "pass") {
             $refundIndents = RefundRecord::where("status", "=", "1")->orWhere("status", "=", "2")->orWhere("status", "=", "4")->orderBy("updated_at", "desc")->with(["order", "user_info"])->paginate($perPage);
         } else {
             if ($type == "unpass") {
                 $refundIndents = RefundRecord::where("status", "=", "3")->orderBy("updated_at", "desc")->with(["order", "user_info"])->paginate($perPage);
             } else {
                 $refundIndents = RefundRecord::orderBy("created_at", "desc")->with(["order", "user_info"])->paginate($perPage);
             }
         }
     }
     return View::make('pages.admin.business-center.refund-application-list', ["refundIndents" => $refundIndents, "count" => $refundIndents->count(), "totalCount" => $refundIndents->getTotal()]);
 }
Пример #4
0
 public function refund_record()
 {
     $paginator = RefundRecord::where('user_id', Sentry::getUser()->user_id)->paginate(static::$default_per_page);
     return View::make('pages.finance-center.cost-manage.refund-record', ['records' => $paginator->getCollection(), 'paginator' => $paginator]);
 }