Evaluate.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. *
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 控制器
  14. */
  15. class Evaluate extends AdminControl
  16. {
  17. public function initialize()
  18. {
  19. parent::initialize(); // TODO: Change the autogenerated stub
  20. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/evaluate.lang.php');
  21. }
  22. /**
  23. * 商品来自买家的评价列表
  24. */
  25. public function evalgoods_list()
  26. {
  27. $evaluategoods_model = model('evaluategoods');
  28. $condition = array();
  29. //商品名称
  30. if (input('param.goods_name')) {
  31. $condition[] = array('geval_goodsname', 'like', '%' . input('param.goods_name') . '%');
  32. }
  33. //店铺名称
  34. if (input('param.store_name')) {
  35. $condition[] = array('geval_storename', 'like', '%' . input('param.store_name') . '%');
  36. }
  37. if (input('param.stime')) {
  38. $stime = strtotime(input('param.stime'));
  39. $condition[] = array('geval_addtime', '>=', $stime);
  40. }
  41. if (input('param.etime')) {
  42. $etime = strtotime(input('param.etime')) + 86399;
  43. $condition[] = array('geval_addtime', '<=', $etime);
  44. }
  45. $evalgoods_list = $evaluategoods_model->getEvaluategoodsList($condition, 10);
  46. View::assign('show_page', $evaluategoods_model->page_info->render());
  47. View::assign('evalgoods_list', $evalgoods_list);
  48. View::assign('filtered', $condition ? 1 : 0); //是否有查询条件
  49. $this->setAdminCurItem('evalgoods_list');
  50. return View::fetch('index');
  51. }
  52. /**
  53. * 删除商品评价
  54. */
  55. public function evalgoods_del()
  56. {
  57. $geval_id = intval(input('param.geval_id'));
  58. if ($geval_id <= 0) {
  59. ds_json_encode(10001, lang('param_error'));
  60. }
  61. $evaluategoods_model = model('evaluategoods');
  62. $result = $evaluategoods_model->delEvaluategoods(array('geval_id' => $geval_id));
  63. if ($result) {
  64. $this->log(lang('del_evaluategoods') . $geval_id);
  65. ds_json_encode(10000, lang('ds_common_del_succ'));
  66. } else {
  67. ds_json_encode(10001, lang('ds_common_del_fail'));
  68. }
  69. }
  70. /**
  71. * 店铺动态评价列表
  72. */
  73. public function evalstore_list()
  74. {
  75. $evaluatestore_model = model('evaluatestore');
  76. $condition = array();
  77. //评价人
  78. if (input('param.from_name')) {
  79. $condition[] = array('seval_membername', 'like', '%' . input('param.from_name') . '%');
  80. }
  81. //店铺名称
  82. if (input('param.store_name')) {
  83. $condition[] = array('seval_storename', 'like', '%' . input('param.store_name') . '%');
  84. }
  85. if (input('param.stime')) {
  86. $stime = strtotime(input('param.stime'));
  87. $condition[] = array('seval_addtime', '>=', $stime);
  88. }
  89. if (input('param.etime')) {
  90. $etime = strtotime(input('param.etime'));
  91. $condition[] = array('seval_addtime', '<=', $etime);
  92. }
  93. $evalstore_list = $evaluatestore_model->getEvaluatestoreList($condition, 10);
  94. View::assign('show_page', $evaluatestore_model->page_info->render());
  95. View::assign('evalstore_list', $evalstore_list);
  96. $this->setAdminCurItem('evalstore_list');
  97. return View::fetch();
  98. }
  99. /**
  100. * 删除店铺评价
  101. */
  102. public function evalstore_del()
  103. {
  104. $seval_id = intval(input('param.seval_id'));
  105. if ($seval_id <= 0) {
  106. ds_json_encode(10001, lang('param_error'));
  107. }
  108. $evaluatestore_model = model('evaluatestore');
  109. $result = $evaluatestore_model->delEvaluatestore(array('seval_id' => $seval_id));
  110. if ($result) {
  111. $this->log(lang('del_evaluatestore') . $seval_id);
  112. ds_json_encode(10000, lang('ds_common_del_succ'));
  113. } else {
  114. ds_json_encode(10001, lang('ds_common_del_fail'));
  115. }
  116. }
  117. protected function getAdminItemList()
  118. {
  119. $menu_array = array(
  120. array(
  121. 'name' => 'evalgoods_list',
  122. 'text' => lang('admin_evaluate_list'),
  123. 'url' => (string)url('Evaluate/evalgoods_list')
  124. ),
  125. array(
  126. 'name' => 'evalstore_list',
  127. 'text' => lang('admin_evalstore_list'),
  128. 'url' => (string)url('Evaluate/evalstore_list')
  129. )
  130. );
  131. return $menu_array;
  132. }
  133. }