You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.3 KiB

<?php
namespace app\distribution\controller\api;
use app\distribution\model\DistributionCommissionIncome;
use app\distribution\model\DistributionUserRelation;
class Relation extends Base
{
/**
* 获取我的分销关系数据
* @date 2021-03-01
*/
public function getMyNextData()
{
$param = input('post.');
$user_relation_model = new DistributionUserRelation();
//今日邀请数
$my['today'] = $user_relation_model->getNumber([
['first_user_id', '=', USER_ID],
['create_time', 'between time', [date('Y-m-d', time()), date('Y-m-d', strtotime('+1 days'))]]
]);
//历史邀请数
$my['history'] = $user_relation_model->getNumber([
['first_user_id', '=', USER_ID]
]);
$return_data = [
'my' => $my
];
return sendSuccessMessage($return_data);
}
/**
* 获取我的下级列表
* @date 2021-03-01
*/
public function getMyNextList()
{
$param = input('post.');
$relation_model = new DistributionUserRelation();
$income_model = new DistributionCommissionIncome();
$next_income = $income_model->group('user_id')->where([
['uid', '=', UID],
['status', '=', 2],
['distributor_user_id', '=', USER_ID]
])->column('sum(commission)', 'user_id');
$where = [
// ['uid', '=', UID]
];
$where_u = [];
if (!empty($param['keyword'])) {
$where_u[] = ['nick_name', 'like', '%' . $param['keyword'] . '%'];
}
switch ($param['index']) {
case 0:
$where[] = ['first_user_id', '=', USER_ID];
break;
case 1:
$where[] = ['second_user_id', '=', USER_ID];
break;
case 2:
$where[] = ['third_user_id', '=', USER_ID];
break;
default:
return sendErrorMessage(2001, 'index参数错误');
break;
}
$field = 'id,uid,user_id,create_time';
$list = $relation_model->getRelationList($where, $where_u, $next_income, $param['page'], $field, 'id desc');
return sendMessage([
'list' => $list
]);
}
}