diff --git a/app/common/dao/system/admin/AdminDao.php b/app/common/dao/system/admin/AdminDao.php index b82f7ee..a8a2232 100644 --- a/app/common/dao/system/admin/AdminDao.php +++ b/app/common/dao/system/admin/AdminDao.php @@ -34,21 +34,25 @@ class AdminDao extends BaseDao * @author xaboy * @day 2020-04-09 */ - public function search(array $where = [], $is_del = 0,$level = true) - { + public function search(array $where = [],$is_del = 0,$level = TRUE){ $query = Admin::getDB(); - if($level) $query->where('level', '<>', 0); - $query->when($is_del !== null, function ($query) use ($is_del) { - $query->where('is_del', $is_del); - })->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) { - getModelTime($query, $where['date']); - }); - if (isset($where['keyword']) && $where['keyword'] !== '') { - $query = $query->whereLike('real_name|account', '%' . $where['keyword'] . '%'); + if($level) $query->where('level','<>',0); + $query->when($is_del !== NULL,function($query) use ($is_del){ + $query->where('is_del',$is_del); + }) + ->when(isset($where['date']) && $where['date'] !== '',function($query) use ($where){ + getModelTime($query,$where['date']); + }); + if(isset($where['keyword']) && $where['keyword'] !== ''){ + $query = $query->whereLike('real_name|account','%'.$where['keyword'].'%'); } - if (isset($where['status']) && $where['status'] !== '') { - $query = $query->where('status', intval($where['status'])); + if(isset($where['status']) && $where['status'] !== ''){ + $query = $query->where('status',intval($where['status'])); } + if(isset($where['admin_type']) && $where['admin_type'] !== ''){ + $query = $query->where('admin_type',intval($where['admin_type'])); + } + return $query; } @@ -105,5 +109,26 @@ class AdminDao extends BaseDao ->field(['account', 'pwd', 'real_name', 'login_count', 'admin_id', 'status']) ->find(); } + + /** + * 获取列表 + * @param array $where + * @param int $page + * @param int $limit + * @param string $field + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function getList(array $where,int $page = 0,int $limit = 0,string $field = '*'){ + return $this->search($where) + ->field($field) + ->when($page && $limit,function($query) use ($page,$limit){ + $query->page($page,$limit); + }) + ->select() + ->toArray(); + } } diff --git a/app/common/model/store/CityArea.php b/app/common/model/store/CityArea.php index d0679e4..477358e 100644 --- a/app/common/model/store/CityArea.php +++ b/app/common/model/store/CityArea.php @@ -35,4 +35,12 @@ class CityArea extends BaseModel $count = self::where('parent_id',$this->id)->count(); return $count ? true : false; } + + /** + * @return \think\model\relation\HasMany|\think\model\relation\HasOne + */ + public function children() + { + return $this->hasMany(self::class, 'parent_id', 'id'); + } } diff --git a/app/common/model/system/config/SystemConfig.php b/app/common/model/system/config/SystemConfig.php index 5e3f1ab..1cadc24 100644 --- a/app/common/model/system/config/SystemConfig.php +++ b/app/common/model/system/config/SystemConfig.php @@ -7,6 +7,7 @@ namespace app\common\model\system\config; use app\common\model\BaseModel; +use app\model\store\StoreConfig; use think\model\relation\HasOne; /** @@ -47,4 +48,14 @@ class SystemConfig extends BaseModel return $this->hasOne(SystemConfig::class, 'config_classify_id', 'config_classify_id'); } + /** + * 一对一关联门店配置表 + * @return \think\model\relation\HasOne + */ + public function storeConfig() + { + return $this->hasOne(StoreConfig::class, 'key_name', 'menu_name')->field(['key_name', 'type', 'relation_id', 'value'])->bind([ + 'store_value' => 'value', + ]); + } } diff --git a/app/controller/supplier/Common.php b/app/controller/supplier/Common.php index 3a0adcc..383ce3f 100644 --- a/app/controller/supplier/Common.php +++ b/app/controller/supplier/Common.php @@ -57,7 +57,10 @@ class Common extends AuthController */ public function city(CityAreaServices $services, $pid = 0) { - return app('json')->success('' , $services->getCityTreeList((int)$pid)); + $data = $services->getCityTreeList((int)$pid); + + + return app('json')->success('' , $data); } /** diff --git a/app/controller/supplier/system/Config.php b/app/controller/supplier/system/Config.php index 348c490..71be892 100644 --- a/app/controller/supplier/system/Config.php +++ b/app/controller/supplier/system/Config.php @@ -91,6 +91,8 @@ class Config extends AuthController public function getFormBuild(StoreConfigServices $services, string $type) { $supplier_id = (int)$this->supplierId; - return app('json')->success('',$services->getFormBuildRule($type, 2, $supplier_id)); + $data = $services->getFormBuildRule($type, 2, $supplier_id); + + return app('json')->success('', $data); } } diff --git a/app/controller/supplier/system/SupplierAdmin.php b/app/controller/supplier/system/SupplierAdmin.php index 7dfc931..85592f6 100644 --- a/app/controller/supplier/system/SupplierAdmin.php +++ b/app/controller/supplier/system/SupplierAdmin.php @@ -53,12 +53,14 @@ class SupplierAdmin extends AuthController public function index() { $where = [ - 'is_del' => 1, + // 'is_del' => 0, 'admin_type' => 4, - 'relation_id' => $this->supplierId, - 'level' => 1 + // 'relation_id' => $this->supplierId, + // 'level' => 1 ]; - return app('json')->success('',$this->adminServices->getAdminList($where)); + $data = $this->adminServices->getAdminList($where); + + return app('json')->success('', $data); } /** diff --git a/app/dao/system/SystemRoleDao.php b/app/dao/system/SystemRoleDao.php index 1ebbc4d..8d04e18 100644 --- a/app/dao/system/SystemRoleDao.php +++ b/app/dao/system/SystemRoleDao.php @@ -37,7 +37,7 @@ class SystemRoleDao extends BaseDao */ public function getRoule(array $where = [], ?string $field = null, ?string $key = null) { - return $this->search($where)->column($field ?: 'role_name', $key ?: 'id'); + return $this->search($where)->column($field ?: 'role_name', $key ?: 'role_id'); } /** diff --git a/app/services/store/StoreConfigServices.php b/app/services/store/StoreConfigServices.php index 0237e0f..af2d8a8 100644 --- a/app/services/store/StoreConfigServices.php +++ b/app/services/store/StoreConfigServices.php @@ -144,7 +144,7 @@ class StoreConfigServices extends BaseServices { /** @var SystemConfigServices $systemConfigServices */ $systemConfigServices = app()->make(SystemConfigServices::class); - $list = $systemConfigServices->getConfigAllListByWhere(['menu_name' => $configName], $type, $relation_id, ['menu_name', 'info', 'type', 'value', 'desc', 'parameter']); + $list = $systemConfigServices->getConfigAllListByWhere(['config_name' => $configName], $type, $relation_id, ['config_name', 'info', 'config_type', 'config_rule']); if ($list) { foreach ($list as &$item) { if ($relation_id != 0) { @@ -152,7 +152,7 @@ class StoreConfigServices extends BaseServices } $item['value'] = json_decode($item['value'], true); } - $list = array_combine(array_column($list, 'menu_name'), $list); + $list = array_combine(array_column($list, 'config_name'), $list); } $value = []; @@ -160,7 +160,7 @@ class StoreConfigServices extends BaseServices if ($group) { $value[$key] = $list[$key]['value'] ?? ''; } else { - $value[$key] = $list[$key] ?? ['info' => '', 'type' => 'text', 'value' => '', 'desc' => '', 'parameter' => '']; + $value[$key] = $list[$key] ?? ['info' => '', 'config_type' => 'text', 'value' => '', 'config_rule' => '']; } } return $value; @@ -228,7 +228,8 @@ class StoreConfigServices extends BaseServices ])->options($this->getOptions($data['store_config_export_open']['parameter']))->info($data['store_config_export_open']['desc']) ]) ]); - } elseif ($type = 2) { + } + elseif ($type = 2) { $data = $this->getConfigAllField([ 'store_pay_success_printing_switch', 'store_develop_id', 'store_printing_api_key', 'store_printing_client_id', 'store_terminal_number', 'store_print_type', 'store_fey_user', 'store_fey_ukey', 'store_fey_sn', @@ -238,15 +239,15 @@ class StoreConfigServices extends BaseServices Build::tabs()->option('小票打印配置', [ Build::switch('store_pay_success_printing_switch', $data['store_pay_success_printing_switch']['info'], (int)($data['store_pay_success_printing_switch']['value'] ?? 0))->control(1, [ Build::radio('store_print_type', $data['store_print_type']['info'], in_array($data['store_print_type']['value'], [1, 2]) ? $data['store_print_type']['value'] : 1)->control(1, [ - Build::input('store_develop_id', $data['store_develop_id']['info'], $data['store_develop_id']['value'])->info($data['store_develop_id']['desc']), - Build::input('store_printing_api_key', $data['store_printing_api_key']['info'], $data['store_printing_api_key']['value'])->info($data['store_printing_api_key']['desc']), - Build::input('store_printing_client_id', $data['store_printing_client_id']['info'], $data['store_printing_client_id']['value'])->info($data['store_printing_client_id']['desc']), - Build::input('store_terminal_number', $data['store_terminal_number']['info'], $data['store_terminal_number']['value'])->info($data['store_terminal_number']['desc']), + Build::input('store_develop_id', $data['store_develop_id']['info'], $data['store_develop_id']['value'])->info($data['store_develop_id']['info']), + Build::input('store_printing_api_key', $data['store_printing_api_key']['info'], $data['store_printing_api_key']['value'])->info($data['store_printing_api_key']['info']), + Build::input('store_printing_client_id', $data['store_printing_client_id']['info'], $data['store_printing_client_id']['value'])->info($data['store_printing_client_id']['info']), + Build::input('store_terminal_number', $data['store_terminal_number']['info'], $data['store_terminal_number']['value'])->info($data['store_terminal_number']['info']), ])->control(2, [ - Build::input('store_fey_user', $data['store_fey_user']['info'], $data['store_fey_user']['value'])->info($data['store_fey_user']['desc']), - Build::input('store_fey_ukey', $data['store_fey_ukey']['info'], $data['store_fey_ukey']['value'])->info($data['store_fey_ukey']['desc']), - Build::input('store_fey_sn', $data['store_fey_sn']['info'], $data['store_fey_sn']['value'])->info($data['store_fey_sn']['desc']) - ])->options($this->getOptions($data['store_print_type']['parameter']))->info($data['store_print_type']['desc']) + Build::input('store_fey_user', $data['store_fey_user']['info'], $data['store_fey_user']['value'])->info($data['store_fey_user']['info']), + Build::input('store_fey_ukey', $data['store_fey_ukey']['info'], $data['store_fey_ukey']['value'])->info($data['store_fey_ukey']['info']), + Build::input('store_fey_sn', $data['store_fey_sn']['info'], $data['store_fey_sn']['value'])->info($data['store_fey_sn']['info']) + ])->options($this->getOptions($data['store_print_type']['config_rule']))->info($data['store_print_type']['info']) ])->trueValue('打开', 1)->falseValue('关闭', 0), ]) ]); diff --git a/app/services/system/admin/SystemAdminServices.php b/app/services/system/admin/SystemAdminServices.php index ced4fe8..ec5d0cc 100644 --- a/app/services/system/admin/SystemAdminServices.php +++ b/app/services/system/admin/SystemAdminServices.php @@ -152,7 +152,6 @@ class SystemAdminServices extends BaseServices [$page, $limit] = $this->getPageValue(); $list = $this->dao->getList($where, $page, $limit); $count = $this->dao->count($where); - /** @var SystemRoleServices $service */ $service = app()->make(SystemRoleServices::class); $allRole = $service->getRoleArray(['type' => 0]); @@ -168,8 +167,8 @@ class SystemAdminServices extends BaseServices $item['roles'] = ''; } } - $item['_add_time'] = date('Y-m-d H:i:s', $item['add_time']); - $item['_last_time'] = $item['last_time'] ? date('Y-m-d H:i:s', $item['last_time']) : ''; + $item['_add_time'] = $item['create_time']; + $item['_last_time'] = $item['last_time'] ? : ''; } return compact('list', 'count'); }