InstantMessage.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /**
  3. * 商品管理
  4. */
  5. namespace app\admin\controller;
  6. use think\facade\View;
  7. use think\facade\Db;
  8. use think\facade\Lang;
  9. use GatewayClient\Gateway;
  10. /**
  11. * ============================================================================
  12. * DSKMS多用户商城
  13. * ============================================================================
  14. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  15. * 网站地址: http://www.csdeshang.com
  16. * ----------------------------------------------------------------------------
  17. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  18. * 不允许对程序代码以任何形式任何目的的再发布。
  19. * ============================================================================
  20. * 控制器
  21. */
  22. class InstantMessage extends AdminControl {
  23. public function initialize() {
  24. parent::initialize();
  25. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/instant_message.lang.php');
  26. }
  27. /**
  28. * 商品管理
  29. */
  30. public function index() {
  31. $instant_message_model = model('instant_message');
  32. $f_name = trim(input('param.f_name'));
  33. $t_name = trim(input('param.t_name'));
  34. $time_add_from = input('param.add_time_from')?strtotime(input('param.add_time_from')):'';
  35. $time_add_to = input('param.add_time_to')?strtotime(input('param.add_time_to')):'';
  36. /**
  37. * 查询条件
  38. */
  39. $condition = array();
  40. if($f_name){
  41. $condition[]=array('instant_message_from_name','like','%'.$f_name.'%');
  42. }
  43. if($t_name){
  44. $condition[]=array('instant_message_to_name','like','%'.$t_name.'%');
  45. }
  46. if($time_add_from){
  47. $condition[]=array('instant_message_add_time','>=',$time_add_from);
  48. }
  49. if($time_add_to){
  50. $condition[]=array('instant_message_add_time','>=',$time_add_to);
  51. }
  52. $instant_message_open = input('param.instant_message_open');
  53. if (in_array($instant_message_open, array('0', '1', '2'))) {
  54. $condition[]=array('instant_message_open','=',$instant_message_open);
  55. }
  56. $instant_message_list = $instant_message_model->getInstantMessageList($condition, 10);
  57. foreach($instant_message_list as $key => $val){
  58. $instant_message_list[$key]=$instant_message_model->formatInstantMessage($val);
  59. }
  60. View::assign('instant_message_list', $instant_message_list);
  61. View::assign('show_page', $instant_message_model->page_info->render());
  62. View::assign('search', $condition);
  63. $this->setAdminCurItem('index');
  64. return View::fetch();
  65. }
  66. /**
  67. * 删除商品
  68. */
  69. public function del() {
  70. $instant_message_id = input('param.instant_message_id');
  71. $instant_message_id_array = ds_delete_param($instant_message_id);
  72. if ($instant_message_id_array == FALSE) {
  73. ds_json_encode('10001', lang('ds_common_op_fail'));
  74. }
  75. $condition = array();
  76. $condition[] = array('instant_message_id','in', $instant_message_id_array);
  77. model('instant_message')->delInstantMessage($condition);
  78. $this->log(lang('ds_del') . lang('instant_message') . ' ID:' . implode('、', $instant_message_id_array), 1);
  79. ds_json_encode('10000', lang('ds_common_op_succ'));
  80. }
  81. /*
  82. * 直播设置
  83. */
  84. public function setting() {
  85. $config_model = model('config');
  86. if (!request()->isPost()) {
  87. $list_config = rkcache('config', true);
  88. View::assign('list_config', $list_config);
  89. $this->setAdminCurItem('setting');
  90. return View::fetch();
  91. } else {
  92. $update_array=array();
  93. $update_array['instant_message_gateway_url'] = input('param.instant_message_gateway_url');
  94. $update_array['instant_message_register_url'] = input('param.instant_message_register_url');
  95. $update_array['instant_message_open'] = input('param.instant_message_open');
  96. $result = $config_model->editConfig($update_array);
  97. if ($result) {
  98. dkcache('config');
  99. $this->log(lang('ds_setting') . lang('instant_message'), 1);
  100. $this->success(lang('ds_common_save_succ'));
  101. } else {
  102. $this->log(lang('ds_setting') . lang('instant_message'), 0);
  103. }
  104. }
  105. }
  106. /**
  107. * 获取卖家栏目列表,针对控制器下的栏目
  108. */
  109. protected function getAdminItemList() {
  110. $menu_array = array(
  111. array(
  112. 'name' => 'index',
  113. 'text' => lang('ds_list'),
  114. 'url' => url('InstantMessage/index')
  115. ),
  116. array(
  117. 'name' => 'setting',
  118. 'text' => lang('ds_setting'),
  119. 'url' => url('InstantMessage/setting')
  120. ),
  121. );
  122. return $menu_array;
  123. }
  124. }
  125. ?>