| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Services\Common;
- use App\Models\MemberBankModel;
- use App\Services\BaseService;
- /**
- * 用户银行卡管理-服务类
- * @author laravel开发员
- * @since 2020/11/11
- * Class MemberBankService
- * @package App\Services\Common
- */
- class MemberBankService extends BaseService
- {
- // 静态对象
- protected static $instance = null;
- /**
- * 构造函数
- * @author laravel开发员
- * @since 2020/11/11
- * MemberBankService constructor.
- */
- public function __construct()
- {
- $this->model = new MemberBankModel();
- }
- /**
- * 静态入口
- * @return static|null
- */
- public static function make()
- {
- if (!self::$instance) {
- self::$instance = (new static());
- }
- return self::$instance;
- }
- /**
- * 列表数据
- * @param $params
- * @param int $pageSize
- * @return array
- */
- public function getDataList($params, $pageSize = 15)
- {
- $where = ['a.mark' => 1];
- $status = isset($params['status']) ? $params['status'] : 0;
- if ($status > 0) {
- $where['a.status'] = $status;
- }
- $userId = isset($params['user_id']) ? $params['user_id'] : 0;
- if ($userId > 0) {
- $where['a.user_id'] = $userId;
- }
- $userType = isset($params['user_type']) ? $params['user_type'] : 0;
- if ($userType > 0) {
- $where['a.user_type'] = $userType;
- }
- $list = $this->model->from('member_banks as a')
- ->where($where)
- ->where(function($query) use($params){
- $keyword = isset($params['keyword'])? trim($params['keyword']) : '';
- if($keyword){
- $query->where('a.realname','like',"%{$keyword}%")
- ->orWhere('a.bank_name','like',"%{$keyword}%")
- ->orWhere('a.bank_card','like',"%{$keyword}%");
- }
- })
- ->select(['a.*'])
- ->orderBy('a.create_time', 'desc')
- ->orderBy('a.id', 'desc')
- ->paginate($pageSize > 0 ? $pageSize : 9999999);
- $list = $list ? $list->toArray() : [];
- if ($list) {
- foreach ($list['data'] as &$item) {
- $item['create_time'] = $item['create_time'] ? datetime($item['create_time'], 'Y-m-d H.i.s') : '';
- $item['bank_card_text'] = $item['bank_card'] ? format_bank_card($item['bank_card']) : '';
- $item['name_text'] = $item['bank_name'] ? mb_substr($item['bank_name'],0,1,'utf-8') : '';
- $item['icon'] = get_image_url('/images/icons/banks/icon-'.$item['bank_code'].'.png');
- }
- }
- return [
- 'pageSize' => $pageSize,
- 'total' => isset($list['total']) ? $list['total'] : 0,
- 'list' => isset($list['data']) ? $list['data'] : []
- ];
- }
- /**
- * @return array|false
- */
- public function delete()
- {
- $this->model->where(['mark'=>0])->where('update_time','<=', time() - 3*86400)->delete();
- return parent::delete();
- }
- }
|