<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Member\Model; use Illuminate\Database\Eloquent\Model; class MemberDataStatistic extends Model { protected $table = 'member_data_statistic'; public static function getCreateMemberUser($ULYbu) { goto PfN3M; PfN3M: $mBh0v = self::where('id', $ULYbu)->first(); goto jUVKN; jUVKN: if (empty($mBh0v)) { goto LYiXl; Pp_IY: $Kwhgm->id = $ULYbu; goto Foowl; Foowl: $Kwhgm->sizeLimit = modstart_config('Member_DataStatisticDefaultLimit', 1024); goto PZIxJ; eeeo1: self::updateMemberUserUsedSize($ULYbu); goto E60Nq; PZIxJ: $Kwhgm->save(); goto eeeo1; E60Nq: return self::getCreateMemberUser($ULYbu); goto gCwiu; LYiXl: $Kwhgm = new self(); goto Pp_IY; gCwiu: } goto lzOWE; lzOWE: return $mBh0v->toArray(); goto jZ4hP; jZ4hP: } public static function updateMemberUser($ULYbu, $U8wjN) { goto HBxO5; zkViH: $Kwhgm->save(); goto DotFH; AgxaT: foreach ($U8wjN as $kEhTf => $y2Ltn) { $Kwhgm->{$kEhTf} = $y2Ltn; } goto zkViH; HBxO5: $Kwhgm = self::where('id', $ULYbu)->first(); goto yMjIe; yaQ0V: if (empty($Kwhgm)) { goto G7mT4; G7mT4: $Kwhgm = new self(); goto s76PC; s76PC: $Kwhgm->id = $ULYbu; goto FOY36; FOY36: $T_iud = true; goto tQue0; tQue0: } goto AgxaT; yMjIe: $T_iud = false; goto yaQ0V; DotFH: if ($T_iud) { self::updateMemberUserUsedSize($ULYbu); } goto cmmX_; cmmX_: } public static function calcMemberUserUsedSize($ULYbu) { $ahibX = MemberUpload::where(array('userId' => $ULYbu))->leftJoin('data', 'data.id', '=', 'member_upload.dataId')->sum('data.size'); return intval($ahibX); } public static function updateMemberUserUsedSize($ULYbu) { $chyCL = array('sizeUsed' => self::calcMemberUserUsedSize($ULYbu)); self::where('id', $ULYbu)->update($chyCL); } }