payResp.php 983 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Description of payResp.php
  4. * 返回值基类, 统一的序列化到字符串的方法, json_encode...
  5. * @version
  6. * 1.0.0 Created at 2017-12-22. by --gwang
  7. * @author gwang (mail@wanggangzero.cn)
  8. * @copyright ? 2017-12-22, SJZ LoyalSoft Corporation & gwang. All rights reserved.
  9. */
  10. class payResp {
  11. public $err = 0;
  12. public $ret = 1;
  13. public $msg = "OK";
  14. public static function ok($ret = 0) {
  15. $resp = new payResp();
  16. $resp->err = 0;
  17. $resp->ret = $ret;
  18. return $resp;
  19. }
  20. public static function err($err_no, $msg) {
  21. $resp = new payResp();
  22. $resp->err = $err_no;
  23. $resp->msg = $msg;
  24. return $resp;
  25. }
  26. public function __toString() {
  27. return $this->toString();
  28. }
  29. public function toString() {
  30. // var_dump(\JsonUtil::encode($this));
  31. $str = loyalsoft\JsonUtil::encode($this);
  32. return $str;
  33. // return \gzdeflate($str);
  34. }
  35. }