人人商城

Cloud.php 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. 'main_module_name',
  25. 'main_module_logo',
  26. 'has_new_version',
  27. 'has_new_branch',
  28. 'is_ban',
  29. 'lastupdatetime',
  30. );
  31. protected $default = array(
  32. 'name' => '',
  33. 'title' => '',
  34. 'title_initial' => '',
  35. 'logo' => '',
  36. 'version' => '',
  37. 'install_status' => 0,
  38. 'account_support' => 1,
  39. 'wxapp_support' => 1,
  40. 'webapp_support' => 1,
  41. 'phoneapp_support' => 1,
  42. 'welcome_support' => 1,
  43. 'xzapp_support' => 1,
  44. 'aliapp_support' => 1,
  45. 'main_module_name' => '',
  46. 'main_module_logo' => '',
  47. 'has_new_version' => 0,
  48. 'has_new_branch' => 0,
  49. 'is_ban' => 0,
  50. 'lastupdatetime' => 0,
  51. );
  52. public function getByName($name) {
  53. if (empty($name)) {
  54. return array();
  55. }
  56. return $this->query->where('name', $name)->get('name');
  57. }
  58. public function getUpgradeByModuleNameList($module_name_list, $account_type = ACCOUNT_TYPE_SIGN) {
  59. if (empty($module_name_list)) {
  60. return array();
  61. }
  62. return $this->query->where('name', $module_name_list)->where(function ($query){
  63. $query->where('has_new_version', 1)->whereor('has_new_branch', 1);
  64. })->orderby('lastupdatetime', 'desc')->getall('name');
  65. }
  66. public function searchWithoutRecycle() {
  67. return $this->query->from('modules_cloud', 'a')->select('a.*')->leftjoin('modules_recycle', 'b')->on(array('a.name' => 'b.name'))->where('b.name', 'NULL');
  68. }
  69. public function getUninstallTotalBySupportType($support) {
  70. return $this->searchWithoutRecycle()->where('a.' . $support. '_support', MODULE_SUPPORT_ACCOUNT)->where('install_status', array(MODULE_LOCAL_UNINSTALL, MODULE_CLOUD_UNINSTALL))->getcolumn('COUNT(*)');
  71. }
  72. public function deleteByName($modulename) {
  73. return $this->query->where('name', $modulename)->delete();
  74. }
  75. public function getUninstallModule() {
  76. return $this->searchWithoutRecycle()->where(function ($query){
  77. $query->where('a.install_status', MODULE_LOCAL_UNINSTALL)->whereor('a.install_status', MODULE_CLOUD_UNINSTALL);
  78. })->orderby('a.lastupdatetime', 'desc')->getall('a.name');
  79. }
  80. public function getUpgradeTotalBySupportType($support) {
  81. return $this->searchWithoutRecycle()->where('a.' . $support. '_support', 2)->where(function ($query){
  82. $query->where('a.has_new_version', 1)->whereor('a.has_new_branch', 1);
  83. })->getcolumn('COUNT(*)');
  84. }
  85. }