Cloud.php 4.2 KB

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