Ad.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop开源商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | gitee下载:https://gitee.com/likeshop_gitee
  7. // | github下载:https://github.com/likeshop-github
  8. // | 访问官网:https://www.likeshop.cn
  9. // | 访问社区:https://home.likeshop.cn
  10. // | 访问手册:http://doc.likeshop.cn
  11. // | 微信公众号:likeshop技术社区
  12. // | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
  13. // | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
  14. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  15. // | likeshop团队版权所有并拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshop.cn.team
  18. // +----------------------------------------------------------------------
  19. namespace app\shop\controller\decoration;
  20. use app\common\basics\ShopBase;
  21. use app\common\enum\ShopAdEnum;
  22. use app\common\model\shop\ShopAd;
  23. use app\common\model\shop\ShopCategory;
  24. use app\common\model\shop\ShopGoodsCategory;
  25. use app\common\server\JsonServer;
  26. use app\shop\logic\decoration\ShopAdLogic;
  27. use think\response\Json;
  28. use think\response\View;
  29. class Ad extends ShopBase
  30. {
  31. /**
  32. * @notes 广告列表
  33. * @return Json|View
  34. * @author lbzy
  35. * @datetime 2023-12-05 10:06:46
  36. */
  37. function lists()
  38. {
  39. if ($this->request->isAjax()) {
  40. return JsonServer::success('', ShopAdLogic::lists($this->request->get(), $this->shop_id));
  41. }
  42. return view();
  43. }
  44. /**
  45. * @notes 新增广告
  46. * @return Json|View
  47. * @author lbzy
  48. * @datetime 2023-12-05 11:58:07
  49. */
  50. function add()
  51. {
  52. if ($this->request->isAjax()) {
  53. $result = ShopAdLogic::add(input(), $this->shop_id);
  54. if ($result) {
  55. return JsonServer::success('添加成功');
  56. }
  57. return JsonServer::error(ShopAdLogic::getError() ? : '添加失败');
  58. }
  59. return view('', [
  60. 'placeList' => ShopAdEnum::getPlaceDesc(),
  61. 'terminalList' => ShopAdEnum::getTerminal(),
  62. ]);
  63. }
  64. /**
  65. * @notes 编辑广告
  66. * @return Json|View
  67. * @author lbzy
  68. * @datetime 2023-12-05 11:58:17
  69. */
  70. function edit()
  71. {
  72. if ($this->request->isAjax()) {
  73. $result = ShopAdLogic::edit(input(), $this->shop_id);
  74. if ($result) {
  75. return JsonServer::success('编辑成功');
  76. }
  77. return JsonServer::error(ShopAdLogic::getError() ? : '编辑失败');
  78. }
  79. return view('', [
  80. 'info' => ShopAd::where('id', input('id/d'))->where('shop_id', $this->shop_id)->findOrEmpty()->toArray(),
  81. 'placeList' => ShopAdEnum::getPlaceDesc(),
  82. 'terminalList' => ShopAdEnum::getTerminal(),
  83. ]);
  84. }
  85. /**
  86. * @notes 设置状态
  87. * @return Json
  88. * @author lbzy
  89. * @datetime 2023-12-05 11:59:01
  90. */
  91. function status()
  92. {
  93. if ($this->request->isAjax()) {
  94. ShopAdLogic::status(input(), $this->shop_id);
  95. return JsonServer::success('成功');
  96. }
  97. }
  98. /**
  99. * @notes 删除广告
  100. * @return Json
  101. * @author lbzy
  102. * @datetime 2023-12-05 11:58:34
  103. */
  104. function delete()
  105. {
  106. if ($this->request->isAjax()) {
  107. ShopAdLogic::delete(input(), $this->shop_id);
  108. return JsonServer::success('成功');
  109. }
  110. }
  111. /**
  112. * @notes 选择链接
  113. * @return Json|View
  114. * @author lbzy
  115. * @datetime 2023-12-05 18:33:00
  116. */
  117. function select_link()
  118. {
  119. if ($this->request->isAjax()) {
  120. return JsonServer::success('');
  121. }
  122. return view('', [
  123. 'links' => ShopAdEnum::getLinkPage(),
  124. 'shopLinkPaths' => ShopAdEnum::getShopLinkPaths(),
  125. 'goodsCategoryList' => ShopGoodsCategory::where('shop_id', $this->shop_id)->where('is_show', 1)->select()->toArray(),
  126. 'select_link' => input('link/s', ''),
  127. 'getShopGoodsListPath' => ShopAdEnum::getShopGoodsListPath(),
  128. 'getShopGoodsCategoryPath' => ShopAdEnum::getShopGoodsCategoryPath(),
  129. ]);
  130. }
  131. }