model = new TaxiUser(); } /** * @desc 审核司机 * @param $ids * @throws \think\exception\PDOException * @author weichuanbao<654745815@qq.com> * @date 2021/12/7 0007 */ public function check($ids) { $row = $this->model::get($ids); if (!$row) { IResponse::failure('记录不存在'); } if(!$row['user_id'] || !model('common/users')->where(['id'=> $row['user_id']])->find()){ IResponse::failure('未绑定用户账号'); } $result = false; $this->model->startTrans(); try { $row->status = 5; $result = $row->save(); $this->model->commit(); } catch(Exception $e) { $this->model->rollback(); } if ($result) { IResponse::success([],'成功'); } IResponse::failure('失败'); } /** * 用户批量操作 * * @author 许祖兴 < zuxing.xu@lettered.cn> * @date 2020/6/11 14:34 * * @return mixed */ public function plectron(){ // 收参数 $params = $this->request->param(); foreach (str2arr($params['ids']) as $id){ $user = model('common/Users')->getBy($id); if ($this->request->isDelete()){ $user->deleteBy($id); } //表里不存ids这个字段,要把ids改回表对应的字段名:id //user这个模型没有updateBy这个方法,所以回报错,既然循环,也不可能直接单个id对应 // $user->allowField(true)->updateBy($id, $params); //懒得去补模型的方法了,我直接用原生写法对表操作了。 //2022-3-3 丘 改动 //判断 原状态 和 修改致状态 未交费之前 冻结,启用动作 都忽略; $olduser=Db::table('ins_users_motor_agent')->where('id',$id)->find(); if(!$olduser){ return IResponse::failure('用户不存在!'); } if( $params['status']==40){ if($olduser['status']<40){ //没有通过交费 啥也不做 }else{ //做解冻,或冬季操作 $res=Db::table('ins_users_motor_agent')->update(['status' => $params['status'],'id'=>$id]); } } if( $params['status']==50){ if($olduser['status']<40){ //没有通过交费 啥也不做 }else{ //做解冻,或冬季操作 $res=Db::table('ins_users_motor_agent')->update(['status' => $params['status'],'id'=>$id]); } } } return IResponse::success([],'操作成功'); } /** * @desc 发放合伙资产 * @param $ids * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException * @author weichuanbao<654745815@qq.com> * @date 2022/1/7 0007 */ public function partnership($ids) { $row = $this->model->with('user')->find($ids); if (!$row) { IResponse::failure('记录不存在'); } $params = input(); $params['amount'] = input('amount', 0); if(floatval($params['amount'])<=0){ IResponse::failure('请输入合法资产金额'); } $MotorRecord = new MotorRecord(); $result = false; $this->model->startTrans(); try { if(!$row->user->id){ IResponse::failure('该司机未绑定用户'); } $row->user->taxi_property += $params['amount']; $result = $row->user->save(); if(!$result){ $this->model->rollback(); IResponse::failure('发放失败'); } $MotorRecord->setMoneyLog($row['user'], 'taxi_property', $params['amount'], 30, '发放通证资产'); $MotorRecord->saveMoneyLog(); $this->model->commit(); } catch(Exception $e) { $this->model->rollback(); IResponse::failure($e->getMessage()); } if ($result) { IResponse::success([],'成功'); }else{ IResponse::failure('失败'); } } }