|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Distributor\Repositories;
|
|
|
|
|
|
+use App\Libraries\CommonHelper;
|
|
|
use App\Models\SmmPostLog as Model;
|
|
|
use Carbon\Carbon;
|
|
|
use Dcat\Admin\Repositories\EloquentRepository;
|
|
@@ -57,20 +58,11 @@ class SmmPostLog extends EloquentRepository
|
|
|
Log::info('有正在发送中的帖子,返回[]');
|
|
|
return [];
|
|
|
}
|
|
|
- //找出是否有帖子正在上传到Oss如果有,则不发送
|
|
|
-// $ossUploadPost = SmmPost::getOssUploadPost();
|
|
|
-//
|
|
|
-// if ($ossUploadPost->isNotEmpty()) {
|
|
|
-// Log::info('有帖子正在上传到oss,不发送帖子');
|
|
|
-// return [];
|
|
|
-// }
|
|
|
-
|
|
|
//找出待发送与发送失败的日志,重试2次
|
|
|
$result = $log->wherein('status', [0,3])->where('request_count', '<=', 2)->where('send_time', '<', Carbon::now())->limit($limit)->get();
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/*
|
|
|
* 计算Twitter月配额,每月只能发送100个帖子,(只限发送帖子,其他接口,每个用户1个请求,15分钟内只允许发送一次)
|
|
|
* 全站统计
|
|
@@ -172,4 +164,65 @@ class SmmPostLog extends EloquentRepository
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 得到当前用户要发送帖子的日志
|
|
|
+ */
|
|
|
+ public static function getSendLogDist($limit = 5)
|
|
|
+ {
|
|
|
+ $log = new Model();
|
|
|
+ $result = $log->where('status', 1)->where('dist_id', getDistributorId())->first();//查找状态为1的日志,发送中的日志
|
|
|
+ if ($result) {
|
|
|
+ //updated_at与当前时间差距30分钟以上,则更新日志状态为3
|
|
|
+ $nowTime = Carbon::now();
|
|
|
+ $diffTime = $nowTime->diffInMinutes($result->updated_at);
|
|
|
+ if ($diffTime >= 30) {
|
|
|
+ Log::info('发送中的帖子超过30分钟,更新状态为3,发送失败');
|
|
|
+ $result->status = 3;
|
|
|
+ $result->save();
|
|
|
+ }
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ //找出待发送与发送失败的日志,重试2次
|
|
|
+ //$result = $log->wherein('status', [0,3])->where('request_count', '<=', 10)->where('send_time', '<', Carbon::now())->where('dist_id', getDistributorId())->limit($limit)->get();
|
|
|
+ $result = $log->where('id',22)->get();
|
|
|
+ $resultArray = $result->toArray();
|
|
|
+ foreach ($result as $k => $v) {
|
|
|
+ $image_video_url = explode(',', $v->post->image_video_url);
|
|
|
+ $tmp = [];
|
|
|
+ foreach ($image_video_url as $key => $value) {
|
|
|
+ $tmp[] = CommonHelper::ossUrl($value);
|
|
|
+ }
|
|
|
+ $image_video_url = implode(',', $tmp);
|
|
|
+ $resultArray[$k]['message'] = $v->post->message;
|
|
|
+ $resultArray[$k]['post_type'] = $v->post->post_type;
|
|
|
+ $resultArray[$k]['image_video_url'] = $image_video_url;
|
|
|
+ $resultArray[$k]['cookie_data'] = $v->account->cookie_data;
|
|
|
+ $resultArray[$k]['account_id'] = $v->account->account_id;
|
|
|
+ $resultArray[$k]['post_backup_field1'] = $v->post->backup_field1;
|
|
|
+ }
|
|
|
+ return $resultArray;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function updateSendLogDist($id, $status, $request_count = 0,$remark = '')
|
|
|
+ {
|
|
|
+ $log = new Model();
|
|
|
+ $result = $log->where('id', $id)->first();
|
|
|
+ if ($result) {
|
|
|
+ $result->status = $status;
|
|
|
+ $request_count = intval($request_count);
|
|
|
+ if ($request_count > 0) {
|
|
|
+ $result->request_count = $request_count;
|
|
|
+ } else {
|
|
|
+ $result->request_count = $result->request_count + 1;
|
|
|
+ }
|
|
|
+ $result->remark = $remark;
|
|
|
+ $result->save();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
}
|