0,'account_yesterday' => 0,'case_out_money' => 0]; $data['user_money'] = MasterWorker::where('id',$params['worker_id'])->value('user_money') ?? 0; $where = []; $where[] = ['worker_id','=',$params['worker_id']] ; $where[] = ['change_type', '=', WorkerAccountLogEnum::UM_INC_ADMIN]; $where[] = ['action', '=',WorkerAccountLogEnum::INC]; $where[] = ['create_time','between',[$ytime,$yetime]]; $data['account_yesterday']= MasterWorkerAccountLog::where($where) ->sum('change_amount'); $data['case_out_money']= MasterWorkerCaseOutLog::where([ 'worker_id'=>$params['worker_id'], 'review_status' => 1, ])->sum('change_amount'); return $data; } catch(\Exception $e){ self::setError($e->getMessage()); return false; } } public static function monthAccountWithCaseOutTotal($params) { try{ $month = $params['month']; $firstDay = date("Y-m-d 00:00:00", strtotime("first day of {$month}")); $lastDay = date("Y-m-d 23:59:59", strtotime("{$month} +1 month -1 day")); $firstTime = strtotime($firstDay); $lastTime = strtotime($lastDay); $where = []; $where[] = ['worker_id','=',$params['worker_id']] ; $where[] = ['create_time','between',[$firstTime,$lastTime]]; $data= []; $incAccountWhere[] = $where+[ ['change_type', '=', WorkerAccountLogEnum::UM_INC_ADMIN], ['action', '=',WorkerAccountLogEnum::INC], ]; $data['account_amount_inc_total'] = MasterWorkerAccountLog::where($incAccountWhere) ->sum('change_amount'); $decAccountWhere[] = $where+[ ['change_type', '=', WorkerAccountLogEnum::UM_DEC_ADMIN], ['action', '=',WorkerAccountLogEnum::DEC], ]; $data['account_amount_dec_total'] = MasterWorkerAccountLog::where($decAccountWhere) ->sum('change_amount'); $data['account_amount_total'] = $data['account_amount_inc_total'] - $data['account_amount_dec_total']; $caseOutWhere = $where+[ ['review_status','=',1] ]; $data['case_out_total'] = MasterWorkerCaseOutLog::where($caseOutWhere)->sum('change_amount'); return $data; }catch(\Exception $e){ self::setError($e->getMessage()); return false; } } }