ExpertService.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\extra\service\blue;
  3. use app\extra\basic\Service;
  4. use app\model\blue\BlueExpert;
  5. class ExpertService extends Service
  6. {
  7. public array $source = [
  8. "douyin" => "抖音",
  9. "kuaishou" => "快手",
  10. "xiaohongshu" => "小红书",
  11. "tengxun" => "视频号"
  12. ];
  13. /**
  14. * 列表
  15. * @param array $param
  16. */
  17. public function getList(array $param = [])
  18. {
  19. $this->mode = new BlueExpert();
  20. return $this->searchVal($param,$this->searchFilter($param))->with(['platform' => function($query){
  21. $query->field("openid,source")->append(['source_name'])->withAttr(['source_name' => function($data,$resp){
  22. return $this->source[$resp['source']];
  23. }]);
  24. }])->paginate([
  25. "list_rows" => $param['pageSize'],
  26. "page" => $param['page']
  27. ]);
  28. }
  29. /**
  30. *
  31. * @param array $param
  32. * @return array
  33. */
  34. public function searchFilter(array $param = []): array
  35. {
  36. $filter = [];
  37. !empty($param['type']) && $filter[] = ["type", '=', $param['type']];
  38. !empty($param['status']) && $filter[] = ["status", '=', ($param['status']-1)];
  39. !empty($param['truename']) && $filter[] = ["truename", 'like', "%{$param['truename']}%"];
  40. return $filter;
  41. }
  42. }