select('cash,available_cash')-> where('account_identity', $accountId)->find(); $newCash = array( 'cash' => $userInfo['cash'] + $money, 'available_cash' => $userInfo['available_cash'] + $money, ); $res = M('account_detailed')->where('account_identity', $accountId)->update($newCash); if ($res > 0) { return 1; } else { return -1; } } else { //用户资金明细、余额变更 $moneyInfo = M('fund_detailed')->select('account_identity,money,status')->where('order_id', $orderId)->find(); if ($moneyInfo['status'] == 1) { return 1; } $userInfo = M('account_detailed')->select('cash,available_cash')-> where('account_identity', $moneyInfo['account_identity'])->find(); $newCash = array( 'cash' => $userInfo['cash'] + $moneyInfo['money'], 'available_cash' => $userInfo['available_cash'] + $moneyInfo['money'], ); $sw = new DBExtension(); $sw->B(); $sw->ST('fund_detailed')->W('order_id', $orderId)->U(array('status' => 1, 'cur_cash' => $newCash['available_cash'])); $sw->ST('account_detailed')->W('account_identity', $moneyInfo['account_identity'])->U($newCash); $res = $sw->C(); if ($res) { return 1; } else { return -1; } } } }