= $value; } /** * 获取自购金额 * @param $userId * @return void */ public static function getSelfPay($userId){ $value = \app\common\model\order\Order::where([ 'status'=>\app\common\constant\order\Status::STATUS_SUCCESS, 'user_id'=>$userId ])->sum('real_pay_price'); if(!$value){ return 0; } return $value; } /** * 获取推广金额 * @param $userId * @return void */ public static function getCustomerPay($userId){ $value = \app\common\model\app\agent\Order::where([ 'status'=>1, 'beneficiary_user_id'=>$userId ])->sum('brokerage_price'); if(!$value){ return 0; } return $value; } /** * 获取客户数量 * @param $userId * @return int */ public static function getAgent($userId){ $value = \app\common\model\app\agent\Relation::where([ 'status'=>1, 'parent_id'=>$userId ])->count(); if(!$value){ return 0; } return $value; } /** * 获取下级分销员 * @param $userId * @return int */ public static function getCustomer($userId){ $value = \app\common\model\app\agent\Relation::alias('relation') ->join(\app\common\model\app\agent\Member::getTable().' member','relation.user_id = member.user_id') ->where([ 'relation.status'=>1, 'member.status'=>1, 'relation.parent_id'=>$userId ])->count(); if(!$value){ return 0; } return $value; } }