BasePayService.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\common\service\pay;
  15. use think\facade\Log;
  16. class BasePayService
  17. {
  18. /**
  19. * 错误信息
  20. * @var string
  21. */
  22. protected $error;
  23. /**
  24. * 返回状态码
  25. * @var int
  26. */
  27. protected $returnCode = 0;
  28. /**
  29. * @notes 获取错误信息
  30. * @return string
  31. * @author 段誉
  32. * @date 2021/7/21 18:23
  33. */
  34. public function getError()
  35. {
  36. if (false === self::hasError()) {
  37. return '系统错误';
  38. }
  39. return $this->error;
  40. }
  41. /**
  42. * @notes 设置错误信息
  43. * @param $error
  44. * @author 段誉
  45. * @date 2021/7/21 18:20
  46. */
  47. public function setError($error)
  48. {
  49. $this->error = $error;
  50. }
  51. /**
  52. * @notes 是否存在错误
  53. * @return bool
  54. * @author 段誉
  55. * @date 2021/7/21 18:32
  56. */
  57. public function hasError()
  58. {
  59. return !empty($this->error);
  60. }
  61. /**
  62. * @notes 设置状态码
  63. * @param $code
  64. * @author 段誉
  65. * @date 2021/7/28 17:05
  66. */
  67. public function setReturnCode($code)
  68. {
  69. $this->returnCode = $code;
  70. }
  71. /**
  72. * @notes 特殊场景返回指定状态码,默认为0
  73. * @return int
  74. * @author 段誉
  75. * @date 2021/7/28 15:14
  76. */
  77. public function getReturnCode()
  78. {
  79. return $this->returnCode;
  80. }
  81. }