Exemple #1
0
 public function attenEno($paraObj)
 {
     $login_account = isset($paraObj["login_account"]) ? $paraObj["login_account"] : $paraObj["user"]->getUsername();
     $eno = $paraObj["eno"];
     try {
         //关注默认公众号
         $account = "_wexin_{$eno}@fafatime.com";
         //取出默认公众号
         $sql1 = "select number from we_micro_account where eno=? and number=?";
         $params1 = array((string) $eno, (string) $account);
         $ds = $this->da->Getdata('account', $sql1, $params1);
         if ($ds['account']['recordcount'] > 0) {
             $sql[] = "insert into we_staff_atten (login_account,atten_type,atten_id,atten_date) values(?,?,?,now())";
             $params[] = array($login_account, "01", $account);
         } else {
             //未找到公众号时,直接关注该企业,
             //注:当注册成功时,需要将这些关注数据转换为关注对应的默认公众号
             $sql[] = "insert into we_staff_atten (login_account,atten_type,atten_id,atten_date) values(?,?,?,now())";
             $params[] = array($login_account, self::$code, $eno);
         }
         if (!$this->da->ExecSQLs($sql, $params)) {
             return false;
         }
         $friendevent = new \Justsy\BaseBundle\Management\FriendEvent($this->da, $this->logger, $this->container);
         $friendevent->atteneno($login_account, $eno);
         return true;
     } catch (\Exception $e) {
         $this->writelog($e);
         return false;
     }
 }