'phone', 'cash' => 'amount', 'operator'=>'operator', 'isSlow'=>'isSlow' ); $param['operator'] = '1'; if (isset($param['isp']) && $param['isp']) { if($param['isp'] == 1){ $param['operator']= $param['isp']; }elseif($param['isp'] == 2){ $param['operator']= 3; }elseif ($param['isp'] == 3){ $param['operator'] = 2; } } // $param['nProductClass']=1; $param['isSlow']=1; $this->api = 'upper/order/api/createNewOrder'; return $this->submit($param, $check); } # 通知处理 主要返回状态 2是成功 3是失败 public function notify($data) { $request = $data; $result = array(); $result['cash'] = 1; $result['status'] = 4; if ($data['rechargeStatus'] == 2) { $result['status'] = 2; } else if($data['rechargeStatus'] == 3) { $result['status'] = 3; }else { $result['status'] = 4; } if (isset($data['certNo']) && $data['certNo']) { # 流水号 $data['s_nubmer'] = $result['s_nubmer'] = $data['certNo']; } $result['yes'] = '{"code":200,"msg":"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'] == '200') { # 正确 $msg = 'ok'; } // } else { # 错误 $msg = $array['desc'] ?? 'error'; } return array ( 'msg' => $msg, 'data' => $data, 'array' => $array, ); } # 订单查询 # 查询余额接口 public function account($day) { $request['day'] = $day; $request['appid'] = $this->mid; $request['api_product'] = 'query'; $this->token = $this->mid . '|' . $this->token; $request = $this->getParam($request, $this->token); $url = $this->host . 'api/old/queryBalance'; $response = $this->curl('post', $url, $request); $response = $this->response($response); return $response['array']['data']; } # 查询接口 public function query($order) { $request['szAgentId'] = $this->mid; $request['szOrderId'] = $order['order_id']; $request['szVerifyString'] = $this->_sign($request, array('szAgentId', 'szOrderId')); $request['szFormat'] = 'json'; $url = $this->host . 'api/old/queryorder'; $response = $this->curl('post', $url, $request); $log['type'] = 'query_response'; $log['data'] = $response; $log['config'] = $this->data; $this->log($log); $array = $this->json_decode($response); $result = array(); $result['status'] = 4; if (isset($array['nRtn']) ) { if($array['nRtn'] == '5012'){ $result['nFlag'] = 2; $result['status'] = 2; }elseif ($array['nRtn'] == '5013'){ $result['nFlag'] = 3; $result['status'] = 3; } if (isset($array['szRtnMsg']) && $array['szRtnMsg']) { # 流水号 // $data['szRtnMsg'] $result['szRtnMsg'] = $array['szRtnMsg']; } } return $result; } # 提交数据 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['thirdOrderNo'] = $param['order']; $request['time'] = time(); $request['createdTime'] = $request['time']; $request['_sign'] = $this->_sign($request); $url = $this->host . $this->api; $response = $this->curl('post', $url, $request); $response = $this->response($response); $channel_order_id = ''; // if (isset($response['array']['szRtnCode']) && $response['array']['szRtnCode'] != 'success') { // #警告类型 // $channel_order_id = $response['array']['szRtnCode']; // } // $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) { ksort($request); $signature_string = ''; foreach ($request as $k => $v) { if (isset($v) && $v) { $signature_string .= $k . '=' . $v . '&'; } } $signature_string .='key='. $this->token; // var_dump($signature_string);die; return md5($signature_string); } }