From 09776fc9069ac5f95e543530493328d88dd6b0b7 Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Wed, 4 Sep 2019 14:08:01 +0800 Subject: [PATCH] add clear --- wx/Recharge.php | 2 +- wx/Result.php | 39 +++++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/wx/Recharge.php b/wx/Recharge.php index 8c05f2f..f129218 100644 --- a/wx/Recharge.php +++ b/wx/Recharge.php @@ -151,7 +151,7 @@ class Recharge extends Miniprogarampage $this->request->setCallback(function ($data) { $array = Help::toArray($data); if ($array['result_code'] != 'SUCCESS') { - $data = ['code' => 500, 'message' => $array['err_code_des']]; + $data = ['code' => $array['err_code'], 'message' => $array['err_code_des']]; } else { $data = ['code' => 0, 'message' => '支付成功']; } diff --git a/wx/Result.php b/wx/Result.php index 0614cff..4718930 100644 --- a/wx/Result.php +++ b/wx/Result.php @@ -19,17 +19,17 @@ class Result public $count = 0; public $data; public $header; - + public function __construct(array $data) { foreach ($data as $key => $val) { $this->$key = $val; } - + $this->header = $this->reloadResponse($this->header); } - - + + /** * @param $header * @@ -50,20 +50,20 @@ class Result } return $data; } - + public function __get($name) { return $this->$name; } - - + + public function __set($name, $value) { $this->$name = $value; - + return $this; } - + public function getTime() { return [ @@ -72,7 +72,7 @@ class Result 'runTime' => $this->runTime, ]; } - + /** * @param $key * @param $data @@ -87,13 +87,16 @@ class Result $this->$key = $data; return $this; } - - + + public function isResultsOK() { + if (!is_numeric($this->code)) { + return false; + } return $this->code == 0; } - + /** * @param array $headers * 批量设置返回头 @@ -104,7 +107,7 @@ class Result $this->setHeader($key, $val); } } - + /** * @param $key * @param $val @@ -114,7 +117,7 @@ class Result { header($key . ':' . $val); } - + /** * @param string $name * @return mixed @@ -129,7 +132,7 @@ class Result } return $this->data; } - + /** * @param $key * @param $data @@ -140,12 +143,12 @@ class Result $this->data[$key] = $data; return $this; } - + public function getMessage() { return $this->message; } - + public function getCode() { return $this->code;