'uuid', 'cash' => 'itemFace', ); $this->card_type = 30; return $this->submit($param, $check); } # 中石化油卡充值 public function dhcz($param) { $check = array ( 'mobile' => 'uuid', 'cash' => 'itemFace', ); $this->card_type = 3; if (isset($param['isp']) && $param['isp']) { if ($param['isp'] == 1) { $this->card_type = 3; } elseif ($param['isp'] == 2) { $this->card_type = 4; } elseif ($param['isp'] == 3) { $this->card_type = 5; } } return $this->submit($param, $check); } # 中石油油卡充值 拼音来吧 public function zsycz($param) { $check = array ( 'card' => 'uuid', 'cash' => 'itemFace', 'mobile' => 'ext1', 'idCard' => 'ext2', 'realName' => 'ext3', ); $this->card_type = 2; return $this->submit($param, $check); } # 中石化油卡充值 public function zshcz($param) { $check = array ( 'card' => 'uuid', 'cash' => 'itemFace', ); $this->card_type = 1; return $this->submit($param, $check); } # 通知处理 主要返回状态 2是成功 3是失败 public function notify($data) { $request = $data; unset($request['sign']); unset($request['s_order']); $request['appSecret'] = $this->token; $sign = $this->_sign($request); if ($sign != $data['sign']) { //return false; } $result = array(); $result['cash'] = 1; if ($data['orderStatus'] == 2) { $result['status'] = 2; } elseif ($data['orderStatus'] == 3) { $result['status'] = 3; } else { $result['status'] = 4; } if (isset($data['ext1']) && $data['ext1']) { # 错误信息 $msg = $data['msg'] = $result['msg'] = urldecode($data['ext1']); # 流水号 if (strstr($data['msg'], '订单号:')) { $temp = explode('订单号:', $data['msg']); $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'] == '00') { # 正确 $msg = 'ok'; } else { # 错误 $msg = $array['msg']; } 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['appId'] = $this->mid; $request['outOrderId'] = $param['order']; if ($this->card_type == 30) { $request['itemId'] = 100028; $request['amount'] = $request['itemFace']; $request['itemFace'] = 1; } else { $request['itemId'] = $this->getGid($param['cash']); if (!$request['itemId'] || $request['itemId'] == -1) { $request['itemId'] = $this->getCode($param['cash']); } } $request['timestamp'] = date('YmdHisu'); $request['callbackUrl'] = $this->getNotify($param['order'], 1); $request['appSecret'] = $this->token; $url = $this->host . $this->api; $request['sign'] = $this->_sign($request, 'md5'); unset($request['appSecret']); $response = $this->curl('post', $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 _sign($request) { ksort($request); $signature_string = array(); foreach ($request as $k => $v) { $signature_string[] .= $k . '=' . $v; } $signature_string = implode('&', $signature_string); return md5($signature_string); } private function getCode($cash) { if ($this->card_type == 1) { if ($cash == 100) { return 100005; } elseif ($cash == 200) { return 100006; } elseif ($cash == 500) { return 100007; } elseif ($cash == 1000) { return 100008; } } elseif ($this->card_type == 2) { if ($cash == 500) { return 100001; } elseif ($cash == 1000) { return 100002; } elseif ($cash == 2000) { return 100003; } } elseif ($this->card_type == 3) { if ($cash == 30) { return 100002; } elseif ($cash == 50) { return 100007; } elseif ($cash == 100) { return 100003; } elseif ($cash == 200) { return 100004; } elseif ($cash == 300) { return 100005; } elseif ($cash == 500) { return 100006; } } elseif ($this->card_type == 4) { if ($cash == 30) { return 100008; } elseif ($cash == 50) { return 100009; } elseif ($cash == 100) { return 100010; } elseif ($cash == 200) { return 100011; } elseif ($cash == 300) { return 100012; } elseif ($cash == 500) { return 100013; } } elseif ($this->card_type == 5) { if ($cash == 30) { return 100014; } elseif ($cash == 50) { return 100015; } elseif ($cash == 100) { return 100016; } elseif ($cash == 200) { return 100017; } elseif ($cash == 300) { return 100018; } elseif ($cash == 500) { return 100019; } } return 1; } }