初始化项目

This commit is contained in:
2026-09-01 22:15:50 +08:00
commit b5a26a8848
11217 changed files with 1710987 additions and 0 deletions
@@ -0,0 +1,94 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\store\controller\store;
use app\store\controller\Controller;
use app\store\model\store\Address as AddressModel;
/**
* 商家地址管理
* Class Delivery
* @package app\store\controller\setting
*/
class Address extends Controller
{
/**
* 列表记录
* @return array
* @throws \think\db\exception\DbException
*/
public function list()
{
$model = new AddressModel;
$list = $model->getList($this->request->param());
return $this->renderSuccess(compact('list'));
}
/**
* 全部记录
* @return array
* @throws \think\db\exception\DbException
*/
public function all()
{
$model = new AddressModel;
$list = $model->getAll($this->request->param());
return $this->renderSuccess(compact('list'));
}
/**
* 添加记录
* @return array|string
*/
public function add()
{
// 新增记录
$model = new AddressModel;
if ($model->add($this->postForm())) {
return $this->renderSuccess('添加成功');
}
return $this->renderError($model->getError() ?: '添加失败');
}
/**
* 编辑记录
* @param int $addressId
* @return array|mixed
*/
public function edit(int $addressId)
{
// 详情记录
$model = AddressModel::detail($addressId);
// 更新记录
if ($model->edit($this->postForm())) {
return $this->renderSuccess('更新成功');
}
return $this->renderError($model->getError() ?: '更新失败');
}
/**
* 删除记录
* @param int $addressId
* @return array
*/
public function delete(int $addressId)
{
// 详情记录
$model = AddressModel::detail($addressId);
if (!$model->remove()) {
return $this->renderError($model->getError() ?: '删除失败');
}
return $this->renderSuccess('删除成功');
}
}
@@ -0,0 +1,43 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\store\controller\store;
use app\store\controller\Controller;
use app\store\model\store\Menu as MenuModel;
/**
* 商家后台菜单管理
* Class Menu
* @package app\store\controller\store
*/
class Menu extends Controller
{
/**
* 菜单列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function list()
{
$model = new MenuModel;
$list = $model->getList();
//二级账户创建角色,不能给管理员模块权限,意味着三级账户不能新建管理员
/*if($this->store['user']['level'] == 2){
unset($list[1]);
$list = array_values($list);
}*/
return $this->renderSuccess(compact('list'));
}
}
@@ -0,0 +1,99 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\store\controller\store;
use app\store\controller\Controller;
use app\store\model\store\Role as RoleModel;
use app\store\model\store\User;
/**
* 商家用户角色控制器
* Class StoreUser
* @package app\store\controller
*/
class Role extends Controller
{
/**
* 角色列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function list()
{
$model = new RoleModel;
$filter = [];
$user = $this->store['user'];
if($user['is_super'] == 0){
$filter[] = ['store_user_id', 'in', User::getScope($user)];
}
$list = $model->getList($filter);
return $this->renderSuccess(compact('list','user'));
}
/**
* 添加角色
* @return array
*/
public function add()
{
// 新增记录
$model = new RoleModel;
$data = $this->postForm();
$data['store_user_id'] = $this->store['user']['store_user_id'];
/*if($this->store['user']['is_super'] == 0){
$data['store_user_id'] = $this->store['user']['store_user_id'];
}*/
if ($model->add($data)) {
return $this->renderSuccess('添加成功');
}
return $this->renderError($model->getError() ?: '添加失败');
}
/**
* 更新角色
* @param $roleId
* @return array|bool|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function edit(int $roleId)
{
// 角色详情
$model = RoleModel::detail($roleId);
// 更新记录
if ($model->edit($this->postForm())) {
return $this->renderSuccess('更新成功');
}
return $this->renderError($model->getError() ?: '更新失败');
}
/**
* 删除角色
* @param $roleId
* @return array|bool
* @throws \Exception
*/
public function delete(int $roleId)
{
// 角色详情
$model = RoleModel::detail($roleId);
if (!$model->remove()) {
return $this->renderError($model->getError() ?: '删除失败');
}
return $this->renderSuccess('删除成功');
}
}
@@ -0,0 +1,142 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\store\controller\store;
use app\store\controller\Controller;
use app\store\model\store\User as StoreUserModel;
use app\store\service\store\User as StoreUserService;
use app\store\service\store\Role as StoreRoleService;
use GatewayWorker\Lib\Gateway;
/**
* 商家用户控制器
* Class StoreUser
* @package app\store\controller
*/
class User extends Controller
{
/**
* 获取当前登录的用户信息
* @return array
* @param String $client_id
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function info(string $client_id = '')
{
/*if($client_id) {
Gateway::bindUid($client_id, (int)StoreUserService::getLoginUserId());
'client_id' => $client_id,
'uidList' => Gateway::getAllUidList(),
'clientIdList' => Gateway::getAllClientIdList(),
'state' => Gateway::isUidOnline((int)StoreUserService::getLoginUserId()),
}*/
return $this->renderSuccess([
// 用户信息
'userInfo' => StoreUserModel::detail(StoreUserService::getLoginUserId()),
// 菜单权限
'roles' => StoreRoleService::getLoginPermissions(),
]);
}
/**
* 管理员列表
* @return array
* @throws \think\db\exception\DbException
*/
public function list()
{
$model = new StoreUserModel;
$list = $model->getList($this->request->param(),$this->store['user']);
return $this->renderSuccess(compact('list'));
}
/**
* 添加管理员
* @return array
*/
public function add()
{
// 新增记录
$model = new StoreUserModel;
if ($model->add($this->postForm(),$this->store['user'])) {
return $this->renderSuccess('添加成功');
}
return $this->renderError($model->getError() ?: '添加失败');
}
/**
* 更新管理员
* @param int $userId
* @return array
*/
public function edit(int $userId)
{
// 管理员详情
$model = StoreUserModel::detail($userId);
// 更新记录
if ($model->edit($this->postForm(),$this->store['user'])) {
return $this->renderSuccess('更新成功');
}
return $this->renderError($model->getError() ?: '更新失败');
}
/**
* 删除管理员
* @param int $userId
* @return array|bool
*/
public function delete(int $userId)
{
// 管理员详情
$model = StoreUserModel::detail($userId);
if (!$model->setDelete()) {
return $this->renderError($model->getError() ?: '删除失败');
}
return $this->renderSuccess('删除成功');
}
/**
* 更新当前管理员信息
* @return array|bool|string
*/
public function renew()
{
// 管理员详情
$model = StoreUserModel::detail(StoreUserService::getLoginUserId());
// 更新当前管理员信息
if ($model->renew($this->postForm())) {
return $this->renderSuccess('更新成功');
}
return $this->renderError($model->getError() ?: '更新失败');
}
/**
* 更新状态
* * @param $status
* @return array|mixed
* @throws \think\exception\DbException
*/
public function state($status)
{
$text = $status == 1?"已上线":"已下线";
// 管理员详情
$model = StoreUserModel::detail($this->store['user']['store_user_id']);
$warn = $model->setStatus($status);
if ($warn !== true) {
return $this->renderError($warn);
}
return $this->renderSuccess($text);
}
}