Job.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. namespace We7\Table\Core;
  7. class Job extends \We7Table {
  8. protected $tableName = 'core_job';
  9. protected $primaryKey = 'id';
  10. protected $field = array(
  11. 'type',
  12. 'uniacid',
  13. 'payload',
  14. 'status',
  15. 'title',
  16. 'handled',
  17. 'total',
  18. 'createtime',
  19. 'updatetime',
  20. 'endtime',
  21. 'uid',
  22. 'isdeleted',
  23. );
  24. protected $default = array(
  25. 'type' => '',
  26. 'uniacid' => '0',
  27. 'payload' => '',
  28. 'status' => '0',
  29. 'title' => '',
  30. 'handled' => '0',
  31. 'total' => '0',
  32. 'createtime' => TIMESTAMP,
  33. 'updatetime' => TIMESTAMP,
  34. 'endtime' => '0',
  35. 'uid' => '0',
  36. 'isdeleted' => '0',
  37. );
  38. const DELETE_ACCOUNT = 10;
  39. const SYNC_FANS = 20;
  40. public function createDeleteAccountJob($uniacid, $accountName, $total, $uid) {
  41. $exits_job = $this->exitsJob($uniacid, self::DELETE_ACCOUNT);
  42. if ($exits_job) {
  43. return $exits_job['id'];
  44. }
  45. $this->fill(array(
  46. 'type' => self::DELETE_ACCOUNT,
  47. 'title'=> "删除{$accountName}的素材数据",
  48. 'uniacid'=>$uniacid,
  49. 'total'=> $total,
  50. 'uid'=>$uid
  51. ));
  52. if ($this->save()) {
  53. return pdo_insertid();
  54. } else {
  55. return false;
  56. }
  57. }
  58. public function exitsJob($uniacid, $type) {
  59. $result = self::getQuery()
  60. ->where('uniacid', $uniacid)
  61. ->where('type', $type)
  62. ->get();
  63. return !empty($result);
  64. }
  65. public function clear($uid, $isfounder) {
  66. $this->where('status', 1)->fill('isdeleted', 1);
  67. if (!$isfounder) {
  68. $this->where('uid', $uid);
  69. }
  70. return $this->save();
  71. }
  72. }