人人商城

display.ctrl.php 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. defined('IN_IA') or exit('Access Denied');
  7. load()->model('miniapp');
  8. load()->model('phoneapp');
  9. $dos = array('rank', 'display', 'switch', 'platform');
  10. $do = in_array($_GPC['do'], $dos) ? $do : 'display';
  11. $_W['page']['title'] = '所有权限';
  12. if ($do == 'platform') {
  13. $url = url('account/display');
  14. $last_uniacid = uni_account_last_switch();
  15. $cache_last_account_type = cache_load(cache_system_key('last_account_type'));
  16. if (empty($cache_last_account_type) || empty($last_uniacid)) {
  17. itoast('', $url, 'info');
  18. }
  19. if (!empty($last_uniacid) && $last_uniacid != $_W['uniacid']) {
  20. uni_account_switch($last_uniacid, '', $cache_last_account_type);
  21. }
  22. $permission = permission_account_user_role($_W['uid'], $last_uniacid);
  23. if (empty($permission)) {
  24. itoast('', $url, 'info');
  25. }
  26. if ($cache_last_account_type == ACCOUNT_TYPE_SIGN || $cache_last_account_type == XZAPP_TYPE_SIGN) {
  27. $url = url('home/welcome');
  28. } elseif ($cache_last_account_type == WXAPP_TYPE_SIGN) {
  29. $last_version = miniapp_fetch($last_uniacid);
  30. if (!empty($last_version)) {
  31. $url = url('miniapp/version/home', array('version_id' => $last_version['version']['id']));
  32. }
  33. } elseif ($cache_last_account_type == WEBAPP_TYPE_SIGN) {
  34. $url = url('webapp/home/display');
  35. } elseif ($cache_last_account_type == PHONEAPP_TYPE_SIGN) {
  36. $last_version = phoneapp_fetch($last_uniacid);
  37. if (!empty($last_version)) {
  38. $url = url('phoneapp/version/home', array('version_id' => $last_version['version']['id']));
  39. }
  40. } elseif ($cache_last_account_type == ALIAPP_TYPE_SIGN) {
  41. $last_version = miniapp_fetch($last_uniacid);
  42. if (!empty($last_version)) {
  43. $url = url('miniapp/version/home', array('version_id' => $last_version['version']['id']));
  44. }
  45. }
  46. itoast('', $url);
  47. }
  48. if ($do == 'display') {
  49. $account_info = permission_user_account_num($_W['uid']);
  50. if (user_is_founder($_W['uid'])) {
  51. $founders = pdo_getall('users', array('founder_groupid' => 2), array('uid', 'username'), 'uid');
  52. $founder_id = intval($_GPC['founder_id']);
  53. }
  54. $pindex = max(1, intval($_GPC['page']));
  55. $psize = 10;
  56. $title = safe_gpc_string($_GPC['title']);
  57. $type = in_array($_GPC['type'], array('all', ACCOUNT_TYPE_SIGN, WXAPP_TYPE_SIGN, WEBAPP_TYPE_SIGN, PHONEAPP_TYPE_SIGN, XZAPP_TYPE_SIGN, ALIAPP_TYPE_SIGN)) ? $_GPC['type'] : 'all';
  58. if ($type == 'all') {
  59. $title = ' 公众号/微信小程序/PC/APP/熊掌号/支付宝小程序 ';
  60. }
  61. if ($type == 'all') {
  62. $condition = array(ACCOUNT_TYPE_OFFCIAL_NORMAL, ACCOUNT_TYPE_OFFCIAL_AUTH, ACCOUNT_TYPE_APP_NORMAL, ACCOUNT_TYPE_APP_AUTH, ACCOUNT_TYPE_WEBAPP_NORMAL, ACCOUNT_TYPE_PHONEAPP_NORMAL, ACCOUNT_TYPE_XZAPP_NORMAL, ACCOUNT_TYPE_ALIAPP_NORMAL);
  63. } elseif ($type == ACCOUNT_TYPE_SIGN) {
  64. $condition = array(ACCOUNT_TYPE_OFFCIAL_NORMAL, ACCOUNT_TYPE_OFFCIAL_AUTH);
  65. } elseif ($type == WXAPP_TYPE_SIGN) {
  66. $condition = array(ACCOUNT_TYPE_APP_NORMAL, ACCOUNT_TYPE_APP_AUTH);
  67. } elseif ($type == WEBAPP_TYPE_SIGN) {
  68. $condition = array(ACCOUNT_TYPE_WEBAPP_NORMAL);
  69. } elseif ($type == PHONEAPP_TYPE_SIGN) {
  70. $condition = array(ACCOUNT_TYPE_PHONEAPP_NORMAL);
  71. } elseif ($type == XZAPP_TYPE_SIGN) {
  72. $condition = array(ACCOUNT_TYPE_XZAPP_NORMAL, ACCOUNT_TYPE_XZAPP_AUTH);
  73. } elseif ($type == ALIAPP_TYPE_SIGN) {
  74. $condition = array(ACCOUNT_TYPE_ALIAPP_NORMAL);
  75. }
  76. $keyword = safe_gpc_string($_GPC['keyword']);
  77. $letter = safe_gpc_string($_GPC['letter']);
  78. $table = table('account');
  79. $table->searchWithType($condition);
  80. $table->searchWithKeyword($keyword);
  81. $table->searchWithLetter($letter);
  82. if ($type == 'all') {
  83. $total_list = array('account' => 0, 'xzapp' => 0, 'wxapp' => 0, 'webapp' => 0, 'phoneapp' => 0, 'aliapp' => 0);
  84. $account_total = $table->searchAccounTotal(false, $founder_id);
  85. $table->searchWithType($condition);
  86. $table->searchWithKeyword($keyword);
  87. $table->searchWithLetter($letter);
  88. foreach ($account_total as $row) {
  89. if (in_array($row['type'], array(ACCOUNT_TYPE_OFFCIAL_NORMAL, ACCOUNT_TYPE_OFFCIAL_AUTH))) {
  90. $total_list['account'] += $row['total'];
  91. } elseif (in_array($row['type'], array(ACCOUNT_TYPE_XZAPP_NORMAL, ACCOUNT_TYPE_XZAPP_AUTH))) {
  92. $total_list['xzapp'] += $row['total'];
  93. } elseif (in_array($row['type'], array(ACCOUNT_TYPE_APP_NORMAL, ACCOUNT_TYPE_APP_AUTH))) {
  94. $total_list['wxapp'] += $row['total'];
  95. } elseif (in_array($row['type'], array(ACCOUNT_TYPE_WEBAPP_NORMAL))) {
  96. $total_list['webapp'] += $row['total'];
  97. } elseif (in_array($row['type'], array(ACCOUNT_TYPE_PHONEAPP_NORMAL))) {
  98. $total_list['phoneapp'] += $row['total'];
  99. } elseif (in_array($row['type'], array(ACCOUNT_TYPE_ALIAPP_NORMAL))) {
  100. $total_list['aliapp'] += $row['total'];
  101. }
  102. }
  103. }
  104. $table->accountRankOrder();
  105. $table->accountUniacidOrder();
  106. $table->searchWithPage($pindex, $psize);
  107. $list = $table->searchAccountList(false, $fields, $founder_id);
  108. $total = $table->getLastQueryTotal();
  109. $list = array_values($list);
  110. foreach($list as &$account) {
  111. $account = uni_fetch($account['uniacid']);
  112. if ($account['endtime'] > 0 && $account['endtime'] < TIMESTAMP) {
  113. $account['endtime_status'] = 1;
  114. } else {
  115. $account['endtime_status'] = 0;
  116. }
  117. switch ($account['type']) {
  118. case ACCOUNT_TYPE_APP_NORMAL :
  119. case ACCOUNT_TYPE_APP_AUTH :
  120. case ACCOUNT_TYPE_ALIAPP_NORMAL :
  121. $account['versions'] = miniapp_get_some_lastversions($account['uniacid']);
  122. if (!empty($account['versions'])) {
  123. foreach ($account['versions'] as $version) {
  124. if (!empty($version['current'])) {
  125. $account['current_version'] = $version;
  126. }
  127. }
  128. }
  129. break;
  130. case ACCOUNT_TYPE_PHONEAPP_NORMAL :
  131. $account['versions'] = phoneapp_get_some_lastversions($account['uniacid']);
  132. if (!empty($account['versions'])) {
  133. foreach ($account['versions'] as $version) {
  134. if (!empty($version['current'])) {
  135. $account['current_version'] = $version;
  136. }
  137. }
  138. }
  139. break;
  140. }
  141. }
  142. if ($_W['ispost']) {
  143. iajax(0, $list);
  144. }
  145. template('account/display');
  146. }
  147. if ($do == 'rank' && $_W['isajax'] && $_W['ispost']) {
  148. $uniacid = intval($_GPC['uniacid']);
  149. if (!empty($uniacid)) {
  150. $exist = uni_fetch($uniacid);
  151. if (!$exist) {
  152. iajax(1, '账号信息不存在', '');
  153. }
  154. }
  155. uni_account_rank_top($uniacid);
  156. iajax(0, '更新成功!', '');
  157. }
  158. if ($do == 'switch') {
  159. $uniacid = intval($_GPC['uniacid']);
  160. if (!empty($uniacid)) {
  161. $role = permission_account_user_role($_W['uid'], $uniacid);
  162. if(empty($role)) {
  163. itoast('操作失败, 非法访问.', '', 'error');
  164. }
  165. $account_info = uni_fetch($uniacid);
  166. if ($account_info['endtime'] > 0 && TIMESTAMP > $account_info['endtime'] && !user_is_founder($_W['uid'], true)) {
  167. itoast('帐号已到期。', '', 'error');
  168. }
  169. $type = $account_info['type'];
  170. $module_name = safe_gpc_string($_GPC['module_name']);
  171. $version_id = intval($_GPC['version_id']);
  172. if ($account_info->supportVersion != STATUS_ON) {
  173. if (empty($module_name)) {
  174. $url = url('home/welcome');
  175. } else {
  176. $url = url('home/welcome/ext', array('m' => $module_name));
  177. }
  178. if ($type == ACCOUNT_TYPE_WEBAPP_NORMAL) {
  179. $url = url('webapp/home/display');
  180. }
  181. } else {
  182. if (empty($version_id)) {
  183. if ($type == ACCOUNT_TYPE_PHONEAPP_NORMAL) {
  184. $versions = phoneapp_get_some_lastversions($uniacid);
  185. } else {
  186. $versions = miniapp_get_some_lastversions($uniacid);
  187. }
  188. foreach ($versions as $val) {
  189. if ($val['current']) {
  190. $version_id = $val['id'];
  191. }
  192. }
  193. }
  194. if (!empty($module_name) && !empty($version_id)) {
  195. if ($type == ACCOUNT_TYPE_PHONEAPP_NORMAL) {
  196. $version_info = phoneapp_version($version_id);
  197. } else {
  198. $version_info = table('wxapp_versions')->getById($version_id);
  199. }
  200. $module_info = array();
  201. if (!empty($version_info['modules'])) {
  202. foreach ($version_info['modules'] as $key => $module_val) {
  203. if ($module_val['name'] == $module_name) {
  204. $module_info = $module_val;
  205. }
  206. }
  207. }
  208. if (empty($module_info)) {
  209. itoast('版本信息错误');
  210. }
  211. $url = url('home/welcome/ext/', array('m' => $module_name));
  212. if (!empty($module_info['uniacid'])) {
  213. $uniacid = $module_info['uniacid'];
  214. } else {
  215. $url .= '&version_id=' . $version_id;
  216. }
  217. } elseif (in_array($type, array(ACCOUNT_TYPE_APP_NORMAL, ACCOUNT_TYPE_APP_AUTH, ACCOUNT_TYPE_ALIAPP_NORMAL))) {
  218. miniapp_update_last_use_version($uniacid, $version_id);
  219. $url = url('miniapp/version/home', array('version_id' => $version_id));
  220. } elseif ($type == ACCOUNT_TYPE_PHONEAPP_NORMAL) {
  221. phoneapp_update_last_use_version($uniacid, $version_id);
  222. $url = url('phoneapp/version/home', array('version_id' => $version_id));
  223. }
  224. }
  225. uni_account_switch($uniacid, $url, $account_info['type_sign']);
  226. }
  227. }