MachineService.php 3.2 KB

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