截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\api\logic;
  3. use app\common\basics\Logic;
  4. use app\common\enum\AdEnum;
  5. use app\common\model\Ad;
  6. use think\facade\Db;
  7. use app\common\server\UrlServer;
  8. class AdLogic extends Logic
  9. {
  10. public static function lists($pid,$terminal)
  11. {
  12. $ad_list = Ad::alias('a')
  13. ->join('ad_position ap', 'a.pid = ap.id')
  14. ->where(['pid' => $pid, 'ap.terminal' => $terminal, 'a.status' => 1, 'a.del' => 0, 'ap.status' => 1, 'ap.del' => 0])
  15. ->field('a.*')
  16. ->order('a.sort asc, a.id desc')
  17. ->select()
  18. ->toArray();
  19. $list = [];
  20. foreach ($ad_list as $key => $ad) {
  21. $url = $ad['link'];
  22. $is_tab = 0;
  23. $params = [];
  24. switch ($ad['link_type']) {
  25. case 1: // 商城页面
  26. $page = AdEnum::getLinkPage($ad['terminal'], $ad['link']);
  27. $url = $page['path'];
  28. $is_tab = $page['is_tab'] ?? 0;
  29. break;
  30. case 2: // 商品页面
  31. $goods_path = AdEnum::getGoodsPath($ad['terminal']);
  32. $url = $goods_path;
  33. $params = [
  34. 'id' => $ad['link'],
  35. ];
  36. break;
  37. }
  38. $list[] = [
  39. 'image' => UrlServer::getFileUrl($ad['image']),
  40. 'link' => $url,
  41. 'link_type' => $ad['link_type'],
  42. 'params' => $params,
  43. 'is_tab' => $is_tab,
  44. ];
  45. }
  46. return $list;
  47. }
  48. }