|
@@ -72,17 +72,17 @@ class SmmUserAccount extends EloquentRepository
|
|
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
- * 查找所有用户账号(只显示有效的账号)
|
|
|
|
|
|
+ * 查找当前用户下所有用户账号(只显示有效的账号)
|
|
*/
|
|
*/
|
|
public static function getUserAccounts()
|
|
public static function getUserAccounts()
|
|
{
|
|
{
|
|
$model = new Model();
|
|
$model = new Model();
|
|
- $accounts = $model->where('dist_id','>', 0)->where('parent_id','>',0)->where('expires_at','>', Carbon::now())->orderBy('parent_id', 'asc')->get();
|
|
|
|
|
|
+ $accounts = $model->where('dist_id','=', getDistributorId())->where('parent_id','>',0)->where('expires_at','>', Carbon::now())->orderBy('parent_id', 'asc')->get();
|
|
return $accounts;
|
|
return $accounts;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
- * 查找所有用户账号
|
|
|
|
|
|
+ * 查找所有用户账号 (全站账号)
|
|
*/
|
|
*/
|
|
public static function getAllYouTubeUserAccounts()
|
|
public static function getAllYouTubeUserAccounts()
|
|
{
|
|
{
|
|
@@ -114,10 +114,10 @@ class SmmUserAccount extends EloquentRepository
|
|
/*
|
|
/*
|
|
* 返回子账号数量
|
|
* 返回子账号数量
|
|
*/
|
|
*/
|
|
- public static function returnChildCount($id)
|
|
|
|
|
|
+ public static function returnChildCount($id, $distId)
|
|
{
|
|
{
|
|
$model = new Model();
|
|
$model = new Model();
|
|
- $count = $model->where('parent_id', $id)->where('expires_at','>', Carbon::now())->count();
|
|
|
|
|
|
+ $count = $model->where('parent_id', $id)->where('dist_id', $distId)->where('expires_at','>', Carbon::now())->count();
|
|
return $count;
|
|
return $count;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -133,11 +133,11 @@ class SmmUserAccount extends EloquentRepository
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- public static function deleteAccount($id)
|
|
|
|
|
|
+ public static function deleteAccount($id, $distId)
|
|
{
|
|
{
|
|
$model = new Model();
|
|
$model = new Model();
|
|
$account = $model->find($id);
|
|
$account = $model->find($id);
|
|
- if ($account && $account->dist_id == getDistributorId() && $account->parent_id > 0) {
|
|
|
|
|
|
+ if ($account && $account->dist_id == $distId && $account->parent_id > 0) {
|
|
$account->delete();
|
|
$account->delete();
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -147,11 +147,39 @@ class SmmUserAccount extends EloquentRepository
|
|
/*
|
|
/*
|
|
* 查找用户IDS中有无YouTube的帐号
|
|
* 查找用户IDS中有无YouTube的帐号
|
|
*/
|
|
*/
|
|
- public static function findYoutubeAccount($ids)
|
|
|
|
|
|
+ public static function findYoutubeAccount($ids, $distId)
|
|
{
|
|
{
|
|
$model = new Model();
|
|
$model = new Model();
|
|
$youTubeRs = $model->where('name', 'YouTube')->first();
|
|
$youTubeRs = $model->where('name', 'YouTube')->first();
|
|
- $result = $model->where('parent_id', $youTubeRs->id)->whereIn('id', $ids)->get();
|
|
|
|
|
|
+ $result = $model->where('parent_id', $youTubeRs->id)->whereIn('id', $ids)->where('dist_id', $distId)->get();
|
|
return $result;
|
|
return $result;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * 判断用户是否可以发送POST
|
|
|
|
+ * 根据IDS查找用户账号,找到是否超
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ public static function checkAccountCanSendPost($ids, $distId) {
|
|
|
|
+ $model = new Model();
|
|
|
|
+ $result = $model->whereIn('id', $ids)->where('dist_id', $distId)->get();
|
|
|
|
+ $youTubeCount = 0;
|
|
|
|
+ $twitterCount = 0;
|
|
|
|
+ foreach ($result as $row) {
|
|
|
|
+ if ($row->getParent->name == 'YouTube') {
|
|
|
|
+ $youTubeCount++;
|
|
|
|
+ }
|
|
|
|
+ if ($row->getParent->name == 'Twitter') {
|
|
|
|
+ $twitterCount++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (SmmPostLog::getPostQuota('YouTube') < $youTubeCount) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (SmmPostLog::getPostQuota('Twitter') < $twitterCount) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|