Flea.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. * DSMall多用户商城
  8. * ============================================================================
  9. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  10. * 网站地址: http://www.csdeshang.com
  11. * ----------------------------------------------------------------------------
  12. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  13. * 不允许对程序代码以任何形式任何目的的再发布。
  14. * ============================================================================
  15. * 控制器
  16. */
  17. class Flea extends AdminControl
  18. {
  19. public function initialize()
  20. {
  21. parent::initialize(); // TODO: Change the autogenerated stub
  22. Lang::load(base_path() . 'admin/lang/'.config('lang.default_lang').'/flea.lang.php');
  23. if (config('ds_config.flea_isuse') != 1 ){
  24. $this->error(lang('flea_index_unable'),'dashboard/welcome');
  25. }
  26. }
  27. /**
  28. * 商品管理
  29. */
  30. public function flea(){
  31. $flea_model = model('flea');
  32. /**
  33. * 排序
  34. */
  35. $special_condition = array();
  36. $keyword = trim(input('param.search_goods_name'));
  37. if($keyword){
  38. $special_condition['keyword'] = $keyword;
  39. }
  40. $like_member_name = trim(input('param.search_store_name'));
  41. if($like_member_name){
  42. $special_condition['like_member_name'] = $like_member_name;//店铺名称
  43. }
  44. $search_brand_id = intval(input('param.search_brand_id'));
  45. if($search_brand_id){
  46. $special_condition['brand_id'] = $search_brand_id;
  47. }
  48. $cate_id = intval(input('param.cate_id'));
  49. if($cate_id){
  50. $special_condition['fleaclass_id'] = $cate_id;
  51. }
  52. /**
  53. * 分页
  54. */
  55. $goods_list = $flea_model->getFleaList($special_condition,10);
  56. if (is_array($goods_list) and !empty($goods_list)) {
  57. foreach ($goods_list as $key => $val) {
  58. $goods_list[$key]['goods_image'] = $goods_list[$key]['goods_image'] == '' ? '' : ds_get_pic(ATTACH_MFLEA . '/' . $val['member_id'] , str_replace('_1024', '_240', $val['goods_image']));
  59. }
  60. }
  61. /**
  62. * 商品类别
  63. */
  64. /**
  65. * 商品分类
  66. */
  67. $fleaclass_model = model('fleaclass');
  68. $goods_class = $fleaclass_model->getTreeClassList(1);
  69. View::assign('goods_class',$goods_class);
  70. View::assign('goods_list',$goods_list);
  71. View::assign('show_page',$flea_model->page_info->render());
  72. View::assign('filtered', $special_condition ? 1 : 0); //是否有查询条件
  73. $this->setAdminCurItem('index');
  74. return View::fetch('index');
  75. }
  76. /**
  77. * 闲置商品删除
  78. */
  79. public function del()
  80. {
  81. $del_id = input('param.del_id');
  82. $del_id_array = ds_delete_param($del_id);
  83. if ($del_id_array == FALSE) {
  84. ds_json_encode('10001', lang('goods_index_argument_invalid'));
  85. }
  86. $flea_model = model('flea');
  87. $result = $flea_model->delFlea($del_id_array);
  88. if($result){
  89. ds_json_encode('10000', lang('goods_index_del_succ'));
  90. }else{
  91. ds_json_encode('10001', lang('goods_index_choose_del'));
  92. }
  93. }
  94. /**
  95. * ajax操作
  96. */
  97. public function ajax() {
  98. $branch = input('get.branch');
  99. $column = input('get.column');
  100. $value = trim(input('get.value'));
  101. $id = intval(input('get.id'));
  102. switch ($branch) {
  103. /**
  104. * 商品名称
  105. */
  106. case 'goods_name':
  107. $flea_model = model('flea');
  108. $update_array = array();
  109. $update_array[$column] = $value;
  110. $flea_model->editFlea($update_array, array('goods_id'=>$id));
  111. echo 'true';
  112. exit;
  113. break;
  114. }
  115. }
  116. protected function getAdminItemList()
  117. {
  118. $menu_array = array(
  119. array(
  120. 'name' => 'index', 'text' => lang('flea_all_ldle'), 'url' => (string)url('Flea/flea')
  121. ),
  122. );
  123. return $menu_array;
  124. }
  125. }