| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace app\common\service;
- use app\common\model\WithdrawAccountModel;
- use app\common\model\YsBankListModel;
- use utils\RedisCache;
- /**
- * 提现账号 by wes
- * Class WithdrawAccountService
- * @package app\common\service
- */
- class WithdrawAccountService
- {
- protected static $instance = null;
- protected $model = null;
- public function __construct()
- {
- $this->model = new WithdrawAccountModel();
- }
- /**
- * 静态化入口
- * @return static|null
- */
- public static function make()
- {
- if (!self::$instance) {
- self::$instance = new static();
- }
- return self::$instance;
- }
- /**
- * 获取银行卡列表
- * @param $uid 查询参数
- * @param string $field
- * @param string $cache
- * @return array|mixed
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function getListByUser($uid, $type=0, $field = '', $cache=true)
- {
- $cacheKey = "caches:temp:withdrawAccount:{$uid}_{$type}" . md5($field);
- $data = RedisCache::get($cacheKey);
- if ($data && $cache) {
- return $data;
- }
- $where = ['uid'=> $uid];
- if($type){
- $where['type'] = $type;
- }
- $field = $field ? $field : 'id,name,number,bank_subname,create_time';
- $data = $this->model->where($where)->where(['is_del' => 2])
- ->field($field)
- ->select();
- $data = $data? $data->toArray() : [];
- if($data && $cache){
- RedisCache::set($cacheKey, $data, 5,10);
- }
- return $data;
- }
- }
|