예제 #1
0
 public function handle_request()
 {
     $currentTableSplitSuffix = date('m');
     $failedActionQueue = Model_Choice_ActionQueue::getFailedAbandonFee($this->queueId, Model_Choice_ActionQueue::ENUM_HAOZU, $this->tableSplitSuffix);
     if (empty($failedActionQueue)) {
         /** 如果不是同一个月的话,那么前一个月没有需要修复的数据就开始修复本月的数据 */
         if (strcmp($currentTableSplitSuffix, $this->tableSplitSuffix) != 0) {
             $this->saveCursor($currentTableSplitSuffix, 0);
         }
         return;
     }
     $this->log("开始修复: ID={$failedActionQueue['id']}\tBrokerId={$failedActionQueue['brokerId']}\tPlanId={$failedActionQueue['planId']}\tupdateRemark={$failedActionQueue['updateRemark']}");
     $ajkBrokerExtend = Model_Broker_AjkBrokerExtend::getDataByBrokerId($failedActionQueue['brokerId']);
     /** TODO 添加获取二手房经纪人信息为空日志 */
     if (empty($ajkBrokerExtend)) {
         $this->log(sprintf('    获取经纪人(%d)的UserId失败(%d)。', $failedActionQueue['brokerId'], $failedActionQueue['id']));
         $this->saveCursor($this->tableSplitSuffix, $failedActionQueue['id']);
         return;
     }
     $planExtend = Dao_Broker_HzPlan::get_bid_sn($failedActionQueue['planId']);
     /** TODO 添加获取SN 失败日志 */
     if (empty($planExtend)) {
         $this->log(sprintf('    获取计划(%d)的SN失败(%d)。', $failedActionQueue['planId'], $failedActionQueue['id']));
         $this->saveCursor($this->tableSplitSuffix, $failedActionQueue['id']);
         return;
     }
     // $planInfo = Dao_Broker_HzPlan::get_plan($failedActionQueue['planId']);
     $planInfo = Model_Plan_HzPlanBasic::get_plan_by_id($failedActionQueue['planId']);
     /** TODO 添加获取计划信息失败日志*/
     if (empty($planInfo)) {
         $this->log(sprintf('    获取计划(%d)的信息失败(%d)。', $failedActionQueue['planId'], $failedActionQueue['id']));
         $this->saveCursor($this->tableSplitSuffix, $failedActionQueue['id']);
         return;
     }
     //精选结算
     $amount = $planInfo['total_consume'];
     $note = '%E8%A7%A3%E5%86%BB';
     $this->log("    传递的参数:UserId={$ajkBrokerExtend['userId']}\tamount={$amount}\tplanId={$failedActionQueue['planId']}\tSN={$planExtend['sn']}");
     $unlockSuccess = Bll_PayAccount::cancel_frozen($ajkBrokerExtend['userId'], $amount, $failedActionQueue['planId'], Const_PaymentApp::HZ_CHOICE, $planExtend['sn'], $note, true);
     if ($unlockSuccess === true) {
         $this->log('    解冻成功。');
         $this->saveCursor($this->tableSplitSuffix, $failedActionQueue['id']);
         $repairRemark = $failedActionQueue['updateRemark'] . ', 解冻修复成功';
         /** 更新队列状态为处理成功 */
         Model_Choice_ActionQueue::setBidQueenStatusById($this->tableSplitSuffix, $failedActionQueue['id'], Model_Choice_ActionQueue::ENUM_SUCCESS, $repairRemark);
         return;
     }
     $this->log('    解冻失败。');
 }
예제 #2
0
 /**
  *
  */
 public function handle_request()
 {
     //分表
     $date = date('Ymd');
     //获取游标
     $dateFlag = $this->getFlag();
     if (!empty($dateFlag)) {
         $date = $dateFlag['date'];
     }
     //竞价队列数据获取
     $split = date('m', strtotime($date));
     $year = date('Y', strtotime($date));
     $day = date('d', strtotime($date));
     $BidList = Model_Choice_ActionQueue::getBidQueenList($split);
     //判断当前队列是否处理完成
     if (empty($BidList)) {
         //判断是否切换表
         if ($split + 0 != date('m') + 0) {
             $split += 1;
             if ($split < 10) {
                 $date = $year . '0' . $split . $day;
             } elseif ($split <= 12) {
                 $date = $year . $split . $day;
             } else {
                 $date = $year + 1 . '0' . ($split - 12) . $day;
             }
             //记录表游标
             $this->setFlag(array('date' => $date));
         }
         //休息1秒钟
         $this->setShCommonSleepTime(1);
         $this->setLog(date('Y-m-d H:i:s') . ' 处理完成');
         exit;
     }
     //队列数据处理
     foreach ($BidList as $list) {
         try {
             $AjkChoice = new Bll_Plan_Bid_AjkChoice();
             $AjkBlockChoice = new Bll_Plan_Bid_AjkBlockChoice();
             $result = '';
             if ($list['siteType'] == 1) {
                 //查询计划信息
                 $propSpread = Model_Plan_AjkPropspread::getAjkPropspreadById($list['planId']);
             }
             switch ($list['actionId']) {
                 case 1:
                     //精选推广
                     if ($list['siteType'] == 1) {
                         $list['bidStatus'] = 1;
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->choiceStartForJobByBroker($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->blockChoiceStartForJobByBroker($list);
                         }
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::choiceSpread($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpChoice::choicePromotion($list);
                     }
                     break;
                 case 2:
                     //手动停止
                     if ($list['siteType'] == 1) {
                         $list['bidStatus'] = 3;
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->choiceStopForJobByBroker($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->blockChoiceStopForJobByBroker($list);
                         }
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::stopChoiceSpread($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpChoice::stopSpread($list);
                     }
                     break;
                 case 3:
                     //计划14天到期
                     if ($list['siteType'] == 1) {
                         $list['bidStatus'] = 6;
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->choiceStopForJobBySystem($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->blockChoiceStopForJobBySystem($list);
                         }
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::timeIsUp($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpChoice::expireSpread($list);
                     }
                     break;
                 case 4:
                     //计划没钱
                     if ($list['siteType'] == 1) {
                         $list['bidStatus'] = 5;
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->choiceStopForJobByNoMoney($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->blockChoiceStopForJobByNoMoney($list);
                         }
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::planNoMoney($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpChoice::noMoneySpread($list);
                     }
                     break;
                 case 5:
                     //房源移出定价计划,导致精选停止(房源日志发起)
                     if ($list['siteType'] == 1) {
                         $list['bidStatus'] = 2;
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->choiceStopForJobBySystem($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->blockChoiceStopForJobBySystem($list);
                         }
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::removeFixPlanForChoice($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpChoice::removeFixSpread($list);
                     }
                     break;
                 case 6:
                     //房源价格变更(房源日志发起)
                     $priceaArr = json_decode($list['createRemark'], true);
                     $list = array_merge($list, $priceaArr);
                     if ($list['siteType'] == 1) {
                         $list['bidStatus'] = 4;
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->choiceChangePriceForJob($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->blockChoiceChangePriceForJob($list);
                         }
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::changeProPrice($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpChoice::changePriceForHouse($list);
                     }
                     break;
                 case 7:
                     //房源移出定价计划,导致竞价停止(房源日志发起)20140717 caoyang 新增
                     if ($list['siteType'] == 1) {
                         /** 二手房走老队列 */
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::removeFixPlanForBid($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpBidManage::stopJpBidData($list);
                     }
                     break;
                 case Const_ChoiceType::CHOICE_REMOVE_FROM_COMBO:
                     //房源取消套餐推广,导致精选停止(房源日志发起)20140815 caoyang 新增
                     if ($list['siteType'] == 1) {
                         $list['bidStatus'] = 2;
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->choiceStopForJobBySystem($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->blockChoiceStopForJobBySystem($list);
                         }
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::removeComboForChoice($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpChoice::removeFixSpread($list);
                     }
                     break;
                 case Const_ChoiceType::BID_REMOVE_FROM_COMBO:
                     //房源取消套餐推广,导致竞价停止(房源日志发起)20140815 caoyang 新增
                     if ($list['siteType'] == 1) {
                         /** 二手房走老队列 */
                     } elseif ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::removeFixPlanForBid($list);
                     } elseif ($list['siteType'] == 3) {
                         $result = Bll_Plan_Bid_JpBidManage::stopJpBidData($list);
                     }
                     break;
                     /** 精选房源板块变更 */
                 /** 精选房源板块变更 */
                 case Const_ChoiceType::CHOICE_HOUSE_AREA_CHANGE:
                     if ($list['siteType'] == 1) {
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->communityMerge($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->communityMerge($list);
                         }
                         break;
                     }
                     if ($list['siteType'] == 2) {
                         $result = Bll_Plan_Bid_HzChoice::houseAreaChange($list);
                         break;
                     } else {
                         if ($list['siteType'] == 3) {
                             $result = Bll_Plan_Bid_JpChoice::houseBlockChange($list);
                         }
                     }
                     break;
                     /** 精选房源价格段变更 */
                 /** 精选房源价格段变更 */
                 case Const_ChoiceType::CHOICE_PRICE_INTERVAL_CHANGE:
                     $result = array('status' => 2, 'msg' => '未知的动作类型');
                     if ($list['siteType'] == 1) {
                         if ($propSpread['model'] == 1) {
                             $result = $AjkChoice->choicePriceIntervalChange($list);
                         } elseif ($propSpread['model'] == 2) {
                             $result = $AjkBlockChoice->choicePriceIntervalChange($list);
                         }
                     }
                     break;
                     /** 精选上下架状态维护,该上没上,改下没下 */
                 /** 精选上下架状态维护,该上没上,改下没下 */
                 case Const_ChoiceType::NOTIFY_SOLR_UP_DOWN:
                     switch ($list['siteType']) {
                         case Const_Site::ANJUKE:
                             $result = $AjkChoice->notifySolrUpDown($list);
                             break;
                         case Const_Site::HAOZU:
                             $result = Bll_Plan_Bid_HzChoice::notifySolrUpDown($list);
                             break;
                         case Const_Site::JINPU:
                             $result = Bll_Plan_Bid_JpChoice::notifySolrUpDown($list);
                             break;
                     }
                     break;
                 default:
                     $result = array('status' => 2, 'msg' => '未知的动作类型');
                     break;
             }
             //解析返回值
             if ($list['siteType'] == 1) {
                 $status = $result ? 1 : 2;
                 if ($propSpread['model'] == 1) {
                     $updateRemark = $AjkChoice->getMsg();
                 } elseif ($propSpread['model'] == 2) {
                     $updateRemark = $AjkBlockChoice->getMsg();
                 }
             } elseif ($list['siteType'] == 2) {
                 $status = $result['status'] ? 1 : 2;
                 $updateRemark = is_array($result['msg']) ? implode(';', $result['msg']) : $result['msg'];
             } elseif ($list['siteType'] == 3) {
                 $status = $result['status'] ? 1 : 2;
                 $updateRemark = is_array($result['msg']) ? implode(';', $result['msg']) : $result['msg'];
             } else {
                 $status = 2;
                 $updateRemark = '未知的网站类型';
             }
         } catch (Exception $e) {
             $status = 2;
             $updateRemark = print_r($e, true);
         }
         //更新队列状态
         Model_Choice_ActionQueue::setBidQueenStatusById($split, $list['id'], $status, $updateRemark);
         //记录处理日志
         $this->setLog(date('Y-m-d H:i:s') . ' id:' . $list['id'] . '; 网站: ' . $list['siteType'] . '; split:' . $split . '; remark:' . $updateRemark);
         //记录表游标
         $this->setFlag(array('date' => $date));
     }
     //休息10毫秒
     $this->setShCommonSleepTime(0.01);
 }