From c8a270e0106c56d7d25ea40d7ffc49c0d9f1c33b Mon Sep 17 00:00:00 2001 From: dengbw Date: Fri, 11 Nov 2022 10:30:03 +0800 Subject: [PATCH] market_draw_1111 --- home/controllers/h5/market/Draw.php | 18 +++++++++++----- home/views/h5/market/draw/index.php | 32 ++++++++++++----------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/home/controllers/h5/market/Draw.php b/home/controllers/h5/market/Draw.php index e1d7507c..d9f80608 100644 --- a/home/controllers/h5/market/Draw.php +++ b/home/controllers/h5/market/Draw.php @@ -115,15 +115,23 @@ class Draw extends CI_Controller 'uname' => $v['uname'], 'mobile' => $v['mobile']]; } } + $count = count($list); + $time = "在【" . date('Y-m-d H:i:s') . "】"; + if (!$count) { + $this->show_json(400, "{$time}暂无获取到抽奖人,不能开始抽奖"); + } + if ($count < $winNum) { + $this->show_json(400, "{$time}获取到抽奖人数{$count}人,不够选择中奖人数{$winNum}人,不能开始抽奖"); + } $data['list'] = $list; //$winNumCount = $this->mdSyliveOrder->count(['activityId' => $activityId, 'win' => 1, 'status' => 1, 'winType' => $winType]); //$num = $winTypeAry[$winType]['num']; //$winNum = ($winNum + $winNumCount) > $num ? $num - $winNumCount : $winNum; - if ($winNum > 0) { - shuffle($list); - $result = array_slice($list, 0, $winNum); - } - $msg = "在【" . date('Y-m-d H:i:s') . "】获取到信息"; + //选择中奖人结果 + shuffle($list); + $result = array_slice($list, 0, $winNum); + + $msg = "{$time}获取到的信息,可开始抽奖"; $data['result'] = $result; $data['type'] = $winType; $data['prizeUrl'] = $winTypeAry[$winType]['img']; diff --git a/home/views/h5/market/draw/index.php b/home/views/h5/market/draw/index.php index e9da5321..2f2eb6fb 100644 --- a/home/views/h5/market/draw/index.php +++ b/home/views/h5/market/draw/index.php @@ -205,25 +205,19 @@ }, success: function (re) { if (re.code == 200) { - if (re.data.list.length == 0) { - that.msgTip = '无抽奖人...'; - } else if (re.data.list.result == 0) { - that.msgTip = '无中抽奖人...'; - } else { - that.msgTip = re.msg; - that.topTitle = $("#win_type_id").find("option:selected").text(); - that.draw = { - list: re.data.list, - result: re.data.result, - type: re.data.type, - prizeUrl: re.data.prizeUrl - }; - // let arr = that.draw.list.slice(0); - // arr.sort(function () { - // return Math.random() - 0.5; - // }); - // that.list = arr; - } + that.msgTip = re.msg; + that.topTitle = $("#win_type_id").find("option:selected").text(); + that.draw = { + list: re.data.list, + result: re.data.result, + type: re.data.type, + prizeUrl: re.data.prizeUrl + }; + // let arr = that.draw.list.slice(0); + // arr.sort(function () { + // return Math.random() - 0.5; + // }); + // that.list = arr; } else { that.msgTip = re.msg; }