初始上传
This commit is contained in:
116
app/model/web/Account.php
Executable file
116
app/model/web/Account.php
Executable file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\web;
|
||||
|
||||
use app\model\BaseModel;
|
||||
|
||||
/**
|
||||
* 系统站账户
|
||||
*/
|
||||
class Account extends BaseModel
|
||||
{
|
||||
public $from_type = [
|
||||
'order' => [
|
||||
'type_name' => '订单结算',
|
||||
'type_url' => '',
|
||||
],
|
||||
'withdraw' => [
|
||||
'type_name' => '提现',
|
||||
'type_url' => '',
|
||||
],
|
||||
];
|
||||
/**************************************************************店铺账户****************************************************************/
|
||||
/**
|
||||
* 添加分站账户数据
|
||||
* @param int $site_id
|
||||
* @param int $account_type 账户类型 默认account
|
||||
* @param float $account_data
|
||||
* @param $from_type
|
||||
* @param $relate_tag
|
||||
* @param string $remark
|
||||
* @return array
|
||||
*/
|
||||
public function addAccount($site_id, $account_type, $account_data, $from_type, $relate_tag, $remark)
|
||||
{
|
||||
$data = array (
|
||||
'account_no' => date('YmdHi') . rand(1000, 9999),
|
||||
'site_id' => $site_id,
|
||||
'account_type' => $account_type,
|
||||
'account_data' => $account_data,
|
||||
'from_type' => $from_type,
|
||||
'relate_tag' => $relate_tag,
|
||||
'create_time' => time(),
|
||||
'remark' => $remark
|
||||
);
|
||||
|
||||
$account = model('website')->getInfo([
|
||||
'site_id' => 0
|
||||
], $account_type);
|
||||
$account_new_data = (float) $account[ $account_type ] + (float) $account_data;
|
||||
if ((float) $account_new_data < 0) {
|
||||
return $this->error('', 'RESULT_ERROR');
|
||||
}
|
||||
|
||||
$res = model('account')->add($data);
|
||||
$res = model('website')->update([
|
||||
$account_type => $account_new_data
|
||||
], [
|
||||
'site_id' => 0
|
||||
]);
|
||||
event('AddAccount', $data);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺账户流水分页
|
||||
* @param unknown $condition
|
||||
* @param number $page
|
||||
* @param string $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @return multitype:number unknown
|
||||
*/
|
||||
public function getAccountPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
|
||||
{
|
||||
|
||||
$list = model('account')->pageList($condition, $field, $order, $page, $page_size);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员金额账户
|
||||
* @return multitype:
|
||||
*/
|
||||
public function getMemberBalanceSum($site_id = 0)
|
||||
{
|
||||
$field = '
|
||||
sum(balance) as balance,
|
||||
sum(balance_money) as balance_money,
|
||||
sum(balance_withdraw_apply) as balance_withdraw_apply,
|
||||
sum(balance_withdraw) as balance_withdraw
|
||||
';
|
||||
$info = model('member')->getInfo([ [ 'member_id', '>', 0 ], [ 'site_id', '=', $site_id ] ], $field);
|
||||
if ($info[ 'balance' ] == null) {
|
||||
$info[ 'balance' ] = '0.00';
|
||||
}
|
||||
if ($info[ 'balance_money' ] == null) {
|
||||
$info[ 'balance_money' ] = '0.00';
|
||||
}
|
||||
if ($info[ 'balance_withdraw_apply' ] == null) {
|
||||
$info[ 'balance_withdraw_apply' ] = '0.00';
|
||||
}
|
||||
if ($info[ 'balance_withdraw' ] == null) {
|
||||
$info[ 'balance_withdraw' ] = '0.00';
|
||||
}
|
||||
return $this->success($info);
|
||||
}
|
||||
|
||||
}
|
||||
122
app/model/web/Adv.php
Executable file
122
app/model/web/Adv.php
Executable file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\web;
|
||||
|
||||
|
||||
use think\facade\Cache;
|
||||
use app\model\BaseModel;
|
||||
use app\model\upload\Upload;
|
||||
|
||||
/**
|
||||
* 广告管理
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class Adv extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 添加广告
|
||||
* @param array $data
|
||||
*/
|
||||
public function addAdv($data)
|
||||
{
|
||||
$ap_id = model('adv')->add($data);
|
||||
Cache::tag('adv')->clear();
|
||||
return $this->success($ap_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改广告
|
||||
* @param array $data
|
||||
*/
|
||||
public function editAdv($data, $condition)
|
||||
{
|
||||
if (isset($data[ 'adv_image' ])) {
|
||||
$adv_info = model('adv')->getInfo($condition);
|
||||
if ($adv_info[ 'adv_image' ] && $data[ 'adv_image' ] && $adv_info[ 'adv_image' ] != $data[ 'adv_image' ]) {
|
||||
$upload_model = new Upload();
|
||||
$upload_model->deletePic($adv_info[ 'adv_image' ], $adv_info[ 'site_id' ]);
|
||||
}
|
||||
}
|
||||
|
||||
$res = model('adv')->update($data, $condition);
|
||||
Cache::tag('adv')->clear();
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除广告
|
||||
* @param array $condition
|
||||
*/
|
||||
public function deleteAdv($condition)
|
||||
{
|
||||
$list = model('adv')->getList($condition);
|
||||
if ($list) {
|
||||
foreach ($list as $k => $v) {
|
||||
if ($v[ 'adv_image' ]) {
|
||||
$upload_model = new Upload();
|
||||
$upload_model->deletePic($v[ 'adv_image' ], $v[ 'site_id' ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$res = model('adv')->delete($condition);
|
||||
Cache::tag('adv')->clear();
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取广告基础信息
|
||||
* @param int $ap_id
|
||||
* @return multitype:string mixed
|
||||
*/
|
||||
public function getAdvInfo($ap_id)
|
||||
{
|
||||
$res = model('adv')->getInfo([ [ 'adv_id', '=', $ap_id ] ], 'adv_id, adv_title, ap_id, adv_url, adv_image, slide_sort, price, background,state');
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取广告列表
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @param string $limit
|
||||
*/
|
||||
public function getAdvList($condition = [], $field = 'adv_id, adv_title, ap_id, adv_url, adv_image, slide_sort, price, background', $order = 'slide_sort desc,adv_id desc', $limit = null)
|
||||
{
|
||||
$list = model('adv')->getList($condition, $field, $order, '', '', '', $limit);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取广告分页列表
|
||||
* @param array $condition
|
||||
* @param number $page
|
||||
* @param string $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
*/
|
||||
public function getAdvPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'a.adv_id desc', $field = 'a.adv_id, a.ap_id, a.adv_title, a.adv_url, a.adv_image, a.slide_sort, a.price, a.background, a.state, ap.ap_name')
|
||||
{
|
||||
$join = [
|
||||
[
|
||||
'adv_position ap',
|
||||
'a.ap_id = ap.ap_id',
|
||||
'left'
|
||||
]
|
||||
];
|
||||
$list = model('adv')->pageList($condition, $field, $order, $page, $page_size, 'a', $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
}
|
||||
124
app/model/web/AdvPosition.php
Executable file
124
app/model/web/AdvPosition.php
Executable file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\web;
|
||||
|
||||
|
||||
use think\facade\Cache;
|
||||
use app\model\BaseModel;
|
||||
|
||||
/**
|
||||
* 广告位管理
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class AdvPosition extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 添加广告位
|
||||
* @param array $data
|
||||
*/
|
||||
public function addAdvPosition($data)
|
||||
{
|
||||
//查询是否有重复关键字
|
||||
$condition = [
|
||||
[ 'keyword', '=', $data[ 'keyword' ] ]
|
||||
];
|
||||
$result = $this->getAdvPositionInfo($condition);
|
||||
if (!empty($result[ 'data' ])) return $this->error('', '广告关键字已存在');
|
||||
$ap_id = model('adv_position')->add($data);
|
||||
Cache::tag("adv_position")->clear();
|
||||
return $this->success($ap_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改广告位
|
||||
* @param array $data
|
||||
*/
|
||||
public function editAdvPosition($data, $condition)
|
||||
{
|
||||
$check_condition = array_column($condition, 2, 0);
|
||||
$ap_id = $check_condition['ap_id'] ?? '';
|
||||
if ($ap_id === '') {
|
||||
return $this->error('', 'REQUEST_SITE_ID');
|
||||
}
|
||||
//查询是否有重复关键字
|
||||
if (isset($data[ 'keyword' ])) {
|
||||
$conditions = [
|
||||
[ 'keyword', '=', $data[ 'keyword' ] ],
|
||||
[ 'ap_id', '<>', $ap_id ],
|
||||
];
|
||||
$result = $this->getAdvPositionInfo($conditions);
|
||||
if (!empty($result[ 'data' ])) return $this->error('', '广告关键字已存在');
|
||||
}
|
||||
$res = model('adv_position')->update($data, $condition);
|
||||
Cache::tag("adv_position")->clear();
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除广告位
|
||||
* @param $condition
|
||||
* @param $ap_ids
|
||||
* @return array
|
||||
*/
|
||||
public function deleteAdvPosition($condition, $ap_ids)
|
||||
{
|
||||
$list = model('adv_position')->getList([ [ 'ap_id', 'in', $ap_ids ], [ 'is_system', '=', 1 ] ]);
|
||||
if ($list) {
|
||||
return $this->error('', '删除的广告位存在系统广告位');
|
||||
}
|
||||
$res = model('adv_position')->delete($condition);
|
||||
Cache::tag("adv_position")->clear();
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取广告位基础信息
|
||||
* @param $condition
|
||||
* @param string $file
|
||||
* @return array
|
||||
*/
|
||||
public function getAdvPositionInfo($condition, $file = 'ap_id, keyword , ap_name, ap_intro, ap_height, ap_width, default_content, ap_background_color, type,is_system,state')
|
||||
{
|
||||
$res = model('adv_position')->getInfo($condition, $file);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取广告位列表
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @param string $limit
|
||||
*/
|
||||
public function getAdvPositionList($condition = [], $field = 'ap_id, keyword , ap_name, ap_intro, ap_height, ap_width, default_content, ap_background_color, type', $order = '', $limit = null)
|
||||
{
|
||||
$list = model('adv_position')->getList($condition, $field, $order, '', '', '', $limit);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取广告位分页列表
|
||||
* @param array $condition
|
||||
* @param number $page
|
||||
* @param string $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
*/
|
||||
public function getAdvPositionPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'ap_id desc', $field = 'ap_id, keyword , ap_name, ap_intro, ap_height, ap_width, default_content, ap_background_color, type,is_system,state')
|
||||
{
|
||||
$list = model('adv_position')->pageList($condition, $field, $order, $page, $page_size);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
}
|
||||
911
app/model/web/Config.php
Executable file
911
app/model/web/Config.php
Executable file
@@ -0,0 +1,911 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\web;
|
||||
|
||||
use app\model\system\Config as ConfigModel;
|
||||
use app\model\BaseModel;
|
||||
use app\model\system\Upgrade;
|
||||
use app\model\upload\Upload;
|
||||
|
||||
/**
|
||||
* 网站系统性设置
|
||||
*/
|
||||
class Config extends BaseModel
|
||||
{
|
||||
//缓存类型
|
||||
private $cache_list = [
|
||||
[
|
||||
'name' => '数据缓存',
|
||||
'desc' => '清除cache数据缓存',
|
||||
'key' => 'content',
|
||||
'btn' => '清除',
|
||||
'icon' => 'public/static/img/cache/data.png'
|
||||
],
|
||||
[
|
||||
'name' => '数据表缓存',
|
||||
'desc' => '新增/修改数据表后,需要清除数据表缓存',
|
||||
'key' => 'data_table_cache',
|
||||
'btn' => '清除',
|
||||
'icon' => 'public/static/img/cache/data_table.png'
|
||||
],
|
||||
[
|
||||
'name' => '模板缓存',
|
||||
'desc' => '模板缓存',
|
||||
'key' => 'template_cache',
|
||||
'btn' => '清除',
|
||||
'icon' => 'public/static/img/cache/template.png'
|
||||
],
|
||||
[
|
||||
'name' => '刷新菜单',
|
||||
'desc' => '新增/修改插件菜单后,需要刷新插件菜单',
|
||||
'key' => 'menu_cache',
|
||||
'btn' => '刷新',
|
||||
'icon' => 'public/static/img/cache/template.png'
|
||||
],
|
||||
[
|
||||
'name' => '刷新自定义模板',
|
||||
'desc' => '新增/修改自定义组件后,需要刷新自定义模板',
|
||||
'key' => 'diy_view',
|
||||
'btn' => '刷新',
|
||||
'icon' => 'public/static/img/cache/template.png'
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* 验证码设置
|
||||
* @param $data
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function setCaptchaConfig($data, $site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '验证码设置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'CAPTCHA_CONFIG']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询验证码设置
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function getCaptchaConfig($site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'CAPTCHA_CONFIG']]);
|
||||
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'shop_login' => 1,
|
||||
'shop_reception_login' => 1,
|
||||
'shop_reception_register' => 1
|
||||
];
|
||||
} else {
|
||||
if (isset($res[ 'data' ][ 'value' ][ 'shop_reception_login' ]) === false) {
|
||||
$res[ 'data' ][ 'value' ][ 'shop_reception_login' ] = 1;
|
||||
}
|
||||
if (isset($res[ 'data' ][ 'value' ][ 'shop_reception_register' ]) === false) {
|
||||
$res[ 'data' ][ 'value' ][ 'shop_reception_register' ] = 1;
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认图上传配置
|
||||
* @param $data
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultImg($data, $site_id = 0, $app_module = 'shop')
|
||||
{
|
||||
$config_info = $this->getDefaultImg($site_id, $app_module)[ 'data' ][ 'value' ];
|
||||
if (!empty($config_info)) {
|
||||
$upload_model = new Upload();
|
||||
if ($data[ 'goods' ] && $config_info[ 'goods' ] && $data[ 'goods' ] != $config_info[ 'goods' ]) {
|
||||
$upload_model->deletePic($config_info[ 'goods' ], $site_id);
|
||||
}
|
||||
if ($data[ 'head' ] && $config_info[ 'head' ] && $data[ 'head' ] != $config_info[ 'head' ]) {
|
||||
$upload_model->deletePic($config_info[ 'head' ], $site_id);
|
||||
}
|
||||
if ($data[ 'store' ] && $config_info[ 'store' ] && $data[ 'store' ] != $config_info[ 'store' ]) {
|
||||
$upload_model->deletePic($config_info[ 'store' ], $site_id);
|
||||
}
|
||||
if ($data[ 'article' ] && $config_info[ 'article' ] && $data[ 'article' ] != $config_info[ 'article' ]) {
|
||||
$upload_model->deletePic($config_info[ 'article' ], $site_id);
|
||||
}
|
||||
}
|
||||
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '默认图设置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'DEFAULT_IMAGE']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认图查询上传配置
|
||||
* @param $site_id
|
||||
* @param string $app_model
|
||||
* @return array
|
||||
*/
|
||||
public function getDefaultImg($site_id, $app_model = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_model], ['config_key', '=', 'DEFAULT_IMAGE']]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'goods' => 'public/static/img/default_img/square.png',
|
||||
'head' => 'public/static/img/default_img/head.png',
|
||||
'store' => 'public/static/img/default_img/store.png',
|
||||
'article' => 'public/static/img/default_img/article.png',
|
||||
];
|
||||
}
|
||||
|
||||
if (empty($res[ 'data' ][ 'value' ][ 'head' ])) {
|
||||
$res[ 'data' ][ 'value' ][ 'head' ] = 'public/static/img/default_img/head.png';
|
||||
}
|
||||
if (empty($res[ 'data' ][ 'value' ][ 'article' ])) {
|
||||
$res[ 'data' ][ 'value' ][ 'article' ] = 'public/static/img/default_img/article.png';
|
||||
}
|
||||
if (empty($res[ 'data' ][ 'value' ][ 'store' ])) {
|
||||
$res[ 'data' ][ 'value' ][ 'store' ] = 'public/static/img/default_img/store.png';
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存类型
|
||||
*/
|
||||
public function getCacheList()
|
||||
{
|
||||
return $this->cache_list;
|
||||
}
|
||||
|
||||
public function setCopyright($data, $site_id = 1, $app_model = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '版权设置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_model], ['config_key', '=', 'COPYRIGHT']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取版权信息
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function getCopyright($site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'COPYRIGHT']]);
|
||||
|
||||
$auth_info = cache('auth_info_copyright');
|
||||
if (empty($auth_info)) {
|
||||
$upgrade_model = new Upgrade();
|
||||
$auth_info = $upgrade_model->authInfo();
|
||||
cache('auth_info_copyright', $auth_info, ['expire' => 604800]);
|
||||
}
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'logo' => '',
|
||||
'company_name' => '',
|
||||
'copyright_link' => '',
|
||||
'copyright_desc' => '',
|
||||
'icp' => '',
|
||||
'business_show_link' => '',//营业执照亮照链接
|
||||
'gov_record' => '',
|
||||
'gov_url' => '',
|
||||
'market_supervision_url' => ''
|
||||
];
|
||||
} else {
|
||||
if (is_null($auth_info) || $auth_info[ 'code' ] != 0) {
|
||||
$res[ 'data' ][ 'value' ][ 'logo' ] = '';
|
||||
$res[ 'data' ][ 'value' ][ 'company_name' ] = '';
|
||||
$res[ 'data' ][ 'value' ][ 'copyright_link' ] = '';
|
||||
$res[ 'data' ][ 'value' ][ 'copyright_desc' ] = '';
|
||||
}
|
||||
|
||||
}
|
||||
// 检查是否授权
|
||||
if (!empty($auth_info) && $auth_info[ 'code' ] >= 0) {
|
||||
$res[ 'data' ][ 'value' ][ 'auth' ] = true;
|
||||
} else {
|
||||
$res[ 'data' ][ 'value' ][ 'auth' ] = false;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权设置
|
||||
* @param $data
|
||||
* @param int $site_id
|
||||
* @param string $app_model
|
||||
* @return array
|
||||
*/
|
||||
public function setAuth($data, $site_id = 1, $app_model = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '授权设置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_model], ['config_key', '=', 'AUTH']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取授权设置
|
||||
* @return array
|
||||
*/
|
||||
public function getAuth($site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'AUTH']]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'code' => '',
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 地图设置
|
||||
* @param $data
|
||||
* @param int $site_id
|
||||
* @param string $app_model
|
||||
* @return array
|
||||
*/
|
||||
public function setMapConfig($data, $site_id = 1, $app_model = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '地图设置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_model], ['config_key', '=', 'MAP_CONFIG']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取地图设置
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function getMapConfig($site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'MAP_CONFIG']]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'tencent_map_key' => '',
|
||||
'wap_is_open' => 1, // 手机端是否开启定位
|
||||
'wap_valid_time' => 5 // 手机端定位有效期/分钟,过期后将重新获取定位信息,0为不过期
|
||||
];
|
||||
}
|
||||
$res[ 'data' ][ 'value' ][ 'wap_is_open' ] = $res[ 'data' ][ 'value' ][ 'wap_is_open' ] ?? 1;
|
||||
$res[ 'data' ][ 'value' ][ 'wap_valid_time' ] = $res[ 'data' ][ 'value' ][ 'wap_valid_time' ] ?? 5;
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置获取H5域名配置
|
||||
* @param $data
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function seth5DomainName($data, $site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$search = '/^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/';
|
||||
if ($data[ 'deploy_way' ] == 'separate') {
|
||||
if (!preg_match($search, $data[ 'domain_name_h5' ])) {
|
||||
return $this->error('', '请输入正确的域名地址');
|
||||
}
|
||||
}
|
||||
// 默认部署,更新店铺域名
|
||||
if ($data[ 'deploy_way' ] == 'default') {
|
||||
$this->setShopDomainConfig([
|
||||
'domain_name' => __ROOT__
|
||||
], $site_id);
|
||||
}
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, 'H5域名配置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'H5_DOMAIN_NAME']]);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取H5域名配置
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function getH5DomainName($site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'H5_DOMAIN_NAME']]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'domain_name_h5' => __ROOT__ . '/h5',
|
||||
'deploy_way' => 'default'
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置域名跳转配置
|
||||
* @param $data
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function setDomainJumpConfig($data, $site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '获取域名跳转配置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'DOMAIN_JUMP_CONFIG']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取域名跳转配置
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function getDomainJumpConfig($site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([
|
||||
['site_id', '=', $site_id],
|
||||
['app_module', '=', $app_module],
|
||||
['config_key', '=', 'DOMAIN_JUMP_CONFIG']
|
||||
]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'jump_type' => 3, // 1:用户前台,2:商家后台,3:引导页
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置获取PC域名配置
|
||||
* @param $data
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function setPcDomainName($data, $site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$search = '/^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/';
|
||||
if ($data[ 'deploy_way' ] == 'separate') {
|
||||
if (!preg_match($search, $data[ 'domain_name_pc' ])) {
|
||||
return $this->error('', '请输入正确的域名地址');
|
||||
}
|
||||
}
|
||||
// 默认部署,更新店铺域名
|
||||
if ($data[ 'deploy_way' ] == 'default') {
|
||||
$this->setShopDomainConfig([
|
||||
'domain_name' => __ROOT__
|
||||
], $site_id);
|
||||
}
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, 'PC域名配置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'PC_DOMAIN_NAME']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取PC域名配置
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function getPcDomainName($site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'PC_DOMAIN_NAME']]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'domain_name_pc' => __ROOT__ . '/web',
|
||||
'deploy_way' => 'default'
|
||||
];
|
||||
} else {
|
||||
if ($res[ 'data' ][ 'value' ][ 'domain_name_pc' ] == '' || empty($res[ 'data' ][ 'value' ][ 'deploy_way' ]) || $res[ 'data' ][ 'value' ][ 'deploy_way' ] == 'default') {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'domain_name_pc' => __ROOT__ . '/web'
|
||||
];
|
||||
}
|
||||
$res[ 'data' ][ 'value' ][ 'deploy_way' ] = $res[ 'data' ][ 'value' ][ 'deploy_way' ] ?? 'default';
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置热门搜索关键词
|
||||
* @param $data
|
||||
* @param $site_id
|
||||
* @param $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function setHotSearchWords($data, $site_id, $app_module)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '商品热门搜索关键词', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'GOODS_HOT_SEARCH_WORDS_CONFIG']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取热门搜索关键词
|
||||
* @param $site_id
|
||||
* @param $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function getHotSearchWords($site_id, $app_module)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'GOODS_HOT_SEARCH_WORDS_CONFIG']]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'words' => ''
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置商品推荐—猜你喜欢
|
||||
* @param $data
|
||||
* @param $site_id
|
||||
* @param $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function setGuessYouLike($data, $site_id, $app_module)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '商品推荐', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'GOODS_GUESS_YOU_LIKE_CONFIG']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品推荐—猜你喜欢
|
||||
* @param $site_id
|
||||
* @param $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function getGuessYouLike($site_id, $app_module)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'GOODS_GUESS_YOU_LIKE_CONFIG']]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'title' => '猜你喜欢',
|
||||
'supportPage' => ['goods_detail', 'cart', 'collect', 'pay', 'order_detail', 'super_member', 'guafen', 'fenxiao_level'],
|
||||
'sources' => 'sort',
|
||||
'goodsIds' => [],
|
||||
'fontWeight' => false,
|
||||
'padding' => 10,
|
||||
'cartEvent' => 'detail',
|
||||
'text' => '购买',
|
||||
'textColor' => '#FFFFFF',
|
||||
'theme' => 'default',
|
||||
'aroundRadius' => 25,
|
||||
'control' => true,
|
||||
'bgColor' => '#FF6A00',
|
||||
'style' => 'button',
|
||||
'nameLineMode' => 'single',
|
||||
'iconDiy' => [
|
||||
'iconType' => 'icon',
|
||||
'icon' => '',
|
||||
'style=' => [
|
||||
'fontSize' => '60',
|
||||
'iconBgColor' => [],
|
||||
'iconBgColorDeg' => 0,
|
||||
'iconBgImg' => '',
|
||||
'bgRadius' => 0,
|
||||
'iconColor' => ['#000000'],
|
||||
'iconColorDeg' => 0
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
$res[ 'data' ][ 'value' ][ 'nameLineMode' ] = $res[ 'data' ][ 'value' ][ 'nameLineMode' ] ?? 'single'; // 商品名称,单行、多行展示
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置商品列表配置
|
||||
* @param $data
|
||||
* @param $site_id
|
||||
* @param $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function setGoodsListConfig($data, $site_id, $app_module)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '商品列表配置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'GOODS_LIST_CONFIG']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置商品列表配置
|
||||
* @param $site_id
|
||||
* @param $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function getGoodsListConfig($site_id, $app_module)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'GOODS_LIST_CONFIG']]);
|
||||
//数据格式化
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$data = [
|
||||
'fontWeight' => false,
|
||||
'padding' => 10,
|
||||
'cartEvent' => 'detail',
|
||||
'text' => '购买',
|
||||
'textColor' => '#FFFFFF',
|
||||
'theme' => 'default',
|
||||
'aroundRadius' => 25,
|
||||
'control' => true,
|
||||
'bgColor' => '#FF6A00',
|
||||
'style' => 'button',
|
||||
'nameLineMode' => 'single',
|
||||
'iconDiy' => [
|
||||
'iconType' => 'icon',
|
||||
'icon' => '',
|
||||
'style=' => [
|
||||
'fontSize' => '60',
|
||||
'iconBgColor' => [],
|
||||
'iconBgColorDeg' => 0,
|
||||
'iconBgImg' => '',
|
||||
'bgRadius' => 0,
|
||||
'iconColor' => ['#000000'],
|
||||
'iconColorDeg' => 0
|
||||
]
|
||||
]
|
||||
];
|
||||
$res[ 'data' ][ 'value' ] = $data;
|
||||
}
|
||||
$res[ 'data' ][ 'value' ][ 'nameLineMode' ] = $res[ 'data' ][ 'value' ][ 'nameLineMode' ] ?? 'single'; // 商品名称,单行、多行展示
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置默认搜索关键词
|
||||
* @param $data
|
||||
* @param $site_id
|
||||
* @param $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultSearchWords($data, $site_id, $app_module)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '默认搜索关键词', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'GOODS_DEFAULT_SEARCH_WORDS_CONFIG']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认搜索关键词
|
||||
* @param $site_id
|
||||
* @param $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function getDefaultSearchWords($site_id, $app_module)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'GOODS_DEFAULT_SEARCH_WORDS_CONFIG']]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'words' => '搜索 商品'
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置商品排序方式
|
||||
* @param $data
|
||||
* @param $site_id
|
||||
* @param $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function setGoodsSort($data, $site_id, $app_module)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '商品默认排序方式', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'GOODS_SORT_CONFIG']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品排序方式
|
||||
* @param $site_id
|
||||
* @param $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function getGoodsSort($site_id, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'GOODS_SORT_CONFIG']]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'type' => 'asc',
|
||||
'default_value' => 100
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置PC端首页分类设置
|
||||
* @param $data
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function setCategoryConfig($data, $site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, 'PC端首页分类设置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SHOP_CATEGORY_CONFIG']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取pc首页商品分类配置
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function getCategoryConfig($site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SHOP_CATEGORY_CONFIG']]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'category' => 1,
|
||||
'img' => 1
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置商品详情配置
|
||||
* @param $data
|
||||
* @param $site_id
|
||||
* @param $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function setGoodsDetailConfig($data, $site_id, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '商品详情配置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'GOODS_DETAIL_CONFIG']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品详情配置
|
||||
* @param $site_id
|
||||
* @param $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function getGoodsDetailConfig($site_id, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'GOODS_DETAIL_CONFIG']]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'nav_bar_switch' => 0, // 是否透明,0:不透明,1:透明
|
||||
'introduction_color' => '#303133',
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置店铺域名配置
|
||||
* @param $data
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function setShopDomainConfig($data, $site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '店铺域名配置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SHOP_DOMAIN_CONFIG']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺域名配置
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function getShopDomainConfig($site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SHOP_DOMAIN_CONFIG']]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'domain_name' => __ROOT__,
|
||||
];
|
||||
$this->setShopDomainConfig($res[ 'data' ][ 'value' ], $site_id);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function checkQqMapKey($tencent_map_key, $type = 0)
|
||||
{
|
||||
$qq_map = new \app\model\map\QqMap(['key' => $tencent_map_key]);
|
||||
$res = $qq_map->addressToDetail([
|
||||
'address' => '山西省太原市人民政府',
|
||||
]);
|
||||
|
||||
if (!empty($res)) {
|
||||
if ($res[ 'status' ] != 0 && $type == 0) {
|
||||
$res[ 'message' ] = '腾讯地图KEY无效';
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置商品编码设置
|
||||
* @param $data
|
||||
* @param $site_id
|
||||
* @param $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function setGoodsNo($data, $site_id, $app_module)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '商品编码设置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'GOODS_NO_CONFIG']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品编码设置
|
||||
* @param $site_id
|
||||
* @param $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function getGoodsNo($site_id, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'GOODS_NO_CONFIG']]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'uniqueness_switch' => 1,
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置后台主题风格配置
|
||||
* @param $data
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function setThemeConfig($data, $site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '后台主题风格配置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SHOP_THEME_CONFIG']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取后台主题风格配置
|
||||
* @param int $site_id
|
||||
* @param string $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function getThemeConfig($site_id = 1, $app_module = 'shop')
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([
|
||||
['site_id', '=', $site_id],
|
||||
['app_module', '=', $app_module],
|
||||
['config_key', '=', 'SHOP_THEME_CONFIG']
|
||||
]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = $this->getThemeList()[ 'data' ][ 0 ];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台主题风格列表
|
||||
* @return array
|
||||
*/
|
||||
public function getThemeList()
|
||||
{
|
||||
// todo 这里支持扩展色调
|
||||
$res = [
|
||||
[
|
||||
'title' => '蓝色', // 标题
|
||||
'name' => 'blue', // 标识
|
||||
'color' => '#105CFB', // 主色调
|
||||
'url' => 'default/common.css' // 样式路径
|
||||
],
|
||||
[
|
||||
'title' => '橙色',
|
||||
'name' => 'orange',
|
||||
'color' => '#FA6400',
|
||||
'url' => 'orange/common.css'
|
||||
],
|
||||
[
|
||||
'title' => '粉色',
|
||||
'name' => 'pink',
|
||||
'color' => '#ff08a7',
|
||||
'url' => 'pink/common.css'
|
||||
],
|
||||
[
|
||||
'title' => '棕色',
|
||||
'name' => 'brown',
|
||||
'color' => '#CFAF70',
|
||||
'url' => 'brown/common.css'
|
||||
],
|
||||
[
|
||||
'title' => '绿色',
|
||||
'name' => 'green',
|
||||
'color' => '#19C650',
|
||||
'url' => 'green/common.css'
|
||||
],
|
||||
[
|
||||
'title' => '紫色',
|
||||
'name' => 'purple',
|
||||
'color' => '#A253FF',
|
||||
'url' => 'purple/common.css'
|
||||
],
|
||||
[
|
||||
'title' => '红色',
|
||||
'name' => 'red',
|
||||
'color' => '#F4391c',
|
||||
'url' => 'red/common.css'
|
||||
]
|
||||
];
|
||||
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置分词配置
|
||||
* @param $data
|
||||
* @param $site_id
|
||||
* @param $app_module
|
||||
* @return array
|
||||
*/
|
||||
public function setSplitWordConfig($data, $site_id, $app_module): array
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '分词配置', 1, [['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SPLIT_WORD_CONFIG']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取分词配置
|
||||
*/
|
||||
public function getSplitWordConfig($site_id=1, $app_module='shop'){
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', $app_module], ['config_key', '=', 'SPLIT_WORD_CONFIG']]);
|
||||
if (empty($res[ 'data' ][ 'value' ])) {
|
||||
$res[ 'data' ][ 'value' ] = [
|
||||
'is_open' => 0,
|
||||
'apiKey'=>'',
|
||||
'secretKey'=>''
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
1810
app/model/web/DiyView.php
Executable file
1810
app/model/web/DiyView.php
Executable file
File diff suppressed because it is too large
Load Diff
278
app/model/web/DiyViewLink.php
Executable file
278
app/model/web/DiyViewLink.php
Executable file
@@ -0,0 +1,278 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\web;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use app\model\web\DiyView as DiyViewModel;
|
||||
use think\facade\Cache;
|
||||
|
||||
class DiyViewLink extends BaseModel
|
||||
{
|
||||
public $list = [];
|
||||
|
||||
/**
|
||||
* 获取链接信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getLinkInfo($condition, $field = '*')
|
||||
{
|
||||
$list = model('link')->getInfo($condition, $field);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取链接列表
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @param null $limit
|
||||
* @return array
|
||||
*/
|
||||
public function getLinkList($condition = [], $field = '*', $order = '', $limit = null)
|
||||
{
|
||||
$list = model('link')->getList($condition, $field, $order, '', '', '', $limit);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 链接分页列表
|
||||
* @param array $condition
|
||||
* @param int $page
|
||||
* @param int $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
* @return array
|
||||
*/
|
||||
public function getLinkPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
|
||||
{
|
||||
$list = model('link')->pageList($condition, $field, $order, $page, $page_size);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询自定义微页面
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function getMicroPageLinkList($site_id)
|
||||
{
|
||||
$diy_view_model = new DiyViewModel();
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $site_id ],
|
||||
[ 'name', 'like', '%DIY_VIEW_RANDOM_%' ]
|
||||
];
|
||||
$site_diy_view_list = $diy_view_model->getSiteDiyViewList($condition, 'sort desc,create_time desc', 'name, title')[ 'data' ];
|
||||
|
||||
$link_mic = [
|
||||
'name' => 'MICRO_PAGE_LIST',
|
||||
'title' => '微页面',
|
||||
'parent' => 'MICRO_PAGE',
|
||||
'child_list' => []
|
||||
];
|
||||
foreach ($site_diy_view_list as $page_k => $page_v) {
|
||||
$link_mic[ 'child_list' ][] = [
|
||||
'name' => $page_v[ 'name' ],
|
||||
'title' => $page_v[ 'title' ],
|
||||
'parent' => 'MICRO_PAGE_LIST',
|
||||
'wap_url' => '/pages_tool/index/diy?name=' . $page_v[ 'name' ]
|
||||
];
|
||||
}
|
||||
return $this->success($link_mic);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义链接树结构
|
||||
* @param $params
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @return array
|
||||
*/
|
||||
public function getLinkTree($params, $field = 'title, name, addon_name, parent, level, wap_url', $order = 'level asc,sort asc,id asc')
|
||||
{
|
||||
$condition = [
|
||||
[ 'level', '<=', $params['level'] ?? 4]
|
||||
];
|
||||
// 查询全部自定义链接
|
||||
$list = model('link')->getList($condition, $field, $order);
|
||||
$link_list = [];
|
||||
if (!empty($list)) {
|
||||
foreach ($list as $k => $v) {
|
||||
// 要查询当前站点是否购买此插件
|
||||
if ($v[ 'addon_name' ] && !addon_is_exit($v[ 'addon_name' ], $params[ 'site_id' ])) {
|
||||
unset($list[ $k ]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$list = array_values($list);
|
||||
|
||||
// 一级
|
||||
foreach ($list as $k => $v) {
|
||||
if ($v[ 'parent' ] == '') {
|
||||
$link_list [] = $v;
|
||||
unset($list[ $k ]);
|
||||
}
|
||||
}
|
||||
$list = array_values($list);
|
||||
|
||||
// 二级
|
||||
foreach ($list as $k => $v) {
|
||||
foreach ($link_list as $ck => $cv) {
|
||||
if ($v[ 'level' ] == 2 && $cv[ 'name' ] == $v[ 'parent' ]) {
|
||||
$link_list[ $ck ][ 'child_list' ][] = $v;
|
||||
unset($list[ $k ]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$list = array_values($list);
|
||||
|
||||
// 三级
|
||||
foreach ($list as $k => $v) {
|
||||
foreach ($link_list as $ck => $cv) {
|
||||
if (!empty($cv[ 'child_list' ])) {
|
||||
foreach ($cv[ 'child_list' ] as $third_k => $third_v) {
|
||||
if ($v[ 'level' ] == 3 && $third_v[ 'name' ] == $v[ 'parent' ]) {
|
||||
$link_list[ $ck ][ 'child_list' ][ $third_k ][ 'child_list' ][] = $v;
|
||||
unset($list[ $k ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$list = array_values($list);
|
||||
|
||||
// 四级
|
||||
foreach ($list as $k => $v) {
|
||||
foreach ($link_list as $ck => $cv) {
|
||||
if (!empty($cv[ 'child_list' ])) {
|
||||
foreach ($cv[ 'child_list' ] as $third_k => $third_v) {
|
||||
if (!empty($third_v[ 'child_list' ])) {
|
||||
foreach ($third_v[ 'child_list' ] as $four_k => $four_v) {
|
||||
if ($v[ 'level' ] == 4 && $four_v[ 'name' ] == $v[ 'parent' ]) {
|
||||
$link_list[ $ck ][ 'child_list' ][ $third_k ][ 'child_list' ][ $four_k ][ 'child_list' ][] = $v;
|
||||
unset($list[ $k ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 自定义微页面
|
||||
foreach ($link_list as $k => $v) {
|
||||
if (isset($v[ 'child_list' ])) {
|
||||
foreach ($v[ 'child_list' ] as $ck => $cv) {
|
||||
if ($cv[ 'name' ] == 'MICRO_PAGE') {
|
||||
$link_list[ $k ][ 'child_list' ][ $ck ][ 'child_list' ] = [ $this->getMicroPageLinkList($params[ 'site_id' ])[ 'data' ] ];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$link_list[ $k ][ 'child_list' ] = [];
|
||||
}
|
||||
}
|
||||
return $this->success($link_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除自定义链接
|
||||
* @param $condition
|
||||
* @return array
|
||||
*/
|
||||
public function deleteLink($condition)
|
||||
{
|
||||
$res = model('link')->delete($condition);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $tree
|
||||
* @param $addon
|
||||
* @return array
|
||||
*/
|
||||
public function getViewLinkList($tree, $addon)
|
||||
{
|
||||
$list = [];
|
||||
foreach ($tree as $k => $v) {
|
||||
$parent = '';
|
||||
$level = 1;
|
||||
if (isset($v[ 'parent' ])) {
|
||||
$parent_menu_info = model('link')->getInfo([ [ 'name', "=", $v[ 'parent' ] ] ]);
|
||||
if ($parent_menu_info) {
|
||||
$parent = $parent_menu_info[ 'name' ];
|
||||
$level = $parent_menu_info[ 'level' ] + 1;
|
||||
}
|
||||
}
|
||||
|
||||
$item = [
|
||||
'title' => $v[ 'title' ],
|
||||
'name' => $v[ 'name' ],
|
||||
'addon_name' => $addon ?? '',
|
||||
'parent' => $parent,
|
||||
'level' => $level,
|
||||
'wap_url' => $v['wap_url'] ?? '',
|
||||
'web_url' => $v['web_url'] ?? '',
|
||||
'icon' => $v['icon'] ?? '',
|
||||
'support_diy_view' => $v['support_diy_view'] ?? '',
|
||||
'sort' => $v['sort'] ?? 0,
|
||||
];
|
||||
|
||||
array_push($list, $item);
|
||||
if (isset($v[ 'child_list' ])) {
|
||||
$this->list = [];
|
||||
$this->linkTreeToList($v[ 'child_list' ], $addon, $v[ 'name' ], $level + 1);
|
||||
$list = array_merge($list, $this->list);
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 链接树转化为列表
|
||||
* @param $tree
|
||||
* @param string $addon
|
||||
* @param string $parent
|
||||
* @param int $level
|
||||
*/
|
||||
private function linkTreeToList($tree, $addon = '', $parent = '', $level = 1)
|
||||
{
|
||||
if (is_array($tree)) {
|
||||
foreach ($tree as $key => $value) {
|
||||
$item = [
|
||||
'title' => $value[ 'title' ],
|
||||
'name' => $value[ 'name' ],
|
||||
'addon_name' => $addon,
|
||||
'parent' => $parent,
|
||||
'level' => $level,
|
||||
'wap_url' => $value['wap_url'] ?? '',
|
||||
'web_url' => $value['web_url'] ?? '',
|
||||
'support_diy_view' => $value['support_diy_view'] ?? '',
|
||||
'icon' => $value['icon'] ?? '',
|
||||
'sort' => $value['sort'] ?? 0,
|
||||
];
|
||||
$refer = $value;
|
||||
if (isset($refer[ 'child_list' ])) {
|
||||
unset($refer[ 'child_list' ]);
|
||||
array_push($this->list, $item);
|
||||
$p_name = $refer[ 'name' ];
|
||||
$this->linkTreeToList($value[ 'child_list' ], $addon, $p_name, $level + 1);
|
||||
} else {
|
||||
array_push($this->list, $item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
250
app/model/web/Help.php
Executable file
250
app/model/web/Help.php
Executable file
@@ -0,0 +1,250 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\web;
|
||||
|
||||
use think\facade\Cache;
|
||||
use app\model\BaseModel;
|
||||
|
||||
/**
|
||||
* 帮助中心管理
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class Help extends BaseModel
|
||||
{
|
||||
/****************************************************************帮助******************************************/
|
||||
/**
|
||||
* 添加帮助
|
||||
* @param array $data
|
||||
*/
|
||||
public function addHelp($data)
|
||||
{
|
||||
$help_id = model('help')->add($data);
|
||||
return $this->success($help_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改帮助
|
||||
* @param array $data
|
||||
*/
|
||||
public function editHelp($data, $condition)
|
||||
{
|
||||
$res = model('help')->update($data, $condition);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除帮助
|
||||
* @param $condition
|
||||
* @return array
|
||||
*/
|
||||
public function deleteHelp($condition)
|
||||
{
|
||||
$res = model('help')->delete($condition);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帮助详情
|
||||
* @param $help_id
|
||||
* @return array
|
||||
*/
|
||||
public function getHelpInfo($help_id, $field = 'id, title, content, class_id, class_name, sort, link_address, create_time, modify_time')
|
||||
{
|
||||
$res = model('help')->getInfo([ [ 'id', '=', $help_id ] ], $field);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单列表
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @param string $limit
|
||||
*/
|
||||
public function getHelpList($condition = [], $field = 'id, title, content, class_id, class_name, sort, create_time', $order = '', $limit = null)
|
||||
{
|
||||
$list = model('help')->getList($condition, $field, $order, '', '', '', $limit);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帮助分页列表
|
||||
* @param array $condition
|
||||
* @param number $page
|
||||
* @param string $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
*/
|
||||
public function getHelpPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'sort asc,create_time desc', $field = 'id, title, content, class_id, class_name, sort, link_address, create_time')
|
||||
{
|
||||
$list = model('help')->pageList($condition, $field, $order, $page, $page_size);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
* @param int $sort
|
||||
* @param int $help_id
|
||||
*/
|
||||
public function modifyHelpSort($sort, $help_id)
|
||||
{
|
||||
$res = model('help')->update([ 'sort' => $sort ], [ [ 'id', '=', $help_id ] ]);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/****************************************************************帮助表******************************************/
|
||||
/**
|
||||
* 添加帮助类型
|
||||
* @param array $data
|
||||
*/
|
||||
public function addHelpClass($data)
|
||||
{
|
||||
|
||||
$model = model('help_class');
|
||||
$res = $model->add($data);
|
||||
if ($res) {
|
||||
return $this->success($res);
|
||||
} else {
|
||||
return $this->error($res);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改帮助类型(主键修改,不修改排序)
|
||||
* @param array $data
|
||||
* @param int $class_id
|
||||
*/
|
||||
public function editHelpClass($data, $class_id)
|
||||
{
|
||||
$res = model('help_class')->update($data, [ [ 'class_id', '=', $class_id ] ]);
|
||||
if ($res !== false) {
|
||||
model('help')->update([ 'class_name' => $data[ 'class_name' ] ], [ [ 'class_id', '=', $class_id ] ]);
|
||||
return $this->success($res);
|
||||
} else {
|
||||
return $this->error($res);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帮助分类详情
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
*/
|
||||
public function getHelpClassInfo($condition, $field = 'class_id, class_name, sort')
|
||||
{
|
||||
$res = model('help_class')->getInfo($condition, $field);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帮助分类分页列表
|
||||
* @param array $condition
|
||||
* @param number $page
|
||||
* @param number $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
*/
|
||||
public function getHelpClassPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'sort asc,create_time desc', $field = 'class_id, class_name, sort')
|
||||
{
|
||||
|
||||
$res = model('help_class')->pageList($condition, $field, $order, $page, $page_size);
|
||||
$check_condition = array_column($condition, 2, 0);
|
||||
if ($check_condition) {
|
||||
unset($check_condition[ 'class_name' ]);
|
||||
}
|
||||
$help_data = model('help')->getList($check_condition, 'class_id');
|
||||
$arr = [];
|
||||
if ($help_data) {
|
||||
$arr = array_column($help_data, 'class_id');
|
||||
$arr = array_unique($arr);
|
||||
}
|
||||
if ($res[ 'list' ]) {
|
||||
foreach ($res[ 'list' ] as $k => $v) {
|
||||
|
||||
if (in_array($v[ 'class_id' ], $arr)) {
|
||||
$res[ 'list' ][ $k ][ 'child' ] = 1;
|
||||
} else {
|
||||
$res[ 'list' ][ $k ][ 'child' ] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帮助分类列表
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @param number $limit
|
||||
*/
|
||||
public function getHelpClassList($condition = [], $field = 'class_id, class_name, sort', $order = '', $limit = null)
|
||||
{
|
||||
$res = model('help_class')->getList($condition, $field, $order, $alias = 'a', $join = [], $group = '', $limit);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除帮助分类
|
||||
* @param array $condition
|
||||
*/
|
||||
public function deleteHelpClass($condition)
|
||||
{
|
||||
|
||||
$model = model('help_class');
|
||||
$res = $model->delete($condition);
|
||||
if ($res) {
|
||||
return $this->success($res);
|
||||
} else {
|
||||
return $this->error($res);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
* @param int $sort
|
||||
* @param int $class_id
|
||||
*/
|
||||
public function modifyHelpClassSort($sort, $class_id)
|
||||
{
|
||||
$res = model('help_class')->update([ 'sort' => $sort ], [ [ 'class_id', '=', $class_id ] ]);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成推广二维码链接
|
||||
* @param $qrcode_param
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function urlQrcode($qrcode_param, $app_type, $site_id)
|
||||
{
|
||||
$h5_page = '/pages_tool/help/detail';
|
||||
$pc_page = '/cms/help/detail';
|
||||
$params = [
|
||||
'site_id' => $site_id,
|
||||
'data' => $qrcode_param,
|
||||
'pc_data' => $qrcode_param,
|
||||
'page' => $h5_page,
|
||||
'h5_path' => $h5_page . '?id=' . $qrcode_param[ 'id' ],
|
||||
'pc_page' => $pc_page,
|
||||
'pc_path' => $pc_page . '?id=' . $qrcode_param[ 'id' ],
|
||||
'qrcode_path' => 'upload/qrcode/help',
|
||||
'qrcode_name' => 'help_qrcode' . $qrcode_param[ 'id' ] . '_' . $site_id,
|
||||
'app_type' => $app_type,
|
||||
];
|
||||
|
||||
$solitaire = event('PromotionQrcode', $params);
|
||||
return $this->success($solitaire[ 0 ]);
|
||||
}
|
||||
|
||||
}
|
||||
145
app/model/web/Notice.php
Executable file
145
app/model/web/Notice.php
Executable file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\web;
|
||||
|
||||
use think\facade\Cache;
|
||||
use app\model\BaseModel;
|
||||
|
||||
/**
|
||||
* 公告管理
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class Notice extends BaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* 添加公告
|
||||
* @param unknown $data
|
||||
*/
|
||||
public function addNotice($data)
|
||||
{
|
||||
$data[ 'create_time' ] = time();
|
||||
$res = model('notice')->add($data);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改公告
|
||||
* @param $data
|
||||
* @param $condition
|
||||
* @return array
|
||||
*/
|
||||
public function editNotice($data, $condition)
|
||||
{
|
||||
$data[ 'modify_time' ] = time();
|
||||
$res = model('notice')->update($data, $condition);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除公告
|
||||
* @param array $condition
|
||||
*/
|
||||
public function deleteNotice($condition)
|
||||
{
|
||||
$res = model('notice')->delete($condition);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公告数量
|
||||
* @param $condition
|
||||
* @return array
|
||||
*/
|
||||
public function getNoticeCount($condition)
|
||||
{
|
||||
$count = model('notice')->getCount($condition);
|
||||
return $this->success($count);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公告信息
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
*/
|
||||
public function getNoticeInfo($condition, $field = 'id, title, content, create_time, modify_time, is_top,receiving_type,receiving_name')
|
||||
{
|
||||
$res = model('notice')->getInfo($condition, $field);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公告列表
|
||||
* @param array $condition
|
||||
* @param string $field
|
||||
* @param string $order
|
||||
* @param string $limit
|
||||
*/
|
||||
public function getNoticeList($condition = [], $field = 'id, title, content, create_time, modify_time, is_top,receiving_type,receiving_name', $order = '', $limit = null)
|
||||
{
|
||||
$list = model('notice')->getList($condition, $field, $order, '', '', '', $limit);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公告分页列表
|
||||
* @param array $condition
|
||||
* @param number $page
|
||||
* @param string $page_size
|
||||
* @param string $order
|
||||
* @param string $field
|
||||
*/
|
||||
public function getNoticePageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = 'is_top desc,create_time desc', $field = 'id, title,content, create_time, is_top,receiving_type,receiving_name,sort')
|
||||
{
|
||||
$list = model('notice')->pageList($condition, $field, $order, $page, $page_size);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改标签排序
|
||||
* @param $sort
|
||||
* @param $id
|
||||
* @return array
|
||||
*/
|
||||
public function modifyNoticeSort($sort, $id)
|
||||
{
|
||||
$res = model('notice')->update([ 'sort' => $sort ], [ [ 'id', '=', $id ] ]);
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成推广二维码链接
|
||||
* @param $qrcode_param
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function urlQrcode($qrcode_param, $app_type, $site_id)
|
||||
{
|
||||
$h5_page = '/pages_tool/notice/detail';
|
||||
$pc_page = '/cms/notice/detail';
|
||||
$params = [
|
||||
'site_id' => $site_id,
|
||||
'data' => $qrcode_param,
|
||||
'pc_data' => [ 'id' => $qrcode_param[ 'notice_id' ] ],
|
||||
'page' => $h5_page,
|
||||
'h5_path' => $h5_page . '?notice_id=' . $qrcode_param[ 'notice_id' ],
|
||||
'pc_page' => $pc_page,
|
||||
'pc_path' => $pc_page . '?id=' . $qrcode_param[ 'notice_id' ],
|
||||
'qrcode_path' => 'upload/qrcode/notice',
|
||||
'qrcode_name' => 'notice_qrcode' . $qrcode_param[ 'notice_id' ] . '_' . $site_id,
|
||||
'app_type' => $app_type,
|
||||
];
|
||||
|
||||
$solitaire = event('PromotionQrcode', $params);
|
||||
return $this->success($solitaire[ 0 ]);
|
||||
}
|
||||
}
|
||||
85
app/model/web/WebSite.php
Executable file
85
app/model/web/WebSite.php
Executable file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace app\model\web;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use app\model\system\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 系统站点信息管理
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
class WebSite extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 获取系统银行账户
|
||||
*/
|
||||
public function getSystemBankAccount()
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', 1], ['app_module', '=', 'shop'], ['config_key', '=', 'SYSTEM_BANK_ACCOUNT']]);
|
||||
if (empty($res['data']['value'])) {
|
||||
$res['data']['value'] = [
|
||||
'bank_account_name' => '',
|
||||
'bank_account_no' => '',
|
||||
'bank_name' => '',
|
||||
'bank_address' => ''
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置系统银行账户
|
||||
* @param unknown $data
|
||||
* @return Ambigous <multitype:unknown , multitype:number unknown >
|
||||
*/
|
||||
public function setSystemBankAccount($data)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '平台银行账户', 1, [['site_id', '=', 1], ['app_module', '=', 'shop'], ['config_key', '=', 'SYSTEM_BANK_ACCOUNT']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取发票设置
|
||||
*/
|
||||
public function getInvoiceConfig()
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->getConfig([['site_id', '=', 1], ['app_module', '=', 'shop'], ['config_key', '=', 'SYSTEM_INVOICE_CONFIG']]);
|
||||
if (empty($res['data']['value'])) {
|
||||
$res['data']['value'] = [
|
||||
'status' => 0,
|
||||
'rate' => 0,
|
||||
'content' => '',
|
||||
'money' => 0
|
||||
];
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置发票设置
|
||||
* @param unknown $data
|
||||
* @return Ambigous <multitype:unknown , multitype:number unknown >
|
||||
*/
|
||||
public function setInvoiceConfig($data)
|
||||
{
|
||||
$config = new ConfigModel();
|
||||
$res = $config->setConfig($data, '发票设置', 1, [['site_id', '=', 1], ['app_module', '=', 'shop'], ['config_key', '=', 'SYSTEM_INVOICE_CONFIG']]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user