/** * 从new_tao表中找出状态为15的交易,请求dc接口解锁域名,解锁成功后,将该记录复制到new_trans_history表,同时从new_tao表删除该记录 * * * */ public function downAction() { $taoModel = new NewTaoModel(); $taoData = $taoModel->getDataByStatus(15); if (!empty($taoData)) { $dLogic = new DomainLogic(); foreach ($taoData as $v) { $data[$v->t_id] = (array) $v; $res = $dLogic->setDomainStatus(\core\Config::item('doPubSta')->toArray()['down'], 1); if ($res !== true) { unset($data[$v->t_id]); echo "解锁new_tao状态为15的域名id{$v->t_id}失败,解锁时间:" . date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . "\n"; } } if (!empty($data)) { $data = array_values($data); $TransLogic = new TransLogic(); //将信息更新到历史表中,并在new_tao中删除 foreach ($data as $v) { $copyRes = $TransLogic->copyToHistory($v, $v['t_status']); $delRes = $TransLogic->delByTid($v['t_id']); if (!$copyRes) { echo "域名id{$v['t_id']}解锁成功,但在插入new_trans_history时发生错误.时间:" . date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . "\n"; } if (!$delRes) { echo "域名id{$v['t_id']}解锁成功,但在从new_tao删除该条记录时发生错误.时间:" . date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . "\n"; } } } } }
/** * 定时处理竞价结束的数据处理 * * */ public function checkAcuctionStatusAction() { // step1 取出已过交易结束时间,类型为竞价的并且有买家id的交易记录 $taoModel = new NewTaoModel(); $taoData = $taoModel->getExpiredByType(\core\Config::item('isInquiry')->toArray()[1], time()); // step2 将step1的记录修改状态为等待买卖双方确认的状态,存到new_trans_result表,并更新用户关注表 $historyModel = new NewTransHistoryModel(); $transLogic = new TransLogic(); if (!empty($taoData)) { foreach ($taoData as $data) { $data = get_object_vars($data); $data['t_status'] = 2; //存表 if ($historyModel->setTransHistory($data)) { //更新用户关注表 if ($transLogic->updateWatchInfo($data['t_id'], $data['t_now_price'], $data['t_nickname'], $endTime = $data['t_end_time'])) { // step3 删除new_tao里面该条交易记录 if ($taoModel->delByTid($data['t_id'])) { echo 'tid 为' . $data['t_id'] . '操作成功'; } else { echo 'tid 为' . $data['t_id'] . '删除net_tao原表数据失败'; } } else { echo 'tid 为' . $data['t_id'] . '更新用户关注表失败'; } } else { echo 'tid 为' . $data['t_id'] . '复制到history 失败'; } } } }
/** * 定时从new_tao表删除指定状态的数据 * 指定状态为:交易成功,等待卖家确认,管理员取消交易 * * * */ public function delFromTaoAction() { $status = \core\Config::item('transStaCode'); $status = array($status->tranSuc, $status->buyHasCon, $status->adminCanceled); $newTaoModel = new NewTaoModel(); $res = $newTaoModel->delDataByStatus($status); echo "删除{$res}条记录" . PHP_EOL; }
/** * 卖家违约流程 * @param array $data 交易结果表全部字段的记录 */ public function main(array $data) { if (!in_array($data['t_status'], array(2, 4))) { throw new \Exception('交易状态错误不能执行违约操作'); } $dn = $data['t_dn']; $money = $data['t_now_price']; $buyer = $data['t_buyer']; $seller = $data['t_enameId']; $sellerOrderId = $data['t_seller_order']; //卖家保证金订单 $orderId = $this->createOrder($dn, $money, $buyer, $seller, $sellerOrderId); if (!$orderId) { return false; //违约失败 } // 设置卖家违约 $newTao = new \NewTaoModel(); $newTao->updateTrans(array("t_status" => 7), array("t_id" => $data['t_id'])); // 如果是我司域名 解锁域名 if (1 == $data['t_is_out']) { $domains = new \common\Domain(); $domains->lockDomain($data['t_dn'], 1); } // 如果买家已经确认 取消买家支付订单 一口价买家肯定是确认状态 $finance = new \finance\Orders($buyer); if (!$finance->cancelOrder($data['t_order_id'])) { //log } // 如果买家未确认 取消买家保证金订单 一口价没有这个 竞价才有这个 // 确认违约订单 // $moneyType['UNWITHDRAWAL'] $finance = new \finance\Orders($seller); if ($finance->confirmOrder($orderid, 2, $buyer)) { //log } // 违约是否要评论 //移动交易记录 到历史表 $newHistory = new \NewTransHistoryModel(); if (!$newHistory->setTransHistory($data)) { //log } // 通知卖家 $nowTime = date('Y-m-d H:i:s'); $message = new \common\Message(); $message->sendAuctionBuyerrefuseSeller($dn, $nowTime, $id, $seller); // 通知买家 $message->sendAuctionBuyerrefuseBuyer($dn, $nowTime, $id, $buyer); return true; }
public function deleteDataAction() { $esFile = ROOT_PATH . './app/tasks/es.id'; $startId = @file_get_contents($esFile); $limit = 200; $newTaoModel = new \NewTaoModel(); $list = $newTaoModel->getListForDeleteEs($startId, $limit); $es = \core\Config::item('elasticSearch'); $client = \Elasticsearch\ClientBuilder::create()->setHosts(array($es['server']))->build(); echo 'start:' . time() . "\n"; foreach ($list as $v) { $params = ['index' => $es['index'], 'type' => $es['type'], 'id' => $v->t_id]; $response = $client->delete($params); $startId = $v->t_last_time; } file_put_contents($esFile, $startId); echo 'end:' . time() . "\n"; }
/** * 根据tid删除数据 * return effected_rows */ public function delByTid($tid) { $taoModel = new NewTaoModel(); return $taoModel->delByTid($tid); }
/** * 写入交易表 * $uId int [用户uid] * $domain string [域名] * $desc string [域名简介] * $expireTime int [域名到期时间] * $type int [交易类型:1-一口价;2-竞价;3-竞价(预订竞价);4-竞价(专题拍卖);5-竞价(易拍易卖);] * $price int [价格] * $endTime int [交易结束时间] * $moneyType int [是否提现:2-不可提现;3-可提现] * $isOur int [是否我司域名:1-是;2-否] * $isHot int [是否用户推荐:0-否;1-是] * $ip string [客户端ip] * $orderId int [保证金订单id] * $startTime int [拍卖时间] */ public function publicDomain($uId, $domain, $desc, $expireTime, $type, $price, $endTime, $moneyType, $isOur, $isHot, $ip, $orderId = false, $startTime = false) { $domainInfo = new \common\Common(); $body = $domainInfo->getDomainBody($domain); $domainClass = \common\domain\Domain::getDomainClass($domain); $data = array('t_dn' => $domain, 't_body' => $domainClass[4], 't_type' => $type, 't_enameid' => $uId, 't_start_price' => $price, 't_now_price' => $price, 't_create_time' => $_SERVER['REQUEST_TIME'], 't_start_time' => $startTime ? $startTime : $_SERVER['REQUEST_TIME'], 't_end_time' => $endTime, 't_tld' => $domainInfo->getTldType($domain), 't_len' => $domainClass[3], 't_desc' => $desc, 't_money_type' => $moneyType, 't_ip' => $ip, 't_is_our' => $isOur, 't_exp_time' => $expireTime, 't_hot' => $isHot, 't_class_name' => $domainClass[0], 't_two_class' => !$domainClass[1] ? 0 : $domainClass[1], 't_three_class' => !$domainClass[2] ? 0 : $domainClass[2]); // 非我司域名,获取保证金订单信息 if ($isOur !== 1) { if ($orderId) { $data['t_seller_order'] = $orderId; } else { return array('flag' => '10001', 'msg' => '非我司域名须提交保证金订单id'); } } $taoModel = new NewTaoModel(); $taoId = $taoModel->setDoaminInfo($data); if (!$taoId) { \core\Logger::write("domain.log", array(__METHOD__, "域名{$domain}发布插入到交易表new_tao失败,用户id:{" . $uId . "},发布时间:" . date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']))); } return $taoId; }