3.0.3版本

This commit is contained in:
小城外的桃李 2024-08-15 11:06:13 +08:00
parent 8e46e0faee
commit 5e64528893
2049 changed files with 99511 additions and 53640 deletions

View file

@ -77,7 +77,7 @@ likeshop开源团队专注于围绕电商交易领域打造新时代的开源商
## 免费企业版和付费企业版的区别
likeshop开源不代表不收费健康合理大大方方的收费方式能够助力开源项目持续的更新迭代长久提供质量可靠的开源代码。现在重点说明likeshop单商户开源商城系统免费企业版和付费企业版的区别
1. 本仓库代码为单商户免费企业版版本号v2.5.7,代码全开源,支持免费商用,不能去除版权。任何发布在本仓库的单商户企业版代码都属于已免费开源的企业版本。其它领先的未发布版本为付费企业版。
1. 本仓库代码为单商户免费企业版版本号v3.0.3,代码全开源,支持免费商用,不能去除版权。任何发布在本仓库的单商户企业版代码都属于已免费开源的企业版本。其它领先的未发布版本为付费企业版。
2. 免费企业版没有阉割任何功能分销、拼团、砍价、抽奖、支付宝支付、APP商城等等功能模块完全同步付费企业版。免费企业版本包含H5商城端小程序商城端、APP商城端、PC管理后台端不含PC商城端不能去除版权不支持在线升级和更新包升级。
3. 付费企业版本比免费企业版本领先若干个版本([点击前往技术社区查看最新企业版本号](https://www.likeshop.cn/source_download?id=1&type=1) 包含H5商城端小程序商城端、APP商城端、PC商城端PC管理后台端可以去版本、支持在线升级和更新包升级付费后可永远获取最新企业版本加入付费会员群交换资源享受更好的技术支持
4. likeshop之所以开源齐全完整的企业版本进行免费商用核心的原因是我们的商城系统口碑好无论是使用的稳定性还是二开的便利性都获得了很多的赞誉和欣赏受宠若惊再次感谢各位朋友。但是之前的免费版本过于基础很多好功能因为收费原因没有办法及时释放出来不仅是用户无法体验我们也是跟着干着急。在一次项目会议上大家提到这个问题一致同意既然开源那肯定是希望更多的用户能够使用likeshop实现大家的价值显然比实现likeshop团队的价值是一个更宏伟的命题所以我们开源企业版了

View file

@ -2,7 +2,7 @@
#// | likeshop100%开源免费商用商城系统
#// +----------------------------------------------------------------------
#// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
#// | 开源版本可自由商用,可去除界面版权logo
#// | 开源版本可自由商用,保留版权即可
#// | 商业版本务必购买商业授权,以免引起法律纠纷
#// | 禁止对系统程序代码以任何目的,任何形式的再发布
#// | gitee下载https://gitee.com/likeshop_gitee

View file

@ -6,11 +6,11 @@ app_trace = false;
hostname = like-mysql
database = test_likeshop
username = root
password = root
password = roixxx2008fffot
hostport = 3306
[project]
env_name =
file_domain = www.likeshopb2c.localhost
file_domain = www.likeshopv2.localhost

0
server/application/admin/cache/LoginStateCache.php vendored Normal file → Executable file
View file

0
server/application/admin/cache/RoleMenuCache.php vendored Normal file → Executable file
View file

0
server/application/admin/cache/RoleNoneAuthCacheIds.php vendored Normal file → Executable file
View file

0
server/application/admin/cache/RoleNoneAuthCacheUris.php vendored Normal file → Executable file
View file

0
server/application/admin/config/app.php Normal file → Executable file
View file

0
server/application/admin/config/project.php Normal file → Executable file
View file

0
server/application/admin/config/template.php Normal file → Executable file
View file

0
server/application/admin/controller/Account.php Normal file → Executable file
View file

View file

@ -29,7 +29,8 @@ class Activity extends AdminBase{
*/
public function areaLists(){
if($this->request->isAjax()){
$list = ActivityAreaLogic::areaLists();
$get = $this->request->get();
$list = ActivityAreaLogic::areaLists($get);
$this->_success('',$list);
}
}
@ -74,7 +75,7 @@ class Activity extends AdminBase{
$result = $this->validate($post,'app\admin\validate\ActivityArea');
if($result === true){
ActivityAreaLogic::editActivity($post);
$this->_success('新增成功',[]);
$this->_success('编辑成功',[]);
}
$this->_error($result);
}

View file

@ -108,7 +108,6 @@ class AdPosition extends AdminBase
$result = $this->validate($post, 'app\admin\validate\AdPosition.del');
if ($result === true) {
// dd($result);
$result = AdPositionLogic::del($delData, $client, $attr);
if ($result) {
$this->_success('删除成功');

0
server/application/admin/controller/Admin.php Normal file → Executable file
View file

0
server/application/admin/controller/AdminBase.php Normal file → Executable file
View file

0
server/application/admin/controller/Auth.php Normal file → Executable file
View file

View file

@ -33,22 +33,22 @@ class Basic extends AdminBase
{
$config = [
'file_url' => UrlServer::getFileUrl('/'),
'name' => ConfigServer::get('website', 'name'),
'login_logo' => ConfigServer::get('website', 'login_logo'),
'keyword' => ConfigServer::get('website', 'keyword'),
'slogan_status' => ConfigServer::get('website', 'slogan_status'),
'slogan' => ConfigServer::get('website', 'slogan'),
'backstage_logo' => ConfigServer::get('website', 'backstage_logo'),
'admin_image' => ConfigServer::get('website', 'admin_image'),
'admin_title' => ConfigServer::get('website', 'admin_title'),
'partner_image' => ConfigServer::get('website', 'partner_image'),
'partner_title' => ConfigServer::get('website', 'partner_title'),
'shop_logo' => ConfigServer::get('website', 'shop_logo'),
'shop_login_logo' =>ConfigServer::get('website', 'shop_login_logo'),
'pc_logo' => ConfigServer::get('website', 'pc_logo'),
'user_image' => ConfigServer::get('website', 'user_image'),
'goods_image' =>ConfigServer::get('website', 'goods_image'),
'web_favicon' =>ConfigServer::get('website', 'web_favicon'),
'name' => ConfigServer::get('website', 'name'),
'login_logo' => UrlServer::getFileUrl(ConfigServer::get('website', 'login_logo')),
'keyword' => ConfigServer::get('website', 'keyword'),
'slogan_status' => ConfigServer::get('website', 'slogan_status'),
'slogan' => UrlServer::getFileUrl(ConfigServer::get('website', 'slogan')),
'backstage_logo' => UrlServer::getFileUrl(ConfigServer::get('website', 'backstage_logo')),
'admin_image' => UrlServer::getFileUrl(ConfigServer::get('website', 'admin_image')),
'admin_title' => ConfigServer::get('website', 'admin_title'),
'partner_image' => UrlServer::getFileUrl(ConfigServer::get('website', 'partner_image')),
'partner_title' => ConfigServer::get('website', 'partner_title'),
'shop_logo' => UrlServer::getFileUrl(ConfigServer::get('website', 'shop_logo')),
'shop_login_logo' => UrlServer::getFileUrl(ConfigServer::get('website', 'shop_login_logo')),
'pc_logo' => UrlServer::getFileUrl(ConfigServer::get('website', 'pc_logo')),
'user_image' => UrlServer::getFileUrl(ConfigServer::get('website', 'user_image')),
'goods_image' => UrlServer::getFileUrl(ConfigServer::get('website', 'goods_image')),
'web_favicon' => UrlServer::getFileUrl(ConfigServer::get('website', 'web_favicon')),
];
$this->assign('config', $config);
@ -72,17 +72,17 @@ class Basic extends AdminBase
if ($result === true) {
ConfigServer::set('website', 'name', $post['name']);
ConfigServer::set('website', 'login_logo', $post['login_logo']);
ConfigServer::set('website', 'web_favicon', $post['web_favicon']);
ConfigServer::set('website', 'login_logo', UrlServer::setFileUrl($post['login_logo']));
ConfigServer::set('website', 'web_favicon', UrlServer::setFileUrl($post['web_favicon']));
ConfigServer::set('website', 'backstage_logo', $post['backstage_logo']);
ConfigServer::set('website', 'admin_image', $post['admin_image']);
ConfigServer::set('website', 'backstage_logo', UrlServer::setFileUrl($post['backstage_logo']));
ConfigServer::set('website', 'admin_image', UrlServer::setFileUrl($post['admin_image']));
ConfigServer::set('website', 'admin_title', $post['admin_title']);
ConfigServer::set('website', 'shop_logo', $post['shop_logo']);
ConfigServer::set('website', 'shop_login_logo', $post['shop_login_logo']);
ConfigServer::set('website', 'pc_logo', $post['pc_logo']);
ConfigServer::set('website', 'user_image', $post['user_image']);
ConfigServer::set('website', 'goods_image', $post['goods_image']);
ConfigServer::set('website', 'shop_logo', UrlServer::setFileUrl($post['shop_logo']));
ConfigServer::set('website', 'shop_login_logo', UrlServer::setFileUrl($post['shop_login_logo']));
ConfigServer::set('website', 'pc_logo', UrlServer::setFileUrl($post['pc_logo']));
ConfigServer::set('website', 'user_image', UrlServer::setFileUrl($post['user_image']));
ConfigServer::set('website', 'goods_image', UrlServer::setFileUrl($post['goods_image']));
$this->_success('修改成功');
}
@ -100,7 +100,15 @@ class Basic extends AdminBase
'company_name' => ConfigServer::get('copyright', 'company_name'),
'number' => ConfigServer::get('copyright', 'number'),
'link' => ConfigServer::get('copyright', 'link'),
'business_license' => ConfigServer::get('copyright', 'business_license'),
'other_qualifications' => ConfigServer::get('copyright', 'other_qualifications',[]),
];
$config['business_license'] = $config['business_license'] ? UrlServer::getFileUrl($config['business_license']) : '';
if (!empty($config['other_qualifications'])) {
foreach ($config['other_qualifications'] as &$val) {
$val = UrlServer::getFileUrl($val);
}
}
$this->assign('config', $config);
@ -124,6 +132,15 @@ class Basic extends AdminBase
// ConfigServer::set('copyright', 'logo',$post['logo']);
ConfigServer::set('copyright', 'number', $post['number']);
ConfigServer::set('copyright', 'link', $post['link']);
ConfigServer::set('copyright', 'business_license', UrlServer::setFileUrl($post['business_license'] ?? ''));
$other_qualifications = [];
if (!empty($post['other_qualifications'])) {
foreach ($post['other_qualifications'] as &$val) {
$val = UrlServer::setFileUrl($val);
}
$other_qualifications = json_encode($post['other_qualifications']);
}
ConfigServer::set('copyright', 'other_qualifications', $other_qualifications);
return $this->_success('修改成功');
}
@ -175,7 +192,7 @@ class Basic extends AdminBase
}
/**
* APP设置
* APP设置页面
* @return mixed
*/
public function app()
@ -191,6 +208,14 @@ class Basic extends AdminBase
return $this->fetch();
}
/**
* @notes 设置APP
* @throws @\think\Exception
* @throws @\think\db\exception\ModelNotFoundException
* @throws @\think\exception\DbException
* @throws @\think\exception\PDOException
* @date 2021/9/24 14:08
*/
public function setApp()
{
$post = $this->request->post();
@ -205,7 +230,7 @@ class Basic extends AdminBase
}
/**
* 分享设置
* 分享设置页面
*/
public function share()
{
@ -217,13 +242,24 @@ class Basic extends AdminBase
'h5_share_image' => ''
]),
'mnp' => ConfigServer::get('share', 'mnp', [
'mnp_share_title' => ''
'mnp_share_title' => '',
'mnp_share_image' => ''
])
];
$this->assign('config', $config);
return $this->fetch();
}
/**
* @notes 设置分享
* @throws @\think\Exception
* @throws @\think\db\exception\DataNotFoundException
* @throws @\think\db\exception\ModelNotFoundException
* @throws @\think\exception\DbException
* @throws @\think\exception\PDOException
* @author 张无忌
* @date 2021/9/24 14:08
*/
public function setShare()
{
$post = $this->request->post();
@ -234,6 +270,7 @@ class Basic extends AdminBase
], JSON_UNESCAPED_UNICODE);
$mnp = json_encode([
'mnp_share_title' => $post['mnp_share_title'],
'mnp_share_image' => $post['mnp_share_image'],
], JSON_UNESCAPED_UNICODE);
ConfigServer::set('share', 'h5', $h5);
ConfigServer::set('share', 'mnp', $mnp);

View file

@ -0,0 +1,83 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\logic\CommentHelperLogic;
use app\admin\logic\GoodsCategoryLogic;
use app\admin\logic\UserLogic;
use app\common\model\Goods;
/**
* 评价助手
* Class CommentHelper
* @package app\admin\controller
*/
class CommentHelper extends AdminBase
{
/**
* @notes 商品列表
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @author 段誉
* @date 2022/1/12 11:01
*/
public function lists()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
$this->_success('', CommentHelperLogic::lists($get));
}
$this->assign('category_list', GoodsCategoryLogic::categoryTreeeTree());
$this->assign('status_list', Goods::getStatusDesc(true));
return $this->fetch();
}
/**
* @notes 添加虚拟评论
* @return mixed
* @author 段誉
* @date 2022/1/12 11:00
*/
public function add()
{
$goods_id = $this->request->get('id');
if ($this->request->isAjax()) {
$post = $this->request->post();
$check = $this->validate($post, 'app\admin\validate\CommentHelper');
if ($check !== true) {
$this->_error($check);
}
$result = CommentHelperLogic::addComment($post);
if (true === $result) {
$this->_success('操作成功');
}
$this->_error($result);
}
$this->assign('user_level', UserLogic::getLevelList());
$this->assign('goods_id', $goods_id);
return $this->fetch();
}
}

View file

@ -92,20 +92,6 @@ class Crontab extends AdminBase
$this->_error('删除失败');
}
/**
* 定时任务操作
*/
public function operation()
{
$post = $this->request->post();
$result = CrontabLogic::operation($post['operation'], $post['id']);
if ($result !== true) {
$this->_error('操作失败:' . $result);
}
$this->_success('操作成功');
}
/**
* 获取接下来执行时间
*/

0
server/application/admin/controller/Dispatch.php Normal file → Executable file
View file

View file

@ -0,0 +1,40 @@
<?php
namespace app\admin\controller;
use app\admin\logic\DistributionApplyLogic;
use think\facade\View;
class DistributionApply extends AdminBase
{
public function lists()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
$lists = DistributionApplyLogic::lists($get);
return $this->_success('获取成功', $lists);
}
return view();
}
public function detail()
{
$id = $this->request->get('id');
View::assign('detail', DistributionApplyLogic::detail($id));
return view();
}
public function audit()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$res = DistributionApplyLogic::audit($post);
if ($res === false) {
return $this->_error(DistributionApplyLogic::getError());
}
return $this->_success('操作成功');
}
return view();
}
}

View file

@ -0,0 +1,70 @@
<?php
namespace app\admin\controller;
use app\admin\logic\DistributionCenterLogic;
use app\common\model\Distribution;
class DistributionCenter extends AdminBase
{
/**
* @notes 数据概览
* @return \think\response\Json
* @author Tab
*/
public function center()
{
$data = DistributionCenterLogic::center();
return view('', ['data' => $data]);
}
/**
* @notes 分销初始化数据
* @return \think\response\Json
* @author Tab
*/
public function updateTable()
{
try {
$defaultLevel = \app\common\model\DistributionLevel::where('is_default', 1)->findOrEmpty()->toArray();
if (empty($defaultLevel)) {
// 没有默认等级,初始化
\app\common\model\DistributionLevel::create([
'name' => '默认等级',
'weights' => '1',
'is_default' => '1',
'remark' => '默认等级',
'update_relation' => '1'
]);
}
// 默认分销会员等级
$defaultLevelId = \app\common\model\DistributionLevel::where('is_default', 1)->value('id');
// 生成分销基础信息表
$users = \app\common\model\User::field('id,is_distribution')
->where(['del' => 0])
->select()
->toArray();
$distribution = Distribution::column('user_id');
$addData = [];
foreach($users as $item) {
if (in_array($item['id'], $distribution)) {
// 已有基础分销记录,跳过
continue;
}
$data = [
'user_id' => $item['id'],
'level_id' => $defaultLevelId,
'is_distribution' => $item['is_distribution'],
'is_freeze' => 0,
'remark' => '',
];
$addData[] = $data;
}
$distributionModel = new Distribution();
$distributionModel->saveAll($addData);
return '初始化数据完成';
} catch(\Exception $e) {
return $e->getMessage();
}
}
}

View file

@ -0,0 +1,59 @@
<?php
namespace app\admin\controller;
use app\admin\controller\AdminBase;
use app\admin\logic\DistributionGoodsLogic;
class DistributionGoods extends AdminBase
{
/**
* @notes 分销商品列表页
* @return \think\response\View
* @author Tab
*/
public function index()
{
if ($this->request->isPost()) {
$params = $this->request->post();
$lists = DistributionGoodsLogic::lists($params);
return $this->_success('', $lists);
}
return view();
}
/**
* @notes 设置佣金
* @return \think\response\View
* @author Tab
*/
public function set()
{
if ($this->request->isPost()) {
$params = $this->request->post();
$result = DistributionGoodsLogic::set($params);
if ($result) {
return $this->_success('设置成功');
}
return $this->_error(DistributionGoodsLogic::getError());
}
$params = $this->request->get();
$detail = DistributionGoodsLogic::detail($params);
return view('', ['detail' => $detail]);
}
/**
* @notes 参与分销/取消分销
* @return \think\response\Json
* @author Tab
*/
public function isDistribution()
{
$params = $this->request->post();
$result = DistributionGoodsLogic::isDistribution($params);
if ($result) {
return $this->_success('操作成功');
}
return $this->_error(DistributionGoodsLogic::getError());
}
}

View file

@ -0,0 +1,88 @@
<?php
namespace app\admin\controller;
use app\admin\logic\DistributionLevelLogic;
use app\admin\validate\DistributionLevelValidate;
use think\Validate;
class DistributionLevel extends AdminBase
{
/**
* @notes 分销等级列表
* @return \think\response\View
* @author Tab
*/
public function index()
{
if ($this->request->isPost()) {
$result = DistributionLevelLogic::index();
return $this->_success('', $result);
}
return view();
}
/**
* @notes 添加分销等级
* @return \think\response\View
* @author Tab
*/
public function add()
{
if ($this->request->isPost()) {
$params = $this->request->post();
$validate = new DistributionLevelValidate();
if (!$validate->scene('add')->check($params)) {
return $this->_error($validate->getError());
}
$result = DistributionLevelLogic::add($params);
if($result) {
return $this->_success('添加成功');
}
return $this->_error(DistributionLevelLogic::getError());
}
// 显示添加页面
return view();
}
/**
* @notes 编辑分销等级
* @return \think\response\View
* @author Tab
*/
public function edit()
{
if ($this->request->isPost()) {
$params = $this->request->post();
$validate = new DistributionLevelValidate();
if (!$validate->scene('edit')->check($params)) {
return $this->_error($validate->getError());
}
$result = DistributionLevelLogic::edit($params);
if($result) {
return $this->_success('编辑成功');
}
return $this->_error(DistributionLevelLogic::getError());
}
$params = $this->request->get();
$detail = DistributionLevelLogic::detail($params);
$template = $detail['is_default'] ? 'edit_default' : 'edit';
return view($template, ['detail' => $detail]);
}
/**
* @notes 删除分销等级
* @return \think\response\Json
* @author Tab
*/
public function delete()
{
$params = $this->request->post();
$result = DistributionLevelLogic::delete($params);
if($result) {
return $this->_success('删除成功');
}
return $this->_error(DistributionLevelLogic::getError());
}
}

View file

@ -1,184 +1,105 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\logic\DistributionLevelLogic;
use app\admin\logic\DistributionMemberLogic;
use app\common\model\DistributionMember as DistributionMemberModel;
/**
* 分销会员
* Class DistributionMember
* @package app\admin\controller\distribution
*/
class DistributionMember extends AdminBase
{
/**
* 分销会员列表/审核会员列表
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @notes 分销会员列表
* @return \think\response\View
* @author Tab
*/
public function index()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
$type = $get['type'] ?? 'member';
if ($type == 'member') {
$this->_success('获取成功', DistributionMemberLogic::memberLists($get));
}
$this->_success('获取成功', DistributionMemberLogic::auditLists($get));
if ($this->request->isPost()) {
$params = $this->request->post();
$result = DistributionMemberLogic::lists($params);
return $this->_success('', $result);
}
$this->assign('status', DistributionMemberModel::getApplyStatus(true));
return $this->fetch('index');
$levels = DistributionLevelLogic::getLevels();
return view('', ['levels' => $levels]);
}
/**
* 审核分销会员
* @notes 开通分销会员
* @return \think\response\View
* @author Tab
*/
public function audit()
public function open()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$check = $this->validate($post, 'app\admin\validate\DistributionMember.audit');
if (true !== $check) {
$this->_error($check);
if($this->request->isPost()) {
$params = $this->request->post();
$result = DistributionMemberLogic::open($params);
if($result) {
return $this->_success('开通成功');
}
if ($post['type'] == 'pass') {
$res = DistributionMemberLogic::auditPass($post);
} else {
$res = DistributionMemberLogic::auditRefuse($post);
}
if ($res !== true) {
$this->_error('操作失败');
}
$this->_success('操作成功');
return $this->_error(DistributionMemberLogic::getError());
}
}
//冻结/解冻分销资格
public function freeze()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$check = $this->validate($post, 'app\admin\validate\DistributionMember.freeze');
if (true !== $check) {
$this->_error($check);
}
DistributionMemberLogic::freeze($post);
$this->_success('操作成功');
}
$this->_error('操作失败');
$levels = DistributionLevelLogic::getLevels();
return view('', ['levels' => $levels]);
}
/**
* 分销会员详情(分销资料)
* @return mixed
* @notes 用户列表
* @return \think\response\Json|\think\response\View
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @author Tab
*/
public function info()
public function userLists()
{
$get = $this->request->get();
$info = DistributionMemberLogic::getMemberInfo($get);
$this->assign('detail', $info);
return $this->fetch();
if ($this->request->isPost()) {
$params = $this->request->post();
$lists = DistributionMemberLogic::getUserLists($params);
return $this->_success('', $lists);
}
return view();
}
/**
* 推广会员
* @return mixed
* @notes 分销会员等级调整
* @return \think\response\Json|\think\response\View
* @author Tab
*/
public function fans()
public function adjust()
{
$user_id = $this->request->get('id');
if ($this->request->isAjax()) {
$get = $this->request->get();
$this->_success('获取成功', DistributionMemberLogic::getFansLists($get));
}
$this->assign('user_id', $user_id);
return $this->fetch();
}
/**
* 分销收入明细
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function earningsDetail()
{
$user_id = $this->request->get('id');
if ($this->request->isAjax()) {
$get = $this->request->get();
$this->_success('获取成功', DistributionMemberLogic::getEarningsDetail($get));
}
$this->assign('user_id', $user_id);
return $this->fetch();
}
//修改上级
public function updateLeader()
{
$user_id = $this->request->get('id');
if ($this->request->isAjax()) {
$post = $this->request->post();
$check = $this->validate($post, 'app\admin\validate\DistributionMember.updateLeader');
if (true !== $check) {
$this->_error($check);
if($this->request->isPost()) {
$params = $this->request->post();
$result = DistributionMemberLogic::adjust($params);
if($result) {
return $this->_success('调整成功');
}
$res = DistributionMemberLogic::updateRelation($post);
if ($res === true){
$this->_success('操作成功');
}
$this->_error($res);
return $this->_error(DistributionMemberLogic::getError());
}
$this->assign('first_leader',DistributionMemberLogic::getLeaderInfo($user_id));
$this->assign('user_id', $user_id);
return $this->fetch();
$params = $this->request->get();
$user = DistributionMemberLogic::getUser($params);
$levels = DistributionLevelLogic::getLevels();
return view('', [
'user' => $user,
'levels' => $levels
]);
}
/**
* Notes: 添加分销会员
* @author 张无忌(2021/1/11 16:32)
* @notes 冻结资格/恢复资格
* @return \think\response\Json
* @author Tab
*/
public function addMember()
public function isFreeze()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$check = $this->validate($post, 'app\admin\validate\DistributionMember.addMember');
if (true !== $check) {
$this->_error($check);
}
$result = DistributionMemberLogic::addMember($post);
if ($result === true) {
$this->_success('添加成功');
} else {
$this->_error($result);
}
$params = $this->request->post();
$result = DistributionMemberLogic::isFreeze($params);
if($result) {
return $this->_success('操作成功');
}
return $this->fetch('distribution_member/add_member');
return $this->_error(DistributionMemberLogic::getError());
}
}

View file

@ -0,0 +1,52 @@
<?php
namespace app\admin\controller;
use app\admin\logic\DistributionOrderGoodsLogic;
use app\common\model\OrderGoods;
class DistributionOrderGoods extends AdminBase
{
/**
* @notes 分销订单列表
* @return \think\response\View
* @author Tab
* @date 2021/9/3 14:38
*/
public function index()
{
if($this->request->isPost()) {
$params = $this->request->post();
$result = DistributionOrderGoodsLogic::lists($params);
return $this->_success('', $result);
}
return view();
}
/**
* @notes 处理旧数据
* @author Tab
* @date 2021/10/16 15:03
*/
public function processOldData()
{
// 查询order_id为0的数据
$lists = \app\common\model\DistributionOrderGoods::where('order_id', 0)->select()->toArray();
// 默认分销等级
$defaultId = \app\common\model\DistributionLevel::where('is_default', 1)->value('id');
$updateData = [];
foreach($lists as $item) {
$temp['id'] = $item['id'];
$temp['level_id'] = $defaultId;
$temp['level'] = 1;
$temp['order_id'] = OrderGoods::where('id', $item['order_goods_id'])->value('order_id');
$updateData[] = $temp;
}
if (count($updateData) > 0) {
$model = new \app\common\model\DistributionOrderGoods();
$model->saveAll($updateData);
return '旧数据处理完成';
}
return '无旧数据需要处理';
}
}

View file

@ -0,0 +1,29 @@
<?php
namespace app\admin\controller;
use app\admin\logic\DistributionSettingLogic;
class DistributionSetting extends AdminBase
{
public function index()
{
$config = DistributionSettingLogic::getConfig();
return view('', ['config' => $config]);
}
public function set()
{
$params = $this->request->post();
$result = DistributionSettingLogic::set($params);
if ($result) {
return $this->_success('设置成功');
}
return $this->_error(DistributionSettingLogic::getError());
}
public function settlement()
{
$config = DistributionSettingLogic::getConfig();
return view('', ['config' => $config]);
}
}

View file

@ -29,9 +29,9 @@ class Express extends AdminBase
/**
* lists
* @return mixed
* @throws \think\exception\DbException
* @throws db\exception\DataNotFoundException
* @throws db\exception\ModelNotFoundException
* @throws @\think\exception\DbException
* @throws @db\exception\DataNotFoundException
* @throws @db\exception\ModelNotFoundException
*/
public function lists()
{
@ -44,6 +44,9 @@ class Express extends AdminBase
/**
* 添加
* @return mixed
* @throws @\think\exception\DbException
* @throws @db\exception\DataNotFoundException
* @throws @db\exception\ModelNotFoundException
*/
public function add()
{
@ -66,6 +69,11 @@ class Express extends AdminBase
* 编辑
* @param $id
* @return mixed
* @throws @\think\Exception
* @throws @\think\exception\DbException
* @throws @\think\exception\PDOException
* @throws @db\exception\DataNotFoundException
* @throws @db\exception\ModelNotFoundException
*/
public function edit($id)
{
@ -89,8 +97,8 @@ class Express extends AdminBase
/**
* 删除
* @param $delData
* @throws \think\Exception
* @throws \think\exception\PDOException
* @throws @\think\Exception
* @throws @\think\exception\PDOException
*/
public function del($delData)
{

View file

@ -0,0 +1,138 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用,保留版权即可
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\logic\ExpressLogic;
use app\admin\logic\FaceSheetLogic;
use app\common\server\ConfigServer;
class FaceSheet extends AdminBase
{
/**
* @notes 面单设置
* @return mixed
* @throws @\think\Exception
* @throws @\think\db\exception\DataNotFoundException
* @throws @\think\db\exception\ModelNotFoundException
* @throws @\think\exception\DbException
* @throws @\think\exception\PDOException
* @author 张无忌
* @date 2021/9/24 17:32
*/
public function setting()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
ConfigServer::set('faceSheet', 'type', $post['type']);
ConfigServer::set('kd100', 'kd100_key', $post['kd100_key']);
ConfigServer::set('kd100', 'kd100_secret', $post['kd100_secret']);
ConfigServer::set('kd100', 'kd100_siid', $post['kd100_siid']);
$this->_success('修改成功');
}
$faceSheet = ConfigServer::get('faceSheet');
$detail = [
'kd100_key' => ConfigServer::get('kd100', 'kd100_key'),
'kd100_secret' => ConfigServer::get('kd100', 'kd100_secret'),
'kd100_siid' => ConfigServer::get('kd100', 'kd100_siid'),
];
$this->assign('detail', $detail);
$this->assign('faceSheet', $faceSheet);
return $this->fetch();
}
/**
* @notes 电子面单模板列表
* @author 张无忌
* @date 2021/9/24 17:35
*/
public function lists()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
$list = FaceSheetLogic::lists($get);
$this->_success('获取成功', $list);
}
return $this->fetch();
}
/**
* @notes 新增电子面单模板
* @author 张无忌
* @date 2021/9/24 18:35
*/
public function add()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$result = FaceSheetLogic::add($post);
if ($result !== true) {
$this->_error($result);
}
$this->_success('新增成功');
}
$this->assign('express', ExpressLogic::all());
return $this->fetch();
}
/**
* @notes 编辑电子面单模板
* @author 张无忌
* @date 2021/9/24 18:35
*/
public function edit()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$result = FaceSheetLogic::edit($post);
if ($result !== true) {
$this->_error($result);
}
$this->_success('编辑成功');
}
$id = $this->request->get('id');
$this->assign('detail', FaceSheetLogic::detail($id));
$this->assign('express', ExpressLogic::all());
return $this->fetch();
}
/**
* @notes 删除电子面单模板
* @author 张无忌
* @date 2021/9/28 15:45
*/
public function del()
{
if ($this->request->isAjax()) {
$id = $this->request->post('id');
$result = FaceSheetLogic::del($id);
if ($result !== true) {
$this->_error($result);
}
$this->_success('删除成功');
}
}
}

View file

@ -0,0 +1,79 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用,保留版权即可
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\logic\FaceSheetOrderLogic;
use app\admin\logic\FaceSheetSenderLogic;
use app\admin\logic\FaceSheetLogic;
class FaceSheetOrder extends AdminBase
{
/**
* @notes 获取待发货订单列表
* @return mixed
* @author 张无忌
* @date 2021/9/27 9:39
*/
public function lists()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
$lists = FaceSheetOrderLogic::lists($get);
$this->_success('获取成功', $lists);
}
return $this->fetch();
}
/**
* @notes 选择打印模板
* @return mixed
* @author 张无忌
* @date 2021/9/27 15:59
*/
public function select()
{
$this->assign('template', FaceSheetLogic::all());
$this->assign('sender', FaceSheetSenderLogic::all());
return $this->fetch();
}
/**
* @notes 批量打印
* @author 张无忌
* @date 2021/9/27 14:49
*/
public function print()
{
if ($this->request->isAjax()) {
$order_id = $this->request->post('order_id', 0, 'intval');
$tempid = $this->request->post('tempid', 0, 'intval');
$sender_id = $this->request->post('sender_id', 0, 'intval');
$result = FaceSheetOrderLogic::print($order_id, $tempid, $sender_id, $this->admin_id);
if ($result !== true) {
return $this->_error($result);
}
return $this->_success('打印成功');
}
return $this->_error('请求异常');
}
}

View file

@ -0,0 +1,99 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用,保留版权即可
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\logic\FaceSheetSenderLogic;
class FaceSheetSender extends AdminBase
{
/**
* @notes 发件人列表
* @author 张无忌
* @date 2021/9/26 14:26
*/
public function lists()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
$list = FaceSheetSenderLogic::lists($get);
$this->_success('获取成功', $list);
}
return $this->fetch();
}
/**
* @notes 新增发件人模板
* @author 张无忌
* @date 2021/9/26 14:27
*/
public function add()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$result = FaceSheetSenderLogic::add($post);
if ($result !== true) {
$this->_error($result);
}
$this->_success('新增成功');
}
return $this->fetch();
}
/**
* @notes 编辑发件人
* @author 张无忌
* @date 2021/9/26 14:27
*/
public function edit()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$result = FaceSheetSenderLogic::edit($post);
if ($result !== true) {
$this->_error($result);
}
$this->_success('编辑成功');
}
$id = $this->request->get('id');
$this->assign('detail', FaceSheetSenderLogic::detail($id));
return $this->fetch();
}
/**
* @notes 删除发件人
* @author 张无忌
* @date 2021/9/26 14:27
*/
public function del()
{
if ($this->request->isAjax()) {
$id = $this->request->post('id');
$result = FaceSheetSenderLogic::del($id);
if ($result !== true) {
$this->_error($result);
}
$this->_success('删除成功');
}
}
}

0
server/application/admin/controller/File.php Normal file → Executable file
View file

View file

@ -1,4 +1,22 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\controller\AdminBase;

View file

@ -34,12 +34,19 @@ class Freight extends AdminBase
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$post['type'] = isset($post['type']) && $post['type'] == 'on' ? 1 : 0;
ConfigServer::set('express', 'is_express', $post['type']);
$post['is_express'] = isset($post['is_express']) && $post['is_express'] == 'on' ? 1 : 0;
$post['is_selffetch'] = isset($post['is_selffetch']) && $post['is_selffetch'] == 'on' ? 1 : 0;
if ($post['is_express'] === 0 && $post['is_selffetch'] === 0) {
$this->_error('至少保留一种配送方式');
}
ConfigServer::set('delivery_type', 'is_express', $post['is_express']);
ConfigServer::set('delivery_type', 'is_selffetch', $post['is_selffetch']);
$this->_success('操作成功');
}
$type = ConfigServer::get('express', 'is_express');
$this->assign('type', $type);
$is_express = ConfigServer::get('delivery_type', 'is_express', 1);
$is_selffetch = ConfigServer::get('delivery_type', 'is_selffetch', 0);
$this->assign('is_express', $is_express);
$this->assign('is_selffetch', $is_selffetch);
return $this->fetch();
}
@ -140,4 +147,5 @@ class Freight extends AdminBase
{
return $this->fetch();
}
}

View file

@ -19,8 +19,10 @@
namespace app\admin\controller;
use app\common\model\Order as CommonOrder;
use app\admin\logic\{GoodsBrandLogic, GoodsCategoryLogic, GoodsLogic, SupplierLogic,FreightLogic,CommonLogic};
use think\Db;
use think\facade\Hook;
class Goods extends AdminBase
{
@ -45,6 +47,7 @@ class Goods extends AdminBase
$this->assign('statistics',GoodsLogic::statistics());
$this->assign('category_list', GoodsCategoryLogic::categoryTreeeTree());
$this->assign('supplier_list',SupplierLogic::getSupplierList());
$this->assign('delivery_type', CommonOrder::getDeliveryType(true));
return $this->fetch();
}
@ -134,6 +137,11 @@ class Goods extends AdminBase
$this->_error($result);
}
}
// 校验规格
$total_stock = array_sum(array_column($spec_lists, 'stock'));
if ($total_stock <= 0) {
$this->_error('至少有一个规格的库存大于0');
}
}
//添加商品
@ -211,6 +219,11 @@ class Goods extends AdminBase
$this->_error($result);
}
}
// 校验规格
$total_stock = array_sum(array_column($spec_lists, 'stock'));
if ($total_stock <= 0) {
$this->_error('至少有一个规格的库存大于0');
}
}
if ($post['status'] == 0) {
@ -232,7 +245,7 @@ class Goods extends AdminBase
if ($result !== true) {
$this->_error('添加失败:' . $result);
}
$this->_success('修改成功');
$this->_success(GoodsLogic::$error ? : '修改成功');
}
$this->assign('category_lists', json_encode(GoodsCategoryLogic::getAllTree(), JSON_UNESCAPED_UNICODE));
@ -274,6 +287,8 @@ class Goods extends AdminBase
$field_value = $this->request->post('value');
$result = CommonLogic::changeTableValue($table,$pk_name,$pk_value,$field,$field_value);
if($result === true){
// 下架或删除商品,更新商品收藏
Hook::listen('update_collect', ['goods_id' => $pk_value]);
$this->_success('修改成功');
}
$this->_error($result);

View file

@ -0,0 +1,46 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;
/**
* H5商城控制器
* Class Hfive
* @package app\admin\controller
*/
class Hfive extends AdminBase
{
/**
* @notes H5商城设置
* @return \think\response\View|void
* @author Tab
* @date 2021/8/14 14:55
*/
public function set()
{
if($this->request->isPost()) {
$params = $this->request->post();
\app\admin\logic\Hfive::set($params);
return $this->_success('设置成功');
}
$config = \app\admin\logic\Hfive::getConfig();
$this->assign('config', $config);
return view();
}
}

View file

@ -1,5 +1,21 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;

0
server/application/admin/controller/Index.php Normal file → Executable file
View file

View file

@ -0,0 +1,125 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用,保留版权即可
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\logic\LiveGoodsLogic;
/**
* 直播商品控制器
* Class LiveGoods
* @package app\admin\controller
*/
class LiveGoods extends AdminBase
{
/**
* @notes 获取直播商品列表
* @return mixed|void
* @throws @\EasyWeChat\Kernel\Exceptions\HttpException
* @throws @\EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws @\EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws @\EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws @\Psr\SimpleCache\InvalidArgumentException
* @author heshihu
* @date 2021/9/17 11:42
*/
public function lists()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
$lists = LiveGoodsLogic::lists($get);
if (is_string($lists)) {
return $this->_error($lists);
}
$this->_success('获取成功', $lists);
}
return $this->fetch();
}
/**
* @notes 添加直播商品
* @return mixed|void
* @throws @\EasyWeChat\Kernel\Exceptions\HttpException
* @throws @\EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws @\EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws @\EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws @\Psr\SimpleCache\InvalidArgumentException
* @author heshihu
* @date 2021/9/17 15:26
*/
public function add()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$result = $this->validate($post, 'app\admin\validate\LiveGoods');
if ($result !== true) {
$this->_error($result);
}
$result = LiveGoodsLogic::add($post);
if ($result !== true) {
return $this->_error($result);
}
$this->_success('添加成功');
}
return $this->fetch();
}
public function addUploadImage()
{
if ($this->request->isPost()) {
$goods_image = $this->request->post('goods_image');
$result = LiveGoodsLogic::addUploadImage($goods_image);
if (is_string($result)) {
return $this->_error($result);
}
return $this->_success('上传成功', $result);
}
}
/**
* @notes 删除商品
* @return false|void
* @throws @\EasyWeChat\Kernel\Exceptions\HttpException
* @throws @\EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws @\EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws @\EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws @\Psr\SimpleCache\InvalidArgumentException
* @author heshihu
* @date 2021/9/17 18:38
*/
public function del()
{
if ($this->request->isAjax()) {
$id = $this->request->post('id');
$result = LiveGoodsLogic::del($id);
if ($result !== true) {
return $this->_error($result);
}
$this->_success('删除成功');
}
return false;
}
}

View file

@ -0,0 +1,110 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用,保留版权即可
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\logic\LiveRoomLogic;
class LiveRoom extends AdminBase
{
public $like_not_need_login = ['upload'];
/**
* @notes 获取直播间列表
* @return mixed|void
* @author 张无忌
* @date 2021/9/13 15:57
*/
public function lists()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
$lists = LiveRoomLogic::lists($get);
if (is_string($lists)) {
return $this->_error($lists);
}
$this->_success('获取成功', $lists);
}
return $this->fetch();
}
/**
* @notes 创建直播间
* @return mixed
* @author 张无忌
* @date 2021/9/13 15:57
*/
public function add()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$result = LiveRoomLogic::add($post);
if ($result !== true) {
return $this->_error($result);
}
$this->_success('创建成功');
}
return $this->fetch();
}
/**
* @notes 删除直播间
* @return bool|void
* @author 张无忌
* @date 2021/9/14 18:50
*/
public function del()
{
if ($this->request->isAjax()) {
$id = $this->request->post('id');
$result = LiveRoomLogic::del($id);
if ($result !== true) {
return $this->_error($result);
}
$this->_success('删除成功');
}
return false;
}
/**
* @notes 上传临时图片
* @return mixed|void
* @author 张无忌
* @date 2021/9/14 14:51
*/
public function uploadImage()
{
if ($this->request->isPost()) {
$file = request()->file('file');
$info = $file->move( './uploads/temp');
$result = LiveRoomLogic::upload($info->getSaveName());
if (is_string($result)) {
return $this->_error($result);
}
return $this->_success('上传成功', $result);
}
return $this->fetch();
}
}

View file

@ -1,10 +1,28 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\logic\LuckDrawLogic;
use app\common\server\ConfigServer;
use app\common\model\Luckdraw as LuckdrawModel;
class LuckDraw extends AdminBase
{
@ -24,8 +42,10 @@ class LuckDraw extends AdminBase
// 获取抽奖设置信息
$this->assign('setConfig', [
'limit' => ConfigServer::get('luckdraw', 'limit', 0),
'need' => ConfigServer::get('luckdraw', 'need', 0),
'rule' => ConfigServer::get('luckdraw', 'rule', ''),
'status' => ConfigServer::get('luckdraw', 'status', 0)
'status' => ConfigServer::get('luckdraw', 'status', 0),
'show_win' => ConfigServer::get('luckdraw', 'show_win', 0)
]);
return $this->fetch();
@ -49,7 +69,8 @@ class LuckDraw extends AdminBase
$error = LuckDrawLogic::getError() ?: '新增失败';
$this->_error($error);
}
$this->assign('prizes', LuckdrawModel::getPrizeDesc(true));
$this->assign('coupon', LuckDrawLogic::coupon());
return $this->fetch();
}
@ -73,6 +94,8 @@ class LuckDraw extends AdminBase
}
$id = $this->request->get('id');
$this->assign('prizes', LuckdrawModel::getPrizeDesc(true));
$this->assign('coupon', LuckDrawLogic::coupon());
$this->assign('detail', LuckDrawLogic::detail($id));
return $this->fetch();
}

View file

@ -0,0 +1,44 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\logic\MapConfigLogic;
class MapConfig extends AdminBase{
/**
* @notes 获取地图配置
* @return mixed|void
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
* @author ljj
* @date 2021/8/20 8:34 下午
*/
public function config(){
if($this->request->isAjax()){
$post = $this->request->post();
MapConfigLogic::setConfig($post);
return $this->_success('设置成功',[]);
}
$this->assign('config',MapConfigLogic::getConfig());
return $this->fetch();
}
}

0
server/application/admin/controller/My.php Normal file → Executable file
View file

View file

@ -1,4 +1,22 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\logic\OpLogic;

View file

@ -192,9 +192,36 @@ class Order extends AdminBase
if(true === $result){
$result = OrderLogic::orderPrint($id);
if(true === $result){
$this->success('打印成功,如未出小票,请检查打印机是否在线');
$this->success('打印成功,如未出小票,请检查打印机是否在线');
}
}
$this->_error($result);
}
/**
* @notes 修改快递单号
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @author suny
* @date 2021/11/08 16:06 下午
*/
public function change_delivery()
{
$get = $this->request->get();
if($this->request->isAjax() && $this->request->isPost())
{
$post = $this->request->post();
$result = OrderLogic::changeDelivery($post);
if ($result) {
$this->_success('操作成功');
}
}
$detail = OrderLogic::getDelivery($get);
$this->assign('detail', $detail);
$this->assign('express', OrderLogic::express());
return $this->fetch();
}
}

View file

@ -0,0 +1,46 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;
/**
* PC商城控制器
* Class Pc
* @package app\admin\controller
*/
class Pc extends AdminBase
{
/**
* @notes PC商城设置
* @return \think\response\View|void
* @author Tab
* @date 2021/8/14 14:55
*/
public function set()
{
if($this->request->isPost()) {
$params = $this->request->post();
\app\admin\logic\Pc::set($params);
return $this->_success('设置成功');
}
$config = \app\admin\logic\Pc::getConfig();
$this->assign('config', $config);
return view();
}
}

0
server/application/admin/controller/Role.php Normal file → Executable file
View file

View file

@ -0,0 +1,154 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\logic\SelffetchShopLogic;
use app\common\server\ConfigServer;
class SelffetchShop extends AdminBase
{
/**
* @notes 查看自提门店列表
* @return mixed
* @author ljj
* @date 2021/8/14 6:02 下午
*/
public function lists()
{
if ($this->request->isAjax()) {
$params = $this->request->get();
$this->_success('', SelffetchShopLogic::lists($params));
}
return $this->fetch();
}
/**
* @notes 添加自提门店
* @return mixed
* @author ljj
* @date 2021/8/16 11:22 上午
*/
public function add()
{
if ($this->request->isAjax() && $this->request->isPost()) {
$params = $this->request->post();
$result = $this->validate($params, 'app\admin\validate\SelffetchShop.add');
if ($result !== true) {
$this->_error($result);
}
$result = SelffetchShopLogic::add($params);
if ($result !== true) {
$this->_error('添加失败:' . $result);
}
$this->_success('添加成功');
}
$this->assign('tx_map_key',ConfigServer::get('map','tx_map_key',''));
$this->assign('area_lists', json_encode(SelffetchShopLogic::getAreaLists(), JSON_UNESCAPED_UNICODE));
return $this->fetch();
}
/**
* @notes 编辑自提门店
* @param $id
* @return mixed
* @author ljj
* @date 2021/8/16 2:15 下午
*/
public function edit($id)
{
if ($this->request->isAjax() && $this->request->isPost()) {
$params = $this->request->post();
$result = $this->validate($params, 'app\admin\validate\SelffetchShop.edit');
if ($result !== true) {
$this->_error($result);
}
$result = SelffetchShopLogic::edit($params);
if ($result !== true) {
$this->_error('修改失败:' . $result);
}
$this->_success('修改成功');
}
$this->assign('tx_map_key',ConfigServer::get('map','tx_map_key',''));
$this->assign('area_lists', json_encode(SelffetchShopLogic::getAreaLists(), JSON_UNESCAPED_UNICODE));
$this->assign('detail', SelffetchShopLogic::detail($id));
return $this->fetch();
}
/**
* @notes 修改自提门店状态
* @author ljj
* @date 2021/8/16 2:35 下午
*/
public function status()
{
if ($this->request->isAjax() && $this->request->isPost()) {
$params = $this->request->post();
$result = $this->validate($params, 'app\admin\validate\SelffetchShop.status');
if ($result !== true) {
$this->_error($result);
}
$result = SelffetchShopLogic::status($params);
if ($result !== true) {
$this->_error('修改失败:' . $result);
}
$this->_success('修改成功');
}
}
/**
* @notes 删除自提门店
* @author ljj
* @date 2021/8/16 2:42 下午
*/
public function del()
{
if ($this->request->isAjax() && $this->request->isPost()) {
$params = $this->request->post();
$result = $this->validate($params, 'app\admin\validate\SelffetchShop.del');
if ($result !== true) {
$this->_error($result);
}
$result = SelffetchShopLogic::del($params);
if ($result !== true) {
$this->_error('删除失败:' . $result);
}
$this->_success('删除成功');
}
}
/**
* @notes 导出列表
* @author ljj
* @date 2021/8/16 2:50 下午
*/
public function exportFile()
{
$params = $this->request->get();
$this->_success('', SelffetchShopLogic::exportFile($params));
}
}

View file

@ -0,0 +1,171 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\logic\SelffetchVerifierLogic;
class SelffetchVerifier extends AdminBase
{
/**
* @notes 核销员列表
* @return mixed
* @author ljj
* @date 2021/8/16 3:30 下午
*/
public function lists()
{
if ($this->request->isAjax()) {
$params = $this->request->get();
$this->_success('', SelffetchVerifierLogic::lists($params));
}
return $this->fetch();
}
/**
* @notes 添加核销员
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @author ljj
* @date 2021/8/16 4:45 下午
*/
public function add()
{
if ($this->request->isAjax() && $this->request->isPost()) {
$params = $this->request->post();
$result = $this->validate($params, 'app\admin\validate\SelffetchVerifier.add');
if ($result !== true) {
$this->_error($result);
}
$result = SelffetchVerifierLogic::add($params);
if ($result !== true) {
$this->_error('添加失败:' . $result);
}
$this->_success('添加成功');
}
$this->assign('shop_lists', SelffetchVerifierLogic::getShopLists());
return $this->fetch();
}
/**
* @notes 获取用户列表
* @return mixed
* @author ljj
* @date 2021/8/19 2:42 下午
*/
public function userLists()
{
if ($this->request->isAjax()) {
$params = $this->request->get();
$this->_success('', SelffetchVerifierLogic::getUserLists($params));
}
return $this->fetch();
}
/**
* @notes 编辑核销员
* @param $id
* @return mixed
* @author ljj
* @date 2021/8/16 4:49 下午
*/
public function edit($id)
{
if ($this->request->isAjax() && $this->request->isPost()) {
$params = $this->request->post();
$result = $this->validate($params, 'app\admin\validate\SelffetchVerifier.edit');
if ($result !== true) {
$this->_error($result);
}
$result = SelffetchVerifierLogic::edit($params);
if ($result !== true) {
$this->_error('修改失败:' . $result);
}
$this->_success('修改成功');
}
//$this->assign('user_lists', SelffetchVerifierLogic::getUserLists());
$this->assign('shop_lists', SelffetchVerifierLogic::getShopLists());
$this->assign('detail', SelffetchVerifierLogic::detail($id));
return $this->fetch();
}
/**
* @notes 修改核销员状态
* @author ljj
* @date 2021/8/16 4:55 下午
*/
public function status()
{
if ($this->request->isAjax() && $this->request->isPost()) {
$params = $this->request->post();
$result = $this->validate($params, 'app\admin\validate\SelffetchVerifier.status');
if ($result !== true) {
$this->_error($result);
}
$result = SelffetchVerifierLogic::status($params);
if ($result !== true) {
$this->_error('修改失败:' . $result);
}
$this->_success('修改成功');
}
}
/**
* @notes 删除核销员
* @author ljj
* @date 2021/8/16 4:58 下午
*/
public function del()
{
if ($this->request->isAjax() && $this->request->isPost()) {
$params = $this->request->post();
$result = $this->validate($params, 'app\admin\validate\SelffetchVerifier.del');
if ($result !== true) {
$this->_error($result);
}
$result = SelffetchVerifierLogic::del($params);
if ($result !== true) {
$this->_error('删除失败:' . $result);
}
$this->_success('删除成功');
}
}
/**
* @notes 导出核销员列表
* @author ljj
* @date 2021/8/16 5:02 下午
*/
public function exportFile()
{
$params = $this->request->get();
$this->_success('', SelffetchVerifierLogic::exportFile($params));
}
}

View file

@ -111,7 +111,9 @@ class ShopSetting extends AdminBase
'min_withdraw' => ConfigServer::get('withdraw', 'min_withdraw'),
'max_withdraw' => ConfigServer::get('withdraw', 'max_withdraw'),
'poundage' => ConfigServer::get('withdraw', 'poundage'),
'type' => ConfigServer::get('withdraw', 'type') ? ConfigServer::get('withdraw', 'type') : []
'type' => ConfigServer::get('withdraw', 'type') ? ConfigServer::get('withdraw', 'type') : [],
'transfer_way' => ConfigServer::get('withdraw', 'transfer_way',1),
];
$this->assign('config', $config);
return $this->fetch();
@ -124,11 +126,15 @@ class ShopSetting extends AdminBase
if(empty($post['type'])) {
return $this->_error('至少选择一种提现方式');
}
if ($post['poundage'] > 100 || $post['poundage'] < 0) {
return $this->_error('提现手续费须在0-100区间内');
}
if ($post) {
ConfigServer::set('withdraw', 'min_withdraw', $post['min_withdraw']);//最低提现
ConfigServer::set('withdraw', 'max_withdraw', $post['max_withdraw']);//最高提现
ConfigServer::set('withdraw', 'poundage', $post['poundage']);//提现手续费
ConfigServer::set('withdraw', 'type', $post['type']);//提现方式
ConfigServer::set('withdraw', 'transfer_way', $post['transfer_way']);//微信零钱接口
$this->_success('操作成功');
}
}

0
server/application/admin/controller/Sites.php Normal file → Executable file
View file

View file

@ -1,4 +1,21 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;
@ -6,55 +23,70 @@ use app\admin\logic\StatisticsLogic;
class Statistics extends AdminBase
{
/**
* 会员统计
* @notes 获取会员统计数据
* @return mixed
* @author 段誉
* @date 2022/4/27 10:51
*/
public function member()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$this->_success('', StatisticsLogic::member($post));
$params = $this->request->get();
$this->_success('', StatisticsLogic::getMemberData($params));
}
$this->assign('res', StatisticsLogic::member(['days' => 'today']));
$this->assign('time', StatisticsLogic::getDateData());
return $this->fetch();
}
/**
* 商品统计
* @notes 获取商品统计数据
* @return mixed
* @author 段誉
* @date 2022/4/27 15:04
*/
public function goods()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$this->_success('', StatisticsLogic::goods($post));
$params = $this->request->get();
$this->_success('', StatisticsLogic::getGoodsData($params));
}
$this->assign('res', StatisticsLogic::goods(['days' => 'today']));
$this->assign('time', StatisticsLogic::getDateData());
return $this->fetch();
}
/**
* 访问
*/
public function visit()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$this->_success('', StatisticsLogic::visit($post));
}
$this->assign('res', StatisticsLogic::visit(['days' => 'today']));
return $this->fetch();
}
/**
* 交易
* @notes 获取交易数据
* @return mixed
* @author 段誉
* @date 2022/4/27 15:33
*/
public function deal()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$this->_success('', StatisticsLogic::deal($post));
$params = $this->request->get();
$this->_success('', StatisticsLogic::getDealData($params));
}
$this->assign('res', StatisticsLogic::deal(['days' => 'today']));
$this->assign('time', StatisticsLogic::getDateData());
return $this->fetch();
}
/**
* @notes 获取访问数据
* @return mixed
* @author 段誉
* @date 2022/4/27 15:47
*/
public function visit()
{
if ($this->request->isAjax()) {
$params = $this->request->get();
$this->_success('', StatisticsLogic::getVisitData($params));
}
$this->assign('time', StatisticsLogic::getDateData());
return $this->fetch();
}
}

View file

@ -54,7 +54,7 @@ class StorageConfig extends AdminBase
'status' => $default == 'aliyun' ? 1 : 0
],
[
'name' => '腾讯云OSS',
'name' => '腾讯云COS',
'path' => '存储在腾讯云,请前往腾讯云开通存储服务',
'engine' => 'qcloud',
'status' => $default == 'qcloud' ? 1 : 0

View file

@ -1,4 +1,21 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;

View file

@ -1,4 +1,21 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;

View file

@ -105,7 +105,7 @@ class User extends AdminBase
}
$this->_error($result);
}
$this->assign('info',UserLogic::getUser($id));
$this->assign('info',UserLogic::getInfo($id));
$this->assign('user_level',UserLogic::getLevelList());
return $this->fetch();
@ -130,13 +130,21 @@ class User extends AdminBase
/*
* 会员详情
*/
public function info($id){
public function infoOld($id){
$detail = UserLogic::getUser($id,false,true);
$this->assign('detail',$detail);
return $this->fetch();
}
public function info(){
$id = $this->request->get('id', '', 'intval');
$detail = UserLogic::getInfo($id);
return view('', [
'detail' => $detail
]);
}
public function getList(){
$post = $this->request->get('');
$list = UserLogic::getList($post);
@ -150,6 +158,18 @@ class User extends AdminBase
return $this->fetch();
}
public function fans()
{
if ($this->request->isPost()) {
$params = $this->request->post();
$result = UserLogic::fans($params);
return $this->_success('', $result);
}
$id = $this->request->get('id/d');
return view('', ['id' => $id]);
}
/**
* 转账记录
*/
@ -164,4 +184,35 @@ class User extends AdminBase
}
return $this->fetch();
}
public function adjustFirstLeader()
{
if($this->request->isPost()) {
$params = $this->request->post();
$result = UserLogic::adjustFirstLeader($params);
if ($result) {
return $this->_success('调整成功');
}
return $this->_error(UserLogic::getError());
}
$id = $this->request->get('id/d');
$user = \app\common\model\User::field('id,sn,nickname,first_leader')->findOrEmpty($id)->toArray();
$firstLeader = \app\common\model\User::getUserInfo($user['first_leader']);
return view('', [
'user_id' => $id,
'user' => $user,
'first_leader' => $firstLeader
]);
}
public function userLists()
{
if ($this->request->isPost()) {
$params = $this->request->post();
$lists = UserLogic::userLists($params);
return $this->_success('', $lists);
}
return view();
}
}

View file

@ -93,7 +93,7 @@ class UserLevel extends AdminBase{
UserLevelLogic::del($id);
$this->_success('删除成功','');
}
$this->_error('删除失败','');
$this->_error($result,'');
}
}
}

View file

@ -40,6 +40,7 @@ class UserPrivilege extends AdminBase{
public function add(){
if($this->request->isAjax()){
$post = $this->request->post();
$post['del'] = 0;
$result = $this->validate($post,'app\admin\validate\UserPrivilege.add');
if($result === true){
UserPrivilegeLogic::add($post);
@ -57,6 +58,7 @@ class UserPrivilege extends AdminBase{
public function edit($id){
if($this->request->isAjax()){
$post = $this->request->post();
$post['del'] = 0;
$result = $this->validate($post,'app\admin\validate\UserPrivilege.edit');
if($result === true){
UserPrivilegeLogic::edit($post);

View file

@ -0,0 +1,56 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\logic\UserSettingLogic;
/**
* 用户设置
* Class User
* @package app\admin\controller\setting
*/
class UserSetting extends AdminBase
{
/**
* @notes 用户设置
* @return \think\response\View
* @author Tab
*/
public function index()
{
$config = UserSettingLogic::getConfig();
return view('', ['config' => $config,'user_level'=>UserSettingLogic::getUserLevel()]);
}
/**
* @notes 用户设置
* @return \think\response\Json
* @author Tab
*/
public function set()
{
$params = $this->request->post();
$result = UserSettingLogic::set($params);
if($result) {
return $this->_success('保存成功');
}
return $this->_error(UserSettingLogic::getError());
}
}

View file

@ -0,0 +1,103 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\admin\logic\VerificationLogic;
use app\common\model\Client_;
use app\common\model\Order as CommonOrder;
use app\common\model\Pay;
class Verification extends AdminBase
{
/**
* @notes 自提订单列表
* @return mixed
* @author ljj
* @date 2021/8/16 6:10 下午
*/
public function lists()
{
if ($this->request->isAjax()) {
$params = $this->request->get();
$params['admin_name'] = $this->admin_info['name'];
$this->_success('', VerificationLogic::lists($params));
}
$this->assign('order_type', CommonOrder::getOrderType(true));
$this->assign('pay_way', Pay::getPayWay(true));
$this->assign('order_source', Client_::getClient(true));
$this->assign('verification_status', CommonOrder::getVerificationStatus(true));
return $this->fetch();
}
/**
* @notes 导出自提订单列表
* @author ljj
* @date 2021/8/16 7:55 下午
*/
public function exportFile()
{
$params = $this->request->get();
$params['admin_name'] = $this->admin_info['name'];
$this->_success('', VerificationLogic::exportFile($params));
}
/**
* @notes 提货核销
* @param $id
* @return mixed
* @author ljj
* @date 2021/8/17 10:09 上午
*/
public function verification($id)
{
if ($this->request->isAjax() && $this->request->isPost()) {
$params = $this->request->post();
$params['admin_info'] = $this->admin_info;
$result = $this->validate($params, 'app\admin\validate\Verification.verification');
if ($result !== true) {
$this->_error($result);
}
$result = VerificationLogic::verification($params);
if ($result !== true) {
$this->_error('核销失败:' . $result);
}
$this->_success('核销成功');
}
$this->assign('detail', VerificationLogic::verificationInfo($id));
return $this->fetch();
}
/**
* @notes 核销查询
* @param $id
* @return mixed
* @author ljj
* @date 2021/8/17 11:47 上午
*/
public function verificationQuery($id)
{
$this->assign('detail', VerificationLogic::verificationQuery($id));
return $this->fetch();
}
}

0
server/application/admin/http/middleware/Auth.php Normal file → Executable file
View file

0
server/application/admin/http/middleware/Login.php Normal file → Executable file
View file

View file

@ -25,8 +25,11 @@ use app\common\model\DistributionOrder;
use think\Db;
use think\helper\Time;
class AccountLogLogic{
public static function lists($get){
class AccountLogLogic
{
public static function lists($get)
{
$source_type = '';
$where = [];
switch ($get['type']){//记录类型
@ -76,6 +79,8 @@ class AccountLogLogic{
$item['create_time'] = date('Y-m-d H:i:s',$item['create_time']);
// 获取来源单号
$item['order_sn'] = Db::name('order')->where(['del'=>0, 'id'=>$item['source_id']])->value('order_sn');
// + -
$item['change_amount'] = $item['change_type'] == 1 ? "+{$item['change_amount']}" : "-{$item['change_amount']}";
}
return ['count'=>$count,'lists'=>$list];
}

View file

@ -25,13 +25,14 @@ class ActivityAreaLogic{
* note 活动专区列表
* create_time 2020/11/24 11:23
*/
public static function areaLists(){
public static function areaLists($get){
$count = Db::name('activity_area')
->where(['del'=>0])
->count();
$lists = Db::name('activity_area')
->where(['del'=>0])
->page($get['page'], $get['limit'])
->select();
foreach ($lists as &$item){
$item['status_desc'] = '下架';
@ -68,6 +69,7 @@ class ActivityAreaLogic{
->join('goods G','AG.Goods_id = G.id')
->where($where)
->field('AG.id,AG.goods_id,AG.activity_id,AA.name,AA.status,G.id,G.name,G.image')
->page($get['page'], $get['limit'])
->order('AG.id desc')
->select();
$activity_lisst = Db::name('activity_area')

View file

@ -57,7 +57,7 @@ class AdLogic
->count();
$ad_list = $ad->where($where)
->page($get['page'], $get['limit'])
->order('id desc')
->order(['sort' => 'desc', 'id' => 'desc'])
->select();
$position = AdPosition::where('del', 0)->column('id,name', 'id');
@ -139,6 +139,7 @@ class AdLogic
'status' => $post['status'],
'category_id' => $post['category_id'] ?? 0,
'create_time' => $time,
'sort' => $post['sort'] ?? 50,
];
return $ad->allowField(true)->save($data);
@ -181,7 +182,7 @@ class AdLogic
'category_id' => $post['category_id'] ?? 0,
'status' => $post['status'],
'update_time' => $time,
'sort' => $post['sort'] ?? 50,
];
return $ad->allowField(true)->save($data, ['id' => $post['id']]);
}
@ -227,6 +228,16 @@ class AdLogic
$info['goods'] = $goods;
}
$info['abs_image'] = UrlServer::getFileUrl($info['image']);
$info['position_desc'] = '';
if (isset($info['pid'])) {
$position = Db::name('ad_position')
->field('width, height')
->where(['id' => $info['pid']])
->find();
$info['position_desc'] = '建议上传广告图片宽*高, '.$position['width'].'px*'.$position['height'].'px';
}
return $info;
}

View file

@ -124,7 +124,7 @@ class AdPositionLogic
'width' => $post['width'],
'height' => $post['height'],
'status' => $post['status'],
'attr' => 0,
'attr' => $post['attr'],
'update_time' => $time,
];

0
server/application/admin/logic/AdminLogic.php Normal file → Executable file
View file

View file

@ -118,18 +118,18 @@ class AfterSaleLogic
->group('a.id')
->select();
foreach ($lists as &$list) {
$list['order']['pay_way'] = Pay::getPayWay($list['order']['pay_way']);
$list['order']['order_status'] = Order::getOrderStatus($list['order']['order_status']);
$list['refund_type'] = AfterSale::getRefundTypeDesc($list['refund_type']);
$list['create_time'] = date('Y-m-d H:i:s', $list['create_time']);
$list['status'] = AfterSale::getStatusDesc($list['status']);
foreach ($lists as $key => $list) {
$lists[$key]['order']['pay_way'] = Pay::getPayWay($list['order']['pay_way']);
$lists[$key]['order']['order_status_text'] = Order::getOrderStatus($list['order']['order_status']);
$lists[$key]['refund_type'] = AfterSale::getRefundTypeDesc($list['refund_type']);
$lists[$key]['create_time'] = date('Y-m-d H:i:s', $list['create_time']);
$lists[$key]['status'] = AfterSale::getStatusDesc($list['status']);
foreach ($list['order_goods'] as &$good) {
foreach ($list['order_goods'] as $ko => $good) {
$info = json_decode($good['goods_info'], true);
$good['goods_name'] = $info['goods_name'];
$good['spec_value'] = $info['spec_value_str'];
$good['image'] = empty($info['spec_image']) ?
$lists[$key]['order_goods'][$ko]['goods_name'] = $info['goods_name'];
$lists[$key]['order_goods'][$ko]['spec_value'] = $info['spec_value_str'];
$lists[$key]['order_goods'][$ko]['image'] = empty($info['spec_image']) ?
UrlServer::getFileUrl($info['image']) : UrlServer::getFileUrl($info['spec_image']);
}
}
@ -155,6 +155,7 @@ class AfterSaleLogic
$result['status_text'] = AfterSale::getStatusDesc($result['status']);
$result['order']['pay_way'] = Pay::getPayWay($result['order']['pay_way']);
$result['order']['order_status'] = Order::getOrderStatus($result['order']['order_status']);
$result['order']['delivery_type_text'] = Order::getDeliveryType($result['order']['delivery_type']);
$result['create_time'] = date('Y-m-d H:i:s', $result['create_time']);
foreach ($result['order_goods'] as &$good) {

0
server/application/admin/logic/AuthLogic.php Normal file → Executable file
View file

View file

@ -78,6 +78,7 @@ class BargainLogic
->where($where)
->with(['goods'])
->withCount(['launchPeopleNumber', 'successKnifePeopleNumber'])
->order(['id' => 'desc'])
->page($get['page'], $get['limit'])
->select();
@ -469,11 +470,11 @@ class BargainLogic
->with(['user.level'])
->find()->toArray();
$detail['domain'] = UrlServer::getFileUrl();
$detail['domain'] = UrlServer::getFileUrl('/');
$detail['goods_snap']['goods_iamge'] = UrlServer::getFileUrl($detail['goods_snap']['goods_iamge']);
$detail['launch_start_time'] = date('Y-m-d H:i:s', $detail['launch_start_time']);
$detail['launch_end_time'] = date('Y-m-d H:i:s', $detail['launch_end_time']);
$detail['payment_where'] = $detail['bargain_snap']['payment_where'] == 1 ? '任意金额购买' : '固定金额购买';
$detail['payment_where'] = $detail['bargain_snap']['payment_where'] == 1 ? '砍到指定底价' : '任意金额';
$detail['status'] = BargainLaunch::getStatusDesc($detail['status']);
return $detail;
}
@ -495,10 +496,14 @@ class BargainLogic
->where('order_id', '>', 0)
->with(['user.level', 'order'])
->page($get['page'], $get['limit'])
->select();
->select()->toArray();
foreach ($lists as &$item) {
$item['order_status'] = Order::getOrderStatus($item['order']['order_status']);
if (!empty($item['goods_snap']['goods_iamge'])) {
$item['goods_snap']['goods_iamge'] = UrlServer::getFileUrl($item['goods_snap']['goods_iamge']);
}
}
return ['count'=>$count, 'lists'=>$lists];

View file

@ -0,0 +1,132 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\logic;
use app\common\model\Goods;
use app\common\server\UrlServer;
use think\Db;
class CommentHelperLogic
{
/**
* @notes 商品列表
* @param $get
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @author 段誉
* @date 2022/1/12 11:00
*/
public static function lists($get)
{
$where = [];
$where[] = ['del', '=', '0'];
if (isset($get['status']) && $get['status'] != '') {
$where[] = ['status', '=', $get['status']];
}
if (isset($get['keyword']) && $get['keyword'] != '') {
$where[] = ['name', 'like', '%' . $get['keyword'] . '%'];
}
if (isset($get['category_id']) && $get['category_id'] != '') {
$where[] = ['first_category_id|second_category_id|third_category_id', '=', $get['category_id']];
}
$count = Db::name('goods')->where($where)->count();
$lists = Db::name('goods')
->field('*,virtual_sales_sum+sales_sum as total_sales_sum')
->where($where)
->withAttr('comment_count', function ($value,$data){
return Db::name('goods_comment')->where(['goods_id' => $data['id']])->count();
})
->page($get['page'], $get['limit'])
->order('id desc')
->select();
$goods_category = Db::name('goods_category')->where(['del' => 0])->column('name', 'id');
foreach ($lists as &$item) {
$item['cate_name'] = GoodsLogic::getCateName($goods_category, $item);
$item['price'] = '¥' . $item['min_price'];
if ($item['spec_type'] == 2 && $item['max_price'] !== $item['min_price']) {
$item['price'] = '¥' . $item['min_price'] . '~' . '¥' . $item['max_price'];
}
$item['create_time_desc'] = date('Y-m-d H:i:s', $item['create_time']);
$item['image'] = UrlServer::getFileUrl($item['image']);
$item['status_desc'] = Goods::getStatusDesc($item['status']);
}
return ['count' => $count, 'list' => $lists];
}
/**
* @notes 添加虚拟评论
* @param $post
* @return bool|string
* @author 段誉
* @date 2022/1/12 11:00
*/
public static function addComment($post)
{
try {
$goods_item = Db::name('goods_item')->where(['goods_id'=> $post['goods_id']])->find();
if (empty($goods_item)) {
throw new \Exception('当前商品规格参数错误');
}
$virtual_data = [
'sn' => create_user_sn(),
'nickname' => $post['nickname'],
'avatar' => $post['avatar'],
'comment_time' => strtotime($post['comment_time']),
'level' => $post['level'],
];
$data = [
'goods_id' => $post['goods_id'],
'item_id' => $goods_item['id'],
'user_id' => 0,
'order_goods_id' => 0,
'goods_comment' => $post['score'],
'service_comment' => $post['score'],
'express_comment' => $post['score'],
'description_comment' => $post['score'],
'comment' => $post['comment'],
'create_time' => time(),
'virtual_data' => json_encode($virtual_data, JSON_UNESCAPED_UNICODE)
];
$comment_id = Db::name('goods_comment')->insertGetId($data);
if (!empty($post['comment_image'])) {
foreach ($post['comment_image'] as $image_val) {
$image[] = ['uri' => $image_val, 'goods_comment_id' => $comment_id];
}
Db::name('goods_comment_image')->insertAll($image);
}
return true;
} catch (\Exception $e) {
return $e->getMessage();
}
}
}

View file

@ -52,12 +52,11 @@ class CommonLogic{
];
if ($field == 'status' and $field_value == 0) {
$res = Db::name('team_activity')
->where(['goods_id'=>$pk_value])
->find();
if ($res) {
return '该商品正在参与拼团,请先关闭后才允许下架';
$activity_goods = GoodsLogic::activityGoods()['activity_goods'];
if(in_array($pk_value,$activity_goods)){
return '该商品正在参与活动,请先关闭后才允许下架';
}
}
$result = Db::name($table)->where($where)->update($data);
@ -85,6 +84,10 @@ class CommonLogic{
->where($where)
->page($get['page'], $get['limit'])
->column('*','id');
$activity_goods = GoodsLogic::activityGoods();
$seckill_goods = $activity_goods['seckill_goods'];
$team_goods = $activity_goods['team_goods'];
$bargain_goods = $activity_goods['bargain_goods'];
foreach ($goods_list as &$item) {
$item['goods_item'] = [];
@ -94,6 +97,14 @@ class CommonLogic{
}
$item['create_time_desc'] = date('Y-m-d H:i:s',$item['create_time']);
$item['image'] = UrlServer::getFileUrl($item['image']);
$item['attribute'] = '普通商品';
if(in_array($item['id'],$seckill_goods)){
$item['attribute'] = '秒杀商品';
}elseif (in_array($item['id'],$team_goods)){
$item['attribute'] = '拼团商品';
}elseif (in_array($item['id'],$bargain_goods)){
$item['attribute'] = '砍价商品';
}
}
if($is_item){

View file

@ -67,57 +67,6 @@ class CrontabLogic
->find();
}
/**
* 操作
* @param $operation
* @param $id
* @return bool|string
* @throws Exception
* @throws \think\exception\PDOException
*/
public static function operation($operation, $id)
{
try {
$cron = Db::name('dev_crontab')
->where(['id' => $id])
->find();
if ($cron['type'] == 1 && CronExpression::isValidExpression($cron['expression']) === false) {
throw new Exception("规则设置错误"); //定时任务运行规则错误,不执行
}
switch ($operation) {
case 'start':
case 'restart':
Db::name('dev_crontab')
->where(['id' => $id])
->update(['status' => 1]);
break;
case 'stop':
Db::name('dev_crontab')
->where(['id' => $id])
->update(['status' => 2]);
default;
}
/*$count = Db::name('dev_crontab')
->where(['status' => 1])
->count();
$crontab_server = new CrontabServer();
if ($count == 0) {
$crontab_server->run(true);
} else {
$crontab_server->run(false);
}*/
return true;
} catch (Exception $e) {
Db::name('dev_crontab')
->where(['id' => $id])
->update(['status' => 3, 'error' => $e->getMessage()]);
return $e->getMessage();
}
}
/**
* 获取接下来几次执行时间
* @param $get

View file

@ -0,0 +1,119 @@
<?php
namespace app\admin\logic;
use app\admin\model\DistributionMemberApply;
use app\common\logic\DistributionLogic;
use app\common\logic\LogicBase;
use app\common\model\Distribution;
use app\common\server\AreaServer;
use app\common\server\UrlServer;
use think\Db;
class DistributionApplyLogic extends LogicBase
{
public static function lists($get)
{
try {
$where[] = ['DMA.status', '=', $get['type'] ?? 0];
if (!empty($get['keyword']) and $get['keyword']) {
switch ($get['keyword_type']) {
case 'sn':
$where[] = ['U.sn', 'like', '%'.$get['keyword'].'%'];
break;
case 'nickname':
$where[] = ['U.nickname', 'like', '%'.$get['keyword'].'%'];
break;
case 'mobile':
$where[] = ['U.mobile', '=', $get['keyword']];
break;
}
}
$model = new DistributionMemberApply();
$lists = $model->field(['DMA.*'])->alias('DMA')
->where($where)
->with(['user.level'])
->join('user U', 'U.id = DMA.user_id')
->paginate([
'page' => $get['page'],
'list_rows' => $get['limit'],
'var_page' => 'page'
])->toArray();
foreach ($lists['data'] as &$item) {
if ($item['user']) {
$item['user']['avatar'] = UrlServer::getFileUrl($item['user']['avatar']);
}
$item['region'] = AreaServer::getAddress([
$item['province'],
$item['city'],
$item['district']]
);
}
return ['count'=>$lists['total'], 'lists'=>$lists['data']];
} catch (\Exception $e) {
return ['error'=>$e->getMessage()];
}
}
public static function detail($id)
{
$model = new DistributionMemberApply();
$detail = $model->field(true)
->with(['user.level'])
->findOrEmpty($id)
->toArray();
$detail['status_text'] = DistributionMemberApply::getApplyStatus($detail['status']);
$detail['region'] = AreaServer::getAddress([
$detail['province'],
$detail['city'],
$detail['district']]
);
return $detail;
}
public static function audit($post)
{
Db::startTrans();
try {
if ($post['audit_status'] == 1) {
// 审核通过
$model = new DistributionMemberApply();
$apply = $model->field(true)->findOrEmpty((int)$post['id'])->toArray();
DistributionMemberApply::update([
'status' => $post['audit_status'],
'denial_reason' => $post['denial_reason'] ?? '',
'update_time' => time()
], ['id'=>(int)$post['id']]);
$distribution = Distribution::where('user_id', $apply['user_id'])->findOrEmpty()->toArray();
if (empty($distribution)) {
// 生成分销基础信息表
DistributionLogic::add($apply['user_id']);
}
// 更新分销基础信息表
Distribution::where('user_id', $apply['user_id'])->update([
'is_distribution' => 1,
'distribution_time' => time()
]);
} else {
// 审核拒绝
DistributionMemberApply::update([
'status' => $post['audit_status'],
'denial_reason' => $post['denial_reason'] ?? '',
'update_time' => time()
], ['id'=>(int)$post['id']]);
}
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
static::$error = $e->getMessage();
return false;
}
}
}

View file

@ -0,0 +1,143 @@
<?php
namespace app\admin\logic;
use app\common\logic\LogicBase;
use app\common\model\Distribution;
use app\common\model\DistributionOrder;
use app\common\model\DistributionOrderGoods;
use app\common\server\UrlServer;
class DistributionCenterLogic extends LogicBase
{
/**
* @notes 数据概览
* @return array
* @author Tab
*/
public static function center()
{
$data = [
'earnings' => self::earnings(),
'members' => self::members(),
'topGoods' => self::topGoods(),
'topMembers' => self::topMembers(),
];
return $data;
}
/**
* @notes 佣金数据
* @return array
* @author Tab
*/
public static function earnings()
{
// 累计已入账佣金
$totalSuccess = DistributionOrderGoods::where([
'status' => 2,
])->sum('money');
// 今日已入账佣金
$totalTodaySuccess = DistributionOrderGoods::where([
'status' => 2,
])->whereTime('settlement_time', 'd')->sum('money');
// 累计待结算佣金
$totalWait = DistributionOrderGoods::where([
'status' => 1,
])->sum('money');
// 今日待结算佣金
$totalTodayWait = DistributionOrderGoods::where([
'status' => 1,
])->whereTime('create_time', 'd')->sum('money');
return [
'total_success' => $totalSuccess,
'total_today_success' => $totalTodaySuccess,
'total_wait' => $totalWait,
'total_today_wait' => $totalTodayWait,
];
}
/**
* @notes 分销会员数据
* @author Tab
*/
public static function members()
{
$members = Distribution::where('is_distribution', 1)->count();
$users = Distribution::count();
$proportion = 0;
if ($users) {
$proportion = round(($members / $users), 2) * 100;
}
return [
'members' => $members,
'proportion' => $proportion,
];
}
/**
* @notes 分销商品排行榜
* @author Tab
*/
public static function topGoods()
{
$field = [
'sum(dog.money)' => 'total_money',
'g.image' => 'goods_image',
'og.goods_name',
];
$where = [
'dog.status' => 2, // 已入账
];
$topGoods = DistributionOrderGoods::alias('dog')
->leftJoin('order_goods og', 'og.id = dog.order_goods_id')
->leftJoin('goods g', 'g.id = og.goods_id')
->field($field)
->where($where)
->group('g.image,og.goods_name')
->order('total_money', 'desc')
->limit(10)
->select()
->toArray();
foreach ($topGoods as &$item) {
$item['goods_image'] = empty($item['goods_image']) ? '' : UrlServer::getFileUrl($item['goods_image']);
}
return $topGoods;
}
/**
* @notes 分销会员排行榜
* @return mixed
* @author Tab
*/
public static function topMembers()
{
$field = [
'sum(dog.money)' => 'total_money',
'u.avatar',
'u.nickname',
];
$where = [
'dog.status' => 2, // 已入账
];
$topMembers = DistributionOrderGoods::alias('dog')
->leftJoin('user u', 'u.id = dog.user_id')
->field($field)
->where($where)
->group('dog.money,u.avatar,u.nickname')
->order('total_money', 'desc')
->limit(10)
->select()
->toArray();
foreach($topMembers as &$item) {
$item['avatar'] = empty($item['avatar']) ? '' : UrlServer::getFileUrl($item['avatar']);
}
return $topMembers;
}
}

View file

@ -0,0 +1,295 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +------------------------------------------------------------------------
namespace app\admin\logic;
use app\api\model\Goods;
use app\common\logic\LogicBase;
use app\common\model\DistributionGoods;
use app\common\model\DistributionLevel;
use think\Db;
class DistributionGoodsLogic extends LogicBase
{
/**
* @notes 分销商品列表
* @param $params
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author Tab
*/
public static function lists($params)
{
$where = [
['del', '<>', '1'],
];
// 商品信息
if (isset($params['keyword']) && !empty($params['keyword'])) {
$where[] = ['name|code', 'like', '%'. $params['keyword']. '%'];
}
$field = [
'id',
'code',
'name',
'image',
'max_price',
'min_price',
'id' => 'distribution_flag',
];
$lists = Goods::field($field)
->where($where)
->withSearch(['is_distribution'], $params)
->page($params['page'], $params['limit'])
->order('id', 'desc')
->select()
->toArray();
$count = Goods::field($field)
->where($where)
->withSearch(['is_distribution'], $params)
->count();
return [
'count' => $count,
'lists' => $lists
];
}
/**
* @notes 商品详情
* @param $params
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author Tab
*/
public static function detail($params)
{
// 商品信息
$goods = Goods::field('id,code,name')->with('goods_item')->findOrEmpty($params['id'])->toArray();
// 分销等级信息
$distributionLevelLists = DistributionLevel::order('weights', 'asc')->select()->toArray();
// 商品分销信息
$distributionGoods = DistributionGoods::where('goods_id', $params['id'])->select()->toArray();
if(empty($distributionGoods)) {
// 未参与分销
$goods['is_distribution'] = 0;
$goods['rule'] = 1;
$ratio = self::formatLevel($distributionLevelLists, $goods);
} else {
$goods['is_distribution'] = $distributionGoods[0]['is_distribution'];
$goods['rule'] = $distributionGoods[0]['rule'];
if($distributionGoods[0]['rule'] == 1) {
$ratio = self::formatLevel($distributionLevelLists, $goods);
} else {
$ratio = self::formatGoods($distributionLevelLists, $goods);
}
}
return [
'goods' => $goods,
'ratio' => $ratio
];
}
/**
* @notes 拼装分销等级佣金比例
* @param $distributionLevelLists
* @param $goods
* @return array
* @author Tab
*/
public static function formatLevel($distributionLevelLists, $goods)
{
$ratio = [];
foreach($distributionLevelLists as $level) {
foreach($goods['goods_item'] as $item) {
$temp = [
'level_id' => $level['id'],
'level_name' => $level['name'],
'first_ratio' => $level['first_ratio'],
'second_ratio' => $level['second_ratio'],
'goods_id' => $item['goods_id'],
'item_id' => $item['id'],
'spec_value_str' => $item['spec_value_str'],
'price' => $item['price']
];
$ratio[] = $temp;
}
}
return $ratio;
}
/**
* @notes 拼装单独设置的佣金比例
* @param $distributionLevelLists
* @param $goods
* @param $distributionGoods
* @return array
* @author Tab
*/
public static function formatGoods($distributionLevelLists, $goods)
{
$ratio = [];
foreach($distributionLevelLists as $level) {
foreach($goods['goods_item'] as $item) {
$record = DistributionGoods::where([
'level_id' => $level['id'],
'item_id' => $item['id'],
])->findOrEmpty()->toArray();
$temp = [
'level_id' => $level['id'],
'level_name' => $level['name'],
'first_ratio' => $record['first_ratio'] ?? 0,
'second_ratio' => $record['second_ratio'] ?? 0,
'goods_id' => $item['goods_id'],
'item_id' => $item['id'],
'spec_value_str' => $item['spec_value_str'],
'price' => $item['price']
];
$ratio[] = $temp;
}
}
return $ratio;
}
/**
* @notes 设置佣金
* @param $params
* @return bool
* @author Tab
*/
public static function set($params)
{
Db::startTrans();
try {
switch($params['rule']) {
// 根据分销会员等级比例分佣
case 1:
self::setRuleOne($params);
break;
// 单独设置
case 2:
self::setRuleTwo($params);
break;
}
Db::commit();
return true;
}catch(\Exception $e) {
Db::rollback();
self::$error = $e->getMessage();
return false;
}
}
/**
* @notes 设置佣金 - 根据分销会员等级比例分佣
* @param $params
* @author Tab
*/
public static function setRuleOne($params)
{
// 删除旧数据
$deleteIds = DistributionGoods::where('goods_id', $params['id'])->column('id');
DistributionGoods::destroy($deleteIds);
// 生成新数据
$data = [
'goods_id' => $params['id'],
'is_distribution' => $params['is_distribution'],
'rule' => $params['rule'],
];
DistributionGoods::create($data);
}
/**
* @notes 设置佣金 - 单独自定义
* @param $params
* @throws \Exception
* @author Tab
*/
public static function setRuleTwo($params)
{
// 删除旧数据
$deleteIds = DistributionGoods::where('goods_id', $params['id'])->column('id');
DistributionGoods::destroy($deleteIds);
// 生成新数据
$data= [];
foreach($params['first_ratio'] as $k => $v) {
if ($params['first_ratio'][$k] < 0 || $params['second_ratio'][$k] < 0) {
throw new \Exception('分销比例不能小于0');
}
$temp = [
'goods_id' => $params['id'],
'item_id' => $params['items'][$k],
'level_id' => $params['levels'][$k],
'first_ratio' => !empty($params['first_ratio'][$k]) ? round($params['first_ratio'][$k], 2) : 0,
'second_ratio' => !empty($params['second_ratio'][$k]) ? round($params['second_ratio'][$k], 2) : 0,
'is_distribution' => $params['is_distribution'],
'rule' => $params['rule'],
];
$data[] = $temp;
}
(new DistributionGoods())->saveAll($data);
}
/**
* @notes 参与分销/取消分销
* @param $params
* @return bool
* @author Tab
*/
public static function isDistribution($params)
{
Db::startTrans();
try{
$existedIds = DistributionGoods::distinct(true)->column('goods_id');
$updateIds = array_intersect($params['ids'], $existedIds);
$insertIds = array_diff($params['ids'], $existedIds);
if (!empty($updateIds)) {
// 有分销数据,直接修改
DistributionGoods::where('goods_id', 'in', $updateIds)->update(['is_distribution' => $params['is_distribution']]);
}
// 无分销数据,新增
$insertData = [];
foreach($insertIds as $id) {
$item['goods_id'] = $id;
$item['is_distribution'] = $params['is_distribution'];
$item['rule'] = 1;
$insertData[] = $item;
}
(new DistributionGoods())->saveAll($insertData);
Db::commit();
return true;
}catch(\Exception $e) {
Db::rollback();
self::$error = $e->getMessage();
return false;
}
}
}

View file

@ -0,0 +1,493 @@
<?php
namespace app\admin\logic;
use app\common\logic\LogicBase;
use app\common\model\Distribution;
use app\common\model\DistributionGoods;
use app\common\model\DistributionLevel;
use app\common\model\DistributionLevelUpdate;
use app\common\model\DistributionOrderGoods;
use app\common\model\Order;
use think\Db;
class DistributionLevelLogic extends LogicBase
{
/**
* @notes 分销等级列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author Tab
*/
public static function index()
{
$field = [
'id',
'name',
'weights' => 'weights_desc',
'first_ratio',
'second_ratio',
'is_default',
'id' => 'members_num'
];
$lists = DistributionLevel::field($field)
->order('weights', 'asc')
->select()
->toArray();
$count = DistributionLevel::count();
return [
'count' => $count,
'lists' => $lists,
];
}
/**
* @notes 添加分销会员等级
* @param $params
* @return bool
* @author Tab
*/
public static function add($params)
{
Db::startTrans();
try{
// 写入等级主表
$params['remark'] = $params['remark'] ?? '';
$newLevel = DistributionLevel::create($params);
// 写入升级条件表
self::addUpdateCondition($params, $newLevel->id);
// 处理分销商品比例
self::updateDistributionGoods($newLevel->id);
Db::commit();
return true;
}catch(\Exception $e) {
Db::rollback();
self::$error = $e->getMessage();
return false;
}
}
/**
* @notes 添加更新升级条件
* @param $params
* @param $level_id
* @throws \Exception
* @author Tab
*/
public static function addUpdateCondition($params, $level_id)
{
$updateConditionData = [];
foreach($params['update_condition'] as $key) {
// 判断是否在规定的条件字段
if(!in_array($key, DistributionLevel::UPDATE_CONDITION_FIELDS, true)) {
continue;
}
if ($params[$key] < 0) {
throw new \Exception('升级条件不允许小于0');
}
// 获取键对应值的字段名
$valueField = DistributionLevel::getValueFiled($key);
$updateConditionData[] = [
'level_id' => $level_id,
'key' => $key,
$valueField => $params[$key]
];
}
(new DistributionLevelUpdate())->saveAll($updateConditionData);
}
/**
* @notes 获取分销等级详情
* @param $params
* @return array
* @author Tab
*/
public static function detail($params)
{
$level = DistributionLevel::findOrEmpty($params['id']);
if($level->isEmpty()) {
return [];
}
$level = $level->toArray();
// 默认等级
if($level['is_default']) {
unset($level['self_ratio']);
unset($level['third_ratio']);
unset($level['update_relation']);
return $level;
}
// 自定义等级
$level['update_condition'] = self::getUpdateCondition($level);
unset($level['self_ratio']);
unset($level['third_ratio']);
return $level;
}
/**
* @notes 获取升级条件
* @param $level
* @return array
* @author Tab
*/
public static function getUpdateCondition($level)
{
$updateCondition = DistributionLevelUpdate::where('level_id', $level['id'])->column('key,value_int,value_decimal,value_text');
$updateConditionData = [];
foreach($updateCondition as $item) {
if($item['value_int']) {
$updateConditionData[$item['key']] = $item['value_int'];
continue;
}
if($item['value_decimal']) {
$updateConditionData[$item['key']] = $item['value_decimal'];
continue;
}
if($item['value_text']) {
$updateConditionData[$item['key']] = $item['value_text'];
continue;
}
}
$data = [
'keys' => array_keys($updateConditionData),
'data' => $updateConditionData
];
// 补全条件
foreach(DistributionLevel::UPDATE_CONDITION_FIELDS as $field) {
if(!isset($data['data'][$field])) {
$data['data'][$field] = '';
}
}
return $data;
}
/**
* @notes 编辑分销等级
* @param $params
* @return bool
* @author Tab
*/
public static function edit($params)
{
Db::startTrans();
try{
$params['remark'] = $params['remark'] ?? '';
$level = DistributionLevel::findOrEmpty($params['id']);
if($level->isEmpty()) {
throw new \Exception('等级不存在');
}
// 佣金比例保留两位小数
$params['first_ratio'] = !empty($params['first_ratio']) ? round($params['first_ratio'], 2) : 0;
$params['second_ratio'] = !empty($params['second_ratio']) ? round($params['second_ratio'], 2) : 0;
// 默认等级
if($level->is_default) {
$level->allowField(['name', 'first_ratio', 'second_ratio','remark'])->save($params);
Db::commit();
return true;
}
// 自定义等级 - 更新主表信息
if(!$params['weights'] > 1) {
throw new \Exception('级别须大于1');
}
if(!isset($params['update_relation'])) {
throw new \Exception('请选择升级关系');
}
if(!isset($params['update_condition']) || !count($params['update_condition'])) {
throw new \Exception('请选择升级条件');
}
$level->allowField(['name', 'weights', 'first_ratio', 'second_ratio','remark', 'update_relation'])->save($params);
// 自定义等级 - 删除旧升级条件
$deleteIds = DistributionLevelUpdate::where('level_id', $level->id)->column('id');
DistributionLevelUpdate::destroy($deleteIds);
// 自定义等级 - 添加新的升级条件
self::addUpdateCondition($params, $level->id);
Db::commit();
return true;
}catch(\Exception $e) {
Db::rollback();
self::$error = $e->getMessage();
return false;
}
}
/**
* @notes 删除分销等级
* @param $params
* @return bool
* @author Tab
*/
public static function delete($params)
{
Db::startTrans();
try{
$level = DistributionLevel::findOrEmpty($params['id']);
if($level->isEmpty()) {
throw new \Exception('等级不存在');
}
if($level->is_default) {
throw new \Exception('系统默认等级不允许删除');
}
// 重置该等级下的分销会员为系统默认等级
$defaultId = DistributionLevel::where('is_default', 1)->value('id');
Distribution::where('level_id', $level->id)->update(['level_id' => $defaultId]);
// 删除升级条件
$deleteIds = DistributionLevelUpdate::where('level_id', $level->id)->column('id');
DistributionLevelUpdate::destroy($deleteIds);
// 删除该等级下的分销商品比例
$deleteIds = DistributionGoods::where('level_id', $level->id)->column('id');
DistributionGoods::destroy($deleteIds);
// 删除等级
$level->delete();
Db::commit();
return true;
}catch(\Exception $e) {
Db::rollback();
self::$error = $e->getMessage();
return false;
}
}
/**
* @notes 更新分销会员等级
* @param $userId
* @return false
* @author Tab
*/
public static function updateDistributionLevel($userId)
{
// 非默认等级
$levels = DistributionLevel::where('is_default', 0)
->order('weights', 'desc')
->column('id,name,weights,update_relation', 'id');
$userInfo = Distribution::alias('d')
->leftJoin('distribution_level dl', 'dl.id = d.level_id')
->field('d.is_distribution,d.level_id,dl.weights')
->where('d.user_id', $userId)
->findOrEmpty()
->toArray();
// 非分销会员直接返回false
if(empty($userInfo) || !$userInfo['is_distribution']) {
return false;
}
foreach($levels as $level) {
if(self::isMeetConditions($userId, $level) && $level['weights'] > $userInfo['weights']) {
// 满足升级条件且是升更高的等级
Distribution::where(['user_id' => $userId])->update(['level_id' => $level['id']]);
break;
}
}
}
/**
* @notes 判断是否满足当前等级的升级条件
* @param $userId
* @param $level
* @return bool
* @author Tab
*/
public static function isMeetConditions($userId, $level)
{
$updateRelation = $level['update_relation'];
// 任一条件满足升级
if($updateRelation == 1) {
$flagOr = self::singleConsumptionAmountFlag($userId, $level, $updateRelation)
|| self::cumulativeConsumptionAmountFlag($userId, $level, $updateRelation)
|| self::cumulativeConsumptionTimesFlag($userId, $level, $updateRelation)
|| self::returnedCommissionFlag($userId, $level, $updateRelation);
return $flagOr;
}
// 全部条件满足升级
if($updateRelation == 2) {
$flagAnd = self::singleConsumptionAmountFlag($userId, $level, $updateRelation)
&& self::cumulativeConsumptionAmountFlag($userId, $level, $updateRelation)
&& self::cumulativeConsumptionTimesFlag($userId, $level, $updateRelation)
&& self::returnedCommissionFlag($userId, $level, $updateRelation);
return $flagAnd;
}
}
/**
* @notes 判断是否满足单笔消费金额条件
* @param $userId
* @param $level
* @return bool
* @author Tab
*/
public static function singleConsumptionAmountFlag($userId, $level, $updateRelation)
{
$condition = DistributionLevelUpdate::field('value_int,value_decimal,value_text')
->where([
'level_id' => $level['id'],
'key' => 'singleConsumptionAmount'
])
->findOrEmpty();
if($condition->isEmpty()) {
// 等级条件为满足任一条件(updateRelation=1) 返回false (满足已设置的任一条件时才升级,未设置的条件归为未满足,返回false)
// 等级条件为满足全部条件(updateRelation=2) 返回true (满足已设置的所有条件时才升级,未设置的条件归为已满足,返回true)
return $updateRelation == 2;
}
$recentOrder = Order::where([
'user_id' => $userId,
'pay_status' => 1
])
->order('id', 'desc')
->findOrEmpty();
if($recentOrder->isEmpty()) {
return false;
}
if($recentOrder->order_amount >= $condition['value_decimal']) {
return true;
}
return false;
}
/**
* @notes 判断是否满足累计消费金额条件
* @param $userId
* @param $level
* @return bool
* @author Tab
*/
public static function cumulativeConsumptionAmountFlag($userId, $level, $updateRelation)
{
$condition = DistributionLevelUpdate::field('value_int,value_decimal,value_text')
->where([
'level_id' => $level['id'],
'key' => 'cumulativeConsumptionAmount'
])
->findOrEmpty();
if($condition->isEmpty()) {
// 等级条件为满足任一条件(updateRelation=1) 返回false (满足已设置的任一条件时才升级,未设置的条件归为未满足,返回false)
// 等级条件为满足全部条件(updateRelation=2) 返回true (满足已设置的所有条件时才升级,未设置的条件归为已满足,返回true)
return $updateRelation == 2;
}
$cumulativeConsumptionAmount = Order::where([
'user_id' => $userId,
'pay_status' => 1
])->sum('order_amount');
if($cumulativeConsumptionAmount >= $condition['value_decimal']) {
return true;
}
return false;
}
/**
* @notes 判断是否满足累计消费次数条件
* @param $userId
* @param $level
* @return bool
* @author Tab
*/
public static function cumulativeConsumptionTimesFlag($userId, $level, $updateRelation)
{
$condition = DistributionLevelUpdate::field('value_int,value_decimal,value_text')
->where([
'level_id' => $level['id'],
'key' => 'cumulativeConsumptionTimes'
])
->findOrEmpty();
if($condition->isEmpty()) {
// 等级条件为满足任一条件(updateRelation=1) 返回false (满足已设置的任一条件时才升级,未设置的条件归为未满足,返回false)
// 等级条件为满足全部条件(updateRelation=2) 返回true (满足已设置的所有条件时才升级,未设置的条件归为已满足,返回true)
return $updateRelation == 2;
}
$cumulativeConsumptionTimes = Order::where([
'user_id' => $userId,
'pay_status' => 1
])->count();
if($cumulativeConsumptionTimes >= $condition['value_int']) {
return true;
}
return false;
}
/**
* @notes 判断是否消费已返佣金条件
* @param $userId
* @param $level
* @return bool
* @author Tab
*/
public static function returnedCommissionFlag($userId, $level, $updateRelation)
{
$condition = DistributionLevelUpdate::field('value_int,value_decimal,value_text')
->where([
'level_id' => $level['id'],
'key' => 'returnedCommission'
])
->findOrEmpty();
if($condition->isEmpty()) {
// 等级条件为满足任一条件(updateRelation=1) 返回false (满足已设置的任一条件时才升级,未设置的条件归为未满足,返回false)
// 等级条件为满足全部条件(updateRelation=2) 返回true (满足已设置的所有条件时才升级,未设置的条件归为已满足,返回true)
return $updateRelation == 2;
}
$returnedCommission = DistributionOrderGoods::where([
'user_id' => $userId,
'status' => 2
])->sum('money');
if($returnedCommission >= $condition['value_decimal']) {
return true;
}
return false;
}
/**
* @notes 获取所有分销会员等级
* @return array
* @author Tab
*/
public static function getLevels()
{
return DistributionLevel::order('weights', 'asc')->column('id, name,weights');
}
/**
* @notes 更新分销商品比例
* @param $levelId
* @author Tab
*/
public static function updateDistributionGoods($levelId)
{
// 处理单独设置比例的商品,新增分销会等级佣金比例初始化为0
$field = [
'goods_id',
'item_id',
];
$distribution = DistributionGoods::distinct(true)->field($field)->where('rule', 2)->select()->toArray();
$addData = [];
foreach($distribution as $item) {
$temp = [
'goods_id' => $item['goods_id'],
'item_id' => $item['item_id'],
'level_id' => $levelId,
'first_ratio' => 0,
'second_ratio' => 0,
'rule' => 2,
];
$addData[] = $temp;
}
(new DistributionGoods())->saveAll($addData);
}
}

View file

@ -1,488 +1,213 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\logic;
use app\admin\model\DistributionMemberApply;
use app\admin\model\User;
use app\common\model\DistributionMember;
use app\common\model\DistributionOrder;
use app\common\model\Withdraw;
use app\common\logic\LogicBase;
use app\common\model\Distribution;
use app\common\model\DistributionOrderGoods;
use app\common\server\UrlServer;
use think\Db;
use think\Exception;
class DistributionMemberLogic
/**
* 分销会员逻辑层
* Class DistributionMemberLogic
* @package app\admin\logic\distribution
*/
class DistributionMemberLogic extends LogicBase
{
/**
* 分销会员列表
* @param $get
* @notes 分销会员列表
* @param $params
* @return array
* @author Tab
*/
public static function memberLists($get)
public static function lists($params)
{
$where = [];
$where[] = ['is_distribution', '=', 1];
if (!empty($get['search_key']) && !empty($get['keyword'])) {
$keyword = $get['keyword'];
if ($get['search_key'] == 'mobile') {
$where[] = ['mobile', 'like', '%' . $keyword . '%'];
} else {
$where[] = [$get['search_key'], 'like', '%' . $keyword . '%'];
}
$where = [
['d.is_distribution', '=', 1]
];
// 用户信息
if (isset($params['keyword']) && !empty($params['keyword'])) {
$where[] = ['u.sn|u.nickname', 'like', '%'. $params['keyword'] .'%'];
}
//分销状态
if (isset($get['freeze_distribution']) && $get['freeze_distribution'] != '') {
$where[] = ['freeze_distribution', '=', $get['freeze_distribution']];
// 分销等级
if (isset($params['level_id']) && $params['level_id'] != 'all') {
$where[] = ['d.level_id', '=', $params['level_id']];
}
$user = new User();
$count = $user->where($where)->count();
$lists = $user
->where($where)
->page($get['page'], $get['limit'])
->append(['fans', 'distribution_order'])
->hidden(['password,pay_password,salt'])
->order('id desc')
->select()->toArray();
$user_level = Db::name('user_level')->where(['del' => 0])->column('name', 'id');
$leader_ids = array_column($lists, 'first_leader');
$leaders = Db::name('user')
->where('id', 'in', $leader_ids)
->column('sn,nickname,mobile,level', 'id');
foreach ($lists as &$item) {
$item['level'] = $user_level[$item['level']] ?? '无等级';
$item['avatar'] = UrlServer::getFileUrl($item['avatar']);
$item['leader'] = $leaders[$item['first_leader']] ?? [];
if (!empty($item['leader'])) {
$leader_level = $item['leader']['level'] ?? 0;
$item['leader']['level'] = $user_level[$leader_level] ?? '无等级';
}
$item['distribution_num'] = $item['distribution_order']['num'] ?? 0;//分销订单数
$item['distribution_amount'] = $item['distribution_order']['amount'] ?? 0;//分销订单金额
$item['distribution_money'] = $item['distribution_order']['money'] ?? 0;//分销佣金
// 分销状态
if (isset($params['is_freeze']) && $params['is_freeze'] != 'all') {
$where[] = ['d.is_freeze', '=', $params['is_freeze']];
}
return ['count' => $count, 'lists' => $lists];
}
/**
* 分销会员审核列表
* @param $get
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function auditLists($get)
{
$where = [];
if (!empty($get['search_key']) && !empty($get['keyword'])) {
$keyword = $get['keyword'];
if ($get['search_key'] == 'mobile') {
$where[] = ['u.mobile', 'like', '%' . $keyword . '%'];
} else {
$where[] = [$get['search_key'], 'like', '%' . $keyword . '%'];
}
}
//审核状态
if (isset($get['status']) && $get['status'] != '') {
$where[] = ['status', '=', $get['status']];
}
$field = [
'a.*', 'u.sn', 'u.nickname', 'u.mobile', 'u.level', 'u.sex', 'a.reason',
'u.create_time' => 'register_time', 'u.avatar', 'u.first_leader'
'u.id' => 'user_id',
'u.sn' => 'user_sn',
'u.avatar',
'u.nickname',
'dl.id' => 'level_id',
'dl.weights',
'dl.name' => 'level_name',
'd.is_freeze',
'd.distribution_time',
];
$count = Db::name('distribution_member_apply a')
->join('user u', 'u.id = a.user_id')
->where($where)
->count();
$lists = Db::name('distribution_member_apply a')
$lists = Distribution::alias('d')
->leftJoin('user u', 'u.id = d.user_id')
->leftJoin('distribution_level dl', 'dl.id = d.level_id')
->field($field)
->join('user u', 'u.id = a.user_id')
->order('a.id desc')
->page($get['page'], $get['limit'])
->where($where)
->select();
->order('u.id', 'desc')
->page($params['page'], $params['limit'])
->select()
->toArray();
$user_level = Db::name('user_level')->where(['del' => 0])->column('name', 'id');
$count = Distribution::alias('d')
->leftJoin('user u', 'u.id = d.user_id')
->leftJoin('distribution_level dl', 'dl.id = d.level_id')
->field($field)
->where($where)
->count();
$leader_ids = array_column($lists, 'first_leader');
$leaders = Db::name('user')
->where('id', 'in', $leader_ids)
->column('sn,nickname,mobile,level', 'id');
foreach ($lists as &$item) {
$item['level'] = $user_level[$item['level']] ?? '无等级';
$item['sex'] = self::getSexText($item['sex']);
$item['register_time'] = date('Y-m-d H:i:s', $item['register_time']);
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
$item['status_text'] = DistributionMember::getApplyStatus($item['status']);
$item['leader'] = $leaders[$item['first_leader']] ?? [];
$item['avatar'] = UrlServer::getFileUrl($item['avatar']);
if (!empty($item['leader'])) {
$leader_level = $item['leader']['level'] ?? 0;
$item['leader']['level'] = $user_level[$leader_level] ?? '无等级';
}
foreach($lists as &$item) {
$item['avatar'] = empty($item['avatar']) ? '' : UrlServer::getFileUrl($item['avatar']);
$item['earnings'] = DistributionOrderGoods::getEarnings($item['user_id']);
}
return ['count' => $count, 'lists' => $lists];
return [
'count' => $count,
'lists' => $lists
];
}
public static function getSexText($value)
{
switch ($value) {
case 1:
return '男';
case 2:
return '女';
default:
return '未知';
}
}
/**
* 审核通过
* @param $post
* @return bool|string
* @notes 用户列表
* @param $params
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author Tab
*/
public static function auditPass($post)
public static function getUserLists($params)
{
$where[] = ['del', '=', 0];
// 用户信息
if (isset($params['keyword']) && !empty($params['keyword'])) {
$where[] = ['sn|nickname', 'like', '%'. $params['keyword'] .'%'];
}
$lists = \app\common\model\User::field('id,sn,nickname,id as distribution')
->where($where)
->withSearch(['distribution'], $params)
->page($params['page'], $params['limit'])
->select()
->toArray();
$count = \app\common\model\User::where($where)->withSearch(['distribution'], $params)->count();
return [
'count' => $count,
'lists' => $lists,
];
}
/**
* @notes 开通分销会员
* @param $params
* @return bool
* @author Tab
*/
public static function open($params)
{
Db::startTrans();
try {
$apply = DistributionMemberApply::where('id', $post['id'])->find();
$apply->status = DistributionMember::STATUS_AUDIT_SUCCESS;
$apply->update_time = time();
$apply->save();
$user = \app\admin\model\User::where('id', $apply['user_id'])->find();
$user->is_distribution = 1;
$user->save();
Db::commit();
return true;
} catch (Exception $e) {
Db::rollback();
return $e->getMessage();
}
}
/**
* 审核拒绝
* @param $post
*/
public static function auditRefuse($post)
{
$apply = DistributionMemberApply::where('id', $post['id'])->find();
$apply->status = DistributionMember::STATUS_AUDIT_ERROR;
$apply->save();
return true;
}
/**
* 冻结/解冻分销会员资格
* @param $post
*/
public static function freeze($post)
{
$user = User::where('id', $post['id'])->find();
$user->freeze_distribution = 1;
if ($post['type'] == 'unfreeze'){
$user->freeze_distribution = 0;
}
$user->save();
}
/**
* 分销会员信息
* @param $get
* @return User
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function getMemberInfo($get)
{
$user_id = $get['id'];
$user_model = new User();
$user = $user_model->alias('u')
->field('u.*,u.sn as user_sn')
->leftJoin('distribution_order_goods d', 'd.user_id = u.id')
->where('u.id', $user_id)
->append(['distribution_order'])
->hidden(['password', 'pay_password', 'salt'])
->find();
$user['distribution_text'] = '否';
if ($user['is_distribution'] == 1) {
$user['distribution_text'] = '是';
}
//上级编号
$user['first_leader_sn'] = Db::name('user')
->where('id', $user['first_leader'])
->value('sn');
//直推会员数
$user['first_fans'] = Db::name('user')
->where(['first_leader' => $user_id, 'del' => 0])
->count();
$have_withdraw = Db::name('withdraw_apply')
->where(['status' => Withdraw::STATUS_SUCCESS, 'user_id' => $user_id])
->sum('money');
$user['distribution_num'] = $user['distribution_order']['num'] ?? 0;//分销订单数
$user['distribution_amount'] = $user['distribution_order']['amount'] ?? 0;//分销订单金额
$user['distribution_money'] = $user['distribution_order']['money'] ?? 0;//分销佣金
$user['have_withdraw'] = $have_withdraw;//已提现金额
return $user;
}
/**
* 粉丝列表(推广会员)
* @param $get
* @return array
*/
public static function getFansLists($get)
{
$user_id = $get['id'];
$where = [];
if (!empty($get['search_key']) && !empty($get['keyword'])) {
$keyword = $get['keyword'];
$where[] = [$get['search_key'], 'like', '%' . $keyword . '%'];
}
$fans_type = $get['type'] ?? 'all';
if ($fans_type == 'all') {
$where[] = ['', 'exp', Db::raw("FIND_IN_SET($user_id, ancestor_relation)")];
} else {
$where[] = [$fans_type, '=', $user_id];
}
$user = new User();
$count = $user
->where($where)
->append(['fans', 'distribution_order'])
->hidden(['password,pay_password,salt'])
->count();
$lists = $user
->where($where)
->append(['fans', 'distribution_order'])
->hidden(['password,pay_password,salt'])
->page($get['page'], $get['limit'])
->select()->toArray();
$user_level = Db::name('user_level')->where(['del' => 0])->column('name', 'id');
$leader_ids = array_column($lists, 'first_leader');
$leaders = Db::name('user')
->where('id', 'in', $leader_ids)
->column('sn,nickname,mobile,level', 'id');
foreach ($lists as &$item) {
$item['avatar'] = UrlServer::getFileUrl($item['avatar']);
$item['leader'] = $leaders[$item['first_leader']] ?? [];
if (!empty($item['leader'])) {
$leader_level = $item['leader']['level'] ?? 0;
$item['leader']['level'] = $user_level[$leader_level] ?? '无等级';
$user = User::where('id', $params['user_id'])->findOrEmpty()->toArray();
if(empty($user)) {
throw new \Exception('用户不存在');
}
$item['distribution_num'] = $item['distribution_order']['num'] ?? 0;//分销订单数
$item['distribution_amount'] = $item['distribution_order']['amount'] ?? 0;//分销订单金额
$item['distribution_money'] = $item['distribution_order']['money'] ?? 0;//分销佣金
}
return ['count' => $count, 'lists' => $lists];
}
/**
* 分销收入明细
* @param $get
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function getEarningsDetail($get)
{
$user_id = $get['id'];
$where = [];
$where[] = ['d.user_id', '=', $user_id];
$where[] = ['d.status', '=', DistributionOrder::STATUS_SUCCESS];
//记录时间
if (isset($get['start_time']) && $get['start_time'] != '') {
$where[] = ['d.create_time', '>=', strtotime($get['start_time'])];
}
if (isset($get['end_time']) && $get['end_time'] != '') {
$where[] = ['d.create_time', '<=', strtotime($get['end_time'])];
}
$count = Db::name('distribution_order_goods')->alias('d')
->field('d.id as distribution_id, d.sn, o.order_sn, d.money, d.create_time')
->join('order_goods og', 'og.id = d.order_goods_id')
->join('order o', 'o.id = og.order_id')
->where($where)
->count();
$lists = Db::name('distribution_order_goods')->alias('d')
->field('d.id as distribution_id, d.sn, o.order_sn, d.money, d.create_time')
->join('order_goods og', 'og.id = d.order_goods_id')
->join('order o', 'o.id = og.order_id')
->where($where)
->page($get['page'], $get['limit'])
->select();
foreach ($lists as &$item) {
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
$item['type'] = '分销佣金';
}
return ['count' => $count, 'lists' => $lists];
}
/**
* 获取上级名称和编号
* @param $user_id
* @return string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public static function getLeaderInfo($user_id)
{
$first_leader = Db::name('user u')
->field('u1.nickname,u1.sn')
->join('user u1', 'u1.id = u.first_leader')
->where('u.id', $user_id)
->find();
$leader_data = '无';
if ($first_leader) {
$leader_data = $first_leader['nickname'] . '(' . $first_leader['sn'] . ')';
}
return $leader_data;
}
//更新关系
public static function updateRelation($post)
{
Db::startTrans();
try{
$user_id = $post['user_id'];//需要调整上级的user_id
$referrer_sn = $post['referrer_sn'];//新上级推荐人编号
//清空上级
$data = [
'first_leader' => 0,
'second_leader' => 0,
'third_leader' => 0,
'ancestor_relation' => '',
];
$my_leader_id = 0;
$my_first_leader = 0;
$my_ancestor_relation = '';
if ($post['change_type'] == 'appoint'){
//指定上级
$my_leader = Db::name('user')->where(['sn' => $referrer_sn])->find();
//更新我的第一上级、第二上级、第三上级、关系链
$my_leader_id = $my_leader['id'];
$my_first_leader = $my_leader['first_leader'];
$my_third_leader = $my_leader['second_leader'];
$my_ancestor_relation = trim("{$my_leader_id},{$my_leader['ancestor_relation']}", ',');
$distribution = Distribution::where('user_id', $params['user_id'])->findOrEmpty()->toArray();
if(!empty($distribution) && $distribution['is_distribution'] == 1) {
throw new \Exception('用户已是分销会员');
}
if(!empty($distribution) && $distribution['is_distribution'] == 0) {
Distribution::where('user_id', $params['user_id'])->update([
'is_distribution' => 1,
'distribution_time' => time()
]);
}
if(empty($distribution)) {
$data = [
'first_leader' => $my_leader_id,
'second_leader' => $my_first_leader,
'third_leader' => $my_third_leader,
'ancestor_relation' => $my_ancestor_relation,
'user_id' => $params['user_id'],
'level_id' => $params['level_id'],
'is_distribution' => 1,
'is_freeze' => 0,
'remark' => '后台开通分销',
'distribution_time' => time()
];
Distribution::create($data);
}
Db::name('user')->where(['id' => $user_id])->update($data);
//更新我向下一级的第二上级、第三上级
$data = [
'second_leader' => $my_leader_id,
'third_leader' => $my_first_leader,
];
Db::name('user')->where(['first_leader' => $user_id])->update($data);
//更新我向下二级的第三级
$data = [
'third_leader' => $my_leader_id,
];
Db::name('user')->where(['second_leader' => $user_id])->update($data);
//更新与我相关的所有关系链
Db::name('user')
->where("find_in_set({$user_id},ancestor_relation)")
->exp('ancestor_relation', "replace(ancestor_relation,'{$user_id}','" . trim("{$user_id},{$my_ancestor_relation}", ',') . "')")
->update();
Db::commit();
return true;
} catch (Exception $e){
Db::rollback();
return $e->getMessage();
} catch (\Exception $e) {
self::$error = $e->getMessage();
return false;
}
}
public static function getUser($params)
{
$field = [
'u.id' => 'user_id',
'u.sn' => 'user_sn',
'u.nickname' => 'user_nickname',
'dl.name' => 'level_name',
'dl.weights',
];
$info = Distribution::alias('d')
->leftJoin('user u', 'u.id = d.user_id')
->leftJoin('distribution_level dl', 'dl.id = d.level_id')
->field($field)
->where('d.user_id', $params['id'])
->findOrEmpty()
->toArray();
return $info;
}
/**
* @notes 分销会员等级调整
* @param $params
* @return bool
* @author Tab
*/
public static function adjust($params)
{
try {
Distribution::where(['user_id' => $params['user_id']])->update([
'level_id' => $params['level_id']
]);
return true;
} catch (\Exception $e) {
self::$error = $e->getMessage();
return false;
}
}
/**
* Notes: 添加分销会员
* @author 张无忌(2021/1/11 16:49)
* @param $post
* @return bool|string
* @notes 冻结资格/恢复资格
* @param $params
* @return bool
* @author Tab
*/
public static function addMember($post)
public static function isFreeze($params)
{
$userModel = new User();
// 根据会员编号查询用户
$user = $userModel->field('id,sn,is_distribution,distribution_add_remarks,del')
->where(['sn'=>$post['sn']])->find();
// 校验用户
if (!$user) { return '该用户不存在!'; }
if ($user['del'] === 1) { return '该用户已被删除!'; }
if ($user['is_distribution']) { return '该用户已是分销会员,无需重复添加'; }
try {
// 更新用户为分销会员
$result = $userModel->where(['id' => (int)$user['id']])->update([
'is_distribution' => 1,
'distribution_add_remarks' => $post['remarks']
Distribution::where(['user_id' => $params['user_id']])->update([
'is_freeze' => $params['is_freeze']
]);
return $result ? true : '添加失败';
} catch (\Exception $e) {
return $e->getMessage();
return true;
} catch(\Exception $e) {
self::$error = $e->getMessage();
return false;
}
}
}

View file

@ -0,0 +1,117 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +------------------------------------------------------------------------
namespace app\admin\logic;
use app\common\logic\LogicBase;
use app\common\model\DistributionLevel;
use app\common\model\DistributionOrderGoods;
use app\common\model\User;
use app\common\server\UrlServer;
class DistributionOrderGoodsLogic extends LogicBase
{
/**
* @notes 分销订单列表
* @param $params
* @return int[]
* @author Tab
*/
public static function lists($params)
{
$where = [];
// 订单信息
if (isset($params['order_keyword']) && !empty($params['order_keyword'])) {
$where[] = ['o.order_sn', '=', $params['order_keyword']];
}
// 商品名称
if (isset($params['goods_keyword']) && !empty($params['goods_keyword'])) {
$where[] = ['og.goods_name', 'like', '%'.$params['goods_keyword'].'%'];
}
// 分销会员
if (isset($params['distribution_keyword']) && !empty($params['distribution_keyword'])) {
$where[] = ['u.sn|u.nickname', 'like', '%'.$params['distribution_keyword'].'%'];
}
// 佣金状态
if (isset($params['status']) && !empty($params['status'])) {
$where[] = ['dog.status', '=', $params['status']];
}
$field = [
'o.id' => 'order_id',
'o.order_sn',
'o.create_time' => 'order_create_time',
'o.user_id' => 'order_user_id',
'u.id' => 'distribution_user_id',
'u.avatar' => 'distribution_avatar',
'u.sn' => 'distribution_sn',
'u.nickname' => 'distribution_nickname',
'g.image' => 'goods_image',
'g.name' => 'goods_name',
'gi.spec_value_str',
'og.goods_num' => 'goods_num',
'og.total_pay_price' => 'total_pay_price',
'dog.level_id',
'dog.level',
'dog.ratio',
'dog.money',
'dog.status' => 'status_desc',
'dog.settlement_time'
];
$lists = DistributionOrderGoods::alias('dog')
->leftJoin('order o', 'o.id = dog.order_id')
->leftJoin('user u', 'u.id = dog.user_id')
->leftJoin('order_goods og', 'og.id = dog.order_goods_id')
->leftJoin('goods g', 'g.id = og.goods_id')
->leftJoin('goods_item gi', 'gi.id = og.item_id')
->leftJoin('distribution_level dl', 'dl.id = dog.level_id')
->field($field)
->where($where)
->order('dog.id', 'desc')
->page($params['page'], $params['limit'])
->select()
->toArray();
$count = DistributionOrderGoods::alias('dog')
->leftJoin('order o', 'o.id = dog.order_id')
->leftJoin('user u', 'u.id = dog.user_id')
->leftJoin('order_goods og', 'og.id = dog.order_goods_id')
->leftJoin('goods g', 'g.id = og.goods_id')
->leftJoin('goods_item gi', 'gi.id = og.item_id')
->leftJoin('distribution_level dl', 'dl.id = dog.level_id')
->field($field)
->where($where)
->count();
foreach($lists as &$item) {
$item['order_create_time'] = date('Y-m-d H:i:s', $item['order_create_time']);
$item['user_info'] = User::getUserInfo($item['order_user_id']);
$item['distribution_avatar'] = empty($item['distribution_avatar']) ? '' : UrlServer::getFileUrl($item['distribution_avatar']);
$item['user_info']['avatar'] = empty($item['user_info']['avatar']) ? '' : UrlServer::getFileUrl($item['user_info']['avatar']);
$item['level_name'] = DistributionLevel::getLevelName($item['level_id']);
$item['goods_image'] = empty($item['goods_image']) ? '' : UrlServer::getFileUrl($item['goods_image']);
}
return [
'count' => $count,
'lists' => $lists
];
}
}

View file

@ -0,0 +1,81 @@
<?php
namespace app\admin\logic;
use app\admin\model\User;
use app\common\logic\DistributionLogic;
use app\common\logic\LogicBase;
use app\common\model\Distribution;
use app\common\server\ConfigServer;
use think\Db;
class DistributionSettingLogic extends LogicBase
{
public static function getConfig()
{
$config = [
// 分销功能 0-关闭(默认) 1-开启
'is_open' => ConfigServer::get('distribution', 'is_open', 0),
// 分销层级 1-一级分销 2-二级分销(默认)
'level' => ConfigServer::get('distribution', 'level', 2),
// 商品详情是否显示佣金 0-不显示(默认) 1-默认
'is_show_earnings' => ConfigServer::get('distribution', 'is_show_earnings', 0),
// 详情页佣金可见用户 0-全部用户 1-分销商
'show_earnings_scope' => ConfigServer::get('distribution', 'show_earnings_scope', 0),
// 开通分销会员条件 1-无条件 2-申请分销(默认) 3-指定分销
'apply_condition' => ConfigServer::get('distribution', 'apply_condition', 2),
// 佣金计算方式 1-商品实际支付金额(默认)
'cale_method' => ConfigServer::get('distribution', 'cale_method', 1),
// 结算时机 1-订单完成后(默认)
'settlement' => ConfigServer::get('distribution', 'settlement', 1),
// 结算时机 订单完成后多少天内(默认7天)
'settlement_days' => ConfigServer::get('distribution', 'settlement_days', 7),
];
return $config;
}
public static function set($params)
{
Db::startTrans();
try {
$allowFields = ['is_open', 'level', 'is_show_earnings', 'apply_condition', 'cale_method', 'settlement_days', 'show_earnings_scope'];
foreach ($allowFields as $field) {
if ($field == 'settlement_days' && isset($params[$field]) && $params[$field] < 0) {
throw new \Exception('不允许填写负数');
}
if(isset($params[$field])) {
ConfigServer::set('distribution', $field, $params[$field]);
}
if($field == 'apply_condition' && isset($params[$field]) && $params[$field] == 1) {
// 开通分销会员无条件时,所有会员均成为分销会员
self::distribution();
}
}
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::$error = $e->getMessage();
return false;
}
}
public static function distribution()
{
// 将非分销会员变为分销会员
Distribution::where('is_distribution', 0)->update([
'is_distribution' => 1
]);
// 获取所有分销会员id
$distributionIds = Distribution::distinct(true)->column('user_id');
// 查找未生成分销会员基础信息表的会员
$notDistributionIds = \app\common\model\User::where([
['id', 'not in', $distributionIds],
['del', '=', 0],
])->column('id');
foreach($notDistributionIds as $userId) {
// 生成分销会员基础信息表
DistributionLogic::add($userId);
}
}
}

View file

@ -32,9 +32,9 @@ class ExpressLogic
* 列表
* @param $get
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws @\think\db\exception\DataNotFoundException
* @throws @\think\db\exception\ModelNotFoundException
* @throws @\think\exception\DbException
*/
public static function lists($get)
{
@ -61,26 +61,33 @@ class ExpressLogic
return ['lists' => $lists, 'count' => $count];
}
/**
* @notes 获取所有快递公司
* @date 2021/9/26 10:40
*/
public static function all()
{
return Db::name('express')
->where(['del'=>0])
->select();
}
/**
* 添加
* @param $post
* @return array|\PDOStatement|string|\think\Model|null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @return array|string|null
*/
public static function addExpress($post)
{
$time = time();
$data = [
'name' => $post['name'],
'icon' => $post['icon'],
'website' => $post['website'],
'code' => $post['code'],
'code100' => $post['code100'],
'codebird' => $post['codebird'],
'sort' => $post['sort'],
'name' => $post['name'],
'icon' => $post['icon'],
'website' => $post['website'],
'code' => $post['code'],
'code100' => $post['code100'],
'codebird' => $post['codebird'],
'sort' => $post['sort'],
'create_time' => $time
];
$result = Db::name('express')->insert($data);
@ -90,10 +97,10 @@ class ExpressLogic
/**
* 获取信息
* @param $id
* @return array|\PDOStatement|string|\think\Model|null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @return array|string|null
* @throws @\think\db\exception\DataNotFoundException
* @throws @\think\db\exception\ModelNotFoundException
* @throws @\think\exception\DbException
*/
public static function info($id)
{
@ -108,18 +115,18 @@ class ExpressLogic
* @param $post
* @return int|string
* @throws Exception
* @throws \think\exception\PDOException
* @throws @\think\exception\PDOException
*/
public static function editExpress($post)
{
$data = [
'name' => $post['name'],
'icon' => $post['icon'],
'website' => $post['website'],
'code' => $post['code'],
'code100' => $post['code100'],
'codebird' => $post['codebird'],
'sort' => $post['sort'],
'name' => $post['name'],
'icon' => $post['icon'],
'website' => $post['website'],
'code' => $post['code'],
'code100' => $post['code100'],
'codebird' => $post['codebird'],
'sort' => $post['sort'],
'update_time' => time()
];
Db::name('express')->where(['id' => $post['id']])->update(['name' => $post['name'],]);

View file

@ -0,0 +1,147 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用,保留版权即可
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\admin\logic;
use app\common\model\FaceSheetTemplate;
use Exception;
use think\Db;
class FaceSheetLogic
{
/**
* @notes 获取电子面单模板列表
* @param $get
* @return array
* @author 张无忌
* @date 2021/9/26 11:46
*/
public static function lists($get)
{
$model = new FaceSheetTemplate();
$count = $model->count('id');
$lists = $model->order('id', 'desc')
->page($get['page'], $get['limit'])
->select();
foreach ($lists as &$item) {
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
$item['express'] = Db::name('express')->where(['id'=>$item['express_id']])->value('name') ?? '未知';
}
return ['count' => $count, 'lists' => $lists];
}
/**
* @notes 所有电子面单模板
* @author 张无忌
* @date 2021/9/27 15:40
*/
public static function all()
{
$model = new FaceSheetTemplate();
return $model->order('id', 'desc')->select();
}
/**
* @notes 获取电子面单模板详细
* @param $id
* @return FaceSheetTemplate
* @author 张无忌
* @date 2021/9/26 11:51
*/
public static function detail($id)
{
return FaceSheetTemplate::where(['id'=>intval($id)])->find();
}
/**
* @notes 新增电子面单模板
* @param $post
* @return bool|string
* @author 张无忌
* @date 2021/9/26 11:12
*/
public static function add($post)
{
try {
FaceSheetTemplate::create([
'express_id' => $post['express_id'],
'name' => $post['name'],
'tempid' => $post['tempid'],
'partner_id' => $post['partner_id'],
'partner_key' => $post['partner_key'],
'net' => $post['net'],
'pay_type' => $post['pay_type'],
'create_time' => time(),
'update_time' => time()
]);
return true;
} catch (Exception $e) {
return $e->getMessage();
}
}
/**
* @notes 编辑电子面单模板
* @param $post
* @return bool|string
* @author 张无忌
* @date 2021/9/26 11:49
*/
public static function edit($post)
{
try {
FaceSheetTemplate::update([
'express_id' => $post['express_id'],
'name' => $post['name'],
'tempid' => $post['tempid'],
'partner_id' => $post['partner_id'],
'partner_key' => $post['partner_key'],
'net' => $post['net'],
'pay_type' => $post['pay_type'],
'create_time' => time(),
'update_time' => time()
], ['id'=>$post['id']]);
return true;
} catch (Exception $e) {
return $e->getMessage();
}
}
/**
* @notes 删除电子面单模板
* @param $id
* @return string
* @author 张无忌
* @date 2021/9/28 15:38
*/
public static function del($id)
{
try {
FaceSheetTemplate::destroy(intval($id));
return true;
} catch (Exception $e) {
return $e->getMessage();
}
}
}

View file

@ -0,0 +1,308 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用,保留版权即可
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\admin\logic;
use app\common\logic\OrderLogLogic;
use app\common\model\NoticeSetting;
use app\common\model\Order;
use app\common\model\OrderGoods;
use app\common\model\OrderLog;
use app\common\model\TeamFound;
use app\common\model\User;
use app\common\model\FaceSheetSender;
use app\common\model\FaceSheetTemplate;
use app\common\model\Express;
use app\common\server\AreaServer;
use app\common\server\printing\Kuaidi100;
use app\common\server\UrlServer;
use Exception;
use think\Db;
use think\facade\Hook;
class FaceSheetOrderLogic
{
/**
* @notes 获取待发货订单列表
* @param $get
* @return array
* @author 张无忌
* @date 2021/9/27 11:53
*/
public static function lists($get)
{
$where = [
['O.order_status', '=', 1],
['O.pay_status', '=', 1],
['O.delivery_type', '=', 1],
// ['TF.status', '=', 0]
];
if (!empty($get['keyword_type']) and !empty($get['keyword'])) {
switch ($get['keyword_type']) {
case 'order_sn':
$where[] = ['O.order_sn', '=', $get['keyword']];
break;
case 'user_sn':
$where[] = ['U.sn', 'like', '%'.$get['keyword'].'%'];
break;
case 'nickname':
$where[] = ['U.nickname', 'like', '%'.$get['keyword'].'%'];
break;
case 'consignee':
$where[] = ['O.consignee', 'like', '%'.$get['keyword'].'%'];
break;
case 'consignee_mobile':
$where[] = ['O.consignee_mobile', '=', $get['keyword']];
break;
}
}
if (!empty($get['goods_name']) and $get['goods_name']) {
$where[] = ['OG.goods_name', 'like', '%'.$get['goods_name'].'%'];
}
if (!empty($get['start_time']) and $get['start_time']) {
$where[] = ['O.create_time', '>=', strtotime($get['start_time'])];
}
if (!empty($get['end_time']) and $get['end_time']) {
$where[] = ['O.create_time', '<=', strtotime($get['end_time'])];
}
$count = Order::where($where)->alias('O')
->join('user U', 'U.id = O.user_id')
->join('orderGoods OG', 'OG.order_id = O.id')
->leftJoin('team_found TF', 'TF.id = O.team_found_id')
->group('O.id')
->count('O.id');
$lists = Order::field(
'O.id,O.user_id,O.order_type,O.order_sn,O.order_status,O.total_num,O.order_amount,O.delivery_type,
O.consignee,O.mobile,O.province,O.city,O.district,O.address,O.create_time,TF.status as team_found_status'
)->alias('O')
->where($where)
->join('user U', 'U.id = O.user_id')
->join('orderGoods OG', 'OG.order_id = O.id')
->leftJoin('team_found TF', 'TF.id = O.team_found_id')
->group('O.id')
->order('O.id desc')
->page($get['page'], $get['limit'])
->select();
foreach ($lists as &$item) {
$user = User::field('nickname,sn')->where(['id'=>$item['user_id']])->find();
$item['user'] = $user['nickname'];
// $item['team_found_status'] = $item['team_found_status'] ? 1 : 0;
$item['order_type'] = Order::getOrderType($item['order_type']);
$item['order_status'] = Order::getOrderStatus($item['order_status']);
$item['delivery_type'] = Order::getDeliveryType($item['delivery_type']);
$item['address'] = AreaServer::getAddress([$item['province'], $item['city'], $item['district']], $item['address']);
$orderGoods = OrderGoods::field('id,goods_price,goods_num,goods_info')->where(['order_id'=>$item['id']])->select();
$orderGoodsData = [];
foreach ($orderGoods as $og) {
$info = json_decode($og['goods_info'], true);
$orderGoodsData[] = [
'id' => $og['id'],
'goods_price' => $og['goods_price'],
'goods_num' => $og['goods_num'],
'goods_name' => $info['goods_name'],
'spec_value_str' => $info['spec_value_str'],
'image' => $info['spec_image'] ? UrlServer::getFileUrl($info['spec_image']) : UrlServer::getFileUrl($info['image']),
];
}
$item['orderGoods'] = $orderGoodsData;
}
return ['count'=>$count, 'lists'=>$lists];
}
/**
* @notes 打印电子面单
* @param $order_id
* @param $tempid
* @param $sender_id
* @param $admin_id
* @return string
* @author 张无忌
* @date 2021/9/27 11:54
*/
public static function print($order_id, $tempid, $sender_id, $admin_id)
{
try {
// 查询出订单信息
$order = Order::field(true)->with(['orderGoods'])->where(['id' => intval($order_id)])->find();
if (!$order) {
throw new Exception('订单不存在');
}
if ($order['order_status'] != 1) {
throw new Exception('该订单不是待发货状态的订单');
}
if ($order['pay_status'] == 0) {
throw new Exception('该订单未支付');
}
if ($order['pay_status'] == 2) {
throw new Exception('该订单已退款');
}
// 拼团订单(未成功的订单)
if ($order['order_type'] == 2) {
$found = TeamFound::where(['id'=>$order['team_found_id']])->find();
if ($found['status'] != 1) {
throw new Exception('拼团未成功禁止打印:'.$order['order_sn']);
}
}
// 获取发件人模板
$sender = FaceSheetSender::where(['id'=>intval($sender_id)])->find();
if (!$sender) {
throw new Exception('未找到发件人模板信息');
}
// 获取电子面单模板
$template = FaceSheetTemplate::where(['id'=>intval($tempid)])->find();
if (!$template) {
throw new Exception('未找到电子面单模板信息');
}
// 获取快递公司
$express = Express::field('id,name,code100')->where(['id'=>$template['express_id']])->find();
if (!$template) {
throw new Exception('未找到快递公司信息');
}
$goodsName = '';
$totalWeight = 0;
foreach ($order['order_goods'] as $item) {
$goodsInfo = json_decode($item['goods_info'], true);
$goodsName .= $goodsInfo['goods_name'].' ('.$goodsInfo['spec_value_str'].$item['goods_num'].'件)\n';
$totalWeight = round($goodsInfo['weight']+$totalWeight,2);
}
// 打印电子面单
$result = (new Kuaidi100())->print([
'remark' => $goodsName ?? '',
'template' => [
'partnerId' => $template['partner_id'],
'partnerKey' => $template['partner_key'],
'payType' => $template['pay_type'],
'net' => $template['net'],
'tempid' => $template['tempid'],
'expressName' => $express['name'],
'expressCode' => $express['code100'],
],
'total_weight' => $totalWeight,
'recMan' => [
'name' => trim($order['consignee']),
'mobile' => trim($order['mobile']),
'printAddr' => AreaServer::getAddress([$order['province'], $order['city'], $order['district']], $order['address'])
],
'sendMan' => array(
'name' => $sender['name'],
'mobile' => $sender['mobile'],
'printAddr' => AreaServer::getAddress([$sender['province_id'], $sender['city_id'], $sender['district_id']], $sender['address']),
)
]);
// 更新信息状态为已发货
$delivery_id = Db::name('delivery')->insertGetId([
'order_id' => $order['id'],
'order_sn' => $order['order_sn'],
'user_id' => $order['user_id'],
'admin_id' => $admin_id,
'consignee' => $order['consignee'],
'mobile' => $order['mobile'],
'province' => $order['province'],
'city' => $order['city'],
'district' => $order['district'],
'address' => $order['address'],
'shipping_status' => 1,
'shipping_id' => $express['id'],
'shipping_name' => $express['name'],
'send_type' => 1,
'invoice_no' => $result['data']['kuaidinum'],
'create_time' => time()
]);
Order::update([
'order_status' => 2,
'shipping_status' => 1,
'delivery_id' => $delivery_id,
'shipping_time' => time(),
'update_time' => time(),
], ['id'=>$order['id']]);
//订单日志
OrderLogLogic::record(
OrderLog::TYPE_SHOP,
OrderLog::SHOP_DELIVERY_ORDER,
$order_id,
$admin_id,
OrderLog::SHOP_DELIVERY_ORDER
);
//发货短信通知
if($order['mobile']){
$nickname = Db::name('user')->where(['id' => $order['user_id']])->value('nickname');
$send_data = [
'key' => NoticeSetting::ORDER_DELIVERY_NOTICE,
'user_id' => $order['user_id'],
'mobile' => $order['mobile'],
'params' => [
'order_sn' => $order['order_sn'],
'nickname' => $nickname,
'time' => date('Y-m-d H:i:s'),
'invoice_no' => $result['data']['kuaidinum'],
'shipping_name' => $express['name'],
'goods_name' => omit_str($order['order_goods'][0]['goods_name'] ?? '商品', 8)
],
];
Hook::listen('sms_send', $send_data);
}
// 赠送成长值和积分
Hook::listen('give_reward', [
'order_id' => $order['id'],
'scene' => 2, //2=发货场景
]);
// 发货模板消息
Hook::listen('notice', [
'user_id' => $order['user_id'],
'order_id' => $order['id'],
'scene' => NoticeSetting::ORDER_DELIVERY_NOTICE,
'shipping_name' => $express['name'],
'invoice_no' => $result['data']['kuaidinum'],
'time' => date('Y-m-d H:i:s')
]);
return true;
} catch (Exception $e) {
return $e->getMessage();
}
}
}

View file

@ -0,0 +1,148 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用,保留版权即可
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\admin\logic;
use app\common\model\FaceSheetSender;
use app\common\server\AreaServer;
use Exception;
class FaceSheetSenderLogic
{
/**
* @notes 获取发件人列表
* @param $get
* @return array
* @author 张无忌
* @date 2021/9/26 15:49
*/
public static function lists($get)
{
$model = new FaceSheetSender();
$count = $model->count('id');
$lists = $model->order('id', 'desc')
->page($get['page'], $get['limit'])
->select();
foreach ($lists as &$item) {
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
$item['region'] = AreaServer::getAddress([
$item['province_id'],
$item['city_id'],
$item['district_id'],
]);
}
return ['count' => $count, 'lists' => $lists];
}
/**
* @notes 所有发件人模板
* @author 张无忌
* @date 2021/9/27 15:40
*/
public static function all()
{
$model = new FaceSheetSender();
return $model->order('id', 'desc')->select();
}
/**
* @notes 获取发件人模板详细
* @param $id
* @return FaceSheetSender
* @author 张无忌
* @date 2021/9/26 15:51
*/
public static function detail($id)
{
return FaceSheetSender::where(['id'=>$id])->find();
}
/**
* @notes 新增发件人模板
* @param $post
* @return bool|string
* @author 张无忌
* @date 2021/9/26 15:18
*/
public static function add($post)
{
try {
FaceSheetSender::create([
'name' => $post['name'],
'mobile' => $post['mobile'],
'province_id' => $post['province_id'],
'city_id' => $post['city_id'],
'district_id' => $post['district_id'],
'address' => $post['address'],
'create_time' => time(),
'update_time' => time(),
]);
return true;
} catch (Exception $e) {
return $e->getMessage();
}
}
/**
* @notes 编辑发件人模板
* @param $post
* @return bool|string
* @author 张无忌
* @date 2021/9/26 15:23
*/
public static function edit($post)
{
try {
FaceSheetSender::update([
'name' => $post['name'],
'mobile' => $post['mobile'],
'province_id' => $post['province_id'],
'city_id' => $post['city_id'],
'district_id' => $post['district_id'],
'address' => $post['address'],
'update_time' => time(),
], ['id'=>$post['id']]);
return true;
} catch (Exception $e) {
return $e->getMessage();
}
}
/**
* @notes 删除发件人模板
* @param $id
* @return bool|string
* @author 张无忌
* @date 2021/9/26 15:45
*/
public static function del($id)
{
try {
FaceSheetSender::destroy($id);
return true;
} catch (Exception $e) {
return $e->getMessage();
}
}
}

View file

@ -1,4 +1,22 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\logic;
use app\common\model\FileCate;

View file

@ -63,10 +63,19 @@ class GoodsCommentLogic{
$where[] = ['gc.create_time','<=',strtotime($get['end_time'])];
}
// 评价类型-虚拟评价/真实评价
if (isset($get['comment_type']) && $get['comment_type'] != '') {
if ($get['comment_type'] == 1) {
$where[] = ['virtual_data', 'null', ''];
} else {
$where[] = ['virtual_data', 'not null', ''];
}
}
$res = Db::name('goods_comment gc')
->join('goods g','g.id = gc.goods_id')
->leftjoin('goods_item gi','gi.id = gc.item_id')
->join('user u','u.id = gc.user_id')
->leftjoin('user u','u.id = gc.user_id')
->where('gc.del',0)
->where($where)
->withAttr('comment_image', function ($value, $data){
@ -80,7 +89,7 @@ class GoodsCommentLogic{
})
->field('u.id as user_id,u.nickname,u.mobile,u.sex,u.create_time,g.name,gi.spec_value_str
,gc.goods_comment,gc.comment,gc.create_time as comment_time,gc.status,u.avatar,g.image,gc.reply,u.sn,u.level
,gc.id')
,gc.id,gc.virtual_data')
->order('gc.create_time','desc')
->append(['comment_image']);
$count = $res->count();
@ -92,6 +101,19 @@ class GoodsCommentLogic{
foreach ($lists as &$item){
$item['comment_type'] = '真实评价';
// 虚拟评论
if (empty($item['user_id']) && !empty($item['virtual_data'])) {
$virtual_data = json_decode($item['virtual_data'], JSON_UNESCAPED_UNICODE);
$item['sn'] = $virtual_data['sn'] ?? '';
$item['nickname'] = $virtual_data['nickname'] ?? '';
$item['level'] = $virtual_data['level'] ?? '';
$item['avatar'] = $virtual_data['avatar'] ?? '';
$item['create_time'] = $virtual_data['comment_time'] ?? time();
$item['comment_type'] = '虚拟评价';
}
$item['level_name'] = $user_level[$item['level']] ?? '无等级';
switch($item['sex']){
case 0:
@ -103,7 +125,6 @@ class GoodsCommentLogic{
case 2:
$item['sex'] ='女';
break;
}
if($item['goods_comment'] > 3){

View file

@ -18,12 +18,18 @@
// +----------------------------------------------------------------------
namespace app\admin\logic;
use app\common\model\DistributionGoods;
use app\common\model\GoodsItem;
use app\common\server\UrlServer;
use think\Db;
use think\Exception;
use think\facade\Hook;
class GoodsLogic
{
public static $error = '';
/*
* 商品统计
*/
@ -70,6 +76,26 @@ class GoodsLogic
break;
}
}
$activity_goods = self::activityGoods();
$seckill_goods = $activity_goods['seckill_goods'];
$team_goods = $activity_goods['team_goods'];
$bargain_goods = $activity_goods['bargain_goods'];
if(isset($get['goods_type']) && $get['goods_type']){
switch ($get['goods_type']){
case 1:
$where[] = ['id','not in',$activity_goods['activity_goods']];
break;
case 2:
$where[] = ['id','in',$seckill_goods];
break;
case 3:
$where[] = ['id','in',$team_goods];
break;
case 4:
$where[] = ['id','in',$bargain_goods];
break;
}
}
if (isset($get['keyword']) && $get['keyword']) {
$where[] = ['name', 'like', '%' . $get['keyword'] . '%'];
@ -83,6 +109,11 @@ class GoodsLogic
if(isset($get['category_id']) && $get['category_id']){
$where[] = ['first_category_id|second_category_id|third_category_id','=',$get['category_id']];
}
if(isset($get['delivery_type']) && $get['delivery_type'] == 1){
$where[] = ['is_express','=',1];
}elseif (isset($get['delivery_type']) && $get['delivery_type'] == 2) {
$where[] = ['is_selffetch','=',1];
}
$goods_count = Db::name('goods')
->where($where)
@ -123,6 +154,15 @@ class GoodsLogic
if($item['shareholder_ratio'] > 0) $item['shareholder_ratio_desc'] = $item['shareholder_ratio'] /100 .'%';
$item['image'] = UrlServer::getFileUrl($item['image']);
$item['attribute'] = '普通商品';
if(in_array($item['id'],$seckill_goods)){
$item['attribute'] = '秒杀商品';
}elseif (in_array($item['id'],$team_goods)){
$item['attribute'] = '拼团商品';
}elseif (in_array($item['id'],$bargain_goods)){
$item['attribute'] = '砍价商品';
}
}
return ['count' => $goods_count, 'list' => $goods_list];
@ -175,20 +215,17 @@ class GoodsLogic
$goods_category_list = Db::name('goods_category')->where(['del'=>0])->column('name','id');
$exportTitle = ['商品名称', '商品分类', '是否开启分销', '一级佣金比例', '二级佣金比例', '三级佣金比例', 'SKU最低价', 'SKU最高价', '总库存', '总销量', '新品推荐', '好物优选', '猜你喜欢', '排序', '发布时间'];
$exportTitle = ['商品名称', '商品分类', '是否开启分销', 'SKU最低价', 'SKU最高价', '总库存', '总销量', '新品推荐', '好物优选', '猜你喜欢', '排序', '发布时间'];
$exportExt = 'xls';
$exportData = [];
foreach($goods_list_export as $item) {
$cateName = self::getCateName($goods_category_list, $item); // 商品分类
$isCommission = $item['is_commission'] ? '开启' : '关闭';
$firstRatio = $item['first_ratio'] > 0 ? $item['first_ratio'].'%' : 0;
$secondRatio = $item['second_ratio'] > 0 ? $item['second_ratio'].'%' : 0;
$threeRatio = $item['three_ratio'] > 0 ? $item['three_ratio'].'%' : 0;
$isNew = $item['is_new'] ? '是' : '否';
$isBest = $item['is_best'] ? '是' : '否';
$isLike = $item['is_like'] ? '是' : '否';
$createTime = date('Y-m-d H:i:s',$item['create_time']);
$exportData[] = [$item['name'], $cateName, $isCommission, $firstRatio, $secondRatio, $threeRatio, $item['min_price'], $item['max_price'], $item['stock'], $item['total_sales_sum'], $isNew, $isBest, $isLike, $item['sort'], $createTime];
$exportData[] = [$item['name'], $cateName, $isCommission, $item['min_price'], $item['max_price'], $item['stock'], $item['total_sales_sum'], $isNew, $isBest, $isLike, $item['sort'], $createTime];
}
return ['exportTitle'=> $exportTitle, 'exportData' => $exportData, 'exportExt'=>$exportExt, 'exportName'=>'商品列表'.date('Y-m-d H:i:s')];
@ -199,12 +236,21 @@ class GoodsLogic
*/
public static function del($id)
{
try {
$data = [
'del' => 1,
'update_time' => time()
];
Db::name('goods')->where(['del' => 0, 'id' => $id])->update($data);
$data = [
'del' => 1,
'update_time' => time()
];
return Db::name('goods')->where(['del' => 0, 'id' => $id])->update($data);
// 下架或删除商品,更新商品收藏
Hook::listen('update_collect', ['goods_id' => $id]);
return true;
} catch (Exception $e) {
return $e->getMessage();
}
}
/**
* 添加商品
@ -228,7 +274,8 @@ class GoodsLogic
} else {
$max_price = max($post['price']);
$min_price = min($post['price']);
$market_price = max($post['market_price']);
$min_price_key = array_search($min_price,$post['price']);
$market_price = $post['market_price'][$min_price_key];
$total_stock = array_sum($post['stock']);
}
$free_shipping = $post['free_shipping_type'] == 2 ? $post['free_shipping']: '';
@ -273,27 +320,23 @@ class GoodsLogic
'stock' => $total_stock,
'status' => $post['status'],
'virtual_sales_sum' => $post['virtual_sales_sum'],
'virtual_click' => $post['virtual_click'] ?? 0,
'stock_warn' => $post['stock_warn'],
'is_show_stock' => $post['is_show_stock'],
'free_shipping_type' => $post['free_shipping_type'],
'free_shipping' => $free_shipping,
'free_shipping_template_id' => $free_shipping_template_id,
'is_commission' => $post['is_commission'],
'first_ratio' => $post['first_ratio'],
'second_ratio' => $post['second_ratio'],
'three_ratio' => $post['three_ratio'],
'is_new' => isset($post['is_new']) && $post['is_new'] == 'on' ? 1 : 0,
'is_best' => isset($post['is_best']) && $post['is_best'] == 'on' ? 1 : 0,
'is_like' => isset($post['is_like']) && $post['is_like'] == 'on' ? 1 : 0,
// 'is_share_bouns' => $post['is_share_bouns'],
// 'region_ratio' => $post['region_ratio'],
// 'shareholder_ratio' => $post['shareholder_ratio'],
'is_integral' => $post['is_integral'],
'is_member' => $post['is_member'],
'give_integral_type' => $give_integral_type,
'give_integral' => $give_integral,
'spec_type' => $post['spec_type'],
'create_time' => $time
'create_time' => $time,
'is_express' => isset($post['is_express']) && $post['is_express'] == 'on' ? 1 : 0,
'is_selffetch' => isset($post['is_selffetch']) && $post['is_selffetch'] == 'on' ? 1 : 0,
];
$goods_id = Db::name('goods')->insertGetId($data);
@ -405,6 +448,9 @@ class GoodsLogic
try {
Db::startTrans();
$oldItemIds = GoodsItem::where('goods_id', $post['id'])->column('id');
$time = time();
//算出最大最小价格
@ -414,13 +460,14 @@ class GoodsLogic
$market_price = $post['one_market_price'];
$total_stock = $post['one_stock'];
} else {
$max_price = max($post['price']);
$min_price = min($post['price']);
$market_price = max($post['market_price']);
$min_price_key = array_search($min_price,$post['price']);
$market_price = $post['market_price'][$min_price_key];
$total_stock = array_sum($post['stock']);
}
$free_shipping = $post['free_shipping_type'] == 2 ? $post['free_shipping']: '';
$free_shipping_template_id = $post['free_shipping_type'] == 3 ? $post['free_shipping_template_id']: '';
@ -467,33 +514,34 @@ class GoodsLogic
'stock' => $total_stock,
'status' => $post['status'],
'virtual_sales_sum' => $post['virtual_sales_sum'],
'virtual_click' => $post['virtual_click'] ?? 0,
'stock_warn' => $post['stock_warn'],
'is_show_stock' => $post['is_show_stock'],
'free_shipping_type' => $post['free_shipping_type'],
'free_shipping' => $free_shipping,
'free_shipping_template_id' => $free_shipping_template_id,
'is_commission' => $post['is_commission'],
'first_ratio' => $post['first_ratio'],
'second_ratio' => $post['second_ratio'],
'three_ratio' => $post['three_ratio'],
'is_new' => isset($post['is_new']) && $post['is_new'] == 'on' ? 1 : 0,
'is_best' => isset($post['is_best']) && $post['is_best'] == 'on' ? 1 : 0,
'is_like' => isset($post['is_like']) && $post['is_like'] == 'on' ? 1 : 0,
// 'is_share_bouns' => $post['is_share_bouns'],
// 'region_ratio' => $post['region_ratio'],
// 'shareholder_ratio' => $post['shareholder_ratio'],
'is_integral' => $post['is_integral'],
'is_member' => $post['is_member'],
'give_integral_type' => $give_integral_type,
'give_integral' => $give_integral,
'spec_type' => $post['spec_type'],
'update_time' => $time
'update_time' => $time,
'is_express' => isset($post['is_express']) && $post['is_express'] == 'on' ? 1 : 0,
'is_selffetch' => isset($post['is_selffetch']) && $post['is_selffetch'] == 'on' ? 1 : 0,
];
Db::name('goods')
->where(['id' => $post['goods_id']])
->update($data);
// 下架或删除商品,更新商品收藏
if ($data['status'] != 1) {
Hook::listen('update_collect', ['goods_id' => $post['goods_id']]);
}
//重新更新图片表
Db::name('goods_image')
->where(['goods_id' => $post['goods_id']])
@ -506,6 +554,7 @@ class GoodsLogic
];
}
Db::name('goods_image')->insertAll($data);
//写入规格表
if ($post['spec_type'] == 1) {
@ -549,6 +598,7 @@ class GoodsLogic
'spec_value_ids' => $goods_spec_value_id,
'spec_value_str' => '默认',
'market_price' => $post['one_market_price'],
'cost_price' => $post['one_cost_price'],
'price' => $post['one_price'],
'stock' => $post['one_stock'],
'volume' => $post['one_volume'],
@ -678,6 +728,16 @@ class GoodsLogic
->delete();
}
}
$newItemIds = GoodsItem::where('goods_id', $post['id'])->column('id');
$destroyIds = DistributionGoods::where('goods_id', $post['goods_id'])->column('id');
// 删除原来的分销设置
if ($oldItemIds != $newItemIds && $destroyIds) {
DistributionGoods::destroy($destroyIds);
self::$error = '商品信息修改成功,该商品属于分销商品,请重新设置分销信息';
}
Db::commit();
return true;
} catch (Exception $e) {
@ -767,10 +827,10 @@ class GoodsLogic
try {
if ($type == 0) {
$res = Db::name('team_activity')->whereIn('goods_id', $ids)
->where(['status' => 1])->find();
if ($res) {
return '该商品正在参与拼团,请先关闭后才允许下架';
$activity_goods = GoodsLogic::activityGoods()['activity_goods'];
$diff_goods = array_diff($activity_goods,$ids);
if($activity_goods != $diff_goods){
return '该商品正在参与活动,请先关闭后才允许下架';
}
}
@ -778,6 +838,10 @@ class GoodsLogic
'status' => $type,
'update_time' => time()
]);
// 下架或删除商品,更新商品收藏
Hook::listen('update_collect', ['goods_id' => $ids]);
return $result ? true : '上架失败';
} catch (\Exception $e) {
return '上架失败';
@ -808,4 +872,37 @@ class GoodsLogic
return '';
}
/**
* @notes 获取有活动中商品
* @return array
* @author cjhao
* @date 2022/1/19 9:52
*/
public static function activityGoods(){
//秒杀验证
$seckill_goods = Db::name('seckill_goods')
->where(['del'=>0])
->column('goods_id');
//拼团活动验证
$team_goods = Db::name('team_activity')
->where(['del'=>0])
->column('goods_id');
// 砍价活动验证
$bargain_goods = Db::name('bargain')
->where(['del'=>0])
->column('goods_id');
$activity_goods = array_merge($seckill_goods,$team_goods,$bargain_goods);
return [
'activity_goods' => $activity_goods,
'seckill_goods' => $seckill_goods,
'team_goods' => $team_goods,
'bargain_goods' => $bargain_goods,
];
}
}

View file

@ -0,0 +1,95 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\logic;
use app\common\server\ConfigServer;
use think\facade\Env;
/**
* H5商城逻辑层
* Class Hfive
* @package app\admin\logic
*/
class Hfive
{
/**
* @notes 获取H5商城设置
* @return array
* @author Tab
* @date 2021/8/14 14:56
*/
public static function getConfig()
{
$config = [
'is_open' => ConfigServer::get('h5', 'is_open', 1),
'page' => ConfigServer::get('h5', 'page', 1),
'page_url' => ConfigServer::get('h5', 'page_url', ''),
'h5_url' => request()->domain() . '/mobile'
];
return $config;
}
/**
* @notes H5商城设置
* @param $params
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
* @author Tab
* @date 2021/8/14 14:57
*/
public static function set($params)
{
ConfigServer::set('h5', 'is_open', $params['is_open']);
ConfigServer::set('h5', 'page', $params['page']);
ConfigServer::set('h5', 'page_url', $params['page_url']);
// 恢复原入口
if(file_exists('./mobile/index_lock.html')) {
// 存在则原商城入口被修改过,先清除修改后的入口
unlink('./mobile/index.html');
// 恢复原入口
rename('./mobile/index_lock.html', './mobile/index.html');
}
// H5商城关闭 且 显示空白页
if($params['is_open'] == 0 && $params['page'] == 1) {
// 变更文件名
rename('./mobile/index.html', './mobile/index_lock.html');
// 创建新空白文件
$newfile = fopen('./mobile/index.html', 'w');
fclose($newfile);
}
// H5商城关闭 且 跳转指定页
if($params['is_open'] == 0 && $params['page'] == 2 && !empty($params['page_url'])) {
// 变更文件名
rename('./mobile/index.html', './mobile/index_lock.html');
// 创建重定向文件
$newfile = fopen('./mobile/index.html', 'w');
$content = '<script>window.location.href = "' . $params['page_url'] . '";</script>';
fwrite($newfile, $content);
fclose($newfile);
}
}
}

View file

@ -1,5 +1,21 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\logic;

View file

@ -0,0 +1,247 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用,保留版权即可
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\admin\logic;
use app\common\model\LiveGoods;
use app\common\server\UrlServer;
use app\common\server\WeChatServer;
use EasyWeChat\Factory;
use Exception;
use think\facade\Cache;
/**
* 直播商品逻辑层
* Class LiveGoodsLogic
* @package app\admin\logic
*/
class LiveGoodsLogic
{
/**
* @notes 获取直播商品列表
* @param $get
* @return array|string
* @throws \EasyWeChat\Kernel\Exceptions\HttpException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws \Psr\SimpleCache\InvalidArgumentException
* @author heshihu
* @date 2021/9/17 11:43
*/
public static function Lists($get)
{
try {
$config = WeChatServer::getMnpConfig();
$app = Factory::miniProgram($config);
$access_token = $app->access_token->getToken()['access_token'];
$goods_url = '&status=' . $get['type'] . '&limit=' . $get['limit'] . '&offset=' . ($get['page'] - 1);
$url = 'https://api.weixin.qq.com/wxaapi/broadcast/goods/getapproved?access_token=' . $access_token . $goods_url;
$result = curl_get($url);
$result = json_decode($result, true);
if ($result['errcode'] != 0) {
return ['count' => 0, 'lists' => []];
}
$goodsStatus = [0 => '未审核', 1 => '审核中', 2 => '审核通过', 3 => '审核驳回'];
foreach ($result['goods'] as &$goods) {
// 获取商品信息
$goods['goods_status_desc'] = $goodsStatus[$get['type']];
}
return ['count' => $result['total'], 'lists' => $result['goods']];
}catch (Exception $e){
return $e->getMessage();
}
}
/**
* @notes 添加直播商品
* @param $post
* @return bool|string
* @throws \EasyWeChat\Kernel\Exceptions\HttpException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws \Psr\SimpleCache\InvalidArgumentException
* @author heshihu
* @date 2021/9/17 15:28
*/
public static function add($post)
{
$config = WeChatServer::getMnpConfig();
$app = Factory::miniProgram($config);
$access_token = $app->access_token->getToken()['access_token'];
$price = 0;
$price2 = 0;
switch ($post['use_price_type']) {
case 1:
$price = $post['price'];
break;
case 2:
$price = $post['section_price_start'];
$price2 = $post['section_price_end'];
break;
case 3:
$price = $post['discount_price_start'];
$price2 = $post['discount_price_end'];
break;
}
$data['goodsInfo'] = [
'coverImgUrl' => $post['feedsImg'],
'name' => $post['goods_name'],
'priceType' => $post['use_price_type'],
'price' => $price,
'price2' => $price2,
'url' => $post['url'],
];
$url = 'https://api.weixin.qq.com/wxaapi/broadcast/goods/add?access_token=' . $access_token;
$result = curl_post($url, $data);
$result = json_decode($result, true);
if ($result['errcode'] != 0) {
return self::getLiveGoodsError($result['errcode'], $result['errmsg']);
}
return true;
}
/**
* @notes 删除商品
* @param $id
* @return bool|string
* @throws \EasyWeChat\Kernel\Exceptions\HttpException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws \Psr\SimpleCache\InvalidArgumentException
* @author heshihu
* @date 2021/9/17 18:39
*/
public static function del($id)
{
$config = WeChatServer::getMnpConfig();
$app = Factory::miniProgram($config);
$access_token = $app->access_token->getToken()['access_token'];
$url = 'https://api.weixin.qq.com/wxaapi/broadcast/goods/delete?access_token=' . $access_token;
$result = curl_post($url, ['goodsId' => intval($id)]);
$result = json_decode($result, true);
if ($result['errcode'] != 0) {
return self::getLiveGoodsError($result['errcode'], $result['errmsg']);
}
return true;
}
/**
* @notes 获取商品的信息与审核状态
* @param $goods_ids
* @return mixed|string
* @throws \EasyWeChat\Kernel\Exceptions\HttpException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws \Psr\SimpleCache\InvalidArgumentException
* @author heshihu
* @date 2021/9/17 17:42
*/
// public static function goodsInfo($goods_ids)
// {
// $config = WeChatServer::getMnpConfig();
// $app = Factory::miniProgram($config);
// $access_token = $app->access_token->getToken(true)['access_token'];
//
// $url = 'https://api.weixin.qq.com/wxa/business/getgoodswarehouse?access_token=' . $access_token;
// $result = curl_post($url, ['goods_ids' => $goods_ids]);
// $result = json_decode($result, true);
// if ($result['errcode'] != 0) {
// return '';
// }
// return $result;
// }
public static function addUploadImage($goods_image)
{
try {
$config = WeChatServer::getMnpConfig();
$app = Factory::miniProgram($config);
$path = env('root_path') . 'public/' . strrchr($goods_image, 'uploads');
if (!file_exists($path)) {
return '商品封面不存在,请上传商品封面';
}
// 裁剪图片尺寸,避免图片太大导致上传失败
// 打开图片文件
$image = \think\Image::open($path);
// 定义上传文件目录
$dir = './uploads/goods/';
// 判断文件目录是否存在
if (!is_dir($dir)) {
// 创建文件目录
if (!mkdir($dir, 0777, true)) {
return '请给uploads目录开启777权限';
}
}
// 定义新图片名称
$new_image = 'livegoods' . time() . '.png';
$image->thumb(300, 300)->save('./uploads/goods/' . $new_image);
// 获取完整的新文件路径
$new_path = env('root_path') . 'public/uploads/goods/' . $new_image;
$result = $app->media->uploadImage($new_path);
return ['media_id' => $result['media_id'], 'url' => UrlServer::getFileUrl('uploads/goods/' . $new_image)];
} catch (Exception $e) {
return $e->getMessage();
}
}
public static function getLiveGoodsError($code, $errmsg){
$error_msg = [
-1 => '系统错误',
1003 => '商品id不存在',
47001 => '参格式不符合规范',
200002 => '入参错误',
300001 => '禁止创建/更新商品',
300002 => '名称长度不符合规则',
300003 => '价格输入不合规',
300004 => '商品名称存在违规违法内容',
300005 => '商品封面图片存在违规违法内容',
300006 => '图片上传失败',
300007 => '线上小程序版本不存在该链接',
300008 => '添加商品失败',
300009 => '商品审核撤回失败',
300010 => '商品审核状态不对',
300011 => '操作非法',
300012 => '没有提审额度每天500次提审额度',
300013 => '提审失败',
300014 => '审核中,无法删除',
300017 => '商品未提审',
300018 => '商品封面图片尺寸过大',
300021 => '商品添加成功,审核失败'
];
if(!isset($error_msg[$code])){
return $errmsg;
}
return $error_msg[$code];
}
}

View file

@ -0,0 +1,209 @@
<?php
// +----------------------------------------------------------------------
// | likeshop100%开源免费商用商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用,保留版权即可
// | 商业版本务必购买商业授权,以免引起法律纠纷
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshopTeam
// +----------------------------------------------------------------------
namespace app\admin\logic;
use app\common\server\UrlServer;
use app\common\server\WeChatServer;
use EasyWeChat\Factory;
use Exception;
class LiveRoomLogic
{
/**
* @notes 获取assessToken
* @return mixed
* @throws @\EasyWeChat\Kernel\Exceptions\HttpException
* @throws @\EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws @\EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws @\Psr\SimpleCache\InvalidArgumentException
* @author 张无忌
* @date 2021/10/13 11:36
*/
public static function getAccessToken()
{
$config = WeChatServer::getMnpConfig();
$app = Factory::miniProgram($config);
return $app->access_token->getToken()['access_token'];
}
/**
* @notes 获取直播间列表
* @param $get
* @return array|string
* @author 张无忌
* @date 2021/9/13 15:54
*/
public static function lists($get)
{
try {
$config = WeChatServer::getMnpConfig();
$app = Factory::miniProgram($config);
$result = $app->live->getRooms($get['page'] - 1, $get['limit']);
if ($result['errcode'] != 0) {
return $result['errcode'] . '' . $result['errmsg'];
}
$liveStatus = [101 => '直播中', 102 => '未开始', 103 => '已结束', 104 => '禁播', 105 => '暂停', 106 => '异常', 107 => '已过期'];
$data = [];
foreach ($result['room_info'] as $item) {
$data[] = [
'name' => $item['name'],
'roomid' => $item['roomid'],
'cover_img' => $item['cover_img'],
'anchor_name' => $item['anchor_name'],
'live_status' => $liveStatus[$item['live_status']],
'goods' => count($item['goods']),
'start_time' => date('Y-m-d H:i:s', $item['start_time']),
'end_time' => date('Y-m-d H:i:s', $item['end_time'])
];
}
return ['count' => $result['total'], 'lists' => $data];
} catch (Exception $e) {
return $e->getMessage();
}
}
/**
* @notes 创建直播间
* @param $post
* @return bool|string
* @throws @\EasyWeChat\Kernel\Exceptions\HttpException
* @throws @\EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws @\EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws @\EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws @\Psr\SimpleCache\InvalidArgumentException
* @author 张无忌
* @date 2021/9/14 15:49
*/
public static function add($post)
{
$config = WeChatServer::getMnpConfig();
$app = Factory::miniProgram($config);
$access_token = $app->access_token->getToken()['access_token'];
$startTime = strtotime($post['startTime']);
$endTime = strtotime($post['endTime']);
if (($startTime - time()) <= 610) {
return '开播时间需要在当前时间的10分钟后';
}
if (($endTime - $startTime) <= (30 * 60)) {
return '播时间和结束时间间隔不得短于30分钟';
}
if (empty($post['coverImg'])) {
return '请上传封面图';
}
if (empty($post['shareImg'])) {
return '请上传分享图';
}
if (empty($post['feedsImg'])) {
return '请上传背景图';
}
$data = [
'name' => $post['name'],
'coverImg' => $post['coverImg'],
'startTime' => strtotime($post['startTime']),
'endTime' => strtotime($post['endTime']),
'anchorName' => $post['anchorName'],
'anchorWechat' => $post['anchorWechat'],
'subAnchorWechat' => $post['subAnchorWechat'] ?? '',
'createrWechat' => $post['anchorWechat'],
'shareImg' => $post['shareImg'],
'feedsImg' => $post['feedsImg'],
'type' => intval($post['type']),
'isFeedsPublic' => empty($post['isFeedsPublic']) ? 0 : 1,
'closeLike' => empty($post['closeLike']) ? 1 : 0,
'closeGoods' => empty($post['closeGoods']) ? 1 : 0,
'closeComment' => empty($post['closeComment']) ? 1 : 0,
'closeReplay' => empty($post['closeReplay']) ? 1 : 0,
'closeShare' => empty($post['closeShare']) ? 1 : 0,
'closeKf' => empty($post['closeKf']) ? 1 : 0,
];
$url = 'https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token='.$access_token;
$result = curl_post($url, $data);
$result = json_decode($result, true);
if ($result['errcode'] != 0) {
return $result['errcode'] . '' . $result['errmsg'];
}
return true;
}
/**
* @notes 删除直播间
* @param $id
* @return bool|string
* @throws @\EasyWeChat\Kernel\Exceptions\HttpException
* @throws @\EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws @\EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws @\EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws @\Psr\SimpleCache\InvalidArgumentException
* @author 张无忌
* @date 2021/9/14 16:00
*/
public static function del($id)
{
$config = WeChatServer::getMnpConfig();
$app = Factory::miniProgram($config);
$access_token = $app->access_token->getToken()['access_token'];
$url = 'https://api.weixin.qq.com/wxaapi/broadcast/room/deleteroom?access_token='.$access_token;
$result = curl_post($url, ['id'=>intval($id)]);
$result = json_decode($result, true);
if ($result['errcode'] != 0) {
return $result['errcode'] . '' . $result['errmsg'];
}
return true;
}
/**
* @notes 上传临时素材图片
* @param $url
* @return array|string
* @throws @\GuzzleHttp\Exception\GuzzleException
* @author 张无忌
* @date 2021/9/13 17:34
*/
public static function upload($url)
{
try {
$config = WeChatServer::getMnpConfig();
$app = Factory::miniProgram($config);
$path = env('root_path').'public/uploads/temp/'.$url;
$result = $app->media->uploadImage($path);
return ['media_id'=>$result['media_id'], 'url'=>UrlServer::getFileUrl('uploads/temp/'.$url)];
}catch (Exception $e) {
return $e->getMessage();
}
}
}

View file

@ -39,14 +39,12 @@ class LogLogic
*/
public static function lists($page_no, $size, $get)
{
$where[] = ['create_time', 'between', Time::today()];
if (isset($get['start_time']) && $get['start_time'] && isset($get['end_time']) && $get['end_time']) {
$where[] = ['create_time', 'between', [strtotime($get['start_time']), strtotime($get['end_time'])]];
} else {
$where[] = ['create_time', 'between', Time::today()];
}
if (isset($get['account']) && $get['account']) {
$where[] = ['account', 'like', "%{$get['account']}%"];
}
@ -60,7 +58,6 @@ class LogLogic
$where[] = ['ip', 'like', "%{$get['ip']}%"];
}
$lists = Db::name('system_log')
->where($where)
->page($page_no, $size)
@ -74,6 +71,7 @@ class LogLogic
$count = Db::name('system_log')
->where($where)
->count();
return ['lists' => $lists, 'count' => $count];
}
}

0
server/application/admin/logic/LoginLogic.php Normal file → Executable file
View file

View file

@ -1,8 +1,26 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\logic;
use app\admin\model\Coupon;
use app\common\model\Luckdraw;
use app\common\model\LuckdrawRecord;
use app\common\server\ConfigServer;
@ -36,7 +54,8 @@ class LuckDrawLogic
$model = new Luckdraw();
$count = $model->where($where)->count();
$lists = $model->field(true)->where($where)
->order(['sort'=>'desc'])
->append(['prize_name'])
->order(['sort'=>'desc', 'id' => 'desc'])
->page($get['page'], $get['limit'])
->select();
@ -65,8 +84,7 @@ class LuckDrawLogic
public static function add($post)
{
try {
$name_text = ['', '积分', '谢谢惠顾', '优惠券'];
$post['name'] = $name_text[$post['prize_type']];
$post['name'] = Luckdraw::getPrizeDesc($post['prize_type']);
$post['image'] = !empty($post['image']) ? $post['image'] : '';
$model = new Luckdraw();
@ -74,7 +92,7 @@ class LuckDrawLogic
'prize_type' => $post['prize_type'],
'name' => $post['name'],
'image' => $post['image'],
'number' => $post['number'],
'number' => self::getPrizeValue($post),
'sort' => $post['sort'],
'probability' => $post['probability'],
'status' => $post['status'],
@ -97,8 +115,7 @@ class LuckDrawLogic
public static function edit($post)
{
try {
$name_text = ['', '积分', '谢谢惠顾', '优惠券'];
$post['name'] = $name_text[$post['prize_type']];
$post['name'] = Luckdraw::getPrizeDesc($post['prize_type']);
$post['image'] = !empty($post['image']) ? $post['image'] : '';
$model = new Luckdraw();
@ -106,7 +123,7 @@ class LuckDrawLogic
'prize_type' => $post['prize_type'],
'name' => $post['name'],
'image' => $post['image'],
'number' => $post['number'],
'number' => self::getPrizeValue($post),
'sort' => $post['sort'],
'probability' => $post['probability'],
'status' => $post['status'],
@ -155,19 +172,26 @@ class LuckDrawLogic
{
if ($post['status'] == 1) {
$model = new Luckdraw();
$count = $model->field(true)
$prizes = $model->field(true)
->where(['is_delete' => 0, 'status'=>1])
->order(['id'=>'desc', 'sort'=>'desc'])
->count();
if ($count < 8) {
static::$error = '请设置最少8个抽奖商品再来启动';
->select();
if (count($prizes) != 8) {
static::$error = '抽奖限制8个抽奖奖品';
return false;
}
$probability = array_column($prizes->toArray(), 'probability');
if (array_sum($probability) > 100) {
static::$error = '中奖概率合计不能大于100%';
return false;
}
}
ConfigServer::set('luckdraw', 'limit', $post['limit']);
ConfigServer::set('luckdraw', 'need', $post['need']);
ConfigServer::set('luckdraw', 'rule', $post['rule']);
ConfigServer::set('luckdraw', 'status', $post['status']);
ConfigServer::set('luckdraw', 'show_win', $post['show_win']);
return true;
}
@ -185,6 +209,7 @@ class LuckDrawLogic
->with('user')
->order('id', 'desc')
->page($get['page'], $get['limit'])
->append(['send_desc'])
->select();
return ['count'=>$count, 'list'=>$lists];
@ -231,4 +256,45 @@ class LuckDrawLogic
return false;
}
}
/**
* @notes 优惠券列表
* @return Coupon[]
* @author 段誉
* @date 2022/2/15 10:18
*/
public static function coupon()
{
$where[] = ['del', '=', 0];
$where[] = ['status', '=', 1];
$where[] = ['get_type', '=', 2];
return Coupon::where($where)->order('id desc')->select();
}
/**
* @notes 获取奖品数值
* @param $param
* @return int|mixed
* @author 段誉
* @date 2022/2/15 14:14
*/
public static function getPrizeValue($param)
{
$number = 0;
switch ($param['prize_type']) {
case Luckdraw::PRIZE_INTEGRAL:
$number = $param['integral'];
break;
case Luckdraw::PRIZE_COUPON:
$number = $param['coupon'];
break;
case Luckdraw::PRIZE_BALANCE:
$number = $param['balance'];
break;
}
return $number;
}
}

View file

@ -16,59 +16,38 @@
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\controller;
namespace app\admin\logic;
use app\common\server\ConfigServer;
use app\common\server\UrlServer;
/**
* 分销设置
* Class Distribution
* @package app\admin\controller
*/
class Distribution extends AdminBase
{
class MapConfigLogic{
/**
* 分销会员列表/审核会员列表
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @notes 获取地图配置
* @return array
* @author ljj
* @date 2021/8/20 8:34 下午
*/
public function setting()
{
public static function getConfig(){
$config = [
'is_open' => ConfigServer::get('distribution', 'is_open', 1),
'member_apply' => ConfigServer::get('distribution', 'member_apply', 1),
'show_commission' => ConfigServer::get('distribution', 'show_commission', 0),
'share_poster' => ConfigServer::get('distribution', 'share_poster'),//分享海报
'tx_map_key' => ConfigServer::get('map','tx_map_key',''),
];
$config['share_poster'] = UrlServer::getFileUrl($config['share_poster']);
$this->assign('config', $config);
return $this->fetch('');
return $config;
}
/**
* 设置分销配置
* @notes 地图设置
* @param $post
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
* @author ljj
* @date 2021/8/20 8:34 下午
*/
public function setDistribution()
public static function setConfig($post)
{
$post = $this->request->post();
if ($post) {
ConfigServer::set('distribution', 'is_open', $post['is_open']);
ConfigServer::set('distribution', 'member_apply', $post['member_apply']);
ConfigServer::set('distribution', 'show_commission', $post['show_commission']);
ConfigServer::set('distribution', 'share_poster', UrlServer::setFileUrl($post['share_poster']));
$this->_success('修改成功');
}
ConfigServer::set('map','tx_map_key',$post['tx_map_key']);
}
}

View file

@ -36,6 +36,7 @@ class MnpLogic{
'uploadfile_domain' => 'https://'.$domain_name,
'downloadfile_domain' => 'https://'.$domain_name,
'udp_domain' => 'udp://'.$domain_name,
'tcp_domain' => 'tcp://'.$domain_name,
'business_domain' => $domain_name,
'url' => url('api/weChat/index','','',true),
'token' => ConfigServer::get('mnp', 'token', 'LikeShop'),

0
server/application/admin/logic/MyLogic.php Normal file → Executable file
View file

View file

@ -27,6 +27,7 @@ use app\common\model\OrderGoods;
use app\common\model\OrderLog;
use app\common\logic\OrderLogLogic;
use app\common\model\Pay;
use app\common\model\SelffetchShop;
use app\common\model\UserLevel;
use app\common\server\ConfigServer;
use app\common\server\UrlServer;
@ -164,8 +165,12 @@ class OrderLogic
$order_goods['image'] = empty($order_good_info['spec_image']) ?
UrlServer::getFileUrl($order_good_info['image']) : UrlServer::getFileUrl($order_good_info['spec_image']);
}
$list['delivery_type'] = Order::getDeliveryType($list['delivery_type']);
$list['delivery_type_desc'] = Order::getDeliveryType($list['delivery_type']);
$list['user_level'] = $list['user']['level']['name'] ?? '无等级';
if ($list['delivery_type'] == 2) {
$list['shop_name'] = SelffetchShop::where('id',$list['selffetch_shop_id'])->value('name');
}
}
return ['count' => $count, 'lists' => $lists];
}
@ -294,7 +299,12 @@ class OrderLogic
$order_goods['spec_value'] = $info['spec_value_str'];
$order_goods['goods_image'] = empty($info['spec_image']) ?
UrlServer::getFileUrl($info['image']) : UrlServer::getFileUrl($info['spec_image']);
$order_goods['refund_status_desc'] = OrderGoods::getRefundStatus($order_goods['refund_status']);
}
$result['shop_name'] = SelffetchShop::where('id',$result['selffetch_shop_id'])->value('name');
return $result;
}
@ -445,7 +455,7 @@ class OrderLogic
'params' => [
'order_sn' => $order->order_sn,
'nickname' => $nickname,
'time' => date('Y-m-d H:i:s'),
'time' => date('Y-m-d H:i'),
'invoice_no' => $data['invoice_no'] ?? '',
'shipping_name' => $delivery_data['shipping_name'] ?? '无需快递',
'goods_name' => omit_str($order['order_goods'][0]['goods_name'] ?? '商品', 8)
@ -539,7 +549,7 @@ class OrderLogic
{
$orderModel = new Order();
$order = $orderModel->alias('o')
->field('invoice_no,shipping_name,shipping_id,o.shipping_status')
->field('invoice_no,shipping_name,shipping_id,o.shipping_status,o.mobile')
->join('delivery d', 'd.order_id = o.id')
->where(['o.id' => $order_id])
->find();
@ -567,7 +577,16 @@ class OrderLogic
->value($shipping_field);
//获取物流轨迹
$expressage->logistics($shipping_code, $order['invoice_no']);
if (in_array(strtolower($shipping_code ), [ 'sf', 'shunfeng' ])) {
if ($express === 'kdniao') {
$expressage->logistics($shipping_code, $order['invoice_no'], substr($order['mobile'],-4));
} else {
$expressage->logistics($shipping_code, $order['invoice_no'], $order['mobile']);
}
}else {
$expressage->logistics($shipping_code, $order['invoice_no']);
}
$traces = $expressage->logisticsFormat();
if ($traces == false) {
$traces[] = [$expressage->getError()];
@ -613,15 +632,13 @@ class OrderLogic
//打印机配置
$printer_config = Db::name('printer_config')->where(['status'=>1])->find();
//打印机列表
$printer_list = Db::name('printer')->where(['type'=>$printer_config['id'],'del'=>0])->select();
$printer_list = Db::name('printer')->where(['type'=>$printer_config['id'],'status'=>1,'del'=>0])->select();
if(empty($printer_config) || empty($printer_list)){
throw new Exception('请先配置打印机');
}
$yly_print = new YlyPrinter($printer_config['client_id'],$printer_config['client_secret']);
$order = self::getPrintOrder($id);
$template_config = ConfigServer::get('printer', 'yly_template', []);
$yly_print->ylyPrint($printer_list,$order,$template_config);
@ -640,6 +657,13 @@ class OrderLogic
}
}
/**
* @notes 获取订单信息
* @param $id
* @return array
* @author cjhao
* @date 2021/9/26 11:43
*/
public static function getPrintOrder($id){
$order = new Order();
$result = $order
@ -647,8 +671,14 @@ class OrderLogic
->where('id', $id)
->append(['delivery_address'])
->find();
$selffetch_shop = [];
if(Order::DELIVERY_STATUS_SELF == $result->delivery_type){
$selffetch_shop = SelffetchShop::where(['id'=>$result->selffetch_shop_id])
->field('id,name,province,city,district,address')
->append(['shop_address'])
->find();
}
$result->selffetch_shop = $selffetch_shop;
foreach ($result['order_goods'] as &$order_goods) {
$info = json_decode($order_goods['goods_info'], true);
$order_goods['name'] = $info['goods_name'];
@ -658,4 +688,52 @@ class OrderLogic
return $result->toArray();
}
/**
* @notes 获取发货单
* @param $get
* @return array|\PDOStatement|string|\think\Model|null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @author suny
* @date 2021/11/08 16:06 下午
*/
public static function getDelivery($get)
{
return Db::name('delivery')
->where(['order_id' => $get['id']])
->find();
}
/**
* @notes 修改物流信息
* @param $get
* @return array|string|\think\Model|null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @author suny
* @date 2021/11/08 16:07 下午
*/
public static function changeDelivery($post)
{
$delivery = Db::name('delivery')
->where(['id' => $post['id']])
->find();
if(!$delivery){
return false;
}
$express = Db::name('express')
->where(['id' => $post['shipping_id']])
->find();
$data = [
'shipping_id' => $post['shipping_id'],
'shipping_name' => $express['name'],
'invoice_no' => $post['invoice_no'],
];
Db::name('delivery')
->where(['id' => $post['id']])
->update($data);
return true;
}
}

View file

@ -0,0 +1,95 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\logic;
use app\common\server\ConfigServer;
use think\facade\Env;
/**
* PC商城逻辑层
* Class Pc
* @package app\admin\logic
*/
class Pc
{
/**
* @notes 获取PC商城设置
* @return array
* @author Tab
* @date 2021/8/14 14:56
*/
public static function getConfig()
{
$config = [
'is_open' => ConfigServer::get('pc', 'is_open', 1),
'page' => ConfigServer::get('pc', 'page', 1),
'page_url' => ConfigServer::get('pc', 'page_url', ''),
'pc_url' => request()->domain() . '/pc'
];
return $config;
}
/**
* @notes PC商城设置
* @param $params
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
* @author Tab
* @date 2021/8/14 14:57
*/
public static function set($params)
{
ConfigServer::set('pc', 'is_open', $params['is_open']);
ConfigServer::set('pc', 'page', $params['page']);
ConfigServer::set('pc', 'page_url', $params['page_url']);
// 恢复原入口
if(file_exists('./pc/index_lock.html')) {
// 存在则原商城入口被修改过,先清除修改后的入口
unlink('./pc/index.html');
// 恢复原入口
rename('./pc/index_lock.html', './pc/index.html');
}
// PC商城关闭 且 显示空白页
if($params['is_open'] == 0 && $params['page'] == 1) {
// 变更文件名
rename('./pc/index.html', './pc/index_lock.html');
// 创建新空白文件
$newfile = fopen('./pc/index.html', 'w');
fclose($newfile);
}
// PC商城关闭 且 跳转指定页
if($params['is_open'] == 0 && $params['page'] == 2 && !empty($params['page_url'])) {
// 变更文件名
rename('./pc/index.html', './pc/index_lock.html');
// 创建重定向文件
$newfile = fopen('./pc/index.html', 'w');
$content = '<script>window.location.href = "' . $params['page_url'] . '";</script>';
fwrite($newfile, $content);
fclose($newfile);
}
}
}

View file

@ -55,7 +55,7 @@ class PrinterLogic{
case 3:
$list = ConfigServer::get('printer', 'yly_template', []);
$list['file_url'] = UrlServer::getFileUrl('');
$list['file_url'] = UrlServer::getFileUrl('/');
break;
}
@ -340,6 +340,7 @@ class PrinterLogic{
$order = [
'order_sn' => date("Ymd").'88888888888',
'create_time' => date('Y-m-d H:i:s'),
'delivery_type' => 1,
'consignee' => '张先生',
'mobile' => '138888888888',
'delivery_address' => '广东省广州市天河区XXXX科技园',
@ -367,6 +368,7 @@ class PrinterLogic{
'total_price' => '88888',
],
],
'selffetch_shop' => [],
'total_amount' => '888888', //商品总价
'discount_amount' => '80', //优惠金额
'shipping_price' => '12', //应付

Some files were not shown because too many files have changed in this diff Show more