Cloud.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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\Modules;
  7. class Cloud extends \We7Table {
  8. protected $tableName = 'modules_cloud';
  9. protected $primaryKey = 'id';
  10. protected $field = array(
  11. 'cloud_id',
  12. 'name',
  13. 'application_type',
  14. 'title',
  15. 'title_initial',
  16. 'logo',
  17. 'version',
  18. 'install_status',
  19. 'account_support',
  20. 'wxapp_support',
  21. 'webapp_support',
  22. 'phoneapp_support',
  23. 'welcome_support',
  24. 'xzapp_support',
  25. 'aliapp_support',
  26. 'baiduapp_support',
  27. 'toutiaoapp_support',
  28. 'main_module_name',
  29. 'main_module_logo',
  30. 'has_new_version',
  31. 'has_new_branch',
  32. 'is_ban',
  33. 'modified_time',
  34. 'lastupdatetime',
  35. 'buytime',
  36. 'module_status',
  37. 'service_expire_time',
  38. 'system_shutdown_time',
  39. 'status',
  40. );
  41. protected $default = array(
  42. 'cloud_id' => 0,
  43. 'name' => '',
  44. 'application_type' => 1,
  45. 'title' => '',
  46. 'title_initial' => '',
  47. 'logo' => '',
  48. 'version' => '',
  49. 'install_status' => 0,
  50. 'account_support' => 1,
  51. 'wxapp_support' => 1,
  52. 'webapp_support' => 1,
  53. 'phoneapp_support' => 1,
  54. 'welcome_support' => 1,
  55. 'xzapp_support' => 1,
  56. 'aliapp_support' => 1,
  57. 'baiduapp_support' => 1,
  58. 'toutiaoapp_support' => 1,
  59. 'main_module_name' => '',
  60. 'main_module_logo' => '',
  61. 'has_new_version' => 0,
  62. 'has_new_branch' => 0,
  63. 'is_ban' => 0,
  64. 'modified_time' => 0,
  65. 'lastupdatetime' => 0,
  66. 'buytime' => 0,
  67. 'module_status' => 1,
  68. 'service_expire_time' => 0,
  69. 'system_shutdown_time' => 0,
  70. 'status' => 1,
  71. );
  72. public function getByName($name) {
  73. if (empty($name)) {
  74. return array();
  75. }
  76. return $this->query->where('name', $name)->get('name');
  77. }
  78. public function deleteByName($modulename) {
  79. return $this->query->where('name', $modulename)->delete();
  80. }
  81. public function getUpgradeByModuleNameList($module_name_list) {
  82. if (empty($module_name_list)) {
  83. return array();
  84. }
  85. return $this->query->where('name', $module_name_list)->where(function ($query) {
  86. $query->where('has_new_version', 1)->whereor('has_new_branch', 1);
  87. })->orderby('lastupdatetime', 'desc')->getall('name');
  88. }
  89. public function searchWithoutRecycle($support = '') {
  90. if (empty($support)) {
  91. $recycle_module = table('modules_recycle')->getall('name');
  92. } else {
  93. $recycle_module = table('modules_recycle')->where($support, 1)->getall('name');
  94. }
  95. if (!empty($recycle_module)) {
  96. $this->where('name <>', array_keys($recycle_module));
  97. }
  98. return $this;
  99. }
  100. public function getUninstallModulesBySupportType($support) {
  101. return $this->searchWithoutRecycle($support . '_support')
  102. ->where("{$support}_support", MODULE_SUPPORT_ACCOUNT)
  103. ->where('install_status', array(MODULE_LOCAL_UNINSTALL, MODULE_CLOUD_UNINSTALL))
  104. ->getall('name');
  105. }
  106. public function searchWithUninstall($local_or_cloud = 0) {
  107. if ($local_or_cloud == MODULE_LOCAL_UNINSTALL) {
  108. return $this->where('install_status', MODULE_LOCAL_UNINSTALL);
  109. } elseif ($local_or_cloud == MODULE_CLOUD_UNINSTALL) {
  110. return $this->where('install_status', MODULE_CLOUD_UNINSTALL);
  111. } else {
  112. return $this->where('install_status', array(MODULE_LOCAL_UNINSTALL, MODULE_CLOUD_UNINSTALL));
  113. }
  114. }
  115. public function searchUninstallSupport($support) {
  116. return $this->searchWithUninstall()->where($support, 2);
  117. }
  118. public function searchUninstallWithOutWelcome() {
  119. return $this->searchWithUninstall()
  120. ->where(function ($query) {
  121. $query->where('account_support', 2)
  122. ->whereor('wxapp_support', 2)
  123. ->whereor('webapp_support', 2)
  124. ->whereor('phoneapp_support', 2)
  125. ->whereor('welcome_support', 2)
  126. ->whereor('xzapp_support', 2)
  127. ->whereor('aliapp_support', 2)
  128. ->whereor('baiduapp_support', 2)
  129. ->whereor('toutiaoapp_support', 2);
  130. });
  131. }
  132. public function getUninstallModule($local_or_cloud = 0) {
  133. return $this->searchWithUninstall($local_or_cloud)
  134. ->where(function ($query) {
  135. $query->where('account_support', 2)
  136. ->whereor('wxapp_support', 2)
  137. ->whereor('webapp_support', 2)
  138. ->whereor('phoneapp_support', 2)
  139. ->whereor('welcome_support', 2)
  140. ->whereor('xzapp_support', 2)
  141. ->whereor('aliapp_support', 2)
  142. ->whereor('baiduapp_support', 2)
  143. ->whereor('toutiaoapp_support', 2);
  144. })
  145. ->orderby('lastupdatetime', 'desc')
  146. ->getall('name');
  147. }
  148. public function getUpgradeModulesBySupportType($support) {
  149. return $this->searchWithoutRecycle($support . '_support')
  150. ->where("{$support}_support", MODULE_SUPPORT_ACCOUNT)
  151. ->where(function ($query) {
  152. $query->where('has_new_version', 1)->whereor('has_new_branch', 1);
  153. })->getall('name');
  154. }
  155. }