'phone', 'cash' => 'amount', 'type' => 'type', ); $param['type'] = 1; $this->method = 'youka/apply/invest'; return $this->submit($param, $check); } # 中石油油卡充值 拼音来吧 public function zsycz($param) { $check = array ( 'card' => 'cardNo', 'cash' => 'amount', ); $this->method = 'youka/apply/trade'; return $this->submit($param, $check); } # 中石化油卡充值 public function zshcz($param) { $check = array ( 'card' => 'cardNo', 'cash' => 'amount', ); $this->method = 'youka/apply/trade'; return $this->submit($param, $check); } # 通知处理 主要返回状态 2是成功 3是失败 public function notify($data) { $request = $data; unset($request['s_order']); unset($request['sign']); $sign = strtoupper($this->sign($request, 'md5', '&key=' . $this->token)); if ($sign != $data['sign']) { return false; } /* $result = array(); //$result['data'] = json_encode($data, JSON_UNESCAPED_UNICODE); $result['cash'] = 1; if ($data['status'] == 1) { $result['status'] = 2; } else { $result['status'] = 3; } if (isset($data['voucherNo']) && $data['voucherNo']) { # 流水号 $data['s_nubmer'] = $result['s_nubmer'] = $data['voucherNo']; } $result['data'] = $data; */ $result = array(); if ($data['status'] == 1) { $result['status'] = 2; } elseif ($data['status'] == 2) { $result['status'] = 3; } else { $result['status'] = 4; } if (isset($data['voucherNo']) && $data['voucherNo']) { $data['s_nubmer'] = $result['s_nubmer'] = $data['voucherNo']; # 流水号 /* if (isset($data['phone']) && $data['phone']) { } else { $data['s_nubmer'] = $result['s_nubmer'] = $data['voucherNo']; } */ } $result['cash'] = 1; $result['data'] = $data; return $result; } # 数据响应格式处理 public function response($data) { $log['type'] = 'response'; $log['data'] = $data; $log['config'] = $this->data; $this->log($log); $array = $this->json_decode($data); if (!$array) { $msg = 'error'; } elseif (isset($array['code']) && $array['code'] == '0000' && isset($array['respCode']) && $array['respCode'] == '1111') { # 正确 $msg = 'ok'; } else { # 错误 $msg = isset($array['msg']) ? $array['msg'] : 'error'; } return array ( 'msg' => $msg, 'data' => $data, 'array' => $array, ); } # 主动查询接口 public function query($order) { $request['mid'] = $this->mid; $request['orderNum'] = $order; $request['sign'] = strtoupper($this->sign($request, 'md5', '&key=' . $this->token)); $url = $this->host . 'youka/apply/search'; $response = $this->curl('post', $url, $request, true); $log['type'] = 'query_response'; $log['data'] = $response; $log['config'] = $this->data; $this->log($log); $array = $this->json_decode($response); $result = array(); $result['status'] = 3; if (isset($array['code']) && $array['code'] == '0000') { $result['status'] = 1; } if (isset($array['code']) && $array['code'] == '0004') { $result['status'] = 2; } if (isset($array['voucherNo']) && $array['voucherNo']) { # 流水号 $result['voucherNo'] = $array['voucherNo']; } return $result; } # 提交数据 private function submit($param, $check) { $param = $this->param($param, $check); if (is_string($param) || (is_array($param) && $param['status'] == 1)) { return $param; } return $this->send($param); } private function send($param, $parent_order = '') { $request = $param['detail']; $request['mid'] = $this->mid; $request['orderNum'] = $param['order']; if ($this->method == 'youka/apply/invest') { $request['backUrl'] = $this->getNotify($param['order'], 1); } $request['sign'] = strtoupper($this->sign($request, 'md5', '&key=' . $this->token)); $url = $this->host . $this->method; $response = $this->curl('post', $url, $request, true); $response = $this->response($response); //$response['data'] = '{}'; //$response['msg'] = 'ok'; $channel_order_id = ''; $this->create($param['order'], $channel_order_id, $param['merchant_order'], $param['cash'], $url, $request, $response, 1, $param['account'], $parent_order); return $response['msg']; } }