博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
事务的操作
阅读量:6509 次
发布时间:2019-06-24

本文共 3378 字,大约阅读时间需要 11 分钟。

//批量淘汰-----和待定-----批量婉拒 ------的操作    public function beatchOperation($params = array() ){        $fstatus = $params['fstatus'];        $action = $params['action']; ;        $action_str = '' ;        $action_id = $params['action_id'];        $sourceInterview = new Source_Interview();        $action_id = $sourceInterview->getActionIdByParams($action_id);        if(empty($action_id)){            return array('code' => -3 , 'msg' =>Common::GetLangStr('resume_action_choose','company' ));        }        $action_str = $action_id ;        $action_ids = explode(",", $action_id);        if(count($action_ids) > 50 ){            return array('code' => -3 , 'msg' =>Common::GetLangStr('resume_action_num_max','company' ));        }        $actionModel = new ActionModel();        $deliveryLogModel = new DeliveryLogModel();        $actionData = $actionModel->getActionDataById($action_id);        if(empty($actionData)){            return array('code' =>0, 'msg' => Common::GetLangStr('resume_action_choose','company' ));        }        $c_user_id = 0 ;//企业的id        $c_user_id = isset($actionData[0]['c_user_id']) ? $actionData[0]['c_user_id'] : 0 ;        if(empty($c_user_id)){            return array('code' =>0, 'msg' =>"error company ");        }        //查询企业的帐号状态        $userModel = new UserModel();        $cUser = $userModel->getUserDataById($c_user_id , "*");        if(empty($cUser)){            return array('code' =>0, 'msg' =>"error company..");        }        if($cUser['fstatus'] != 1 ){            $notActive = array(                'email' => $cUser['email'],                'email_check' => $cUser['email_check'],                'mobile' => $cUser['mobile'],                'c_user_id' => $c_user_id,            ) ;                        return array('code' => -1002 , 'msg' =>Common::GetLangStr('account_not_active','user' ),'data' => $notActive);        }        $object = $this->db(0);        $now = date('Y-m-d H:i:s', time());        $deliveryLog = array();        try{            $object->beginTransaction() ; //开始事物             $sql = "update {$object->dbprefix}action set fstatus = '{$fstatus}' ,interview_status = '1' ,updatetime='{$now}' where id in ($action_str)" ;            $num = $object->Exec($sql);            if($num <= 0  ){                throw new Exception(Common::GetLangStr('resume_action_error','company' ) );             }            foreach ($actionData as $key => $value ) {                $deliveryLog[]=array(                    'user_id' => $value['p_user_id'],                    'action_id' => $value['id'],                    'add_time' => $now,                    'action' => $action,                );            }            $dNum = $deliveryLogModel->addAllDeliveryLog($deliveryLog);            if($dNum <= 0 ){                throw new Exception(Common::GetLangStr('resume_action_add_log_error','company' ) );            }            //修改action表中的那个最终的状态            if($fstatus == 4 ){                $actionModel->updateDeliveryAstatus($action_str,4);            }            $object->commit();//事物提交哦            return array('code' => 1 , 'msg' => Common::GetLangStr('resume_action_operation_success','company' ));        }catch(Exception $e){            $object->rollBack();             return array('code'=>-4 , 'msg'=>$e->getMessage());         }

此代码是PC端接口调用的内部代码

转载于:https://www.cnblogs.com/xs-yqz/p/6164651.html

你可能感兴趣的文章
LVS+keepalived+nginx
查看>>
monkey如何通过uiautomatorviewer的bounds坐标点击控件
查看>>
第22章,mysql数据库-1
查看>>
【亲测】教你如何搭建 MongoDB 复制集 + 选举原理
查看>>
网络文件共享-SAMBA
查看>>
虚拟化网络技术
查看>>
阿里云中间件推出全新开发者服务
查看>>
56.随机产生的id重复问题
查看>>
一个快速检测系统CPU负载的小程序
查看>>
java.lang.IllegalArgumentException: No bean specified
查看>>
Wireshark and Tcpdump tips
查看>>
第一课 计算机及操作系统基础知识
查看>>
windows2003单域迁移到2008R2服务器
查看>>
cacti相关资料网站
查看>>
我的友情链接
查看>>
网站的开发流程介绍(转)
查看>>
java面向对象中的方法重载与方法重写的区别
查看>>
浅析:Android--Fragment的懒加载
查看>>
Linux操作系统目录和Linux常用的文件和目录管理命令
查看>>
shell运算(加、减、乘、除)
查看>>