示例#1
0
 public function inviteStat()
 {
     if (!$this->isAcceptedJson()) {
         return \View::make('man::reporter.invite');
     }
     $list = CustomerInviteExternal::with('registered.customer')->with('owner')->orderBy('id', 'desc')->get()->all();
     foreach ($list as $item) {
         $item->registered && $item->registered->customer && $item->registered->customer->initExistsPaid();
     }
     return $list;
 }
示例#2
0
 /**
  * временная запись инвайта для внешнего id клиента
  *
  * @param string $phone внешний id клиента
  *
  * @return null|\Symfony\Component\HttpFoundation\Cookie
  */
 public function registerInviteExternal($phone)
 {
     $code = Cookie::get('dh_invite');
     $phone = Customer::instance()->phone($phone);
     if (!$code) {
         return null;
     }
     $cookie = Cookie::forget('dh_invite');
     $owner = $this->findByCode($code);
     if (!$owner) {
         return $cookie;
     }
     // нельзя приглашать самого себя
     if ($owner->phone == $phone) {
         return $cookie;
     }
     Reporter::inviteCodeFoundExternal($phone, $owner->id, $code);
     $invite = CustomerInviteExternal::create(['phone' => $phone, 'owner_id' => $owner->id, 'source_id' => self::C_LINK]);
     Reporter::inviteCodeRegisteredExternal($phone, $owner->id, $invite->id, $code);
     return $cookie;
 }