|
@@ -184,12 +184,28 @@ class PaymentController extends Controller
|
|
$user->increment('server_limit', $shopProduct->quantity);
|
|
$user->increment('server_limit', $shopProduct->quantity);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //give referral commission always
|
|
|
|
+ if((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE") == "both") && $shopProduct->type=="Credits" && config("SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION") == "true"){
|
|
|
|
+ if($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()){
|
|
|
|
+ $ref_user = User::findOrFail($ref_user->referral_id);
|
|
|
|
+ $increment = number_format($shopProduct->quantity*(PartnerDiscount::getCommission($ref_user->id))/100,0,"","");
|
|
|
|
+ $ref_user->increment('credits', $increment);
|
|
|
|
+
|
|
|
|
+ //LOGS REFERRALS IN THE ACTIVITY LOG
|
|
|
|
+ activity()
|
|
|
|
+ ->performedOn($user)
|
|
|
|
+ ->causedBy($ref_user)
|
|
|
|
+ ->log('gained '. $increment.' '.config("SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME").' for commission-referral of '.$user->name.' (ID:'.$user->id.')');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
//update role give Referral-reward
|
|
//update role give Referral-reward
|
|
if ($user->role == 'member') {
|
|
if ($user->role == 'member') {
|
|
$user->update(['role' => 'client']);
|
|
$user->update(['role' => 'client']);
|
|
|
|
|
|
- if((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE") == "both") && $shopProduct->type=="Credits"){
|
|
|
|
|
|
+ //give referral commission only on first purchase
|
|
|
|
+ if((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE") == "both") && $shopProduct->type=="Credits" && config("SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION") == "false"){
|
|
if($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()){
|
|
if($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()){
|
|
$ref_user = User::findOrFail($ref_user->referral_id);
|
|
$ref_user = User::findOrFail($ref_user->referral_id);
|
|
$increment = number_format($shopProduct->quantity*(PartnerDiscount::getCommission($ref_user->id))/100,0,"","");
|
|
$increment = number_format($shopProduct->quantity*(PartnerDiscount::getCommission($ref_user->id))/100,0,"","");
|