'mobile', 'cash' => 'cash', ); $this->item_type = 1; if (isset($param['isp']) && $param['isp']) { $this->item_type = $param['isp']; } return $this->submit($param, $check); } # 通知处理 主要返回状态 2是成功 3是失败 public function notify($data) { $result = array(); $result['cash'] = 1; if ($data['status'] == '001') { $result['status'] = 2; } else { $result['status'] = 3; } if (isset($data['voucherNo']) && $data['voucherNo']) { # 流水号 $data['s_nubmer'] = $result['s_nubmer'] = $data['voucherNo']; } $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['status']) && $array['status'] == '001') { # 正确 $msg = 'ok'; } else { # 错误 $msg = isset($array['status']) ? $array['status'] : '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['account'] = $this->mid; $request['consumerNo'] = $param['order']; $request['flowCode'] = $this->getCode($param['cash']); if (!$request['flowCode']) { return 'order'; } $request['timestamp'] = date('YmdHis'); $request['sign'] = $this->_sign($request); $url = $this->host . 'flow-receiver/fee/v2/recharge'; $response = $this->curl('get', $url, $request); $response = $this->response($response); $channel_order_id = ''; $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) { $signature = array($this->token, $request['timestamp'], $request['account']); sort($signature, SORT_STRING); $signature = implode($signature); $signature = sha1($signature); return $signature; } private function getCode($cash) { if ($this->item_type == 1) { if ($cash == 30) { return 'CMCCALLr30r-30'; } elseif ($cash == 50) { return 'CMCCALLr50r-50'; } elseif ($cash == 100) { return 'CMCCALLr100r-100'; } elseif ($cash == 200) { return 'CMCCALLr200r-200'; } } elseif ($this->item_type == 2) { if ($cash == 30) { return 'CUCCALLr30r-30'; } elseif ($cash == 50) { return 'CUCCALLr50r-50'; } elseif ($cash == 100) { return 'CUCCALLr100r-100'; } elseif ($cash == 200) { return 'CUCCALLr200r-200'; } } elseif ($this->item_type == 3) { if ($cash == 30) { return 'CTCCALLr30r-30'; } elseif ($cash == 50) { return 'CTCCALLr50r-50'; } elseif ($cash == 100) { return 'CTCCALLr100r-100'; } elseif ($cash == 200) { return 'CTCCALLr200r-200'; } } return false; } }