BaseService.php 917 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace addons\YunfastPay\common\services;
  3. use yii\base\BaseObject;
  4. /**
  5. * class BaseService
  6. * @package addons\YunfastPay\common\services
  7. */
  8. class BaseService extends BaseObject
  9. {
  10. /**
  11. * @var int
  12. */
  13. public $mall_id;
  14. /**
  15. * @var string
  16. */
  17. protected $error_msg;
  18. public function error(string $msg)
  19. {
  20. $this->setErrorMsg($msg);
  21. return false;
  22. }
  23. public function setErrorMsg(string $msg)
  24. {
  25. $this->error_msg = $msg;
  26. }
  27. public function getErrorMsg()
  28. {
  29. return $this->error_msg;
  30. }
  31. /**
  32. * 返回交易状态码
  33. *
  34. * @param array $result
  35. * @return string
  36. */
  37. public function getTransStatus(array $result)
  38. {
  39. // 请求有错误
  40. if (empty($result['transStatus'])) {
  41. return '0';
  42. }
  43. return (string)$result['transStatus'];
  44. }
  45. }