QappPushTaskLogs.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace App\Modules\Push\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class QappPushTaskLogs extends Model
  5. {
  6. protected $table = 'qapp_push_task_logs';
  7. protected $fillable = ['task_id', 'app_id', 'num', 'status', 'push_time', 'push_result'];
  8. /**
  9. * @param $taskId
  10. * @return array
  11. */
  12. public static function getPushTaskLogsByTaskId($taskId): array
  13. {
  14. if (empty($taskId)) {
  15. return [];
  16. }
  17. $result = self::where('task_id', $taskId)->get();
  18. return $result ? $result->toArray() : [];
  19. }
  20. /**
  21. * @param $where
  22. * @param $data
  23. * @return bool
  24. */
  25. public static function updateData($where, $data)
  26. {
  27. if (empty($where) || empty($data)) {
  28. return false;
  29. }
  30. return self::where($where)->update($data);
  31. }
  32. /**
  33. * 更新主任务状态
  34. * @param $id
  35. * @param $status
  36. * @param $result
  37. * @return bool
  38. */
  39. public static function updateSubTaskStatus($id, $status, $result = ''): bool
  40. {
  41. if (empty($id)) {
  42. return false;
  43. }
  44. $pushResult = is_string($result) ? $result : json_encode(compact('result'), JSON_UNESCAPED_UNICODE);
  45. $data = ['status' => $status, 'push_result' => $pushResult, 'updated_at' => date('Y-m-d H:i:s')];
  46. return self::where('id', $id)->update($data);
  47. }
  48. }