| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 | 
							- <?php
 
- namespace App\Services;
 
- use App\Models\Rebate;
 
- use App\Models\User;
 
- use Carbon\Carbon;
 
- class RebateService extends BaseService
 
- {
 
-     /**
 
-      * @description: 模型
 
-      * @return {string}
 
-      */
 
-     public static function model(): string
 
-     {
 
-         return Rebate::class;
 
-     }
 
-     /**
 
-      * @description: 枚举
 
-      * @return {*}
 
-      */
 
-     public static function enum(): string
 
-     {
 
-         return '';
 
-     }
 
-     /**
 
-      * @description: 获取查询条件
 
-      * @param {array} $search 查询内容
 
-      * @return {array}
 
-      */
 
-     public static function getWhere(array $search = []): array
 
-     {
 
-         $where = [];
 
-         if (isset($search['id']) && !empty($search['id'])) {
 
-             $where[] = ['id', '=', $search['id']];
 
-         }
 
-         if (isset($search['member_id']) && !empty($search['member_id'])) {
 
-             $where[] = ['member_id', '=', $search['member_id']];
 
-         }
 
-         if (isset($search['status']) && !empty($search['status'])) {
 
-             $where[] = ['status', '=', $search['status']];
 
-         }
 
-         if (isset($search['date']) && !empty($search['date'])) {
 
-             $where[] = ['date', '=', $search['date']];
 
-         }
 
-         return $where;
 
-     }
 
-     /**
 
-      * @description: 查询单条数据
 
-      * @param array $search
 
-      * @return \App\Models\Rebate|null
 
-      */
 
-     public static function findOne(array $search): ?Rebate
 
-     {
 
-         return self::model()::where(self::getWhere($search))->first();
 
-     }
 
-     /**
 
-      * @description: 查询所有数据
 
-      * @param array $search
 
-      * @return \Illuminate\Database\Eloquent\Collection
 
-      */
 
-     public static function findAll(array $search = [])
 
-     {
 
-         return self::model()::where(self::getWhere($search))->get();
 
-     }
 
-     /**
 
-      * @description: 分页查询
 
-      * @param array $search
 
-      * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
 
-      */
 
-     public static function paginate(array $search = [])
 
-     {
 
-         $limit = isset($search['limit']) ? $search['limit'] : 15;
 
-         $date = Carbon::now('America/New_York')->format('Y-m-d');
 
-         $paginator = self::model()::where(self::getWhere($search))
 
-             ->where('date', '<', $date)
 
-             ->with('wallet:user_id,member_id,address,available_balance')->paginate($limit);
 
-         return ['total' => $paginator->total(), 'data' => $paginator->items()];
 
-     }
 
- }
 
 
  |