$params['id'], 'in_out' => 2, 'status' => 0 ])->findOrEmpty(); if($propertySurplusLogInfo->isEmpty()){ throw new Exception('申请中记录不存在'); } $propertySurplusLogInfo = $propertySurplusLogInfo->toArray(); $propertyHeadId = $propertySurplusLogInfo['property_head_id']; $amount = $propertySurplusLogInfo['amount']; // 更新 出账记录-已入账 PropertySurplusLog::where(['id' => $params['id']])->update(['status' => 1]); // 更新 物业负责人已提收益 PropertyHead::where(['id' => $propertyHeadId])->update(['extract_profit_amount' => Db::raw('extract_profit_amount+'.$amount)]); Db::commit(); return true; }catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * 提现取消 * @param $params * @return false|true */ public static function CancelCash($params) { Db::startTrans(); try { $propertySurplusLogInfo = PropertySurplusLog::where([ "id" => $params['id'], 'in_out' => 2, 'status' => 0 ])->findOrEmpty(); if($propertySurplusLogInfo->isEmpty()){ throw new Exception('申请中记录不存在'); } $propertySurplusLogInfo = $propertySurplusLogInfo->toArray(); $propertyHeadId = $propertySurplusLogInfo['property_head_id']; $amount = $propertySurplusLogInfo['amount']; // 更新 出账记录-取消 PropertySurplusLog::where(['id' => $params['id']])->update(['status' => 2]); // 更新 物业负责人剩余收益 金额恢复 PropertyHead::where(['id' => $propertyHeadId])->update(['surplus_profit_amount' => Db::raw('surplus_profit_amount+'.$amount)]); Db::commit(); return true; }catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 获取详情 * @param $params * @return array * @author likeadmin * @date 2024/09/20 16:17 */ public static function detail($params): array { return PropertyCommission::findOrEmpty($params['id'])->toArray(); } }