LiveGiftService.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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\AcceptorModel;
  13. use App\Models\LiveGiftModel;
  14. use App\Models\TaskModel;
  15. use App\Models\TradeModel;
  16. use App\Services\BaseService;
  17. use Illuminate\Support\Facades\DB;
  18. /**
  19. * 承兑商管理-服务类
  20. * @author laravel开发员
  21. * @since 2020/11/11
  22. * @package App\Services\Common
  23. */
  24. class LiveGiftService extends BaseService
  25. {
  26. /**
  27. * 构造函数
  28. * @author laravel开发员
  29. * @since 2020/11/11
  30. */
  31. public function __construct()
  32. {
  33. $this->model = new LiveGiftModel();
  34. }
  35. /**
  36. * 获取列表
  37. * @param $params 参数
  38. * @param int $pageSize 分页大小:默认 15
  39. * @return array
  40. */
  41. public function getDataList($params, $pageSize = 10, $field=[])
  42. {
  43. $where = ['a.mark' => 1];
  44. $query = $this->model
  45. ->from('live_gift as a')
  46. ->where($where)
  47. ->select($field ? $field : ['a.*']);
  48. if (isset($params['name']) && $params['name'] != '') {
  49. $query->where('a.name','like',"%{$params['name']}%");
  50. }
  51. if (isset($params['status'])) {
  52. if(is_array($params['status'])){
  53. $query->whereIn('a.status',$params['status']);
  54. }else{
  55. if($params['status'] != ''){
  56. $query->where('a.status',$params['status']);
  57. }
  58. }
  59. }
  60. if (isset($params['type'])) {
  61. if(is_array($params['type'])){
  62. $query->whereIn('a.type',$params['type']);
  63. }else{
  64. if($params['type'] != ''){
  65. $query->where('a.type',$params['type']);
  66. }
  67. }
  68. }
  69. $list = $query->paginate($pageSize > 0 ? $pageSize : 9999999);
  70. $list = $list? $list->toArray() :[];
  71. if($list){
  72. foreach($list['data'] as &$item){
  73. $item['icon'] = !empty($item['icon']) ? get_image_url($item['icon']) : '';
  74. $item['file_url'] = !empty($item['file_url']) ? get_image_url($item['file_url']) : '';
  75. }
  76. }
  77. return [
  78. 'pageSize'=> $pageSize,
  79. 'total'=>isset($list['total'])? $list['total'] : 0,
  80. 'list'=> isset($list['data'])? $list['data'] : []
  81. ];
  82. }
  83. /**
  84. * 添加会编辑会员
  85. * @return array
  86. * @since 2020/11/11
  87. * @author laravel开发员
  88. */
  89. public function edit()
  90. {
  91. // 请求参数
  92. $data = request()->all();
  93. if(isset($data['icon'])){
  94. $data['icon'] = remove_image_url($data['icon']);
  95. $data['file_url'] = remove_image_url($data['file_url']);
  96. }
  97. return parent::edit($data); // TODO: Change the autogenerated stub
  98. }
  99. }