market_draw_1110_2

This commit is contained in:
dengbw
2022-11-10 19:45:22 +08:00
committed by lccsw
parent 95c896ae85
commit 51f01c08a1
5 changed files with 120 additions and 40 deletions
+39 -19
View File
@@ -8,7 +8,6 @@ defined('BASEPATH') OR exit('No direct script access allowed');
*/
class Draw extends CI_Controller
{
private $activityId = 4;
public function __construct()
{
@@ -27,19 +26,37 @@ class Draw extends CI_Controller
*/
public function index()
{
$winNumAry = [['title' => '请选择...', 'value' => 0], ['title' => '1人', 'value' => 1], ['title' => '2人', 'value' => 2],
['title' => '5人', 'value' => 5], ['title' => '50人', 'value' => 50]];
$winTypeAry = [];
$winTypeAryGet = $this->mdSyliveOrder->winTypeAry($this->activityId);
foreach ($winTypeAryGet as $k => $v) {
$winTypeAry[] = ['title' => $v['tag'] . ' ' . $v['title'], 'value' => $k];
$this->load->view('/h5/market/draw/index');
}
/**
* Notes:验证登录码
* Created on: 2022/11/10 18:04
* Created by: dengbw
*/
public function post_code()
{
$params = $this->input->post();
$drawCode = $params['drawCode'];
if (!$drawCode) {
$this->show_json(400, '请输入抽奖码');
}
$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 = [];
$winTypeAryGet = $this->mdSyliveOrder->winTypeAry($activityId);
foreach ($winTypeAryGet as $k => $v) {
$winTypeAry[] = ['title' => $v['tag'] . ' ' . $v['title'], 'value' => $k];
}
$title = $re['title'] . '_私域直播抽奖';
$data = ['winNumAry' => $winNumAry, 'winTypeAry' => $winTypeAry, 'activityId' => $activityId, 'title' => $title];
$this->show_json(200, '抽奖码验证成功', $data);
} else {
$this->show_json(400, '抽奖码验证失败');
}
$title = '私域直播抽奖';
$re = $this->mdSyliveActivity->get(['activityId' => $this->activityId], 'title');
$re['title'] && $title = $re['title'] . '_' . $title;
$data['info'] = ['winNumAry' => $winNumAry, 'winTypeAry' => $winTypeAry];
$data['title'] = $title;
$this->load->view('/h5/market/draw/index', $data);
}
/**
@@ -50,10 +67,11 @@ class Draw extends CI_Controller
public function post_win_num()
{
$params = $this->input->post();
$activityId = intval($params['activityId']);
$winType = intval($params['winType']);
$winNumCount = 0;
if ($winType) {
$winNumCount = $this->mdSyliveOrder->count(['activityId' => $this->activityId, 'win' => 1, 'status' => 1, 'winType' => $winType]);
$winNumCount = $this->mdSyliveOrder->count(['activityId' => $activityId, 'win' => 1, 'status' => 1, 'winType' => $winType]);
}
$data['winMsgTip'] = $winNumCount;
$this->show_json(200, '操作成功', $data);
@@ -69,17 +87,18 @@ class Draw extends CI_Controller
$params = $this->input->post();
$winNum = intval($params['winNum']);
$winType = intval($params['winType']);
$activityId = intval($params['activityId']);
if (!$winType) {
$this->show_json(400, '请选择抽奖类型');
}
if (!$winNum) {
$this->show_json(400, '请选择中奖人数');
}
$winTypeAry = $this->mdSyliveOrder->winTypeAry($this->activityId);
$winTypeAry = $this->mdSyliveOrder->winTypeAry($activityId);
$price = $winTypeAry[$winType]['price'];
$limit = $winNum >= 50 ? 100 : 30;
//随机数据
$sql = "SELECT id,userId,mobile,uname,totalPrice FROM lc_market_sylive_order WHERE activityId={$this->activityId}
$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 = [];
@@ -97,7 +116,7 @@ class Draw extends CI_Controller
}
}
$data['list'] = $list;
//$winNumCount = $this->mdSyliveOrder->count(['activityId' => $this->activityId, 'win' => 1, 'status' => 1, 'winType' => $winType]);
//$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) {
@@ -121,11 +140,12 @@ class Draw extends CI_Controller
$params = $this->input->post();
$result = $params['result'];
$winType = $params['type'];
$activityId = intval($params['activityId']);
if (!$result || !$winType) {
$this->show_json(400, '参数错误');
}
$resultSet = [];
$winTypeAry = $this->mdSyliveOrder->winTypeAry($this->activityId, $winType);
$winTypeAry = $this->mdSyliveOrder->winTypeAry($activityId, $winType);
$winTime = date('Y-m-d H:i:s');
$smsTime = date('Y-m-d H:i');
$showMobile = '';
@@ -147,7 +167,7 @@ class Draw extends CI_Controller
}
}
$msg = $showMobile ? $showMobile : "成功抽中{$winNum}";
$winNumCount = $this->mdSyliveOrder->count(['activityId' => $this->activityId, 'win' => 1, 'status' => 1, 'winType' => $winType]);
$winNumCount = $this->mdSyliveOrder->count(['activityId' => $activityId, 'win' => 1, 'status' => 1, 'winType' => $winType]);
$data['result'] = $resultSet;
$data['winMsgTip'] = $winNumCount;
$this->show_json(200, $msg ? $msg : '成功抽奖', $data);
+2 -2
View File
@@ -275,8 +275,8 @@ class Tstic extends Admin{
];
$ty_order_lists = $this->sylive_data_entity->top_team_user_lists($a_id,'order',[], 1, 10,$this->uid);
$ty_order = [
'title' => '团员<span class="color-00a2ff">观看</span>排行',
'url' => "/h5/market/sylive/tstic/rank?type=watch&skey={$skey}&gtype=ty",
'title' => '团员<span class="color-00a2ff">订单</span>排行',
'url' => "/h5/market/sylive/tstic/rank?type=order&skey={$skey}&gtype=ty",
'list' => $ty_order_lists['lists']
];
$data = [
+59 -15
View File
@@ -5,22 +5,25 @@
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title><?= $title ?></title>
<link rel="stylesheet" href="/css/h5/market/draw/pc.css?11091">
<title>私域直播抽奖</title>
<link rel="stylesheet" href="/css/h5/market/draw/pc.css?20221110">
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/jquery.3.4.1.min.js"></script>
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/vue.2.6.10.min.js"></script>
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/mDialog.js"></script>
</head>
<body class="bg-fff">
<div class="bg-fff" id="app" ref="app">
<div class="container">
<div class="absolute box-center mt50 box-1280-720 bg-no-repeat bg-size-fullwidth bg-pos-top"
style="background-image:url('https://qs.haodian.cn/web/images/project/H5-ShiYu-draw/bg.jpg?v=1109')">
<div class="absolute box-center pt10 font-50 text-bold color-fff text-italic ">
style="background-image:url('https://qs.haodian.cn/web/images/project/H5-ShiYu-draw/bg.png?v=20221110')">
<div class="absolute box-center pt3 font-50 text-bold color-fff text-italic">
{{topTitle}}
</div>
<div class="maincontent ulib-r20 overflowhidden">
<div class="box-1200-585 relative overflowhidden">
<div class="absolute box-center-middle" v-if="draw.prizeUrl"><img :src="draw.prizeUrl" style="width:630px;height:340px;" alt="#" /></div>
<div class="absolute box-center-middle" v-if="draw.prizeUrl">
<img :src="draw.prizeUrl" style="width:630px;height:340px;" alt="#"/>
</div>
<div class="fn-flex fn-flex-wrap roll-50-1" v-if="winNum==50">
<div class="wp20 relative" style="height:56px;" v-if="index<winNum"
v-for="(item,index) in list">
@@ -98,6 +101,23 @@
</div>
</div>
<div class="msg fn-hide" :style="isShowLogin?'display:block':'display:none'" v-if="isShowLogin">
<div class="msgBg"></div>
<div class="msgMain">
<div class="content">
<div class="word text-center">
<div class="relative bg-f6 ulib-r10">
<input class="wp100 inner10 font-28 bg-f6 bds-1-ccc ulib-r10" type="text" v-model="drawCode"
placeholder="请输入抽奖码"/>
</div>
</div>
<div class="mt30">
<a class="block pt10 pb10 bg-1a1a1a text-center font-20 color-fff ulib-r10" href="javascript:;"
@click="checkCode">确认</a>
</div>
</div>
</div>
</div>
</div>
<script>
@@ -105,11 +125,13 @@
var app = new Vue({
el: '#app',
data: {
title: '私域直播抽奖',
submitFlag: false,
topTitle: '',
winNum: '0',
winType: 6,
winMsgTip: 0,
activityId: 0,
info: {
winNumAry: [],
winTypeAry: [],
@@ -124,23 +146,45 @@
timer: null,
isStartAc: false,
isOpen: false,
isShowLogin: true,
drawCode: '',
msgTip: ''
},
mounted() {
this.getInfo();
this.getWinNum();
},
beforeDestroy() {
this.list = [];
clearTimeout(this.timer);
},
methods: {
//基础信息
getInfo() {
this.info = {
winNumAry: <?=json_encode($info['winNumAry'], JSON_UNESCAPED_UNICODE)?>,
winTypeAry: <?=json_encode($info['winTypeAry'], JSON_UNESCAPED_UNICODE)?>,
checkCode() {
let that = this;
if (that.isSubmiting) return;
if (!this.drawCode) {
mDialog.msg({duration: 250, pause: 2000, content: '请输入抽奖码'});
return;
}
$.ajax({
url: '/h5/market/draw/post_code',
type: 'post',
dataType: 'json',
data: {drawCode: that.drawCode},
beforeSend: function () {
that.submitFlag = true;
},
success: function (re) {
mDialog.msg({duration: 250, pause: 2000, content: re.msg});
if (re.code == 200) {
$('title').text(re.data.title);
that.isShowLogin = false;
that.activityId = re.data.activityId;
that.info = {winNumAry: re.data.winNumAry, winTypeAry: re.data.winTypeAry};
}
},
complete: function () {
that.submitFlag = false;
}
});
},
//更新信息
getDraw() {
@@ -155,7 +199,7 @@
url: '/h5/market/draw/post_info',
type: 'post',
dataType: 'json',
data: {winNum: that.winNum, winType: that.winType},
data: {winNum: that.winNum, winType: that.winType, activityId: that.activityId},
beforeSend: function () {
that.submitFlag = true;
},
@@ -200,7 +244,7 @@
url: '/h5/market/draw/post_win_num',
type: 'post',
dataType: 'json',
data: {winType: this.winType},
data: {winType: that.winType, activityId: that.activityId},
beforeSend: function () {
that.submitFlag = true;
},
@@ -258,7 +302,7 @@
url: '/h5/market/draw/post_win',
type: 'post',
dataType: 'json',
data: {result: that.draw.result, type: that.draw.type},
data: {result: that.draw.result, type: that.draw.type, activityId: that.activityId},
beforeSend: function () {
that.submitFlag = true;
},
+19 -3
View File
@@ -134,7 +134,7 @@ class Activity extends BaseController
$url = http_host_com('home') . "/h5/market/sylive?skey=" . $skey;//活动连接
$list[] = [
'activityId' => $activityId, 'title' => $v['title'], 'channelId' => $v['channelId'], 'bizIds' => $bizIds, 'teamIds' => $teamIds, 'pay' => $pay,
'introduction' => $v['introduction'], 'shareTitle' => $shareTitle, 'dateRange' => $dateRange, 'coupon' => $coupon,
'introduction' => $v['introduction'], 'shareTitle' => $shareTitle, 'dateRange' => $dateRange, 'coupon' => $coupon, 'drawCode' => $v['drawCode'],
'bgImg' => $bgImg, 'channelImg' => $channelImg, 'sharePhoto' => $sharePhoto, 'shareImg' => $shareImg, 'item' => $item, 'url' => $url,
's_time' => $v['timeStart'], 'e_time' => $v['timeEnd'], 'status' => $status, 'createTime' => $v['createTime']];
}
@@ -162,6 +162,7 @@ class Activity extends BaseController
$bizIds = $this->input_param('bizIds');
$teamIds = $this->input_param('teamIds');
$pay = $this->input_param('pay');
$drawCode = $this->input_param('drawCode');
if (!$title) {
$this->return_json('请输入活动标题');
}
@@ -174,6 +175,12 @@ class Activity extends BaseController
if (!$dateRange) {
$this->return_json('请选择直播时间');
}
if ($drawCode) {
$re = $this->mdSyliveActivity->get(['drawCode' => $drawCode, 'status' => 0], 'drawCode');
if ($re['drawCode']) {
$this->return_json('抽奖码已存在');
}
}
// if (!$introduction) {
// $this->return_json('请输入活动简介');
// }
@@ -196,7 +203,7 @@ class Activity extends BaseController
$jsondata['pay'] = $pay;
$jsondata = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
$addDate = ['title' => $title, 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'channelId' => $channelId, 'jsondata' => $jsondata
, 'introduction' => $introduction, 'shareTitle' => $shareTitle, 'sharePhoto' => $sharePhoto, 'shareImg' => $setShareImg
, 'introduction' => $introduction, 'shareTitle' => $shareTitle, 'sharePhoto' => $sharePhoto, 'shareImg' => $setShareImg, 'drawCode' => $drawCode
, 'timeStart' => $dateRange[0], 'timeEnd' => $dateRange[1], 'status' => 1, 'createTime' => date('Y-m-d H:i:s')];
$activityId = $this->mdSyliveActivity->add($addDate);
if (!$activityId) {
@@ -287,6 +294,7 @@ class Activity extends BaseController
$bizIds = $this->input_param('bizIds');
$teamIds = $this->input_param('teamIds');
$pay = $this->input_param('pay');
$drawCode = $this->input_param('drawCode');
if (!$activityId) {
$this->return_json('参数错误');
}
@@ -306,6 +314,14 @@ class Activity extends BaseController
if (!$re) {
$this->return_json('活动不存在');
}
if ($drawCode) {
if ($drawCode != $re['drawCode']) {
$re = $this->mdSyliveActivity->get(['drawCode' => $drawCode, 'status' => 0], 'drawCode');
if ($re['drawCode']) {
$this->return_json('抽奖码已存在');
}
}
}
$organizationIds = $add_biz = $add_team = [];
if ($bizIds) {
$bizIds = implode(',', $bizIds);
@@ -381,7 +397,7 @@ class Activity extends BaseController
$jsondata = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
$organizationIds = $organizationIds ? ',' . implode(',', $organizationIds) . ',' : '';
$upDate = ['title' => $title, 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'channelId' => $channelId, 'introduction' => $introduction,
'shareTitle' => $shareTitle, 'sharePhoto' => $sharePhoto, 'shareImg' => $setShareImg, 'jsondata' => $jsondata,
'shareTitle' => $shareTitle, 'sharePhoto' => $sharePhoto, 'shareImg' => $setShareImg, 'jsondata' => $jsondata, 'drawCode' => $drawCode,
'timeStart' => $dateRange[0], 'timeEnd' => $dateRange[1], 'organizationIds' => $organizationIds];
$this->mdSyliveActivity->update($upDate, ['activityId' => $activityId]);
$this->return_response();
File diff suppressed because one or more lines are too long