From f8ca91ce60966fa4be7893e4ee679c910ff67325 Mon Sep 17 00:00:00 2001 From: xiaoyu Date: Thu, 12 Oct 2023 15:36:16 +0800 Subject: [PATCH] draw --- home/controllers/h5/market/Draw.php | 98 +++++++++++++++-------------- home/views/h5/market/draw/index.php | 2 +- 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/home/controllers/h5/market/Draw.php b/home/controllers/h5/market/Draw.php index ce41436e..868efc8e 100644 --- a/home/controllers/h5/market/Draw.php +++ b/home/controllers/h5/market/Draw.php @@ -122,11 +122,11 @@ class Draw extends CI_Controller if (date('Y-m-d H:i:s') > $re['timeEnd']) { $this->show_json(400, "直播结束时间【{$re['timeEnd']}】,不能抽奖了..."); } + $limit = $winNum >= 50 ? 400 : 200;//随机数据 $prizeUrl = ''; $whereOrder = ['activityId' => $activityId, 'win' => 0, 'status' => 1]; - $sqlOrder = "SELECT id,userId,mobile,uname,totalPrice FROM lc_market_sylive_order WHERE activityId={$activityId} - AND win=0 AND winType=0 AND status=1 ORDER BY RAND() LIMIT {$limit}"; + $re_draw = $this->mdSyliveActivityDraw->get(['activityId' => $activityId]); if ($re_draw && $re_draw['winType']) { $json_winType = json_decode($re_draw['winType'], true); @@ -134,6 +134,14 @@ class Draw extends CI_Controller if ($v['id'] == $winType) { $v['img'] && $prizeUrl = build_qiniu_image_url($v['img']); if ($v['itemIds']) { + + //不中奖奖品 + if($activityId == 21 and in_array($winType, array(1,2))){ + $activityId = 13; + $whereOrder = ['activityId' => $activityId, 'status' => 1]; + $v['itemIds'] = [21]; + } + $itemIds = implode(',', $v['itemIds']); $whereOrder["itemId in({$itemIds})"] = null; $sqlOrder = "SELECT id,userId,mobile,uname,totalPrice FROM lc_market_sylive_order WHERE activityId={$activityId} @@ -145,6 +153,7 @@ class Draw extends CI_Controller } $time = "在【" . date('Y-m-d H:i:s') . "】"; $count = $this->mdSyliveOrder->count($whereOrder); + $list = $result = []; if ($count) {//判断抽奖名单 //随机数据 @@ -177,29 +186,29 @@ class Draw extends CI_Controller $data['list'] = $list; //暗箱 - if($activityId == 15 && in_array($winType, array(2,3))) - { - $list = array(); - $sqlOrder = "SELECT id,userId,mobile,uname,totalPrice FROM lc_market_sylive_order WHERE activityId={$activityId} AND win=0 AND winType={$winType} AND status=1 ORDER BY RAND() LIMIT {$winNum}"; - $res = $this->db->query($sqlOrder)->result_array(); - - if ($res) { - $str_userIds = implode(',', array_column($res, 'userId')); - $map_user = $this->mdSyliveUser->map('userId', 'headimg', ["userId in({$str_userIds})" => null]); - foreach ($res as $v) { - if ($v['mobile']) { - $tel = mobile_asterisk($v['mobile']); - $name = $v['uname'] ? name_asterisk($v['uname']) : '***'; - if ($map_user[$v['userId']]) { - $headimg = $map_user[$v['userId']]; - } else { - $headimg = $defaultHead; - } - $list[] = ['headimg' => $headimg, 'name' => $name, 'tel' => $tel, 'id' => intval($v['id']), 'uname' => $v['uname'], 'mobile' => $v['mobile']]; - } - } - } - } +// if($activityId == 15 && in_array($winType, array(2,3))) +// { +// $list = array(); +// $sqlOrder = "SELECT id,userId,mobile,uname,totalPrice FROM lc_market_sylive_order WHERE activityId={$activityId} AND win=0 AND winType={$winType} AND status=1 ORDER BY RAND() LIMIT {$winNum}"; +// $res = $this->db->query($sqlOrder)->result_array(); +// +// if ($res) { +// $str_userIds = implode(',', array_column($res, 'userId')); +// $map_user = $this->mdSyliveUser->map('userId', 'headimg', ["userId in({$str_userIds})" => null]); +// foreach ($res as $v) { +// if ($v['mobile']) { +// $tel = mobile_asterisk($v['mobile']); +// $name = $v['uname'] ? name_asterisk($v['uname']) : '***'; +// if ($map_user[$v['userId']]) { +// $headimg = $map_user[$v['userId']]; +// } else { +// $headimg = $defaultHead; +// } +// $list[] = ['headimg' => $headimg, 'name' => $name, 'tel' => $tel, 'id' => intval($v['id']), 'uname' => $v['uname'], 'mobile' => $v['mobile']]; +// } +// } +// } +// } //选择中奖人结果 shuffle($list); @@ -247,34 +256,27 @@ class Draw extends CI_Controller $winNum = $sms = 0; $dev = false !== strpos($_SERVER['HTTP_HOST'], 'dev') ? 1 : 0; foreach ($result as $v) { - $ret = $this->mdSyliveOrder->update(['win' => 1, 'winType' => $winType, 'winTime' => $winTime], ["id" => $v['id']]); - if ($ret) { - $winNum++; + if($activityId == 21 and in_array($winType, array(1,2))){ $resultSet[] = $v; + $winNum++; + $sms++; + }else{ - //半价车不发短信 - if($activityId == 20){ - if(in_array(1,2)){ - $dev = 1; + $ret = $this->mdSyliveOrder->update(['win' => 1, 'winType' => $winType, 'winTime' => $winTime], ["id" => $v['id']]); + + if ($ret) { + $winNum++; + $resultSet[] = $v; + + //中奖发短信 + if ($v['mobile'] && $dev == 0) {//dev==1不发短信通知 + if ($winTime >= $re['timeStart'] && $winSms) {//直播开始时中奖发短信 + b2m_send_sms($v['mobile'], $winSms); + $sms++; + } } } - - //中奖发短信 - if ($v['mobile'] && $dev == 0) {//dev==1不发短信通知 - if ($winTime >= $re['timeStart'] && $winSms) {//直播开始时中奖发短信 - b2m_send_sms($v['mobile'], $winSms); - $sms++; - } - } -// if ($winType == 1 || $winType == 2) {//一等奖、二等奖不发短信 -// $showMobile = $showMobile ? $showMobile . ",{$v['uname']}({$v['mobile']})" : "{$v['uname']}({$v['mobile']})"; -// } else if ($v['mobile'] && $dev == 0) {//dev==1不发短信通知 -// if ($smsTime >= "2022-11-11 19:00") {//发短信 -// $content = "【好店云】礼品锁定提醒:感谢您参与东风ev新能源双11嗨购日专场活动,恭喜您成功锁定({$winTypeAry['title']})礼品一份,只需您在11月30日晚20点前在当地门店选购东风ev新车型纳米box,即可领取礼品哦!"; -// b2m_send_sms($v['mobile'], $content); -// } -// } } } $msg = $showMobile ? $showMobile : "成功抽中{$winNum}人"; diff --git a/home/views/h5/market/draw/index.php b/home/views/h5/market/draw/index.php index 61355bd5..3cda6464 100644 --- a/home/views/h5/market/draw/index.php +++ b/home/views/h5/market/draw/index.php @@ -15,7 +15,7 @@
-
+
{{topTitle}}