GoodsCategoryService.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Services\Common;
  12. use App\Models\GoodsCategoryModel;
  13. use App\Models\GoodsModel;
  14. use App\Services\BaseService;
  15. /**
  16. * 承兑商管理-服务类
  17. * @author laravel开发员
  18. * @since 2020/11/11
  19. * @package App\Services\Common
  20. */
  21. class GoodsCategoryService extends BaseService
  22. {
  23. /**
  24. * 构造函数
  25. * @author laravel开发员
  26. * @since 2020/11/11
  27. */
  28. public function __construct()
  29. {
  30. $this->model = new GoodsCategoryModel();
  31. }
  32. /**
  33. * 获取列表
  34. * @param $params 参数
  35. * @param int $pageSize 分页大小:默认 15
  36. * @return array
  37. */
  38. public function getDataList($params, $pageSize = 10, $field = [])
  39. {
  40. $where = ['a.mark' => 1];
  41. $query = $this->model
  42. ->from('goods_category as a')
  43. ->where($where)
  44. ->select($field ? $field : ['a.*']);
  45. if (isset($params['status']) && $params['status'] != '') {
  46. $query->where('a.status',$params['status']);
  47. }
  48. if (isset($params['is_recommend']) && $params['is_recommend'] != '') {
  49. $query->where('a.is_recommend',$params['is_recommend']);
  50. }
  51. if (isset($params['name']) && $params['name'] != '') {
  52. $query->where('a.name','like',"%{$params['name']}%");
  53. }
  54. $list = $query->paginate($pageSize > 0 ? $pageSize : 9999999);
  55. $list = $list ? $list->toArray() : [];
  56. if ($list) {
  57. // foreach($list['data'] as &$item){
  58. //// $item['create_time_text'] = $item['create_time']? datetime($item['create_time']):'';
  59. // }
  60. }
  61. return [
  62. 'pageSize' => $pageSize,
  63. 'total' => isset($list['total']) ? $list['total'] : 0,
  64. 'list' => isset($list['data']) ? $list['data'] : [],
  65. ];
  66. }
  67. /**
  68. * 添加会编辑会员
  69. * @return array
  70. * @since 2020/11/11
  71. * @author laravel开发员
  72. */
  73. public function edit()
  74. {
  75. // 请求参数
  76. $data = request()->all();
  77. return parent::edit($data); // TODO: Change the autogenerated stub
  78. }
  79. }