Chain.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. class Chain extends AdminControl
  13. {
  14. public function initialize()
  15. {
  16. parent::initialize(); // TODO: Change the autogenerated stub
  17. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/chain.lang.php');
  18. }
  19. /**
  20. * 门店列表
  21. */
  22. public function index()
  23. {
  24. $chain_model = model('chain');
  25. $where = array();
  26. if (input('param.search_name') != '') {
  27. $where[] = array('chain_truename', 'like', '%' . input('param.search_name') . '%');
  28. View::assign('search_name', input('param.search_name'));
  29. }
  30. if (input('param.sign') == 'verify') {
  31. View::assign('sign', 'verify');
  32. $dp_list = $chain_model->getChainWaitVerifyList($where, 10);
  33. $this->setAdminCurItem('verify');
  34. } else {
  35. $dp_list = $chain_model->getChainList($where, 10);
  36. $this->setAdminCurItem('index');
  37. }
  38. View::assign('show_page', $chain_model->page_info->render());
  39. View::assign('dp_list', $dp_list);
  40. View::assign('chain_state', $chain_model->getChainState());
  41. return View::fetch();
  42. }
  43. /**
  44. * 门店设置
  45. */
  46. public function setting()
  47. {
  48. if (!request()->isPost()) {
  49. $list_setting = rkcache('config', true);
  50. View::assign('list_setting', $list_setting);
  51. return View::fetch();
  52. } else {
  53. $update_array = array();
  54. $update_array['chain_isuse'] = intval(input('post.chain_isuse'));
  55. $result = model('config')->editConfig($update_array);
  56. $log = lang('ds_open');
  57. if ($result === true) {
  58. if ($update_array['chain_isuse'] == 0) {
  59. $log = lang('ds_close');
  60. // 删除相关联的收货地址
  61. model('address')->delAddress(array(array('chain_id', '<>', 0)));
  62. }
  63. $this->log($log . lang('chain_function'), 1);
  64. dsLayerOpenSuccess(lang('ds_common_save_succ'));
  65. } else {
  66. $this->log($log . lang('chain_function'), 0);
  67. $this->error(lang('ds_common_save_fail'));
  68. }
  69. }
  70. }
  71. /**
  72. * 编辑门店信息
  73. */
  74. public function edit_chain()
  75. {
  76. $chain_id = intval(input('param.d_id'));
  77. if ($chain_id <= 0) {
  78. $this->error(lang('param_error'));
  79. }
  80. $chain_info = model('chain')->getChainInfo(array('chain_id' => $chain_id));
  81. if (empty($chain_info)) {
  82. $this->error(lang('param_error'));
  83. }
  84. View::assign('chain_info', $chain_info);
  85. $this->setAdminCurItem('edit_chain');
  86. return View::fetch();
  87. }
  88. /**
  89. * 编辑保存
  90. */
  91. public function save_edit()
  92. {
  93. $chain_id = intval(input('param.did'));
  94. if (!request()->isPost() || $chain_id <= 0) {
  95. $this->error(lang('param_error'));
  96. }
  97. $where = array('chain_id' => $chain_id);
  98. $update = array();
  99. $update['chain_mobile'] = input('post.dmobile');
  100. $update['chain_telephony'] = input('post.dtelephony');
  101. $update['chain_addressname'] = input('post.daddressname');
  102. $update['chain_address'] = input('post.daddress');
  103. $chain_passwd = input('post.dpasswd');
  104. if (!empty($chain_passwd)) {
  105. $update['chain_passwd'] = md5($chain_passwd);
  106. }
  107. $update['chain_state'] = intval(input('post.dstate'));
  108. $update['chain_failreason'] = input('post.fail_reason');
  109. $result = model('chain')->editChain($update, $where);
  110. if ($result) {
  111. // 删除相关联的收货地址
  112. model('address')->delAddress(array('chain_id' => $chain_id));
  113. $this->log(lang('ds_edit') . lang('chain_function') . ',ID:' . $chain_id, 1);
  114. $this->success(lang('ds_common_op_succ'), (string)url('Chain/index'));
  115. } else {
  116. $this->log(lang('ds_edit') . lang('chain_function') . ',ID:' . $chain_id, 0);
  117. $this->error(lang('ds_common_op_fail'));
  118. }
  119. }
  120. protected function getAdminItemList()
  121. {
  122. $menu_array = array(
  123. array(
  124. 'name' => 'index',
  125. 'text' => lang('ds_manage'),
  126. 'url' => (string)url('Chain/index')
  127. )/*, array(
  128. 'name' => 'verify',
  129. 'text' => lang('chain_verify'),
  130. 'url' => (string)url('Chain/index',['sign'=>'verify'])
  131. ), array(
  132. 'name' => 'setting',
  133. 'text' => lang('ds_set'),
  134. 'url' => "javascript:dsLayerOpen('".(string)url('Chain/setting')."','".lang('ds_set')."')"
  135. ),*/
  136. );
  137. if (request()->action() == 'edit_chain') {
  138. $menu_array[] = array('name' => 'edit_chain', 'text' => lang('ds_edit'), 'url' => (string)url('Chain/edit_chain'));
  139. }
  140. return $menu_array;
  141. }
  142. }