添加:贡献值分红记录及周期记录查看功能
This commit is contained in:
parent
25c8dad298
commit
4ab3844682
|
|
@ -70,7 +70,7 @@ class PluginApplication extends \app\common\services\PluginApplication{
|
|||
'child' => [
|
||||
// 权限补充
|
||||
'plugin_cultural_space_contribution_index' => [
|
||||
'name' => '变更明细',
|
||||
'name' => '贡献值管理',
|
||||
'url' => 'plugin.cultural-space.admin.contribution.index',
|
||||
'url_params' => '',
|
||||
'permit' => 1,
|
||||
|
|
@ -79,26 +79,6 @@ class PluginApplication extends \app\common\services\PluginApplication{
|
|||
'item' => 'plugin_cultural_space_contribution_index',
|
||||
'parents' => ['cultural-space','plugin_cultural_space_contribution']
|
||||
],
|
||||
'plugin_cultural_space_contribution_hold' => [
|
||||
'name' => '用户持有统计',
|
||||
'url' => 'plugin.cultural-space.admin.contribution.hold',
|
||||
'url_params' => '',
|
||||
'permit' => 1,
|
||||
'menu' => 0,
|
||||
'icon' => '',
|
||||
'item' => 'plugin_cultural_space_contribution_hold',
|
||||
'parents' => ['cultural-space','plugin_cultural_space_contribution']
|
||||
],
|
||||
'plugin_cultural_space_contribution_bonus' => [
|
||||
'name' => '分红记录',
|
||||
'url' => 'plugin.cultural-space.admin.contribution.bonus',
|
||||
'url_params' => '',
|
||||
'permit' => 1,
|
||||
'menu' => 0,
|
||||
'icon' => '',
|
||||
'item' => 'plugin_cultural_space_contribution_bonus',
|
||||
'parents' => ['cultural-space','plugin_cultural_space_contribution']
|
||||
],
|
||||
]
|
||||
],
|
||||
'plugin_cultural_space_set' => [
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@
|
|||
namespace Yunshop\CulturalSpace\admin;
|
||||
|
||||
use app\common\components\BaseController;
|
||||
use Yunshop\CulturalSpace\models\ContributionBonus;
|
||||
use Yunshop\CulturalSpace\models\ContributionBonusLog;
|
||||
use Yunshop\CulturalSpace\models\ContributionLog;
|
||||
use Yunshop\CulturalSpace\models\CulturalSpace;
|
||||
|
||||
class ContributionController extends BaseController{
|
||||
|
||||
|
||||
/**
|
||||
* Common: 变更明细
|
||||
* Author: wu-hui
|
||||
|
|
@ -19,18 +20,14 @@ class ContributionController extends BaseController{
|
|||
if(request()->isMethod('post')){
|
||||
// 参数获取
|
||||
$search = request()->input('search');
|
||||
$tabsActive = request()->input('tabs_active');
|
||||
// 获取变更记录
|
||||
$field = [
|
||||
'id',
|
||||
'uid',
|
||||
'change_type',
|
||||
'change_quantity',
|
||||
'change_front',
|
||||
'change_after',
|
||||
'remark',
|
||||
'created_at'
|
||||
];
|
||||
$result = ContributionLog::getList($search,$field);
|
||||
switch($tabsActive){
|
||||
case 'show_detail':$result = ContributionLog::getList($search);break;// 贡献值变更明细
|
||||
case 'show_group':$result = CulturalSpace::getList($search);break;// 贡献值用户持有统计
|
||||
case 'show_bonus':$result = ContributionBonusLog::getList($search);break;// 贡献值分红明细
|
||||
case 'show_cycle':$result = ContributionBonus::getList();break;// 贡献值分红周期记录
|
||||
}
|
||||
|
||||
return $this->successJson('success',[
|
||||
'current_page' => $result['current_page'],
|
||||
|
|
@ -41,30 +38,6 @@ class ContributionController extends BaseController{
|
|||
|
||||
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(){}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,34 @@ class ContributionBonus extends BaseModel{
|
|||
public $timestamps = false;
|
||||
protected $hidden = ['uniacid'];
|
||||
public $casts = [
|
||||
'start_time' => 'datetime:Y-m-d H:i:s',
|
||||
'end_time' => 'datetime:Y-m-d H:i:s',
|
||||
'created_at' => 'datetime:Y-m-d H:i:s',
|
||||
];
|
||||
protected $fillable = ['uniacid','uid','order_total_money','contribution_bonus_ratio','total_money','start_time','end_time','created_at'];
|
||||
|
||||
|
||||
/**
|
||||
* Common: 获取周期记录列表
|
||||
* Author: wu-hui
|
||||
* Time: 2023/11/03 16:00
|
||||
* @return array
|
||||
*/
|
||||
public function getList(){
|
||||
$list = self::uniacid()
|
||||
->select(['id','order_total_money','contribution_bonus_ratio','total_money','start_time','end_time','created_at'])
|
||||
->orderBy('created_at','DESC')
|
||||
->orderBy('id','DESC')
|
||||
->paginate(10);
|
||||
|
||||
return $list ? $list->toArray() : [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ namespace Yunshop\CulturalSpace\models;
|
|||
|
||||
|
||||
use app\common\models\BaseModel;
|
||||
use app\common\models\Member;
|
||||
use app\common\models\Order;
|
||||
use app\common\models\OrderGoods;
|
||||
use app\common\models\UniAccount;
|
||||
|
|
@ -24,6 +25,34 @@ class ContributionBonusLog extends BaseModel{
|
|||
private $orderTotalMoney = 0;// 周期订单总金额
|
||||
private $bonusTotalMoney = 0;// 分红总销售额(周期订单总金额的N%)
|
||||
|
||||
/**
|
||||
* Common: 获取分红记录
|
||||
* Author: wu-hui
|
||||
* Time: 2023/11/03 15:53
|
||||
* @param $search
|
||||
* @return array
|
||||
*/
|
||||
public function getList($search){
|
||||
// 条件生成
|
||||
$where = [];
|
||||
if($search['uid'] > 0) $where[] = ['uid','=',$search['uid']];
|
||||
if($search['is_settlement'] >= 0 && $search['is_settlement'] != '') $where[] = ['is_settlement','=',$search['is_settlement']];
|
||||
// 列表获取
|
||||
$list = self::uniacid()
|
||||
->select(['id','uid','total_money','money','total_contribution','hold_contribution','proportion','is_settlement','created_at'])
|
||||
->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: 贡献值分红 - 分红处理开始
|
||||
|
|
@ -192,120 +221,13 @@ class ContributionBonusLog extends BaseModel{
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Common: 店长信息统计 - 初始化
|
||||
* Common: 一对一关联 用户信息
|
||||
* Author: wu-hui
|
||||
* Time: 2023/09/18 14:46
|
||||
* Time: 2023/11/03 15:50
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
*/
|
||||
public function infoStatistics(){
|
||||
set_time_limit(0);
|
||||
try{
|
||||
// 循环平台 进行处理
|
||||
$uniAccount = UniAccount::getEnable() ?: [];
|
||||
foreach ($uniAccount as $u) {
|
||||
Setting::$uniqueAccountId = \YunShop::app()->uniacid = $u->uniacid;
|
||||
$set = Setting::get('plugin.team_dividend');
|
||||
$isRun = (boolean)$this->isRun($set);
|
||||
// 判断:允许下一步 开启店长 店补比例大于0
|
||||
if ($isRun && (int)$set['store_manager_switch'] == 1 && (float)$set['store_manager_proportion'] > 0) {
|
||||
\Log::debug('--- 经销商 - 店长统计 - 满足条件,开始处理:'.$u->uniacid);
|
||||
$this->infoStatisticsHandle($set);
|
||||
} else {
|
||||
\Log::debug('--- 经销商 - 店长统计 - 不满足条件:'.$u->uniacid);
|
||||
}
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
\Log::debug('--- 经销商 - 店长统计 - 错误:'.$e->getMessage());
|
||||
}
|
||||
public function member(){
|
||||
return $this->hasOne(Member::class,'uid','uid');
|
||||
}
|
||||
/**
|
||||
* Common: 店长信息统计 - 开始处理
|
||||
* Author: wu-hui
|
||||
* Time: 2023/09/18 14:03
|
||||
* @param $set
|
||||
*/
|
||||
public function infoStatisticsHandle($set){
|
||||
// 获取所有店长
|
||||
$storeManagerList = self::uniacid()
|
||||
->select(['id','uid'])
|
||||
->where('status',1)
|
||||
->orderBy('id','DESC')
|
||||
->get();
|
||||
if(!$storeManagerList){
|
||||
\Log::debug('--- 经销商 - 店长统计 - 没有店长信息');
|
||||
return;
|
||||
}
|
||||
// 订单查询条件
|
||||
$storeManagerCycle = $set['store_manager_cycle'] ?? 'last_month';
|
||||
[$startTime,$endTime] = getTimeStamp($storeManagerCycle);
|
||||
$where = [
|
||||
['yz_order.pay_time','>=',$startTime],
|
||||
['yz_order.pay_time','<',$endTime],
|
||||
['yz_order_goods.payment_amount','>',0],// 实际支付金额必须大于0
|
||||
];
|
||||
// 循环处理店长
|
||||
$storeIds = array_column($storeManagerList->toArray(),'uid');
|
||||
$insertData = [];
|
||||
$time = time();
|
||||
foreach($storeManagerList as $storeInfo){
|
||||
// 获取全部有效下级
|
||||
$validChild = $this->getValidChild($storeInfo->uid,$storeIds);
|
||||
$validChild[] = $storeInfo->uid;// 包括本人
|
||||
// 获取团队全部订单,这里以订单商品的实际支付价格算;统计已支付-待发货,已支付-待收货,已完成订单
|
||||
$totalMoney = (float)OrderGoods::uniacid()
|
||||
->join('yz_order', 'yz_order_goods.order_id', '=','yz_order.id')
|
||||
->where($where)
|
||||
->whereIn('yz_order.status',[Order::WAIT_SEND,Order::WAIT_RECEIVE,Order::COMPLETE])
|
||||
->whereIn('yz_order.uid',$validChild)
|
||||
->sum('yz_order_goods.payment_amount');
|
||||
$insertData[] = [
|
||||
'uniacid' => \YunShop::app()->uniacid,
|
||||
'uid' => $storeInfo->uid,
|
||||
'total_money' => $totalMoney,
|
||||
'money' => sprintf("%.2f",$totalMoney * (float)$set['store_manager_proportion'] / 100),
|
||||
'proportion' => (float)$set['store_manager_proportion'],
|
||||
'start_time' => $startTime,
|
||||
'end_time' => $endTime,
|
||||
'created_at' => $time,
|
||||
];
|
||||
}
|
||||
// 添加记录
|
||||
StoreManagerRecordModel::insert($insertData);
|
||||
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Common: 店长信息统计 - 获取店长全部有效下级(去除店长及其团队的全部下级)
|
||||
* Author: wu-hui
|
||||
* Time: 2023/09/18 13:34
|
||||
* @param $uid
|
||||
* @param $storeIds
|
||||
* @return array
|
||||
*/
|
||||
public function getValidChild($uid,$storeIds){
|
||||
$allChild = MemberChild::uniacid()->where('member_id',$uid)->pluck('child_id')->toArray();
|
||||
$diff = array_values(array_intersect($allChild,$storeIds));// 获取交集 判断下级中是否存在店长
|
||||
if(count($diff) > 0){
|
||||
// 下级中存在店长 进行处理,剔除所有店长及其团队成员
|
||||
$subAllChild = MemberChild::uniacid()->whereIn('member_id',$diff)->pluck('child_id')->toArray();
|
||||
$delIds = array_values(array_merge($diff,$subAllChild));
|
||||
$allChild = array_diff($allChild,$delIds);
|
||||
}
|
||||
|
||||
return $allChild;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,17 +34,25 @@ class ContributionLog extends BaseModel{
|
|||
* Author: wu-hui
|
||||
* Time: 2023/11/03 9:39
|
||||
* @param $search
|
||||
* @param string[] $field
|
||||
* @return array
|
||||
*/
|
||||
public function getList($search,$field = ['*']){
|
||||
public function getList($search){
|
||||
// 条件生成
|
||||
$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)
|
||||
->select([
|
||||
'id',
|
||||
'uid',
|
||||
'change_type',
|
||||
'change_quantity',
|
||||
'change_front',
|
||||
'change_after',
|
||||
'remark',
|
||||
'created_at'
|
||||
])
|
||||
->where($where)
|
||||
->with([
|
||||
'member' => function($query){
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@
|
|||
</el-form-item>
|
||||
</el-form>
|
||||
{{--表单--}}
|
||||
<el-table :data="list" style="width: 100%">
|
||||
<el-table :data="list" style="width: 100%" v-if="tabs_active == 'show_detail'">
|
||||
<el-table-column align="center" prop="id" label="ID" width="80"></el-table-column>
|
||||
<el-table-column align="center" prop="member" label="用户信息" width="230">
|
||||
<template slot-scope="scope">
|
||||
|
|
@ -122,7 +122,7 @@
|
|||
</el-form-item>
|
||||
</el-form>
|
||||
{{--表单--}}
|
||||
<el-table :data="list" style="width: 100%">
|
||||
<el-table :data="list" style="width: 100%" v-if="tabs_active == 'show_group'">
|
||||
<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">
|
||||
|
|
@ -156,13 +156,16 @@
|
|||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
|
||||
|
||||
|
||||
|
||||
<el-tab-pane label="分红记录" name="show_bonus">
|
||||
<el-tab-pane label="分红明细" name="show_bonus">
|
||||
{{--搜索--}}
|
||||
<el-form :inline="true" :model="search_info">
|
||||
<el-form-item label="是否结算">
|
||||
<el-select v-model="search_info.is_settlement" placeholder="全部">
|
||||
<el-option label="全部" value=""></el-option>
|
||||
<el-option label="未结算" value="0"></el-option>
|
||||
<el-option label="已结算" value="1"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="会员ID">
|
||||
<el-input v-model="search_info.uid" placeholder="请输入会员ID"></el-input>
|
||||
</el-form-item>
|
||||
|
|
@ -171,7 +174,7 @@
|
|||
</el-form-item>
|
||||
</el-form>
|
||||
{{--表单--}}
|
||||
<el-table :data="list" style="width: 100%">
|
||||
<el-table :data="list" style="width: 100%" v-if="tabs_active == 'show_bonus'">
|
||||
<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">
|
||||
|
|
@ -188,23 +191,43 @@
|
|||
</el-table-column>
|
||||
<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-default">总销售额</span>
|
||||
<span class="label label-info">分红</span>
|
||||
<span class="label label-warning">占比(%)</span>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<span class="label label-default">[[scope.row.total_quantity || '0.00' ]]</span>
|
||||
<span class="label label-info">[[scope.row.quantity || '0.00' ]]</span>
|
||||
<span class="label label-warning">[[scope.row.ratio ? scope.row.ratio + '%' : '0.00' ]]</span>
|
||||
<span class="label label-default">[[scope.row.total_money || '0.00' ]]</span>
|
||||
<span class="label label-info">[[scope.row.money || '0.00' ]]</span>
|
||||
<span class="label label-warning">[[scope.row.proportion ? scope.row.proportion + '%' : '0.00' ]]</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" prop="created_at" label="操作">
|
||||
<el-table-column align="center" prop="is_settlement" label="是否结算">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="primary" @click="seeDetail(scope.row.uid,scope.row.team_dividend_agency_level_id)">变更明细</el-button>
|
||||
<el-tag :type="scope.row.is_settlement == 0 ? 'danger' : 'success'" disable-transitions>
|
||||
[[scope.row.is_settlement == 0 ? '未结算' : '已结算']]
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="分红周期记录" name="show_cycle">
|
||||
<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="order_total_money" label="订单总金额" width="150"></el-table-column>
|
||||
<el-table-column align="center" prop="contribution_bonus_ratio" label="销售额比例" width="150">
|
||||
<template slot-scope="scope">
|
||||
[[ scope.row.contribution_bonus_ratio + '%']]
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" prop="total_money" label="总销售额" width="150"></el-table-column>
|
||||
<el-table-column align="center" label="统计时间段" min-width="400">
|
||||
<template slot-scope="scope">
|
||||
[[scope.row.start_time]] ~ [[scope.row.end_time]]
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" prop="created_at" label="处理时间" width="200"></el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
{{--分页--}}
|
||||
<el-pagination
|
||||
|
|
@ -234,6 +257,7 @@
|
|||
search_info: {
|
||||
uid: '',
|
||||
change_type: '',
|
||||
is_settlement: '',
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -246,18 +270,14 @@
|
|||
getData(){
|
||||
let _this = this;
|
||||
let loading = _this.showLoading();
|
||||
// 获取请求地址
|
||||
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({
|
||||
url: link,
|
||||
url: "{!! yzWebUrl('plugin.cultural-space.admin.contribution.index') !!}",
|
||||
type: "post",
|
||||
data: {
|
||||
page: _this.page,
|
||||
search: _this.search_info,
|
||||
is_get: 1
|
||||
tabs_active: _this.tabs_active,
|
||||
},
|
||||
success: function(result) {
|
||||
let data = result.data;
|
||||
|
|
@ -304,10 +324,6 @@
|
|||
this.tabs_active = 'show_detail';
|
||||
this.getData()
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue