public static function &getInstance() { if (self::$_instance === null) { self::$_instance = new self(); } return self::$_instance; }
/** * * 插入欠费队列,及其后面流程(修改consume表状态,adset表状态,和插入队列日志表) * @param $adSetData * @param $adConsumeData * @param $balance * @param $consumeStatus * @param $apiResult * @param $otherData */ protected function insertArrearage($adSetData, $adConsumeData, $balance, $consumeStatus, $apiResult, $otherData) { // 插入欠费队列表 $tmpResult = Bll_Broker_ShowcaseArrearageQuery::getInstance()->addArrearageData($adConsumeData->brokerId, $adConsumeData->dateIndex, $adConsumeData->price, $balance, $adConsumeData->id, $adConsumeData->requestId, $apiResult, $otherData, $this->_dateBase); if ($tmpResult['status'] == 0) { // 插入失败,中断执行 $adConsumeData->status = 0; $adConsumeData->updateTime = date("Y-m-d H:i:s", time()); $adConsumeData->save(); $msg = "插入欠费队列失败"; $this->setMyFlag($adSetData->id, $msg); $this->textOutput($adSetData, $msg); } else { $updateArr = array('status' => $consumeStatus, 'balance' => $balance); $this->updateAdConsumeLogTable($adConsumeData, $updateArr, 1, $apiResult['apiData'], $otherData); } }
public function handle_request() { $list = Bll_Broker_ShowcaseArrearageQuery::getInstance()->getBrokerSumList($this->_lastAdSetId, $this->_dateBase); //$list = Bll_Broker_ShowcaseArrearageQuery::getInstance()->getBrokerSumList(0,$this->_dateBase); if ($list) { foreach ($list as $val) { $this->setMyFlag($val['broker_id']); $data = array('brokerId' => $val['broker_id']); $orderinfo = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerOrders($data, $this->_dateBase); if ($orderinfo) { $lavedays = ceil((strtotime($orderinfo->endDate) - strtotime(date('Ymd'))) / 3600 / 24); $brokerInfo = new Model_Broker_AjkBrokerExtend(); $info = $brokerInfo->getDataByBrokerId($val['broker_id']); $tmp = array('cityId' => $info['cityId'], 'status' => 1, 'startDate' => date('Ymd')); $cityPrice = Bll_Broker_ConfigCityPrice::getInstance()->getCityPrice($tmp, $this->_dateBase); $isComboCity = $this->isComboCity($orderinfo->cityId); if ($isComboCity['code'] == 200) { if ($isComboCity['data']) { if ($val['cnt'] >= 1) { if ($orderinfo->isStop == 0 && $lavedays > 0) { $stopstatus = Bll_Broker_ShowcaseOrders::getInstance()->stopBrokerOthersAuto($orderinfo, $cityPrice->discountPrice, $this->_dateBase); if (!$stopstatus['status']) { $this->getError($this->_dateBaseName, $val['broker_id']); } } } } else { if ($val['cnt'] >= 7) { if ($orderinfo->isStop == 0 && $lavedays > 0) { $stopstatus = Bll_Broker_ShowcaseOrders::getInstance()->stopBrokerOthersAuto($orderinfo, $cityPrice->discountPrice, $this->_dateBase); if (!$stopstatus['status']) { $this->getError($this->_dateBaseName, $val['broker_id']); } } } } } } /* if($val['cnt']>=7){ $data = array('brokerId'=>$val['broker_id']); $orderinfo = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerOrders($data,$this->_dateBase); if($orderinfo){ $lavedays = ceil((strtotime($orderinfo->endDate)-strtotime(date('Ymd')))/3600/24); if($orderinfo->isStop==0 && $lavedays > 0 ){ $brokerInfo =new Model_Broker_AjkBrokerExtend(); $info = $brokerInfo->getDataByBrokerId($val['broker_id']); $tmp = array('cityId'=>$info['cityId'],'status'=>1,'startDate'=>date('Ymd')); $cityPrice = Bll_Broker_ConfigCityPrice::getInstance()->getCityPrice($tmp,$this->_dateBase); $stopstatus = Bll_Broker_ShowcaseOrders::getInstance()->stopBrokerOthers($orderinfo,$cityPrice->discountPrice,$this->_dateBase); if(!$stopstatus['status']){ $mailSubject = date('Ymd').$this->_dateBaseName.'停止订单出错问题'; $mailBody =$this->_dateBaseName.'的二手房经纪人id:'.$val['broker_id']; Bll_Broker_ShowcaseCommon::getInstance()->sendMail($mailSubject,$mailBody,$this->mailArr); } } } } */ } } else { $this->setMyFlag($this->getLastJobId(), 'over'); $mailSubject = $this->yDate . $this->subject; $mailBody = $mailSubject . "完成 完成时间:" . date("Y-m-d H:i:s", time()); Bll_Broker_ShowcaseCommon::getInstance()->sendMail($mailSubject, $mailBody, $this->mailArr); $this->setShStopFlag(); exit; } }
/** * 获取需要跑的数据 * @return array */ public function getRequestData() { $data = Bll_Broker_ShowcaseArrearageQuery::getInstance()->getDataByBiggerThanId($this->_lastArrearageId, array(0, 2), 'id', 'asc', 0, $this->_limit, $this->_dateBase); if (empty($data)) { // 发生邮件通知 $this->textOutput('', "已经没有待处理数据了", false); $this->setMyFlag(0, 'over'); $this->setShStopFlag(); } else { return $data; } }
/** * 判断有没套餐推广 * 没有则返钱 * @param $task * @return bool */ public function dealTask($task) { $brokerId = $task['brokerId']; // 判断这天有没套餐推广记录 $yesterdayComboPropData = Bll_Broker_ShowcaseAdSetPro::getInstance()->getComboBrokerHouses($brokerId, $this->returnDay, $this->_dataBase); if ($yesterdayComboPropData > 0) { printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '经纪人' . $brokerId . '已经推广了套餐房源,不需要返钱'); return true; } if ($task['status'] == 4) { // 欠费 $opType = Const_ShowcaseOrders::OPTYPE_4; $updateArreargeResult = Bll_Broker_ShowcaseArrearageQuery::getInstance()->updateOneData(array('dateIndex' => $this->returnDay, 'brokerId' => $brokerId), array('status' => 4), $this->_dataBase); printf('经纪人[%s]: 更新欠费队列:%s' . PHP_EOL, $brokerId, $updateArreargeResult ? '成功' : '失败'); } else { $opType = Const_ShowcaseOrders::OPTYPE_9; // 二手房 1331 // 好租 1371 if ($this->_dataBase == Const_ShowcaseOrders::RENT_DB) { $type = 1371; $msg = '租房'; } else { $type = 1331; $msg = '二手房'; } try { // 返钱 $addQueueResult = BLL_Payment_AjkPpccoinQueen::addReturnQueue($brokerId, $task['cityId'], $type, $task['price'], $msg . '橱窗未展示退费'); } catch (Exception $e) { $addQueueResult = false; } printf('经纪人[%s]: 返钱:%s' . PHP_EOL, $brokerId, $addQueueResult ? '成功' : '失败'); } // 记录ad_set_log日志 $adSetLogArr = array('brokerId' => $task['brokerId'], 'cityId' => $task['cityId'], 'totalDays' => (int) ((time() - strtotime($task['startDate'])) / 86400), 'startDate' => $task['startDate'], 'endDate' => date('Ymd', strtotime('-1 day')), 'opType' => $opType, 'createTime' => $task['createTime']); Bll_Broker_ShowcaseOrders::getInstance()->insertSetLog($adSetLogArr, $this->_dataBase); return true; }