<?php

namespace app\extra\service\blue;

use app\extra\basic\Service;
use app\model\blue\BlueUserBank;

class UserBankService extends Service
{


    /**
     * 列表
     * @param array $param
     */
    public function getList(array $param = [])
    {
        $this->mode = new BlueUserBank();
        return $this->searchVal($param,$this->searchFilter($param))->append(['bank_img'])->withAttr(['bank_img' => function($data,$resp){
            return "https://apimg.alipay.com/combo.png?d=cashier&t={$resp['bank_code']}";
        }])->paginate([
            "list_rows" => $param['pageSize'],
            "page"      => $param['page']
        ]);
    }


    /**
     *
     * @param array $param
     * @return array
     */
    public function searchFilter(array $param = []): array
    {
        $filter = [];
        !empty($param['openid']) && $filter[] = ["openid", '=', $param['openid']];
        !empty($param['status']) && $filter[] = ["status", '=', ($param['status']-1)];
        !empty($param['truename']) && $filter[] = ["truename", 'like', "%{$param['truename']}%"];
        !empty($param['nick']) && $filter[] = ["nickname", 'like', "%{$param['nick']}%"];
        !empty($param['source']) && $filter[] = ["source", '=', $param['source']];
        return $filter;
    }

}