AutoreplyService.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Bear
  5. * Date: 2020/6/19
  6. * Time: 上午11:52
  7. */
  8. namespace app\main\service;
  9. use app\main\constants\ApiConstants;
  10. class AutoreplyService extends BaseService
  11. {
  12. /**
  13. * @var AutoreplyService
  14. */
  15. protected static $self = null;
  16. /**
  17. * @return $this
  18. */
  19. public static function instance()
  20. {
  21. if (self::$self == null) {
  22. self::$self = new self();
  23. }
  24. return self::$self;
  25. }
  26. /**
  27. * 获取迁移后的数据
  28. * @param $ids
  29. * @return \app\main\model\object\ReturnObject
  30. */
  31. public function getMigrateData($ids)
  32. {
  33. $list = [];
  34. $data = ApiService::instance()->getCollectFromApi(ApiConstants::API_KEYWORDS, ['ids' => $ids])->data;
  35. foreach ($ids as $id) {
  36. $list[$id] = [
  37. 'uv' => 0,
  38. 'subscribe' => 0,
  39. 'money' => 0,
  40. ];
  41. }
  42. if ($data) {
  43. foreach ($data as $item) {
  44. $list[$item['aid']] = [
  45. 'uv' => $item['uv'],
  46. 'subscribe' => $item['subscribe'],
  47. 'money' => $item['money'],
  48. ];
  49. }
  50. }
  51. return $this->setData($list)->getReturn();
  52. }
  53. }