添加:新管理中心 相关信息接口
This commit is contained in:
parent
76c08a9509
commit
b38405fe5d
|
|
@ -18,19 +18,22 @@ use Illuminate\Support\Facades\DB;
|
|||
class MemberChildren extends BaseModel
|
||||
{
|
||||
public $table = 'yz_member_children';
|
||||
|
||||
/**
|
||||
* Common: 获取我的客户(团队总人数,不包括已删除用户) 查询模型
|
||||
* Author: wu-hui
|
||||
* Time: 2023/10/19 10:20
|
||||
* @param $uid
|
||||
* @param $uid
|
||||
* @param int $level
|
||||
* @return BaseModel
|
||||
*/
|
||||
public static function getTeamModel($uid){
|
||||
public static function getTeamModel($uid,$level = 0){
|
||||
return self::uniacid()
|
||||
->join('yz_member', function ($join) {
|
||||
$join->on('yz_member.member_id', '=', 'yz_member_children.child_id')->whereNull('deleted_at');
|
||||
})
|
||||
->when($level > 0,function($query) use ($level){
|
||||
$query->where('yz_member_children.level',$level);
|
||||
})
|
||||
->where('yz_member_children.uniacid',\YunShop::app()->uniacid)
|
||||
->where('yz_member_children.member_id',$uid);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use app\common\models\Income;
|
|||
use app\common\models\Member;
|
||||
use app\common\models\member\MemberChildren;
|
||||
use app\common\models\Order;
|
||||
use app\common\models\Withdraw;
|
||||
use app\common\services\credit\ConstService;
|
||||
use app\common\services\finance\BalanceChange;
|
||||
use app\common\services\password\PasswordService;
|
||||
|
|
@ -26,6 +27,7 @@ use Yunshop\TeamDividend\models\TeamDividendAgencyModel;
|
|||
use Yunshop\TeamDividend\models\TeamDividendLevelModel;
|
||||
use Yunshop\TeamDividend\models\TeamDividendModel;
|
||||
use Yunshop\TeamDividend\models\Uplog;
|
||||
use Yunshop\UseStaff\models\UseStaff;
|
||||
|
||||
class IndexController extends ApiController{
|
||||
/**
|
||||
|
|
@ -50,6 +52,7 @@ class IndexController extends ApiController{
|
|||
$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['team_total'] = MemberChildren::getTeamModel($uid)->count();
|
||||
$data['one_team_total'] = MemberChildren::getTeamModel($uid,1)->count();
|
||||
// 获取统计信息
|
||||
$data['statistics'] = (new CulturalSpace())->getStatistics($uid);
|
||||
|
||||
|
|
@ -431,7 +434,7 @@ class IndexController extends ApiController{
|
|||
if($legumesWithdrawalId <= 0) return $this->errorJson('非法请求,参数错误!');
|
||||
// 获取提现详情
|
||||
$info = CulturalSpaceLegumesWithdrawal::uniacid()
|
||||
->select(['id','uid','withdrawal_total_num','current_fee','commission_num','reality_amount','created_at'])
|
||||
->select(['id','uid','withdrawal_total_num','current_fee','commission_num','reality_amount','created_at','status','reject_reason'])
|
||||
->with(['useStaff'=>function($query){
|
||||
$query->select(['id','uid','card_num']);
|
||||
}])
|
||||
|
|
@ -451,6 +454,178 @@ class IndexController extends ApiController{
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* Common: 获取相关统计信息
|
||||
* Author: wu-hui
|
||||
* Time: 2023/12/01 18:18
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function getPublicStatistics(){
|
||||
// 参数获取
|
||||
$uid = \YunShop::app()->getMemberId();
|
||||
$typeName = request()->input('type_name');
|
||||
$info = [];
|
||||
// 获取相关统计信息
|
||||
switch($typeName){
|
||||
// 生态发展收益
|
||||
case 'ecological':
|
||||
$amount = Income::uniacid()
|
||||
->select(['yz_member_income.id','yz_member_income.amount'])
|
||||
->leftJoin('yz_team_dividend','yz_team_dividend.id','yz_member_income.incometable_id')
|
||||
->where('yz_member_income.incometable_type', 'Yunshop\TeamDividend\models\TeamDividendModel')
|
||||
->where('yz_member_income.status', Income::STATUS_WITHDRAW)
|
||||
->where('yz_member_income.member_id', $uid)
|
||||
->whereIn('yz_team_dividend.type', [4,5])
|
||||
->sum('yz_member_income.amount');
|
||||
|
||||
$poundage = Income::uniacid()
|
||||
->leftJoin('yz_team_dividend','yz_team_dividend.id','yz_member_income.incometable_id')
|
||||
->leftJoin('yz_withdraw_income_apply','yz_withdraw_income_apply.income_id','yz_member_income.id')
|
||||
->leftJoin('yz_withdraw','yz_withdraw.id','yz_withdraw_income_apply.withdraw_id')
|
||||
->where('yz_member_income.incometable_type', 'Yunshop\TeamDividend\models\TeamDividendModel')
|
||||
->where('yz_member_income.status', Income::STATUS_WITHDRAW)
|
||||
->where('yz_member_income.member_id', $uid)
|
||||
->whereIn('yz_team_dividend.type', [4,5])
|
||||
->groupBy('yz_withdraw_income_apply.withdraw_id')
|
||||
->sum('yz_withdraw.poundage');
|
||||
|
||||
|
||||
$info = [
|
||||
'service_income' => TeamDividendModel::getTypeTotalIncome((int)$uid,(int)4)->sum('yz_member_income.amount'),// 生态服务
|
||||
'contribution_income' => TeamDividendModel::getTypeTotalIncome((int)$uid,(int)5)->sum('yz_member_income.amount'),// 生态贡献
|
||||
'share_reward' => CommissionOrder::getIncome((int)$uid,(int)1,'undrawn')->sum('yz_member_income.amount'),// 分享奖励
|
||||
'commission' => $poundage,// 总手续费
|
||||
'withdrawal' => $amount,// 总提现金额
|
||||
];
|
||||
break;
|
||||
// 贡献分红
|
||||
case 'contribution':
|
||||
$poundage = Withdraw::uniacid()
|
||||
->where('type', 'Yunshop\CulturalSpace\models\ContributionBonusLog')
|
||||
->where('status', 2)
|
||||
->sum('poundage');
|
||||
|
||||
$info = [
|
||||
'contribution_bonus' => ContributionBonusLog::getIncomeSum($uid)->sum('yz_member_income.amount'),// 贡献值分红
|
||||
'contribution_bonus_withdrawn' => ContributionBonusLog::getIncomeSum($uid,'withdrawn')->sum('yz_member_income.amount'),// 已提现
|
||||
'contribution_bonus_undrawn' => ContributionBonusLog::getIncomeSum($uid,'undrawn')->sum('yz_member_income.amount'),// 可提现
|
||||
'poundage' => $poundage,// 总服务费
|
||||
];
|
||||
break;
|
||||
// 股权收益
|
||||
case 'shareholding':
|
||||
|
||||
$poundage = Income::uniacid()
|
||||
->leftJoin('yz_shareholder_dividend','yz_shareholder_dividend.id','yz_member_income.incometable_id')
|
||||
->leftJoin('yz_withdraw_income_apply','yz_withdraw_income_apply.income_id','yz_member_income.id')
|
||||
->leftJoin('yz_withdraw','yz_withdraw.id','yz_withdraw_income_apply.withdraw_id')
|
||||
->where('yz_member_income.dividend_code', 64)
|
||||
->where('yz_member_income.status', Income::STATUS_WITHDRAW)
|
||||
->where('yz_member_income.member_id', $uid)
|
||||
->where('yz_shareholder_dividend.income_type', 1)
|
||||
->groupBy('yz_withdraw_income_apply.withdraw_id')
|
||||
->sum('yz_withdraw.poundage');
|
||||
|
||||
|
||||
$info = [
|
||||
'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,// 总服务费
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
||||
return $this->successJson('success',$info);
|
||||
}
|
||||
/**
|
||||
* Common: 获取相关信息列表
|
||||
* Author: wu-hui
|
||||
* Time: 2023/12/01 18:18
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function getPublicList(){
|
||||
// 参数获取
|
||||
$uid = \YunShop::app()->getMemberId();
|
||||
$typeName = request()->input('type_name');
|
||||
$result = [];
|
||||
// 获取相关统计信息
|
||||
switch($typeName){
|
||||
// 生态发展收益
|
||||
case 'ecological':
|
||||
$result = Income::uniacid()
|
||||
->select(['yz_withdraw.amounts','yz_withdraw.id','yz_withdraw.created_at','yz_withdraw.actual_amounts','yz_withdraw.poundage','yz_withdraw.status'])
|
||||
->leftJoin('yz_team_dividend','yz_team_dividend.id','yz_member_income.incometable_id')
|
||||
->leftJoin('yz_withdraw_income_apply','yz_withdraw_income_apply.income_id','yz_member_income.id')
|
||||
->leftJoin('yz_withdraw','yz_withdraw.id','yz_withdraw_income_apply.withdraw_id')
|
||||
->where('yz_member_income.incometable_type', 'Yunshop\TeamDividend\models\TeamDividendModel')
|
||||
->where('yz_member_income.status', Income::STATUS_WITHDRAW)
|
||||
->where('yz_member_income.member_id', $uid)
|
||||
->whereIn('yz_team_dividend.type', [4,5])
|
||||
->groupBy('yz_withdraw_income_apply.withdraw_id')
|
||||
->orderBy('yz_withdraw.created_at','DESC')
|
||||
->paginate(20)
|
||||
->toArray();
|
||||
break;
|
||||
// 贡献分红
|
||||
case 'contribution':
|
||||
$result = Withdraw::uniacid()
|
||||
->select(['id','amounts','created_at','actual_amounts','poundage','status'])
|
||||
->where('type', 'Yunshop\CulturalSpace\models\ContributionBonusLog')
|
||||
->orderBy('created_at','DESC')
|
||||
->paginate(20)
|
||||
->toArray();
|
||||
break;
|
||||
// 股权收益
|
||||
case 'shareholding':
|
||||
$result = Income::uniacid()
|
||||
->select(['yz_withdraw.id','yz_withdraw.amounts','yz_withdraw.created_at','yz_withdraw.actual_amounts','yz_withdraw.poundage','yz_withdraw.status'])
|
||||
->leftJoin('yz_shareholder_dividend','yz_shareholder_dividend.id','yz_member_income.incometable_id')
|
||||
->leftJoin('yz_withdraw_income_apply','yz_withdraw_income_apply.income_id','yz_member_income.id')
|
||||
->leftJoin('yz_withdraw','yz_withdraw.id','yz_withdraw_income_apply.withdraw_id')
|
||||
->where('yz_member_income.dividend_code', 64)
|
||||
->where('yz_member_income.status', Income::STATUS_WITHDRAW)
|
||||
->where('yz_member_income.member_id', $uid)
|
||||
->where('yz_shareholder_dividend.income_type', 1)
|
||||
->groupBy('yz_withdraw_income_apply.withdraw_id')
|
||||
->orderBy('yz_withdraw.created_at','DESC')
|
||||
->paginate(20)
|
||||
->toArray();
|
||||
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
foreach($result['data'] as &$item){
|
||||
$item['created_at'] = date("Y/m/d H:i",strtotime($item['created_at']));
|
||||
}
|
||||
|
||||
return $this->successJson('success',[
|
||||
'current_page' => (int)$result['current_page'],
|
||||
'data' => (array)$result['data'],
|
||||
'last_page' => (int)$result['last_page'],
|
||||
]);
|
||||
}
|
||||
// 获取相关结算信息
|
||||
public function getPublicDetails(){
|
||||
$withdrawId = request()->input('withdraw_id');
|
||||
$info = Withdraw::uniacid()
|
||||
->where('id', $withdrawId)
|
||||
->first();
|
||||
if($info) $info = $info->toArray();
|
||||
$info['expected_receipt_time'] = date("Y-m-d",strtotime($info['created_at']. " +2 day"));
|
||||
// 银行卡获取
|
||||
$staff = UseStaff::uniacid()->where('uid',$info['member_id'])->first();
|
||||
if($staff) {
|
||||
$staff = $staff->toArray();
|
||||
$info['card_num'] = substr($staff['card_num'], 0, 4) . ' **** **** **** '.substr($staff['card_num'], -3, 3) ;
|
||||
}
|
||||
|
||||
|
||||
return $this->successJson('success',$info);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
namespace Yunshop\CulturalSpace\Api;
|
||||
|
||||
use app\common\components\ApiController;
|
||||
use Yunshop\CulturalSpace\models\CulturalSpace;
|
||||
use Yunshop\CulturalSpace\models\CulturalSpaceLegumesWithdrawal;
|
||||
|
||||
class LegumesController extends ApiController{
|
||||
/**
|
||||
* Common: 获取 消费增值 基本统计信息
|
||||
* Author: wu-hui
|
||||
* Time: 2023/12/01 15:59
|
||||
*/
|
||||
public function getStatistics(){
|
||||
$uid = \YunShop::app()->getMemberId();
|
||||
// 获取用户持有信息
|
||||
$info = CulturalSpace::uniacid()->where('uid',$uid)->first();
|
||||
// 共享基金 仅计算已打款
|
||||
$fundNum = CulturalSpaceLegumesWithdrawal::uniacid()
|
||||
->where('uid',$uid)
|
||||
->where('status',3)
|
||||
->sum('fund_num');
|
||||
// 已提现文创豆
|
||||
$withdrawalTotalNum = CulturalSpaceLegumesWithdrawal::uniacid()
|
||||
->where('uid',$uid)
|
||||
->where('status',3)
|
||||
->sum('withdrawal_total_num');
|
||||
|
||||
$data = [
|
||||
'total_get' => $info->voucher_number,// 总获得
|
||||
'voucher_number' => $info->voucher_number,// 当前持有
|
||||
'goods_legumes' => $info->goods_legumes,// 商品兑换
|
||||
'fund_num' => $fundNum,// 共享基金
|
||||
'withdrawal_total_num' => $withdrawalTotalNum
|
||||
];
|
||||
|
||||
return $this->successJson('success',$data);
|
||||
}
|
||||
/**
|
||||
* Common: 提现记录
|
||||
* Author: wu-hui
|
||||
* Time: 2023/12/01 16:09
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function withdrawalRecord(){
|
||||
$uid = \YunShop::app()->getMemberId();
|
||||
// 获取业绩列表
|
||||
$result = CulturalSpaceLegumesWithdrawal::uniacid()
|
||||
->select(['id','created_at','reality_amount','commission_num','withdrawal_total_num','status'])
|
||||
->where('uid',$uid)
|
||||
->orderBY('id','desc')
|
||||
->paginate(20)
|
||||
->toArray();
|
||||
foreach($result['data'] as $item){
|
||||
$item['created_at'] = date("Y/m/d H:i",strtotime($item['created_at']));
|
||||
}
|
||||
|
||||
return $this->successJson('success',[
|
||||
'current_page' => (int)$result['current_page'],
|
||||
'data' => (array)$result['data'],
|
||||
'last_page' => (int)$result['last_page'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -644,6 +644,7 @@ class PluginApplication extends \app\common\services\PluginApplication
|
|||
if($uid > 0){
|
||||
$culturalLevelId = TeamDividendAgencyModel::uniacid()->where('uid',$uid)->value('cultural_level_id');
|
||||
$teamDividendCulturalName = TeamDividendLevelModel::uniacid()->where('id',$culturalLevelId)->value('cultural_level_name');
|
||||
$teamDividendCulturalName = !empty($teamDividendCulturalName) ? $teamDividendCulturalName : '服务津贴';
|
||||
}
|
||||
return [
|
||||
'teamDividend' => [
|
||||
|
|
|
|||
Loading…
Reference in New Issue