当前位置: 首页 > news >正文

事务的操作

 //批量淘汰-----和待定-----批量婉拒 ------的操作
    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

相关文章:

  • [转].net中SessionState相关配置
  • 分享Kali Linux 2016.2第50周镜像文件
  • 静态缓存和动态缓存
  • 编解码-java序列化
  • 富文本控件
  • RAID 详解
  • magento 重写controller、model、block
  • JS for循环 闭包
  • iOS开发UI篇—CAlayer层的属性(转摘)
  • 微软职位内部推荐-Sr SDE
  • 1 - Static Template
  • java jar bat 运行
  • 快递接口——调用分析对比
  • FormsAuthentication实现登录(转)
  • php实现微信推广海报代码示例
  • -------------------- 第二讲-------- 第一节------在此给出链表的基本操作
  • 【Amaple教程】5. 插件
  • 【干货分享】SpringCloud微服务架构分布式组件如何共享session对象
  • 2017年终总结、随想
  • Git 使用集
  • github从入门到放弃(1)
  • Javascripit类型转换比较那点事儿,双等号(==)
  • Laravel 菜鸟晋级之路
  • MQ框架的比较
  • Redash本地开发环境搭建
  • Redis 懒删除(lazy free)简史
  • RedisSerializer之JdkSerializationRedisSerializer分析
  • spring boot下thymeleaf全局静态变量配置
  • Storybook 5.0正式发布:有史以来变化最大的版本\n
  • 当SetTimeout遇到了字符串
  • 分享一份非常强势的Android面试题
  • 给初学者:JavaScript 中数组操作注意点
  • 深度解析利用ES6进行Promise封装总结
  • 使用阿里云发布分布式网站,开发时候应该注意什么?
  • 树莓派 - 使用须知
  • Salesforce和SAP Netweaver里数据库表的元数据设计
  • 测评:对于写作的人来说,Markdown是你最好的朋友 ...
  • 哈罗单车融资几十亿元,蚂蚁金服与春华资本加持 ...
  • 湖北分布式智能数据采集方法有哪些?
  • 说说我为什么看好Spring Cloud Alibaba
  • 昨天1024程序员节,我故意写了个死循环~
  • # 日期待t_最值得等的SUV奥迪Q9:空间比MPV还大,或搭4.0T,香
  • #我与Java虚拟机的故事#连载18:JAVA成长之路
  • (14)Hive调优——合并小文件
  • (Java实习生)每日10道面试题打卡——JavaWeb篇
  • (Python) SOAP Web Service (HTTP POST)
  • (react踩过的坑)Antd Select(设置了labelInValue)在FormItem中initialValue的问题
  • (SpringBoot)第二章:Spring创建和使用
  • (待修改)PyG安装步骤
  • (译) 函数式 JS #1:简介
  • (转)Groupon前传:从10个月的失败作品修改,1个月找到成功
  • (转)Linq学习笔记
  • (转载)跟我一起学习VIM - The Life Changing Editor
  • .dwp和.webpart的区别
  • .mat 文件的加载与创建 矩阵变图像? ∈ Matlab 使用笔记