添加:贡献值变更明细、用户持有统计查看列表
This commit is contained in:
parent
e776d98a33
commit
32415773b0
|
|
@ -2,21 +2,67 @@
|
||||||
namespace Yunshop\CulturalSpace\admin;
|
namespace Yunshop\CulturalSpace\admin;
|
||||||
|
|
||||||
use app\common\components\BaseController;
|
use app\common\components\BaseController;
|
||||||
|
use Yunshop\CulturalSpace\models\ContributionLog;
|
||||||
|
use Yunshop\CulturalSpace\models\CulturalSpace;
|
||||||
|
|
||||||
class ContributionController extends BaseController{
|
class ContributionController extends BaseController{
|
||||||
|
|
||||||
// 列表
|
|
||||||
|
/**
|
||||||
|
* Common: 变更明细
|
||||||
|
* Author: wu-hui
|
||||||
|
* Time: 2023/11/03 9:40
|
||||||
|
* @return array|\Illuminate\Http\JsonResponse|string
|
||||||
|
* @throws \Throwable
|
||||||
|
*/
|
||||||
public function index(){
|
public function index(){
|
||||||
|
if(request()->isMethod('post')){
|
||||||
|
// 参数获取
|
||||||
|
$search = request()->input('search');
|
||||||
|
// 获取变更记录
|
||||||
|
$field = [
|
||||||
|
'id',
|
||||||
|
'uid',
|
||||||
|
'change_type',
|
||||||
|
'change_quantity',
|
||||||
|
'change_front',
|
||||||
|
'change_after',
|
||||||
|
'remark',
|
||||||
|
'created_at'
|
||||||
|
];
|
||||||
|
$result = ContributionLog::getList($search,$field);
|
||||||
|
|
||||||
|
return $this->successJson('success',[
|
||||||
|
'current_page' => $result['current_page'],
|
||||||
|
'data' => $result['data'],
|
||||||
|
'last_page' => $result['last_page'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
return view('Yunshop\CulturalSpace::contribution.index')->render();
|
return view('Yunshop\CulturalSpace::contribution.index')->render();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Common: 用户持有统计
|
||||||
|
* Author: wu-hui
|
||||||
|
* Time: 2023/11/03 10:03
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
|
public function hold(){
|
||||||
|
// 参数获取
|
||||||
|
$search = request()->input('search');
|
||||||
|
// 获取记录
|
||||||
|
$result = CulturalSpace::getList($search);
|
||||||
|
|
||||||
|
return $this->successJson('success',[
|
||||||
|
'current_page' => $result['current_page'],
|
||||||
|
'data' => $result['data'],
|
||||||
|
'last_page' => $result['last_page'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// 分红记录
|
||||||
|
public function bonus(){}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ namespace Yunshop\CulturalSpace\models;
|
||||||
|
|
||||||
|
|
||||||
use app\common\models\BaseModel;
|
use app\common\models\BaseModel;
|
||||||
|
use app\common\models\Member;
|
||||||
|
|
||||||
class ContributionLog extends BaseModel{
|
class ContributionLog extends BaseModel{
|
||||||
|
|
||||||
|
|
@ -27,13 +28,46 @@ class ContributionLog extends BaseModel{
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common: 贡献值变更记录
|
||||||
|
* Author: wu-hui
|
||||||
|
* Time: 2023/11/03 9:39
|
||||||
|
* @param $search
|
||||||
|
* @param string[] $field
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getList($search,$field = ['*']){
|
||||||
|
// 条件生成
|
||||||
|
$where = [];
|
||||||
|
if($search['uid'] > 0) $where[] = ['uid','=',$search['uid']];
|
||||||
|
if($search['change_type'] >= 0 && $search['change_type'] != '') $where[] = ['change_type','=',$search['change_type']];
|
||||||
|
// 列表获取
|
||||||
|
$list = self::uniacid()
|
||||||
|
->select($field)
|
||||||
|
->where($where)
|
||||||
|
->with([
|
||||||
|
'member' => function($query){
|
||||||
|
$query->select(['uid','nickname','realname','avatar']);
|
||||||
|
}
|
||||||
|
])
|
||||||
|
->orderBy('created_at','DESC')
|
||||||
|
->orderBy('id','DESC')
|
||||||
|
->paginate(10);
|
||||||
|
|
||||||
|
return $list ? $list->toArray() : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common: 一对一关联 用户信息
|
||||||
|
* Author: wu-hui
|
||||||
|
* Time: 2023/11/03 9:35
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||||
|
*/
|
||||||
|
public function member(){
|
||||||
|
return $this->hasOne(Member::class,'uid','uid');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,40 @@ class CulturalSpace extends BaseModel{
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common: 贡献值持有信息列表
|
||||||
|
* Author: wu-hui
|
||||||
|
* Time: 2023/11/03 9:51
|
||||||
|
* @param $search
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getList($search){
|
||||||
|
// 条件生成
|
||||||
|
$where = [];
|
||||||
|
if($search['uid'] > 0) $where[] = ['uid','=',$search['uid']];
|
||||||
|
// 查询model
|
||||||
|
$model = self::uniacid()
|
||||||
|
->where($where)
|
||||||
|
->with([
|
||||||
|
'member' => function($query){
|
||||||
|
$query->select(['uid','nickname','realname','avatar']);
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
// 信息获取
|
||||||
|
$totalContribution = $model->sum('contribution');
|
||||||
|
$list = $model->select(['id','uid','contribution'])
|
||||||
|
->orderBy('id','DESC')
|
||||||
|
->paginate(10)
|
||||||
|
->toArray();
|
||||||
|
foreach($list['data'] as &$item){
|
||||||
|
$item['total_proportion'] = (float)sprintf("%.2f",$totalContribution);
|
||||||
|
$item['ratio'] = (float)sprintf("%.2f",$item['contribution'] / $totalContribution * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common: 购买商品奖励贡献值
|
* Common: 购买商品奖励贡献值
|
||||||
* Author: wu-hui
|
* Author: wu-hui
|
||||||
|
|
@ -152,4 +186,15 @@ class CulturalSpace extends BaseModel{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common: 一对一关联 用户信息
|
||||||
|
* Author: wu-hui
|
||||||
|
* Time: 2023/11/03 9:35
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||||
|
*/
|
||||||
|
public function member(){
|
||||||
|
return $this->hasOne(Member::class,'uid','uid');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,21 +34,6 @@
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
.level_0{
|
|
||||||
background-color: #5bc0de!important;
|
|
||||||
}
|
|
||||||
.level_1{
|
|
||||||
background-color: #f0ad4e!important;
|
|
||||||
}
|
|
||||||
.level_2{
|
|
||||||
background-color: #5cb85c!important;
|
|
||||||
}
|
|
||||||
.level_3{
|
|
||||||
background-color: #337ab7!important;
|
|
||||||
}
|
|
||||||
.level_4{
|
|
||||||
background-color: #d9534f!important;
|
|
||||||
}
|
|
||||||
.panel-body .label{
|
.panel-body .label{
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
|
|
@ -81,22 +66,16 @@
|
||||||
<el-tabs v-model="tabs_active" @tab-click="changeTabs">
|
<el-tabs v-model="tabs_active" @tab-click="changeTabs">
|
||||||
<el-tab-pane label="变更明细" name="show_detail">
|
<el-tab-pane label="变更明细" name="show_detail">
|
||||||
{{--搜索--}}
|
{{--搜索--}}
|
||||||
<el-form :inline="true" :model="search_list">
|
<el-form :inline="true" :model="search_info">
|
||||||
<el-form-item label="变更类型">
|
<el-form-item label="变更类型">
|
||||||
<el-select v-model="search_list.change_type" placeholder="全部">
|
<el-select v-model="search_info.change_type" placeholder="全部">
|
||||||
<el-option label="全部" value=""></el-option>
|
<el-option label="全部" value=""></el-option>
|
||||||
<el-option label="减少" value="0"></el-option>
|
<el-option label="减少" value="0"></el-option>
|
||||||
<el-option label="增加" value="1"></el-option>
|
<el-option label="增加" value="1"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="会员ID">
|
<el-form-item label="会员ID">
|
||||||
<el-input v-model="search_list.member_id" placeholder="请输入会员ID"></el-input>
|
<el-input v-model="search_info.uid" placeholder="请输入会员ID"></el-input>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="权重值类型">
|
|
||||||
<el-select v-model="search_list.team_dividend_agency_level_id" placeholder="全部">
|
|
||||||
<el-option label="全部" value=""></el-option>
|
|
||||||
<el-option v-for="(item,index) in level_list" :key="index" :label="item.level_name" :value="item.id"></el-option>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="clickSearch">查询</el-button>
|
<el-button type="primary" @click="clickSearch">查询</el-button>
|
||||||
|
|
@ -128,28 +107,15 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column align="center" prop="change_quantity" label="变更数量" width="150"></el-table-column>
|
<el-table-column align="center" prop="change_quantity" label="变更数量" width="150"></el-table-column>
|
||||||
<el-table-column align="center" prop="change_after" label="变更后持有数" width="150"></el-table-column>
|
<el-table-column align="center" prop="change_after" label="变更后持有数" width="150"></el-table-column>
|
||||||
<el-table-column align="center" prop="change_quantity" label="权重值类型" width="150">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<span :class="'label level_'+scope.row.sort">
|
|
||||||
[[scope.row.level.level_name ? scope.row.level.level_name + '权重值' : '']]
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column align="center" prop="remark" label="变更原因"></el-table-column>
|
<el-table-column align="center" prop="remark" label="变更原因"></el-table-column>
|
||||||
<el-table-column align="center" prop="created_at" label="变更时间" width="200"></el-table-column>
|
<el-table-column align="center" prop="created_at" label="变更时间" width="200"></el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="统计明细" name="show_group">
|
<el-tab-pane label="用户持有统计" name="show_group">
|
||||||
{{--搜索--}}
|
{{--搜索--}}
|
||||||
<el-form :inline="true" :model="search_list">
|
<el-form :inline="true" :model="search_info">
|
||||||
<el-form-item label="会员ID">
|
<el-form-item label="会员ID">
|
||||||
<el-input v-model="search_list.member_id" placeholder="请输入会员ID"></el-input>
|
<el-input v-model="search_info.uid" placeholder="请输入会员ID"></el-input>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="权重值类型">
|
|
||||||
<el-select v-model="search_list.team_dividend_agency_level_id" placeholder="全部">
|
|
||||||
<el-option label="全部" value=""></el-option>
|
|
||||||
<el-option v-for="(item,index) in level_list" :key="index" :label="item.level_name" :value="item.id"></el-option>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="clickSearch">查询</el-button>
|
<el-button type="primary" @click="clickSearch">查询</el-button>
|
||||||
|
|
@ -171,11 +137,53 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column align="center" prop="change_quantity" label="权重值类型">
|
<el-table-column align="center" prop="change_front">
|
||||||
|
<template slot="header" slot-scope="scope">
|
||||||
|
<span class="label label-default">平台总数</span>
|
||||||
|
<span class="label label-info">用户持有</span>
|
||||||
|
<span class="label label-warning">占比(%)</span>
|
||||||
|
</template>
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span :class="'label level_'+scope.row.sort">
|
<span class="label label-default">[[scope.row.total_proportion || '0.00' ]]</span>
|
||||||
[[scope.row.level.level_name ? scope.row.level.level_name + '权重值' : '']]
|
<span class="label label-info">[[scope.row.contribution || '0.00' ]]</span>
|
||||||
</span>
|
<span class="label label-warning">[[scope.row.ratio ? scope.row.ratio + '%' : '0%' ]]</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column align="center" prop="created_at" label="操作">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button type="primary" @click="seeChangeRecord(scope.row.uid)">变更明细</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<el-tab-pane label="分红记录" name="show_bonus">
|
||||||
|
{{--搜索--}}
|
||||||
|
<el-form :inline="true" :model="search_info">
|
||||||
|
<el-form-item label="会员ID">
|
||||||
|
<el-input v-model="search_info.uid" placeholder="请输入会员ID"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="clickSearch">查询</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
{{--表单--}}
|
||||||
|
<el-table :data="list" style="width: 100%">
|
||||||
|
<el-table-column align="center" prop="id" label="ID" width="100"></el-table-column>
|
||||||
|
<el-table-column align="center" prop="member" label="用户信息" width="300">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<div class="user">
|
||||||
|
<div class="user-avatar">
|
||||||
|
<img class="avatar-image" :src="scope.row.member.avatar_image || ''" />
|
||||||
|
</div>
|
||||||
|
<div class="user-info">
|
||||||
|
<div class="user-nickname">昵称:[[scope.row.member.nickname || '']]</div>
|
||||||
|
<div class="user-status">ID:[[scope.row.member.uid || '']]</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column align="center" prop="change_front">
|
<el-table-column align="center" prop="change_front">
|
||||||
|
|
@ -192,7 +200,7 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column align="center" prop="created_at" label="操作">
|
<el-table-column align="center" prop="created_at" label="操作">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button type="primary" @click="seeDetail(scope.row.member_id,scope.row.team_dividend_agency_level_id)">变更明细</el-button>
|
<el-button type="primary" @click="seeDetail(scope.row.uid,scope.row.team_dividend_agency_level_id)">变更明细</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
@ -216,59 +224,58 @@
|
||||||
el: '#contributionIndexContent',
|
el: '#contributionIndexContent',
|
||||||
delimiters: ['[[', ']]'],
|
delimiters: ['[[', ']]'],
|
||||||
name: 'cultural_space_index_content',
|
name: 'cultural_space_index_content',
|
||||||
data: {
|
data() {
|
||||||
tabs_active: 'show_detail',
|
return {
|
||||||
level_list: JSON.parse('{!! json_encode($level_list) !!}'),
|
tabs_active: 'show_detail',
|
||||||
// 分页信息
|
// 分页信息
|
||||||
page: 1,
|
page: 1,
|
||||||
total_page: 1,
|
total_page: 1,
|
||||||
list: [],
|
list: [],
|
||||||
search_list: {
|
search_info: {
|
||||||
member_id: '',
|
uid: '',
|
||||||
team_dividend_agency_level_id: '',
|
change_type: '',
|
||||||
change_type: '',
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch:{},
|
watch:{},
|
||||||
mounted () {
|
mounted () {
|
||||||
// this.getData();
|
this.getData();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 获取数据 根据当前选项卡获取对应的信息
|
// 获取数据 根据当前选项卡获取对应的信息
|
||||||
getData(){
|
getData(){
|
||||||
let _this = this;
|
let _this = this;
|
||||||
let loading = _this.showLoading();
|
let loading = _this.showLoading();
|
||||||
let link = "{!! yzWebUrl('plugin.cultural-space.admin.index.changeRecord') !!}";
|
// 获取请求地址
|
||||||
if(_this.tabs_active === 'show_group') link = "{!! yzWebUrl('plugin.cultural-space.admin.index.changeGroupRecord') !!}";
|
let link = "{!! yzWebUrl('plugin.cultural-space.admin.contribution.index') !!}";
|
||||||
|
if(_this.tabs_active === 'show_group') link = "{!! yzWebUrl('plugin.cultural-space.admin.contribution.hold') !!}";
|
||||||
|
else if(_this.tabs_active === 'show_bonus') link = "{!! yzWebUrl('plugin.cultural-space.admin.contribution.bonus') !!}";
|
||||||
|
// 请求获取数据
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: link,
|
url: link,
|
||||||
type: "post",
|
type: "post",
|
||||||
data: {
|
data: {
|
||||||
page: _this.page,
|
page: _this.page,
|
||||||
search: _this.search_list,
|
search: _this.search_info,
|
||||||
is_get: 1
|
is_get: 1
|
||||||
},
|
},
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
loading.close(0);
|
|
||||||
let data = result.data;
|
let data = result.data;
|
||||||
if(parseInt(result.result) === 1){
|
if(parseInt(result.result) === 1){
|
||||||
// 处理数据
|
// 处理数据
|
||||||
_this.list = data.data;
|
_this.list = data.data;
|
||||||
_this.total_page = data.last_page;
|
_this.total_page = data.last_page;
|
||||||
}
|
}
|
||||||
|
loading.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 切换选项卡
|
// 切换选项卡
|
||||||
changeTabs(){
|
changeTabs(){
|
||||||
this.page = 1;
|
this.page = 1;
|
||||||
this.search_list = {
|
|
||||||
member_id: '',
|
|
||||||
team_dividend_agency_level_id: '',
|
|
||||||
change_type: '',
|
|
||||||
};
|
|
||||||
this.total_page = 1;
|
this.total_page = 1;
|
||||||
this.list = [];
|
this.list = [];
|
||||||
|
this.search_info = Object.assign({},this.$options.data().search_info);
|
||||||
this.getData();
|
this.getData();
|
||||||
},
|
},
|
||||||
// 数据分页
|
// 数据分页
|
||||||
|
|
@ -290,14 +297,17 @@
|
||||||
background: 'rgba(0, 0, 0, 0.7)'
|
background: 'rgba(0, 0, 0, 0.7)'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 查看分组的变更明细
|
// 用户持有统计中查看某个用户的贡献值变更记录
|
||||||
seeDetail(member_id,level_id){
|
seeChangeRecord(uid){
|
||||||
let link = "{{yzWebUrl('plugin.cultural-space.admin.index.changeRecord')}}" + `&member_id=${member_id}&level_id=${level_id}`;
|
this.search_info.uid = uid;
|
||||||
let popup = util.ajaxshow(link,'权重值变更明细',{
|
this.page = 1;
|
||||||
width: $(window).width() * 0.8 > 1200 ? $(window).width() * 0.8 : 1200,
|
this.tabs_active = 'show_detail';
|
||||||
height: $(window).height() * 0.8 > 1200 ? $(window).height() * 0.8 : 1200,
|
this.getData()
|
||||||
});
|
},
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue