123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <?php
- namespace app\admin\controller;
- use think\facade\View;
- use think\facade\Lang;
- /**
-
- *
-
- *
- * ----------------------------------------------------------------------------
- *
-
- * 控制器
- */
- class Chain extends AdminControl
- {
- public function initialize()
- {
- parent::initialize(); // TODO: Change the autogenerated stub
- Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/chain.lang.php');
- }
- /**
- * 门店列表
- */
- public function index()
- {
- $chain_model = model('chain');
- $where = array();
- if (input('param.search_name') != '') {
- $where[] = array('chain_truename', 'like', '%' . input('param.search_name') . '%');
- View::assign('search_name', input('param.search_name'));
- }
- if (input('param.sign') == 'verify') {
- View::assign('sign', 'verify');
- $dp_list = $chain_model->getChainWaitVerifyList($where, 10);
- $this->setAdminCurItem('verify');
- } else {
- $dp_list = $chain_model->getChainList($where, 10);
- $this->setAdminCurItem('index');
- }
- View::assign('show_page', $chain_model->page_info->render());
- View::assign('dp_list', $dp_list);
- View::assign('chain_state', $chain_model->getChainState());
- return View::fetch();
- }
- /**
- * 门店设置
- */
- public function setting()
- {
- if (!request()->isPost()) {
- $list_setting = rkcache('config', true);
- View::assign('list_setting', $list_setting);
- return View::fetch();
- } else {
- $update_array = array();
- $update_array['chain_isuse'] = intval(input('post.chain_isuse'));
- $result = model('config')->editConfig($update_array);
- $log = lang('ds_open');
- if ($result === true) {
- if ($update_array['chain_isuse'] == 0) {
- $log = lang('ds_close');
- // 删除相关联的收货地址
- model('address')->delAddress(array(array('chain_id', '<>', 0)));
- }
- $this->log($log . lang('chain_function'), 1);
- dsLayerOpenSuccess(lang('ds_common_save_succ'));
- } else {
- $this->log($log . lang('chain_function'), 0);
- $this->error(lang('ds_common_save_fail'));
- }
- }
- }
- /**
- * 编辑门店信息
- */
- public function edit_chain()
- {
- $chain_id = intval(input('param.d_id'));
- if ($chain_id <= 0) {
- $this->error(lang('param_error'));
- }
- $chain_info = model('chain')->getChainInfo(array('chain_id' => $chain_id));
- if (empty($chain_info)) {
- $this->error(lang('param_error'));
- }
- View::assign('chain_info', $chain_info);
- $this->setAdminCurItem('edit_chain');
- return View::fetch();
- }
- /**
- * 编辑保存
- */
- public function save_edit()
- {
- $chain_id = intval(input('param.did'));
- if (!request()->isPost() || $chain_id <= 0) {
- $this->error(lang('param_error'));
- }
- $where = array('chain_id' => $chain_id);
- $update = array();
- $update['chain_mobile'] = input('post.dmobile');
- $update['chain_telephony'] = input('post.dtelephony');
- $update['chain_addressname'] = input('post.daddressname');
- $update['chain_address'] = input('post.daddress');
- $chain_passwd = input('post.dpasswd');
- if (!empty($chain_passwd)) {
- $update['chain_passwd'] = md5($chain_passwd);
- }
- $update['chain_state'] = intval(input('post.dstate'));
- $update['chain_failreason'] = input('post.fail_reason');
- $result = model('chain')->editChain($update, $where);
- if ($result) {
- // 删除相关联的收货地址
- model('address')->delAddress(array('chain_id' => $chain_id));
- $this->log(lang('ds_edit') . lang('chain_function') . ',ID:' . $chain_id, 1);
- $this->success(lang('ds_common_op_succ'), (string)url('Chain/index'));
- } else {
- $this->log(lang('ds_edit') . lang('chain_function') . ',ID:' . $chain_id, 0);
- $this->error(lang('ds_common_op_fail'));
- }
- }
- protected function getAdminItemList()
- {
- $menu_array = array(
- array(
- 'name' => 'index',
- 'text' => lang('ds_manage'),
- 'url' => (string)url('Chain/index')
- )/*, array(
- 'name' => 'verify',
- 'text' => lang('chain_verify'),
- 'url' => (string)url('Chain/index',['sign'=>'verify'])
- ), array(
- 'name' => 'setting',
- 'text' => lang('ds_set'),
- 'url' => "javascript:dsLayerOpen('".(string)url('Chain/setting')."','".lang('ds_set')."')"
- ),*/
- );
- if (request()->action() == 'edit_chain') {
- $menu_array[] = array('name' => 'edit_chain', 'text' => lang('ds_edit'), 'url' => (string)url('Chain/edit_chain'));
- }
- return $menu_array;
- }
- }
|