Chain.php 5.6 KB

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