总后台数据授权和商城列表

pull/1/head
lqmac 12 months ago
parent 32a03a000b
commit e01e665488
  1. 1
      .gitignore
  2. 210
      app/admin/controller/Goods.php
  3. 57
      app/admin/controller/Store.php
  4. 28
      app/admin/model/store/SyncTask.php
  5. 40
      config/database.php

1
.gitignore vendored

@ -5,3 +5,4 @@
/runtime /runtime
/public/uploads /public/uploads
/public/static /public/static
sftp-config.json

@ -0,0 +1,210 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\admin\controller;
use think\response\Json;
use think\facade\Db;
/**
* 商城管理
* Class Store
* @package app\admin\controller
*/
class Goods extends Controller
{
/**
* 强制验证当前访问的控制器方法method
* @var array
*/
protected array $methodRules = [
'index' => 'GET',
'recycle' => 'GET',
'add' => 'POST',
'move' => 'POST',
'delete' => 'POST',
];
/**
* 商城列表
* @return Json
* @throws \think\db\exception\DbException
*/
public function index(): Json
{
$list = Db::connect("dataCenterMysql")->table('goods_sku')
->order('update_time desc')
->paginate(15);
return $this->renderSuccess(compact('list'));
}
/**
* 获取商城登录token
* @param int $storeId
* @return Json
*/
public function superLogin(int $storeId): Json
{
// 获取指定商城的管理员用户信息
$userInfo = StoreUserService::getUserInfoByStoreId($storeId);
if (empty($userInfo)) {
return $this->renderError('未找到该商城管理员用户');
}
// 登录商户后台
$token = StoreUserService::login($userInfo->toArray());
return $this->renderSuccess([
'userId' => $userInfo['store_user_id'],
'token' => $token
]);
}
/**
* 回收站列表
* @return Json
* @throws \think\db\exception\DbException
*/
public function recycle(): Json
{
// 商城列表
$model = new StoreModel;
$list = $model->getList(true);
return $this->renderSuccess(compact('list'));
}
/**
* 新增商城
* @return Json
*/
public function add(): Json
{
// 新增记录
$model = new StoreModel;
if ($model->add($this->postForm())) {
return $this->renderSuccess('添加成功');
}
return $this->renderError($model->getError() ?: '添加失败');
}
/**
* 移入回收站
* @param int $storeId
* @return Json
*/
public function recovery(int $storeId): Json
{
// 商城详情
$model = StoreModel::detail($storeId);
if (!$model->recycle()) {
return $this->renderError($model->getError() ?: '操作失败');
}
return $this->renderSuccess('操作成功');
}
/**
* 移出回收站
* @param int $storeId
* @return Json
*/
public function move(int $storeId): Json
{
// 商城详情
$model = StoreModel::detail($storeId);
if (!$model->recycle(false)) {
return $this->renderError($model->getError() ?: '操作失败');
}
return $this->renderSuccess('操作成功');
}
/**
* 删除商城
* @param int $storeId
* @return Json
*/
public function delete(int $storeId): Json
{
// 商城详情
$model = StoreModel::detail($storeId);
if (!$model->setDelete()) {
return $this->renderError($model->getError() ?: '操作失败');
}
return $this->renderSuccess('操作成功');
}
/**
* 审核商城
* @param int $storeId
* @return Json
*/
public function audit(int $storeId): Json
{
// 商城详情
$model = StoreModel::detail($storeId);
if (!$model->auditStore($this->request->param())) {
return $this->renderError($model->getError() ?: '操作失败');
}
return $this->renderSuccess('操作成功');
}
/**
* 审核商城
* @param int $storeId
* @return Json
*/
public function platformList(): Json
{
$platformList = [
'sn' => "苏宁"
];
return $this->renderSuccess($platformList);
}
/**
* 审核商城
* @param int $storeId
* @return Json
*/
public function getStorePlatform(int $storeId): Json
{
$list = SyncTask::where("store_id", $storeId)->order('create_time desc')->select()->toArray();
return $this->renderSuccess($list);
}
/**
* 审核商城
* @param int $storeId
* @return Json
*/
public function auth(int $storeId): Json
{
SyncTask::where('store_id', $storeId)->delete();
$platformList = $this->request->param('platformList');
$inData = [];
foreach ($platformList as $value) {
$inData[] = [
'store_id' => $storeId,
'channel' => $value,
'create_time' => time(),
];
}
$model = new SyncTask;
$model->addAll($inData);
return $this->renderSuccess('操作成功');
}
}

@ -14,6 +14,7 @@ namespace app\admin\controller;
use think\response\Json; use think\response\Json;
use app\admin\model\Store as StoreModel; use app\admin\model\Store as StoreModel;
use app\admin\model\store\SyncTask;
use app\admin\service\store\User as StoreUserService; use app\admin\service\store\User as StoreUserService;
/** /**
@ -154,5 +155,61 @@ class Store extends Controller
} }
return $this->renderSuccess('操作成功'); return $this->renderSuccess('操作成功');
} }
/**
* 审核商城
* @param int $storeId
* @return Json
*/
public function platformList(): Json
{
$platformList = [
'sn' => "苏宁"
];
return $this->renderSuccess($platformList);
}
/**
* 审核商城
* @param int $storeId
* @return Json
*/
public function getStorePlatform(int $storeId): Json
{
$list = SyncTask::where("store_id", $storeId)->order('create_time desc')->select()->toArray();
return $this->renderSuccess($list);
}
/**
* 审核商城
* @param int $storeId
* @return Json
*/
public function auth(int $storeId): Json
{
SyncTask::where('store_id', $storeId)->delete();
$platformList = $this->request->param('platformList');
$inData = [];
foreach ($platformList as $value) {
$inData[] = [
'store_id' => $storeId,
'channel' => $value,
'create_time' => time(),
];
}
$model = new SyncTask;
$model->addAll($inData);
return $this->renderSuccess('操作成功');
}
} }

@ -0,0 +1,28 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\admin\model\store;
use cores\BaseModel;
/**
* 商家功能模块模型
* Class Module
* @package app\admin\model\store
*/
class SyncTask extends BaseModel
{
// 定义表名
protected $name = 'sync_task';
// 定义表主键
protected $pk = 'id';
}

@ -72,7 +72,47 @@ return [
// 字段缓存路径 // 字段缓存路径
'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR, 'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR,
], ],
'dataCenterMysql' => [
// 数据库类型
'type' => env('database.type', 'mysql'),
// 服务器地址
'hostname' => env('database.hostname', $config['host']),
// 数据库名
'database' => "data_center",
// 用户名
'username' => env('database.username', $config['username']),
// 密码
'password' => env('database.password', $config['password']),
// 端口
'hostport' => env('database.hostport', $config['hostport']),
// 数据库连接参数
'params' => [],
// 数据库编码默认采用utf8
'charset' => env('database.charset', 'utf8'),
// 数据库表前缀
'prefix' => "",
// 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
'deploy' => 0,
// 数据库读写是否分离 主从式有效
'rw_separate' => false,
// 读写分离后 主服务器数量
'master_num' => 1,
// 指定从服务器序号
'slave_no' => '',
// 是否严格检查字段是否存在
'fields_strict' => true,
// 是否需要断线重连
'break_reconnect' => false,
// 监听SQL
'trigger_sql' => true,
// 开启字段缓存
'fields_cache' => false,
// 字段缓存路径
'schema_cache_path' => app()->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR,
],
// 更多的数据库配置信息 // 更多的数据库配置信息
], ],
]; ];

Loading…
Cancel
Save