修改:文创空间相关统计和其他普通统计分开
This commit is contained in:
parent
aedff1c1fb
commit
9c88c0fcf2
|
|
@ -317,4 +317,53 @@ class Income extends BaseModel
|
|||
}
|
||||
return $this->withdraw;
|
||||
}
|
||||
|
||||
// 获取累计收入(包括已提现收入)
|
||||
// $contentType:cultural_space=文创空间、broker=非文创空间
|
||||
public static function getAllIncome($uid,$contentType = 'all'){
|
||||
// 这里查询不包括 经销商、分销商、股东分红相关佣金
|
||||
$otherTotal = (float)Income::uniacid()
|
||||
->whereNotIn('dividend_code',[1,2,64])
|
||||
->where('member_id', $uid)
|
||||
->sum('amount');
|
||||
// 获取经销商提成 分红类型:0=分红佣金,1=平级奖,2=感恩奖励,3=额外分红,4=生态建设,5=生态贡献(生态建设平级奖),6=生态服务
|
||||
$teamDividendTotal = (float)Income::uniacid()
|
||||
->leftjoin('yz_team_dividend','yz_team_dividend.id','=','yz_member_income.incometable_id')
|
||||
->where('yz_member_income.dividend_code', 2)
|
||||
->where('yz_member_income.member_id', $uid)
|
||||
->when($contentType != 'all',function($query) use ($contentType){
|
||||
if($contentType == 'cultural_space') $query->whereIn('yz_team_dividend.type',[4,5,6]);
|
||||
else $query->whereNotIn('yz_team_dividend.type',[4,5,6]);
|
||||
})
|
||||
->sum('yz_member_income.amount');
|
||||
// 获取分销商提成 0=普通分销商订单,1=文创分销商订单
|
||||
$commissionTotal = (float)Income::uniacid()
|
||||
->leftjoin('yz_commission_order','yz_commission_order.id','=','yz_member_income.incometable_id')
|
||||
->where('yz_member_income.dividend_code', 1)
|
||||
->where('yz_member_income.member_id', $uid)
|
||||
->when($contentType != 'all',function($query) use ($contentType){
|
||||
if($contentType == 'cultural_space') $query->where('yz_commission_order.level_type',1);
|
||||
else $query->where('yz_commission_order.level_type',0);
|
||||
})
|
||||
->sum('yz_member_income.amount');
|
||||
// 获取股东分红提成 收益类型:0=股权分红,1=加权收益 权证兑换
|
||||
$shareholderDividendTotal = (float)Income::uniacid()
|
||||
->leftjoin('yz_shareholder_dividend','yz_shareholder_dividend.id','=','yz_member_income.incometable_id')
|
||||
->where('yz_member_income.dividend_code', 64)
|
||||
->where('yz_member_income.member_id', $uid)
|
||||
->when($contentType != 'all',function($query) use ($contentType){
|
||||
if($contentType == 'cultural_space') $query->where('yz_shareholder_dividend.income_type',1);
|
||||
else $query->where('yz_shareholder_dividend.income_type',0);
|
||||
})
|
||||
->sum('yz_member_income.amount');
|
||||
// 总计
|
||||
return array_sum([$otherTotal,$teamDividendTotal,$commissionTotal,$shareholderDividendTotal]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -18,6 +18,9 @@ use app\frontend\modules\member\models\MemberBankCard;
|
|||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use app\common\models\Order;
|
||||
use Yunshop\Commission\models\CommissionOrder;
|
||||
use Yunshop\ShareholderDividend\models\ShareholderDividendModel;
|
||||
use Yunshop\TeamDividend\models\TeamDividendModel;
|
||||
|
||||
class IncomeController extends ApiController
|
||||
{
|
||||
|
|
@ -100,10 +103,12 @@ class IncomeController extends ApiController
|
|||
/**
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function getIncomeList()
|
||||
{
|
||||
public function getIncomeList(){
|
||||
$uid = \YunShop::app()->getMemberId();
|
||||
$configs = \app\backend\modules\income\Income::current()->getItems();
|
||||
$type = \YunShop::request()->income_type;
|
||||
$contentType = request()->input('content_type');
|
||||
|
||||
$search = [];
|
||||
foreach ($configs as $key => $config) {
|
||||
if ($config['type'] == $type) {
|
||||
|
|
@ -112,15 +117,115 @@ class IncomeController extends ApiController
|
|||
}
|
||||
}
|
||||
$swich = \app\common\models\MemberRelation::uniacid()->select('share_page_deail')->first();
|
||||
$search['select'] = $swich->share_page_deail;
|
||||
$search['select'] = 1;//$swich->share_page_deail;
|
||||
|
||||
$incomeModel = Income::getIncomesList($search)->where('amount','>',0)->where('member_id', \YunShop::app()->getMemberId())->paginate($this->pageSize);
|
||||
if ($swich->share_page_deail) {
|
||||
$incomeModel = $this->OrderUserDetails($incomeModel);
|
||||
}
|
||||
if ($incomeModel) {
|
||||
return $this->successJson('获取数据成功!', $incomeModel);
|
||||
// 获取明细列表
|
||||
// $incomeModel = Income::getIncomesList($search)
|
||||
// ->where('amount','>',0)
|
||||
// ->where('member_id', \YunShop::app()->getMemberId())
|
||||
// ->paginate($this->pageSize);
|
||||
|
||||
$incomeModel = Income::uniacid()
|
||||
->select([
|
||||
'yz_member_income.id',
|
||||
'yz_member_income.create_month',
|
||||
'yz_member_income.incometable_type',
|
||||
'yz_member_income.type_name',
|
||||
'yz_member_income.amount',
|
||||
'yz_member_income.created_at',
|
||||
'yz_member_income.detail',
|
||||
'yz_member_income.incometable_id',
|
||||
|
||||
'yz_team_dividend.type as team_dividend_type',
|
||||
'yz_commission_order.level_type as commission_type',
|
||||
'yz_shareholder_dividend.income_type as shareholder_dividend_type',
|
||||
])
|
||||
->leftJoin('yz_team_dividend', function ($join){
|
||||
$join->on('yz_team_dividend.id', 'yz_member_income.incometable_id')
|
||||
->where('yz_member_income.dividend_code', 2);
|
||||
})
|
||||
->leftJoin('yz_commission_order', function ($join) {
|
||||
$join->on('yz_commission_order.id', 'yz_member_income.incometable_id')
|
||||
|
||||
->where('yz_member_income.dividend_code', 1);
|
||||
})
|
||||
->leftJoin('yz_shareholder_dividend', function ($join) {
|
||||
$join->on('yz_shareholder_dividend.id', 'yz_member_income.incometable_id')
|
||||
->where('yz_member_income.dividend_code', 64);
|
||||
})
|
||||
->when($contentType != 'all',function($query) use ($contentType){
|
||||
if($contentType == 'cultural_space') {
|
||||
// 文创空间相关
|
||||
$query->where(function($subQuery){
|
||||
$subQuery->where(function($threeQuery){
|
||||
$threeQuery->where('yz_member_income.dividend_code',2)->whereIn('yz_team_dividend.type',[4,5,6]);
|
||||
})->orWhere(function($threeQuery){
|
||||
$threeQuery->where('yz_member_income.dividend_code',1)->where('yz_commission_order.level_type',1);
|
||||
})->orWhere(function($threeQuery){
|
||||
$threeQuery->where('yz_member_income.dividend_code',64)->where('yz_shareholder_dividend.income_type',1);
|
||||
})->orWhere(function($threeQuery){
|
||||
$threeQuery->whereNotIn('yz_member_income.dividend_code',[1,2,64]);
|
||||
});
|
||||
});
|
||||
}
|
||||
else if($contentType == 'broker') {
|
||||
// 非文创空间相关
|
||||
$query->where(function($subQuery){
|
||||
$subQuery->where(function($threeQuery){
|
||||
$threeQuery->where('yz_member_income.dividend_code',2)->whereNotIn('yz_team_dividend.type',[4,5,6]);
|
||||
})->orWhere(function($threeQuery){
|
||||
$threeQuery->where('yz_member_income.dividend_code',1)->where('yz_commission_order.level_type',0);
|
||||
})->orWhere(function($threeQuery){
|
||||
$threeQuery->where('yz_member_income.dividend_code',64)->where('yz_shareholder_dividend.income_type',0);
|
||||
})->orWhere(function($threeQuery){
|
||||
$threeQuery->whereNotIn('yz_member_income.dividend_code',[1,2,64]);
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
->where('yz_member_income.member_id', $uid)
|
||||
->when(!empty($search['type']),function($query) use ($search){
|
||||
$query->where('yz_member_income.incometable_type', $search['type']);
|
||||
})
|
||||
->orderBy('yz_member_income.id', 'desc')
|
||||
->paginate($this->pageSize);
|
||||
|
||||
if ($swich->share_page_deail) $incomeModel = $this->OrderUserDetails($incomeModel);
|
||||
// 循环处理
|
||||
if($incomeModel){
|
||||
$incomeModel = $incomeModel->toArray();
|
||||
foreach($incomeModel['data'] as &$incomeItem){
|
||||
if($incomeItem['commission_type'] == 1) $incomeItem['type_name'] = '生态发展';
|
||||
else if($incomeItem['team_dividend_type'] == 4) $incomeItem['type_name'] = '生态建设';
|
||||
else if($incomeItem['team_dividend_type'] == 5) $incomeItem['type_name'] = '生态贡献';
|
||||
else if($incomeItem['team_dividend_type'] == 6) $incomeItem['type_name'] = '生态服务';
|
||||
else if($incomeItem['shareholder_dividend_type'] == 1) $incomeItem['type_name'] = '权证兑换';//'加权收益';
|
||||
// switch($incomeItem['incometable_type']){
|
||||
// // 分销商相关处理
|
||||
// case 'Yunshop\Commission\models\CommissionOrder':
|
||||
// // 0=普通分销商订单,1=文创分销商订单
|
||||
//
|
||||
// $commissionLevelType = CommissionOrder::where('id',$incomeItem['incometable_id'])->value('level_type');
|
||||
// if($commissionLevelType == 1) $incomeItem['type_name'] = '生态发展';
|
||||
// break;
|
||||
// // 经销商相关处理
|
||||
// case 'Yunshop\TeamDividend\models\TeamDividendModel':
|
||||
// // 分红类型:0=分红佣金,1=平级奖,2=感恩奖励,3=额外分红,4=生态建设,5=生态贡献(生态建设平级奖),6=生态服务
|
||||
// $teamDividendType = TeamDividendModel::where('id',$incomeItem['incometable_id'])->value('type');
|
||||
// if($teamDividendType == 4) $incomeItem['type_name'] = '生态建设';
|
||||
// else if($teamDividendType == 5) $incomeItem['type_name'] = '生态贡献';
|
||||
// else if($teamDividendType == 6) $incomeItem['type_name'] = '生态服务';
|
||||
// break;
|
||||
// // 股东分红相关处理
|
||||
// case 'Yunshop\ShareholderDividend\models\ShareholderDividendModel':
|
||||
// $shareholderDividendType = ShareholderDividendModel::where('id',$incomeItem['incometable_id'])->value('income_type');
|
||||
// if($shareholderDividendType == 1) $incomeItem['type_name'] = '加权收益';
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
// 输入成功
|
||||
if ($incomeModel) return $this->successJson('获取数据成功!', $incomeModel);
|
||||
return $this->errorJson('未检测到数据!');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,19 +74,38 @@ class IncomeWithdrawController extends ApiController
|
|||
* 可提现数据接口【完成】
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function getWithdraw()
|
||||
{
|
||||
public function getWithdraw(){
|
||||
$contentType = request()->input('content_type');
|
||||
|
||||
return $this->successJson('获取数据成功!', $this->computeWithdraw($contentType));
|
||||
}
|
||||
//计算佣金相关内容 $contentType:cultural_space=文创空间、broker=非文创空间
|
||||
public function computeWithdraw($contentType = 'all'){
|
||||
$shopEsign = $this->shopEsign();
|
||||
|
||||
// 区分 是否仅获取文创空间 || 非文创空间
|
||||
$income_config = \app\backend\modules\income\Income::current()->getItems();
|
||||
$culturalContentType = ['commission_share_reward','contributionBonus','weight_income','ecological_services','ecological_construction','ecological_contribution'];
|
||||
if($contentType == 'cultural_space'){
|
||||
//仅获取文创空间相关
|
||||
foreach($income_config as $incomeHandleKey => $incomeHandleItem){
|
||||
if(!in_array($incomeHandleItem['type'],$culturalContentType)){
|
||||
unset($income_config[$incomeHandleKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if($contentType == 'broker'){
|
||||
// 仅获取非文创空间相关
|
||||
foreach($income_config as $incomeHandleKey => $incomeHandleItem){
|
||||
if(in_array($incomeHandleItem['type'],$culturalContentType)){
|
||||
unset($income_config[$incomeHandleKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$income_data = [];
|
||||
|
||||
$loveName = '爱心值';
|
||||
if (app('plugins')->isEnabled('love')) {
|
||||
$loveName = LOVE_NAME;
|
||||
|
||||
}
|
||||
if (app('plugins')->isEnabled('love')) $loveName = LOVE_NAME;
|
||||
$deductionLove = [
|
||||
'love_name' => $loveName,
|
||||
'deduction_type' => 0,
|
||||
|
|
@ -94,7 +113,6 @@ class IncomeWithdrawController extends ApiController
|
|||
'deduction_value' => 0,
|
||||
'deduction_status' => 0,
|
||||
];
|
||||
|
||||
$all_withdraw_income = 0;
|
||||
foreach ($income_config as $key => $income) {
|
||||
//余额不计算 拍卖预付款不计算
|
||||
|
|
@ -121,7 +139,6 @@ class IncomeWithdrawController extends ApiController
|
|||
$income_data[] = $data;
|
||||
}
|
||||
|
||||
|
||||
//增加经销商提现显示口爱心值
|
||||
if ($income['type'] == 'teamDividend') {
|
||||
$teamDividendWithdraw = (new IncomeWithdrawApply());
|
||||
|
|
@ -133,7 +150,7 @@ class IncomeWithdrawController extends ApiController
|
|||
}
|
||||
|
||||
$withdraw_rich_text = WithdrawRichText::uniacid()->first() ?: [];
|
||||
$data = [
|
||||
return [
|
||||
'data' => $income_data,
|
||||
'setting' => [
|
||||
'balance_special' => $this->getBalanceSpecialSet(),
|
||||
|
|
@ -147,9 +164,9 @@ class IncomeWithdrawController extends ApiController
|
|||
'all_withdraw_income' => $all_withdraw_income ?: 0.00,
|
||||
'need_sign' => $this->needSign(),
|
||||
];
|
||||
return $this->successJson('获取数据成功!', $data);
|
||||
}
|
||||
|
||||
|
||||
private function needSign()
|
||||
{
|
||||
if (!app('plugins')->isEnabled('shop-esign-v2')) {
|
||||
|
|
@ -537,7 +554,7 @@ class IncomeWithdrawController extends ApiController
|
|||
->get()->toArray();
|
||||
}
|
||||
else if($income['type'] == 'weight_income'){
|
||||
// 股东分红 - 加权收益
|
||||
// 股东分红 - 加权收益 权证兑换
|
||||
$amountList = ShareholderDividendModel::getIncome((int)$uid,(int)1,'undrawn')
|
||||
->select(['yz_member_income.id','yz_member_income.amount'])
|
||||
->get()->toArray();
|
||||
|
|
|
|||
|
|
@ -64,13 +64,13 @@
|
|||
{{--分享奖励提现设置--}}
|
||||
<div class="vue-main-title">
|
||||
<div class="vue-main-title-left"></div>
|
||||
<div class="vue-main-title-content">分享奖励设置</div>
|
||||
<div class="vue-main-title-content">生态发展奖励设置</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-12 col-sm-3 col-md-2 control-label">提现额度</label>
|
||||
<div class="col-sm-9 col-xs-12">
|
||||
<input type="text" name="withdraw[commission_share_reward][roll_out_limit]" class="form-control" value="{{$commissionShareReward['roll_out_limit']}}"/>
|
||||
<span class="help-block">当前分销商的佣金达到此额度时才能提现</span>
|
||||
<span class="help-block">当前生态发展奖励达到此额度时才能提现</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class IndexController extends ApiController{
|
|||
case 'team_performance':
|
||||
$result = $this->getPerformanceChangeList($uid);
|
||||
break;
|
||||
// 加权收益明细
|
||||
// 加权收益明细 权证兑换
|
||||
case 'weight_income':
|
||||
$result = ShareholderDividendModel::getIncome((int)$uid,(int)1)
|
||||
->select([
|
||||
|
|
@ -247,9 +247,9 @@ class IndexController extends ApiController{
|
|||
|
||||
|
||||
return $this->successJson('success',[
|
||||
'voucher_number' => $culturalSpaceInfo->voucher_number,
|
||||
'goods_legumes' => $culturalSpaceInfo->goods_legumes,
|
||||
'goods_legumes_money' => $culturalSpaceInfo->goods_legumes_money,
|
||||
'voucher_number' => (float)$culturalSpaceInfo->voucher_number,
|
||||
'goods_legumes' => (float)$culturalSpaceInfo->goods_legumes,
|
||||
'goods_legumes_money' => (float)$culturalSpaceInfo->goods_legumes_money,
|
||||
'commission_rate' => $withdrawalCommissionRate,
|
||||
'task_video_link' => $set['task_video_link']
|
||||
]);
|
||||
|
|
@ -522,7 +522,7 @@ class IndexController extends ApiController{
|
|||
'poundage' => $poundage,// 总服务费
|
||||
];
|
||||
break;
|
||||
// 股权收益
|
||||
// 股权收益 权证兑换
|
||||
case 'shareholding':
|
||||
|
||||
$poundage = Income::uniacid()
|
||||
|
|
@ -538,7 +538,7 @@ class IndexController extends ApiController{
|
|||
|
||||
|
||||
$info = [
|
||||
'weight_income' => ShareholderDividendModel::getIncome((int)$uid,(int)1)->sum('yz_member_income.amount'),// 加权收益
|
||||
'weight_income' => ShareholderDividendModel::getIncome((int)$uid,(int)1)->sum('yz_member_income.amount'),// 加权收益 权证兑换
|
||||
'weight_income_withdrawn' => ShareholderDividendModel::getIncome((int)$uid,(int)1,'withdrawn')->sum('yz_member_income.amount'),// 已提现
|
||||
'weight_income_undrawn' => ShareholderDividendModel::getIncome((int)$uid,(int)1,'undrawn')->sum('yz_member_income.amount'),// 可提现
|
||||
'poundage' => $poundage,// 总服务费
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ class LegumesController extends ApiController{
|
|||
->sum('withdrawal_total_num');
|
||||
|
||||
$data = [
|
||||
'total_get' => $info->voucher_number,// 总获得
|
||||
'voucher_number' => $info->voucher_number,// 当前持有
|
||||
'goods_legumes' => $info->goods_legumes,// 商品兑换
|
||||
'total_get' => (float)$info->voucher_number,// 总获得
|
||||
'voucher_number' => (float)$info->voucher_number,// 当前持有
|
||||
'goods_legumes' => (float)$info->goods_legumes,// 商品兑换
|
||||
'fund_num' => $fundNum,// 共享基金
|
||||
'withdrawal_total_num' => $withdrawalTotalNum
|
||||
];
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ class CulturalSpace extends BaseModel
|
|||
$legumesIncome = sprintf("%.2f",$culturalSpace['voucher_number'] * $exchangeRate);
|
||||
// 获取小区业绩(去除最大的线的业绩)和团队总业绩
|
||||
$teamAmount = $this->getTeamOrderAmount($uid);
|
||||
// 获取加权收益
|
||||
// 获取加权收益 权证兑换
|
||||
$weightIncome = ShareholderDividendModel::getIncome((int)$uid,(int)1)->sum('yz_member_income.amount');
|
||||
// 分享奖励
|
||||
$shareReward = CommissionOrder::getIncome((int)$uid,(int)1,'undrawn')->sum('yz_member_income.amount');
|
||||
|
|
@ -356,11 +356,11 @@ class CulturalSpace extends BaseModel
|
|||
'contribution_value' => ['key_name' => 'contribution_value','title' => '贡献值','num' => $culturalSpace['contribution'],'sort' => 5],
|
||||
'area_performance' => ['key_name' => 'area_performance','title' => '小区业绩','num' => $teamAmount['area_amount'],'sort' => 7],
|
||||
'team_performance' => ['key_name' => 'team_performance','title' => '团队总业绩','num' => $teamAmount['team_amount'],'sort' => 8],
|
||||
'weight_income' => ['key_name' => 'weight_income','title' => '加权收益','num' => $weightIncome,'sort' => 9],
|
||||
'weight_income' => ['key_name' => 'weight_income','title' => '权证兑换','num' => $weightIncome,'sort' => 9],
|
||||
'shareholding_income' => ['key_name' => 'shareholding_income','title' => '股权收益','num' => 0,'sort' => 10],
|
||||
'share_reward' => ['key_name' => 'share_reward','title' => '生态发展','num' => $shareReward,'sort' => 11],
|
||||
];
|
||||
// 合伙人等级增加显示加权收益,不显示服务收益、贡献收益、贡献值分红
|
||||
// 合伙人等级增加显示权证兑换,不显示服务收益、贡献收益、贡献值分红
|
||||
// if($isPartner) unset($list['service_income'],$list['contribution_income'],$list['contribution_bonus']);
|
||||
// else unset($list['weight_income']);
|
||||
// 排序
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@ class PluginApplication extends \app\common\services\PluginApplication
|
|||
'class' => 'Yunshop\ShareholderDividend\models\ShareholderDividendModel',
|
||||
],
|
||||
'weight_income' => [
|
||||
'title' => '加权收益',
|
||||
'title' => '权证兑换',// 加权收益
|
||||
'type' => 'weight_income',
|
||||
'type_name' => '加权收益',
|
||||
'type_name' => '权证兑换',
|
||||
'class' => 'Yunshop\ShareholderDividend\models\ShareholderDividendModel',
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class ShareholderDividendModel extends BackendModel
|
|||
* Author: wu-hui
|
||||
* Time: 2023/11/22 10:06
|
||||
* @param int $uid 用户id
|
||||
* @param int $incomeType 收益类型:0=股权分红,1=加权收益
|
||||
* @param int $incomeType 收益类型:0=股权分红,1=加权收益(权证兑换)
|
||||
* @param string $incomeStatus all=全部收益;undrawn=未提现收益,withdrawn=已提现收益
|
||||
* @return mixed
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ class TimedTaskService
|
|||
foreach ($teamLevels as $teamLevel) {
|
||||
// 判断:结算方式是否符合条件
|
||||
$levelSettlementType = (int)$this->set['level_settlement_type']['level_' . $teamLevel['id']];// 结算方式 0=周期,1=订单支付后
|
||||
$incomeType = (int)$this->set['income_type']['level_' . $teamLevel['id']];// 收益类型 0=股东分红,1=加权收益
|
||||
$incomeType = (int)$this->set['income_type']['level_' . $teamLevel['id']];// 收益类型 0=股东分红,1=加权收益(权证兑换)
|
||||
$rate = (float)$this->set['level_rate']['level_' . $teamLevel['id']]; // 等级分红比例
|
||||
if ($rate > 0 && (($settlementType == 'cycle' && $levelSettlementType == 0) || ($settlementType == 'order' && $levelSettlementType == 1))) {
|
||||
$levelBonusType = (float)$this->set['level_bonus_type']['level_' . $teamLevel['id']]; // 分红方式:0=按权重值比例,1=平均分
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@
|
|||
<input type="radio" name="setdata[income_type][level_{{$lelve->id}}]" value="0" @if ((int)$set['income_type']['level_'.$lelve->id] != 1) checked @endif> 股东分红
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="setdata[income_type][level_{{$lelve->id}}]" value="1" @if ((int)$set['income_type']['level_'.$lelve->id] == 1) checked @endif> 加权收益
|
||||
<input type="radio" name="setdata[income_type][level_{{$lelve->id}}]" value="1" @if ((int)$set['income_type']['level_'.$lelve->id] == 1) checked @endif> {{--加权收益--}}权证兑换
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -49,10 +49,10 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{--加权收益提现设置--}}
|
||||
{{--权证兑换提现设置--}}
|
||||
<div class="vue-main-title">
|
||||
<div class="vue-main-title-left"></div>
|
||||
<div class="vue-main-title-content">加权收益提现设置</div>
|
||||
<div class="vue-main-title-content">权证兑换提现设置</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-xs-12 col-sm-3 col-md-2 control-label">提现额度</label>
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@
|
|||
<div class="col-sm-9 col-xs-12">
|
||||
<input type="text" name="withdraw[ecological_services][roll_out_limit]" class="form-control"
|
||||
value="{{$ecological_services['roll_out_limit']}}"/>
|
||||
<span class="help-block">当前代理的佣金达到此额度时才能提现</span>
|
||||
<span class="help-block">当生态服务达到此额度时才能提现</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
@ -158,7 +158,7 @@
|
|||
<div class="col-sm-9 col-xs-12">
|
||||
<input type="text" name="withdraw[ecological_construction][roll_out_limit]" class="form-control"
|
||||
value="{{$ecological_construction['roll_out_limit']}}"/>
|
||||
<span class="help-block">当前代理的佣金达到此额度时才能提现</span>
|
||||
<span class="help-block">当生态建设达到此额度时才能提现</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
@ -208,7 +208,7 @@
|
|||
<div class="col-sm-9 col-xs-12">
|
||||
<input type="text" name="withdraw[ecological_contribution][roll_out_limit]" class="form-control"
|
||||
value="{{$ecological_contribution['roll_out_limit']}}"/>
|
||||
<span class="help-block">当前代理的佣金达到此额度时才能提现</span>
|
||||
<span class="help-block">当生态贡献达到此额度时才能提现</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use app\common\models\Income;
|
|||
use app\common\models\Member;
|
||||
use app\common\models\member\MemberChildren;
|
||||
use app\common\services\password\PasswordService;
|
||||
use app\frontend\modules\finance\controllers\IncomeWithdrawController;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Yunshop\TeamDividend\models\TeamDividendAgencyModel;
|
||||
use Yunshop\TeamDividend\models\TeamDividendLevelModel;
|
||||
|
|
@ -36,8 +37,8 @@ class IndexController extends ApiController{
|
|||
$user = Member::getMemberById($uid,['uid','nickname','realname','avatar']);
|
||||
$data['user'] = $user ? $user->toArray() : [];
|
||||
// 获取可提现金额&团队人数
|
||||
$data['income'] = (float)Income::uniacid()->where('member_id', $uid)->where('status', 0)->sum('amount');// 可提现金额(仅计算未提现)
|
||||
$data['total_income'] = (float)Income::uniacid()->where('member_id', $uid)->sum('amount');// 累计收入(包括已提现收入)
|
||||
$data['income'] = (new IncomeWithdrawController)->computeWithdraw('broker')['all_withdraw_income'];
|
||||
$data['total_income'] = (float)Income::getAllIncome($uid,'broker');
|
||||
$data['team_total'] = MemberChildren::getTeamModel($uid)->count();
|
||||
// 获取统计信息
|
||||
$data['statistics'] = (new WeightValue())->getStatistics($uid,$teamLevelId);
|
||||
|
|
|
|||
|
|
@ -588,8 +588,12 @@ class WeightValue extends BaseModel{
|
|||
public function getStatistics($uid,$teamLevelId){
|
||||
// 获取相关统计信息
|
||||
[$directPush,$recommendAgent] = $this->getCommissionGive($uid);
|
||||
// 获取权重收益(当前等级相关的股东分红)
|
||||
$weightIncome = ShareholderDividendModel::uniacid()->where('member_id',$uid)->where('team_level',$teamLevelId)->sum('amount');
|
||||
// 获取权重收益(当前等级相关的股东分红) 收益类型:0=股权分红,1=加权收益(权证兑换)
|
||||
$weightIncome = ShareholderDividendModel::uniacid()
|
||||
->where('member_id',$uid)
|
||||
->where('team_level',$teamLevelId)
|
||||
->where('income_type',0)
|
||||
->sum('amount');
|
||||
// 团队收益
|
||||
$teamIncomeInfo = $this->getTeamDividendInfo($uid,$teamLevelId);
|
||||
// 权重值
|
||||
|
|
@ -607,7 +611,7 @@ class WeightValue extends BaseModel{
|
|||
// 本人当前持有的 本等级的权重值
|
||||
'weight_value' => ['key_name' => 'weight_value','title' => '权重值','num' => $weightValue,'sort' => 10],
|
||||
// 股权收益 todo:目前仅显示,值固定为0,后期功能开发完成后才显示具体统计值(功能暂定,无开发文档、无功能明细、无基本内容)
|
||||
'shareholding' => ['key_name' => 'order_money','title' => '股权收益','num' => 0,'sort' => 11],
|
||||
'shareholding' => ['key_name' => 'shareholding','title' => '股权收益','num' => 0,'sort' => 11],
|
||||
// 本团队所有相关订单的实际支付金额(不包括本人)
|
||||
'order_money' => ['key_name' => 'order_money','title' => '总订单金额','num' => $teamOrderInfo['total_price'],'sort' => 12],
|
||||
// 本团队所有相关订单总数 (不包括本人)
|
||||
|
|
@ -700,10 +704,18 @@ class WeightValue extends BaseModel{
|
|||
$subUserIds = MemberChildren::getTeamModel($uid)->pluck('yz_member_children.child_id')->toArray();
|
||||
if(count($subUserIds) > 0){
|
||||
$orderInfo = Order::uniacid()
|
||||
->select(DB::raw('sum(price) as total_price,count(id) as total'))
|
||||
->whereIn('uid',$subUserIds)
|
||||
->where('uid','!=',$uid)
|
||||
->select(DB::raw('sum(ims_yz_order.price) as total_price,count(ims_yz_order.id) as total'))
|
||||
->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',$subUserIds)
|
||||
->where('yz_order.uid','!=',$uid)
|
||||
->where('yz_goods_cultural_space.is_open',0)
|
||||
->first();
|
||||
// $orderInfo = Order::uniacid()
|
||||
// ->select(DB::raw('sum(price) as total_price,count(id) as total'))
|
||||
// ->whereIn('uid',$subUserIds)
|
||||
// ->where('uid','!=',$uid)
|
||||
// ->first();
|
||||
$orderStatistics = [
|
||||
'total_price' => sprintf("%.2f",(float)$orderInfo->total_price),
|
||||
'total' => (int)$orderInfo->total,
|
||||
|
|
@ -748,6 +760,7 @@ class WeightValue extends BaseModel{
|
|||
->select(['id','amount','created_at','team_level_name'])
|
||||
->where('member_id',$uid)
|
||||
->where('team_level',$teamLevelId)
|
||||
->where('income_type',0)
|
||||
->paginate(20)
|
||||
->toArray();
|
||||
}
|
||||
|
|
@ -780,15 +793,18 @@ class WeightValue extends BaseModel{
|
|||
if(count($subUserIds) > 0){
|
||||
$result = Order::uniacid()
|
||||
->select([
|
||||
'id',
|
||||
'uid',
|
||||
'order_sn',
|
||||
'create_time',
|
||||
'price',
|
||||
'status',
|
||||
'yz_order.id',
|
||||
'yz_order.uid',
|
||||
'yz_order.order_sn',
|
||||
'yz_order.create_time',
|
||||
'yz_order.price',
|
||||
'yz_order.status',
|
||||
])
|
||||
->whereIn('uid',$subUserIds)
|
||||
->where('uid','!=',$uid)
|
||||
->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',$subUserIds)
|
||||
->where('yz_order.uid','!=',$uid)
|
||||
->where('yz_goods_cultural_space.is_open',0)
|
||||
->with([
|
||||
'belongsToMember' => function($query){
|
||||
$query->select(['uid','nickname','realname','avatar']);
|
||||
|
|
@ -800,6 +816,28 @@ class WeightValue extends BaseModel{
|
|||
->paginate(20)
|
||||
->toArray();
|
||||
|
||||
// $result = Order::uniacid()
|
||||
// ->select([
|
||||
// 'id',
|
||||
// 'uid',
|
||||
// 'order_sn',
|
||||
// 'create_time',
|
||||
// 'price',
|
||||
// 'status',
|
||||
// ])
|
||||
// ->whereIn('uid',$subUserIds)
|
||||
// ->where('uid','!=',$uid)
|
||||
// ->with([
|
||||
// 'belongsToMember' => function($query){
|
||||
// $query->select(['uid','nickname','realname','avatar']);
|
||||
// },
|
||||
// 'orderGoods' => function($query){
|
||||
// $query->select(['id','title','thumb','payment_amount','total','order_id']);
|
||||
// }
|
||||
// ])
|
||||
// ->paginate(20)
|
||||
// ->toArray();
|
||||
|
||||
|
||||
$result['data'] = array_map(function($item){
|
||||
return [
|
||||
|
|
@ -840,7 +878,7 @@ class WeightValue extends BaseModel{
|
|||
->join('yz_commission_order', 'yz_commission_order.id', 'yz_commission_order_goods.commission_order_id')
|
||||
->where('yz_commission_order.uniacid',\YunShop::app()->uniacid)
|
||||
->where('yz_commission_order.member_id',$uid)
|
||||
->where('yz_commission_order.level_type',0)
|
||||
->where('yz_commission_order.level_type',0)// 0=普通分销商订单,1=文创分销商订单
|
||||
->where('yz_commission_order.status',2);
|
||||
}
|
||||
/**
|
||||
|
|
@ -852,10 +890,12 @@ class WeightValue extends BaseModel{
|
|||
* @return BaseModel
|
||||
*/
|
||||
private function getTeamDividendModel($uid,$teamLevelId){
|
||||
// 分红类型:0=分红佣金,1=平级奖,2=感恩奖励,3=额外分红,4=生态建设,5=生态贡献(生态建设平级奖),6=生态服务
|
||||
return TeamDividendModel::uniacid()
|
||||
->where('member_id',$uid)
|
||||
->where('agent_level',$teamLevelId)// 已结算
|
||||
->where('status',1)// 已结算
|
||||
->whereNotIn('type',[4,5,6])
|
||||
->where('settle_money_type',1);// 结算金额类型为 - 收入提现
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue