You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.4 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: xmy 280564871@qq.com
* Date: 2017/4/21
* Time: 10:51
*/
namespace Open\Model;
class BankModel extends BaseModel{
protected $_auto = [
['create_time','time',self::MODEL_INSERT,'function'],
['update_time','time',self::MODEL_BOTH,'function'],
];
protected $_validate = [
['bank','require','请选择银行',self::MUST_VALIDATE, 'regex', self::MODEL_BOTH],
['bank_name','require','开户行名称不能为空',self::MUST_VALIDATE, 'regex', self::MODEL_BOTH],
['account_name','require','账户名不能为空',self::MUST_VALIDATE, 'regex', self::MODEL_BOTH],
['bank_account','require','银行账号不能为空',self::MUST_VALIDATE, 'regex', self::MODEL_BOTH],
];
/**
* 更新银行信息
* @return bool|mixed
* author: xmy 280564871@qq.com
*/
public function update($user_id){
$data = $this->create();
if(!$data){
return false;
}
$open_data = $this->getUserData($user_id);
if(empty($open_data)){//添加
$data['dep_id'] = $user_id;
$result = $this->add($data);
}else{//编辑
$map['id'] = $open_data['id'];
$map['dep_id'] = $user_id;
$result = $this->where($map)->save($data);
}
return $result;
}
/**
* 获取用户数据
* @return mixed
* author: xmy 280564871@qq.com
*/
public function getUserData($user_id){
$map['dep_id'] = $user_id;
return $this->where($map)->find();
}
}