/** * 交易发布 * * @param s $uId * int * @param s $domains * array 包含我司和非我司域名的二维数组,一个域名包含价格和简介以及出售周期 * @param s $cashType * int 提现类型,在控制器检查,2 不可提现 3 可体现 * @param s $type * 发布类型 * @param s $ip * 用户ip */ public function fixedPrice($uId, $domains, $cashType, $type, $ip) { try { $redis = core\driver\Redis::getInstance('default'); $domains = array_merge($domains['domainEname'], $domains['domainNoEname']); $succDomains = $failDomains = $verifyDomains = array(); // step1:检测域名后缀 $res = $this->checkDomainTld(array_keys($domains)); $succDomains = $res[0]; $failDomains = array_merge($failDomains, $res[1], $res[2]); if (empty($succDomains)) { return array('flag' => TRUE, 'msg' => array('succ' => array(), 'fail' => $failDomains)); } if (in_array($type, array(\core\Config::item('transType')->zhuantipaimai, \core\Config::item('transType')->yipaiyimai))) { //专题拍卖和易卖易卖是否需要审核 foreach ($succDomains as $v) { $this->goSer->call($v, 'DomainLogic::checkOtherTrans', array($v, $type)); } $res = $this->goSer->send(); $succDomains = array(); foreach ($res as $k => $v) { $v = $v['DomainLogic::checkOtherTrans']; if (isset($v['goError'])) { $failDomains[$k] = '系统繁忙,请重试'; } else { if ($v === 1) { $succDomains[] = $k; } elseif ($v === 3) { $verifyDomains[$k] = 1; } else { $failDomains[$k] = '不符合专题拍卖条件'; } } } if (empty($succDomains)) { return array('flag' => TRUE, 'msg' => array('succ' => array(), 'fail' => $failDomains)); } if (in_array($type, array(4, 5))) { //专题拍卖和易卖易卖是否需要审核 foreach ($succDomains as $v) { $this->goSer->call($v, 'DomainLogic::checkOtherTrans', array($v, $type)); } $res = $this->goSer->send(); $succDomains = array(); foreach ($res as $k => $v) { $v = $v['DomainLogic::checkOtherTrans']; if (isset($v['goError'])) { $failDomains[$k] = '系统繁忙,请重试'; } else { if ($v === 1) { $succDomains[] = $k; } elseif ($v === 3) { $verifyDomains[$k] = 1; } else { $failDomains[$k] = '不符合专题拍卖条件'; } } } if (empty($succDomains)) { return array('flag' => TRUE, 'msg' => array('succ' => array(), 'fail' => $failDomains)); } //专题是否存在 foreach ($succDomains as $v) { $this->goSer->call($v, 'DomainLogic::checkTopId', array($domains[$v]['topic'])); } $res = $this->goSer->send(); $succDomains = array(); foreach ($res as $k => $v) { $v = $v['DomainLogic::checkTopId']; if (isset($v['goError'])) { $failDomains[$k] = '系统繁忙,请重试'; } else { if ($v === true) { $succDomains[] = $k; } else { $failDomains[$k] = '专题不存在'; } } } if (empty($succDomains)) { return array('flag' => TRUE, 'msg' => array('succ' => array(), 'fail' => $failDomains)); } } } // step2:检测域名简介是否包含关键词 // 检测出售天数,价格 // 使用go并行处理 foreach ($succDomains as $v) { $this->goSer->call($v, 'DomainLogic::checkBaseInfo', array($domains[$v], $type)); } $res = $this->goSer->send(); $succDomains = array(); foreach ($res as $k => $v) { $v = $v['DomainLogic::checkBaseInfo']; if (isset($v['goError'])) { $failDomains[$k] = '系统繁忙,请重试'; } else { if ($v['flag'] === true) { $succDomains[] = $k; } else { $failDomains[$k] = $v['msg']; } } } if (empty($succDomains)) { return array('flag' => TRUE, 'msg' => array('succ' => array(), 'fail' => $failDomains)); } // step3:存在我司域名调用判断我司域名是否可发布 // 非我司域名判断是否$domains里面有非我司域名,有的话从redis中取出 // 上一步缓存的已经认证过的域名,排除$domains里面非我司域名那个数组 // 里面不在缓存中得域名 // 通过go并行调用返回数据 foreach ($succDomains as $v) { $this->goSer->call($v, 'DomainLogic::checkMyDomain', array($uId, $v)); } $res = $this->goSer->send(); $enameDomains = $notInEnameDomains = array(); foreach ($res as $k => $v) { $v = $v['DomainLogic::checkMyDomain']; if (isset($v['goError'])) { $failDomains[$k] = '系统繁忙,请重试'; } else { $inEname = $v['flag']; if ($inEname == 1) { $enameDomains[$k] = $v['msg']; $domains[$k]['expireTime'] = strtotime($v['msg']['expireTime']); $domains[$k]['isOur'] = 1; } elseif ($inEname == 2) { $whois = $redis->get('whois:' . $uId . $k); if ($whois) { $notInEnameDomains[] = $k; $domains[$k]['expireTime'] = strtotime($whois); $domains[$k]['isOur'] = 2; } else { $failDomains[$k] = '非我司域名认证失败'; } } else { $failDomains[$k] = $v['msg']; } if (isset($domains[$k]['expireTime'])) { $minute = rand(0, 59); $domains[$k]['endTime'] = strtotime(date('Y-m-d', time() + 86400 * $domains[$k]['day']) . ' ' . $domains[$k]['hour'] . ':' . $minute . ':00'); if ($domains[$k]['endTime'] > $domains[$k]['expireTime']) { $domains[$k]['endTime'] = $domains[$k]['expireTime']; $domains[$k]['endTimeChange'] = true; } } } } if (empty($enameDomains) && empty($notInEnameDomains)) { return array('flag' => TRUE, 'msg' => array('succ' => array(), 'fail' => $failDomains)); } // 我司域名检测 状态 注册时间和 过期时间 $succComDomains = array(); if (!empty($enameDomains)) { $res = $this->comCheck($uId, $enameDomains, $type); $succComDomains = $res[0]; $failDomains = array_merge($failDomains, $res[1]); } // 非我我司域名检测 tld 和 是否在黑名单 $succNonComDomains = array(); if (!empty($notInEnameDomains)) { $res = $this->nonComCheck($uId, $notInEnameDomains); $succNonComDomains = $res[0]; $failDomains = array_merge($failDomains, $res[1]); } if (empty($succComDomains) && empty($succNonComDomains)) { return array('flag' => TRUE, 'msg' => array('succ' => array(), 'fail' => $failDomains)); } // step4:域名检测是否在交易中 $succComTranDomains = array(); if (!empty($succComDomains)) { $res = $this->isDomainTrans($succComDomains, $type); $succComTranDomains = $res[0]; $failDomains = array_merge($failDomains, $res[1]); } $succNonComTranDomains = array(); if (!empty($succNonComDomains)) { $res = $this->isDomainTrans($succNonComDomains, $type); $succNonComTranDomains = $res[0]; $failDomains = array_merge($failDomains, $res[1]); } if (empty($succComTranDomains) && empty($succNonComTranDomains)) { return array('flag' => TRUE, 'msg' => array('succ' => array(), 'fail' => $failDomains)); } $succLockDomains = array(); $succFreezeDomains = array(); // step6:对于可发布的我司域名和非我司域名 // 处理我司域名锁定 if (!empty($succComTranDomains)) { foreach ($succComTranDomains as $k => $v) { $this->goSer->call($k, 'DomainLogic::lockDomain', array($k)); } $res = $this->goSer->send(); foreach ($res as $k => $v) { $v = $v['DomainLogic::lockDomain']; if (isset($v['goError'])) { $failDomains[$k] = '系统繁忙,请重试'; } else { $domains[$k]['orderId'] = 0; if ($v) { $succLockDomains[$k] = 1; } else { $failDomains[$k] = '域名锁定失败'; } } } } //非我司域名冻结保证金 if (!empty($succNonComTranDomains)) { foreach ($succNonComTranDomains as $k => $v) { $this->goSer->call($k, 'DomainLogic::freezeMoney', array($uId, $k, \core\Config::item('baozhengjin')->fabu)); } $res = $this->goSer->send(); foreach ($res as $k => $v) { $v = $v['DomainLogic::freezeMoney']; if (isset($v['goError'])) { $failDomains[$k] = '系统繁忙,请重试'; } else { if ($v) { $domains[$k]['orderId'] = $v; $succFreezeDomains[$k] = 1; } else { $failDomains[$k] = '保证金冻结失败'; } } } } // step5:从step3和step4里面合并获取可发布的我司域名和非我司域名 // 调用go去并行处理我司和非我司的可发布情况返回来 $succDomains = array_merge($succFreezeDomains, $succLockDomains); if (empty($succDomains)) { return array('flag' => TRUE, 'msg' => array('succ' => array(), 'fail' => $failDomains)); } // 从redis里面获取域名是否推荐数据进行标识 // 同时将推荐域名推到redis中做bbs推荐 // 调用go并发处理 foreach ($succDomains as $k => $v) { $promote = $redis->exists('promote:' . $uId . $k); if ($promote) { $domains[$k]['isHot'] = 1; $bbs = $redis->lRange('bbs:domain', 0, -1); if (!in_array($uId, $bbs)) { $redis->lPush('bbs:domain', $uId); } } else { $domains[$k]['isHot'] = 0; } } // step7:将域名写入交易表 // 调用go并行处理 foreach ($succDomains as $k => $v) { $this->goSer->call($k, 'DomainLogic::publicDomain', array($uId, $k, $domains[$k]['description'], $domains[$k]['expireTime'], $type, $domains[$k]['price'], $domains[$k]['endTime'], $cashType, $domains[$k]['isOur'], $domains[$k]['isHot'], $ip, $domains[$k]['orderId'])); } $res = $this->goSer->send(); $succInsertDomains = array(); foreach ($res as $k => $v) { $v = $v['DomainLogic::publicDomain']; if (isset($v['goError'])) { $failDomains[$k] = '系统繁忙,请重试'; } else { if ($v) { $succInsertDomains[$k] = isset($domains[$k]['endTimeChange']) ? $domains[$k]['endTime'] : 0; } else { $failDomains[$k] = '写入交易表失败'; } } } $msg = array('succ' => $succInsertDomains, 'fail' => $failDomains); //加入审核表 $succVerifyDomains = array(); if ($verifyDomains) { foreach ($verifyDomains as $k => $v) { $this->goSer->call($k, 'DomainLogic::publicToCheck', array($uId, $k, $domains[$k]['description'], $domains[$k]['expireTime'], $type, $domains[$k]['price'], $domains[$k]['endTime'], $cashType, $domains[$k]['isOur'], $domains[$k]['isHot'], $ip, $domains[$k]['topic'], $domains[$k]['orderId'])); } $res = $this->goSer->send(); foreach ($res as $k => $v) { $v = $v['DomainLogic::publicToCheck']; if (isset($v['goError'])) { $failDomains[$k] = '系统繁忙,请重试'; } else { if ($v) { $succVerifyDomains[$k] = isset($domains[$k]['endTimeChange']) ? $domains[$k]['endTime'] : 0; } else { $failDomains[$k] = '写入审核表失败'; } } } } $msg = array('succ' => $succInsertDomains, 'fail' => $failDomains, 'verify' => $succVerifyDomains); return array('flag' => TRUE, 'msg' => $msg); } catch (\Exception $e) { \core\Logger::write('FABU', array('出现异常', $e->getMessage(), $e->getFile(), $e->getLine())); return array('flag' => FALSE, 'msg' => $e->getMessage()); } }
/** * 非我司域名的邮箱验证 * * @param int $uId * enameId * @param string $domain * 域名 * @param array $whoisInfo * 域名的信息 * @param array $userEmails * 用户认证的邮箱 * @return boolean */ public function checkUserEmail($uId, $domain, $whoisInfo, $userEmails) { if ($userEmails) { $emails = $this->verifyEmailConv($userEmails); if (empty($emails) || empty($whoisInfo['AdministrativeEmail']) || !in_array(strtolower($whoisInfo['AdministrativeEmail']), $emails)) { return false; } else { $redis = \core\driver\Redis::getInstance('default'); $redis->setex('whois:' . $uId . $domain, 30 * 60, $whoisInfo['ExpirationDate']); return TRUE; } } else { return false; } }