market_draw_1124
This commit is contained in:
@@ -79,22 +79,40 @@ class Market_sylive_order_model extends HD_Model
|
||||
$winType = [];
|
||||
if ($activityId == 4) {//纳米BOX双11纳享嗨购日
|
||||
$img = 'https://qs.haodian.cn/web/images/project/H5-ShiYu-draw';
|
||||
$winType = [
|
||||
6 => ['title' => '150元京东卡', 'tag' => '六等奖', 'img' => $img . '/prize-jd-150.png', 'price' => 0.99, 'num' => 300]
|
||||
, 5 => ['title' => '200元京东卡', 'tag' => '五等奖', 'img' => $img . '/prize-jd-200.png', 'price' => 0.99, 'num' => 200]
|
||||
, 4 => ['title' => '300元京东卡', 'tag' => '四等奖', 'img' => $img . '/prize-jd-300.png', 'price' => 0.99, 'num' => 100]
|
||||
, 3 => ['title' => '500元京东卡', 'tag' => '三等奖', 'img' => $img . '/prize-jd-500.png', 'price' => 0.99, 'num' => 50]
|
||||
, 2 => ['title' => 'iphone14', 'tag' => '二等奖', 'img' => $img . '/prize-iPhone14.png', 'price' => 199, 'num' => 5]
|
||||
, 1 => ['title' => '半价购车权益', 'tag' => '一等奖', 'img' => $img . '/prize-banjia.png', 'price' => 199, 'num' => 1]
|
||||
, 7 => ['title' => '200元京东卡', 'tag' => '199独享', 'img' => $img . '/prize-jd-200.png', 'price' => 199, 'num' => 5]
|
||||
, 8 => ['title' => '500元京东卡', 'tag' => '199独享', 'img' => $img . '/prize-jd-500.png', 'price' => 199, 'num' => 2]
|
||||
, 9 => ['title' => '1000元京东卡', 'tag' => '199独享', 'img' => $img . '/prize-jd-1000.png', 'price' => 199, 'num' => 1]
|
||||
$winType = [ 0 => ['title' => '请选择抽奖类型']
|
||||
, 6 => ['title' => '150元京东卡', 'tag' => '六等奖', 'img' => $img . '/prize-jd-150.png', 'price' => 0.99]
|
||||
, 5 => ['title' => '200元京东卡', 'tag' => '五等奖', 'img' => $img . '/prize-jd-200.png', 'price' => 0.99]
|
||||
, 4 => ['title' => '300元京东卡', 'tag' => '四等奖', 'img' => $img . '/prize-jd-300.png', 'price' => 0.99]
|
||||
, 3 => ['title' => '500元京东卡', 'tag' => '三等奖', 'img' => $img . '/prize-jd-500.png', 'price' => 0.99]
|
||||
, 2 => ['title' => 'iphone14', 'tag' => '二等奖', 'img' => $img . '/prize-iPhone14.png', 'price' => 199]
|
||||
, 1 => ['title' => '半价购车权益', 'tag' => '一等奖', 'img' => $img . '/prize-banjia.png', 'price' => 199]
|
||||
, 7 => ['title' => '200元京东卡', 'tag' => '199独享', 'img' => $img . '/prize-jd-200.png', 'price' => 199]
|
||||
, 8 => ['title' => '500元京东卡', 'tag' => '199独享', 'img' => $img . '/prize-jd-500.png', 'price' => 199]
|
||||
, 9 => ['title' => '1000元京东卡', 'tag' => '199独享', 'img' => $img . '/prize-jd-1000.png', 'price' => 199]
|
||||
];
|
||||
if ($type) {
|
||||
$winType = $winType[$type];
|
||||
}
|
||||
}
|
||||
if ($type) {
|
||||
$winType = $winType[$type];
|
||||
}
|
||||
return $winType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:中奖人数
|
||||
* Created on: 2022/11/24 15:46
|
||||
* Created by: dengbw
|
||||
* @param int $activityId
|
||||
* @return array
|
||||
*/
|
||||
public function winNumAry($activityId = 0)
|
||||
{
|
||||
$winNumAry = [];
|
||||
if ($activityId == 4) {//纳米BOX双11纳享嗨购日
|
||||
$winNumAry = [['title' => '请选择中奖人数', 'value' => 0],
|
||||
['title' => '1人', 'value' => 1], ['title' => '2人', 'value' => 2],
|
||||
['title' => '5人', 'value' => 5], ['title' => '50人', 'value' => 50]];
|
||||
}
|
||||
return $winNumAry;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,14 +44,14 @@ class Draw extends CI_Controller
|
||||
$re = $this->mdSyliveActivity->get(['drawCode' => $drawCode, 'status' => 0], 'title,activityId');
|
||||
if ($re['activityId']) {
|
||||
$activityId = intval($re['activityId']);
|
||||
$winNumAry = [['title' => '请选择...', 'value' => 0], ['title' => '1人', 'value' => 1], ['title' => '2人', 'value' => 2],
|
||||
['title' => '5人', 'value' => 5], ['title' => '50人', 'value' => 50]];
|
||||
$winTypeAry = [];
|
||||
$winNumAry = $this->mdSyliveOrder->winNumAry($activityId);//中奖人数
|
||||
$winTypeAry = [];//抽奖类型
|
||||
$winTypeAryGet = $this->mdSyliveOrder->winTypeAry($activityId);
|
||||
foreach ($winTypeAryGet as $k => $v) {
|
||||
if ($k == 1 || $k == 2) {//监时加上
|
||||
} else {
|
||||
$winTypeAry[] = ['title' => $v['tag'] . ' ' . $v['title'], 'value' => $k];
|
||||
$title = $v['tag'] ? $v['tag'] . ' ' . $v['title'] : $v['title'];
|
||||
$winTypeAry[] = ['title' => $title, 'value' => $k];
|
||||
}
|
||||
}
|
||||
$title = $re['title'] . '_私域直播抽奖';
|
||||
@@ -102,46 +102,45 @@ class Draw extends CI_Controller
|
||||
$this->show_json(400, '暂无活动');
|
||||
}
|
||||
if (date('Y-m-d H:i:s') > $re['timeEnd']) {
|
||||
$this->show_json(400, '直播已结束,不能开始抽奖');
|
||||
$this->show_json(400, "直播结束时间【{$re['timeEnd']}】,不能抽奖了...");
|
||||
}
|
||||
$winTypeAry = $this->mdSyliveOrder->winTypeAry($activityId);
|
||||
$price = $winTypeAry[$winType]['price'];
|
||||
$limit = $winNum >= 50 ? 100 : 50;
|
||||
//随机数据
|
||||
$sql = "SELECT id,userId,mobile,uname,totalPrice FROM lc_market_sylive_order WHERE activityId={$activityId}
|
||||
AND win=0 AND status=1 AND totalPrice>={$price} ORDER BY RAND() LIMIT {$limit}";
|
||||
$res = $this->db->query($sql)->result_array();
|
||||
$list = $result = [];
|
||||
foreach ($res as $v) {
|
||||
if ($v['mobile']) {
|
||||
$headimg = 'https://qs.haodian.cn/web/images/project/H5-ShiYu/default-head.png';
|
||||
$tel = mobile_asterisk($v['mobile']);
|
||||
$name = $v['uname'] ? name_asterisk($v['uname']) : '***';
|
||||
$re_user = $this->mdSyliveUser->get(['userId' => $v['userId']], 'nickname,headimg');
|
||||
if ($re_user) {
|
||||
$re_user['headimg'] && $headimg = $re_user['headimg'];
|
||||
}
|
||||
$list[] = ['headimg' => $headimg, 'name' => $name, 'tel' => $tel, 'id' => intval($v['id']),
|
||||
'uname' => $v['uname'], 'mobile' => $v['mobile']];
|
||||
}
|
||||
}
|
||||
$count = count($list);
|
||||
$time = "在【" . date('Y-m-d H:i:s') . "】";
|
||||
$count = $this->mdSyliveOrder->count(['activityId' => $activityId, 'win' => 0, 'status' => 1, 'totalPrice>=' => $price]);
|
||||
$list = $result = [];
|
||||
if ($count) {//判断抽奖名单
|
||||
//随机数据
|
||||
$sql = "SELECT id,userId,mobile,uname,totalPrice FROM lc_market_sylive_order WHERE activityId={$activityId}
|
||||
AND win=0 AND status=1 AND totalPrice>={$price} ORDER BY RAND() LIMIT {$limit}";
|
||||
$res = $this->db->query($sql)->result_array();
|
||||
foreach ($res as $v) {
|
||||
if ($v['mobile']) {
|
||||
$headimg = 'https://qs.haodian.cn/web/images/project/H5-ShiYu/default-head.png';
|
||||
$tel = mobile_asterisk($v['mobile']);
|
||||
$name = $v['uname'] ? name_asterisk($v['uname']) : '***';
|
||||
$re_user = $this->mdSyliveUser->get(['userId' => $v['userId']], 'nickname,headimg');
|
||||
if ($re_user && $re_user['headimg']) {
|
||||
$headimg = $re_user['headimg'];
|
||||
}
|
||||
$list[] = ['headimg' => $headimg, 'name' => $name, 'tel' => $tel, 'id' => intval($v['id']),
|
||||
'uname' => $v['uname'], 'mobile' => $v['mobile']];
|
||||
}
|
||||
}
|
||||
$count = count($list);
|
||||
}
|
||||
if (!$count) {
|
||||
$this->show_json(400, "{$time}暂无获取到抽奖人,不能开始抽奖");
|
||||
$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;
|
||||
//选择中奖人结果
|
||||
shuffle($list);
|
||||
$result = array_slice($list, 0, $winNum);
|
||||
|
||||
$msg = "{$time}获取到的信息,可开始抽奖";
|
||||
$msg = "{$time}获取到抽奖名单,可开始抽奖";
|
||||
$data['result'] = $result;
|
||||
$data['type'] = $winType;
|
||||
$data['prizeUrl'] = $winTypeAry[$winType]['img'];
|
||||
@@ -168,6 +167,7 @@ class Draw extends CI_Controller
|
||||
$smsTime = date('Y-m-d H:i');
|
||||
$showMobile = '';
|
||||
$winNum = 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) {
|
||||
@@ -176,7 +176,7 @@ class Draw extends CI_Controller
|
||||
//中奖发短信
|
||||
if ($winType == 1 || $winType == 2) {//一等奖、二等奖不发短信
|
||||
$showMobile = $showMobile ? $showMobile . ",{$v['uname']}({$v['mobile']})" : "{$v['uname']}({$v['mobile']})";
|
||||
} else if ($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);
|
||||
@@ -186,6 +186,7 @@ class Draw extends CI_Controller
|
||||
}
|
||||
$msg = $showMobile ? $showMobile : "成功抽中{$winNum}人";
|
||||
$winNumCount = $this->mdSyliveOrder->count(['activityId' => $activityId, 'win' => 1, 'status' => 1, 'winType' => $winType]);
|
||||
$data['dev'] = $dev;
|
||||
$data['result'] = $resultSet;
|
||||
$data['winMsgTip'] = $winNumCount;
|
||||
$this->show_json(200, $msg ? $msg : '成功抽奖', $data);
|
||||
|
||||
@@ -80,15 +80,15 @@
|
||||
</select>
|
||||
<span class="fn-fl text-middle ml10 mt10 font-18 color-fff">已中奖{{winMsgTip}}人</span>
|
||||
<span v-if="!isStartAc">
|
||||
<span class="text-middle font-18 color-fff">选择中奖人数:</span>
|
||||
<span class="text-middle font-18 color-fff">中奖人数:</span>
|
||||
<select class="text-middle mr10 select-more pl20 pr20 ulib-r5 font-18" style="height:50px;"
|
||||
@change="changeType">
|
||||
<option :value="item.value" v-for="item in info.winNumAry">{{item.title}}</option>
|
||||
</select>
|
||||
<a class="text-middle inline-block bg-1282f4 ml10 mr10 pt10 pb10 pl20 pr20 text-center font-18 color-fff ulib-r5"
|
||||
href="javascript:;" @click="getDraw">更新信息</a>
|
||||
v-if="draw.list.length>0" href="javascript:;" @click="start">开始抽奖</a>
|
||||
<a class="text-middle inline-block bg-1282f4 ml10 mr10 pt10 pb10 pl20 pr20 text-center font-18 color-fff ulib-r5"
|
||||
v-if="draw.list.length>0" href="javascript:;" @click="start">开始抽奖</a>
|
||||
href="javascript:;" @click="getDraw">{{draw.list.length>0 ? '更新' : '获取'}}抽奖名单</a>
|
||||
</span>
|
||||
<span v-else>
|
||||
<a class="text-middle inline-block bg-1282f4 ml10 mr10 pt10 pb10 pl20 pr20 text-center font-18 color-fff ulib-r5"
|
||||
@@ -137,8 +137,8 @@
|
||||
title: '私域直播抽奖',
|
||||
submitFlag: false,
|
||||
topTitle: '',
|
||||
winNum: '0',
|
||||
winType: 6,
|
||||
winNum: 0,
|
||||
winType: 0,
|
||||
winMsgTip: 0,
|
||||
activityId: 0,
|
||||
info: {
|
||||
@@ -196,56 +196,61 @@
|
||||
}
|
||||
});
|
||||
},
|
||||
//更新信息
|
||||
//更新抽奖名单
|
||||
getDraw() {
|
||||
let that = this;
|
||||
if (that.isSubmiting) return;
|
||||
if (!that.winType) {
|
||||
that.msgTip = "请选择抽奖类型";
|
||||
return;
|
||||
}
|
||||
if (!that.winNum) {
|
||||
that.msgTip = "请选择中奖人数";
|
||||
return;
|
||||
}
|
||||
if (that.isOpen) return;
|
||||
clearTimeout(that.timer);
|
||||
that.msgTip = "";
|
||||
this.isShowReset = false;
|
||||
if (!that.isOpen && that.winNum > 0) {
|
||||
that.draw = {list: [], result: [], type: 0, prizeUrl: ''};
|
||||
that.list = [];
|
||||
$.ajax({
|
||||
url: '/h5/market/draw/post_info',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {winNum: that.winNum, winType: that.winType, activityId: that.activityId},
|
||||
beforeSend: function () {
|
||||
that.submitFlag = true;
|
||||
},
|
||||
success: function (re) {
|
||||
if (re.code == 200) {
|
||||
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;
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
that.submitFlag = false;
|
||||
that.isShowReset = false;
|
||||
that.draw = {list: [], result: [], type: 0, prizeUrl: ''};
|
||||
that.list = [];
|
||||
$.ajax({
|
||||
url: '/h5/market/draw/post_info',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {winNum: that.winNum, winType: that.winType, activityId: that.activityId},
|
||||
beforeSend: function () {
|
||||
that.submitFlag = true;
|
||||
},
|
||||
success: function (re) {
|
||||
if (re.code == 200) {
|
||||
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;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
that.msgTip = "请选择中奖人数"
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
that.submitFlag = false;
|
||||
}
|
||||
});
|
||||
},
|
||||
//中奖人数
|
||||
getWinNum() {
|
||||
let that = this;
|
||||
if (that.isSubmiting) return;
|
||||
if (!that.winType || !that.activityId) return;
|
||||
$.ajax({
|
||||
url: '/h5/market/draw/post_win_num',
|
||||
type: 'post',
|
||||
@@ -264,23 +269,26 @@
|
||||
}
|
||||
});
|
||||
},
|
||||
//选择中奖个数
|
||||
changeType(e) {
|
||||
this.isOpen = false;
|
||||
if (this.winNum != e.target.value) {
|
||||
this.draw = {list: [], result: [], type: 0, prizeUrl: ''};
|
||||
this.winNum = e.target.value;
|
||||
this.list = [];
|
||||
this.msgTip = "";
|
||||
}
|
||||
},
|
||||
//选择中奖类型
|
||||
changeTitle(e) {
|
||||
if (this.winType != e.target.value) {
|
||||
this.winType = e.target.value;
|
||||
this.draw = {list: [], result: [], type: 0, prizeUrl: ''};
|
||||
this.list = [];
|
||||
this.msgTip = "";
|
||||
this.getWinNum();
|
||||
}
|
||||
},
|
||||
//选择中奖人数
|
||||
changeType(e) {
|
||||
this.isOpen = false;
|
||||
if (this.winNum != e.target.value) {
|
||||
this.winNum = e.target.value;
|
||||
this.draw = {list: [], result: [], type: 0, prizeUrl: ''};
|
||||
this.list = [];
|
||||
this.msgTip = "";
|
||||
}
|
||||
},
|
||||
//开始抽奖
|
||||
start() {
|
||||
this.msgTip = '';
|
||||
@@ -288,11 +296,11 @@
|
||||
this.isStartAc = true;
|
||||
this.timer = setInterval(res1 => {
|
||||
//随机排序
|
||||
let arr = this.draw.list.slice(0)
|
||||
let arr = this.draw.list.slice(0);
|
||||
arr.sort(function () {
|
||||
return Math.random() - 0.5;
|
||||
})
|
||||
this.list = arr
|
||||
});
|
||||
this.list = arr;
|
||||
}, 20)
|
||||
},
|
||||
//立即开奖
|
||||
@@ -335,6 +343,7 @@
|
||||
this.draw = {list: [], result: [], type: 0, prizeUrl: ''};
|
||||
this.isStartAc = false;
|
||||
this.isOpen = true;
|
||||
this.winNum = 0;
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user