Пример #1
0
 public static function broker_restitution($params)
 {
     $all_return[] = "队列(" . $params['id'] . ")开始处理";
     $all_return[] = '金铺系统返还';
     //todo 查询用户所有定价计划,开启计划,上线房源
     $ajk_broker_id = $params['broker_id'];
     //获取金铺经纪人broker_id
     $jpBrokerInfoObj = Model_Broker_JpBroker::getJpBrokerInfoByAjkBrokerId($params['broker_id']);
     $params['broker_id'] = $jpBrokerInfoObj->id;
     //获取由于余额用完停止的计划
     $fixInfoObjs = Model_Plan_Jp::getNoBalancePlan($params['broker_id']);
     foreach ($fixInfoObjs as $fixInfoObj) {
         $plan_log = array();
         $plan_log['id'] = $params['id'];
         $plan_log['plan_id'] = $fixInfoObj->id;
         $plan_log['broker_id'] = $ajk_broker_id;
         $plan_log['city_id'] = $fixInfoObj->cityId;
         $plan_log['type'] = $params['type'];
         $plan_log = Bll_JpFixPlanBll::build_plan_log($plan_log, 8, "系统返还", 0);
         //写计划日志
         if (!Model_House_UpDown_PlanLog::create($plan_log, date('m'))->save()) {
             $all_return[] = "计划" . $plan_log['planId'] . "房源推广日志写入失败";
         } else {
             $all_return[] = "计划" . $plan_log['planId'] . "房源推广日志写入成功";
         }
         //计划开启
         $fixInfoObj->status = 2;
         $fixInfoObj->stopReason = 0;
         if (!$fixInfoObj->save()) {
             return array('status' => 0, 'msg' => array("定价计划" . $plan_log['planId'] . ",更新失败"));
         }
         //获取房源列表
         $houseInfoObjs = Model_House_JpHouseIdx::getHouseInfoByFixPlanId($plan_log['planId']);
         if ($houseInfoObjs) {
             foreach ($houseInfoObjs as $houseInfoObj) {
                 $prop_log['id'] = $params['id'];
                 $prop_log['pro_id'] = $houseInfoObj->id;
                 $prop_log['plan_id'] = $plan_log['planId'];
                 $prop_log['broker_id'] = $ajk_broker_id;
                 $prop_log['city_id'] = $houseInfoObj->cityId;
                 $prop_log['type'] = $params['type'];
                 $prop_log = Bll_JpPropBll::build_prop_log($prop_log, 5, "系统返还", 0);
                 //写房源日志
                 if (!Model_Log_HouseLogNew::create($prop_log, date('Ymd'))->save()) {
                     $all_return[] = "房源" . $houseInfoObj->id . "系统返还后房源推广日志写入失败";
                 } else {
                     $all_return[] = "房源" . $houseInfoObj->id . "系统返还后房源推广日志写入成功";
                 }
                 //获取房源分表信息
                 $houseClass = Model_House_JpHouseIdx::getHouseTypeModelClass($houseInfoObj->houseType);
                 $houseObj = $houseClass::getPropInfoByPk($houseInfoObj->id);
                 //更新展示房源状态
                 $houseObj->isList = 1;
                 if ($houseObj->save()) {
                     $all_return[] = "houseType=" . $houseInfoObj->houseType . ",更新分表isList=1成功";
                 } else {
                     $all_return[] = "houseType=" . $houseInfoObj->houseType . ",更新分表isList=1失败";
                 }
             }
         }
     }
     return Bll_JpPropBll::build_return(1, $all_return);
 }