public function handle_request()
 {
     $this->__logFile = sprintf('/home/www/logs/User_ImportUserInfo-%s.log', date('Ymd'));
     if (file_exists($this->__idFile) && is_readable($this->__idFile)) {
         $this->startId = intval(file_get_contents($this->__idFile));
     }
     $index = 1;
     $pageSize = 1000;
     while (true) {
         echo "开始导入第{$index}批经纪人信息, 起始BrokerId={$this->startId}\n";
         $brokerList = Model_Broker_AjkBrokerExtend::scanBroker($this->startId, $pageSize);
         if (empty($brokerList)) {
             break;
         }
         foreach ($brokerList as $broker) {
             $this->startId = $broker['brokerId'];
             file_put_contents($this->__idFile, $this->startId);
             file_put_contents($this->__logFile, "{$index}: 导入经纪人: {$broker['trueName']}\tBrokerId: {$broker['brokerId']}\tUserId: {$broker['userId']}\n", FILE_APPEND);
             /** $aid,$user_id,$broker_id,$city_id,$user_name,$gender,$phone,$properties,$origin_properties,$grade_score,$grade_level */
             Bll_Cms_ActivityUserProperty::add_broker(1, $broker['userId'], $broker['brokerId'], $broker['cityId'], $broker['trueName'], $broker['gender'] == 1 ? 0 : 1, $broker['userMobile'], $broker['gradeScore'], $broker['gradeScore'], $broker['gradeScore'], $broker['gradeLevel']);
         }
         $index++;
     }
     echo "导入经纪人信息完成,结束BrokerId={$this->startId}\n";
 }
Example #2
0
 private function ajax_lucky_draw($params)
 {
     if (!isset($params['aid']) || empty($params['aid']) || !isset($params['pro_id']) || empty($params['pro_id'])) {
         return array('status' => -99, 'message' => '参数错误', 'debug' => __CLASS__);
     }
     $request = APF::get_instance()->get_request();
     $broker_id = $request->getBrokerId();
     $periods_no = $params['pro_id'];
     $activity_id = $params['aid'];
     /** 判断抽奖活动当前是否有效 */
     $checkLuckyDraw = Bll_Cms_LuckyDrawConfig::check_lucky_draw_is_valid($activity_id, $periods_no);
     if ($checkLuckyDraw['status'] != 0) {
         return $checkLuckyDraw;
     }
     $consume = $checkLuckyDraw['luckyDrawConfig']['consume'];
     $times_limit = $checkLuckyDraw['luckyDrawConfig']['times_limit'];
     /** 判断经纪人资源是否不足 */
     $userProperty = Bll_Cms_ActivityUserProperty::check_lucky_draw_is_valid($broker_id, $activity_id, $consume);
     if ($userProperty['status'] != 0) {
         return $userProperty;
     }
     /** 判断经纪人抽奖次数是否上线 */
     $checkLuckyDrawTimes = Bll_Cms_LuckyDrawTimes::check_lucky_times_is_valid($activity_id, $broker_id, $periods_no, $times_limit);
     if ($checkLuckyDrawTimes['status'] != 0) {
         return $checkLuckyDrawTimes;
     }
     /** 扣除积分 */
     $effectCount = Dao_Cms_ActivityUserProperty::decrease_user_property($activity_id, $broker_id, $consume);
     if ($effectCount != 1) {
         return array('status' => -1, 'message' => '积分不足', 'debug' => __CLASS__, 'debug_info' => __LINE__);
     }
     $lid = $checkLuckyDraw['luckyDrawConfig']['id'];
     $city_id = $request->getBrokerCityId();
     $property = $userProperty['userProperty']['origin_propertys'];
     /** 开始抽奖 */
     $luckyDraw = Bll_Cms_LuckyDrawConfig::calculate_lucky_draw($lid, $city_id, $property, $checkLuckyDrawTimes['lucky_draw_times'], $checkLuckyDrawTimes['lucky_times']);
     /** 未中奖 */
     if ($luckyDraw['status'] == 0) {
         Bll_Cms_LuckyDrawTimes::increase_broker_times($activity_id, $broker_id, $periods_no, $times_limit);
         Bll_Cms_ActivityComsumePropertyLog::add_lucky_draw_thanks_log($activity_id, $broker_id, $luckyDraw['prize_id'], $userProperty['userProperty']['user_name'], $userProperty['userProperty']['phone'], '谢谢参与', $consume, $userProperty['userProperty']['propertys'], $request->get_client_ip());
         $luckyDraw['leveing'] = $userProperty['userProperty']['propertys'] - $consume;
         return $luckyDraw;
     }
     /** 开始派奖 */
     $lucky_draw_prize_id = $luckyDraw['lucky_prize']['id'];
     $luckyDrawLog = Bll_Cms_LuckyDrawConfig::log_lucky_draw($activity_id, $broker_id, $lucky_draw_prize_id, $periods_no, $times_limit, $consume);
     /** 中奖&奖品还有 */
     if ($luckyDrawLog['status'] == 0 && empty($luckyDrawLog['message'])) {
         Bll_Cms_ActivityComsumePropertyLog::add_lucky_draw_log($activity_id, $broker_id, $luckyDraw['prize_id'], $userProperty['userProperty']['user_name'], $userProperty['userProperty']['phone'], $luckyDraw['prize_title'], $consume, $userProperty['userProperty']['propertys'], $request->get_client_ip());
         return array('status' => 0, 'message' => $luckyDraw['message'], 'prize_id' => $luckyDraw['prize_id'], 'prize_title' => $luckyDraw['prize_title'], 'leveing' => $userProperty['userProperty']['propertys'] - $consume);
     }
     /** 奖品不够 */
     Bll_Cms_ActivityComsumePropertyLog::add_lucky_draw_thanks_log($activity_id, $broker_id, $luckyDraw['prize_id'], $userProperty['userProperty']['user_name'], $userProperty['userProperty']['phone'], '谢谢参与', $consume, $userProperty['userProperty']['propertys'], $request->get_client_ip());
     $luckyDrawLog['prize_title'] = '谢谢参与';
     $luckyDrawLog['leveing'] = $userProperty['userProperty']['propertys'] - $consume;
     return $luckyDrawLog;
 }