コード例 #1
0
 public static function &getInstance()
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
コード例 #2
0
 public function handle_request()
 {
     $listData = $this->getRequestData();
     $errChargeUserId = array();
     $errDeleteLogUserId = array();
     $totalUserId = array();
     foreach ($listData as $val) {
         // 设置游标
         $this->setMyFlag($val['id']);
         $userId = intval($val['userId']);
         $totalUserId[] = $userId;
         $accountId = Bll_Fyk_Payment_User::getInstance()->getUserAccountId($userId, false);
         if (empty($accountId)) {
             continue;
         }
         // 查询余额
         $balanceResult = Bll_Fyk_Payment_Amount::getInstance()->getBalance($userId, $accountId);
         if ($balanceResult && $balanceResult['status'] && $balanceResult['balance'] >= $this->defaltAmount) {
             $balance = $balanceResult['balance'];
         } else {
             continue;
         }
         $requestId = Bll_Fyk_Payment_Common::getInstance()->createRequsetId("unActivateUserAmount", $val['id']);
         $note = "未激活用户,系统赠送的金钱回收";
         $chargeResult = Bll_Fyk_Payment_Amount::getInstance()->chargeMoney($userId, $balance, $accountId, $note, $requestId);
         if ($chargeResult['status'] == false) {
             $errChargeUserId[] = $userId;
             // 记录日志
             echo "扣费失败,userId:" . $userId . ",扣费金额:" . $balance . "\n";
             continue;
         }
         // 删除日志
         $deleteResult = Bll_Fyk_Payment_Log::getInstance()->deleteBalanceLogByUserId($userId);
         if ($deleteResult == 0) {
             $errDeleteLogUserId[] = $userId;
             echo "删除日志失败,userId:" . $userId;
         }
     }
     if ($errChargeUserId) {
         $mailBody = "扣费失败,userId:" . implode(',', $errChargeUserId);
     }
     if ($errDeleteLogUserId) {
         $mailBody .= "<br> 删除日志失败,userId:" . implode(',', $errDeleteLogUserId);
     }
     if (empty($mailBody)) {
         $mailBody = "没有异常";
     }
     $mailBody .= "<br> totalUserId:" . implode(',', $totalUserId);
     print_r($mailBody);
     // 发生邮件通知
     $mailSubject = "未激活用户,系统回收金额";
     $mailArr = array("*****@*****.**");
     Bll_Broker_ShowcaseCommon::getInstance()->sendMail($mailSubject, $mailBody, $mailArr);
 }
コード例 #3
0
 /**
  * 获取要跑的数据
  */
 public function getRequestData()
 {
     $list = Bll_CustomerRush_Coupon::getInstance()->getBrokerCouponByBiggerThanId($this->lastId, 'id', 'asc', 0, $this->limit);
     if (empty($list)) {
         $mailSubject = "抢客券45天后过期";
         $mailBody = "Job在" . date('Y-m-d H:i:s') . "执行结束,最后一个抢客券的ID为" . $this->lastId;
         Bll_Broker_ShowcaseCommon::getInstance()->sendMail($mailSubject, $mailBody, $this->mailArr);
         $this->textOutput('已经没有要处理的数据了', false);
         $this->setMyFlag(0, 'over');
         $this->setShStopFlag();
         return array();
     }
     return $list;
 }
コード例 #4
0
ファイル: DayConsume.php プロジェクト: emilymwang8/ajk-broker
 /**
  * 共用输出函数
  * @param $error_text
  */
 protected function textOutput($adSetData, $error_text, $isWarn = true)
 {
     echo $error_text . "\n";
     if ($isWarn == true) {
         // 报警处理,发送短信
         $content = $this->subject . " " . $error_text . " 当前adsetId = " . $adSetData->id . "job执行时间为" . date("Y-m-d H:i:s", time());
         Bll_Broker_ShowcaseCommon::getInstance()->sendAlertMsg($this->mobileArr, $content);
     }
 }
コード例 #5
0
ファイル: AdStop.php プロジェクト: emilymwang8/ajk-broker
 public function getError($table, $brokerId)
 {
     $mailSubject = date('Ymd') . $table . '停止订单出错问题';
     $mailBody = $table . '的二手房经纪人id:' . $brokerId;
     Bll_Broker_ShowcaseCommon::getInstance()->sendMail($mailSubject, $mailBody, $this->mailArr);
 }
コード例 #6
0
ファイル: Consume.php プロジェクト: emilymwang8/ajk-broker
 /**
  * 更新Query表状态
  * @param $adSetData
  */
 protected function updateQueryTable($val, $status)
 {
     // 设置游标
     $this->setMyFlag($val->id);
     $val->status = $status;
     $val->updateTime = date("Y-m-d H:i:s");
     $val->save();
     if ($status == 2) {
         // 报警
         // 报警处理,发送短信
         $content = "委托扣费出现异常,异常QueryId为:" . $val->id;
         Bll_Broker_ShowcaseCommon::getInstance()->sendAlertMsg($this->mobileArr, $content);
     }
 }
コード例 #7
0
 /**
  * 停止job
  */
 public function stopFlag()
 {
     $mailSubject = "weshop_props表,weshop_prop_images表删除60天前的数据";
     $mailBody = "Job在" . date('Y-m-d H:i:s') . "执行结束,最后一个ID为" . $this->lastId;
     Bll_Broker_ShowcaseCommon::getInstance()->sendMail($mailSubject, $mailBody, $this->mailArr);
     $this->textOutput('已经没有要处理的数据了', false);
     $this->setMyFlag(0, 'over');
     $this->setShStopFlag();
 }
コード例 #8
0
 public function setMail()
 {
     $mailSubject = "抢客券退费后,消耗抢客劵";
     $mailBody = "Job在" . date('Y-m-d H:i:s') . "执行结束,最后一个抢客券的ID为" . $this->lastId;
     $mailBody .= "\r\n 传入的BrokerCouponId为" . implode(',', $this->brokerCouponId);
     Bll_Broker_ShowcaseCommon::getInstance()->sendMail($mailSubject, $mailBody, $this->mailArr);
     $this->textOutput('已经没有要处理的数据了', false);
     $this->setMyFlag(0, 'over');
     $this->setShStopFlag();
     return array();
 }
コード例 #9
0
 /**
  * 抢委托操作流程
  * @param $houseId 房源id
  * @param $brokerId 二手房经纪人Id
  * @param $brokerName 二手房经纪人真实姓名
  * @param $brokerPhone 经纪人手机电话
  * @param $cityId 经纪人城市id
  * @param $comeFrom 来源
  * @param $isConsume 是否扣费
  * @param $conboOn 套餐是否开启
  * @return array
  */
 public function saleRush($houseId, $brokerId, $brokerName, $brokerPhone, $cityId, $comeFrom = Const_Entrust::RUSH_FROM_PC, $isConsume = true, $conboOn = false)
 {
     $result = array('status' => 0, 'data' => array(), 'errorMsg' => "");
     if (empty($houseId) || empty($brokerId) || empty($cityId) || empty($brokerName) || empty($brokerPhone)) {
         $result['status'] = 99;
         $result['errorMsg'] = "输入的参数不正确";
         return $result;
     }
     // 验证套餐开关是否开启
     if ($conboOn == true) {
         $conbosProNum = Bll_Combo_Broker_BrokerComboInfo::getTotalCombosProNum($brokerId);
         if ($conbosProNum['totalSalePropNum'] <= 0) {
             $result['status'] = 20;
             $result['errorMsg'] = "没有购买出售套餐。";
             return $result;
         }
     }
     // 判断房源ID
     $id = isset($houseId) & intval($houseId) > 0 ? intval($houseId) : 0;
     if ($houseId <= 0) {
         $result['status'] = 2;
         $result['errorMsg'] = "无效的房源编号。";
         return $result;
     }
     // 判断委托房源是否存在
     $house = Model_House_CommissionHouse::data_access()->filter('id', $id)->find_only();
     if (!$house) {
         $result['status'] = 3;
         $result['errorMsg'] = "房源不可委托:房源不存在。";
         return $result;
     }
     if ($house->commissionType != Model_House_CommissionHouse::COMMISSION_TYPE_SALE) {
         $result['status'] = 4;
         $result['errorMsg'] = "房源类型不是二手房";
         return $result;
     }
     // 判断委托房源状态
     if ($house->proStatus != Model_House_CommissionHouse::STATUS_ONGOING) {
         if ($house->proStatus == Model_House_CommissionHouse::STATUS_DELETED) {
             $result['status'] = 9;
             $result['errorMsg'] = "房源不可委托:已被房东删除。";
         } elseif ($house->proStatus == Model_House_CommissionHouse::STATUS_ILLEGAL) {
             $result['status'] = 10;
             $result['errorMsg'] = "房源不可委托:已被违规删除。";
         } elseif ($house->proStatus == Model_House_CommissionHouse::STATUS_STOP) {
             $result['status'] = 11;
             $result['errorMsg'] = "房源不可委托:已被停止委托。";
         } elseif ($house->proStatus == Model_House_CommissionHouse::STATUS_SAVE) {
             $result['status'] = 12;
             $result['errorMsg'] = "房源不可委托:已被估价保存。";
         } else {
             $result['status'] = 5;
             $result['errorMsg'] = "房源不可委托:已过期。";
         }
         return $result;
     }
     // 判断委托房源已委托数量
     if ($house->openBrokerCnt >= Model_House_CommissionHouse::allowedMaxCommissionCount()) {
         $result['status'] = 6;
         $result['errorMsg'] = '委托已满。';
         return $result;
     }
     // 判断是否已抢过委托
     $commission = Model_House_Commission::data_access()->filter('brokerId', $brokerId)->filter('houseId', $house->id)->find_only();
     if ($commission) {
         $result['status'] = 7;
         $result['errorMsg'] = '你已经委托了该房源。';
         return $result;
     }
     if ($isConsume === true) {
         // 获取余额
         $userId = Bll_Broker_BrokerCheckInfo::getUserIdByBrokerId($brokerId, 'sale');
         $balance = Bll_Broker_ShowcaseOrders::getInstance()->getBrokerMoney($userId);
         $balance = $balance * 100;
         // 获取委托价格
         $startDate = date("Ymd");
         $price = Bll_Broker_EntrustPrice::getInstance()->getSalePrice($cityId, $startDate);
         // 判断余额是否足够
         if ($balance < $price) {
             $result['status'] = 8;
             $result['errorMsg'] = '对不起,您的账户余额不足,请充值。';
             return $result;
         }
     }
     // 判断15天内未发布的房源的数量是否最多3套
     $tmpTime = time() - 15 * 24 * 3600;
     $startTime = date("Y-m-d H:i:s", $tmpTime > strtotime(Const_Entrust::EUSH_3HOUSE_RULE_STARTTIME) ? $tmpTime : strtotime(Const_Entrust::EUSH_3HOUSE_RULE_STARTTIME));
     $tmpCommission = Model_House_Commission::data_access()->load_field('id')->load_field('type')->load_field('brokerHouseId')->load_field('publishTime')->load_field('isDelete')->filter('brokerId', $brokerId)->filter_by_op('createTime', '>', $startTime)->find();
     // bug46464 慢查询,故把数据获取后来处理
     $tmpCount = 0;
     if (!empty($tmpCommission)) {
         foreach ($tmpCommission as $val) {
             if ($tmpCount == 5000) {
                 break;
             }
             if ($val['publishTime'] == '0000-00-00 00:00:00' && $val['isDelete'] == Model_House_Commission::DELETE_NO && $val['type'] == Model_House_Commission::TYPE_SALE && $val['brokerHouseId'] == 0) {
                 $tmpCount++;
             }
         }
     }
     if ($tmpCount == 5000) {
         $result['status'] = 15;
         $result['errorMsg'] = '15天之内已抢房源中有5000套未发,禁止经纪人继续抢房';
         return $result;
     }
     // 更新commission_prop表的openBrokerCnt+1
     if (!$house->updateCommissionCount()) {
         $result['status'] = 6;
         $result['errorMsg'] = '委托已满。';
         return $result;
     }
     // 更新成功 插入e_commission表
     $commission = Model_House_Commission::create(array('type' => $house->commissionType, 'ownerId' => $house->userId, 'houseId' => $house->id, 'brokerId' => $brokerId, 'origin' => $comeFrom, 'createTime' => date('Y-m-d H:i:s'), 'updateTime' => date('Y-m-d H:i:s')));
     $commission->save();
     if ($isConsume === true) {
         // 插入扣费队列
         $insertQueryArr = array('cityId' => $cityId, 'commissionId' => $commission->id, 'status' => 0, 'dateIndex' => date("Ymd"), 'createTime' => time(), 'updateTime' => date("Y-m-d H:i:s"));
         Bll_Broker_EntrustQuery::getInstance()->insertOneData($insertQueryArr);
     }
     // 更新推送房源状态
     $pushedHouse = Model_House_CommissionHousePushed::data_access()->filter('brokerId', $brokerId)->filter('propertyId', $house->id)->find_only();
     if ($pushedHouse) {
         $pushedHouse->propertyStatus = Model_House_CommissionHousePushed::STATUS_RUSHED;
         $pushedHouse->save();
     }
     // 记录到commission_sale_log日志表
     Bll_Broker_EntrustConsumeLog::getInstance()->insertCommissionSaleLog($house, $brokerId);
     // 给房东发送短信
     if ($house->ownerMobile) {
         // 小区名称
         $commName = mb_strlen($house->commName, "utf-8") <= 12 ? $house->commName : mb_substr($house->commName, 0, 12, "utf-8") . "...";
         // 经纪人信息
         $content = $house->userName . "您好,您在安居客发布的" . $commName . "的委托已被经纪人" . $brokerName . "接受,联系方式" . $brokerPhone;
         Bll_Broker_ShowcaseCommon::getInstance()->sendAlertMsg(array($house->ownerMobile), $content, 1010);
     }
     //给app房东推送消息,added by xiongjiewu at 2014-08-07
     $this->pushEntrustMsg($brokerId, $id);
     // 拼装返回数据
     $result['status'] = 1;
     // 抢委托成功
     $result['data'] = array('owner' => $house->userName, 'phone' => $house->getPhone(), 'title' => '', 'summary' => '', 'manageUrl' => '');
     $area = '[' . implode('-', $house->getAreaCodeNames()) . '] ';
     $houseModel = "{$house->roomNum}室{$house->hallNum}厅{$house->toiletNum}卫,{$house->areaNum}平方米,";
     $baseDomain = APF::get_instance()->get_config('base_domain', 'common');
     $baseUri = defined('BASE_URI') ? BASE_URI : '';
     $result['data']['title'] = '[出售] ' . $house->commName;
     $result['data']['summary'] = $area . $houseModel . $house->proPrice . '万元';
     $result['data']['manageUrl'] = "http://my.{$baseDomain}{$baseUri}/commissions/mysale";
     return $result;
 }
コード例 #10
0
 private function throwError($content)
 {
     $mailSubject = date('Ymd') . ' 软件使用扣费出错!';
     Bll_Broker_ShowcaseCommon::getInstance()->sendMail($mailSubject, $content, $this->mailArr);
 }
コード例 #11
0
 /**
  * 停止job
  */
 public function stopFlag()
 {
     $mailSubject = "同步customer_broker_coupon表orderId的数据";
     $mailBody = "Job在" . date('Y-m-d H:i:s') . "执行结束,最后一个订单ID为" . $this->lastId;
     Bll_Broker_ShowcaseCommon::getInstance()->sendMail($mailSubject, $mailBody, $this->mailArr);
     $this->textOutput('已经没有要处理的数据了', false);
     $this->setShStopFlag();
 }
コード例 #12
0
 public function checkYesterdayOver()
 {
     //获得参数
     $flag = $this->getFlag();
     if ($flag) {
         // 昨天没有执行结束
         if (date('Ymd', strtotime($flag['createTime'])) == $this->yDate && $flag['msg'] != 'over') {
             // 报警处理,发送短信
             $content = $this->subject . " 昨天统计日志没有执行结束,当前job执行时间为" . date("Y-m-d H:i:s", time());
             Bll_Broker_ShowcaseCommon::getInstance()->sendAlertMsg($this->mobileArr, $content);
             $this->setShStopFlag();
             exit;
         }
     }
 }