error(lang("controller.missing_order_sn"), url('visa/index')))); } $this->order_sn = $order_sn; } public function pay() { /*查询订单*/ $order_info = Httpcurl::request(config('app.GET_ORDER_DETAIL_URL'), 'post', ['order_sn' => $this->order_sn, 'model' => MODEL]); $order_info = json_decode($order_info[0], true); if ($order_info['code'] == '0') { return $this->error(lang("controller.order_not_exist"), url('visa/index')); } $order_info = $order_info['data']; if (empty($order_info)) { return $this->error(lang("controller.order_not_exist"), url('visa/index')); } /*判断订单状态*/ if ($order_info['pay_status'] == 1 ) { return $this->success(lang("controller.payment_success"), url('visa/index')); } /*判断订单状态*/ $params = [ 'amount' => $order_info['total_price'], 'terminal' => $order_info['is_mobile'] == '1' ? 'WAP' : 'PC', 'order_sn' => $order_info['order_sn'], 'vendor' => PAY_TYPE[$order_info['pay_type']], 'note' => PAYMODEL, ]; $response = HttpCurl::request(config('app.NI_HAO_PAY_URL'), 'post', $params); Log::info(json_encode($response)); $response = json_decode($response[0], true); if ($response['code'] != 1) { return $this->error($response['msg']); } echo $response['data'];exit(); } public function succ() { /*判断订单状态*/ $order_info = Httpcurl::request(config('app.GET_ORDER_DETAIL_URL'), 'post', ['order_sn' => $this->order_sn, 'model' => MODEL]); $order_info = json_decode($order_info[0], true); if ($order_info['code'] == '0') { return $this->error(lang("controller.order_not_exist")); } $order_info = $order_info['data']; if ($order_info) { if ($order_info['pay_status'] == 0 ) { return $this->success(lang("controller.payment_not_completed"), url('visa/index')); } } /*判断订单状态*/ $arrive_date = $order_info['arrive_date'] ?? ''; $arrive_timestamp = $arrive_date ? strtotime($arrive_date) : false; $latest_submit_timestamp = strtotime(date('Y-m-d') . ' +' . ARRIVE_DATE_COUNT . ' days 23:59:59'); if ($arrive_timestamp === false || $arrive_timestamp < $latest_submit_timestamp) { View::assign('arrive_date_info', ''); } else { $arrive_date_info = sprintf(lang("pay.arrive_date_info"), $arrive_date, date('Y-m-d', $arrive_timestamp - ARRIVE_DATE_COUNT * 86400)); View::assign('arrive_date_info', $arrive_date_info); } View::assign('payment_confirmed', true); View::assign('poll_status_url', ''); View::assign('repay_url', ''); View::assign('order_sn', $this->order_sn); return View::fetch('success'); } public function h5result() { if (Request::instance()->isAjax()) { /*查询订单*/ $order_info = Httpcurl::request(config('app.GET_ORDER_DETAIL_URL'), 'post', ['order_sn' => $this->order_sn, 'model' => MODEL]); $order_info = json_decode($order_info[0], true); if ($order_info['code'] == '0') { return json([ 'status' => 0, 'msg' => lang("controller.order_not_exist_retry"), 'url' => url('visa/index')->build() ]); } $order_info = $order_info['data']; /*判断订单状态*/ if ($order_info['pay_status'] == 1) { return json([ 'status' => 1, 'msg' => lang("controller.payment_success"), 'url' => url('pay/succ', ['reference' => $this->order_sn])->build() ]); } return json([ 'status' => 0, 'msg' => lang("controller.payment_not_completed_retry"), 'url' => url('pay/pay', ['order_sn' => $this->order_sn])->build() ]); } View::assign('order_sn', $this->order_sn); return View::fetch(); } }