123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?php
- namespace app\common\model;
- use app\hander\HelpHander;
- use think\Db;
- use think\Exception;
- use think\Model;
- class UserBank extends Model
- {
- public function add(){
- $data = [
- 'user_id' => input('uid/d',0),
- 'card' => input('card','','trim'),
- 'card_name' => input('cardName','','trim'),
- 'address' => input('address','','trim'),
- 'type' => input('type','','trim'),
- 'certificate' => input('certificate','','trim'),
- 'use' => input('use','','trim'),
- 'remark' => input('remark','','trim'),
- ];
- $result = validate('UserBank')->check($data,[],'');
- if(true !== $result){
- HelpHander::error(validate('UserBank')->getError());
- }
- $ubase = Db::name('user_bank')->where('user_id',$data['user_id'])->find();
- if($ubase){ // 修改
- $data['update_time'] = date('Y-m-d H:i:s');
- $res = Db::name('user_bank')->where('id',$ubase['id'])->update($data);
- } else {// 新增
- $data['create_time'] = date('Y-m-d H:i:s');
- $data['update_time'] = date('Y-m-d H:i:s');
- $res = Db::name('user_bank')->insert($data);
- }
- if(!$res){
- HelpHander::error('操作失败');
- }
- return true;
- }
- public function lists($page,$size,$name,$payType,$companyId,$orgId){
- $uids = model('User')->getAdminUsers();
- if($uids){
- $map[] = ['u.id','not in',$uids];
- }
- if($name){
- $map[] = ['ui.name','like','%'.$name.'%'];
- }
- if($payType >= 0){
- $map[] = ['ui.pay_type','=',$payType];
- }
- if($companyId >= 0){
- $map[] = ['ui.company_id','=',$companyId];
- }
- $map[] = ['u.del','=',0];
- $map[] = ['r.type','=',3];
- $map[] = ['r.org_id','=',$orgId];
- $lists = Db::name('user_info')
- ->alias('ui')
- ->join('user u','ui.user_id = u.id')
- ->join('user_roles ur','ur.user_id = u.id')
- ->join('roles r','ur.roles_id = r.id')
- ->join('user_bank ub','ub.user_id = ui.user_id','left')
- ->where($map)
- ->field('u.enable,ui.user_id as uid,ui.name,ui.gender,ui.pay_type,ui.is_working,ub.*')
- ->page($page,$size)
- ->order('ui.sorts3 asc,u.id desc')
- ->select();
- $lists = $lists?$lists:[];
- $total = Db::name('user_info')
- ->alias('ui')
- ->join('user u','ui.user_id = u.id')
- ->join('user_roles ur','ur.user_id = u.id')
- ->join('roles r','ur.roles_id = r.id')
- ->join('user_bank ub','ub.user_id = ui.user_id','left')
- ->where($map)
- ->count();
- $data = [
- 'total' => $total,
- 'list' => $lists?$lists:[]
- ];
- return $data;
- }
- public function export($id){
- $info = model('SalaryRecord')->info($id);
- if($info['type'] == 5){ // 退休
- $lists = Db::name('user_retired_salary')
- ->alias('ur')
- ->join('user_info ui','ui.user_id = ur.user_id')
- ->join('user_bank ub','ub.user_id = ur.user_id','left')
- ->where('ur.salary_record_id',$id)
- ->field('ur.salary,ub.*,ui.name')
- ->order('ui.sorts3 asc,ur.id desc')
- ->select();
- } else {
- $lists = Db::name('salary_record_log')
- ->alias('ur')
- ->join('user_info ui','ui.user_id = ur.user_id')
- ->join('user_bank ub','ub.user_id = ur.user_id','left')
- ->where('ur.salary_record_id',$id)
- ->field('ur.salary,ub.*,ui.name')
- ->order('ui.sorts3 asc,ur.id desc')
- ->select();
- }
- $lists = $lists?$lists:[];
- foreach ($lists as $k=>$v){
- $lists[$k]['sn'] = $k+1;
- }
- if(in_array($info['type'],[1,2,5,6,8])){ // 中心
- $columns[] = ["title" => "账号","key" => "card"];
- $columns[] = ["title" => "户名","key" => "name"];
- $columns[] = ["title" => "金额","key" => "salary"];
- $columns[] = ["title" => "账号所属省份","key" => "address"];
- $columns[] = ["title" => "证件类型","key" => "type"];
- $columns[] = ["title" => "证件号码","key" => "certificate"];
- $columns[] = ["title" => "用途","key" => "use"];
- $columns[] = ["title" => "附言","key" => "remark"];
- }else{ // 新华
- $columns[] = ["title" => "序号","key" => "sn"];
- $columns[] = ["title" => "账号","key" => "card"];
- $columns[] = ["title" => "户名","key" => "name"];
- $columns[] = ["title" => "金额","key" => "salary"];
- $columns[] = ["title" => "跨行标识","key" => "address"];
- $columns[] = ["title" => "行名","key" => "type"];
- $columns[] = ["title" => "联行行号","key" => "certificate"];
- $columns[] = ["title" => "摘要","key" => "use"];
- $columns[] = ["title" => "备注","key" => "remark"];
- }
- $data = [
- 'columns' => $columns,
- 'list' => $lists
- ];
- return $data;
- }
- }
|