'ChargeAccount', 'cash' => 'ChargeValue', 'OrderType' => 'OrderType', ); $param['OrderType'] = 1; $this->ChargeType = 3;//1.联通 2.电信 3.移动 4.Q币 5.网易 6.DNF 7.LOL 8.石油 9.石化 10.抖音 if (isset($param['isp']) && $param['isp']) { if ($param['isp'] == 1) { $this->ChargeType = 3; } elseif ($param['isp'] == 2) { $this->ChargeType = 1; } elseif ($param['isp'] == 3) { $this->ChargeType = 2; } } return $this->submit($param, $check); } # 中石油油卡充值 拼音来吧 public function zsycz($param) { $check = array ( 'card' => 'ChargeAccount', 'cash' => 'ChargeValue', 'OrderType' => 'OrderType', ); $param['OrderType'] = 4; $this->ChargeType = 8; return $this->submit($param, $check); } # 中石化油卡充值 public function zshcz($param) { $check = array ( 'card' => 'ChargeAccount', 'cash' => 'ChargeValue', 'OrderType' => 'OrderType', ); $param['OrderType'] = 4; $this->ChargeType = 9; return $this->submit($param, $check); } # 通知处理 主要返回状态 2是成功 3是失败 public function notify($data) { $post = $this->aes_decrypt($data['PostData'], $this->token, '1111111111111111'); $post = strstr($post,'}',true) . "}"; $data = json_decode($post, true); /* $sign = $this->_sign($request, array('orderNo', 'partnerOrderNo')); if ($sign != $data['sign']) { return false; } */ $result = array(); $result['cash'] = 1; if ($data['Status'] == 3) { $result['status'] = 2; } elseif ($data['Status'] == 2) { $result['status'] = 3; } else { $result['status'] = 4; } if (isset($data['OperatorSerialNumber']) && $data['OperatorSerialNumber']) { # 流水号 $data['s_nubmer'] = $result['s_nubmer'] = $data['OperatorSerialNumber']; } $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'] == '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; } $post = $param['detail']; $post['SupBuyNum'] = 1; $post['ChargeType'] = $this->ChargeType; $post['Id'] = $param['order']; $request['data'] = $this->aes_encrypt(json_encode($post), $this->token, 1111111111111111); $request['mchid'] = $this->mid; $request['notifyurl'] = $this->getNotify($param['order'], 1); $url = $this->host . $this->api; $response = $this->curl('post', $url, $request); $response = $this->response($response); $channel_order_id = ''; if (isset($response['array']['data']['trans_sn'])) { $channel_order_id = $response['array']['data']['trans_sn']; } $this->create($param['order'], $channel_order_id, $param['merchant_order'], $param['cash'], $url, $request, $response, 1, $param['account']); return $response['msg']; } private function aes_encrypt($data, $key, $iv = '') { $str_padded = $data; if (strlen($str_padded) % 16) { $str_padded = str_pad($str_padded,strlen($str_padded) + 16 - strlen($str_padded) % 16, "\0"); } $data = openssl_encrypt($str_padded, 'AES-128-CBC', $key, OPENSSL_NO_PADDING, $iv); return base64_encode($data); } //AES-128-ECB解密 data 字符串 private function aes_decrypt($data, $key, $iv = '') { $encrypted = base64_decode($data); return openssl_decrypt($encrypted, 'AES-128-CBC', $key, OPENSSL_NO_PADDING, $iv); } }