wang hou sheng 8 months ago
parent 66b9d47dc3
commit f108d5ef44
  1. 35
      app/api/controller/Invite.php
  2. 12
      app/api/model/Invite/InviteLog.php
  3. 30
      app/api/model/dealer/Capital.php

@ -2,7 +2,11 @@
namespace app\api\controller;
use app\api\model\dealer\User as DealerUserModel;
use app\api\model\Invite\InviteLog;
use app\api\model\wholesaler\Apply;
use app\api\service\User as UserService;
use app\common\enum\WholesalerEnum;
use app\common\model\invite\InviteConfig;
use cores\exception\BaseException;
use think\db\exception\DbException;
@ -43,4 +47,35 @@ class Invite extends Controller
$list = $model->getList();
return $this->renderSuccess(compact('list'));
}
/**
* @notes:
* @return Json
* @throws BaseException
* @author: wanghousheng
*/
public function statistics(): Json
{
$refuse_num = 0;
$adoption_num = 0;
$money = 0;
$model = new InviteLog();
$user_ids = $model->inviteeUserIds();
if ($user_ids) {
$applyModel = new Apply();
//审核通过
$adoption_num = $applyModel->whereIn('user_id', $user_ids)->where(['status' => WholesalerEnum::ADOPT])->count();
//审核拒绝
$refuse_num = $applyModel->whereIn('user_id', $user_ids)->where(['status' => WholesalerEnum::REFUSE])->count();
}
// 当前用户ID
$userId = UserService::getCurrentLoginUserId();
// 分销商用户详情
$dealer = DealerUserModel::detail($userId, []);
if (!empty($dealer->freeze_money)) {
$money = $dealer->freeze_money;
}
$data = compact('refuse_num', 'adoption_num', 'money');
return $this->renderSuccess($data);
}
}

@ -119,4 +119,16 @@ class InviteLog extends \app\common\model\invite\InviteLog
$userId = UserService::getCurrentLoginUserId();
return $this->where(['user_id' => $userId])->count();
}
/**
* @notes:获取被邀请人ID
* @return array
* @throws BaseException
* @author: wanghousheng
*/
public function inviteeUserIds(): array
{
$userId = UserService::getCurrentLoginUserId();
return $this->where(['user_id' => $userId])->column('invitee_user_id');
}
}

@ -12,8 +12,9 @@ declare (strict_types=1);
namespace app\api\model\dealer;
use app\common\model\dealer\Capital as CapitalModel;
use app\api\service\User as UserService;
use app\common\model\dealer\Capital as CapitalModel;
use cores\exception\BaseException;
/**
* 分销商资金明细模型
@ -31,23 +32,40 @@ class Capital extends CapitalModel
'update_time',
];
/**
/**
* 获取分销商佣金列表
* @param array $param
* @return \think\Paginator
* @throws \cores\exception\BaseException
* @throws BaseException
* @throws \think\db\exception\DbException
*/
public function getList(array $param = [],int $storeId): \think\Paginator
public function getList(array $param = [], int $storeId): \think\Paginator
{
// 当前用户ID
$userId = UserService::getCurrentLoginUserId();
// 获取分销商佣金列表
$list = $this->getNewQuery()
->where('user_id',$userId)
->where('store_id',$storeId)
->where('user_id', $userId)
->where('store_id', $storeId)
->order(['create_time' => 'desc'])
->paginate(15);
return $list;
}
/**
* @notes:获取收入佣金总额
* @return float
* @throws BaseException
* @author: wanghousheng
*/
public function getTotal(): float
{
// 当前用户ID
$userId = UserService::getCurrentLoginUserId();
return $this->getNewQuery()
->where('user_id', $userId)
->where('store_id', self::$storeId)
->where('flow_type', 10)
->sum('money');
}
}
Loading…
Cancel
Save