Goodsalbum.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. /*
  3. * 空间管理
  4. */
  5. namespace app\admin\controller;
  6. use think\facade\View;
  7. use think\facade\Lang;
  8. /**
  9. *
  10. *
  11. * ----------------------------------------------------------------------------
  12. *
  13. * 控制器
  14. */
  15. class Goodsalbum extends AdminControl
  16. {
  17. public function initialize()
  18. {
  19. parent::initialize();
  20. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/goodsalbum.lang.php');
  21. }
  22. /**
  23. * 相册列表
  24. */
  25. public function index()
  26. {
  27. $condition = array();
  28. $store_name = '';
  29. if (is_numeric(input('param.keyword'))) {
  30. $store_id = intval(input('param.keyword'));
  31. $condition[] = array('s.store_id', '=', $store_id);
  32. $store_name = ds_getvalue_byname('store', 'store_id', $store_id, 'store_name');
  33. } elseif (!empty(input('param.keyword'))) {
  34. $store_name = input('param.keyword');
  35. $store_id = ds_getvalue_byname('store', 'store_name', $store_name, 'store_id');
  36. if (is_numeric($store_id)) {
  37. $condition[] = array('s.store_id', '=', $store_id);
  38. } else {
  39. $condition[] = array('s.store_id', '=', 0);
  40. }
  41. }
  42. $goodsalbum_model = model('album');
  43. $albumclass_list = $goodsalbum_model->getGoodsalbumList($condition, 10, 'a.*,s.store_name');
  44. View::assign('show_page', $goodsalbum_model->page_info->render());
  45. if (is_array($albumclass_list) && !empty($albumclass_list)) {
  46. foreach ($albumclass_list as $v) {
  47. $class[] = $v['aclass_id'];
  48. }
  49. $where = array();
  50. $where[] = array('aclass_id', 'in', $class);
  51. } else {
  52. $where = '1=1';
  53. }
  54. $count = $goodsalbum_model->getAlbumpicCountlist($where, 'aclass_id,count(*) as pcount', 'aclass_id');
  55. $pic_count = array();
  56. if (is_array($count)) {
  57. foreach ($count as $v) {
  58. $pic_count[$v['aclass_id']] = $v['pcount'];
  59. }
  60. }
  61. View::assign('pic_count', $pic_count);
  62. View::assign('albumclass_list', $albumclass_list);
  63. View::assign('store_name', $store_name);
  64. View::assign('filtered', $condition ? 1 : 0); //是否有查询条件
  65. $this->setAdminCurItem('index');
  66. return View::fetch();
  67. }
  68. /**
  69. * 图片列表
  70. */
  71. public function pic_list()
  72. {
  73. $condition = array();
  74. $store_name = '';
  75. if (is_numeric(input('param.keyword'))) {
  76. $store_id = intval(input('param.keyword'));
  77. $condition[] = array('store_id', '=', $store_id);
  78. $store_name = ds_getvalue_byname('store', 'store_id', $store_id, 'store_name');
  79. } elseif ((input('param.keyword'))) {
  80. $store_name = input('param.keyword');
  81. $store_id = ds_getvalue_byname('store', 'store_name', $store_name, 'store_id');
  82. if (is_numeric($store_id)) {
  83. $condition[] = array('store_id', '=', $store_id);
  84. } else {
  85. $condition[] = array('store_id', '=', 0);
  86. }
  87. } elseif (is_numeric(input('param.aclass_id'))) {
  88. $condition[] = array('aclass_id', '=', input('param.aclass_id'));
  89. }
  90. $albumpic_model = model('album');
  91. $albumpic_list = $albumpic_model->getAlbumpicList($condition, 34, '', 'apic_id desc');
  92. //halt($albumpic_list);
  93. $show_page = $albumpic_model->page_info->render();
  94. View::assign('show_page', $show_page);
  95. View::assign('albumpic_list', $albumpic_list);
  96. View::assign('store_name', $store_name);
  97. $this->setAdminCurItem('pic_list');
  98. return View::fetch();
  99. }
  100. /**
  101. * 删除相册
  102. */
  103. public function aclass_del()
  104. {
  105. $aclass_id = input('param.aclass_id');
  106. $aclass_id_array = ds_delete_param($aclass_id);
  107. if ($aclass_id_array == FALSE) {
  108. ds_json_encode('10001', lang('param_error'));
  109. }
  110. $condition = array();
  111. $condition[] = array('aclass_id', 'in', $aclass_id_array);
  112. $albumpic_model = model('album');
  113. //批量删除相册图片
  114. $albumpic_model->delAlbumpic($condition);
  115. $albumpic_model->delAlbumclass($condition);
  116. $this->log(lang('ds_del') . lang('g_album_one') . '[ID:' . intval(input('param.aclass_id')) . ']', 1);
  117. ds_json_encode('10000', lang('ds_common_del_succ'));
  118. }
  119. /**
  120. * 删除一张图片及其对应记录
  121. *
  122. */
  123. public function del_album_pic()
  124. {
  125. $apic_id = input('param.apic_id');
  126. $apic_id_array = ds_delete_param($apic_id);
  127. if ($apic_id_array === FALSE) {
  128. ds_json_encode('10001', lang('param_error'));
  129. }
  130. $condition = array();
  131. $condition[] = array('apic_id', 'in', $apic_id_array);
  132. $albumpic_model = model('album');
  133. //批量删除相册图片
  134. $albumpic_model->delAlbumpic($condition);
  135. $this->log(lang('ds_del') . lang('g_album_pic_one') . '[ID:' . $apic_id . ']', 1);
  136. ds_json_encode('10000', lang('ds_common_op_succ'));
  137. }
  138. protected function getAdminItemList()
  139. {
  140. $menu_array = array(
  141. array(
  142. 'name' => 'index',
  143. 'text' => lang('g_album_list'),
  144. 'url' => (string)url('Goodsalbum/index')
  145. ),
  146. array(
  147. 'name' => 'pic_list',
  148. 'text' => lang('g_album_pic_list'),
  149. 'url' => (string)url('Goodsalbum/pic_list')
  150. ),
  151. );
  152. return $menu_array;
  153. }
  154. }