GoodsGatherLists.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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\adminapi\lists\goods;
  20. use app\adminapi\lists\BaseAdminDataLists;
  21. use app\common\enum\YesNoEnum;
  22. use app\common\lists\ListsExtendInterface;
  23. use app\common\model\GoodsGather;
  24. class GoodsGatherLists extends BaseAdminDataLists implements ListsExtendInterface
  25. {
  26. /**
  27. * @notes 搜索条件
  28. * @return array
  29. * @author ljj
  30. * @date 2023/3/14 9:59 上午
  31. */
  32. public function where()
  33. {
  34. $where[] = ['log_id','=',$this->params['log_id']];
  35. $status = (isset($this->params['status']) && $this->params['status'] != '') ? $this->params['status'] : 0;
  36. $where[] = ['status','=',$status];
  37. return $where;
  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 ljj
  46. * @date 2023/3/14 10:02 上午
  47. */
  48. public function lists(): array
  49. {
  50. $lists = GoodsGather::field('id,gather_url,gather_info,gather_status,channel,create_time,status')
  51. ->append(['goods_info','gather_status_desc','channel_desc'])
  52. ->hidden(['gather_info','channel'])
  53. ->where(self::where())
  54. ->limit($this->limitOffset, $this->limitLength)
  55. ->order('id desc')
  56. ->select()
  57. ->toArray();
  58. return $lists;
  59. }
  60. /**
  61. * @notes 商品采集数量
  62. * @return int
  63. * @author ljj
  64. * @date 2023/3/14 10:03 上午
  65. */
  66. public function count(): int
  67. {
  68. return GoodsGather::where(self::where())->count();
  69. }
  70. /**
  71. * @notes 数据统计
  72. * @return array
  73. * @author ljj
  74. * @date 2023/3/14 10:06 上午
  75. */
  76. public function extend()
  77. {
  78. return [
  79. 'wait' => GoodsGather::where(['log_id'=>$this->params['log_id'],'status'=>YesNoEnum::NO])->count(),
  80. 'already' => GoodsGather::where(['log_id'=>$this->params['log_id'],'status'=>YesNoEnum::YES])->count(),
  81. ];
  82. }
  83. }