'phone', 'cash' => 'amount', 'lx' => 'lx', ); $param['lx'] = 1; if (isset($param['isp']) && $param['isp']) { if ($param['isp'] == 1) { $param['lx'] = 1; } elseif ($param['isp'] == 2) { $param['lx'] = 2; } elseif ($param['isp'] == 3) { $param['lx'] = 3; } } return $this->submit($param, $check); } # 通知处理 主要返回状态 2是成功 3是失败 public function notify($data) { $request = $data; $sign = $this->_sign($request, array('result', 'msg', 'order', 'phone_no', 'amount', 'op_no', 'settle')); if ($sign != $data['sign']) { return false; } $result = array(); $result['cash'] = 1; if ($data['result'] == 'success') { $result['status'] = 2; } elseif ($data['result'] == 'fail') { $result['status'] = 3; } else { $result['status'] = 4; } $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['result']) && $array['result'] == 'SUCCESS') { # 正确 $msg = 'ok'; } else { # 错误 $msg = isset($array['msg']) ? $array['msg'] : '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; } $this->api = 'api/order/invest'; $request = $param['detail']; $request['s_id'] = $this->mid; $request['order_no'] = $param['order']; $request['notify_url'] = $this->getNotify($param['order'], 1); $request['sign'] = $this->_sign($request, array('amount', 'notify_url', 'order_no', 'phone', 'account', 's_id')); $url = $this->host . $this->api; $response = $this->curl('get', $url, $request); $response = $this->response($response); //$response['data'] = ''; //$response['msg'] = 'ok'; $channel_order_id = ''; if (isset($response['array']['data']) && $response['array']['data']) { $channel_order_id = $response['array']['data']; } $this->create($param['order'], $channel_order_id, $param['merchant_order'], $param['cash'], $url, $request, $response, 1, $param['account']); return $response['msg']; } private function _sign($request, $param) { ksort($request); $signature_string = ''; foreach ($request as $k => $v) { if (in_array($k, $param)) { $signature_string .= $v; } } $signature_string .= $this->token; return strtoupper(md5($signature_string)); } }