'mobile', 'cash' => 'price', ); $this->api = 'onlinepay.do'; $this->paytype = ''; return $this->submit($param, $check); } # 中石油油卡充值 拼音来吧 public function zsycz($param) { $check = array ( 'card' => 'mobile', 'cash' => 'price', ); $this->api = 'onlinepay.do'; $this->paytype = 'ZSY'; return $this->submit($param, $check); } # 中石化油卡充值 public function zshcz($param) { $check = array ( 'card' => 'mobile', 'cash' => 'price', ); $this->api = 'onlinepay.do'; $this->paytype = 'ZSH'; return $this->submit($param, $check); } # 通知处理 主要返回状态 2是成功 3是失败 public function notify($data) { $request = $data; unset($request['sign']); unset($request['s_order']); $sign = strtoupper($this->_sign($request, array('userid', 'orderid', 'sporderid', 'merchantsubmittime', 'resultno'))); if ($sign != $data['sign']) { return false; } $result = array(); $result['cash'] = 1; if ($data['resultno'] == 1) { $result['status'] = 2; } elseif ($data['resultno'] == 9) { $result['status'] = 3; } else { $result['status'] = 4; } if (isset($data['remark1']) && $data['remark1']) { # 流水号 $data['s_nubmer'] = $result['s_nubmer'] = $data['remark1']; } $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 = (array) simplexml_load_string($data); if (!$array) { $msg = 'error'; } elseif (isset($array['resultno']) && $array['resultno'] == '0') { # 正确 $msg = 'ok'; } else { # 错误 $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['num'] = 1; $request['productid'] = ''; $request['userid'] = $this->mid; $request['sporderid'] = $param['order']; $request['spordertime'] = date('YmdHis'); $request['back_url'] = $this->getNotify($param['order'], 1); if ($this->paytype) { $request['paytype'] = $this->paytype; $request['productid'] = $this->getCode($param['cash']); if (!$request['productid']) { return 'order'; } } else { if (isset($param['isp']) && $param['isp']) { $isp = $param['isp']; } else { $isp = $this->isp($request['mobile']); } $paytype = ''; if ($isp == 1) { $paytype = 'yd'; } if ($isp == 2) { $paytype = 'lt'; } if ($isp == 3) { $paytype = 'dx'; } $request['paytype'] = $paytype; $request['productid'] = $this->getCode($param['cash'], $paytype); } $request['sign'] = $this->_sign($request, array('userid', 'productid', 'price', 'num', 'mobile', 'spordertime', 'sporderid')); $url = $this->host . $this->api; $response = $this->curl('get', $url, $request); $response = $this->response($response); $channel_order_id = ''; if (isset($response['array']['orderid'])) { $channel_order_id = $response['array']['orderid']; } $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 = false) { if ($this->paytype == 'ZSH') { if ($cash == 100) { return 30000001050; } elseif ($cash == 200) { return 30000001051; } elseif ($cash == 500) { return 30000001053; } elseif ($cash == 1000) { return 30000001054; } elseif ($cash == 2000) { return 40000001090; } } elseif ($this->paytype == 'ZSY') { if ($cash == 100) { return 40000001070; } elseif ($cash == 200) { return 40000001071; } elseif ($cash == 500) { return 40000001072; } elseif ($cash == 1000) { return 40000001073; } } elseif ($type == 'yd') { if ($cash == 30) { return 30000005153; } elseif ($cash == 50) { return 30000005154; } elseif ($cash == 100) { return 30000005155; } elseif ($cash == 200) { return 30000005156; } elseif ($cash == 300) { return 30000005157; } elseif ($cash == 500) { return 30000005158; } } elseif ($type == 'lt') { if ($cash == 30) { return 30000005159; } elseif ($cash == 50) { return 30000005160; } elseif ($cash == 100) { return 30000005161; } elseif ($cash == 200) { return 30000005162; } elseif ($cash == 300) { return 30000005163; } elseif ($cash == 500) { return 30000005164; } } elseif ($type == 'dx') { if ($cash == 30) { return 30000005165; } elseif ($cash == 50) { return 30000005166; } elseif ($cash == 100) { return 30000005167; } elseif ($cash == 200) { return 30000005168; } elseif ($cash == 300) { return 30000005169; } elseif ($cash == 500) { return 30000005170; } } return '1'; } private function _sign($request, $param) { //ksort($request); $signature_string = ''; foreach ($param as $k => $v) { if (isset($request[$v])) { $signature_string .= $v . '=' . $request[$v] . '&'; } } $signature_string .= 'key=' . $this->token; return md5($signature_string); } }