初始化项目
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 萤火科技 <admin@yiovo.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\common\model\store;
|
||||
|
||||
use cores\BaseModel;
|
||||
use app\common\model\Region as RegionModel;
|
||||
|
||||
/**
|
||||
* 商家地址模型
|
||||
* Class Address
|
||||
* @package app\common\model\store
|
||||
*/
|
||||
class Address extends BaseModel
|
||||
{
|
||||
// 定义表名
|
||||
protected $name = 'store_address';
|
||||
|
||||
// 定义主键
|
||||
protected $pk = 'address_id';
|
||||
|
||||
/**
|
||||
* 追加字段
|
||||
* @var array
|
||||
*/
|
||||
protected $append = ['cascader', 'region', 'full_address'];
|
||||
|
||||
/**
|
||||
* 省市区id集
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function getCascaderAttr($value, $data)
|
||||
{
|
||||
return [$data['province_id'], $data['city_id'], $data['region_id']];
|
||||
}
|
||||
|
||||
/**
|
||||
* 省市区名称集
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return array
|
||||
*/
|
||||
public function getRegionAttr($value, $data)
|
||||
{
|
||||
return $this->getRegionNames($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取完整地址
|
||||
* @return string
|
||||
*/
|
||||
public function getFullAddressAttr($value, $data)
|
||||
{
|
||||
$rgionNames = $this->getRegionNames($data);
|
||||
return "{$rgionNames['province']}{$rgionNames['city']}{$rgionNames['region']}{$data['detail']}";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取省市区名称
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
private function getRegionNames(array $data)
|
||||
{
|
||||
static $dataset = [];
|
||||
$id = $data[$this->getPk()];
|
||||
if (!isset($dataset[$id])) {
|
||||
$dataset[$id] = [
|
||||
'province' => RegionModel::getNameById($data['province_id']),
|
||||
'city' => RegionModel::getNameById($data['city_id']),
|
||||
'region' => RegionModel::getNameById($data['region_id']),
|
||||
];
|
||||
}
|
||||
return $dataset[$id];
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情记录
|
||||
* @param int $addressId
|
||||
* @return null|static
|
||||
*/
|
||||
public static function detail(int $addressId)
|
||||
{
|
||||
return self::get($addressId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 萤火科技 <admin@yiovo.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\common\model\store;
|
||||
|
||||
use cores\BaseModel;
|
||||
|
||||
/**
|
||||
* 商家后台API权限模型
|
||||
* Class Api
|
||||
* @package app\common\model\admin
|
||||
*/
|
||||
class Api extends BaseModel
|
||||
{
|
||||
// 定义表名
|
||||
protected $name = 'store_api';
|
||||
|
||||
// 定义表主键
|
||||
protected $pk = 'api_id';
|
||||
|
||||
/**
|
||||
* 获取所有权限
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
protected static function getAll()
|
||||
{
|
||||
$data = static::withoutGlobalScope()
|
||||
->order(['sort', 'create_time'])
|
||||
->select();
|
||||
return !$data->isEmpty() ? $data->toArray() : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限信息
|
||||
* @param int|array $where
|
||||
* @return array|null|static
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public static function detail($where)
|
||||
{
|
||||
$model = static::withoutGlobalScope();
|
||||
is_array($where) ? $model->where($where) : $model->where('api_id', '=', $where);
|
||||
return $model->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定ID集的url
|
||||
* @param array $apiIds
|
||||
* @return array
|
||||
*/
|
||||
public static function getApiUrls(array $apiIds)
|
||||
{
|
||||
return static::withoutGlobalScope()
|
||||
->where('api_id', 'in', $apiIds)
|
||||
->order(['sort', 'create_time'])
|
||||
->column('url');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 萤火科技 <admin@yiovo.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\common\model\store;
|
||||
|
||||
use app\common\library\helper;
|
||||
use cores\BaseModel;
|
||||
|
||||
/**
|
||||
* 商家后台菜单模型
|
||||
* Class Menu
|
||||
* @package app\common\model\admin
|
||||
*/
|
||||
class Menu extends BaseModel
|
||||
{
|
||||
// 定义表名
|
||||
protected $name = 'store_menu';
|
||||
|
||||
// 定义表主键
|
||||
protected $pk = 'menu_id';
|
||||
|
||||
/**
|
||||
* 关联操作权限
|
||||
* @return \think\model\relation\HasMany
|
||||
*/
|
||||
public function menuApi()
|
||||
{
|
||||
return $this->hasMany('MenuApi', 'menu_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getList()
|
||||
{
|
||||
$list = static::getAll();
|
||||
return $this->getTreeData($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有菜单
|
||||
* @param array $where
|
||||
* @return \think\Collection
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
protected static function getAll(array $where = [])
|
||||
{
|
||||
// 菜单列表
|
||||
$model = (new static)->addHidden(['menuApi']);
|
||||
$list = static::withoutGlobalScope()
|
||||
->with(['menuApi'])
|
||||
->where($where)
|
||||
->order(['sort' => 'asc', 'create_time' => 'asc'])
|
||||
->select();
|
||||
// 整理菜单绑定的apiID集
|
||||
return $model->getMenuApiIds($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取树状菜单列表
|
||||
* @param $menuList
|
||||
* @param int $parentId
|
||||
* @return array
|
||||
*/
|
||||
protected function getTreeData($menuList, int $parentId = 0)
|
||||
{
|
||||
$data = [];
|
||||
foreach ($menuList as $key => $item) {
|
||||
if ($item['parent_id'] == $parentId) {
|
||||
$children = $this->getTreeData($menuList, (int)$item['menu_id']);
|
||||
!empty($children) && $item['children'] = $children;
|
||||
$data[] = $item;
|
||||
unset($menuList[$key]);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 整理菜单的api ID集
|
||||
* @param $menuList
|
||||
* @return mixed
|
||||
*/
|
||||
private function getMenuApiIds($menuList)
|
||||
{
|
||||
foreach ($menuList as &$item) {
|
||||
if (!empty($item['menuApi'])) {
|
||||
$item['apiIds'] = helper::getArrayColumn($item['menuApi'], 'api_id');
|
||||
}
|
||||
}
|
||||
return $menuList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单信息
|
||||
* @param int|array $where
|
||||
* @return array|null|static
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public static function detail($where)
|
||||
{
|
||||
$query = static::withoutGlobalScope();
|
||||
is_array($where) ? $query->where($where) : $query->where('menu_id', '=', $where);
|
||||
return $query->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单url集
|
||||
* @param $menuIds
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public static function getMenuUrls($menuIds)
|
||||
{
|
||||
$urls = [];
|
||||
foreach (static::getAll() as $item) {
|
||||
in_array($item['menu_id'], $menuIds) && $urls[] = $item['url'];
|
||||
}
|
||||
return $urls;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 萤火科技 <admin@yiovo.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\common\model\store;
|
||||
|
||||
use cores\BaseModel;
|
||||
|
||||
/**
|
||||
* 商家后台用户角色与菜单权限关系表模型
|
||||
* Class MenuApi
|
||||
* @package app\common\model\store
|
||||
*/
|
||||
class MenuApi extends BaseModel
|
||||
{
|
||||
// 定义表名
|
||||
protected $name = 'store_menu_api';
|
||||
|
||||
// 定义表主键
|
||||
protected $pk = 'id';
|
||||
|
||||
protected $updateTime = false;
|
||||
|
||||
// 不允许全局查询store_id
|
||||
protected $isGlobalScopeStoreId = false;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 萤火科技 <admin@yiovo.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\common\model\store;
|
||||
|
||||
use cores\BaseModel;
|
||||
|
||||
/**
|
||||
* 商家用户角色模型
|
||||
* Class Role
|
||||
* @package app\common\model\admin
|
||||
*/
|
||||
class Role extends BaseModel
|
||||
{
|
||||
// 定义表名
|
||||
protected $name = 'store_role';
|
||||
|
||||
// 定义主键
|
||||
protected $pk = 'role_id';
|
||||
|
||||
/**
|
||||
* 关联操作权限
|
||||
* @return \think\model\relation\HasMany
|
||||
*/
|
||||
public function roleMenu()
|
||||
{
|
||||
return $this->hasMany('RoleMenu', 'role_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联创建人
|
||||
* @return \think\model\relation\HasMany
|
||||
*/
|
||||
public function storeUser()
|
||||
{
|
||||
return $this->hasOne('User', 'store_user_id','store_user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
* @param $where
|
||||
* @return array|null|static
|
||||
*/
|
||||
public static function detail($where)
|
||||
{
|
||||
return static::get($where);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 萤火科技 <admin@yiovo.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\common\model\store;
|
||||
|
||||
use cores\BaseModel;
|
||||
|
||||
/**
|
||||
* 商家后台用户角色与菜单权限关系模型
|
||||
* Class RoleAccess
|
||||
* @package app\common\model\admin
|
||||
*/
|
||||
class RoleMenu extends BaseModel
|
||||
{
|
||||
// 定义表名
|
||||
protected $name = 'store_role_menu';
|
||||
|
||||
protected $updateTime = false;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 萤火科技 <admin@yiovo.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\common\model\store;
|
||||
|
||||
use think\facade\Cache;
|
||||
use app\common\library\helper;
|
||||
use cores\BaseModel;
|
||||
use app\common\enum\Setting as SettingEnum;
|
||||
use app\common\enum\file\Storage as StorageEnum;
|
||||
use app\common\enum\order\DeliveryType as DeliveryTypeEnum;
|
||||
use app\common\enum\setting\sms\Scene as SettingSmsSceneEnum;
|
||||
use app\common\enum\store\page\category\Style as PageCategoryStyleEnum;
|
||||
|
||||
/**
|
||||
* 系统设置模型
|
||||
* Class Setting
|
||||
* @package app\common\model
|
||||
*/
|
||||
class Setting extends BaseModel
|
||||
{
|
||||
// 定义表名
|
||||
protected $name = 'store_setting';
|
||||
|
||||
/**
|
||||
* 获取器: 转义数组格式
|
||||
* @param $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValuesAttr($value)
|
||||
{
|
||||
return helper::jsonDecode($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改器: 转义成json格式
|
||||
* @param $value
|
||||
* @return string
|
||||
*/
|
||||
public function setValuesAttr($value): string
|
||||
{
|
||||
return helper::jsonEncode($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定项设置
|
||||
* @param string $key
|
||||
* @param int|null $storeId
|
||||
* @return array|mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public static function getItem(string $key, int $storeId = null)
|
||||
{
|
||||
$data = self::getAll($storeId);
|
||||
return isset($data[$key]) ? $data[$key]['values'] : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设置项信息
|
||||
* @param string $key
|
||||
* @param int|null $storeId
|
||||
* @return array|\think\Model|null
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public static function detail(string $key, int $storeId = null)
|
||||
{
|
||||
$query = (new static)->getNewQuery();
|
||||
$storeId > 0 && $query->where('store_id', '=', $storeId);
|
||||
return $query->where('key', '=', $key)->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局缓存: 系统设置
|
||||
* @param int|null $storeId
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public static function getAll(int $storeId = null): array
|
||||
{
|
||||
$model = new static;
|
||||
is_null($storeId) && $storeId = static::$storeId;
|
||||
if (!$data = Cache::get("setting_{$storeId}")) {
|
||||
// 获取商城设置列表
|
||||
$setting = $model->getList($storeId);
|
||||
$data = $setting->isEmpty() ? [] : helper::arrayColumn2Key($setting->toArray(), 'key');
|
||||
// 写入缓存中
|
||||
Cache::tag('cache')->set("setting_{$storeId}", $data);
|
||||
}
|
||||
// 合并默认设置
|
||||
return array_merge_multiple($model->defaultData(), $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商城设置列表
|
||||
* @param $storeId
|
||||
* @return \think\Collection
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
private function getList(int $storeId)
|
||||
{
|
||||
return $this->where('store_id', '=', $storeId)->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认配置
|
||||
* @return array
|
||||
*/
|
||||
public function defaultData(): array
|
||||
{
|
||||
return [
|
||||
// 配送设置
|
||||
SettingEnum::DELIVERY => [
|
||||
'key' => SettingEnum::DELIVERY,
|
||||
'describe' => '配送设置',
|
||||
'values' => [
|
||||
// 配送方式
|
||||
'delivery_type' => array_keys(DeliveryTypeEnum::data()),
|
||||
// 快递100
|
||||
'kuaidi100' => [
|
||||
'customer' => '',
|
||||
'key' => '',
|
||||
]
|
||||
],
|
||||
],
|
||||
// 交易设置
|
||||
SettingEnum::TRADE => [
|
||||
'key' => SettingEnum::TRADE,
|
||||
'describe' => '交易设置',
|
||||
'values' => [
|
||||
// 订单流程设置
|
||||
'order' => [
|
||||
// 'close_days' => '3', // 已废弃
|
||||
'closeHours' => 3 * 24, // 未支付订单自动关闭期限(单位:小时)
|
||||
'receive_days' => '10',
|
||||
'refund_days' => '7'
|
||||
],
|
||||
// 运费组合策略
|
||||
'freight_rule' => '10',
|
||||
'expiration_time' => '18000',
|
||||
]
|
||||
],
|
||||
// 上传设置
|
||||
SettingEnum::STORAGE => [
|
||||
'key' => SettingEnum::STORAGE,
|
||||
'describe' => '上传设置',
|
||||
'values' => [
|
||||
'default' => StorageEnum::LOCAL,
|
||||
'engine' => [
|
||||
StorageEnum::LOCAL => null,
|
||||
StorageEnum::QINIU => [
|
||||
'bucket' => '',
|
||||
'access_key' => '',
|
||||
'secret_key' => '',
|
||||
'domain' => 'http://'
|
||||
],
|
||||
StorageEnum::ALIYUN => [
|
||||
'bucket' => '',
|
||||
'access_key_id' => '',
|
||||
'access_key_secret' => '',
|
||||
'domain' => 'http://'
|
||||
],
|
||||
StorageEnum::QCLOUD => [
|
||||
'bucket' => '',
|
||||
'region' => '',
|
||||
'secret_id' => '',
|
||||
'secret_key' => '',
|
||||
'domain' => 'http://'
|
||||
],
|
||||
]
|
||||
],
|
||||
],
|
||||
// 短信通知
|
||||
SettingEnum::SMS => [
|
||||
'key' => SettingEnum::SMS,
|
||||
'describe' => '短信通知',
|
||||
'values' => [
|
||||
'default' => 'aliyun',
|
||||
// 短信服务渠道
|
||||
'engine' => [
|
||||
// 阿里云
|
||||
'aliyun' => [
|
||||
'name' => '阿里云短信',
|
||||
'website' => 'https://dysms.console.aliyun.com/dysms.htm',
|
||||
'AccessKeyId' => '',
|
||||
'AccessKeySecret' => '',
|
||||
'sign' => '萤火商城' // 短信签名
|
||||
],
|
||||
// 腾讯云
|
||||
'qcloud' => [
|
||||
'name' => '腾讯云短信',
|
||||
'website' => 'https://console.cloud.tencent.com/smsv2',
|
||||
'SdkAppID' => '',
|
||||
'AccessKeyId' => '',
|
||||
'AccessKeySecret' => '',
|
||||
'sign' => '萤火商城' // 短信签名
|
||||
],
|
||||
// 七牛云
|
||||
'qiniu' => [
|
||||
'name' => '七牛云短信',
|
||||
'website' => 'https://portal.qiniu.com/sms/dashboard',
|
||||
'AccessKey' => '',
|
||||
'SecretKey' => '',
|
||||
'sign' => '萤火商城' // 短信签名
|
||||
],
|
||||
],
|
||||
// 短信通知场景
|
||||
'scene' => [
|
||||
// 短信验证码
|
||||
SettingSmsSceneEnum::CAPTCHA => [
|
||||
'name' => '短信验证码 (通知用户)', // 场景名称
|
||||
'isEnable' => false, // 是否开启
|
||||
'templateCode' => '', // 模板ID
|
||||
'content' => '验证码%s,您正在进行身份验证,打死不要告诉别人哦!',
|
||||
'variables' => [
|
||||
'aliyun' => ['${code}'],
|
||||
'qiniu' => ['${code}'],
|
||||
'qcloud' => ['{1}'],
|
||||
]
|
||||
],
|
||||
// 新付款订单
|
||||
SettingSmsSceneEnum::ORDER_PAY => [
|
||||
'name' => '新付款订单 (通知商家)', // 场景名称
|
||||
'isEnable' => false, // 是否开启
|
||||
'templateCode' => '', // 模板ID
|
||||
'acceptPhone' => '', // 接收手机号
|
||||
'content' => '您有一条新订单,订单号为:%s,请注意查看',
|
||||
'variables' => [
|
||||
'aliyun' => ['${order_no}'],
|
||||
'qiniu' => ['${order_no}'],
|
||||
'qcloud' => ['{1}'],
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
],
|
||||
// 满额包邮设置
|
||||
SettingEnum::FULL_FREE => [
|
||||
'key' => SettingEnum::FULL_FREE,
|
||||
'describe' => '满额包邮设置',
|
||||
'values' => [
|
||||
'is_open' => 0, // 是否开启满额包邮
|
||||
'money' => '', // 单笔订单额度
|
||||
'excludedRegions' => [ // 不参与包邮的地区
|
||||
'cityIds' => [], // 城市ID集
|
||||
'selectedText' => '' // 选择的地区(文字)
|
||||
],
|
||||
'excludedGoodsIds' => [], // 不参与包邮的商品 (ID集)
|
||||
'describe' => '' // 满额包邮说明
|
||||
],
|
||||
],
|
||||
// 账户注册设置
|
||||
SettingEnum::REGISTER => [
|
||||
'key' => SettingEnum::REGISTER,
|
||||
'describe' => '账户注册设置',
|
||||
'values' => [
|
||||
'registerMethod' => 10, // 默认注册方式: 10=>手机号+短信验证码
|
||||
'isOauthMpweixin' => 1, // 是否开启微信小程序一键授权登录
|
||||
'isForceBindMpweixin' => 1, // 客户端是否强制绑定手机号(微信小程序)
|
||||
'isManualBind' => 1, // 个人中心页显示手动绑定手机号
|
||||
],
|
||||
],
|
||||
// 用户充值设置
|
||||
SettingEnum::RECHARGE => [
|
||||
'key' => SettingEnum::RECHARGE,
|
||||
'describe' => '用户充值设置',
|
||||
'values' => [
|
||||
'is_entrance' => 1, // 是否允许用户充值
|
||||
'is_custom' => 1, // 是否允许自定义金额
|
||||
'lowest_money' => 10, // 最低充值金额
|
||||
'is_match_plan' => 1, // 自定义金额是否自动匹配合适的套餐
|
||||
'describe' => "1. 账户充值仅限微信在线方式支付,充值金额实时到账;\n" .
|
||||
"2. 账户充值套餐赠送的金额即时到账;\n" .
|
||||
"3. 账户余额有效期:自充值日起至用完即止;\n" .
|
||||
"4. 若有其它疑问,可拨打客服电话400-000-1234", // 充值说明
|
||||
],
|
||||
],
|
||||
// 积分设置
|
||||
SettingEnum::POINTS => [
|
||||
'key' => SettingEnum::POINTS,
|
||||
'describe' => SettingEnum::data()[SettingEnum::POINTS]['describe'],
|
||||
'values' => [
|
||||
'points_name' => '积分', // 积分名称自定义
|
||||
'is_shopping_gift' => 0, // 是否开启购物送积分
|
||||
'gift_ratio' => '100', // 积分赠送比例
|
||||
'is_shopping_discount' => 0, // 是否允许下单使用积分抵扣
|
||||
'discount' => [ // 积分抵扣
|
||||
'discount_ratio' => '0.01', // 积分抵扣比例
|
||||
'full_order_price' => '100.00', // 订单满[?]元
|
||||
'max_money_ratio' => '10', // 最高可抵扣订单额百分比
|
||||
],
|
||||
// 积分说明
|
||||
'describe' => "a) 积分不可兑现、不可转让,仅可在本平台使用;\n" .
|
||||
"b) 您在本平台参加特定活动也可使用积分,详细使用规则以具体活动时的规则为准;\n" .
|
||||
"c) 积分的数值精确到个位(小数点后全部舍弃,不进行四舍五入)\n" .
|
||||
"d) 买家在完成该笔交易(订单状态为“已签收”)后才能得到此笔交易的相应积分,如购买商品参加店铺其他优惠,则优惠的金额部分不享受积分获取;",
|
||||
],
|
||||
],
|
||||
// 分类页模板
|
||||
SettingEnum::PAGE_CATEGORY_TEMPLATE => [
|
||||
'key' => SettingEnum::PAGE_CATEGORY_TEMPLATE,
|
||||
'describe' => '分类页模板设置',
|
||||
'values' => [
|
||||
'style' => PageCategoryStyleEnum::COMMODITY, // 分类页样式
|
||||
'shareTitle' => '全部分类', // 分享标题
|
||||
'showAddCart' => true, // 是否显示购物车按钮
|
||||
'cartStyle' => 1, // 购物车按钮样式 1-3
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 萤火科技 <admin@yiovo.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\common\model\store;
|
||||
|
||||
use cores\BaseModel;
|
||||
use think\Session;
|
||||
|
||||
/**
|
||||
* 商家用户模型
|
||||
* Class User
|
||||
* @package app\common\model
|
||||
*/
|
||||
class User extends BaseModel
|
||||
{
|
||||
// 定义表名
|
||||
protected $name = 'store_user';
|
||||
|
||||
// 定义主键
|
||||
protected $pk = 'store_user_id';
|
||||
|
||||
/**
|
||||
* 关联商家记录表
|
||||
* @return \think\model\relation\BelongsTo
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
$module = self::getCalledModule();
|
||||
return $this->belongsTo("app\\{$module}\\model\\Store", 'store_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联用户角色表表
|
||||
* @return \think\model\relation\BelongsToMany
|
||||
*/
|
||||
public function role()
|
||||
{
|
||||
return $this->belongsToMany('Role', 'StoreUserRole');
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联父级用户
|
||||
* @return \think\model\relation\BelongsTo
|
||||
*/
|
||||
public function parentUser()
|
||||
{
|
||||
return $this->belongsTo('User','parent_id','store_user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证用户名是否重复
|
||||
* @param string $userName
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkExist(string $userName)
|
||||
{
|
||||
return (bool)static::withoutGlobalScope()
|
||||
->where('user_name', '=', $userName)
|
||||
->where('is_delete', '=', 0)
|
||||
->value('store_user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家用户详情
|
||||
* @param $where
|
||||
* @param array $with
|
||||
* @return array|static|null
|
||||
*/
|
||||
public static function detail($where, array $with = [])
|
||||
{
|
||||
return static::get($where, $with);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存登录状态
|
||||
* @param $user
|
||||
* @throws \think\Exception
|
||||
*/
|
||||
public function loginState($user)
|
||||
{
|
||||
/** @var \app\common\model\Wxapp $wxapp */
|
||||
$wxapp = $user['wxapp'];
|
||||
// 保存登录状态
|
||||
Session::set('yoshop_store', [
|
||||
'user' => [
|
||||
'store_user_id' => $user['store_user_id'],
|
||||
'user_name' => $user['user_name'],
|
||||
'is_super' => $user['is_super'],
|
||||
'status' => $user['status'],
|
||||
'level' => $user['level'],
|
||||
'parent_id' => $user['parent_id'],
|
||||
'merchant_id' => $user['merchant_id'],
|
||||
],
|
||||
'wxapp' => $wxapp->toArray(),
|
||||
'is_login' => true,
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* 切换状态
|
||||
* @param $status
|
||||
* @return false|int
|
||||
*/
|
||||
public function setStatus($status)
|
||||
{
|
||||
if($status == 1 && $this['stop_date'] == date("Y-m-d")){
|
||||
return '当天已到达收款上限,停止接单';
|
||||
}
|
||||
if($bool = $this->save(['status' => $status])){
|
||||
$session = Session::get('yoshop_store');
|
||||
$session['user']['status'] = $status;
|
||||
// 保存登录状态
|
||||
Session::set('yoshop_store', $session);
|
||||
$bool = true;
|
||||
}
|
||||
return $bool;
|
||||
}
|
||||
/**
|
||||
* 获取全部
|
||||
* @param array $user
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getAll($user = [])
|
||||
{
|
||||
$filter = [];
|
||||
if($user['is_super'] == 0) {
|
||||
$filter[] = ['store_user_id', 'in', \app\store\model\store\User::getScope($user)];
|
||||
}
|
||||
$model = new static;
|
||||
//return $model->where('is_delete', '=', 0)->where('is_super', '=', 0)->where($filter)->order(['store_user_id' => 'asc'])->select();
|
||||
return $model->where('is_delete', '=', 0)->where($filter)->order(['store_user_id' => 'asc'])->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取在线人员
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getOnline()
|
||||
{
|
||||
$model = new static;
|
||||
//在线,并且当天未停止接单
|
||||
$data = $model->where('status', '=', 1)->where('stop_date', '!=', date('Y-m-d'))->order(['store_user_id' => 'asc'])->select()->toArray();
|
||||
return array_column($data,'store_user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换状态
|
||||
* @param $status
|
||||
* @param $user
|
||||
* @return false|int
|
||||
*/
|
||||
public function changeStatus($status,$user)
|
||||
{
|
||||
if($status == 1 && $this['stop_date'] == date("Y-m-d")){
|
||||
return '当天已到达收款上限,停止接单';
|
||||
}
|
||||
if($bool = $this->save(['status' => $status])){
|
||||
//如果是自己则修改在线状态的session
|
||||
if($this['store_user_id'] == $user['store_user_id']) {
|
||||
$session = Session::get('yoshop_store');
|
||||
$session['user']['status'] = $status;
|
||||
// 保存登录状态
|
||||
Session::set('yoshop_store', $session);
|
||||
}
|
||||
$bool = true;
|
||||
}
|
||||
return $bool;
|
||||
}
|
||||
/**
|
||||
* 修改收款金额
|
||||
* @param $data
|
||||
* @return bool
|
||||
*/
|
||||
public function updateMoney($data)
|
||||
{
|
||||
if ($data['money'] <= 0) {
|
||||
$this->error = '收款金额必须大于0';
|
||||
return false;
|
||||
}
|
||||
return $this->save([
|
||||
'max_money' => $data['money'],
|
||||
]) !== false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: 萤火科技 <admin@yiovo.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\common\model\store;
|
||||
|
||||
use cores\BaseModel;
|
||||
|
||||
/**
|
||||
* 商家用户角色模型
|
||||
* Class UserRole
|
||||
* @package app\common\model\admin
|
||||
*/
|
||||
class UserRole extends BaseModel
|
||||
{
|
||||
// 定义表名
|
||||
protected $name = 'store_user_role';
|
||||
|
||||
// 定义主键
|
||||
protected $pk = 'id';
|
||||
|
||||
protected $updateTime = false;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user