public static function &getInstance() { if (self::$_instance === null) { self::$_instance = new self(); } return self::$_instance; }
public function handle_request_internal() { if (!Bll_City::isShowCaseCity(static::$intBrokerCityID)) { $this->redirect('/user/combo/brokerhome'); exit; } $this->apf = APF::get_instance(); $this->request = $this->apf->get_request(); $this->response = $this->apf->get_response(); $this->params = $this->request->get_parameters(); //回调地址 $r_url = base64_decode($this->params['r_url']); if (empty($r_url)) { $r_url = $_SERVER['HTTP_REFERER']; if (empty($r_url)) { $r_url = '/ajkbroker/showcase/zf'; } } $msg = $this->params['msg']; if (!$msg) { //没有报错信息,就是提示成功 $type = $this->params['type'] ? $this->params['type'] : Const_ShowcaseOrders::SALE_DB; //二手房经纪人ID $brokerId = self::$BrokerInfo['BaseInfo']['BROKERID']; if ($type == Const_ShowcaseOrders::SALE_DB) { //二手房 $proCountMax = Const_ShowcaseOrders::SALE_PRO_MAX_COUNT; $brokerAdProInfos = Bll_Broker_ShowcaseAdSetPro::getInstance()->getBrokerAdSalePropInfo($brokerId, true); $brokerAdInfo = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerOrders(array('brokerId' => $brokerId), Const_ShowcaseOrders::SALE_DB); } else { //租房 $proCountMax = Const_ShowcaseOrders::RENT_PRO_MAX_COUNT; $brokerAdProInfos = Bll_Broker_ShowcaseAdSetPro::getInstance()->getBrokerAdRentPropInfo($brokerId, true); $brokerAdInfo = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerOrders(array('brokerId' => $brokerId), Const_ShowcaseOrders::RENT_DB); } //订单信息不存在 if (empty($brokerAdInfo)) { APF::get_instance()->get_response()->redirect($r_url); } $dayCount = ceil((strtotime($brokerAdInfo->endDate) - strtotime($brokerAdInfo->startDate)) / 86400) + 1; $this->request->set_attribute('dayCount', $dayCount); $this->request->set_attribute('proCount', count($brokerAdProInfos)); $this->request->set_attribute('proCount', count($brokerAdProInfos)); $this->request->set_attribute('leftProCount', $proCountMax - count($brokerAdProInfos)); //橱窗价格 $tmp = array('cityId' => self::$BrokerInfo['BaseInfo']['CITYID'], 'status' => 1, 'startDate' => date('Ymd')); $cityPrice = Bll_Broker_ConfigCityPrice::getInstance()->getCityPrice($tmp, $type); $this->request->set_attribute('price', !empty($cityPrice->discountPrice) ? round($cityPrice->discountPrice / 100, 2) : 8); } //报错信息 $this->request->set_attribute('msg', $msg); $this->request->set_attribute('r_url', $r_url); return 'Showcase_Error'; }
/** * 检验是否有推广房源 */ public function checkHasHouse() { $result = Bll_Broker_ShowcaseAdSetPro::getInstance()->checkHasBrokerHouses($this->yDate, $this->_dateBase); $combo = Bll_Broker_ShowcaseAdSetPro::getInstance()->checkHasComboBrokerHouses($this->yDate, $this->_dateBase); if ($result['status'] == false || $combo['status'] == false) { // 报警处理,发送短信 $content = $this->subject . " 没有推广房源,当前job执行时间为" . date("Y-m-d H:i:s", time()); Bll_Broker_ShowcaseCommon::getInstance()->sendAlertMsg($this->mobileArr, $content); $this->setShStopFlag(); exit; } }
public function handle_request() { $adConsumeList = $this->getRequestData(); $sengMail = array(); $i = $id = 0; foreach ($adConsumeList as $adConsumeVal) { $id = $adConsumeVal->id; $sengMail[$i]['brokerId'] = $adConsumeVal->brokerId; $sengMail[$i]['dateIndex'] = $adConsumeVal->dateIndex; ++$i; $this->createTime = time(); $updateConsumeArr = array(); $oldStatus = $adConsumeVal->status; /* *1.设置ad_consume.status = 1,为正在处理中 更新ad_consume为处理状态(更新失败,跳出继续执行下一跳数据) */ $check = Bll_Broker_ShowcaseConsumeQuery::getInstance()->updateConsumeInfo($this->consumeDateIndex, array('id' => $adConsumeVal->id, 'status' => $this->consumeStatus), array('status' => 1), $this->_dateBase); if ($check['status'] == false) { $this->callBackOldStatus($adConsumeVal, $oldStatus); continue; } /* * 2.判断欠费表是否已经存在,如果存在则执行下一条 */ $tmpArrearageData = Bll_Broker_ShowcaseArrearageQuery::getInstance()->getDataByBrokerIdAndDateIndex($adConsumeVal->brokerId, $this->consumeDateIndex, $this->_dateBase); if (!empty($tmpArrearageData)) { $this->callBackOldStatus($adConsumeVal, $oldStatus); continue; } /* * 3.更新相关数据 */ // 判断 request_id 值是否存在,否则更新 if (empty($adConsumeVal->requestId)) { // 生存requestId,并保存 $requestId = Bll_Broker_ShowcaseConsumeQuery::getInstance()->getPayMentRequestId($adConsumeVal->id, $adConsumeVal->dateIndex, $this->_dateBase); $updateConsumeArr['requestId'] = $requestId; $adConsumeVal->requestId = $requestId; } // 判断 price是否存在,否则则更新 if (empty($adConsumeVal->price)) { $tmpArr = array('cityId' => $adConsumeVal->cityId, 'status' => 1, 'startDate' => $this->consumeDateIndex); $tmpCityPrice = Bll_Broker_ConfigCityPrice::getInstance()->getCityPrice($tmpArr, $this->_dateBase); if ($tmpCityPrice) { $updateConsumeArr['price'] = $tmpCityPrice->discountPrice > 0 ? $tmpCityPrice->discountPrice : 0; $adConsumeVal->price = $updateConsumeArr['price']; } } // 判断昨日推广房源是否存在 if (empty($adConsumeVal->houseNum)) { $yesterdayPropData = Bll_Broker_ShowcaseAdSetPro::getInstance()->getBrokerHouses($adConsumeVal->brokerId, $this->consumeDateIndex, $this->_dateBase); if ($yesterdayPropData <= 0) { $updateConsumeArr['status'] = 2; $this->updateAdConsumeLogTable($adConsumeVal, $updateConsumeArr, 1, '', '无主推房源'); continue; } else { $updateConsumeArr['houseNum'] = $yesterdayPropData; $adConsumeVal->houseNum = $yesterdayPropData; } } // 更新balance $userId = Bll_Broker_BrokerCheckInfo::getUserIdByBrokerId($adConsumeVal->brokerId, $this->_dateBase); $balance = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerMoney($userId); $balance = $balance * 100; $this->updateAdConsumeLogTable($adConsumeVal, $updateConsumeArr, 1); /* * 插入欠费表 */ $this->insertArrearage($adConsumeVal, $balance, $this->consumeStatus); /* * 执行结束 */ $this->callBackOldStatus($adConsumeVal, $oldStatus); } // 设置游标 $this->setMyFlag($id); $this->sengDeal($sengMail); }
/** * 获取租房房源数据 * [getBrokerEsfPro description] */ private function getBrokerZfPro() { $data = $proClickInfo = array(); $isCombo = Bll_Combo_HouseRelation::isComboCity($this->cityId); if ($isCombo['data']) { $comboList = Bll_Combo_HouseRelation::getHouseRelations($this->brokerId, Bll_Combo_HouseRelation::SITE_TYPE_HZ, 1); $proIds = $this->getObjFieldInfo($comboList, 'houseId'); $clicksInfo = Bll_Ppc_NewPackageStatsBrokerDay::getHouseComboClickInfo($proIds, date('Ymd'), Model_Ppc_NewPackageStatsHouseDay::SITE_TYPE_HZ); if (!empty($clicksInfo)) { foreach ($clicksInfo as $val) { if (isset($proClickInfo[$val['propId']])) { $proClickInfo[$val['propId']] += intval($val['cnum']); } else { $proClickInfo[$val['propId']] = intval($val['cnum']); } } } } else { $hzBrokerId = Bll_Broker_BrokerCheckInfo::getHzBrokerIdByAjkBrokerId($this->brokerId); //定价房源信息 $fixedProInfos = Bll_House_FixedPro::getInstance()->getBrokerHzFiexdProInfo($hzBrokerId); if (empty($fixedProInfos)) { $this->outData($data, 1); } $proIds = $this->getObjFieldInfo($fixedProInfos, 'proid'); //房源点击量信息 $proClicks = Bll_House_HzPro::getInstance()->getProClicks($proIds, array(), date('Ymd')); if (!empty($proClicks)) { //将房源ID作为key拼接点击量信息 foreach ($proClicks as $proClickVal) { $proClickInfo[$proClickVal['proid']] = intval($proClickVal['cnt']); } } } $proInfos = Bll_House_HzPro::getInstance()->getBrokerHzProInfo($proIds, $this->cityId); if (empty($proInfos)) { $this->outData($data, 1); } //经纪人橱窗房源设置信息 $adProInfos = Bll_Broker_ShowcaseAdSetPro::getInstance()->getBrokerAdRentPropInfo($this->brokerId); $addPro = array(); if (!empty($adProInfos)) { foreach ($adProInfos as $adProVal) { $addPro[$adProVal->propId] = true; } } //房源主表信息 $propMianInfo = Bll_House_HzPro::getInstance()->getHzProInfoByIds($proIds); $propMianNew = array(); foreach ($propMianInfo as $propMianVal) { $propMianNew[$propMianVal->propId]['contentBasic'] = json_decode($propMianVal->contentBasic, true); $propMianNew[$propMianVal->propId]['contentOther'] = json_decode($propMianVal->contentOther, true); } $this->initZfProData($proInfos, $proClickInfo, $addPro, $propMianNew); }
/** * 插入展示房源信息 * @param $proIds * @param $brokerId * @param $cityId * @param $type */ private function insertBrokerShowPros($proIds, $brokerId, $cityId, $type) { foreach ($proIds as $proId) { $insertData = array(); if ($this->jobType == Const_ShowcaseOrders::RENT_DB) { //租房经纪人ID $insertData['hzUserId'] = $this->actionBrokerId; } $insertData['brokerId'] = $brokerId; $insertData['cityId'] = $cityId; $insertData['propId'] = $proId; $insertData['type'] = $type; $insertData['createTime'] = time(); if ($this->jobType == Const_ShowcaseOrders::SALE_DB) { $insertRes = Model_Broker_AdPropsShowSale::getInstance()->insertData($insertData); } elseif ($this->jobType == Const_ShowcaseOrders::RENT_DB) { $insertRes = Model_Broker_AdPropsShowRent::getInstance()->insertData($insertData); } //插入房源变更日志 if (!empty($insertRes)) { //插入日志表 $this->insertProLog($proId, $brokerId, $cityId, $type, Const_ShowcaseOrders::PRO_CHANGE_LOG_FLAG_IN); } } //向中间件发送房源上架消息 Bll_Broker_ShowcaseAdSetPro::getInstance()->sendAdProChangeMes($brokerId, $cityId, array(Const_ShowcaseOrders::SHOWCASE_SET), $proIds, $this->jobType); }
public function handle_request_internal() { if (!Bll_City::isShowCaseCity(static::$intBrokerCityID)) { $this->redirect('/user/combo/brokerhome'); exit; } //获取经纪人id $objRequest = APF::get_instance()->get_request(); $cityid = self::$BrokerInfo['BaseInfo']['CITYID']; $objRequest->set_attribute('PayType', self::$BrokerInfo['BaseInfo']['PAYTYPE']); $isCombo = Bll_Combo_HouseRelation::isComboCity($cityid); $tmp = array('cityId' => $cityid, 'status' => 1, 'startDate' => date('Ymd')); $cityPrice = Bll_Broker_ConfigCityPrice::getInstance()->getCityPrice($tmp, Const_ShowcaseOrders::RENT_DB); $todayPrice = round($cityPrice->discountPrice / 100, 2); $intBrokerID = $objRequest->getBrokerId(); //好租经纪人ID $hzBrokerId = Bll_Broker_BrokerCheckInfo::getHzBrokerIdByAjkBrokerId($intBrokerID); $userId = $objRequest->getUserId(); $data = array('brokerId' => $intBrokerID); $orderinfo = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerOrders($data, $this->db); //判断经纪人是否有订单 if (!$orderinfo) { $this->toManage('/ajkbroker/showcase/zf/'); } $lavedays = ceil((strtotime($orderinfo->endDate) - strtotime(date('Ymd'))) / 3600 / 24); if ($orderinfo->isStop == 1 || $lavedays < 0) { $order_status = 'stop'; } else { $objRequest->set_attribute('lavedays', $lavedays); $objRequest->set_attribute('lastday', date('Y-m-d', strtotime($orderinfo->endDate))); $order_status = 'open'; } //获取参数值 $params = APF::get_instance()->get_request()->get_parameters(); $days = intval($params['days']); //status=2是停止,status=1是续费 if ($params['status'] == 2) { if ($orderinfo->isStop == 0) { $stopstatus = Bll_Broker_ShowcaseOrders::getInstance()->stopBrokerOthers($orderinfo, $cityPrice->discountPrice, $this->db); if ($stopstatus['status']) { $this->toManage(); } else { $this->toError($stopstatus['msg']); } } else { $msg = '订单类型不能操作'; $this->toError($msg); } } elseif ($params['status'] == 1 && $days >= 1) { $BrokerMoney = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerMoney($userId); if ($BrokerMoney < $todayPrice) { $this->toError(Const_ShowcaseOrders::MONEY_NOT_ENOUGH); } $Continueorder = Bll_Broker_ShowcaseOrders::getInstance()->continueBrokerOthers($orderinfo, $days, $cityPrice->discountPrice, $this->db); if ($Continueorder['status']) { $this->toManage(); } else { $this->toError($Continueorder['msg']); } } elseif ($params['status'] == 3) { if (!empty($params['rooms'])) { $proIds = explode(';', $params['rooms']); $filterProIds = Bll_Broker_ShowcaseAdSetPro::getInstance()->filterProIds($intBrokerID, $cityid, $this->db, $proIds); //有些房源不在线上展示 if (count($filterProIds) != count($proIds)) { $this->toError('有些房源没在线上推广,操作失败!'); } $res = Bll_Broker_ShowcaseAdSetPro::getInstance()->insertAdProsInfo($intBrokerID, $cityid, $proIds, $this->db); if (!$res['status']) { $this->toError($res['msg']); } else { //插入成功,跳转至管理页面 if ($orderinfo->isStop == 0) { $log = array(); $log['brokerId'] = $orderinfo->brokerId; $log['cityId'] = $orderinfo->cityId; $log['endDate'] = $orderinfo->endDate; $log['startDate'] = $orderinfo->startDate; $log['opType'] = Const_ShowcaseOrders::OPTYPE_6; $log['totalDays'] = ceil((strtotime($orderinfo->endDate) - strtotime($orderinfo->startDate)) / 3600 / 24) + 1; $log['createTime'] = time(); Bll_Broker_ShowcaseOrders::getInstance()->insertSetLog($log, $this->db); } $this->toManage(); } } } $orderCreated = date('Ymd', $orderinfo->createTime); if ($orderCreated < date('Ymd')) { $click = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerClick($intBrokerID, date('Ymd', strtotime('-1 days')), $this->db); if (!$click->quantityCount) { $objRequest->set_attribute('YClick', 0); } else { $objRequest->set_attribute('YClick', $click->quantityCount); } $objRequest->set_attribute('IS_YClick', true); } if ($isCombo['data']) { $comboList = Bll_Combo_HouseRelation::getHouseRelations($intBrokerID, Bll_Combo_HouseRelation::SITE_TYPE_HZ, 1); if (!empty($comboList)) { if (count($comboList) >= Const_ShowcaseOrders::SALE_PRO_MAX_COUNT) { $fixedProInfosCnt = Const_ShowcaseOrders::SALE_PRO_MAX_COUNT; } else { $fixedProInfosCnt = count($comboList); } } else { $fixedProInfosCnt = 0; } $proInfo = Bll_Broker_ShowcaseAdSetPro::getInstance()->getBrokerAdRentPropInfo($intBrokerID); $proIds = Bll_Broker_ShowcaseOrders::getInstance()->getObjFieldInfo($proInfo, 'propId'); $proInfos = Bll_House_HzPro::getInstance()->getBrokerHzProInfo($proIds, $cityid); $propMianInfo = Bll_House_HzPro::getInstance()->getHzProInfoByIds($proIds); $propMianNew = array(); foreach ($propMianInfo as $propMianVal) { $propMianNew[$propMianVal->propId]['contentBasic'] = json_decode($propMianVal->contentBasic, true); $propMianNew[$propMianVal->propId]['contentOther'] = json_decode($propMianVal->contentOther, true); } $proList = Bll_Broker_ShowcaseAdSetPro::getInstance()->initComboZfProData($proInfos, $propMianNew, $comboList); } else { $fixedProInfos = Bll_House_FixedPro::getInstance()->getBrokerHzFiexdProInfo($hzBrokerId); if (!empty($fixedProInfos)) { $proIds = Bll_Broker_ShowcaseOrders::getInstance()->getObjFieldInfo($fixedProInfos, 'proid'); $proInfos_tmp = Bll_House_HzPro::getInstance()->getBrokerHzProInfo($proIds, $cityid); $proIdsc = Bll_Broker_ShowcaseOrders::getInstance()->getObjFieldInfo($proInfos_tmp, 'proid'); $proInfosc = Bll_House_HzPro::getInstance()->getBrokerHzProInfo($proIdsc, $cityid); if (!empty($proInfosc)) { if (count($proInfosc) >= Const_ShowcaseOrders::RENT_PRO_MAX_COUNT) { $fixedProInfosCnt = Const_ShowcaseOrders::RENT_PRO_MAX_COUNT; } else { $fixedProInfosCnt = count($proInfosc); } } else { $fixedProInfosCnt = 0; } } else { $fixedProInfosCnt = 0; } $proInfo = Bll_Broker_ShowcaseAdSetPro::getInstance()->getBrokerAdRentPropInfo($intBrokerID); $proIds = Bll_Broker_ShowcaseOrders::getInstance()->getObjFieldInfo($proInfo, 'propId'); $proStatus = Bll_House_FixedPro::getInstance()->getBrokerHzFiexdProStatus($proIds); $proInfos = Bll_House_HzPro::getInstance()->getBrokerHzProInfo($proIds, $cityid); $propMianInfo = Bll_House_HzPro::getInstance()->getHzProInfoByIds($proIds); $propMianNew = array(); foreach ($propMianInfo as $propMianVal) { $propMianNew[$propMianVal->propId]['contentBasic'] = json_decode($propMianVal->contentBasic, true); $propMianNew[$propMianVal->propId]['contentOther'] = json_decode($propMianVal->contentOther, true); } $proList = Bll_Broker_ShowcaseAdSetPro::getInstance()->initZfProData($proInfos, $propMianNew, $proStatus); } if (count($proList) > $fixedProInfosCnt) { $fixedProInfosCnt = count($proList); } $objRequest->set_attribute('type', 'hz'); $objRequest->set_attribute('index', 2); //精选推广开关 $isChoice = Bll_City::isChoiceCity($cityid, Const_Site::HAOZU); $objRequest->set_attribute('isChoice', $isChoice); $objRequest->set_attribute('proList', $proList); $objRequest->set_attribute('fixedProInfosCnt', $fixedProInfosCnt); $objRequest->set_attribute('order_status', $order_status); $objRequest->set_attribute('todayPrice', $todayPrice); return 'Showcase_ZfManage'; }
/** * 判断有没套餐推广 * 没有则返钱 * @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; }
/** * 删除展示房源信息 * @param $brokerId 二手房经纪人ID * @param $cityId 城市ID * @param bool $sendShowcase 是否发送橱窗取消消息 * @param bool $sendProMsg 是否发送房源上架消息 */ private function deleteBrokerShowPro($brokerId, $cityId, $sendShowcase = true, $sendProMsg = true) { if ($sendShowcase) { Bll_Broker_ShowcaseAdSetPro::getInstance()->sendAdProChangeMes($brokerId, $cityId, array(Const_ShowcaseOrders::SHOWCASE_CANCEL), array(), $this->jobType, $this->jobYm); } $proInfos = Bll_Broker_ShowcaseAdSetPro::getInstance()->getBrokerAdPropShowInfo($brokerId, $this->jobType); if (!empty($proInfos)) { $proIds = array(); foreach ($proInfos as $proVal) { $proVal->delete(); $proIds[] = $proVal->propId; //插入日志表 $logData = array(); $logData['brokerId'] = $brokerId; $logData['cityId'] = $proVal->cityId; $logData['propId'] = $proVal->propId; $logData['reason'] = Const_ShowcaseOrders::PRO_CHANGE_LOG_REASON_SHOW_DOWN; $logData['type'] = $proVal->type; $logData['flag'] = Const_ShowcaseOrders::PRO_CHANGE_LOG_FLAG_OUT; $logData['createTime'] = time(); if ($this->jobType == Const_ShowcaseOrders::SALE_DB) { Model_Broker_AdPropsChangeSaleLog::getInstance()->insertOne($logData, $this->jobYm); } else { Model_Broker_AdPropsChangeRentLog::getInstance()->insertOne($logData, $this->jobYm); } } //向中间件发送消息 if ($sendProMsg) { Bll_Broker_ShowcaseAdSetPro::getInstance()->sendAdProChangeMes($brokerId, $cityId, array(Const_ShowcaseOrders::SHOWCASE_CANCEL_SET), $proIds, $this->jobType, $this->jobYm); } } }
public function handle_request_internal() { if (!Bll_City::isShowCaseCity(static::$intBrokerCityID)) { $this->redirect('/user/combo/brokerhome'); exit; } $objRequest = APF::get_instance()->get_request(); $cityID = self::$BrokerInfo['BaseInfo']['CITYID']; $objRequest->set_attribute('PayType', self::$BrokerInfo['BaseInfo']['PAYTYPE']); $tmp = array('cityId' => $cityID, 'status' => 1, 'startDate' => date('Ymd')); $cityPrice = Bll_Broker_ConfigCityPrice::getInstance()->getCityPrice($tmp, Const_ShowcaseOrders::SALE_DB); $todayPrice = round($cityPrice->discountPrice / 100, 2); $intBrokerID = $objRequest->getBrokerId(); $userId = $objRequest->getUserId(); $data = array('brokerId' => $intBrokerID); $orderinfo = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerOrders($data, $this->db); if (!$orderinfo) { $this->toManage('/ajkbroker/showcase/esf/'); } $lavedays = ceil((strtotime($orderinfo->endDate) - strtotime(date('Ymd'))) / 3600 / 24); if ($orderinfo->isStop == 1 || $lavedays < 0) { $order_status = 'stop'; } else { $objRequest->set_attribute('lavedays', $lavedays); $objRequest->set_attribute('lastday', date('Y-m-d', strtotime($orderinfo->endDate))); $order_status = 'open'; } $objRequest->set_attribute('order_status', $order_status); $objRequest->set_attribute('todayPrice', $todayPrice); $params = APF::get_instance()->get_request()->get_parameters(); $days = intval($params['days']); //status=2是停止,status=1是续费 if ($params['status'] == 2) { if ($orderinfo->isStop == 0) { $stopstatus = Bll_Broker_ShowcaseOrders::getInstance()->stopBrokerOthers($orderinfo, $cityPrice->discountPrice, $this->db); if ($stopstatus['status']) { $this->toManage(); } else { $this->toError($stopstatus['msg']); } } else { $msg = '订单类型不能操作'; $this->toError($msg); } } elseif ($params['status'] == 1 && $days >= 1) { $BrokerMoney = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerMoney($userId); if ($BrokerMoney < $todayPrice) { $this->toError(Const_ShowcaseOrders::MONEY_NOT_ENOUGH); } $Continueorder = Bll_Broker_ShowcaseOrders::getInstance()->continueBrokerOthers($orderinfo, $days, $cityPrice->discountPrice, $this->db); if ($Continueorder['status']) { $this->toManage(); } else { $this->toError($Continueorder['msg']); } } elseif ($params['status'] == 3) { $proIds = array(); if (!empty($params['rooms'])) { $proIds = explode(';', $params['rooms']); $filterProIds = Bll_Broker_ShowcaseAdSetPro::getInstance()->filterProIds($intBrokerID, $cityID, $this->db, $proIds); //有些房源不在线上展示 if (count($filterProIds) != count($proIds)) { $this->toError('有些房源没在线上推广,操作失败!'); } $res = Bll_Broker_ShowcaseAdSetPro::getInstance()->insertAdProsInfo($intBrokerID, $cityID, $proIds, $this->db); if (!$res['status']) { $this->toError($res['msg']); } else { //插入成功,跳转至管理页面 if ($orderinfo->isStop == 0) { $log = array(); $log['brokerId'] = $orderinfo->brokerId; $log['cityId'] = $orderinfo->cityId; $log['endDate'] = $orderinfo->endDate; $log['startDate'] = $orderinfo->startDate; $log['opType'] = Const_ShowcaseOrders::OPTYPE_6; $log['totalDays'] = ceil((strtotime($orderinfo->endDate) - strtotime($orderinfo->startDate)) / 3600 / 24) + 1; $log['createTime'] = time(); Bll_Broker_ShowcaseOrders::getInstance()->insertSetLog($log, $this->db); } $this->toManage(); } } } $orderCreated = date('Ymd', $orderinfo->createTime); if ($orderCreated < date('Ymd')) { $click = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerClick($intBrokerID, date('Ymd', strtotime('-1 days')), $this->db); if (!$click->quantityCount) { $objRequest->set_attribute('YClick', 0); } else { $objRequest->set_attribute('YClick', $click->quantityCount); } $objRequest->set_attribute('IS_YClick', true); } $isCombo = Bll_Combo_HouseRelation::isComboCity($cityID); if ($isCombo['data']) { $comboList = Bll_Combo_HouseRelation::getHouseRelations($intBrokerID, Bll_Combo_HouseRelation::SITE_TYPE_AJK, 1); if (!empty($comboList)) { if (count($comboList) >= Const_ShowcaseOrders::SALE_PRO_MAX_COUNT) { $fixedProInfosCnt = Const_ShowcaseOrders::SALE_PRO_MAX_COUNT; } else { $fixedProInfosCnt = count($comboList); } } else { $fixedProInfosCnt = 0; } $proInfo = Bll_Broker_ShowcaseAdSetPro::getInstance()->getBrokerAdSalePropInfo($intBrokerID); $proIds = Bll_Broker_ShowcaseOrders::getInstance()->getObjFieldInfo($proInfo, 'propId'); $proInfos = Bll_House_EsfHouse::getHouseInfo($proIds, $cityID); $proList = Bll_Broker_ShowcaseAdSetPro::getInstance()->initComboEsfProData($proInfos, $comboList); } else { //获取经纪人计划 $brokerPlanInfo = BLL_Plan_EsfPropFixedPlanRelation::get_instance()->getBrokerEsfOnlinePlan($intBrokerID); if (!empty($brokerPlanInfo)) { //计划数据不为空 //计划IDs $planIds = Bll_Broker_ShowcaseOrders::getInstance()->getObjFieldInfo($brokerPlanInfo, 'id'); //定价推广房源 $fixedProInfos = Bll_Fixedspread_AjkFixedSpread::getFixedOnlineProByPlanIds($cityID, $planIds); $proIdsc = Bll_Broker_ShowcaseOrders::getInstance()->getObjFieldInfo($fixedProInfos, 'proId'); $proInfosc = Bll_House_EsfHouse::getHouseInfo($proIdsc, $cityID); if (!empty($proInfosc)) { if (count($proInfosc) >= Const_ShowcaseOrders::SALE_PRO_MAX_COUNT) { $fixedProInfosCnt = Const_ShowcaseOrders::SALE_PRO_MAX_COUNT; } else { $fixedProInfosCnt = count($proInfosc); } } else { $fixedProInfosCnt = 0; } } else { $fixedProInfosCnt = 0; } $proInfo = Bll_Broker_ShowcaseAdSetPro::getInstance()->getBrokerAdSalePropInfo($intBrokerID); $proIds = Bll_Broker_ShowcaseOrders::getInstance()->getObjFieldInfo($proInfo, 'propId'); $proInfos = Bll_House_EsfHouse::getHouseInfo($proIds, $cityID); $proStatus = Bll_Fixedspread_AjkFixedSpread::getFixedProBy($cityID, $proIds); $proList = Bll_Broker_ShowcaseAdSetPro::getInstance()->initEsfProData($proInfos, $proStatus, $planIds); } if (count($proList) > $fixedProInfosCnt) { $fixedProInfosCnt = count($proList); } $objRequest->set_attribute('type', 'ajk'); $objRequest->set_attribute('index', 2); //精选推广开关 $isChoice = Bll_City::isChoiceCity($cityID); $objRequest->set_attribute('isChoice', $isChoice); $objRequest->set_attribute('fixedProInfosCnt', $fixedProInfosCnt); $objRequest->set_attribute('proList', $proList); return 'Showcase_EsfManage'; }
public function handle_request() { $adBrokerList = $this->getRequestData(); foreach ($adBrokerList as $val) { $data = array(); $this->setMyFlag($val['id']); // $priceList = Bll_Broker_ShowcaseConsumeQuery::getInstance()->getBrokerQuery($val['brokerId'],$this->yDate,$this->nDate,$this->_dateBase); // $price = 0; // if($priceList){ // foreach($priceList as $plist){ // $price += $plist['realAccount']; // } // } $priceList = Bll_Broker_ShowcaseConsumeQuery::getInstance()->getBrokerQueryV2($val['brokerId'], $this->yDate, $this->_dateBase); $price = 0; if ($priceList) { foreach ($priceList as $plist) { $price += $plist['amount']; } } $time = date('Y-m-d 00:10:00', strtotime($this->yDate)); $propList = Bll_Broker_ShowcaseAdSetPro::getInstance()->getBrokerTimeHouse($val['brokerId'], $time, $this->nDate, $this->_dateBase); $props = $propstmp = array(); if ($propList) { foreach ($propList as $hlist) { if (!in_array($hlist['propId'], $props)) { $props[] = $hlist['propId']; } } } $tpropList = Bll_Broker_ShowcaseAdSetPro::getInstance()->getBrokerTimeHouse($val['brokerId'], $this->nDate, 0, $this->_dateBase); if ($tpropList) { $propstmp = $this->aryMerger($tpropList, $propstmp); } $propShowList = Bll_Broker_ShowcaseAdSetPro::getInstance()->getBrokerAdPropShowInfo($val['brokerId'], $this->_dateBase); if ($propShowList) { $propstmp = $this->aryMerger($propShowList, $propstmp, 2); } if ($propstmp) { foreach ($propstmp as $newval) { if ($newval['flag'] != 1) { if (!in_array($newval['propId'], $props)) { $props[] = $newval['propId']; } } } } $brokerInfo = new Model_Broker_AjkBrokerExtend(); $info = $brokerInfo->getDataByBrokerId($val['brokerId']); $data['brokerId'] = $val['brokerId']; $data['cityId'] = $info['cityId']; $data['dayDate'] = $this->yDate; $data['createTime'] = time(); $data['updateTime'] = date('Y-m-d H:i:s'); $data['propsSum'] = count($props); $data['price'] = $price; $lastid = Bll_Broker_ShowcaseLogs::getInstance()->addAdStatusLog($data, $this->_dateBase); if (!$lastid) { $mailSubject = $this->yDate . $this->_dateBaseName . '插入出错问题'; $mailBody = $this->_dateBaseName . '的' . $val['id'] . ',经纪人id:' . $val['brokerId'] . '执行时间:' . date('Y-m-d H:i:s'); Bll_Broker_ShowcaseCommon::getInstance()->sendMail($mailSubject, $mailBody, $this->mailArr); } } }
/** * 表单处理函数 * @param $discountPrice */ private function formAction($discountPrice) { $show_day = intval($this->params['days']); $proIds = array(); if (!empty($this->params['ids'])) { $proIds = explode(';', $this->params['ids']); $filterProIds = Bll_Broker_ShowcaseAdSetPro::getInstance()->filterProIds($this->brokerId, $this->cityId, $this->type, $proIds); //有些房源不在线上展示 if (count($filterProIds) != count($proIds)) { $this->toError('有些房源没在线上推广,操作失败!'); } } //账户余额 $balance = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerMoney($this->userId); if ($discountPrice > $balance) { $this->toError('账户余额不足,操作失败!'); } //插入订单信息 $inser_res = Bll_Broker_ShowcaseOrders::getInstance()->insertBrokerOrders($this->brokerId, $show_day, $this->cityId, $discountPrice * 100, $this->type); if (!$inser_res['status']) { //验证不通过,跳转 $this->toError($inser_res['msg']); } //插入房源信息 $res = Bll_Broker_ShowcaseAdSetPro::getInstance()->insertAdProsInfo($this->brokerId, $this->cityId, $proIds, $this->type); if (!$res['status']) { $this->toError($res['msg']); } else { //插入成功,跳转至管理页面 $this->toSuccess(); } }