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('    解冻失败。');
 }
 /**
  * 修复竞价计划没有解冻
  */
 public function repairPlanDeduct()
 {
     $planIds = array(823960, 829941, 832069, 832072, 832092, 832094, 836322, 836323, 839239, 839247);
     $note = urlencode('解冻');
     foreach ($planIds as $planId) {
         $this->log(sprintf('开始修复计划%d.....', $planId));
         $planInfo = Model_Plan_HzPlanBasic::get_plan_by_id($planId);
         $hzBrokerId = $planInfo['user_id'];
         $userId = Bll_HzBroker::get_userid_by_hzbrokerid($hzBrokerId);
         $planExtend = Dao_Broker_HzPlan::get_bid_sn($planId);
         $amount = $planInfo['total_consume'];
         $this->log("传递的参数:UserId={$userId}\tamount={$amount}\tplanId={$planId}\tSN={$planExtend['sn']}");
         $charge_sn = Bll_PayAccount::cancel_frozen($userId, $amount, $planId, Const_PaymentApp::HZ_BID, $planExtend['sn'], $note, true);
         if ($charge_sn['data']['status'] === 'ok') {
             $this->log('修复成功。');
         } else {
             $this->log('修复失败。');
         }
     }
 }
Beispiel #3
0
 public static function change_bid_budget($plan_id, $new_amount)
 {
     $flag_array = array('status' => 0, 'msg' => '');
     $plan_info = Dao_Broker_HzPlan::get_plan($plan_id);
     if (empty($plan_info)) {
         $flag_array['msg'] = Const_HzErrorInfo::NULLPLAN;
         return $flag_array;
     }
     if ((int) ($plan_info['amount'] * 100) > (int) ($new_amount * 100)) {
         $flag_array['msg'] = Const_HzErrorInfo::BIDAMOUNTLOW;
         return $flag_array;
     } elseif ((int) ($plan_info['amount'] * 100) == (int) ($new_amount * 100)) {
         $flag_array['status'] = 1;
         return $flag_array;
     }
     $planning = Dao_Broker_HzPlan::get_planning($plan_id, Const_HzPlan::BID_TYPE, 1);
     if (empty($planning)) {
         $flag_array['msg'] = Const_HzErrorInfo::PROPFIXNULL;
         return $flag_array;
     }
     $broker_id = $planning[0]['user_id'];
     $proid = $planning[0]['proid'];
     $sn = Dao_Broker_HzPlan::get_bid_sn($plan_id);
     $user_id = Bll_HzBroker::get_userid_by_hzbrokerid($broker_id);
     $note = urlencode('推广房源' . $proid);
     $cha_amount = $new_amount - $plan_info['amount'];
     // 冻结只能冻结差值
     $freezeResult = Bll_PayAccount::freeze($user_id, $cha_amount, $proid, "ZF", $sn['sn'], $note);
     //冻结流水号
     if ($freezeResult['status'] === "error") {
         if ($freezeResult['errcode'] == 398445) {
             $flag_array['msg'] = Const_HzErrorInfo::BIDAMOUNTTOP;
         } else {
             $flag_array['msg'] = Const_HzErrorInfo::DATAFAIL;
         }
         return $flag_array;
     }
     $new_sn = $freezeResult['sn'];
     Dao_Broker_HzPlan::update_bid_extend($plan_id, $new_sn);
     $log_option = Const_HzLog::BIDUPDATE;
     if (Dao_Broker_HzPlan::change_plan_amount($plan_id, $new_amount)) {
         //更新预算,预算直接改输入值
         Dao_Broker_HzPlan::add_plan_log($plan_id, $planning[0]['proid'], $log_option, 2, $planning[0]['user_id'], 0, $plan_info['status'], $plan_info['status']);
         //记录日志
         //Dao_Broker_HzProp::into_prop_lucene($planning['proid'],$planning['city_id'],1);    //更新房源
         $flag_array['status'] = 1;
         return $flag_array;
     }
     $flag_array['msg'] = Const_HzErrorInfo::DATAFAIL;
     return $flag_array;
 }
Beispiel #4
0
 /**
  * 动作 7
  * 房源移出定价计划,导致竞价停止(房源日志发起)
  * 结算
  * 更新计划为停止状态
  * 通知solr下(停止的房源)
  * 记录房源日志(停止的房源)
  * 根据停止的房源,取出坑位里面的推广、排队房源
  * 计算排名
  * 更新计划状态(坑位里面的异动房源更新状态)
  * 通知solr(坑位里面的异动房源通知solr)
  * 记房源日志(坑位里面的房源异动日志)
  * @param array $params
  * @return array|bool
  */
 public static function removeFixPlanForBid($params = array())
 {
     self::$qInfo = $params;
     // 检查参数
     $checkParams = self::checkParams($params);
     if (!$checkParams['status']) {
         return $checkParams;
     }
     // 获取信息,组装$params
     $joinParams = self::joinParams($params);
     if (!$joinParams['status']) {
         return $joinParams;
     }
     $all_return = array();
     //判断竞价计划是否删除
     if ($params['flag'] != 1) {
         return Bll_HzPropBll::build_return(0, '无效的竞价计划' . json_encode($params));
     }
     //非推广的计划
     if ($params['status'] != 1) {
         return Bll_HzPropBll::build_return(0, '非推广的竞价计划' . json_encode($params));
     }
     // 非精选判断
     if ($params['bidVersion'] == 2) {
         return Bll_HzPropBll::build_return(0, '房源为精选' . json_encode($params));
     }
     //获取竞价计划的冻结号
     $sn = Dao_Broker_HzPlan::get_bid_sn($params['planId']);
     $sn = $sn['sn'];
     if (empty($sn)) {
         return Bll_HzPropBll::build_return(0, Const_HzErrorInfo::PROPERROR . json_encode($params));
     }
     //获取竞价花费
     $amount = $params['totalConsume'];
     $note = urlencode('推广房源' . $params['proId']);
     $user_id = Bll_HzBroker::get_userid_by_hzbrokerid($params['']);
     /** 竞价结算 调用3次 */
     $charge_sn = false;
     $unfreezeOrderData = array('userId' => $user_id, 'proId' => $params['proId'], 'serialNumber' => $sn, 'planId' => $params['planId'], 'amount' => $amount);
     $unfreezeOrder = Bll_Ppc_BidUnfreeze::createHzOrder($unfreezeOrderData);
     for ($i = 0; $i < 3 && !$charge_sn; $i++) {
         $charge_sn = Bll_PayAccount::cancel_frozen($user_id, $amount, '', Const_PaymentApp::HZ_BID, $sn, $note, true);
     }
     if (!$charge_sn) {
         $unfreezeOrder->fail();
         $flag_array['msg'] = Const_HzErrorInfo::CHARGEFAIL;
         // 此处不需要block,由job保证此处解冻正确
         //return $flag_array;
     } else {
         $unfreezeOrder->complete();
     }
     //维护竞价关联关系
     if (!Dao_Broker_HzPlan::update_planning($params['planId'], Const_HzPlan::DELETE)) {
         $flag_array['msg'] = '维护竞价关联关系,数据更新失败.';
         return $flag_array;
     }
     //维护计划状态
     if (!Dao_Broker_HzPlan::update_plan_status($params['planId'], Const_HzPlan::DELETE)) {
         $flag_array['msg'] = '维护计划状态,数据更新失败.';
         return $flag_array;
     }
     // 更新计划的flag为删除状态
     if (!Dao_Broker_HzPlan::update_history_bids($params['planId'])) {
         $flag_array['msg'] = '更新计划的flag为删除状态,数据更新失败.';
         return $flag_array;
     }
     //记录房源日志
     $data = array('houseId' => $params['proId'], 'planId' => $params['planId'], 'brokerId' => $params['ajkBrokerId'], 'cityId' => $params['cityId'], 'type' => 15, 'changeType' => 407, 'remark' => '房源' . $params['proId'] . '移出定价计划。竞价' . $params['planId'] . '(id)取消竞价推广。', 'addDate' => date('Y-m-d H:i:s'), 'operatorId' => $params['operationId'], 'siteType' => 2);
     if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) {
         return Bll_HzPropBll::build_return(0, array("日志写入失败"));
     }
     //计算房源状态
     Bll_HzPropBll::bulidHzProStatu($params['proId']);
     return Bll_HzPropBll::build_return(1, array('竞价' . $params['planId'] . '(id)取消竞价推广。'));
 }