添加:管理后台查看团队每条线的业绩及大小区业绩
This commit is contained in:
parent
687e9daf83
commit
dc71b58de4
|
|
@ -415,8 +415,9 @@ class CulturalSpace extends BaseModel
|
|||
$areaAmount = (float)sprintf("%.2f",$teamAmount - $maxAmount);// 小区业绩 = 总业绩 - 最大一条线的业绩
|
||||
|
||||
return [
|
||||
'team_amount' => $teamAmount,
|
||||
'area_amount' => $areaAmount
|
||||
'team_amount' => (float)$teamAmount,
|
||||
'area_amount' => (float)$areaAmount,
|
||||
'max_amount' => (float)$maxAmount
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -578,59 +578,83 @@ class PluginApplication extends \app\common\services\PluginApplication
|
|||
],
|
||||
],
|
||||
// 店长管理
|
||||
'team_dividend_store_manager' => [
|
||||
'name' => '店长管理',
|
||||
'url' => 'plugin.team-dividend.admin.store-manager.index',
|
||||
'url_params' => '',
|
||||
'permit' => 1,
|
||||
'menu' => 1,
|
||||
'icon' => '',
|
||||
'item' => 'team_dividend',
|
||||
'parents' => ['team_dividend'],
|
||||
'child' => [
|
||||
'team_dividend_store_manager_index' => [
|
||||
'name' => '店长列表',
|
||||
'url' => 'plugin.team-dividend.admin.store-manager.index',
|
||||
'url_params' => '',
|
||||
'permit' => 1,
|
||||
'menu' => 0,
|
||||
'icon' => '',
|
||||
'item' => 'team_dividend_store_manager_index',
|
||||
'parents' => ['team_dividend', 'team_dividend_store_manager'],
|
||||
],
|
||||
'team_dividend_store_manager_addInfo' => [
|
||||
'name' => '添加店长',
|
||||
'url' => 'plugin.team-dividend.admin.store-manager.addInfo',
|
||||
'url_params' => '',
|
||||
'permit' => 1,
|
||||
'menu' => 0,
|
||||
'icon' => '',
|
||||
'item' => 'team_dividend_store_manager_addInfo',
|
||||
'parents' => ['team_dividend', 'team_dividend_store_manager'],
|
||||
],
|
||||
'team_dividend_store_manager_change_status' => [
|
||||
'name' => '删除店长',
|
||||
'url' => 'plugin.team-dividend.admin.store-manager.change-status',
|
||||
'url_params' => '',
|
||||
'permit' => 1,
|
||||
'menu' => 0,
|
||||
'icon' => '',
|
||||
'item' => 'team_dividend_store_manager_change_status',
|
||||
'parents' => ['team_dividend', 'team_dividend_store_manager'],
|
||||
],
|
||||
'team_dividend_store_manager_change_see_info' => [
|
||||
'name' => '查看店补',
|
||||
'url' => 'plugin.team-dividend.admin.store-manager.see-info',
|
||||
'url_params' => '',
|
||||
'permit' => 1,
|
||||
'menu' => 0,
|
||||
'icon' => '',
|
||||
'item' => 'team_dividend_store_manager_see_info',
|
||||
'parents' => ['team_dividend', 'team_dividend_store_manager'],
|
||||
],
|
||||
// 'team_dividend_store_manager' => [
|
||||
// 'name' => '店长管理',
|
||||
// 'url' => 'plugin.team-dividend.admin.store-manager.index',
|
||||
// 'url_params' => '',
|
||||
// 'permit' => 1,
|
||||
// 'menu' => 1,
|
||||
// 'icon' => '',
|
||||
// 'item' => 'team_dividend',
|
||||
// 'parents' => ['team_dividend'],
|
||||
// 'child' => [
|
||||
// 'team_dividend_store_manager_index' => [
|
||||
// 'name' => '店长列表',
|
||||
// 'url' => 'plugin.team-dividend.admin.store-manager.index',
|
||||
// 'url_params' => '',
|
||||
// 'permit' => 1,
|
||||
// 'menu' => 0,
|
||||
// 'icon' => '',
|
||||
// 'item' => 'team_dividend_store_manager_index',
|
||||
// 'parents' => ['team_dividend', 'team_dividend_store_manager'],
|
||||
// ],
|
||||
// 'team_dividend_store_manager_addInfo' => [
|
||||
// 'name' => '添加店长',
|
||||
// 'url' => 'plugin.team-dividend.admin.store-manager.addInfo',
|
||||
// 'url_params' => '',
|
||||
// 'permit' => 1,
|
||||
// 'menu' => 0,
|
||||
// 'icon' => '',
|
||||
// 'item' => 'team_dividend_store_manager_addInfo',
|
||||
// 'parents' => ['team_dividend', 'team_dividend_store_manager'],
|
||||
// ],
|
||||
// 'team_dividend_store_manager_change_status' => [
|
||||
// 'name' => '删除店长',
|
||||
// 'url' => 'plugin.team-dividend.admin.store-manager.change-status',
|
||||
// 'url_params' => '',
|
||||
// 'permit' => 1,
|
||||
// 'menu' => 0,
|
||||
// 'icon' => '',
|
||||
// 'item' => 'team_dividend_store_manager_change_status',
|
||||
// 'parents' => ['team_dividend', 'team_dividend_store_manager'],
|
||||
// ],
|
||||
// 'team_dividend_store_manager_change_see_info' => [
|
||||
// 'name' => '查看店补',
|
||||
// 'url' => 'plugin.team-dividend.admin.store-manager.see-info',
|
||||
// 'url_params' => '',
|
||||
// 'permit' => 1,
|
||||
// 'menu' => 0,
|
||||
// 'icon' => '',
|
||||
// 'item' => 'team_dividend_store_manager_see_info',
|
||||
// 'parents' => ['team_dividend', 'team_dividend_store_manager'],
|
||||
// ],
|
||||
//
|
||||
// ]
|
||||
// ],
|
||||
|
||||
]
|
||||
],
|
||||
// 团队信息
|
||||
'team_dividend_team' => [
|
||||
'name' => '团队信息',
|
||||
'url' => 'plugin.team-dividend.admin.team.index',
|
||||
'url_params' => '',
|
||||
'permit' => 1,
|
||||
'menu' => 1,
|
||||
'icon' => '',
|
||||
'item' => 'team_dividend',
|
||||
'parents' => ['team_dividend'],
|
||||
'child' => [
|
||||
'team_dividend_team_index' => [
|
||||
'name' => '团队信息',
|
||||
'url' => 'plugin.team-dividend.admin.team.index',
|
||||
'url_params' => '',
|
||||
'permit' => 1,
|
||||
'menu' => 0,
|
||||
'icon' => '',
|
||||
'item' => 'team_dividend_team_index',
|
||||
'parents' => ['team_dividend', 'team_dividend_team'],
|
||||
],
|
||||
]
|
||||
],
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace Yunshop\TeamDividend\admin;
|
||||
|
||||
use app\common\components\BaseController;
|
||||
use app\common\helpers\PaginationHelper;
|
||||
use app\common\models\Member;
|
||||
use app\common\models\user\User;
|
||||
use Yunshop\CulturalSpace\models\CulturalSpace;
|
||||
use Yunshop\TeamDividend\models\TeamDividendAgencyModel;
|
||||
|
||||
class TeamController extends BaseController{
|
||||
/**
|
||||
* Common: 获取信息列表
|
||||
* Author: wu-hui
|
||||
* Time: 2024/01/05 14:12
|
||||
* @return array|string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function index(){
|
||||
//参数获取
|
||||
$pageSize = request()->input('page_size',10);
|
||||
$search = request()->input('search');
|
||||
// 获取全部团队的小区业绩总和
|
||||
$minAreaSumAmount = TeamDividendAgencyModel::teamMinAreaSumAmount();
|
||||
// 获取列表信息
|
||||
$result = TeamDividendAgencyModel::teamGetAllList($pageSize,$search);
|
||||
foreach($result['data'] as &$dataInfo){
|
||||
$dataInfo['team_performance'] = (new CulturalSpace())->getTeamOrderAmount($dataInfo['uid']);
|
||||
$dataInfo['team_performance']['area_amount_rate'] = (float)sprintf("%.2f",(float)$dataInfo['team_performance']['area_amount'] / $minAreaSumAmount * 100);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'list' => $result['data'],
|
||||
'pager' => PaginationHelper::show($result['total'],$result['current_page'],$result['per_page']),
|
||||
'search' => $search,
|
||||
'min_area_sum_amount' => $minAreaSumAmount
|
||||
];
|
||||
|
||||
return view('Yunshop\TeamDividend::admin.team.index',$data)->render();
|
||||
}
|
||||
/**
|
||||
* Common: 查看团队业绩明细
|
||||
* Author: wu-hui
|
||||
* Time: 2024/01/05 14:39
|
||||
* @return array|string
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function teamPerformanceList(){
|
||||
//参数获取
|
||||
$uid = request()->input('uid');
|
||||
// 获取每条线的业绩
|
||||
$lineData = TeamDividendAgencyModel::teamGetPerformanceList($uid);
|
||||
// 获取团队长信息
|
||||
$ids = array_column($lineData['line_list'],'sub_uid');
|
||||
$lineData['user_list'] = Member::select(['uid','nickname','realname','avatar'])->whereIn('uid',$ids)->get()->keyBy('uid')->toArray();
|
||||
|
||||
|
||||
return view('Yunshop\TeamDividend::admin.team.record',$lineData)->render();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -5,11 +5,15 @@ namespace Yunshop\TeamDividend\models;
|
|||
|
||||
|
||||
use app\backend\models\BackendModel;
|
||||
use app\common\models\Member;
|
||||
use app\common\models\member\MemberChildren;
|
||||
use app\common\models\MemberShopInfo;
|
||||
use app\common\models\Order;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Yunshop\CulturalSpace\models\CulturalSpace;
|
||||
use Yunshop\TeamDividend\admin\models\MemberChild;
|
||||
use Yunshop\TeamDividend\observers\DealerObserver;
|
||||
use Yunshop\TeamDividend\services\UpgradeService;
|
||||
|
||||
|
|
@ -463,4 +467,116 @@ class TeamDividendAgencyModel extends BackendModel
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Common: 团队信息 - 获取全部团队信息列表(分页)
|
||||
* Author: wu-hui
|
||||
* Time: 2024/01/05 13:32
|
||||
* @param $pageSize
|
||||
* @param $search
|
||||
* @return array
|
||||
*/
|
||||
public static function teamGetAllList($pageSize,$search){
|
||||
// 条件生成
|
||||
$where = [];
|
||||
if($search['uid'] > 0) $where[] = ['uid','=',$search['uid']];
|
||||
// 列表获取
|
||||
$model = self::uniacid()
|
||||
->select(['id','uid'])
|
||||
->where($where)
|
||||
->when(!empty($search['nickname']),function($query) use ($search){
|
||||
// 合伙人 昵称|真实姓名搜索
|
||||
$ids = Member::where('nickname','like',"%{$search['nickname']}%")
|
||||
->orwhere('realname','like',"%{$search['nickname']}%")
|
||||
->pluck('uid');
|
||||
if($ids) $ids = $ids->toArray();
|
||||
$query->whereIn('uid',(array)$ids);
|
||||
})
|
||||
->with([
|
||||
'hasOneMember' => function($query){
|
||||
$query->select(['uid','nickname','realname','avatar']);
|
||||
}
|
||||
])
|
||||
->orderBy('created_at','DESC')
|
||||
->orderBy('id','DESC');
|
||||
$list = $model->paginate($pageSize);
|
||||
|
||||
return $list ? $list->toArray() : [];
|
||||
}
|
||||
/**
|
||||
* Common: 团队信息 - 获某个用户的所有团队业绩信息(仅获取直推团队)
|
||||
* Author: wu-hui
|
||||
* Time: 2024/01/05 13:37
|
||||
* @param $uid
|
||||
* @return array
|
||||
*/
|
||||
public static function teamGetPerformanceList($uid):array{
|
||||
// 获取直推下级列表
|
||||
$subIds = MemberChild::uniacid()
|
||||
->where('level',1)
|
||||
->where('member_id',$uid)
|
||||
->pluck('child_id')
|
||||
->toArray();
|
||||
$data = [
|
||||
'line_list' => [],// 每条线的信息
|
||||
'min_line' => [],// 业绩最少的一条线的信息
|
||||
'max_line' => [],// 业绩最多的一条线的信息
|
||||
];
|
||||
foreach($subIds as $subUid){
|
||||
$lineAllUid = MemberChild::uniacid()->where('member_id',$subUid)->pluck('child_id')->toArray();
|
||||
$lineAllUid[] = $subUid;
|
||||
$subPerformance = Order::uniacid()
|
||||
->leftJoin('yz_order_goods','yz_order_goods.order_id','yz_order.id')
|
||||
->leftJoin('yz_goods_cultural_space','yz_goods_cultural_space.goods_id','yz_order_goods.goods_id')
|
||||
->whereIn('yz_order.uid',$lineAllUid)
|
||||
->where('yz_order.status','>',0)
|
||||
->where('yz_goods_cultural_space.is_open',1)
|
||||
->sum('yz_order_goods.payment_amount');
|
||||
// 信息处理赋值
|
||||
$currentLineData = [
|
||||
'sub_uid' => $subUid,
|
||||
'line_all_uid' => implode(',',$lineAllUid),
|
||||
'performance' => $subPerformance,
|
||||
];
|
||||
$data['line_list'][] = $currentLineData;
|
||||
// 判断:当前线是否为最小业绩
|
||||
if((float)$currentLineData['performance'] < (float)$data['min_line']['performance'] || (float)$data['min_line']['performance'] <= 0){
|
||||
$data['min_line'] = $currentLineData;
|
||||
}
|
||||
// 判断:当前线是否为大区业绩
|
||||
if((float)$currentLineData['performance'] > (float)$data['max_line']['performance']){
|
||||
$data['max_line'] = $currentLineData;
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* Common: 团队信息 - 获取全部经销商的小区业绩之和
|
||||
* Author: wu-hui
|
||||
* Time: 2024/01/05 14:08
|
||||
* @return float|int
|
||||
*/
|
||||
public static function teamMinAreaSumAmount(){
|
||||
// 小区业绩 = 总业绩 - 最大一条线的业绩
|
||||
$uidList = self::uniacid()->pluck('uid');
|
||||
$totalPerformance = 0;// 全平台所有用户小区业绩之和
|
||||
foreach($uidList as $uid){
|
||||
// 获取团队业绩信息
|
||||
$teamPerformance = (new CulturalSpace())->getTeamOrderAmount($uid);
|
||||
$totalPerformance += (float)$teamPerformance['area_amount'];
|
||||
}
|
||||
|
||||
return $totalPerformance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
@extends('layouts.base')
|
||||
<style>
|
||||
.user{
|
||||
display: inline-flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
overflow: hidden;
|
||||
height: 80px;
|
||||
}
|
||||
.user .user-avatar{
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
margin-right: 5px;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
}
|
||||
.user .user-avatar .avatar-image{
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
}
|
||||
.user .user-info{
|
||||
height: 50px;
|
||||
text-align: left;
|
||||
}
|
||||
.user .user-info .user-nickname{
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.user .user-info .user-status{
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.area-sum-amount{
|
||||
font-size: 15px;
|
||||
}
|
||||
</style>
|
||||
@section('content')
|
||||
<div class="w1200 m0a" id="storeManagerIndex">
|
||||
{{--顶部搜索--}}
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-body">
|
||||
<form action="" method="post" class="form-horizontal" role="form" id="form1">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-11 col-xs-12">
|
||||
<div class="row row-fix tpl-category-container" >
|
||||
<div class="col-xs-12 col-sm-8 col-lg-3">
|
||||
<input class="form-control" name="search[uid]" id="" type="text" value="{{ $search['uid'] }}" placeholder="用户ID">
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-8 col-lg-3">
|
||||
<input class="form-control" name="search[nickname]" id="" type="text" value="{{ $search['nickname'] }}" placeholder="用户昵称|真实姓名">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-xs-12 col-sm-6 col-lg-6">
|
||||
<button class="btn btn-success" id="search"><i class="fa fa-search"></i> 搜索</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{{--信息列表--}}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body" style="padding-top: 0;margin-bottom: 30px;overflow: auto;padding-right: 30px;">
|
||||
<div class="area-sum-amount">小区总业绩:{{ $min_area_sum_amount }}</div>
|
||||
<table class="table" style="min-width:1500px;overflow: auto;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align:center;width: 80px;">UID</th>
|
||||
<th style="text-align:center;">店长信息</th>
|
||||
<th style="text-align:center;">总业绩</th>
|
||||
<th style="text-align:center;">小区业绩 / 平台小区业绩占比</th>
|
||||
<th style="text-align:center;">大区业绩</th>
|
||||
<th style="text-align:center;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($list as $item)
|
||||
<tr style="height: 50px;">
|
||||
<td style="text-align:center;">{{ $item['uid'] }}</td>
|
||||
<td style="text-align:center;" >
|
||||
<div class="user">
|
||||
<div class="user-avatar">
|
||||
<img class="avatar-image" src="{{$item['has_one_member']['avatar_image']}}" />
|
||||
</div>
|
||||
<div class="user-info">
|
||||
<div class="user-nickname">{{ $item['has_one_member']['username'] ? : $item['has_one_member']['nickname'] }}</div>
|
||||
<div class="user-status">ID:{{ $item['has_one_member']['uid'] }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td style="text-align:center;">{{ $item['team_performance']['team_amount'] ?? '0.00' }}</td>
|
||||
<td style="text-align:center;">{{ $item['team_performance']['area_amount'] ?? '0.00'}} / {{ $item['team_performance']['area_amount_rate'] ?? '0'}}%</td>
|
||||
<td style="text-align:center;">{{ $item['team_performance']['max_amount'] ?? '0.00' }}</td>
|
||||
<td style="text-align:center;">
|
||||
<button onclick="seeInfo({{$item['uid']}})" type="button" class="btn btn-info btn-sm">团队业绩明细</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
{!! $pager !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
// 查看店长业绩及补助信息
|
||||
function seeInfo(uid){
|
||||
let link = "{{yzWebUrl('plugin.team-dividend.admin.team.teamPerformanceList')}}" + `&uid=${uid}`;
|
||||
let popup = util.ajaxshow(link,'查看团队业绩明细',{
|
||||
width: $(window).width() * 0.8 > 1200 ? $(window).width() * 0.8 : 1200,
|
||||
height: $(window).height() * 0.8 > 1200 ? $(window).height() * 0.8 : 1200,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<style>
|
||||
.performance-content{
|
||||
display: inline-flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.performance-content .min-performance{
|
||||
font-size: 12px;
|
||||
font-weight: unset;
|
||||
margin-left: 10px;
|
||||
background-color: #f56c6c;
|
||||
border-color: #f56c6c;
|
||||
color: #fff;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
padding: 0 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.performance-content .max-performance{
|
||||
font-size: 12px;
|
||||
font-weight: unset;
|
||||
margin-left: 10px;
|
||||
background-color: #67c23a;
|
||||
border-color: #67c23a;
|
||||
color: #fff;
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
padding: 0 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
</style>
|
||||
<div class="w1200 m0a" id="storeManagerIndex">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body" style="padding-top: 0;margin-bottom: 30px;overflow: auto;padding-right: 30px;">
|
||||
<table class="table" style="min-width:1200px;overflow: auto;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align:center;">用户信息</th>
|
||||
<th style="text-align:center;">当前团队人数</th>
|
||||
<th style="text-align:center;">团队业绩</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($line_list as $item)
|
||||
<tr style="height: 50px;">
|
||||
<td style="text-align:center;" >
|
||||
<div class="user">
|
||||
<div class="user-avatar">
|
||||
<img class="avatar-image" src="{{$user_list[$item['sub_uid']]['avatar_image']}}" />
|
||||
</div>
|
||||
<div class="user-info">
|
||||
<div class="user-nickname">{{ $user_list[$item['sub_uid']]['username'] ? : $user_list[$item['sub_uid']]['nickname'] }}</div>
|
||||
<div class="user-status">ID:{{ $user_list[$item['sub_uid']]['uid'] }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td style="text-align:center;">{{ count(explode(',',$item['line_all_uid'])) }}</td>
|
||||
<td style="text-align:center;">
|
||||
<div class="performance-content">
|
||||
{{ $item['performance'] }}
|
||||
@if(count($line_list) > 1)
|
||||
@if($item['sub_uid'] == $min_line['sub_uid'])<span class="min-performance"> 最大业绩 </span>@endif
|
||||
@if($item['sub_uid'] == $max_line['sub_uid'])<span class="max-performance"> 最小业绩 </span>@endif
|
||||
@endif
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Loading…
Reference in New Issue