model = new \app\admin\model\users\MotorAgentWithdraw(); } /** * 显示资源列表 * * @return \think\Response * @throws \think\exception\DbException */ public function index() { $params = input(); $params['card_id'] = input('card_id/s', ''); $params['nickname'] = input('nickname/s', ''); $where = []; if ($params['nickname']) { $where['nickname'] = ['like', '%' . $params['nickname'] . '%']; } $list = $this->model // ->with(['user']) ->where($where) ->order(['id' => 'desc']) ->paginate(input('limit', 10),false); return IResponse::paginate($list); } /** * 显示创建资源表单页. * * @return \think\Response */ public function create() { // } /** * 保存新建的资源 * * @param \think\Request $request * @return \think\Response */ public function save(Request $request) { // } /** * 显示指定的资源 * * @param int $id * @return \think\Response */ public function read($id) { // } /** * 显示编辑资源表单页. * * @param int $id * @return \think\Response */ public function edit($id) { // } /** * 保存更新的资源 * * @param \think\Request $request * @param int $id * @return \think\Response */ public function update(Request $request, $id) { // } public function check($ids) { $row = $this->model->with(['user'])->find($ids); if (!$row || $row['status'] > 20) { return IResponse::failure('不可操作'); } if ($row['user']['motor_agent_money'] < $row['withdraw_amount']) { return IResponse::failure('代理合伙资产余额不足'); } $result = false; $this->model->startTrans(); try { $row->status = 30; $row->save(); $row->user->balance += $row['withdraw_amount']; $row->user->motor_agent_money -= $row['withdraw_amount']; $result = $row->user->save(); $MotorRecord = new MotorRecord(); $MotorRecord->setMoneyLog($row['user'], 'motor_agent_money', $row['withdraw_amount'], 20, '摩的代理-提现', 2); $MotorRecord->saveMoneyLog(); $this->model->commit(); } catch(Exception $e) { $this->model->rollback(); } if ($result) { return IResponse::success('成功'); } return IResponse::failure('失败'); } /** * 删除指定资源 * * @param int $id * @return \think\Response */ public function delete($id) { // } }