login_white = 'all';//登录白名单 $this->check_status = [];//用户状态校验 $this->check_mobile = [];//需要手机号 $this->check_headimg = [];//授权微信信息 $this->load->model('market/market_sylive_activity_model'); $this->load->model('market/market_sylive_order_model'); $this->load->model('market/market_sylive_customer_model'); } protected function get_user() { $ukey = $this->input_param('ukey'); $activityId = 27;//活动id $activity = $this->market_sylive_activity_model->get(['activityId' => $activityId]); if (!$activity) { //throw new Hd_exception('活动不存在', API_CODE_FAIL); } if (!$ukey) { throw new Hd_exception('ukey不存在', API_CODE_FAIL); } $customer = $this->market_sylive_customer_model->get(['ukey' => $ukey]); if(!$customer){ throw new Hd_exception('用户不存在', API_CODE_FAIL); } $data = [ 'customerId' => $customer['customerId'], ]; return $data; } protected function post_reward() { $activityId = 27;//活动id $ukey = $this->input_param('ukey'); $reward_id = $this->input_param('reward_id'); //$reward_id 对应 winType $winTypes = array( '5051' => '1', //电视机 '5052' => '2', //电冰箱 '5053' => '3', //平板 ); $winName = array( '5051' => '电视机', '5052' => '电冰箱', '5053' => '平板电脑', ); $activity = $this->market_sylive_activity_model->get(['activityId' => $activityId]); if (!$activity) { throw new Hd_exception('活动不存在', API_CODE_FAIL); } if (!$reward_id || !in_array($reward_id, $winTypes)) { throw new Hd_exception('参数错误', API_CODE_FAIL); } if (!$ukey) { throw new Hd_exception('ukey不存在', API_CODE_FAIL); } $customer = $this->market_sylive_customer_model->get(['ukey' => $ukey]); if(!$customer){ throw new Hd_exception('用户不存在', API_CODE_FAIL); } $order = $this->market_sylive_order_model->get(['activityId' => $activityId, 'userId' => $customer['userId'], 'status' => 1,]); if($order && $order['win'] == 0){ $data = [ 'win' => 1, 'winType' => $winTypes[$reward_id], 'winTime' => date('Y-m-d H:i:s'), ]; $rt = $this->market_sylive_order_model->update($data, ['id' => $order['id']]); } if ($rt) { $winSms = "【好店云】“龙行龘龘「哪」红包”感谢您参与哪吒汽车华南大区新春活动,恭喜您成功锁定(".$winName[$reward_id].")一份,只需您在2024年2月29日前在当地门店选购哪吒X\哪吒AYA\哪吒U-II等车型并完成上牌,即可领取礼品!"; b2m_send_sms($order['mobile'], $winSms); throw new Hd_exception('执行成功', API_CODE_SUCCESS); } throw new Hd_exception('目标对象不存在', API_CODE_FAIL); } protected function post_car() { $activityId = 27;//活动id $ukey = $this->input_param('ukey'); $car = $this->input_param('car'); $activity = $this->market_sylive_activity_model->get(['activityId' => $activityId]); if (!$activity) { throw new Hd_exception('活动不存在', API_CODE_FAIL); } if (!$car) { throw new Hd_exception('参数错误', API_CODE_FAIL); } if (!$ukey) { throw new Hd_exception('ukey不存在', API_CODE_FAIL); } $customer = $this->market_sylive_customer_model->get(['ukey' => $ukey]); if(!$customer){ throw new Hd_exception('用户不存在', API_CODE_FAIL); }else{ $data = ['visitTagId' => $car,]; $rt = $this->market_sylive_customer_model->update($data, ['customerId' => $customer['customerId']]); } if ($rt) { throw new Hd_exception('执行成功', API_CODE_SUCCESS); } throw new Hd_exception('目标对象不存在', API_CODE_FAIL); } }