market_groups_1215

This commit is contained in:
dengbw
2022-12-15 09:52:38 +08:00
committed by lccsw
parent 33a5c20c27
commit ee2a0e5d18
6 changed files with 270 additions and 277 deletions
@@ -80,22 +80,32 @@ class Market_sylive_order_model extends HD_Model
$img = 'https://qs.haodian.cn/web/images/project/H5-ShiYu-draw';
if ($activityId == 4) {//纳米BOX双11纳享嗨购日
$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]
, 6 => ['title' => '150元京东卡', 'tag' => '六等奖', 'merge' => 1, 'img' => $img . '/prize-jd-150.png', 'price' => 0.99]
, 5 => ['title' => '200元京东卡', 'tag' => '五等奖', 'merge' => 1, 'img' => $img . '/prize-jd-200.png', 'price' => 0.99]
, 4 => ['title' => '300元京东卡', 'tag' => '四等奖', 'merge' => 1, 'img' => $img . '/prize-jd-300.png', 'price' => 0.99]
, 3 => ['title' => '500元京东卡', 'tag' => '三等奖', 'merge' => 1, 'img' => $img . '/prize-jd-500.png', 'price' => 0.99]
, 2 => ['title' => 'iphone14', 'tag' => '二等奖', 'merge' => 1, 'img' => $img . '/prize-iPhone14.png', 'price' => 199]
, 1 => ['title' => '半价购车权益', 'tag' => '一等奖', 'merge' => 1, 'img' => $img . '/prize-banjia.png', 'price' => 199]
, 7 => ['title' => '200元京东卡', 'tag' => '199独享', 'merge' => 1, 'img' => $img . '/prize-jd-200.png', 'price' => 199]
, 8 => ['title' => '500元京东卡', 'tag' => '199独享', 'merge' => 1, 'img' => $img . '/prize-jd-500.png', 'price' => 199]
, 9 => ['title' => '1000元京东卡', 'tag' => '199独享', 'merge' => 1, 'img' => $img . '/prize-jd-1000.png', 'price' => 199]
];
} else if ($activityId == 5) {//哪吒汽车宁德时代员工私享内购会
$winType = [0 => ['title' => '请选择抽奖类型']
, 1 => ['title' => '哪吒V车模', 'tag' => '车模', 'img' => $img . '/nz-prize-chemo.png', 'price' => 0.99]
, 2 => ['title' => '车载吸尘器', 'tag' => '吸尘器', 'img' => $img . '/nz-prize-xihenqi.png', 'price' => 0.99]
, 3 => ['title' => '免费保养券', 'tag' => '保养券', 'img' => $img . '/nz-prize-baoyangquan.png', 'price' => 0.99]
, 4 => ['title' => '65寸液晶电视', 'tag' => '电视机', 'img' => $img . '/nz-prize-dianshi.png', 'price' => 99]
, 1 => ['title' => '哪吒V车模', 'tag' => '车模', 'merge' => 0, 'img' => $img . '/nz-prize-chemo.png', 'price' => 0.99]
, 2 => ['title' => '车载吸尘器', 'tag' => '吸尘器', 'merge' => 0, 'img' => $img . '/nz-prize-xihenqi.png', 'price' => 0.99]
, 3 => ['title' => '免费保养券', 'tag' => '保养券', 'merge' => 0, 'img' => $img . '/nz-prize-baoyangquan.png', 'price' => 0.99]
, 4 => ['title' => '65寸液晶电视', 'tag' => '电视机', 'merge' => 0, 'img' => $img . '/nz-prize-dianshi.png', 'price' => 99]
];
} else if ($activityId == 6) {//万券齐发,国补保价——纳米BOX年终抢购会 ​
$winType = [0 => ['title' => '请选择抽奖类型']
, 1 => ['title' => '体脂称', 'tag' => '体脂称', 'merge' => 0, 'img' => $img . '/221214-prize-1.png', 'price' => 9.90]
, 2 => ['title' => '车载空气净化器', 'tag' => '净化器', 'merge' => 0, 'img' => $img . '/221214-prize-6.png', 'price' => 9.90]
, 3 => ['title' => '电烤箱', 'tag' => '电烤箱', 'merge' => 0, 'img' => $img . '/221214-prize-3.png', 'price' => 0.99]
, 4 => ['title' => '车载冰箱', 'tag' => '冰箱', 'merge' => 0, 'img' => $img . '/221214-prize-5.png', 'price' => 9.90]
, 5 => ['title' => '微波炉', 'tag' => '微波炉', 'merge' => 0, 'img' => $img . '/221214-prize-2.png', 'price' => 9.90]
, 6 => ['title' => '吸尘器', 'tag' => '吸尘器', 'merge' => 0, 'img' => $img . '/221214-prize-4.png', 'price' => 9.90]
, 7 => ['title' => '万元购车券', 'tag' => '购车券', 'merge' => 0, 'img' => $img . '/221214-prize-7.png', 'price' => 9.90]
];
}
if ($type) {
@@ -105,21 +115,33 @@ class Market_sylive_order_model extends HD_Model
}
/**
* Notes:中奖人数
* Created on: 2022/11/24 15:46
* Notes:抽奖配置
* Created on: 2022/12/14 9:55
* Created by: dengbw
* @param int $activityId
* @return array
* @param string $type
* @return array|mixed
*/
public function winNumAry($activityId = 0)
public function drawConfig($activityId = 0, $type = '')
{
$winNumAry = [];
if ($activityId == 4 ||$activityId == 5 ) {//纳米BOX双11纳享嗨购日
$winNumAry = [];//中奖人数
$bgImg = '';//抽奖背景图
if ($activityId == 4) {
$winNumAry = [['title' => '请选择中奖人数', 'value' => 0],
['title' => '1人', 'value' => 1], ['title' => '2人', 'value' => 2],
['title' => '5人', 'value' => 5], ['title' => '50人', 'value' => 50]];
$bgImg = 'https://qs.haodian.cn/web/images/project/H5-ShiYu-draw/bg.png?v=20221110';
} else if ($activityId == 6) {
$winNumAry = [['title' => '请选择中奖人数', 'value' => 0],
['title' => '1人', 'value' => 1], ['title' => '20人', 'value' => 20],
['title' => '50人', 'value' => 50]];
$bgImg = 'https://qs.haodian.cn/web/images/project/H5-ShiYu-draw/bg-20221213.png?v=20221214';
}
return $winNumAry;
$data = ['winNumAry' => $winNumAry, 'bgImg' => $bgImg];
if ($type) {
$data = $data[$type];
}
return $data;
}
}
+43 -28
View File
@@ -44,18 +44,18 @@ class Draw extends CI_Controller
$re = $this->mdSyliveActivity->get(['drawCode' => $drawCode, 'status' => 0], 'title,activityId');
if ($re['activityId']) {
$activityId = intval($re['activityId']);
$winNumAry = $this->mdSyliveOrder->winNumAry($activityId);//中奖人数
$drawConfig = $this->mdSyliveOrder->drawConfig($activityId);
$winNumAry = $drawConfig['winNumAry'];//中奖人数
$winTypeAry = [];//抽奖类型
$winTypeAryGet = $this->mdSyliveOrder->winTypeAry($activityId);
foreach ($winTypeAryGet as $k => $v) {
if ($k == 1 || $k == 2) {//监时加上
} else {
$title = $v['tag'] ? $v['tag'] . ' ' . $v['title'] : $v['title'];
$winTypeAry[] = ['title' => $title, 'value' => $k];
}
$title = $v['merge'] ? $v['tag'] . ' ' . $v['title'] : $v['title'];
$winTypeAry[] = ['title' => $title, 'value' => $k];
}
$title = $re['title'] . '_私域直播抽奖';
$data = ['winNumAry' => $winNumAry, 'winTypeAry' => $winTypeAry, 'activityId' => $activityId, 'title' => $title];
$bgImg = "background-image:url('{$drawConfig['bgImg']}')";
$data = ['winNumAry' => $winNumAry, 'winTypeAry' => $winTypeAry, 'activityId' => $activityId,
'bgImg' => $bgImg, 'title' => $title];
$this->show_json(200, '抽奖码验证成功', $data);
} else {
$this->show_json(400, '抽奖码验证失败');
@@ -106,7 +106,7 @@ class Draw extends CI_Controller
}
$winTypeAry = $this->mdSyliveOrder->winTypeAry($activityId);
$price = $winTypeAry[$winType]['price'];
$limit = $winNum >= 50 ? 100 : 50;
$limit = $winNum >= 50 ? 120 : 60;
$time = "在【" . date('Y-m-d H:i:s') . "";
$count = $this->mdSyliveOrder->count(['activityId' => $activityId, 'win' => 0, 'status' => 1, 'totalPrice>=' => $price]);
$list = $result = [];
@@ -115,20 +115,24 @@ class Draw extends CI_Controller
$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'];
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 = 'https://qs.haodian.cn/web/images/project/H5-ShiYu/default-head.png';
}
$list[] = ['headimg' => $headimg, 'name' => $name, 'tel' => $tel, 'id' => intval($v['id']),
'uname' => $v['uname'], 'mobile' => $v['mobile']];
}
$list[] = ['headimg' => $headimg, 'name' => $name, 'tel' => $tel, 'id' => intval($v['id']),
'uname' => $v['uname'], 'mobile' => $v['mobile']];
}
$count = count($list);
}
$count = count($list);
}
if (!$count) {
$this->show_json(400, "{$time}暂无获取到抽奖名单,不能开始抽奖");
@@ -158,15 +162,18 @@ class Draw extends CI_Controller
$result = $params['result'];
$winType = $params['type'];
$activityId = intval($params['activityId']);
if (!$result || !$winType) {
if (!$result || !$winType || !$activityId) {
$this->show_json(400, '参数错误');
}
$re = $this->mdSyliveActivity->get(['activityId' => $activityId]);
if (!$re) {
$this->show_json(400, '暂无活动');
}
$resultSet = [];
$winTypeAry = $this->mdSyliveOrder->winTypeAry($activityId, $winType);
$winTime = date('Y-m-d H:i:s');
$smsTime = date('Y-m-d H:i');
$showMobile = '';
$winNum = 0;
$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']]);
@@ -174,21 +181,29 @@ class Draw extends CI_Controller
$winNum++;
$resultSet[] = $v;
//中奖发短信
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,即可领取礼品哦!";
if ($v['mobile'] && $dev == 0) {//dev==1不发短信通知
if ($winTime >= $re['timeStart']) {//直播开始时发短信
$content = "【好店云】感谢您参与东风EV新能源纳米BOX年终抢购会,恭喜您成功锁定({$winTypeAry['title']})礼品一份,只需您在12月31日前在当地门店选购东风EV新能源纳米BOX并完成上牌,即可领取礼品哦!";
b2m_send_sms($v['mobile'], $content);
$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}";
$winNumCount = $this->mdSyliveOrder->count(['activityId' => $activityId, 'win' => 1, 'status' => 1, 'winType' => $winType]);
$data['dev'] = $dev;
$data['result'] = $resultSet;
$data['winMsgTip'] = $winNumCount;
$data['dev'] = $dev;
$data['sms'] = $sms;
$this->show_json(200, $msg ? $msg : '成功抽奖', $data);
}
+38 -24
View File
@@ -6,7 +6,7 @@
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>
<link rel="stylesheet" href="/css/h5/market/draw/pc.css?20221110">
<link rel="stylesheet" href="/css/h5/market/draw/pc.css?20221214">
<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>
@@ -14,8 +14,7 @@
<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.png?v=20221110')">
<div class="absolute box-center mt50 box-1280-720 bg-no-repeat bg-size-fullwidth bg-pos-top" :style="bgImg">
<div class="absolute box-center pt3 font-50 text-bold color-fff text-italic">
{{topTitle}}
</div>
@@ -24,18 +23,23 @@
<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"
<div class="absolute box-center-middle" style="width:500px;" v-if="winNum==1">
<div class="relative pb20 text-center" v-if="index<winNum" v-if="index<winNum"
v-for="(item,index) in list">
<img class="absolute box-middle left-0 ml50 imgsize-30X30 ulib-r750" :src="item.headimg"
alt="#"/>
<div class="absolute box-middle left-0 right-0 pl90">
<div class="text-nowrap font-14">{{item.name}}</div>
<div class="font-12 color-666">{{item.tel}}</div>
</div>
<img class="imgsize-140X140 ulib-r750" :src="item.headimg" alt="#"/>
<div class="mt20 text-nowrap font-60">{{item.name}}</div>
<div class="mt10 font-40 color-666">{{item.tel}}</div>
</div>
</div>
<div class="absolute box-center-middle" style="width:1000px;" v-if="winNum==5">
<div class="absolute box-center-middle fn-flex" style="width:900px;" v-else-if="winNum==2">
<div class="relative fn-flex-item wp50 text-center overflowhidden" v-if="index<winNum"
v-for="(item,index) in list">
<img class="imgsize-140X140 ulib-r750" :src="item.headimg" alt="#"/>
<div class="mt20 text-nowrap font-50">{{item.name}}</div>
<div class="mt10 font-30 color-666">{{item.tel}}</div>
</div>
</div>
<div class="absolute box-center-middle" style="width:1000px;" v-else-if="winNum==5">
<div class="fn-flex text-center">
<div class="relative fn-flex-item wp33 text-center overflowhidden" v-if="index<3"
v-for="(item,index) in list">
@@ -53,20 +57,28 @@
</div>
</div>
</div>
<div class="absolute box-center-middle fn-flex" style="width:900px;" v-if="winNum==2">
<div class="relative fn-flex-item wp50 text-center overflowhidden" v-if="index<winNum"
v-for="(item,index) in list">
<img class="imgsize-140X140 ulib-r750" :src="item.headimg" alt="#"/>
<div class="mt20 text-nowrap font-50">{{item.name}}</div>
<div class="mt10 font-30 color-666">{{item.tel}}</div>
<div class="absolute box-center-middle" style="width:100%;" v-else-if="winNum==20">
<div class="fn-flex fn-flex-wrap">
<div class="wp25 relative" style="height:100px;" v-if="index<winNum"
v-for="(item,index) in list">
<img class="absolute box-middle left-0 ml50 imgsize-60X60 ulib-r750" :src="item.headimg"
alt="#"/>
<div class="absolute box-middle left-0 right-0 pl130">
<div class="text-nowrap font-18">{{item.name}}</div>
<div class="font-14 color-666">{{item.tel}}</div>
</div>
</div>
</div>
</div>
<div class="absolute box-center-middle" style="width:500px;" v-if="winNum==1">
<div class="relative pb20 text-center" v-if="index<winNum" v-if="index<winNum"
<div class="fn-flex fn-flex-wrap roll-50-1" v-else>
<div class="wp20 relative" style="height:56px;" v-if="index<winNum"
v-for="(item,index) in list">
<img class="imgsize-140X140 ulib-r750" :src="item.headimg" alt="#"/>
<div class="mt20 text-nowrap font-60">{{item.name}}</div>
<div class="mt10 font-40 color-666">{{item.tel}}</div>
<img class="absolute box-middle left-0 ml50 imgsize-30X30 ulib-r750" :src="item.headimg"
alt="#"/>
<div class="absolute box-middle left-0 right-0 pl90">
<div class="text-nowrap font-14">{{item.name}}</div>
<div class="font-12 color-666">{{item.tel}}</div>
</div>
</div>
</div>
</div>
@@ -86,7 +98,7 @@
<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"
v-if="draw.list.length>0" href="javascript:;" @click="start">开始抽奖</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"
href="javascript:;" @click="getDraw">{{draw.list.length>0 ? '更新' : '获取'}}抽奖名单</a>
</span>
@@ -135,6 +147,7 @@
el: '#app',
data: {
title: '私域直播抽奖',
bgImg: '',
submitFlag: false,
topTitle: '',
winNum: 0,
@@ -186,6 +199,7 @@
mDialog.msg({duration: 250, pause: 2000, content: re.msg});
if (re.code == 200) {
$('title').text(re.data.title);
that.bgImg = re.data.bgImg;
that.isShowLogin = false;
that.activityId = re.data.activityId;
that.info = {winNumAry: re.data.winNumAry, winTypeAry: re.data.winTypeAry};
+142 -203
View File
@@ -19,6 +19,7 @@ class Activity extends BaseController
$this->load->model('market/Market_sylive_team_model', 'mdSyliveTeam');
$this->load->model('market/Market_sylive_activity_team_model', 'mdSyliveActivityTeam');
$this->load->model('market/Market_sylive_groups_model', 'mdSyliveGroups');
$this->load->model('market/Market_sylive_groups_user_model', 'mdSyliveGroupsUser');
}
/**
@@ -55,7 +56,7 @@ class Activity extends BaseController
$this->load->library('MyEncryption');
$res = $this->mdSyliveActivity->select($where, $sort_order, $page, $limit);
foreach ($res as $v) {
$dateRange = [$v['timeStart'], $v['timeEnd']];
$dateRange = $v['timeStart'] != '0000-00-00 00:00:00' ? [$v['timeStart'], $v['timeEnd']] : '';
$status = intval($v['status']);
$activityId = intval($v['activityId']);
$bgImg = $channelImg = $banner = $sharePhoto = $shareImg = $shareTitle = $pay = $bottoms = [];
@@ -156,43 +157,6 @@ class Activity extends BaseController
$this->return_response_list($date);
}
/**
* Notes:活动详情
* Created on: 2022/9/29 10:37
* Created by: dengbw
* @param null $activityId
*/
public function index_get($activityId = null)
{
if (!$activityId) {
$this->return_json('参数错误');
}
$re = $this->mdSyliveActivity->get(['activityId' => $activityId], 'activityId,title');
if (!$re) {
$this->return_json('活动不存在');
}
$this->return_response($re);
}
/**
* Notes:复制活动
* Created on: 2022/12/8 10:08
* Created by: dengbw
* @param null $activityId
*/
public function copy_get($activityId = null)
{
if (!$activityId) {
$this->return_json('参数错误');
}
$re = $this->mdSyliveActivity->get(['activityId' => $activityId]);
if (!$re) {
$this->return_json('活动不存在');
}
$this->return_response();
}
/**
* Notes:添加活动
* Created on: 2022/9/21 16:46
@@ -269,11 +233,11 @@ class Activity extends BaseController
$jsondata['blacklist'] = $blacklist;
$jsondata = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
$createTime = date('Y-m-d H:i:s');
$addDate = ['title' => $title, 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'channelId' => $channelId, 'jsondata' => $jsondata
$addData = ['title' => $title, 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'channelId' => $channelId, 'jsondata' => $jsondata
, 'shareTitle' => $shareTitle, 'sharePhoto' => $sharePhoto, 'shareImg' => $setShareImg, 'organizationId' => $organizationId
, 'drawCode' => $drawCode, 'mchId' => $mchId, 'protocolTitle' => $protocolTitle, 'protocol' => $protocol, 'activityStart' => $activityStart
, 'timeStart' => $dateRange[0], 'timeEnd' => $dateRange[1], 'status' => 1, 'createTime' => $createTime];
$activityId = $this->mdSyliveActivity->add($addDate);
$activityId = $this->mdSyliveActivity->add($addData);
if (!$activityId) {
$this->return_json('添加活动失败');
}
@@ -373,11 +337,147 @@ class Activity extends BaseController
}
$jsondata['bottoms'] = $setBottoms;
$jsondata = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
$upDate = ['title' => $title, 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'channelId' => $channelId, 'activityStart' => $activityStart,
$upData = ['title' => $title, 'bgImg' => $bgImg, 'channelImg' => $channelImg, 'channelId' => $channelId, 'activityStart' => $activityStart,
'shareTitle' => $shareTitle, 'sharePhoto' => $sharePhoto, 'shareImg' => $setShareImg, 'jsondata' => $jsondata,
'drawCode' => $drawCode, 'mchId' => $mchId, 'protocolTitle' => $protocolTitle, 'protocol' => $protocol,
'timeStart' => $dateRange[0], 'timeEnd' => $dateRange[1], 'organizationId' => $organizationId];
$this->mdSyliveActivity->update($upDate, ['activityId' => $activityId]);
$this->mdSyliveActivity->update($upData, ['activityId' => $activityId]);
$this->return_response();
}
/**
* Notes:复制活动
* Created on: 2022/12/8 10:08
* Created by: dengbw
* @param null $activityId
*/
public function copy_get($activityId = null)
{
$activityIdOld = intval($activityId);
if (!$activityIdOld) {
$this->return_json('参数错误');
}
$re = $this->mdSyliveActivity->get(['activityId' => $activityIdOld]);
if (!$re) {
$this->return_json('活动不存在');
}
$jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : [];
$jsondata['banner'] = '';
$createTime = date('Y-m-d H:i:s');
$addData = ['title' => '【复制】' . $re['title'], 'organizationId' => $re['organizationId'], 'mchId' => $re['mchId']
, 'protocolTitle' => $re['protocolTitle'], 'protocol' => $re['protocol']
, 'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE), 'status' => 1, 'createTime' => $createTime];
$activityId = $this->mdSyliveActivity->add($addData);
if (!$activityId) {
$this->return_json('复制活动失败');
}
$groupsIds = [];
if ($re['organizationId']) {//分组所属机构
//分级分组
$groupsLevel = [['groupsLevel' => 0, 'parentId' => 'parentId=0', 'title' => '顶级']
, ['groupsLevel' => 1, 'parentId' => 'parentId>0', 'title' => '1级']
, ['groupsLevel' => 2, 'parentId' => 'parentId>0', 'title' => '2级']
, ['groupsLevel' => 3, 'parentId' => 'parentId>0', 'title' => '3级']
, ['groupsLevel' => 0, 'parentId' => 'parentId>0', 'title' => '门店']];
$fileds = 'groupsId,parentId,groupsLevel,sortNumber,userFrom,groupsName,ifBiz,statisticsType,originalBizId';
foreach ($groupsLevel as $v1) {
$res = $this->mdSyliveGroups->select(['groupsLevel' => $v1['groupsLevel'], $v1['parentId'] => null
, 'status>=' => 0, 'activityId' => $activityIdOld], 'groupsId asc', 0, 0, $fileds);
foreach ($res as $v2) {
$parentId = intval($groupsIds[$v2['parentId']]);
$groupsData = ['activityId' => $activityId, 'parentId' => $parentId, 'originalBizId' => $v2['originalBizId']
, 'groupsName' => $v2['groupsName'], 'groupsLevel' => $v2['groupsLevel'], 'statisticsType' => $v2['statisticsType']
, 'userFrom' => $v2['userFrom'], 'ifBiz' => $v2['ifBiz'], 'sortNumber' => $v2['sortNumber'], 'createTime' => $createTime];
$groupsId = $this->mdSyliveGroups->add($groupsData);
$groupsId && $groupsIds[$v2['groupsId']] = $groupsId;
}
}
//分组用户
$fileds = 'userId,groupsId,bizId,levelId1,levelId2,levelId3,type,userFrom,status';
$res = $this->mdSyliveGroupsUser->select(['status>=' => 0, 'activityId' => $activityIdOld], 'groupsUserId asc', 0, 0, $fileds);
$userData = [];
foreach ($res as $v) {
$groupsId = intval($groupsIds[$v['groupsId']]);
$bizId = intval($groupsIds[$v['bizId']]);
$levelId1 = intval($groupsIds[$v['levelId1']]);
$levelId2 = intval($groupsIds[$v['levelId2']]);
$levelId3 = intval($groupsIds[$v['levelId3']]);
$type = intval($groupsIds[$v['type']]);
$userFrom = intval($groupsIds[$v['userFrom']]);
$userData[] = [
'activityId' => $activityId, 'userId' => $v['userId'], 'groupsId' => $groupsId, 'bizId' => $bizId, 'levelId1' => $levelId1,
'levelId1' => $levelId1, 'levelId2' => $levelId2, 'levelId3' => $levelId3,
'type' => $type, 'userFrom' => $userFrom, 'status' => $v['status'], 'createTime' => $createTime];
}
$userData && $this->mdSyliveGroupsUser->add_batch($userData);
}
$this->return_response($groupsIds);
}
/**
* Notes:活动详情
* Created on: 2022/9/29 10:37
* Created by: dengbw
* @param null $activityId
*/
public function index_get($activityId = null)
{
if (!$activityId) {
$this->return_json('参数错误');
}
$re = $this->mdSyliveActivity->get(['activityId' => $activityId], 'activityId,title');
if (!$re) {
$this->return_json('活动不存在');
}
$this->return_response($re);
}
/**
* Notes:删除活动
* Created on: 2022/9/21 16:10
* Created by: dengbw
* @param null $activityId
*/
public function index_delete($activityId = null)
{
if (!$activityId) {
$this->return_json('参数错误');
}
$this->mdSyliveActivity->update(['status' => -1], ['activityId' => $activityId]);
$this->return_response();
}
/**
* Notes:批量删除用户
* Created on: 2022/9/8 17:11
* Created by: dengbw
*/
public function batch_delete()
{
$ids = $this->inputs;
if (!$ids) {
$this->return_json('参数错误');
}
$str_ids = implode(',', $ids);
if ($str_ids) {
$this->mdSyliveActivity->update(['status' => -1], ["activityId in($str_ids)" => null]);
}
$this->return_response();
}
/**
* Notes:修改状态
* Created on: 2022/9/8 16:10
* Created by: dengbw
*/
public function status_put()
{
$activityId = $this->input_param('activityId');
$status = $this->input_param('status');
if (!$activityId) {
$this->return_json('参数错误');
}
$this->mdSyliveActivity->update(['status' => $status], ['activityId' => $activityId]);
$this->return_response();
}
@@ -461,165 +561,4 @@ class Activity extends BaseController
$this->return_response();
}
/**
* Notes:删除活动
* Created on: 2022/9/21 16:10
* Created by: dengbw
* @param null $activityId
*/
public function index_delete($activityId = null)
{
if (!$activityId) {
$this->return_json('参数错误');
}
$this->mdSyliveActivity->update(['status' => -1], ['activityId' => $activityId]);
$this->return_response();
}
/**
* Notes:批量删除用户
* Created on: 2022/9/8 17:11
* Created by: dengbw
*/
public function batch_delete()
{
$ids = $this->inputs;
if (!$ids) {
$this->return_json('参数错误');
}
$str_ids = implode(',', $ids);
if ($str_ids) {
$this->mdSyliveActivity->update(['status' => -1], ["activityId in($str_ids)" => null]);
}
$this->return_response();
}
/**
* Notes:修改状态
* Created on: 2022/9/8 16:10
* Created by: dengbw
*/
public function status_put()
{
$activityId = $this->input_param('activityId');
$status = $this->input_param('status');
if (!$activityId) {
$this->return_json('参数错误');
}
$this->mdSyliveActivity->update(['status' => $status], ['activityId' => $activityId]);
$this->return_response();
}
/**
* Notes:活动订单列表
* Created on: 2022/9/29 9:53
* Created by: dengbw
*/
public function order_get()
{
$date = $this->orderList($this->inputs);
$this->return_response_list($date);
}
/**
* Notes:导出活动订单数据
* Created on: 2022/10/10 15:26
* Created by: dengbw
*/
public function order_export_get()
{
$this->inputs['page'] = 1;
$this->inputs['limit'] = 10000;
$date = $this->orderList($this->inputs);
$this->return_response_list($date);
}
private function orderList($params)
{
$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_kpidata_model', 'mdSyliveActivityKpidata');
$activityId = intval($params['activityId']);
$page = $params['page'];
$limit = $params['limit'];
$uname = $params['uname'];
$mobile = $params['mobile'];
$status = $params['status'];
$cfrom = $params['cfrom'];
$sort = $params['sort'];
$order = $params['order'];
!$page && $page = 1;
!$limit && $limit = 10;
$sort_order = 'id desc';
if ($sort && $order) {
if ($sort == 'statusName') {
$sort_order = 'status ' . $order;
} else if ($sort == 'cfromName') {
$sort_order = 'cfrom ' . $order;
} else {
$sort_order = $sort . ' ' . $order;
}
}
$list = [];
if (!strlen($status)) {
$status = 1;
}
$where['status'] = $status;
$activityId && $where['itemId'] = $activityId;
$uname && $where['uname LIKE "%' . trim($uname) . '%"'] = null;
$mobile && $where['mobile LIKE "%' . trim($mobile) . '%"'] = null;
strlen($cfrom) && $where['cfrom'] = $cfrom;
if ($limit == 10000) {
$count = 1;
} else {
$count = $this->mdSyliveOrder->count($where);
}
if ($count) {
$res = $this->mdSyliveOrder->select($where, $sort_order, $page, $limit);
foreach ($res as $v) {
$consultant = $this->consultantGet(['activityId' => $v['itemId'], 'cfrom' => $v['cfrom'], 'userId' => $v['userId']]);
$list[] = [
'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'] : ''
, '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) {
return $list;
} else {
return ['list' => $list, 'count' => $count];
}
}
/**
* Notes:获取顾问信息
* Created on: 2022/10/8 11:29
* Created by: dengbw
* @param $params
* @return string
*/
private function consultantGet($params)
{
$area = $stores = $consultant = '';
$re = $this->mdSyliveActivityKpidata->get(['activityId' => $params['activityId'], 'userId' => $params['userId'], 'type' => $params['cfrom'], 'kpi' => 'order']);
if ($re['cfUserId']) {
if ($params['cfrom'] == 1) {
$res_teama = $this->mdSyliveTeam->get(["teamId" => $re['areaId']]);
$res_teamb = $this->mdSyliveTeam->get(["teamId" => $re['bizId']]);
$res_teama['teamName'] && $area = $res_teama['teamName'];
$res_teamb['teamName'] && $stores = $res_teamb['teamName'];
} else {
$res_orga = $this->mdSyliveOrganization->get(["organizationId" => $re['areaId']]);
$res_orgb = $this->mdSyliveOrganization->get(["organizationId" => $re['bizId']]);
$res_orga['organizationName'] && $area = $res_orga['organizationName'];
$res_orgb['organizationName'] && $stores = $res_orgb['organizationName'];
}
$re_user = $this->mdSyliveUser->get(['userId' => $re['cfUserId']]);
$re_user['uname'] && $consultant = $re_user['uname'];
}
return ['area' => $area, 'stores' => $stores, 'consultant' => $consultant];
}
}
+4 -1
View File
@@ -202,7 +202,10 @@ class Groups extends BaseController
if (!$groupsId) {
$this->return_json('参数错误');
}
$this->mdSyliveGroups->update(['status' => -1], ['groupsId' => $groupsId]);
$ret = $this->mdSyliveGroups->update(['status' => -1], ['groupsId' => $groupsId]);
if ($ret) {//删除分组用户
$this->mdSyliveGroupsUser->update(['status' => -1], ['groupsId' => $groupsId]);
}
$this->return_response();
}
File diff suppressed because one or more lines are too long