'account', 'buyCount' => 'buyCount', 'other' => 'ip', ); if (!isset($param['other'])) { $param['other'] = '8.140.175.72'; } $param['buyCount'] = 1; $this->api = 'api/libao/makeOrder'; $this->sign = array('account', 'extOrderId', 'merchantId', 'notifyUrl', 'productId'); return $this->submit($param, $check); } # 电话充值 public function dhcz($param) { $check = array ( 'mobile' => 'phone', 'cash' => 'amt', ); $this->api = 'api/huafei/makeOrder'; $this->sign = array('amt', 'extOrderId', 'merchantId', 'notifyUrl', 'phone'); return $this->submit($param, $check); } # 中石油油卡充值 拼音来吧 public function zsycz($param) { $check = array ( 'card' => 'account', 'cash' => 'amt', 'number' => 'number', 'type' => 'type', ); $param['number'] = 1; $param['type'] = 'ZSY'; $this->api = 'api/jyk/makeOrder'; $this->sign = array('account', 'amt', 'extOrderId', 'merchantId', 'notifyUrl', 'number', 'type'); return $this->submit($param, $check); } # 中石化油卡充值 public function zshcz($param) { $check = array ( 'card' => 'account', 'cash' => 'amt', 'number' => 'number', 'type' => 'type', ); $param['number'] = 1; $param['type'] = 'ZSH'; $this->api = 'api/jyk/makeOrder'; $this->sign = array('account', 'amt', 'extOrderId', 'merchantId', 'notifyUrl', 'number', 'type'); return $this->submit($param, $check); } # 通知处理 主要返回状态 2是成功 3是失败 public function notify($data) { $request = $data; $sign = $this->_sign($request, array('extOrderId', 'orderId', 'state')); if ($sign != $data['sign']) { return false; } $result = array(); $result['cash'] = 1; if ($data['state'] == 4) { $result['status'] = 2; } elseif ($data['state'] == 5) { $result['status'] = 3; } else { $result['status'] = 4; } if (isset($data['exchangeTraded']) && $data['exchangeTraded']) { # 流水号 if (strstr($data['exchangeTraded'], '订单号:')) { $temp = explode('订单号:', $data['exchangeTraded']); } else { $temp[1] = $data['exchangeTraded']; } $data['s_nubmer'] = $result['s_nubmer'] = $temp[1]; } $result['yes'] = 'ok'; $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' => $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['merchantId'] = $this->mid; $request['extOrderId'] = $param['order']; $request['notifyUrl'] = $this->getNotify($param['order'], 1); if ($this->mid == 'M00122') { $request['phone'] = '13811270555'; } elseif (isset($request['type']) && $request['type'] == 'ZSY') { $request['phone'] = '13800000000'; } $request['phone'] = $this->getMobile($request['account']); if ($this->api == 'api/libao/makeOrder') { $request['productId'] = $this->getGid($param['cash']); $request['sign'] = $this->_sign($request, $this->sign); } else { $request['md5'] = $this->_sign($request, $this->sign); } $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']['order_no'])) { $channel_order_id = $response['array']['order_no']; } $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 ($param as $k => $v) { if (isset($request[$v]) && $request[$v]) { //$signature_string .= $v . '=' . $request[$v] . '&'; $signature_string .= $request[$v]; } } //$signature_string = substr($signature_string, 0, -1); $signature_string .= $this->token; return md5($signature_string); } }