market_draw_202

This commit is contained in:
dengbw
2023-02-02 17:11:40 +08:00
parent 1810b6a478
commit 72a7c3a0b6
5 changed files with 157 additions and 35 deletions
@@ -0,0 +1,11 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Market_sylive_activity_draw_model extends HD_Model
{
private $table_name = 'lc_market_sylive_activity_draw';
public function __construct(){
parent::__construct($this->table_name, 'default');
}
}
+56 -22
View File
@@ -15,6 +15,7 @@ class Draw extends CI_Controller
$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');
$this->load->model('market/Market_sylive_activity_draw_model', 'mdSyliveActivityDraw');
}
/**
@@ -43,19 +44,28 @@ class Draw extends CI_Controller
}
$re = $this->mdSyliveActivity->get(['drawCode' => $drawCode, 'status' => 0], 'title,activityId');
if ($re['activityId']) {
$winNumAry[] = ['title' => '请选择中奖人数', 'value' => 0];
$winTypeAry[] = ['title' => '请选择抽奖类型'];
$bgImg = 'https://qs.haodian.cn/web/images/project/H5-ShiYu-draw/bg-20221213.png';
$activityId = intval($re['activityId']);
$drawConfig = $this->mdSyliveOrder->drawConfig($activityId);
$winNumAry = $drawConfig['winNumAry'];//中奖人数
$winTypeAry = [];//抽奖类型
$winTypeAryGet = $this->mdSyliveOrder->winTypeAry($activityId);
foreach ($winTypeAryGet as $k => $v) {
if ($k != 7) {
$title = $v['merge'] ? $v['tag'] . ' ' . $v['title'] : $v['title'];
$winTypeAry[] = ['title' => $title, 'value' => $k];
$re_draw = $this->mdSyliveActivityDraw->get(['activityId' => $activityId]);
if ($re_draw) {
$re_draw['bgImg'] && $bgImg = build_qiniu_image_url($re_draw['bgImg']);
if ($re_draw['winType']) {
$json_winType = json_decode($re_draw['winType'], true);
foreach ($json_winType as $v) {
$v['show'] && $winTypeAry[] = ['title' => $v['title'], 'value' => $v['id']];
}
}
if ($re_draw['winNum']) {
$json_winNum = json_decode($re_draw['winNum'], true);
foreach ($json_winNum as $v) {
$winNumAry[] = ['title' => $v['title'], 'value' => $v['value']];
}
}
}
$title = $re['title'] . '_私域直播抽奖';
$bgImg = "background-image:url('{$drawConfig['bgImg']}')";
$bgImg = "background-image:url('{$bgImg}')";
$data = ['winNumAry' => $winNumAry, 'winTypeAry' => $winTypeAry, 'activityId' => $activityId,
'bgImg' => $bgImg, 'title' => $title];
$this->show_json(200, '抽奖码验证成功', $data);
@@ -106,17 +116,33 @@ class Draw extends CI_Controller
if (date('Y-m-d H:i:s') > $re['timeEnd']) {
$this->show_json(400, "直播结束时间【{$re['timeEnd']}】,不能抽奖了...");
}
$winTypeAry = $this->mdSyliveOrder->winTypeAry($activityId);
$price = $winTypeAry[$winType]['price'];
$limit = $winNum >= 50 ? 120 : 60;
$limit = $winNum >= 50 ? 120 : 60;//随机数据
$prizeUrl = '';
$whereOrder = ['activityId' => $activityId, 'win' => 0, 'status' => 1];
$sqlOrder = "SELECT id,userId,mobile,uname,totalPrice FROM lc_market_sylive_order WHERE activityId={$activityId}
AND win=0 AND status=1 ORDER BY RAND() LIMIT {$limit}";
$re_draw = $this->mdSyliveActivityDraw->get(['activityId' => $activityId]);
if ($re_draw && $re_draw['winType']) {
$json_winType = json_decode($re_draw['winType'], true);
foreach ($json_winType as $v) {
if ($v['id'] == $winType) {
$v['img'] && $prizeUrl = build_qiniu_image_url($v['img']);
if ($v['itemIds']) {
$itemIds = implode(',', $v['itemIds']);
$whereOrder["itemId in({$itemIds})"] = null;
$sqlOrder = "SELECT id,userId,mobile,uname,totalPrice FROM lc_market_sylive_order WHERE activityId={$activityId}
AND win=0 AND status=1 AND itemId in({$itemIds}) ORDER BY RAND() LIMIT {$limit}";
}
break;
}
}
}
$time = "在【" . date('Y-m-d H:i:s') . "";
$count = $this->mdSyliveOrder->count(['activityId' => $activityId, 'win' => 0, 'status' => 1, 'totalPrice>=' => $price]);
$count = $this->mdSyliveOrder->count($whereOrder);
$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();
$res = $this->db->query($sqlOrder)->result_array();
if ($res) {
$str_userIds = implode(',', array_column($res, 'userId'));
$map_user = $this->mdSyliveUser->map('userId', 'headimg', ["userId in({$str_userIds})" => null]);
@@ -149,7 +175,7 @@ class Draw extends CI_Controller
$msg = "{$time}获取到抽奖名单,可开始抽奖";
$data['result'] = $result;
$data['type'] = $winType;
$data['prizeUrl'] = $winTypeAry[$winType]['img'];
$data['prizeUrl'] = $prizeUrl;
$this->show_json(200, $msg, $data);
}
@@ -172,7 +198,17 @@ class Draw extends CI_Controller
$this->show_json(400, '暂无活动');
}
$resultSet = [];
$winTypeAry = $this->mdSyliveOrder->winTypeAry($activityId, $winType);
$winSms = '';
$re_draw = $this->mdSyliveActivityDraw->get(['activityId' => $activityId]);
if ($re_draw && $re_draw['winType'] && $re_draw['sms']) {
$json_winType = json_decode($re_draw['winType'], true);
foreach ($json_winType as $v) {
if ($v['id'] == $winType && $v['title']) {
$winSms = str_replace("中奖标题", $v['title'], $re_draw['sms']);
break;
}
}
}
$winTime = date('Y-m-d H:i:s');
$showMobile = '';
$winNum = $sms = 0;
@@ -184,9 +220,8 @@ class Draw extends CI_Controller
$resultSet[] = $v;
//中奖发短信
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);
if ($winTime >= $re['timeStart'] && $winSms) {//直播开始时中奖发短信
b2m_send_sms($v['mobile'], $winSms);
$sms++;
}
}
@@ -204,7 +239,6 @@ class Draw extends CI_Controller
$winNumCount = $this->mdSyliveOrder->count(['activityId' => $activityId, 'win' => 1, 'status' => 1, 'winType' => $winType]);
$data['result'] = $resultSet;
$data['winMsgTip'] = $winNumCount;
$data['dev'] = $dev;
$data['sms'] = $sms;
$this->show_json(200, $msg ? $msg : '成功抽奖', $data);
}
+69 -3
View File
@@ -15,6 +15,7 @@ class Activity extends BaseController
parent::__construct();
$this->load->model('market/Market_sylive_activity_model', 'mdSyliveActivity');
$this->load->model('market/Market_sylive_activity_biz_model', 'mdSyliveActivityBiz');
$this->load->model('market/Market_sylive_activity_draw_model', 'mdSyliveActivityDraw');
$this->load->model('market/Market_sylive_organization_model', 'mdSyliveOrganization');
$this->load->model('market/Market_sylive_team_model', 'mdSyliveTeam');
$this->load->model('market/Market_sylive_activity_team_model', 'mdSyliveActivityTeam');
@@ -60,8 +61,9 @@ class Activity extends BaseController
$status = intval($v['status']);
$activityId = intval($v['activityId']);
$bgImg = $channelImg = $banner = $sharePhoto = $shareImg = $shareTitle = $pay = $bottoms = [];
$item = ['activityId' => $activityId, 'itemImg' => [], 'title' => '', 'introduction' => '', 'price' => '', 'stock' => '', 'dateRange' => ''];
$coupon = ['activityId' => $activityId, 'img' => [], 'title' => '', 'rules' => '', 'price' => '', 'dateRange' => ''];
$item = ['itemImg' => [], 'title' => '', 'introduction' => '', 'price' => '', 'stock' => '', 'dateRange' => ''];
$coupon = ['img' => [], 'title' => '', 'rules' => '', 'price' => '', 'dateRange' => ''];
$draw = ['bgImg' => [], 'sms' => '', 'winNum' => [], 'winType' => []];
$pay = ['way' => 1, 'price' => '', 'img' => []];
$v['shareTitle'] && $shareTitle = json_decode($v['shareTitle'], true);
$jsondata = $v['jsondata'] ? json_decode($v['jsondata'], true) : [];
@@ -145,11 +147,30 @@ class Activity extends BaseController
$re_gro = $this->mdSyliveGroups->get(['activityId' => $activityId, 'parentId' => 0, 'status>=' => 0]);
$re_gro && $groups = 1;
$blacklist = intval($jsondata['blacklist']);
//抽奖配置
$re_draw = $this->mdSyliveActivityDraw->get(['activityId' => $activityId]);
if ($re_draw) {
if ($re_draw['bgImg']) {
$draw['bgImg'] = [['uid' => 1, 'fileUrl' => $re_draw['bgImg'], 'url' => build_qiniu_image_url($re_draw['bgImg']), 'status' => 'done']];
}
$re_draw['sms'] && $draw['sms'] = $re_draw['sms'];
$re_draw['winNum'] && $draw['winNum'] = json_decode($re_draw['winNum'], true);
if ($re_draw['winType']) {
$winType = [];
$json_winType = json_decode($re_draw['winType'], true);
foreach ($json_winType as $v2) {
$v2['img'] = $v2['img'] ?
[['uid' => 1, 'fileUrl' => $v2['img'], 'url' => build_qiniu_image_url($v2['img']), 'status' => 'done']] : [];
$winType[] = $v2;
}
$draw['winType'] = $winType;
}
}
$list[] = [
'activityId' => $activityId, 'title' => $v['title'], 'channelId' => $v['channelId'], 'pay' => $pay, 'organizationId' => $organizationId,
'activityStart' => $activityStart, 'shareTitle' => $shareTitle, 'dateRange' => $dateRange, 'coupon' => $coupon, 'drawCode' => $v['drawCode'],
'bgImg' => $bgImg, 'channelImg' => $channelImg, 'banner' => $banner, 'sharePhoto' => $sharePhoto, 'shareImg' => $shareImg, 'item' => $item, 'url' => $url,
'mchId' => $v['mchId'], 'protocolTitle' => $v['protocolTitle'], 'protocol' => $v['protocol'], 'serviceLink' => $serviceLink, 'bottoms' => $bottoms
'mchId' => $v['mchId'], 'protocolTitle' => $v['protocolTitle'], 'protocol' => $v['protocol'], 'serviceLink' => $serviceLink, 'bottoms' => $bottoms, 'draw' => $draw
, 's_time' => $v['timeStart'], 'e_time' => $v['timeEnd'], 'status' => $status, 'groups' => $groups, 'blacklist' => $blacklist, 'createTime' => $v['createTime']];
}
}
@@ -561,4 +582,49 @@ class Activity extends BaseController
$this->return_response();
}
/**
* Notes:修改抽奖配置
* Created on: 2023/1/30 10:08
* Created by: dengbw
*/
public function draw_put()
{
$activityId = intval($this->input_param('activityId'));
if (!$activityId) {
$this->return_json('参数错误');
}
$bgImg = $this->input_param('bgImg');
$sms = $this->input_param('sms');
$winNum = $this->input_param('winNum');
$winType = $this->input_param('winType');
$re = $this->mdSyliveActivityDraw->get(['activityId' => $activityId]);
$upDate['bgImg'] = $bgImg ? $bgImg[0]['fileUrl'] : '';
$upDate['sms'] = $sms;
$setWinNum = $setWinType = [];
if ($winNum) {
foreach ($winNum as $v) {
$setWinNum[] = ['title' => $v['value'] . '人', 'value' => $v['value']];
}
}
if ($winType) {
foreach ($winType as $v) {
$v['img'] = $v['img'] ? $v['img'][0]['fileUrl'] : '';
$setWinType[] = $v;
}
}
$upDate['winNum'] = $setWinNum ? json_encode($setWinNum, JSON_UNESCAPED_UNICODE) : [];
$upDate['winType'] = $setWinType ? json_encode($setWinType, JSON_UNESCAPED_UNICODE) : [];
if (!$re) {
$upDate['activityId'] = $activityId;
$upDate['createTime'] = date('Y-m-d H:i:s');
$ret = $this->mdSyliveActivityDraw->add($upDate);
} else {
$ret = $this->mdSyliveActivityDraw->update($upDate, ['activityId' => $activityId]);
}
if (!$ret) {
$this->return_json('抽奖配置失败');
}
$this->return_response();
}
}
+4 -2
View File
@@ -64,9 +64,9 @@ class Goods extends BaseController
$v['timeEnd'] != '0000-00-00 00:00:00' && $dateRange[] = $v['timeEnd'];
$v['useStart'] != '0000-00-00 00:00:00' && $useRange[] = $v['useStart'];
$v['useEnd'] != '0000-00-00 00:00:00' && $useRange[] = $v['useEnd'];
if($activityId>=6){
if ($activityId >= 6) {
$url = http_host_com('home') . "/h5/market/sylive2/item/detail?skey={$skey}";//活动连接
}else{
} else {
$url = http_host_com('home') . "/h5/market/sylive/item/detail?skey={$skey}";//活动连接
}
$list[] = ['itemId' => $v['itemId'], 'activityId' => $v['activityId'], 'title' => $v['title'], 'banner' => $banner
@@ -87,8 +87,10 @@ class Goods extends BaseController
public function items_get()
{
$activityId = intval($this->input_param('activityId'));
$type = $this->input_param('type');
$where['status>='] = 0;
$where['activityId'] = $activityId;
strlen($type) && $where['type'] = $type;
$list = $this->mdSyliveItems->select($where, 'sort asc,itemId desc', 0, 0, 'itemId,title');
$this->return_response_list($list);
}
+17 -8
View File
@@ -17,7 +17,7 @@ class groupsWin extends BaseController
$this->load->model('market/Market_sylive_user_model', 'mdSyliveUser');
$this->load->model('market/Market_sylive_activity_kpidata_model', 'mdSyliveActivityKpidata');
$this->load->model('market/Market_sylive_groups_model', 'mdSyliveGroups');
$this->load->model('market/Market_sylive_activity_draw_model', 'mdSyliveActivityDraw');
$this->load->model('market/Market_sylive_organization_model', 'mdSyliveOrganization');
$this->load->model('market/Market_sylive_team_model', 'mdSyliveTeam');
}
@@ -54,11 +54,12 @@ class groupsWin extends BaseController
public function win_type_get()
{
$activityId = intval($this->input_param('activityId'));
$winTypeAry = $this->mdSyliveOrder->winTypeAry($activityId);
$re_draw = $this->mdSyliveActivityDraw->get(['activityId' => $activityId]);
$date = [];
foreach ($winTypeAry as $k => $v) {
if ($k > 0) {
$date[] = ['id' => $k, 'name' => $v['title']];
if ($re_draw && $re_draw['winType']) {
$json_winType = json_decode($re_draw['winType'], true);
foreach ($json_winType as $v) {
$date[] = ['id' => $v['id'], 'name' => $v['title']];
}
}
$this->return_response_list($date);
@@ -76,7 +77,7 @@ class groupsWin extends BaseController
$order = $params['order'];
$bizId = $params['bizId'];
$itemId = $params['itemId'];
$winType= $params['winType'];
$winType = $params['winType'];
!$page && $page = 1;
!$limit && $limit = 10;
$sort_order = 'winTime desc';
@@ -109,16 +110,24 @@ class groupsWin extends BaseController
$count = $this->mdSyliveOrder->count($where);
}
if ($count) {
$winTypeAry = $this->mdSyliveOrder->winTypeAry($activityId);
$winTypeAry = [];
$re_draw = $this->mdSyliveActivityDraw->get(['activityId' => $activityId]);
if ($re_draw && $re_draw['winType']) {
$json_winType = json_decode($re_draw['winType'], true);
foreach ($json_winType as $v) {
$winTypeAry[$v['id']] = $v['title'];
}
}
$res = $this->mdSyliveOrder->select($where, $sort_order, $page, $limit);
foreach ($res as $v) {
$consultant = $this->consultantGet(['activityId' => $v['activityId'], 'userId' => $v['userId']
, 'levelId1' => $v['levelId1'], 'levelId2' => $v['levelId2'], 'levelId3' => $v['levelId3']
, 'bizId' => $v['bizId'], 'cfUserId' => $v['cfUserId']]);
$winName = $winTypeAry[$v['winType']] ? $winTypeAry[$v['winType']] : '';
$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'] : ''
, 'winTime' => $v['winTime'] ? $v['winTime'] : '', 'winName' => $winTypeAry[$v['winType']]['title']
, 'winTime' => $v['winTime'] ? $v['winTime'] : '', 'winName' => $winName
, 'levelName1' => $consultant['levelName1'], 'levelName2' => $consultant['levelName2'], 'levelName3' => $consultant['levelName3']
, 'stores' => $consultant['stores'], 'consultant' => $consultant['consultant']
];