BasePayService.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LikeShop有特色的全开源社交分销电商系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 商业用途务必购买系统授权,以免引起不必要的法律纠纷
  7. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  8. // | 微信公众号:好象科技
  9. // | 访问官网:http://www.likemarket.net
  10. // | 访问社区:http://bbs.likemarket.net
  11. // | 访问手册:http://doc.likemarket.net
  12. // | 好象科技开发团队 版权所有 拥有最终解释权
  13. // +----------------------------------------------------------------------
  14. // | Author: LikeShopTeam-段誉
  15. // +----------------------------------------------------------------------
  16. namespace app\common\service\pay;
  17. use think\facade\Log;
  18. class BasePayService
  19. {
  20. /**
  21. * 错误信息
  22. * @var string
  23. */
  24. protected $error;
  25. /**
  26. * 返回状态码
  27. * @var int
  28. */
  29. protected $returnCode = 0;
  30. /**
  31. * @notes 获取错误信息
  32. * @return string
  33. * @author 段誉
  34. * @date 2021/7/21 18:23
  35. */
  36. public function getError()
  37. {
  38. if (false === self::hasError()) {
  39. return '系统错误';
  40. }
  41. return $this->error;
  42. }
  43. /**
  44. * @notes 设置错误信息
  45. * @param $error
  46. * @author 段誉
  47. * @date 2021/7/21 18:20
  48. */
  49. public function setError($error)
  50. {
  51. $this->error = $error;
  52. // $class = app('request')->controller();
  53. // $action = app('request')->action();
  54. // $errorMsg = $class.'/'.$action.'-'.$error;
  55. // Log::write('支付错误:'.$errorMsg);
  56. }
  57. /**
  58. * @notes 是否存在错误
  59. * @return bool
  60. * @author 段誉
  61. * @date 2021/7/21 18:32
  62. */
  63. public function hasError()
  64. {
  65. return !empty($this->error);
  66. }
  67. /**
  68. * @notes 设置状态码
  69. * @param $code
  70. * @author 段誉
  71. * @date 2021/7/28 17:05
  72. */
  73. public function setReturnCode($code)
  74. {
  75. $this->returnCode = $code;
  76. }
  77. /**
  78. * @notes 特殊场景返回指定状态码,默认为0
  79. * @return int
  80. * @author 段誉
  81. * @date 2021/7/28 15:14
  82. */
  83. public function getReturnCode()
  84. {
  85. return $this->returnCode;
  86. }
  87. }