Goodsalbum.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. /*
  3. * 空间管理
  4. */
  5. namespace app\admin\controller;
  6. use think\facade\View;
  7. use think\facade\Lang;
  8. /**
  9. * ============================================================================
  10. * DSMall多用户商城
  11. * ============================================================================
  12. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  13. * 网站地址: http://www.csdeshang.com
  14. * ----------------------------------------------------------------------------
  15. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  16. * 不允许对程序代码以任何形式任何目的的再发布。
  17. * ============================================================================
  18. * 控制器
  19. */
  20. class Goodsalbum extends AdminControl {
  21. public function initialize() {
  22. parent::initialize();
  23. Lang::load(base_path() . 'admin/lang/'.config('lang.default_lang').'/goodsalbum.lang.php');
  24. }
  25. /**
  26. * 相册列表
  27. */
  28. public function index() {
  29. $condition = array();
  30. $store_name = '';
  31. if (is_numeric(input('param.keyword'))) {
  32. $store_id = intval(input('param.keyword'));
  33. $condition[] = array('s.store_id','=',$store_id);
  34. $store_name = ds_getvalue_byname('store', 'store_id', $store_id, 'store_name');
  35. } elseif (!empty(input('param.keyword'))) {
  36. $store_name = input('param.keyword');
  37. $store_id = ds_getvalue_byname('store', 'store_name', $store_name, 'store_id');
  38. if (is_numeric($store_id)) {
  39. $condition[] = array('s.store_id','=',$store_id);
  40. } else {
  41. $condition[] = array('s.store_id','=',0);
  42. }
  43. }
  44. $goodsalbum_model = model('album');
  45. $albumclass_list = $goodsalbum_model->getGoodsalbumList($condition,10,'a.*,s.store_name');
  46. View::assign('show_page', $goodsalbum_model->page_info->render());
  47. if (is_array($albumclass_list) && !empty($albumclass_list)) {
  48. foreach ($albumclass_list as $v) {
  49. $class[] = $v['aclass_id'];
  50. }
  51. $where=array();
  52. $where[]=array('aclass_id','in',$class);
  53. } else {
  54. $where = '1=1';
  55. }
  56. $count = $goodsalbum_model->getAlbumpicCountlist($where,'aclass_id,count(*) as pcount','aclass_id');
  57. $pic_count = array();
  58. if (is_array($count)) {
  59. foreach ($count as $v) {
  60. $pic_count[$v['aclass_id']] = $v['pcount'];
  61. }
  62. }
  63. View::assign('pic_count', $pic_count);
  64. View::assign('albumclass_list', $albumclass_list);
  65. View::assign('store_name', $store_name);
  66. View::assign('filtered', $condition ? 1 : 0); //是否有查询条件
  67. $this->setAdminCurItem('index');
  68. return View::fetch();
  69. }
  70. /**
  71. * 图片列表
  72. */
  73. public function pic_list() {
  74. $condition = array();
  75. $store_name = '';
  76. if (is_numeric(input('param.keyword'))) {
  77. $store_id = intval(input('param.keyword'));
  78. $condition[] = array('store_id','=',$store_id);
  79. $store_name = ds_getvalue_byname('store','store_id',$store_id,'store_name');
  80. } elseif ((input('param.keyword'))) {
  81. $store_name = input('param.keyword');
  82. $store_id = ds_getvalue_byname('store','store_name',$store_name,'store_id');
  83. if (is_numeric($store_id)) {
  84. $condition[] = array('store_id','=',$store_id);
  85. } else {
  86. $condition[] = array('store_id','=',0);
  87. }
  88. } elseif (is_numeric(input('param.aclass_id'))) {
  89. $condition[] = array('aclass_id','=',input('param.aclass_id'));
  90. }
  91. $albumpic_model = model('album');
  92. $albumpic_list = $albumpic_model->getAlbumpicList($condition,34,'','apic_id desc');
  93. //halt($albumpic_list);
  94. $show_page = $albumpic_model->page_info->render();
  95. View::assign('show_page', $show_page);
  96. View::assign('albumpic_list', $albumpic_list);
  97. View::assign('store_name', $store_name);
  98. $this->setAdminCurItem('pic_list');
  99. return View::fetch();
  100. }
  101. /**
  102. * 删除相册
  103. */
  104. public function aclass_del() {
  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. $apic_id = input('param.apic_id');
  125. $apic_id_array = ds_delete_param($apic_id);
  126. if ($apic_id_array === FALSE) {
  127. ds_json_encode('10001', lang('param_error'));
  128. }
  129. $condition=array();
  130. $condition[]=array('apic_id','in',$apic_id_array);
  131. $albumpic_model = model('album');
  132. //批量删除相册图片
  133. $albumpic_model->delAlbumpic($condition);
  134. $this->log(lang('ds_del') . lang('g_album_pic_one') . '[ID:' . $apic_id . ']', 1);
  135. ds_json_encode('10000', lang('ds_common_op_succ'));
  136. }
  137. protected function getAdminItemList() {
  138. $menu_array = array(
  139. array(
  140. 'name' => 'index',
  141. 'text' => lang('g_album_list'),
  142. 'url' => (string)url('Goodsalbum/index')
  143. ),
  144. array(
  145. 'name' => 'pic_list',
  146. 'text' => lang('g_album_pic_list'),
  147. 'url' => (string)url('Goodsalbum/pic_list')
  148. ),
  149. );
  150. return $menu_array;
  151. }
  152. }
  153. ?>