Chain.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. * DSMall多用户商城
  8. * ============================================================================
  9. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  10. * 网站地址: http://www.csdeshang.com
  11. * ----------------------------------------------------------------------------
  12. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  13. * 不允许对程序代码以任何形式任何目的的再发布。
  14. * ============================================================================
  15. * 控制器
  16. */
  17. class Chain extends AdminControl
  18. {
  19. public function initialize()
  20. {
  21. parent::initialize(); // TODO: Change the autogenerated stub
  22. Lang::load(base_path() . 'admin/lang/'.config('lang.default_lang').'/chain.lang.php');
  23. }
  24. /**
  25. * 门店列表
  26. */
  27. public function index()
  28. {
  29. $chain_model = model('chain');
  30. $where = array();
  31. if (input('param.search_name') != '') {
  32. $where[]=array('chain_truename','like', '%' . input('param.search_name') . '%');
  33. View::assign('search_name', input('param.search_name'));
  34. }
  35. if (input('param.sign') == 'verify') {
  36. View::assign('sign', 'verify');
  37. $dp_list = $chain_model->getChainWaitVerifyList($where, 10);
  38. $this->setAdminCurItem('verify');
  39. }
  40. else {
  41. $dp_list = $chain_model->getChainList($where, 10);
  42. $this->setAdminCurItem('index');
  43. }
  44. View::assign('show_page', $chain_model->page_info->render());
  45. View::assign('dp_list', $dp_list);
  46. View::assign('chain_state', $chain_model->getChainState());
  47. return View::fetch();
  48. }
  49. /**
  50. * 门店设置
  51. */
  52. public function setting()
  53. {
  54. if (!request()->isPost()) {
  55. $list_setting = rkcache('config', true);
  56. View::assign('list_setting', $list_setting);
  57. return View::fetch();
  58. } else {
  59. $update_array = array();
  60. $update_array['chain_isuse'] = intval(input('post.chain_isuse'));
  61. $result = model('config')->editConfig($update_array);
  62. $log = lang('ds_open');
  63. if ($result === true) {
  64. if ($update_array['chain_isuse'] == 0) {
  65. $log = lang('ds_close');
  66. // 删除相关联的收货地址
  67. model('address')->delAddress(array(array('chain_id','<>', 0)));
  68. }
  69. $this->log($log . lang('chain_function'), 1);
  70. dsLayerOpenSuccess(lang('ds_common_save_succ'));
  71. } else {
  72. $this->log($log . lang('chain_function'), 0);
  73. $this->error(lang('ds_common_save_fail'));
  74. }
  75. }
  76. }
  77. /**
  78. * 编辑门店信息
  79. */
  80. public function edit_chain()
  81. {
  82. $chain_id = intval(input('param.d_id'));
  83. if ($chain_id <= 0) {
  84. $this->error(lang('param_error'));
  85. }
  86. $chain_info = model('chain')->getChainInfo(array('chain_id' => $chain_id));
  87. if (empty($chain_info)) {
  88. $this->error(lang('param_error'));
  89. }
  90. View::assign('chain_info', $chain_info);
  91. $this->setAdminCurItem('edit_chain');
  92. return View::fetch();
  93. }
  94. /**
  95. * 编辑保存
  96. */
  97. public function save_edit()
  98. {
  99. $chain_id = intval(input('param.did'));
  100. if (!request()->isPost() || $chain_id <= 0) {
  101. $this->error(lang('param_error'));
  102. }
  103. $where = array('chain_id' => $chain_id);
  104. $update = array();
  105. $update['chain_mobile'] = input('post.dmobile');
  106. $update['chain_telephony'] = input('post.dtelephony');
  107. $update['chain_addressname'] = input('post.daddressname');
  108. $update['chain_address'] = input('post.daddress');
  109. $chain_passwd = input('post.dpasswd');
  110. if (!empty($chain_passwd)) {
  111. $update['chain_passwd'] = md5($chain_passwd);
  112. }
  113. $update['chain_state'] = intval(input('post.dstate'));
  114. $update['chain_failreason'] = input('post.fail_reason');
  115. $result = model('chain')->editChain($update, $where);
  116. if ($result) {
  117. // 删除相关联的收货地址
  118. model('address')->delAddress(array('chain_id' => $chain_id));
  119. $this->log(lang('ds_edit').lang('chain_function').',ID:' . $chain_id, 1);
  120. $this->success(lang('ds_common_op_succ'), (string)url('Chain/index'));
  121. }
  122. else {
  123. $this->log(lang('ds_edit').lang('chain_function').',ID:' . $chain_id, 0);
  124. $this->error(lang('ds_common_op_fail'));
  125. }
  126. }
  127. protected function getAdminItemList()
  128. {
  129. $menu_array = array(
  130. array(
  131. 'name' => 'index',
  132. 'text' => lang('ds_manage'),
  133. 'url' => (string)url('Chain/index')
  134. )/*, array(
  135. 'name' => 'verify',
  136. 'text' => lang('chain_verify'),
  137. 'url' => (string)url('Chain/index',['sign'=>'verify'])
  138. ), array(
  139. 'name' => 'setting',
  140. 'text' => lang('ds_set'),
  141. 'url' => "javascript:dsLayerOpen('".(string)url('Chain/setting')."','".lang('ds_set')."')"
  142. ),*/
  143. );
  144. if (request()->action() == 'edit_chain') {
  145. $menu_array[] = array('name' => 'edit_chain', 'text' => lang('ds_edit'), 'url' => (string)url('Chain/edit_chain'));
  146. }
  147. return $menu_array;
  148. }
  149. }