public function handle_request_internal() { $brokerId = $this->_params['brokerId']; $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } $sendNumChangeDate = APF::get_instance()->get_config("customer_daily_mission_reward_num", "customer"); if (time() >= strtotime($sendNumChangeDate)) { $sendNum = self::PRESENT_COUPON_NEW_NUM; $rewardMsg = APF::get_instance()->get_config("customer_daily_mission_reward_msg", "customer"); } else { $sendNum = self::PRESENT_COUPON_NUM; $rewardMsg = "恭喜你,获得抢客券2张"; } $data = array('brokerId' => $brokerId, 'rewardMsg' => $rewardMsg); $this->brokerId = $brokerId; // 获取活动劵类型数据 $cityId = $brokerInfo['cityId']; $couponData = Bll_CustomerRush_Coupon::getInstance()->getCoupon($cityId, date("Ymd"), Model_Mobile_CustomerCoupon::TYPE_DAILYCOUPON_PRESENT); if (empty($couponData)) { return array('status' => 'error', 'message' => '不存在活动劵信息'); } $this->couponId = $couponData['id']; $currentTime = date("Ymd", time()); //验证是否可领取奖励 if (Bll_Commsign::getAlreadyGetRewards($brokerId, $currentTime)) { return array('status' => 'error', 'message' => '已经领取过奖励'); } $dailyQuestStatus = Model_DailyQuest_DailyQuestStatus::getDailyQuestStatusByBrokerId($brokerId, $currentTime); $signStatus = $dailyQuestStatus['signState'] ? $dailyQuestStatus['signState'] : 0; $shareStatus = $dailyQuestStatus['shareState'] ? $dailyQuestStatus['shareState'] : 0; $rewardStatus = $dailyQuestStatus['rewardState'] ? $dailyQuestStatus['rewardState'] : 0; if (!($signStatus == '1' && $shareStatus == '1' && $rewardStatus == '0')) { return array('status' => 'error', 'message' => '已经领取过奖励'); } //赠送抢客劵 for ($i = 0; $i < $sendNum; $i++) { // 插入经纪人劵表 $arr = array('brokerId' => $this->brokerId, 'couponId' => $this->couponId, 'status' => Model_Mobile_CustomerBrokerCoupon::STATUS_OK_USE, 'totalNum' => $couponData['totalNum'], 'usedNum' => 0, 'updateTime' => date("Y-m-d H:i:s"), 'createTime' => time()); $this->brokerCouponId = Bll_CustomerRush_Coupon::getInstance()->insertBrokerCoupon($arr); if ($this->brokerCouponId) { // 记录日志 $this->_insertPresentCouponLog(); } else { return array('status' => 'error', 'message' => '赠送失败'); } } //更新已领取 Bll_Commsign::alreadyGetRewards($brokerId, $currentTime); $status = Model_DailyQuest_DailyQuestStatus::updateGetReward($brokerId, $currentTime); if (!$status) { return array('status' => 'error', 'message' => '更新领取状态失败'); } return array('status' => 'ok', 'data' => $data); }