public function handle_request_internal() { $userId = $this->_params['userId']; $code = $this->_params['code']; //4.3之前版本的兼容性处理,此api之后将废弃 return array('status' => 'error', 'errcode' => Const_APIStatus::E_FYK_USER_ACTIVATION_CODE_CLOSE, 'message' => '此功能已关闭'); // TODO 校验用户是否存在 $brokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('userId', $userId)->find_only(); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } // TODO 校验激活码是否有效 $codeInfo = Model_Fyk_InvitationCodes::data_access()->filter(Model_Fyk_InvitationCodes::CODE, $code)->filter(Model_Fyk_InvitationCodes::BIND_TO, $userId)->get_all(); if (empty($codeInfo)) { return API_Result::create()->error()->errorCode('9999')->message('邀请码错误')->toArray(); } $userInfo = Model_Fyk_Users::data_access()->filter(Model_Fyk_Users::USER_ID, $userId)->find_only(); if ($userInfo->status != Model_Fyk_Users::INIT) { return API_Result::create()->error()->errorCode('9999')->message('房源库功能已经激活')->toArray(); } $userInfo->status = Model_Fyk_Users::INVITATION; if ($userInfo->save()) { //TODO 关注房源库公共账号-待补充 $msg = '{"title": "房源库小喵 小贝欢迎大家到来","date": "' . date('m') . '月' . date('d') . '日","img":"http://pic1.ajkimg.com/m/fc68794e8da91a3d03f80487b888a193/540x270x95.jpg","desc": "成交从好的房源开始,好的房源来自移动房源库!","url": "http://api.anjuke.com/web/chat/content?id=101_290_0","jsonVersion": "1"}'; $chatInfo = Bll_Mobile_ChatInfoBll::getInstance()->getChatInfo($brokerInfo->brokerId, 1); $chatId = $chatInfo['data']['chatId']; Bll_Mobile_ChatInfoBll::sendFykPublicMsg($chatId, $msg); return array('status' => 'ok', 'message' => '激活成功'); } }
/** * Job执行逻辑 */ public function handle_request() { //记录调用api参数 printf('[%s] lastLogId: %s' . PHP_EOL, date('Y-m-d H:i:s'), $this->lastLogId); $logs = $this->getLogList(); if (!empty($logs)) { foreach ($logs as $log) { //记录游标 $this->setFlag(array('id' => $log['id'])); if ($log['changeType'] == 1) { continue; } $couponInfo = $this->getCouponInfo($log['brokerCouponId']); if (!empty($couponInfo)) { $data = array(); $data['changeType'] = 0; if ($log['changeType'] == 2) { $data['changeType'] = 1; } elseif ($log['changeType'] == 3) { $data['changeType'] = 2; } $data['brokerId'] = $log['brokerId']; $data['num'] = $log['num']; $data['changeTime'] = $log['createTime']; $data['price'] = $couponInfo['disPrice'] / $couponInfo['totalNum'] * $data['num']; //消耗的券价值多少 $data['realPrice'] = $data['price']; $cityInfo = Model_Broker_AjkBrokerExtend::data_access()->load_field('cityId')->filter('brokerId', $data['brokerId'])->get_row(); $data['cityId'] = $cityInfo['cityId']; Model_KuaiJi_CustomerBrokerCouponConsume::create($data)->save(); } } } }
public static function communitySignTopSigner($communityId, $currentSignRange, $per = 3) { $signs = Model_Broker_CommunitySign::data_access(date('Ym', strtotime($currentSignRange[0])))->filter('communityId', $communityId)->filter_by_op_multi(array(array('signTime', '>=', $currentSignRange[0]), array('signTime', '<=', $currentSignRange[1])))->sort('signTime', 'asc')->limit(3)->find_all(); $signers = array(); if ($signs) { $brokerIds = array(); foreach ($signs as $sign) { $brokerIds[] = $sign['brokerId']; } $brokers = Model_Broker_AjkBrokerExtend::data_access()->filter('brokerId', $brokerIds)->find_all(); $indexedBrokers = array(); foreach ($brokers as $broker) { $indexedBrokers[$broker['brokerId']] = $broker; } foreach ($signs as $sign) { if (!isset($indexedBrokers[$sign['brokerId']])) { continue; } $broker = $indexedBrokers[$sign['brokerId']]; $signer = array(); $signer['brokerId'] = $broker['brokerId']; $signer['brokerTrueName'] = $broker['trueName']; // 图片地址替换 if ($broker['userPhoto']) { $signer['brokerPhoto'] = Util_DisplayImages::get_img_url($broker['userPhoto'], -1, '100x133'); } else { $signer['brokerPhoto'] = PageHelper::pure_static_url('/img/bknoimg.gif'); // 默认头像 } $signers[] = $signer; } } return $signers; }
public function handle_request_internal() { $mobile = $this->_params['mobile']; $brokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('userMobile', $mobile)->find_only(); if (!$brokerInfo) { return API_Result::create()->error()->errorCode('9999')->message('经纪人不存在')->toArray(); } $userId = $brokerInfo->userId; $userAccountId = Bll_Fyk_Payment_User::getInstance()->getUserAccountId($userId); if (empty($userAccountId)) { return API_Result::create()->error()->message('没有用户支付中心ID')->toArray(); } $time = date('Y-m-d H:i:s'); $data['userId'] = $brokerInfo->userId; $data['brokerId'] = $brokerInfo->brokerId; $data['cityId'] = $brokerInfo->cityId; $data['createTime'] = $time; $insertUserId = Model_Fyk_Users::getInstance()->insertData($data); unset($data); if ($insertUserId) { do { $code = rand(100000, 999999); $arr = Model_Fyk_InvitationCodes::data_access()->load_field('id')->filter('code', $code)->get_row(); } while ($arr !== NULL); $data['code'] = $code; //生成邀请码 $data['bindTo'] = $userId; $data['createTime'] = $time; $insertInvitationCodeId = Model_Fyk_InvitationCodes::getInstance()->insertData($data); if ($insertInvitationCodeId) { return API_Result::create()->ok()->data(array('status' => 1))->toArray(); } } }
public function get_broker_info($brokerId) { $da = Model_Broker_AjkBrokerExtend::data_access(); $da->filter('brokerId', $brokerId); $data = $da->find(); return $data; }
public function handle_request_internal() { /** * 签到小区列表 * * - 验证参数 * * - 获取经纪人 * * - 根据lat和lng获取1.5km内的小区列表(查询Solr) * * - 判断经纪人是否签到过(用于设置当前时间段内经纪人是否签到过) * * - 返回数据 */ $result = array('status' => 'error', 'errcode' => '', 'message' => ''); // 获取参数 $brokerId = $this->_params['brokerId']; $lat = $this->_params['lat']; $lng = $this->_params['lng']; // 获取经纪人 $broker = Model_Broker_AjkBrokerExtend::data_access()->filter('brokerId', $brokerId)->find_only(); if (!$broker) { throw new Exception('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } if (empty($lat) || empty($lng)) { $result['message'] = '获取定位数据失败,请重新定位'; return $result; } // 获取数据 $communities = $this->getCommList($brokerId, $lat, $lng); // 判断经纪人是否签到过 if ($communities) { $communityIds = array(); foreach ($communities as $community) { $communityIds[] = $community['commId']; } // 获取当前所处签到周期 $signedCommunities = array(); $currentSignRange = Bll_Broker_CommunitySign::getCurrentSignRange(); if ($currentSignRange) { $signs = Model_Broker_CommunitySign::data_access(date('Ym', strtotime($currentSignRange[0])))->filter('brokerId', $brokerId)->filter_by_op_multi(array(array('signTime', '>=', $currentSignRange[0]), array('signTime', '<=', $currentSignRange[1])))->get_all(); foreach ($signs as $sign) { $signedCommunities[$sign['communityId']] = $sign['communityId']; } } // 标记小区签到状态 foreach ($communities as &$row) { if (isset($signedCommunities[$row['commId']])) { $row['signed'] = 1; } else { $row['signed'] = 0; } } } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'total' => count($communities), 'data' => $communities); }
/** * Job执行逻辑 */ public function handle_request() { $mail = array('*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'); $frozenList = Model_Payment_AcFreezen::data_access()->filter('freezeEffective', 1)->filter('appid', $this->appids)->filter_by_op('createTime', '<=', $this->errorTime)->get_all(); $re = $accountId = array(); if ($frozenList) { $this->setLog('今日共' . count($frozenList)); foreach ($frozenList as $frozen) { $word = $this->getWord($frozen['appid']); $re[$word['word']]['数量']++; $re[$word['word']]['金额'] += $frozen['amount']; $userInfo = Model_Payment_AjkUserAccount::data_access()->filter('accountId', $frozen['accountId'])->get_row(); if (!$userInfo['userId']) { continue; } $brokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('userId', $userInfo['userId'])->get_row(); if (!$brokerInfo['brokerId']) { continue; } $brokerId = $brokerInfo['brokerId']; $accountId[$brokerId]['word'] = $word['word']; $accountId[$brokerId]['amount'] = $frozen['amount']; if ($this->dealFlag) { //解冻处理 $url = $this->acenterHost . 'acenter/interfaces/?action=use&account=' . $frozen['accountId'] . '&amount=0&frozen=' . $frozen['acBalanceId'] . '¬e=解冻金额&appid=' . $frozen['appid'] . '&appkey=' . $this->appInfo[$word['constWord']]['appKey'] . '&requestid=' . date('YmdHis') . mt_rand(0, 1000) . $frozen['accountId']; $result = Uri_Curl::get_curl($url); $this->setLog($url); $this->setLog($result); if ($result['result']) { //解冻成功,call @马荟的查询余额接口进行数据修复 $balanceUrl = $this->proxyHost . 'service-exes/rest/exes/inquiry?json&appId=23&appKey=' . $this->appInfo['ajk_bid']['appKey'] . '&account=' . $frozen['accountId']; $reBalance = Uri_Curl::get_curl($balanceUrl); $this->setLog($balanceUrl); $this->setLog($reBalance); $this->setLog('account: ' . $frozen['accountId'] . ' ,业务: ' . $word['word'] . ' ,amount: ' . $frozen['amount'] . ' ,serialNumber: ' . $frozen['acBalanceId']); } } } $str = '<table border="1"><tr><td>业务类型</td><td>数量</td><td>金额</td></tr>'; foreach ($re as $wr => $ac) { $str .= '<tr><td>' . $wr . '</td><td>' . $ac['数量'] . '</td><td>' . $ac['金额'] . '</td></tr>'; } $str .= '</table><br /><br /><table border="1"><tr><td>业务类型</td><td>经纪人ID</td><td>金额</td></tr>'; foreach ($accountId as $brokerId => $ac) { $str .= '<tr><td>' . $ac['word'] . '</td><td>' . $brokerId . '</td><td>' . $ac['amount'] . '</td></tr>'; } $str .= '</table>'; $this->send_mail($mail, '有问题的冻结共 ' . count($frozenList), $str); return true; } else { $this->send_mail($mail, '今天没有有问题的冻结', '今天没有有问题的冻结'); return true; } }
/** * 获取二手房经纪人的userId * * @param int $ajkBrokerId * @return int * @throws Exception */ public static function getBrokerUserIdByBrokerId($ajkBrokerId) { $dataAccess = Model_Broker_AjkBrokerExtend::data_access(); $dataAccess->filter('brokerId', $ajkBrokerId); $dataAccess->load_field(array('userId')); $row = $dataAccess->get_row(); if (empty($row)) { throw new Exception(sprintf('没有获取到经纪人[%d]信息', $ajkBrokerId)); } return intval($row['userId']); }
public function handle_request_internal() { /** * 00:00 * 获取前一天20:00 以后 * 10:00 * 获取10:00 以后 * 15:00 * 获取15:00 以后 * 20:00 * 获取20:00 以后 * */ // 获取参数; $commId = $this->_params['commId']; // 根据ID获取小区 $community = Bll_Community_APIComm::getInstance()->getInfoByIdMapping($commId, 2); if (!$community || !$community['sosolat'] || !$community['sosolng']) { throw new Exception('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } $data = array(); if (Bll_Broker_CommunitySign::isTopSignerActivityOngoing()) { $hour = intval(date('H')); if ($hour >= 0 && $hour < 10) { $theSignRange = array(date('Y-m-d 20:00:00', strtotime('-1 day')), date('Y-m-d 23:59:59', strtotime('-1 day'))); } elseif ($hour >= 10 && $hour < 15) { $theSignRange = array(date('Y-m-d 10:00:00'), date('Y-m-d 14:59:59')); } elseif ($hour >= 15 && $hour < 20) { $theSignRange = array(date('Y-m-d 15:00:00'), date('Y-m-d 19:59:59')); } else { $theSignRange = array(date('Y-m-d 20:00:00'), date('Y-m-d 23:59:59')); } $brokerInfos = Bll_Commsign::getFirstThr($commId, $theSignRange[0]); //var_dump($data);exit; $data = array(); if (!empty($brokerInfos)) { foreach ($brokerInfos as $k => $v) { $brokerTmp = Bll_Commsign::getBrokerInfo($v['brokerId']); if (!$brokerTmp) { $broker = Model_Broker_AjkBrokerExtend::data_access()->filter('brokerId', $v['brokerId'])->find_only(); $broker_photo = Util_ImageUtils::get_broker_photo_url($broker['userPhoto'], '200x200'); $brokerTmp = array('brokerId' => $broker['brokerId'], 'username' => $broker['trueName'], 'userPhoto' => $broker_photo, 'cityId' => $broker['cityId']); Bll_Commsign::redisBrokerInfo($v['brokerId'], $brokerTmp); } if (empty($brokerTmp['userPhoto'])) { $brokerTmp['userPhoto'] = PageHelper::pure_static_url('/img/bknoimg.gif'); } $dataTmp = array('brokerId' => $brokerTmp['brokerId'], 'brokerTrueName' => $brokerTmp['username'], 'brokerPhoto' => $brokerTmp['userPhoto']); $data[] = $dataTmp; } } } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data); }
public function handle_request_internal() { $userId = $this->_params['userId']; // TODO 校验用户是否存在 $brokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('userId', $userId)->find_only(); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } $data = self::getFykStatus(intval($userId), $brokerInfo['cityId']); return API_Result::create()->ok()->data($data)->toArray(); }
public function handle_request_internal() { //4.3之前版本的兼容性处理,此api之后将废弃 header("Access-Control-Allow-Origin: *"); return array('status' => 'error', 'errcode' => Const_APIStatus::E_FYK_USER_ACTIVATION_CODE_CLOSE, 'message' => '此功能已关闭'); $userId = $this->_params['userId']; // TODO 校验用户是否存在 $brokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('userId', $userId)->find_only(); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } $codeInfo = Model_Fyk_InvitationCodes::data_access()->filter(Model_Fyk_InvitationCodes::BIND_TO, $userId)->get_row(); if (empty($codeInfo)) { return API_Result::create()->error()->errorCode('9999')->message('邀请码错误')->toArray(); } return API_Result::create()->ok()->data(array('code' => $codeInfo['code']))->toArray(); }
public function handle_request_internal() { $userId = $this->_params['userId']; $mobile = $this->_params['mobile']; $status = $this->_params['status']; if (!$userId) { $brokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('userMobile', $mobile)->find_only(); } else { $brokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('userId', $userId)->find_only(); } if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } $userId = $brokerInfo->userId; try { Model_Fyk_Users::data_access()->set_field(Model_Fyk_Users::STATUS, $status)->filter(Model_Fyk_Users::USER_ID, $userId)->update(); } catch (Exception $e) { return API_Result::create()->error()->errorCode('9999')->message('修改房源库权限失败')->toArray(); } return API_Result::create()->ok()->data(array('message' => '修改成功'))->toArray(); }
public function handle_request_internal(){ $mobile = $this->_params['mobile']; $price = $this->_params['price']; $brokerInfo = Model_Broker_AjkBrokerExtend::data_access() ->filter('userMobile', $mobile) ->find_only(); if (!$brokerInfo) { return API_Result::create()->error()->errorCode('9999')->message('经纪人不存在')->toArray(); } $userId = $brokerInfo->userId; $userAccountId = Bll_Fyk_Payment_User::getInstance()->getUserAccountId($userId); if (empty($userAccountId)) { return API_Result::create()->error()->message('没有用户支付中心ID')->toArray(); } $addArr = array( 'userId' => $userId, 'propId' => 0, 'price' => $price, 'requestId' => 0, 'actionMsg' => '', 'actionCode' => Const_Fyk::USER_RECHARGE_BY_SYSTEM, 'status' => Model_Fyk_MoneyActionQueue::STATUS_NODEAL, 'createTime' => time() ); $id = Model_Fyk_MoneyActionQueue::getInstance()->insertData($addArr); if($id){ return API_Result::create() ->ok() ->toArray(); } else { return API_Result::create() ->error() ->message('插入系统加钱队列失败') ->toArray(); } }
public function handle_request_internal() { /** * 签到小区详情 * * - 验证参数 * * * - 获取经纪人 * * - 获取小区(AjkCommunity) * - * * - 获取小区签到人数 * * - 判断经纪人是否可签到(经纪人是否已签到、当前是否在签到时间段) * - 校验小区坐标和lat、lng的距离5公里,超出不可签到(如小区无坐标,不可签到) * * - 计算距离下一时间点的签到倒计时(单位:s) * * - 获取小区各个时间段签到前3名 * * - 返回数据 */ // 获取参数 $brokerId = $this->_params['brokerId']; $commId = $this->_params['commId']; $lat = $this->_params['lat']; $lng = $this->_params['lng']; // 根据ID获取经纪人 $broker = Bll_Commsign::getBrokerInfo($brokerId); if (!$broker) { $broker = Model_Broker_AjkBrokerExtend::data_access()->filter('brokerId', $brokerId)->find_only(); if (!$broker) { throw new Exception('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } $broker_photo = Util_ImageUtils::get_broker_photo_url($broker['userPhoto'], '200x200'); $brokerInfo = array('brokerId' => $broker['brokerId'], 'username' => $broker['trueName'], 'userPhoto' => $broker_photo, 'cityId' => $broker['cityId']); Bll_Commsign::redisBrokerInfo($brokerId, $brokerInfo); } // 根据ID获取小区 $community = Bll_Commsign::getCommInfo($commId); if (empty($community)) { $community = Bll_Community_APIComm::getInstance()->getInfoByIdMapping($commId, 2); $commInfo = array(); $commInfo['commId'] = $community['commId']; $commInfo['commName'] = $community['commName']; $commInfo['sosolng'] = $community['sosolng']; $commInfo['sosolat'] = $community['sosolat']; Bll_Commsign::setCommInfo($commId, $commInfo); } if (!$community || !$community['sosolat'] || !$community['sosolng']) { throw new Exception('小区不存在', Const_APIStatus::E_COMMUNITY_NOT_EXISTS); } // 获取小区签到人数 $communitySignCount = Bll_Commsign::getCommCount($commId); // 判断经纪人是否可签到 $signAble = true; $currentSignRange = Bll_Broker_CommunitySign::getCurrentSignRange(); if (!$currentSignRange) { $signAble = false; } else { // 经纪人是否已经签过到 if (Bll_Commsign::isSignedAlready($brokerId, $commId, $currentSignRange[0])) { $signAble = false; } } // 对比小区坐标和参数坐标两点的距离(5km) $distance = Util_Map::distance($lat, $lng, $community['sosolat'], $community['sosolng']); if ($distance > 5000) { $signAble = false; } $data = array(); $data['signAble'] = intval($signAble); $data['signCount'] = $communitySignCount; $data['countDown'] = $signAble ? 0 : Bll_Broker_CommunitySign::nextSignCountDown(); $data['signList'] = array(); // 获取各时间段签到前三名 if (Bll_Broker_CommunitySign::isTopSignerActivityOngoing()) { $data['signList'] = array(array('hour' => '10:00', 'brokers' => array()), array('hour' => '15:00', 'brokers' => array()), array('hour' => '20:00', 'brokers' => array())); foreach ($data['signList'] as &$theSignList) { $theHour = intval($theSignList['hour']); $hour = intval(date('H')); if ($hour >= 0 && $hour < 10) { break; } elseif ($hour >= 10 && $hour < 20) { if ($theHour > $hour) { continue; } } $theSignRange = array(); switch ($theHour) { case 10: $theSignRange = array(date('Y-m-d 10:00:00'), date('Y-m-d 14:59:59')); break; case 15: $theSignRange = array(date('Y-m-d 15:00:00'), date('Y-m-d 19:59:59')); break; case 20: $theSignRange = array(date('Y-m-d 20:00:00'), date('Y-m-d 23:59:59')); break; } $theSignList['brokers'] = Bll_Commsign::getFirstThr($commId, $theSignRange[0]); if (empty($theSignList['brokers'])) { $theSignList['brokers'] = Model_Broker_CommunitySign::data_access(date('Ym', strtotime($currentSignRange[0])))->filter('communityId', $commId)->filter_by_op_multi(array(array('signTime', '>=', $theSignRange[0]), array('signTime', '<=', $theSignRange[1])))->sort('signTime', 'asc')->limit(3)->get_all(); } $tmp = array(); if (!empty($theSignList['brokers'])) { foreach ($theSignList['brokers'] as $k => $v) { $brokerTmp = Bll_Commsign::getBrokerInfo($v['brokerId']); if (!$brokerTmp) { $broker = Model_Broker_AjkBrokerExtend::data_access()->filter('brokerId', $v['brokerId'])->find_only(); $broker_photo = Util_ImageUtils::get_broker_photo_url($broker['userPhoto'], '200x200'); $brokerTmp = array('brokerId' => $broker['brokerId'], 'username' => $broker['trueName'], 'userPhoto' => $broker_photo, 'cityId' => $broker['cityId']); Bll_Commsign::redisBrokerInfo($v['brokerId'], $brokerTmp); } if (empty($brokerTmp['userPhoto'])) { $brokerTmp['userPhoto'] = PageHelper::pure_static_url('/img/bknoimg.gif'); } $dataTmp = array('brokerId' => $brokerTmp['brokerId'], 'brokerTrueName' => $brokerTmp['username'], 'brokerPhoto' => $brokerTmp['userPhoto']); $tmp[] = $dataTmp; } $theSignList['brokers'] = $tmp; } } } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data); }
/** * 插入返钱队列 * * @return array */ public function insertQueue() { $typeId = APF::get_instance()->get_request()->get_parameter('typeId'); $brokerId = APF::get_instance()->get_request()->get_parameter('brokerId'); $cityId = APF::get_instance()->get_request()->get_parameter('cityid'); $remark = APF::get_instance()->get_request()->get_parameter('remark'); $amount = APF::get_instance()->get_request()->get_parameter('amount'); $mobile = APF::get_instance()->get_request()->get_parameter('mobile'); //验证手机号和经纪人id的正确性 $brokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter_by_op('userMobile', '=', $mobile)->find_only(); if (empty($brokerInfo)) { return array('status' => 'fail', 'info' => '对应手机号对应的经纪人不存在'); } if ($brokerInfo->brokerId != $brokerId) { return array('status' => 'fail', 'info' => '手机号与经纪人id不符'); } $sqlResult = Model_Broker_AjkPppccoinQueen::data_access()->force_master()->filter_by_op('typeid', '=', $typeId)->filter_by_op('brokerid', '=', $brokerId)->find_only(); if ($sqlResult) { return array('status' => 'fail', 'info' => '该经纪人当天已有一条返还记录'); } $mysqlAccessor = new Model_Broker_AjkPppccoinQueen(); $mysqlAccessor->brokerid = $brokerId; $mysqlAccessor->cityid = $cityId; $mysqlAccessor->typeid = $typeId; $mysqlAccessor->remark = $remark; $mysqlAccessor->amount = $amount; $mysqlAccessor->addtime = time(); $mysqlAccessor->save(); return array('status' => 'success', 'info' => 'insert success'); }
public function getMemberBalance($memberId) { $memberInfo = Model_Broker_JpBroker::data_access()->filter('id', $memberId)->get_row(); if (intval($memberInfo['ajkMemberId']) > 0) { $ajkBrokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('brokerId', $memberInfo['ajkMemberId'])->get_row(); if (!empty($ajkBrokerInfo) && $ajkBrokerInfo['userId']) { $balanceInfo = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $ajkBrokerInfo['userId'])); if ($balanceInfo['status'] == 'error') { return -1; } return $balanceInfo['data']['balance']; } } return -1; }
public function push($remind, &$error) { // 订阅不存在,不推送 if (!isset($this->subscriptions[$remind['subscriptionId']])) { $error = 'subscription is not exist.'; return false; } // 订阅已取消,不推送 $subscription = $this->subscriptions[$remind['subscriptionId']]; if ($subscription['status'] == Model_Choice_Subscription::SUBSCRIPTION_CANCEL) { $error = 'subscription is canceled'; return false; } // 微聊账户不存在,不推送 $chatInfo = Model_Mobile_BrokerChatInfo::data_access()->filter('brokerId', $subscription['brokerId'])->find_only(); if (!$chatInfo) { $error = 'broker has no chat account.'; return false; } // 文案:XXX(小区)的精选推广位空出来了,快去占位吧! if ($subscription['site'] == Model_Choice_Subscription::SITE_AJK) { // 获取二手房房源小区 $broker = Model_Broker_AjkBrokerExtend::data_access()->filter('brokerId', $subscription['brokerId'])->find_only(); $cityId = $broker['cityId']; $prop = Bll_House_EsfHouse::getHouseInfo($subscription['propId'], $cityId); $commName = $prop['commName']; } elseif ($subscription['site'] == Model_Choice_Subscription::SITE_RENT) { // 获取租房房源小区 $prop = Model_House_HzProp::findByPropId($subscription['propId']); $cityId = $prop->getContentBasic('cityid'); $propSearch = Model_House_HzPropSearch::data_access($cityId)->filter('proid', $prop['propId'])->find_only(); $commName = $propSearch['commname']; } else { $error = 'invalid subscription site.'; return false; } if (!$commName) { $error = 'failed to fetch community name'; return false; } // 准备待推送文案 $type = 'subscription'; $text = $commName . '的精选推广位空出来了,快去占位吧!'; $propId = strval($subscription['propId']); $tradeType = strval($subscription['site']); // 1 二手房 2租房 // 推送消息 $chatId = $chatInfo['chatId']; $api_host = APF::get_instance()->get_config('chat_api_host'); $message_url = $api_host['host'] . '/common/sendUserNotify/' . $chatId . '?from_idc=1&from=mobile-ajk-broker'; $message = json_encode(array('msgType' => 'push', 'type' => $type, 'message' => $text, 'propId' => $propId, 'tradeType' => $tradeType, 'body' => array('type' => $type, 'msg' => $text, 'propId' => $propId, 'tradeType' => $tradeType))); $result = Util_API::postData($message_url, $message); if ($result['status'] != 'OK') { $error = 'failed to call push api: ' . json_encode($result); return false; } return true; }
/** * 根据区域获取经济人信息 * @param $areaCode * @return array * add by zhennanwang */ public static function getDataByAreaCodeAll($areaCode) { if (empty($areaCode) || !is_numeric($areaCode)) { return array(); } $brokerData = Model_Broker_AjkBrokerExtend::data_access()->filter('areaCode', $areaCode)->limit(50)->find(); return $brokerData; }
/** * 开始处理数据 * @return bool */ protected function proccessData() { if (empty($this->jobData)) { //没有数据 return false; } $tDate = date('Ymd'); foreach ($this->jobData as $jobData) { $this->id = $jobData->id; //查询委托关系 $commissionInfo = Model_House_Commission::getInfoByBrokerIdAndBrokerHouseId($jobData->proId, 1, ''); if (!empty($commissionInfo)) { if (empty($this->cPropInfo[$commissionInfo->houseId])) { //房东房源具体信息 try { $this->cPropInfo[$commissionInfo->houseId] = Model_House_CommissionHouse::data_access()->find_by_pk($commissionInfo->houseId); } catch (Exception $e) { $this->cPropInfo[$commissionInfo->houseId] = false; } } $commissionProp = $this->cPropInfo[$commissionInfo->houseId]; if (empty($commissionProp)) { //房东信息没有,跳过处理下一跳 continue; } //写入委托房源被推广日志 $spreadObj = new Model_House_CommissionSaleLog(); $spreadObj->cityId = $commissionProp->cityId; $spreadObj->ownerId = $commissionInfo->ownerId; $spreadObj->houseId = $commissionInfo->houseId; $spreadObj->brokerId = $commissionInfo->brokerId; $spreadObj->brokerHouseId = $jobData->proId; $spreadObj->dateindex = $tDate; $spreadObj->status = $jobData->type == 1 ? Model_House_CommissionSaleLog::STATUS_PROP_FS : Model_House_CommissionSaleLog::STATUS_PROP_BS; $spreadObj->origin = $commissionInfo->origin; $spreadObj->createTime = time(); $spreadObj->save(); unset($spreadObj); $firstSmsInfo = Model_House_CommissionFirstAction::getBrokerHouseInfo($commissionInfo->brokerId, $commissionInfo->houseId); if (!empty($firstSmsInfo)) { //如果已经发过短信,无需再处理 continue; } if (empty($this->brokerInfo[$commissionInfo->brokerId])) { //经纪人信息 $this->brokerInfo[$commissionInfo->brokerId] = Model_Broker_AjkBrokerExtend::data_access()->find_by_pk($commissionInfo->brokerId); } $bInfo = $this->brokerInfo[$commissionInfo->brokerId]; if (empty($bInfo) || empty($commissionProp)) { continue; } if (mb_strlen($commissionProp->commName, 'UTF-8') > 12) { //小区名称 $commName = mb_substr($commissionProp->commName, 0, 12, 'UTF-8') . '...'; } else { $commName = $commissionProp->commName; } //短信内容 $content = $commissionProp->userName . '您好,' . $bInfo->trueName . ' ' . $bInfo->userMobile . ' 已将您在' . $commName . '的房源在安居客网站上挂牌'; $smsInfo = array('userid' => $commissionProp->userId, 'brokerid' => $commissionInfo->brokerId, 'mobile' => $commissionProp->ownerMobile, 'content' => $content, 'status' => '0', 'createtime' => date('Y-m-d H:i:s'), 'bizid' => 1010); Model_Notice_AjkSmsTask::insertLayer($smsInfo); //插入发短信信息表 $smsObj = new Model_House_CommissionFirstAction(); $smsObj->brokerId = $commissionInfo->brokerId; $smsObj->houseId = $commissionInfo->houseId; $smsObj->type = $jobData->type; $smsObj->dateIndex = $tDate; $smsObj->createTime = time(); $smsObj->save(); //给app推送消息 $this->senfAppMsg($commissionInfo->brokerId, $jobData->proId, $commissionInfo->houseId, $commissionProp->userId); var_dump('LOG:' . $jobData->id . ' send sms done!' . "\n"); } var_dump('LOG:' . $jobData->id . ' is done!' . "\n"); } return true; }
protected function getDbCurrentTime() { $result = Model_Broker_AjkBrokerExtend::data_access()->native_sql('SELECT UNIX_TIMESTAMP() AS current;', array(), true, PDO::FETCH_ASSOC); return intval($result[0]['current']); }
public function handle_request_internal() { $userId = $this->_params['userId']; $brokerId = $this->_params['brokerId']; $cityId = $this->_params['cityId']; // TODO 校验用户是否存在 $brokerInfo = Model_Broker_AjkBrokerExtend::data_access()->filter('userId', $userId)->find_only(); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } //查询用户是否存在fyk_users表 $userInfo = Bll_Fyk_User_User::getInstance()->getUsersByUserId($userId); if (empty($userInfo)) { //不存在则插入 $data = array('userId' => $userId, 'brokerId' => $brokerId, 'cityId' => $cityId, 'status' => Model_Fyk_Users::INIT, 'openDate' => 0, 'activeTime' => 0, 'createTime' => date('Y-m-d h:i;s', time())); do { $tableId = Model_Fyk_Users::getInstance()->insertData($data); } while (empty($tableId)); } else { //判断用户是否未激活 $isInIt = $this->_isUserInIt($userInfo); if ($isInIt === false) { //该用户已激活,返回错误信息 return array('status' => 'error', 'errcode' => Const_APIStatus::E_FYK_USER_ALREADY_ACTIVATE, 'message' => '该用户已报名'); } } $result = array(); $result['hasActivity'] = 1; $result['isStart'] = 1; $result['canActivate'] = 1; $result['activateMessage'] = '立即激活'; if (Const_Fyk::ACTIVATE_START_HOUR < 12) { $result['startMessage'] = '每天' . '早上' . Const_Fyk::ACTIVATE_START_HOUR . '点开抢'; } else { $result['startMessage'] = '每天' . '下午' . Const_Fyk::ACTIVATE_START_HOUR . '点开抢'; } //获取当先正在进行的活动配置信息 $onActivateConfig = Bll_Fyk_User_User::getInstance()->getOnActivateConfig($cityId); if (empty($onActivateConfig)) { //如果没有正在进行的活动,则查询最近且最新的一条将要进行的活动 $result['isStart'] = 0; $result['canActivate'] = 0; $result['activateNumMessage'] = ''; $result['activateMessage'] = '暂未开启'; $nearActivateConfig = Bll_Fyk_User_User::getInstance()->getNearActivateConfig($cityId); if (empty($nearActivateConfig)) { //如果近期都没有活动,则返回固定文案 $result['hasActivity'] = 0; $result['activateMessage'] = '本期活动已结束'; $result['startMessage'] = ''; $result['dateMessage'] = '下期具体开放时间会另行通知!'; return array('status' => 'ok', 'data' => $result); } $result['dateMessage'] = $this->_assembleDate($nearActivateConfig['startDate'], $nearActivateConfig['endDate']); return array('status' => 'ok', 'data' => $result); } $result['dateMessage'] = $this->_assembleDate($onActivateConfig['startDate'], $onActivateConfig['endDate']); $nowHour = intval(date('H', time())); if ($nowHour < Const_Fyk::ACTIVATE_START_HOUR) { //当天有活动,但活动没开始 $result['isStart'] = 0; $result['canActivate'] = 0; $result['activateNumMessage'] = ''; $result['activateMessage'] = '暂未开启'; return array('status' => 'ok', 'data' => $result); } //当天有活动且活动开始 $today = intval(date('Ymd', time())); $activateInfo = Bll_Fyk_User_User::getInstance()->getActivateInfoByCityIdAndDate($cityId, $today); $activateNum = intval($activateInfo['activateNum']); $dayNum = intval($onActivateConfig['dayNum']); $num = $dayNum - $activateNum; $num = $num > 0 ? $num : 0; $result['activateNumMessage'] = '今日剩余名额: ' . $num; if ($activateNum >= $dayNum) { //本日报名人数达到上限 $result['canActivate'] = 0; $result['activateMessage'] = '今日已抢完'; return array('status' => 'ok', 'data' => $result); } return array('status' => 'ok', 'data' => $result); }
public function fetchMultiBrokerInfos($brokerIds) { $brokerInfos = Model_Broker_AjkBrokerExtend::data_access()->filter('brokerId', $brokerIds)->find_all(); $indexedBrokerInfos = array(); foreach ($brokerInfos as $brokerInfo) { $indexedBrokerInfos[$brokerInfo['brokerId']] = $brokerInfo; } return $indexedBrokerInfos; }
public function handle_request_internal() { /** * 小区签到逻辑 * * - 验证参数 * * - 获取经纪人 * * - 获取小区(AjkCommunity) * - 校验小区坐标和lat、lng的距离5公里(如小区无坐标,直接拒绝) * * - 添加签到记录 * - 添加签到记录 * - 更新签到按日统计信息(incr) * * - 更新经纪人坐标 * - 添加经纪人坐标日志 * - 更新经纪人坐标 * * - 返回数据 */ $result = array('status' => 'error', 'errcode' => '', 'message' => ''); // 获取参数 $brokerId = $this->_params['brokerId']; $commId = $this->_params['commId']; $lat = $this->_params['lat']; $lng = $this->_params['lng']; if (empty($lat) || empty($lng)) { $result['message'] = '获取定位数据失败,请重新定位'; return $result; } // 根据ID获取经纪人 $broker = Bll_Commsign::getBrokerInfo($brokerId); if (!$broker) { $broker = Model_Broker_AjkBrokerExtend::data_access()->filter('brokerId', $brokerId)->find_only(); if (!$broker) { throw new Exception('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } $broker_photo = Util_ImageUtils::get_broker_photo_url($broker['userPhoto'], '200x200'); $brokerInfo = array('brokerId' => $broker['brokerId'], 'username' => $broker['trueName'], 'userPhoto' => $broker_photo, 'cityId' => $broker['cityId']); Bll_Commsign::redisBrokerInfo($brokerId, $brokerInfo); } // 根据ID获取小区 $community = Bll_Commsign::getCommInfo($commId); if (empty($community)) { $community = Bll_Community_APIComm::getInstance()->getInfoByIdMapping($commId, 2); $commInfo = array(); $commInfo['commId'] = $community['commId']; $commInfo['commName'] = $community['commName']; $commInfo['sosolng'] = $community['sosolng']; $commInfo['sosolat'] = $community['sosolat']; Bll_Commsign::setCommInfo($commId, $commInfo); } // 小区不存在或小区经纬租表不存在时,返回小区不存在 if (!$community || !$community['sosolat'] || !$community['sosolng']) { $result['errcode'] = Const_APIStatus::E_COMMUNITY_NOT_EXISTS; $result['message'] = '小区暂未开通签到功能'; return $result; } // 对比小区坐标和参数坐标两点的距离(5km) $distance = Util_Map::distance($lat, $lng, $community['sosolat'], $community['sosolng']); if ($distance > 5000) { $result['errcode'] = Const_APIStatus::E_BROKER_COMMSIGN_FAR_AWAY; $result['message'] = '签到失败!你跑得太远了,请返回重新定位'; return $result; } // 获取当前所处签到时间(10:00 15:00 20:00) $currentSignRange = Bll_Broker_CommunitySign::getCurrentSignRange(); if (!$currentSignRange) { $result['errcode'] = Const_APIStatus::E_BROKER_COMMSIGN_NOT_IN_RANGE; $result['message'] = '不在签到时间范围'; return $result; } // 判断是否已经签到 if (Bll_Commsign::isSigned($brokerId, $commId, $currentSignRange[0])) { $result['errcode'] = Const_APIStatus::E_BROKER_COMMSIGN_ALREADY_SIGNED; $result['message'] = '已经签到!'; return $result; } try { // 新建签到, $sign = array('brokerId' => $brokerId, 'communityId' => $commId, 'lat' => $lat, 'lng' => $lng, 'signTime' => date('Y-m-d H:i:s'), 'currentSignRange' => $currentSignRange[0]); Bll_Commsign::Signed($brokerId, $commId, $currentSignRange[0], $sign); //缓存‘签到信息’到同步数据库的redis中 Bll_RedisToDb::writeBrokerCommunitySign($sign); // 缓存经纪人位置 $locationInfo = array('brokerId' => $brokerId, 'lng' => $lng, 'lat' => $lat, 'updateTime' => date('Y-m-d H:i:s')); Bll_Commsign::setLocationInfo($brokerId, $locationInfo); //缓存‘位置信息’到同步数据库的redis中 Bll_RedisToDb::writeBrokerLocation($locationInfo); //记录每日签到情况 Bll_Commsign::dailySignedRecord($brokerId); // 获取签到排名 $rank = Bll_Commsign::getSignRank($commId, $currentSignRange[0]); //连续签到统计 $SignStatistics = Bll_Commsign::getSignStatistics($brokerId); $sendFlag = false; if ($SignStatistics) { if (date('Y-m-d', strtotime($SignStatistics['updateTime'])) == date('Y-m-d', strtotime('yesterday'))) { $SignStatistics['signCount'] = $SignStatistics['signCount'] + 1; $sendFlag = true; } elseif (date('Y-m-d', strtotime($SignStatistics['updateTime'])) == date('Y-m-d', time())) { } else { $SignStatistics['signCount'] = 1; $sendFlag = true; } if ($SignStatistics['signCount'] > $SignStatistics['maxSignCount']) { $SignStatistics['maxSignCount'] = $SignStatistics['signCount']; } $SignStatistics['updateTime'] = date('Y-m-d H:i:s'); Bll_Commsign::setSignStatistics($brokerId, $SignStatistics); //缓存‘签到统计信息’到同步数据库的redis中 $SignStatistics = array_merge($SignStatistics, array('sendFlag' => $sendFlag)); Bll_RedisToDb::writeCommSignStatistics($SignStatistics); } else { $SignStatistics = array('brokerId' => $brokerId, 'signCount' => 1, 'maxSignCount' => 1, 'createTime' => date('Y-m-d H:i:s')); Bll_Commsign::setSignStatistics($brokerId, $SignStatistics); $sendFlag = true; //缓存‘签到统计信息’到同步数据库的redis中 $SignStatistics = array_merge($SignStatistics, array('sendFlag' => $sendFlag)); Bll_RedisToDb::writeCommSignStatistics($SignStatistics); } } catch (Exception $e) { $result['message'] = '签到人太多,系统繁忙,请稍后再试~'; return $result; } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('signRank' => $rank, 'countDown' => Bll_Broker_CommunitySign::nextSignCountDown())); }