Express.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  10. * 网站地址: https://www.valimart.net/
  11. * ----------------------------------------------------------------------------
  12. *
  13. * ============================================================================
  14. * 控制器
  15. */
  16. class Express extends AdminControl {
  17. public function initialize() {
  18. parent::initialize();
  19. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/express.lang.php');
  20. }
  21. public function index() {
  22. $express_letter = input('get.express_letter');
  23. $condition = array();
  24. if (preg_match('/^[A-Z]$/', $express_letter)) {
  25. $condition[]=array('express_letter','=',$express_letter);
  26. }
  27. $express_name = input('get.express_name');
  28. if(!empty($express_name)){
  29. $condition[]=array('express_name','like', "%" . $express_name . "%");
  30. }
  31. $express_model = model('express');
  32. $express_list = $express_model->getAllExpresslist($condition, 10);
  33. View::assign('show_page', $express_model->page_info->render());
  34. View::assign('express_list', $express_list);
  35. $this->setAdminCurItem('index');
  36. return View::fetch();
  37. }
  38. /**
  39. * 添加品牌
  40. */
  41. public function add() {
  42. $express_mod = model('express');
  43. if (request()->isPost()) {
  44. $insert_array['express_name'] = trim(input('post.express_name'));
  45. $insert_array['express_code'] = input('post.express_code');
  46. $insert_array['express_state'] = intval(input('post.express_state'));
  47. $insert_array['express_letter'] = strtoupper(input('post.express_letter'));
  48. $insert_array['express_order'] = intval(input('post.express_order'));
  49. $insert_array['express_url'] = input('post.express_url');
  50. $result = $express_mod->addExpress($insert_array);
  51. if ($result) {
  52. $this->log(lang('ds_add') . lang('express') . '[' . input('post.express_name') . ']', 1);
  53. dsLayerOpenSuccess(lang('ds_common_save_succ'));
  54. } else {
  55. $this->error(lang('ds_common_save_fail'));
  56. }
  57. } else {
  58. $express = [
  59. 'express_order' => 1,
  60. 'express_state' => 1,
  61. ];
  62. View::assign('express', $express);
  63. return View::fetch('form');
  64. }
  65. }
  66. public function edit() {
  67. $express_model = model('express');
  68. $express_id = input('param.express_id');
  69. $condition = array();
  70. if (request()->isPost()) {
  71. $condition[] = array('express_id','=',$express_id);
  72. $data['express_name'] = trim(input('post.express_name'));
  73. $data['express_code'] = input('post.express_code');
  74. $data['express_state'] = intval(input('post.express_state'));
  75. $data['express_letter'] = strtoupper(input('post.express_letter'));
  76. $data['express_order'] = intval(input('post.express_order'));
  77. $data['express_url'] = input('post.express_url');
  78. $result = $express_model->editExpress($condition, $data);
  79. if ($result) {
  80. $this->log(lang('ds_edit') . lang('express_name') . lang('ds_state') . '[ID:' . $express_id . ']', 1);
  81. dsLayerOpenSuccess(lang('ds_common_save_succ'));
  82. } else {
  83. $this->log(lang('ds_edit') . lang('express_name') . lang('ds_state') . '[ID:' . $express_id . ']', 0);
  84. $this->error(lang('ds_common_save_fail'));
  85. }
  86. } else {
  87. $condition[] = array('express_id','=',$express_id);
  88. $express = $express_model->getOneExpress($condition);
  89. if (empty($express)) {
  90. $this->error(lang('param_error'));
  91. }
  92. View::assign('express', $express);
  93. return View::fetch('form');
  94. }
  95. }
  96. /**
  97. * 删除品牌
  98. */
  99. public function del() {
  100. $express_id = input('param.express_id');
  101. $express_id_array = ds_delete_param($express_id);
  102. if ($express_id_array == FALSE) {
  103. $this->log(lang('ds_del') . lang('express') . '[ID:' . $express_id . ']', 0);
  104. ds_json_encode(10001, lang('param_error'));
  105. }
  106. $express_mod = model('express');
  107. $express_mod->delExpress(array(array('express_id','in', implode(',', $express_id_array))));
  108. $this->log(lang('ds_del') . lang('express') . '[ID:' . $express_id . ']', 1);
  109. ds_json_encode(10000, lang('ds_common_del_succ'));
  110. }
  111. /**
  112. * ajax操作
  113. */
  114. public function ajax() {
  115. $branch = input('get.branch');
  116. $column = input('get.column');
  117. $value = trim(input('get.value'));
  118. $id = intval(input('get.id'));
  119. $condition = array();
  120. switch ($branch) {
  121. case 'state':
  122. $express_model = model('express');
  123. $update_array = array();
  124. $condition[] = array('express_id','=',$id);
  125. $update_array[$column] = $value;
  126. $express_model->editExpress($condition, $update_array);
  127. $this->log(lang('ds_edit') . lang('express_name') . lang('ds_state') . '[ID:' . $id . ']', 1);
  128. echo 'true';
  129. exit;
  130. break;
  131. case 'order':
  132. $express_model = model('express');
  133. $update_array = array();
  134. $condition[] = array('express_id','=',$id);
  135. $update_array[$column] = $value;
  136. $express_model->editExpress($condition, $update_array);
  137. $this->log(lang('ds_edit') . lang('express_name') . lang('ds_state') . '[ID:' . $id . ']', 1);
  138. echo 'true';
  139. exit;
  140. break;
  141. }
  142. }
  143. public function config(){
  144. $config_model = model('config');
  145. if (!request()->isPost()) {
  146. $list_config = rkcache('config', true);
  147. View::assign('list_config', $list_config);
  148. /* 设置卖家当前栏目 */
  149. $this->setAdminCurItem('express_config');
  150. return View::fetch();
  151. } else {
  152. $update_array = array();
  153. $update_array['expresscf_kdn_type'] = input('post.expresscf_kdn_type');
  154. $update_array['expresscf_kdn_id'] = input('post.expresscf_kdn_id');
  155. $update_array['expresscf_kdn_key'] = input('post.expresscf_kdn_key');
  156. $result = $config_model->editConfig($update_array);
  157. if ($result) {
  158. $this->success(lang('ds_common_save_succ'));
  159. } else {
  160. $this->error(lang('ds_common_save_fail'));
  161. }
  162. }
  163. }
  164. /**
  165. * 获取卖家栏目列表,针对控制器下的栏目
  166. */
  167. protected function getAdminItemList() {
  168. $menu_array = array(
  169. array(
  170. 'name' => 'index',
  171. 'text' => lang('ds_manage'),
  172. 'url' => (string)url('Express/index'),
  173. ),
  174. array(
  175. 'name' => 'express_config',
  176. 'text' => '快递查询设置',
  177. 'url' => (string)url('Express/config')
  178. ),
  179. array(
  180. 'name' => 'express_add',
  181. 'text' => lang('ds_add'),
  182. 'url' => "javascript:dsLayerOpen('" . (string)url('Express/add') . "','".lang('ds_add')."')"
  183. ),
  184. );
  185. return $menu_array;
  186. }
  187. }
  188. ?>