<?php
/**
 * Created by PhpStorm.
 * User: stanley-king
 * Date: 2017/11/2
 * Time: 上午10:17
 */

namespace async;

abstract class IAsync
{
    const max_level_pushs = 100;
    abstract public function run();

    protected function ex_user($invitees,$user)
    {
        $result = [];
        foreach ($invitees as $invitee)
        {
            if($invitee != $user) {
                $result[] = $invitee;
            }
        }
        return $result;
    }

    protected function tag_rewarded($user)
    {
        $user = intval($user);
        if($user <=0) return false;

        $mod_member = Model('member');
        $mod_member->editMember(['member_id' => $user],['rewared_inviter' => 1]);
    }

    protected function add_invitee($user)
    {
        $user = intval($user);
        if($user <=0) return false;

        $mod_member = Model('member');
        $mod_member->editMember(['member_id' => $user],['invitees' => ['exp','invitees+1']]);
    }

    protected function add_reward($user,$amount)
    {
        $user = intval($user);
        if($user <=0) return false;

        $mod_member = Model('member');
        $mod_member->editMember(['member_id' => $user],['reward_amount' => ['exp', "reward_amount+{$amount}"]]);
    }
}
