private function add_lucky_draw_config($periods_no, $start_time, $end_time) { $aid = 1; $times_limit = 100; $title = '积分回馈抽奖'; $consume = 20; return Bll_Cms_LuckyDrawConfig::add_config($aid, $periods_no, $times_limit, $title, $consume, $start_time, $end_time); }
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; }