'phone', 'cash' => 'price', ); $this->api = 'Pay/telpay'; return $this->submit($param, $check); } # 通知处理 主要返回状态 2是成功 3是失败 public function notify($data) { $request = $data; $result = array(); $result['cash'] = 1; if ($data['status'] == 1) { $result['status'] = 2; } else { $result['status'] = 3; } if (isset($data['remark1']) && $data['remark1']) { # 流水号 $data['s_nubmer'] = $result['s_nubmer'] = $data['remark1']; } $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['msg']) ? $array['msg'] : 'error'; } return array ( 'msg' => $msg, 'data' => $array, '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['mchid'] = $this->mid; $request['orderid'] = $param['order']; $request['product'] = $this->getCode($param['cash'], $param['isp']); $request['notify'] = $this->getNotify($param['order'], 1); $request['sign'] = $this->_sign($request); $url = $this->host . $this->api; $response = $this->curl('post', $url, $request); $response = $this->response($response); $channel_order_id = ''; if (isset($response['array']['data']['out order id'])) { $channel_order_id = $response['array']['data']['out 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 _sign($request) { ksort($request); $signature_string = ''; foreach ($request as $k => $v) { if ($v) { $signature_string .= $k . $v; } } $signature_string .= $this->token; return md5($signature_string); } private function getCode($cash, $isp) { if ($isp == 1) { if ($cash == 50) { return 10; } elseif ($cash == 100) { return 11; } elseif ($cash == 200) { return 12; } } if ($isp == 2) { if ($cash == 50) { return 13; } elseif ($cash == 100) { return 14; } elseif ($cash == 200) { return 15; } } if ($isp == 3) { if ($cash == 50) { return 16; } elseif ($cash == 100) { return 17; } elseif ($cash == 200) { return 18; } } return 0000; } }