SettleQueue.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /**
  3. * SettleQueue.php UTF-8
  4. * 提现队列
  5. *
  6. * @date : 2018/10/10 11:39
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HuoMp 1.0
  11. */
  12. namespace huo\controller\queue;
  13. use huo\controller\common\Base;
  14. use huolib\queue\constant\ClassConst;
  15. use huolib\queue\constant\JobConst;
  16. use huolib\status\CommonStatus;
  17. use think\Queue;
  18. class SettleQueue extends Base {
  19. protected $param = [];
  20. protected $job_class = '';
  21. protected $job_name = '';
  22. public function __construct($s_data = []) {
  23. $this->job_class = ClassConst::CLASS_SETTLE_FIRE;
  24. $this->job_name = JobConst::JOB_SETTLE;
  25. $this->param = $s_data;
  26. $this->param['ts'] = time();
  27. }
  28. /**
  29. * 返回数据
  30. *
  31. * @param int $code
  32. * @param array $data
  33. *
  34. * @return array
  35. */
  36. protected function retSucMsg($code = CommonStatus::NO_ERROR, $data = []) {
  37. /* 数据录入LOG */
  38. $this->param['queue'] = '1';
  39. return $this->huoSuccess($code, CommonStatus::getMsg($code), $data);
  40. }
  41. /**
  42. * 返回数据
  43. *
  44. * @param $code
  45. *
  46. * @return array|mixed
  47. */
  48. protected function retErrMsg($code = CommonStatus::PUSH_QUEUE_ERROR) {
  49. /* 数据录入LOG */
  50. $this->param['queue'] = '0';
  51. return $this->huoError($code, CommonStatus::getMsg($code));
  52. }
  53. /**
  54. * 入队列
  55. *
  56. * @return array
  57. */
  58. public function pushQueue() {
  59. if (class_exists('think\\Queue')) {
  60. $_is_pushed = Queue::push($this->job_class, $this->param, $this->job_name);
  61. if ($_is_pushed === false) {
  62. return $this->retErrMsg();
  63. }
  64. }
  65. return $this->retSucMsg();
  66. }
  67. /**
  68. * @return array
  69. */
  70. public function getParam() {
  71. return $this->param;
  72. }
  73. /**
  74. * @param array $param
  75. */
  76. public function setParam($param) {
  77. $this->param = $param;
  78. }
  79. /**
  80. * @return string
  81. */
  82. public function getJobClass() {
  83. return $this->job_class;
  84. }
  85. /**
  86. * @param string $job_class
  87. */
  88. public function setJobClass($job_class) {
  89. $this->job_class = $job_class;
  90. }
  91. /**
  92. * @return string
  93. */
  94. public function getJobName() {
  95. return $this->job_name;
  96. }
  97. /**
  98. * @param string $job_name
  99. */
  100. public function setJobName($job_name) {
  101. $this->job_name = $job_name;
  102. }
  103. }