其余文件

This commit is contained in:
2026-04-14 17:46:22 +08:00
parent 294b68fe37
commit 3691f4db22
1343 changed files with 189847 additions and 0 deletions

View File

@ -0,0 +1,58 @@
<?php
namespace app\admin\controller\distribution;
use app\admin\logic\distribution\ApplyLogic;
use app\common\basics\AdminBase;
use app\common\server\JsonServer;
use think\facade\View;
class Apply extends AdminBase
{
/**
* @Notes: 分销申请列表
* @Author: 张无忌
*/
public function lists()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
$lists = ApplyLogic::lists($get);
return JsonServer::success('获取成功', $lists);
}
return view();
}
/**
* @Notes: 分销申请详细
* @Author: 张无忌
*/
public function detail()
{
$id = $this->request->get('id');
View::assign('detail', ApplyLogic::detail($id));
return view();
}
/**
* @Notes: 审核分销申请
* @Author: 张无忌
*/
public function audit()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
$res = ApplyLogic::audit($post);
if ($res === false) {
$message = ApplyLogic::getError() ?: '审核失败';
return JsonServer::error($message);
}
return JsonServer::success('审核成功');
}
return view();
}
}

View File

@ -0,0 +1,89 @@
<?php
namespace app\admin\controller\distribution;
use app\admin\logic\distribution\CenterLogic;
use app\common\basics\AdminBase;
use app\common\model\distribution\Distribution;
use app\common\model\distribution\DistributionLevel;
use app\common\model\user\User;
use app\common\server\JsonServer;
use app\common\model\distribution\DistributionOrderGoods;
class Center extends AdminBase
{
public function data()
{
// 已结算: 已结算
$settled = DistributionOrderGoods::where(['status'=>2])->sum('money');
// 预估: 待返佣 + 已结算
$estimate = DistributionOrderGoods::where('status', 'in', [1, 2])->sum('money');
return view('', [
'settled' => $settled,
'estimate' => $estimate
]);
}
/**
* @notes 数据概览
* @return \think\response\Json
* @author Tab
* @date 2021/9/6 14:35
*/
public function center()
{
$data = CenterLogic::center();
return view('', ['data' => $data]);
}
/**
* @notes 分销初始化数据
* @return \think\response\Json
* @author Tab
* @date 2021/9/6 14:26
*/
public function updateTable()
{
try {
$defaultLevel = DistributionLevel::where('is_default', 1)->findOrEmpty()->toArray();
if (empty($defaultLevel)) {
// 没有默认等级,初始化
DistributionLevel::create([
'name' => '默认等级',
'weights' => '1',
'is_default' => '1',
'remark' => '默认等级',
'update_relation' => '1'
]);
}
// 默认分销会员等级
$defaultLevelId = DistributionLevel::where('is_default', 1)->value('id');
// 生成分销基础信息表
$users = 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 JsonServer::success('初始化数据完成');
} catch(\Exception $e) {
return JsonServer::error($e->getMessage());
}
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace app\admin\controller\distribution;
use app\admin\logic\distribution\DistributionGoodsLogic;
use app\common\basics\AdminBase;
use app\admin\logic\goods\CategoryLogic as MallCategoryLogic;
use app\common\server\JsonServer;
use app\shop\logic\goods\CategoryLogic as ShopCategoryLogic;
/**
* 分销商品
* Class DistributionGoodsLogic
* @package app\admin\controller\distribution
*/
class DistributionGoods extends AdminBase
{
/**
* @notes 分销商品列表页
* @return \think\response\View
* @author Tab
* @date 2021/9/2 17:30
*/
public function index()
{
if ($this->request->isPost()) {
$params = $this->request->post();
$lists = DistributionGoodsLogic::lists($params);
return JsonServer::success('', $lists);
}
// 显示分销商品列表页
$cate_list = MallCategoryLogic::categoryTreeeTree();
return view('', ['cate_list' => $cate_list]);
}
/**
* @notes 查看商品佣金比例
* @return \think\response\View
* @author Tab
* @date 2021/9/2 17:57
*/
public function detail()
{
$params = $this->request->get();
$detail = DistributionGoodsLogic::detail($params);
return view('', ['detail' => $detail]);
}
}

View File

@ -0,0 +1,84 @@
<?php
namespace app\admin\controller\distribution;
use app\admin\logic\distribution\DistributionLevelLogic;
use app\admin\validate\distribution\DistributionLevelValidate;
use app\common\basics\AdminBase;
use app\common\server\JsonServer;
class DistributionLevel extends AdminBase
{
/**
* @notes 分销等级列表
* @return \think\response\View
* @author Tab
* @date 2021/9/1 11:01
*/
public function index()
{
if ($this->request->isPost()) {
$result = DistributionLevelLogic::index();
return JsonServer::success('', $result);
}
return view();
}
/**
* @notes 添加分销等级
* @return \think\response\View
* @author Tab
* @date 2021/9/1 12:02
*/
public function add()
{
if ($this->request->isPost()) {
$params = (new DistributionLevelValidate())->goCheck('add');
$result = DistributionLevelLogic::add($params);
if($result) {
return JsonServer::success('添加成功');
}
return JsonServer::error(DistributionLevelLogic::getError());
}
// 显示添加页面
return view();
}
/**
* @notes 编辑分销等级
* @return \think\response\View
* @author Tab
* @date 2021/9/1 15:39
*/
public function edit()
{
if ($this->request->isPost()) {
$params = (new DistributionLevelValidate())->goCheck('edit');
$result = DistributionLevelLogic::edit($params);
if($result) {
return JsonServer::success('编辑成功');
}
return JsonServer::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
* @date 2021/9/1 16:18
*/
public function delete()
{
$params = $this->request->post();
$result = DistributionLevelLogic::delete($params);
if($result) {
return JsonServer::success('删除成功');
}
return JsonServer::error(DistributionLevelLogic::getError());
}
}

View File

@ -0,0 +1,112 @@
<?php
namespace app\admin\controller\distribution;
use app\admin\logic\distribution\DistributionLevelLogic;
use app\admin\logic\distribution\DistributionMemberLogic;
use app\common\basics\AdminBase;
use app\common\server\JsonServer;
/**
* 分销会员
* Class DistributionMember
* @package app\admin\controller\distribution
*/
class DistributionMember extends AdminBase
{
/**
* @notes 分销会员列表
* @return \think\response\View
* @author Tab
* @date 2021/9/2 18:26
*/
public function index()
{
if ($this->request->isPost()) {
$params = $this->request->post();
$result = DistributionMemberLogic::lists($params);
return JsonServer::success('', $result);
}
$levels = DistributionLevelLogic::getLevels();
return view('', ['levels' => $levels]);
}
/**
* @notes 开通分销会员
* @return \think\response\View
* @author Tab
* @date 2021/9/2 19:32
*/
public function open()
{
if($this->request->isPost()) {
$params = $this->request->post();
$result = DistributionMemberLogic::open($params);
if($result) {
return JsonServer::success('开通成功');
}
return JsonServer::error(DistributionMemberLogic::getError());
}
$levels = DistributionLevelLogic::getLevels();
return view('', ['levels' => $levels]);
}
/**
* @notes 用户列表
* @return \think\response\Json|\think\response\View
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author Tab
* @date 2021/9/3 11:50
*/
public function userLists()
{
if ($this->request->isPost()) {
$params = $this->request->post();
$lists = DistributionMemberLogic::getUserLists($params);
return JsonServer::success('', $lists);
}
return view();
}
/**
* @notes 分销会员等级调整
* @return \think\response\Json|\think\response\View
* @author Tab
* @date 2021/9/3 14:10
*/
public function adjust()
{
if($this->request->isPost()) {
$params = $this->request->post();
$result = DistributionMemberLogic::adjust($params);
if($result) {
return JsonServer::success('调整成功');
}
return JsonServer::error(DistributionMemberLogic::getError());
}
$params = $this->request->get();
$user = DistributionMemberLogic::getUser($params);
$levels = DistributionLevelLogic::getLevels();
return view('', [
'user' => $user,
'levels' => $levels
]);
}
/**
* @notes 冻结资格/恢复资格
* @return \think\response\Json
* @author Tab
* @date 2021/9/3 14:20
*/
public function isFreeze()
{
$params = $this->request->post();
$result = DistributionMemberLogic::isFreeze($params);
if($result) {
return JsonServer::success('操作成功');
}
return JsonServer::error(DistributionMemberLogic::getError());
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace app\admin\controller\distribution;
use app\admin\logic\distribution\DistributionOrderLogic;
use app\common\basics\AdminBase;
use app\common\server\JsonServer;
class DistributionOrder extends AdminBase
{
/**
* @notes 分销订单列表
* @return \think\response\View
* @author Tab
* @date 2021/9/3 16:53
*/
public function index()
{
if($this->request->isPost()) {
$params = $this->request->post();
$result = DistributionOrderLogic::lists($params);
return JsonServer::success('', $result);
}
return view();
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace app\admin\controller\distribution;
use app\admin\logic\distribution\DistributionSettingLogic;
use app\common\basics\AdminBase;
use app\common\server\JsonServer;
class DistributionSetting extends AdminBase
{
/**
* @notes 基础设置
* @return \think\response\View
* @author Tab
* @date 2021/9/1 9:14
*/
public function index()
{
$config = DistributionSettingLogic::getConfig();
return view('', ['config' => $config]);
}
/**
* @notes 分销设置
* @return \think\response\Json
* @author Tab
* @date 2021/9/1 9:15
*/
public function set()
{
$params = $this->request->post();
$result = DistributionSettingLogic::set($params);
if ($result) {
return JsonServer::success('设置成功');
}
return JsonServer::error(DistributionSettingLogic::getError());
}
/**
* @notes 结算设置
* @return \think\response\View
* @author Tab
* @date 2021/9/1 9:17
*/
public function settlement()
{
$config = DistributionSettingLogic::getConfig();
return view('', ['config' => $config]);
}
}

View File

@ -0,0 +1,154 @@
<?php
namespace app\admin\controller\distribution;
use app\common\basics\AdminBase;
use app\common\model\distribution\DistributionMemberApply;
use app\common\server\JsonServer;
use app\admin\logic\distribution\MemberLogic;
use app\admin\validate\distribution\MemberValidate;
use think\exception\ValidateException;
class Member extends AdminBase
{
public function index()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
$type = $get['type'] ?? 'member';
if ($type == 'member') {
return JsonServer::success('获取成功', MemberLogic::memberLists($get));
}
return JsonServer::success('获取成功', MemberLogic::auditLists($get));
}
return view('index', ['status' => DistributionMemberApply::getApplyStatus(true)]);
}
public function addMember()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
try{
validate(MemberValidate::class)->scene('add')->check($post);
}catch(ValidateException $e) {
return JsonServer::error($e->getError());
}
$result = MemberLogic::addMember($post);
if($result === true) {
return JsonServer::success('添加成功');
}
return JsonServer::error($result);
}
return view();
}
public function info()
{
$get = $this->request->get();
$info = MemberLogic::getMemberInfo($get);
return view('info', ['detail'=>$info]);
}
public function fans()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
return JsonServer::success('', MemberLogic::getFansLists($get));
}
$user_id = $this->request->get('id');
return view('', ['user_id'=>$user_id]);
}
public function earningsDetail()
{
if ($this->request->isAjax()) {
$get = $this->request->get();
return JsonServer::success('', MemberLogic::getEarningsDetail($get));
}
$user_id = $this->request->get('id');
return view('', ['user_id'=>$user_id]);
}
public function updateLeader()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
try{
validate(MemberValidate::class)->scene('updateLeader')->check($post);
}catch(ValidateException $e) {
return JsonServer::error($e->getError());
}
$result = MemberLogic::updateRelation($post);
if ($result === true){
return JsonServer::success('操作成功');
}
return JsonServer::error($result);
}
$user_id = $this->request->get('id');
return view('',[
'first_leader' => MemberLogic::getLeaderInfo($user_id),
'user_id' => $user_id
]);
}
public function freeze()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
try{
validate(MemberValidate::class)->scene('freeze')->check($post);
}catch(ValidateException $e) {
return JsonServer::error($e->getError());
}
$result = MemberLogic::freeze($post);
if($result === true) {
return JsonServer::success('操作成功');
}
return JsonServer::error('操作失败');
}
}
// 删除分销资格
public function del()
{
if($this->request->isPost()) {
$post = $this->request->post();
$result = MemberLogic::del($post);
if($result === true) {
return JsonServer::success('操作成功');
}
return JsonServer::error('操作失败');
}
}
/**
* 审核分销会员
*/
public function audit()
{
if ($this->request->isAjax()) {
$post = $this->request->post();
try{
validate(MemberValidate::class)->scene('audit')->check($post);
}catch(ValidateException $e) {
return JsonServer::error($e->getError());
}
if ($post['type'] == 'pass') {
$res = MemberLogic::auditPass($post);
} else {
$res = MemberLogic::auditRefuse($post);
}
if ($res !== true) {
return JsonServer::error('操作失败');
}
return JsonServer::success('操作成功');
}
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace app\admin\controller\distribution;
use app\admin\logic\distribution\RecordLogic;
use app\common\basics\AdminBase;
use app\common\server\JsonServer;
use app\common\utils\Time;
class Record extends AdminBase
{
public function lists()
{
if($this->request->isAjax()) {
$get = $this->request->get();
$data = RecordLogic::lists($get);
return JsonServer::success('', $data);
}
return view('', [
'time' => Time::getTime()
]);
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace app\admin\controller\distribution;
use app\common\basics\AdminBase;
use app\common\server\ConfigServer;
use app\common\server\JsonServer;
class Setting extends AdminBase
{
/**
* 分销设置
*/
public function setting()
{
if($this->request->isPost()) {
$post = $this->request->post();
ConfigServer::set('distribution', 'is_open', $post['is_open']);
ConfigServer::set('distribution', 'member_apply', $post['member_apply']);
if(isset($post['image'])) {
// 图片链接去除域名再入库
$domain = $this->request->domain();
$post['image'] = str_replace($domain, '', $post['image']);
ConfigServer::set('distribution', 'image', $post['image']);
}else{
ConfigServer::set('distribution', 'image', '');
}
return JsonServer::success('设置成功');
}
$config = [
'is_open' => ConfigServer::get('distribution', 'is_open', 1),
'member_apply' => ConfigServer::get('distribution', 'member_apply', 1),
'image' => ConfigServer::get('distribution', 'image', ''),
];
return view('', ['config' => $config]);
}
}