PerformanceRulesLists.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\lists\performance;
  15. use app\adminapi\lists\BaseAdminDataLists;
  16. use app\common\model\goods_category\GoodsCategory;
  17. use app\common\model\performance\PerformanceRules;
  18. use app\common\lists\ListsSearchInterface;
  19. /**
  20. * PerformanceRules列表
  21. * Class PerformanceRulesLists
  22. * @package app\adminapi\listsperformance
  23. */
  24. class PerformanceRulesLists extends BaseAdminDataLists implements ListsSearchInterface
  25. {
  26. /**
  27. * @notes 设置搜索条件
  28. * @return \string[][]
  29. * @author likeadmin
  30. * @date 2024/07/15 17:52
  31. */
  32. public function setSearch(): array
  33. {
  34. return [
  35. '=' => ['type', 'create_time', 'update_time'],
  36. '%like%' => ['goods_category_ids'],
  37. ];
  38. }
  39. /**
  40. * @notes 获取列表
  41. * @return array
  42. * @throws \think\db\exception\DataNotFoundException
  43. * @throws \think\db\exception\DbException
  44. * @throws \think\db\exception\ModelNotFoundException
  45. * @author likeadmin
  46. * @date 2024/07/15 17:52
  47. */
  48. public function lists(): array
  49. {
  50. $data = PerformanceRules::where($this->searchWhere)
  51. ->field(['id', 'goods_category_ids', 'type', 'rate', 'create_time', 'update_time'])
  52. ->limit($this->limitOffset, $this->limitLength)
  53. ->order(['id' => 'desc'])
  54. ->select()
  55. ->toArray();
  56. $goodsCategoryObj = GoodsCategory::where(['status'=>1])->order(['pid' => 'asc','weigh' => 'desc', 'id' => 'desc'])
  57. ->select();
  58. foreach ($data as &$datum) {
  59. $datum['goods_category_ids_str_arr'] = $goodsCategoryObj->whereIn('id',$datum['goods_category_ids'])->column('name');
  60. }
  61. return $data;
  62. }
  63. /**
  64. * @notes 获取数量
  65. * @return int
  66. * @author likeadmin
  67. * @date 2024/07/15 17:52
  68. */
  69. public function count(): int
  70. {
  71. return PerformanceRules::where($this->searchWhere)->count();
  72. }
  73. }