market_draw_1110

This commit is contained in:
dengbw
2022-11-10 16:58:46 +08:00
committed by lccsw
parent 64c7715fd2
commit b6c08345a2
8 changed files with 165 additions and 60 deletions
+13
View File
@@ -474,6 +474,19 @@ if (!function_exists('b2m_send_sms')) {
}
}
/**
* 北京亿美短信
*/
if (!function_exists('b2m_send_batch_sms')) {
function b2m_send_batch_sms($mobiles, $content)
{
require_once COMMPATH . '/third_party/b2m/sms.php';
$resobj = SendBatchSMS($mobiles, $content);
$resobj->ciphertext = "";
return $resobj ? $resobj->plaintext : false;
}
}
/*
* 随机码
*/
@@ -77,16 +77,18 @@ class Market_sylive_order_model extends HD_Model
public function winTypeAry($activityId = 0, $type = 0)
{
$winType = [];
if ($activityId == 1) {
$winType = [6 => ['title' => '150元京东卡', 'tag' => '六等奖', 'img' => '', 'num' => 300, 'price' => 0.99]
, 5 => ['title' => '200元京东卡', 'tag' => '五等奖', 'img' => '', 'num' => 200, 'price' => 0.99]
, 4 => ['title' => '300元京东卡', 'tag' => '等奖', 'img' => '', 'num' => 100, 'price' => 0.99]
, 3 => ['title' => '500元京东卡', 'tag' => '等奖', 'img' => '', 'num' => 50, 'price' => 0.99]
, 2 => ['title' => 'iphone14', 'tag' => '等奖', 'img' => '', 'num' => 5, 'price' => 199]
, 1 => ['title' => '半价购车权益', 'tag' => '等奖', 'img' => '', 'num' => 1, 'price' => 199]
, 7 => ['title' => '200元京东卡', 'tag' => '199独享', 'img' => '', 'num' => 5, 'price' => 199]
, 8 => ['title' => '500元京东卡', 'tag' => '199独享', 'img' => '', 'num' => 2, 'price' => 199]
, 9 => ['title' => '1000元京东卡', 'tag' => '199独享', 'img' => '', 'num' => 1, 'price' => 199]
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]
];
if ($type) {
$winType = $winType[$type];
+2 -2
View File
@@ -229,8 +229,8 @@ function SendBatchSMS($mobiles, $content,
$json_data = json_encode($item, JSON_UNESCAPED_UNICODE);
echo "[send json is] :" . END;
echo "" . $json_data . END;
// echo "[send json is] :" . END;
// echo "" . $json_data . END;
$encryptObj = new MagicCrypt();
$senddata = $encryptObj->encrypt($json_data);//加密结果
+56 -16
View File
@@ -8,13 +8,14 @@ defined('BASEPATH') OR exit('No direct script access allowed');
*/
class Draw extends CI_Controller
{
private $activityId = 1;
private $activityId = 4;
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sylive_order_model', 'mdSyliveOrder');
$this->load->model('market/Market_sylive_user_model', 'mdSyliveUser');
$this->load->model('market/Market_sylive_activity_model', 'mdSyliveActivity');
}
/**
@@ -33,11 +34,31 @@ class Draw extends CI_Controller
foreach ($winTypeAryGet as $k => $v) {
$winTypeAry[] = ['title' => $v['tag'] . ' ' . $v['title'], 'value' => $k];
}
$title = '私域直播抽奖';
$re = $this->mdSyliveActivity->get(['activityId' => $this->activityId], 'title');
$re['title'] && $title = $re['title'] . '_' . $title;
$data['info'] = ['winNumAry' => $winNumAry, 'winTypeAry' => $winTypeAry];
$data['title'] = '私域直播抽奖';
$data['title'] = $title;
$this->load->view('/h5/market/draw/index', $data);
}
/**
* Notes:中奖人数
* Created on: 2022/11/10 11:50
* Created by: dengbw
*/
public function post_win_num()
{
$params = $this->input->post();
$winType = intval($params['winType']);
$winNumCount = 0;
if ($winType) {
$winNumCount = $this->mdSyliveOrder->count(['activityId' => $this->activityId, 'win' => 1, 'status' => 1, 'winType' => $winType]);
}
$data['winMsgTip'] = $winNumCount;
$this->show_json(200, '操作成功', $data);
}
/**
* Notes:获取抽奖人
* Created on: 2022/11/9 17:21
@@ -56,22 +77,25 @@ class Draw extends CI_Controller
}
$winTypeAry = $this->mdSyliveOrder->winTypeAry($this->activityId);
$price = $winTypeAry[$winType]['price'];
$limit = $winNum >= 50 ? 100 : 50;
$where = ['activityId' => $this->activityId, 'win' => 0, 'status' => 1, 'totalPrice>=' => $price];
$res = $this->mdSyliveOrder->select($where, 'payTime desc,id asc', 1, $limit, 'id,userId,mobile,uname');
$limit = $winNum >= 50 ? 100 : 30;
//随机数据
$sql = "SELECT id,userId,mobile,uname,totalPrice FROM lc_market_sylive_order WHERE activityId={$this->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';
$name = $v['uname'] ? $v['uname'] : '***';
$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[] = ['id' => intval($v['id']), 'name' => $name, 'tel' => $v['mobile'], 'headimg' => $headimg];
$list[] = ['headimg' => $headimg, 'name' => $name, 'tel' => $tel, 'id' => intval($v['id']),
'uname' => $v['uname'], 'mobile' => $v['mobile']];
}
}
shuffle($list);//随机数组
$data['list'] = $list;
//$winNumCount = $this->mdSyliveOrder->count(['activityId' => $this->activityId, 'win' => 1, 'status' => 1, 'winType' => $winType]);
//$num = $winTypeAry[$winType]['num'];
@@ -80,9 +104,11 @@ class Draw extends CI_Controller
shuffle($list);
$result = array_slice($list, 0, $winNum);
}
$msg = "在【" . date('Y-m-d H:i:s') . "】获取到信息";
$data['result'] = $result;
$data['type'] = $winType;
$this->show_json(200, '更新信息成功', $data);
$data['prizeUrl'] = $winTypeAry[$winType]['img'];
$this->show_json(200, $msg, $data);
}
/**
@@ -99,18 +125,32 @@ class Draw extends CI_Controller
$this->show_json(400, '参数错误');
}
$resultSet = [];
$winTypeAry = $this->mdSyliveOrder->winTypeAry($this->activityId, $winType);
$winTime = date('Y-m-d H:i:s');
$smsTime = date('Y-m-d H:i');
$showMobile = '';
$winNum = 0;
foreach ($result as $v) {
$ret = $this->mdSyliveOrder->update(['win' => 1, 'winType' => $winType], ["id" => $v['id']]);
$ret = $this->mdSyliveOrder->update(['win' => 1, 'winType' => $winType, 'winTime' => $winTime], ["id" => $v['id']]);
if ($ret) {
$resultSet = $v;
$winNum++;
$resultSet[] = $v;
//中奖发短信
if ($winType == 1 || $winType == 2) {//一等奖、二等奖不发短信
$showMobile = $showMobile ? $showMobile . "{$v['uname']}({$v['mobile']})" : "{$v['uname']}({$v['mobile']})";
} else if ($v['mobile']) {
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}";
$winNumCount = $this->mdSyliveOrder->count(['activityId' => $this->activityId, 'win' => 1, 'status' => 1, 'winType' => $winType]);
$winTypeAry = $this->mdSyliveOrder->winTypeAry($this->activityId, $winType);
$winMsgTip = "已中奖{$winNumCount}人({$winTypeAry['tag']} {$winTypeAry['title']})";
$data['result'] = $resultSet;
$data['winMsgTip'] = $winMsgTip;
$this->show_json(200, '中奖成功', $data);
$data['winMsgTip'] = $winNumCount;
$this->show_json(200, $msg ? $msg : '成功抽奖', $data);
}
private function show_json($code, $msg, $info = [])
@@ -121,4 +161,4 @@ class Draw extends CI_Controller
die(json_encode($data, JSON_UNESCAPED_UNICODE));
}
}
}
+56 -21
View File
@@ -20,6 +20,7 @@
</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="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">
@@ -71,6 +72,7 @@
@change="changeTitle">
<option :value="item.value" v-for="(item,index) in info.winTypeAry">{{item.title}}</option>
</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>
<select class="text-middle mr10 select-more pl20 pr20 ulib-r5 font-18" style="height:50px;"
@@ -80,12 +82,12 @@
<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>
<a class="text-middle inline-block bg-1282f4 ml10 mr10 pt10 pb10 pl20 pr20 text-center font-18 color-fff ulib-r5"
v-if="list.length>0&&draw.list.length>0" href="javascript:;" @click="start">开始抽奖</a>
v-if="draw.list.length>0" href="javascript:;" @click="start">开始抽奖</a>
</span>
<a v-else
class="text-middle inline-block bg-1282f4 ml10 mr10 pt10 pb10 pl20 pr20 text-center font-18 color-fff ulib-r5"
href="javascript:;" @click="result">立即开奖</a>
<div class=" absolute left-0 right-0 top-0 pt10 font-14 color-eb5359 ">{{msgTip}} {{winMsgTip}}</div>
<div class="absolute left-0 right-0 top-0 pt10 font-14 color-eb5359 text-bold">{{msgTip}}</div>
</div>
<!--隐藏加载数据-->
@@ -107,6 +109,7 @@
topTitle: '',
winNum: '0',
winType: 6,
winMsgTip: 0,
info: {
winNumAry: [],
winTypeAry: [],
@@ -115,16 +118,17 @@
list: [],
result: [],
type: 0,
prizeUrl: ''
},
list: [],
timer: null,
isStartAc: false,
isOpen: false,
msgTip: '',
winMsgTip: '',
msgTip: ''
},
mounted() {
this.getInfo()
this.getInfo();
this.getWinNum();
},
beforeDestroy() {
this.list = [];
@@ -144,9 +148,8 @@
if (that.isSubmiting) return;
clearTimeout(that.timer);
that.msgTip = "";
that.winMsgTip = "";
if (!that.isOpen && that.winNum > 0) {
that.draw = {list: [], result: [], type: 0};
that.draw = {list: [], result: [], type: 0, prizeUrl: ''};
that.list = [];
$.ajax({
url: '/h5/market/draw/post_info',
@@ -163,13 +166,19 @@
} 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};
let arr = that.draw.list.slice(0);
arr.sort(function () {
return Math.random() - 0.5;
});
that.list = arr;
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;
@@ -183,25 +192,50 @@
that.msgTip = "请选择中奖人数"
}
},
//中奖人数
getWinNum() {
let that = this;
if (that.isSubmiting) return;
$.ajax({
url: '/h5/market/draw/post_win_num',
type: 'post',
dataType: 'json',
data: {winType: this.winType},
beforeSend: function () {
that.submitFlag = true;
},
success: function (re) {
if (re.code == 200) {
that.winMsgTip = re.data.winMsgTip;
}
},
complete: function () {
that.submitFlag = false;
}
});
},
//选择中奖个数
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 = "";
this.winMsgTip = "";
}
},
//选择类型
//选择中奖类型
changeTitle(e) {
if (this.winType != e.target.value) {
this.winType = e.target.value;
this.getWinNum();
}
},
//开始抽奖
start() {
this.isStartAc = true
this.msgTip = '';
this.draw.prizeUrl = '';
this.isStartAc = true;
this.timer = setInterval(res1 => {
//随机排序
let arr = this.draw.list.slice(0)
@@ -215,6 +249,10 @@
result() {
let that = this;
if (that.isSubmiting) return;
clearTimeout(that.timer);
that.list = that.draw.result;
that.isStartAc = false;
that.isOpen = true;
//提交中奖数据
$.ajax({
url: '/h5/market/draw/post_win',
@@ -226,13 +264,10 @@
},
success: function (re) {
if (re.code == 200) {
that.msgTip = '';
that.msgTip = re.msg;
that.winMsgTip = re.data.winMsgTip;
clearTimeout(that.timer);
that.list = re.data.result;
that.isStartAc = false;
that.isOpen = true;
that.draw = {list: [], result: [], type: 0};
that.draw = {list: [], result: [], type: 0, prizeUrl: ''};
} else {
that.msgTip = re.msg;
}
@@ -264,7 +264,6 @@ class Activity extends BaseController
if (!$re) {
$this->return_json('活动不存在');
}
$this->return_response($re);
}
+11 -8
View File
@@ -32,7 +32,7 @@ class Goods extends BaseController
$type = $this->input_param('type');
!$page && $page = 1;
!$limit && $limit = 10;
$sort_order = 'itemId desc';
$sort_order = 'sort asc,itemId desc';
if ($sort && $order) {
if ($sort == 'typeName') {
$sort_order = 'type ' . $order;
@@ -104,15 +104,14 @@ class Goods extends BaseController
$addDate['timeEnd'] = $dateRange[1] ? $dateRange[1] : '0000-00-00 00:00:00';
$addDate['useStart'] = $useRange[0] ? $useRange[0] : '0000-00-00 00:00:00';
$addDate['useEnd'] = $useRange[1] ? $useRange[1] : '0000-00-00 00:00:00';
$imgs = [];
$imgs_banner = [];
if ($banner) {
$imgs_banner = [];
foreach ($banner as $v) {
$imgs_banner[] = $v['fileUrl'];
}
$imgs_banner && $imgs['banner'] = $imgs_banner;
}
$imgs && $upDate['imgs'] = json_encode($imgs, JSON_UNESCAPED_UNICODE);
$imgs['banner'] = $imgs_banner ? $imgs_banner : '';
$addDate['imgs'] = json_encode($imgs, JSON_UNESCAPED_UNICODE);
$id = $this->mdSyliveItems->add($addDate);
if (!$id) {
$this->return_json('添加商品失败');
@@ -143,20 +142,24 @@ class Goods extends BaseController
if (!$title) {
$this->return_json('请输入商品标题');
}
$re = $this->mdSyliveItems->get(['itemId' => $itemId]);
if (!$re) {
$this->return_json('商品不存在');
}
$upDate = ['title' => $title, 'price' => $price, 'stock' => $stock, 'sort' => $sort
, 'descrip' => $descrip, 'type' => $type];
$upDate['timeStart'] = $dateRange[0] ? $dateRange[0] : '0000-00-00 00:00:00';
$upDate['timeEnd'] = $dateRange[1] ? $dateRange[1] : '0000-00-00 00:00:00';
$upDate['useStart'] = $useRange[0] ? $useRange[0] : '0000-00-00 00:00:00';
$upDate['useEnd'] = $useRange[1] ? $useRange[1] : '0000-00-00 00:00:00';
$imgs = [];
$imgs = $re['imgs'] ? json_decode($re['imgs'], true) : [];
$imgs_banner = [];
if ($banner) {
$imgs_banner = [];
foreach ($banner as $v) {
$imgs_banner[] = $v['fileUrl'];
}
$imgs_banner && $imgs['banner'] = $imgs_banner;
}
$imgs['banner'] = $imgs_banner ? $imgs_banner : '';
$imgs && $upDate['imgs'] = json_encode($imgs, JSON_UNESCAPED_UNICODE);
$this->mdSyliveItems->update($upDate, ['itemId' => $itemId]);
$this->return_response();
+15 -2
View File
@@ -103,7 +103,7 @@ class Order extends BaseController
}
}
if ($limit == 10000) {
$count = 1;
$count = $limit;
} else {
$count = $this->mdSyliveOrder->count($where);
}
@@ -112,13 +112,26 @@ class Order extends BaseController
foreach ($res as $v) {
$consultant = $this->consultantGet(['activityId' => $v['activityId'], 'userId' => $v['userId']
, 'areaId' => $v['areaId'], 'bizId' => $v['bizId'], 'cfrom' => $v['cfrom'], 'cfUserId' => $v['cfUserId']]);
$list[] = [
$item = [
'id' => $v['id'], 'sid' => $v['sid'], 'uname' => $v['uname'], 'mobile' => $v['mobile'], 'itemTitle' => $v['itemTitle']
, 'totalPrice' => $v['totalPrice'], 'payTime' => $v['payTime'] != '0000-00-00 00:00:00' ? $v['payTime'] : ''
, 'typeName' => $this->mdSyliveOrder->typeAry($v['type'])
, 'statusName' => $this->mdSyliveOrder->statusAry($v['status']), 'cfromName' => $this->mdSyliveOrder->cfromAry($v['cfrom'])
, 'createTime' => $v['createTime'], 'area' => $consultant['area'], 'stores' => $consultant['stores'], 'consultant' => $consultant['consultant']
];
if ($limit == 10000) {
$address = $biz = '';
$jsondata = $v['jsondata'] ? json_decode($v['jsondata'], true) : [];
if ($jsondata['address']) {
$address = $jsondata['address']['region'] . $jsondata['address']['detail'];
}
if ($jsondata['biz']) {
$biz = $jsondata['biz'];
}
$item['address'] = $address;
$item['biz'] = $biz;
}
$list[] = $item;
}
}
if ($limit == 10000) {