'telephone', 'cash' => 'cash', ); $this->api = 'phone-charge-order/create'; $this->api_type = 1; return $this->submit($param, $check); } # 中石油油卡充值 拼音来吧 public function zsycz($param) { $check = array ( 'card' => 'oilAccount', 'cash' => 'amount', 'mobile' => 'oilPhone', ); if (isset($param['mobile']) && $param['mobile']) { } else { $mobile = $this->randomMobile(); $param['mobile'] = $mobile[0]; } $this->api = 'oil-charge-order/create'; $this->api_type = 2; return $this->submit($param, $check); } # 中石化油卡充值 public function zshcz($param) { $check = array ( 'card' => 'oilAccount', 'cash' => 'cash', 'mobile' => 'oilPhone', ); if (isset($param['mobile']) && $param['mobile']) { } else { $mobile = $this->randomMobile(); $param['mobile'] = $mobile[0]; } $this->api = 'oil-charge-order/create'; $this->api_type = 3; return $this->submit($param, $check); } # 通知处理 主要返回状态 2是成功 3是失败 public function notify($data) { $result = array(); $result['cash'] = 1; if ($data['status'] == 5) { $result['status'] = 2; } elseif ($data['status'] == 10) { $result['status'] = 3; } else { $result['status'] = 4; } if (isset($data['transactionId']) && $data['transactionId']) { # 流水号 //$data['s_nubmer'] = $result['s_nubmer'] = $data['transactionId']; } $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'] == '200') { $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']; unset($request['cash']); $request['outTradeNo'] = $param['order']; $request['notifyUrl'] = $this->getNotify($param['order'], 1); $request['goodsId'] = $this->getGoodsId($param['cash']); $headers['appId'] = $this->mid; $headers['sign'] = strtoupper($this->sign($request, 'md5', '&key=' . $this->token)); $url = $this->host . $this->api; $response = $this->curl('post', $url, $request, true, $headers); $response = $this->response($response); $channel_order_id = ''; if (isset($response['array']['data'])) { $channel_order_id = $response['array']['data']; } $this->create($param['order'], $channel_order_id, $param['merchant_order'], $param['cash'], $url, $request, $response, 1, $param['account']); return $response['msg']; } private function getGoodsId($cash) { if ($this->api_type == 1) { if ($cash == 200) { return 1132; } elseif ($cash == 100) { return 1131; } elseif ($cash == 50) { return 1130; } } elseif ($this->api_type == 2) { } elseif ($this->api_type == 3) { if ($cash == 500) { return 1135; } elseif ($cash == 200) { return 1134; } elseif ($cash == 100) { return 1133; } } return 1; } }