123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace app\common\model;
- use app\hander\HelpHander;
- use think\Db;
- use think\Exception;
- use tools\Idcard;
- class PhUser extends Base
- {
- public function updates($orgId){
- $data = request()->post();
- if(!$data['user']){
- $this->error = '请选择负责人';
- return false;
- }
- if(!$data['dep']){
- $this->error = '请选择负责部门';
- return false;
- }
- $id = $data['id'];
- unset($data['id']);
- Db::startTrans();
- try{
- if($id > 0){
- $res = $this->where('id',$id)
- ->update($data);
- if(!$res){
- \exception('更新失败');
- }
- }else{
- $data['org_id'] = $orgId;
- $data['create_time'] = date('Y-m-d H:i:s');
- $ret = $this->allowField(true)->insert($data);
- if(!$ret){
- \exception('操作失败');
- }
- }
- Db::commit();
- return true;
- }catch (Exception $e){
- Db::rollback();
- $this->error = $e->getMessage();
- return false;
- }
- }
- }
|