'phone', 'cash' => 'amount', 'other' => 'area', 'official' => 'official', ); $param['official'] = 1; if (isset($param['isp']) && $param['isp']) { if ($param['isp'] == 1) { $param['official'] = 1; } elseif ($param['isp'] == 2) { $param['official'] = 2; } elseif ($param['isp'] == 3) { $param['official'] = 3; } } $this->api = 'open/api/hf/recharge'; return $this->submit($param, $check); } public function zshcz($param) { $check = array ( 'card' => 'phone', 'cash' => 'amount', ); $this->api = 'open/api/jy/recharge'; return $this->submit($param, $check); } # 通知处理 主要返回状态 2是成功 3是失败 public function notify($data) { $request = $data; unset($request['sign']); unset($request['s_order']); $sign = $this->_sign($request); if ($sign != $data['sign']) { //return false; } $result = array(); $result['cash'] = 1; if ($data['status'] == 2) { $result['status'] = 2; } elseif ($data['status'] == 3) { $result['status'] = 3; } else { $result['status'] = 4; } if (isset($data['voucher']) && $data['voucher']) { # 流水号 $data['s_nubmer'] = $result['s_nubmer'] = $data['voucher']; } $result['yes'] = 'SUCCESS'; $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'] == '0') { # 正确 $msg = 'ok'; } else { # 错误 $msg = isset($array['errMsg']) ? $array['errMsg'] : 'error'; } return array ( 'msg' => $msg, 'data' => $data, 'array' => $array, ); } # 查询接口 public function query($param) { } # 提交数据 private function submit($param, $check) { $param = $this->param($param, $check); if (is_string($param) || (is_array($param) && $param['status'] == 1)) { return $param; } $request = $param['detail']; $request['amount'] = $request['amount'] * 100; $request['appid'] = $this->mid; $request['orderId'] = $param['order']; if (isset($request['area']) && !$request['area']) { $request['area'] = '北京'; } $request['asynchUrl'] = $this->getUrl('/gateway/api.notify/yiyunfu'); $request['sign'] = $this->_sign($request); $url = $this->host . $this->api; $response = $this->curl('post', $url, $request, true); $response = $this->response($response); //$response['data'] = ''; //$response['msg'] = 'ok'; $channel_order_id = ''; if (isset($response['array']['order_id']) && $response['array']['order_id']) { $channel_order_id = $response['array']['order_id']; } $this->create($param['order'], $channel_order_id, $param['merchant_order'], $param['cash'], $url, $request, $response, 1, $param['account']); return $response['msg']; } private function getCode($cash, $type) { if ($type == 2) { if ($cash == 30) { return 20011; } elseif ($cash == 50) { return 20012; } elseif ($cash == 100) { return 20013; } elseif ($cash == 200) { return 20014; } } return 0000; } private function _sign($request) { ksort($request); $signature_string = ''; foreach ($request as $k => $v) { $signature_string .= $k . '=' . $v . '&'; } $signature_string .= 'key=' . $this->token; return md5($signature_string); } }