Ejemplo n.º 1
0
 /**
  * @param $task
  * @return bool
  */
 public function dealTask($task)
 {
     $brokerId = $task['brokerId'];
     //获取订单信息
     $brokerOrderInfo = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerOrders(array('brokerId' => $brokerId), $this->_dataBase);
     if (empty($brokerOrderInfo)) {
         printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '经纪人' . $brokerId . '还没有购买橱窗');
         return true;
     }
     // 判断该经纪人橱窗是否过期
     if ($this->currentYMD > $brokerOrderInfo['endDate']) {
         printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '经纪人' . $brokerId . '购买的橱窗已过期');
         return true;
     }
     //TODO 查询该经纪人当前推广房源数是否小于0
     if ($this->_dataBase == Const_ShowcaseOrders::SALE_DB) {
         $comboList = Bll_Combo_HouseRelation::getHouseRelations($brokerId, Bll_Combo_HouseRelation::SITE_TYPE_AJK, 1);
     } else {
         $comboList = Bll_Combo_HouseRelation::getHouseRelations($brokerId, Bll_Combo_HouseRelation::SITE_TYPE_HZ, 1);
     }
     if (empty($comboList)) {
         printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '经纪人' . $brokerId . '当前还没有推广房源');
         return true;
     }
     //判断该经纪人当天是否已经扣费
     //default没有扣费记录
     $requestTimes = 0;
     $siteType = 1;
     if ($this->_dataBase == Const_ShowcaseOrders::RENT_DB) {
         $siteType = 2;
     }
     $condition = array('brokerId' => $brokerId, 'siteType' => $siteType, 'consumeDate' => $this->currentYMD);
     $limit = 1;
     $sort = array('id', 'desc');
     $brokerConsumeInfo = Bll_Broker_ShowcaseAdConsumeQueue::getBrokerIsConsume($condition, $limit, $sort);
     //有扣费记录
     if (!empty($brokerConsumeInfo)) {
         //待扣费
         if ($brokerConsumeInfo['status'] == 0) {
             printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '经纪人' . $brokerId . '橱窗待扣费');
             return true;
         } elseif ($brokerConsumeInfo['status'] == 3) {
             //已经扣费
             printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '经纪人' . $brokerId . '橱窗已经扣费');
             return true;
         } elseif ($brokerConsumeInfo['status'] == 2) {
             //扣费失败
             printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '经纪人' . $brokerId . '橱窗扣费调用api失败');
             return true;
         } elseif ($brokerConsumeInfo['status'] == 1) {
             //余额不足,继续写入扣费记录
             $requestTimes = $brokerConsumeInfo['requestTimes'] + 1;
         }
     }
     //获取扣费price
     $tmpArr = array('cityId' => $task['cityId'], 'status' => 1, 'startDate' => $this->currentYMD);
     $tmpCityPrice = Bll_Broker_ConfigCityPrice::getInstance()->getCityPrice($tmpArr, $this->_dataBase);
     if ($tmpCityPrice) {
         $cityPrice = $tmpCityPrice->discountPrice > 0 ? $tmpCityPrice->discountPrice : 0;
     }
     if (empty($cityPrice)) {
         printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '经纪人' . $brokerId . '橱窗扣费价格为0');
         return true;
     }
     // 写扣费记录
     $adConsumeArr = array('brokerId' => $brokerId, 'amount' => $cityPrice, 'consumeDate' => $this->currentYMD, 'status' => 0, 'siteType' => $siteType, 'requestTimes' => $requestTimes, 'createTime' => time());
     Bll_Broker_ShowcaseAdConsumeQueue::dataInsert($adConsumeArr);
     printf('[%s] remark: %s' . PHP_EOL, date('Y-m-d H:i:s'), '经纪人' . $brokerId . '橱窗扣费记录插入成功,请求次数:' . $requestTimes);
     return true;
 }
Ejemplo n.º 2
0
 public function dealTask($task)
 {
     $brokerId = $task['brokerId'];
     $createTime = date('Ymd', $task['createTime']);
     //获取订单信息
     $brokerOrderInfo = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerOrders(array('brokerId' => $brokerId), $this->_dataBase);
     if (empty($brokerOrderInfo)) {
         $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '经纪人' . $brokerId . '还没有购买橱窗'));
         return true;
     }
     // 判断该经纪人橱窗是否过期
     if ($createTime > $brokerOrderInfo['endDate']) {
         $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '经纪人' . $brokerId . '还购买的橱窗已过期'));
         return true;
     }
     //判断该经纪人当天是否已经扣费
     //default没有扣费记录
     $requestTimes = 0;
     $siteType = 1;
     if ($this->_dataBase == Const_ShowcaseOrders::RENT_DB) {
         $siteType = 2;
     }
     $condition = array('brokerId' => $brokerId, 'siteType' => $siteType, 'consumeDate' => $createTime);
     $limit = 1;
     $sort = array('id', 'desc');
     $brokerConsumeInfo = Bll_Broker_ShowcaseAdConsumeQueue::getBrokerIsConsume($condition, $limit, $sort);
     //有扣费记录
     if (!empty($brokerConsumeInfo)) {
         //待扣费
         if ($brokerConsumeInfo['status'] == 0) {
             $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '经纪人' . $brokerId . '橱窗待扣费'));
             return true;
         } elseif ($brokerConsumeInfo['status'] == 3) {
             //已经扣费
             $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '经纪人' . $brokerId . '橱窗已经扣费'));
             return true;
         } elseif ($brokerConsumeInfo['status'] == 2) {
             //扣费失败
             $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '经纪人' . $brokerId . '橱窗扣费调用api失败'));
             return true;
         } elseif ($brokerConsumeInfo['status'] == 1) {
             //余额不足,继续写入扣费记录
             $requestTimes = $brokerConsumeInfo['requestTimes'] + 1;
         }
     }
     //获取扣费price
     $tmpArr = array('cityId' => $task['cityId'], 'status' => 1, 'startDate' => $createTime);
     $tmpCityPrice = Bll_Broker_ConfigCityPrice::getInstance()->getCityPrice($tmpArr, $this->_dataBase);
     if ($tmpCityPrice) {
         $cityPrice = $tmpCityPrice->discountPrice > 0 ? $tmpCityPrice->discountPrice : 0;
     }
     if (empty($cityPrice)) {
         $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '经纪人' . $brokerId . '橱窗扣费价格为0'));
         return true;
     }
     // 写扣费记录
     $adConsumeArr = array('brokerId' => $brokerId, 'amount' => $cityPrice, 'consumeDate' => $createTime, 'status' => 0, 'siteType' => $siteType, 'requestTimes' => $requestTimes, 'createTime' => time());
     Bll_Broker_ShowcaseAdConsumeQueue::dataInsert($adConsumeArr);
     $this->setLog(sprintf('[%s] remark: %s', date('Y-m-d H:i:s'), '经纪人' . $brokerId . '橱窗扣费记录插入成功,请求次数:' . $requestTimes));
     return true;
 }