Exemplo n.º 1
0
 /**
  * 更新计划的状态
  *
  * @param status 1. 未推广 2.推广中 3.第二天推广 4.账户没钱停止 5.手动停止
  */
 public static function updatePlanStatus($planId, $status)
 {
     $param = array();
     switch ($status) {
         case 1:
             $param = array('ID' => $planId, 'STATUS' => 0);
             break;
         case 2:
             $param = array('ID' => $planId, 'VIEWTIME' => time() - 1);
             break;
         case 3:
             $param = array('ID' => $planId, 'VIEWTIME' => self::getNextDaySpreadTime());
             break;
         case 4:
             $param = array('ID' => $planId, 'VIEWTIME' => self::$_noMoneyViewtime);
             break;
         case 5:
             $param = array('ID' => $planId, 'VIEWTIME' => self::$_handStopViewtime);
             break;
         default:
             break;
     }
     return DAO_Plan_StaticPricePlan::updateStaticPricePlanById($param);
 }
Exemplo n.º 2
0
 /**
  * 303竞价结算
  * 1. 查询经纪人所有有效计划,
  *      没有计划return
  *
  * 2. 基于推广计划,查询计划下有效房源(循环计划查询)
  *
  *      判断计划状态
  *          推广中,contine
  *          第二天推广,continue
  *          手动停止,continue
  *          账户限额不足,计划置为推广中,记录计划推广日志
  *      查询计划下房源关系,
  *          如果为空,contine
  *          不为空,判断计划状态
  *                  如果账户余额不足,记录房源推广日志
  */
 public static function broker_frozen_money($params)
 {
     if (empty($params['broker_id'])) {
         return Bll_JpPropBll::build_return(1, array("经纪人ID为空"));
     }
     $returnLog = array();
     //获取账户余额
     try {
         $userId = Bll_Broker_MainBusiness::getDataByEsfId($params['broker_id'])->memberId;
         $balance = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $userId));
     } catch (Exception $e) {
         array_push($returnLog, "获取账户余额不足失败");
         return Bll_JpPropBll::build_return(0, $returnLog);
     }
     if ($balance['data']['balance'] <= 0) {
         array_push($returnLog, "当前账户余额不足");
         return Bll_JpPropBll::build_return(1, $returnLog);
     }
     array_push($returnLog, "当前账户余额:" . $balance['data']['balance']);
     //获取经纪人正在推广的计划
     $StaticPricePlanList = DAO_Plan_StaticPricePlan::getStaticPricePlanListByBrokerId($params['broker_id']);
     foreach ($StaticPricePlanList as $list) {
         if ($list['Status'] != 1) {
             //无效的计划
             array_push($returnLog, "无效的计划:" . $list['Id'] . ";");
             continue;
         }
         if ($list['ViewTime'] != 1893427200) {
             //非账户没钱停止的计划
             array_push($returnLog, "计划Id:" . $list['Id'] . "展示时间:" . date("Y-m-d H:i:s", $list['ViewTime']) . ";");
             continue;
         }
         $tmpStr = "计划Id:" . $list['Id'] . "展示时间:" . date("Y-m-d H:i:s", $list['ViewTime']) . ";";
         //获取计划下面的房源
         $StaticPriceRelation = DAO_Plan_StaticPriceRelation::getProSpreadRelation($list['Id'], $list['CityId']);
         //更新计划的状态
         if (BLL_Fixedspread_StaticPlanUpDownSwicher::isOnline()) {
             DAO_Plan_StaticPricePlan::updateStaticPricePlanById(array('Id' => $list['Id'], 'ViewTime' => time()));
         }
         //记录计划日志
         $params['plan_id'] = $list['Id'];
         $data = self::build_plan_log($params, 8, "账户有钱计划推广,动作id:" . $params['id'], $params['broker_id']);
         if (!Model_House_UpDown_PlanLog::create($data, date('m'))->save()) {
             array_push($returnLog, "账户有钱计划推广日志写入失败");
             return Bll_JpPropBll::build_return(0, $returnLog);
         }
         //记录房源日志
         foreach ($StaticPriceRelation as $Relation) {
             $params['pro_id'] = $Relation['ProId'];
             $data = Bll_EsfPropBll::build_prop_log($params, 5, "房源推广,动作id:" . $params['id'], $params['broker_id']);
             if (!Model_Log_HouseLogNew::create($data, date('Ymd'))->save()) {
                 array_push($returnLog, "房源" . $Relation['ProId'] . "房源推广日志写入失败");
                 return Bll_JpPropBll::build_return(0, $returnLog);
             }
             $tmpStr .= $Relation['ProId'] . ",";
         }
         array_push($returnLog, $tmpStr);
     }
     if (empty($returnLog)) {
         array_push($returnLog, "经纪人没有计划");
     }
     return Bll_JpPropBll::build_return(1, $returnLog);
 }