This commit is contained in:
xiaoyu
2023-07-13 10:46:37 +08:00
parent 0c163b1695
commit 8ebf1f92e3
+33 -35
View File
@@ -90,7 +90,9 @@ class Draw extends CI_Controller
if ($winType) {
$winNumCount = $this->mdSyliveOrder->count(['activityId' => $activityId, 'win' => 1, 'status' => 1, 'winType' => $winType]);
}
$data['winMsgTip'] = $winNumCount;
$this->show_json(200, '操作成功', $data);
}
@@ -105,6 +107,8 @@ class Draw extends CI_Controller
$winNum = intval($params['winNum']);
$winType = intval($params['winType']);
$activityId = intval($params['activityId']);
$defaultHead = 'https://qs.haodian.cn/web/images/project/H5-ShiYu/default-head.png';
if (!$winType) {
$this->show_json(400, '请选择抽奖类型');
}
@@ -122,7 +126,7 @@ class Draw extends CI_Controller
$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}";
AND win=0 AND winType=0 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);
@@ -133,7 +137,7 @@ class Draw extends CI_Controller
$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}";
AND win=0 AND winType=0 AND status=1 AND itemId in({$itemIds}) ORDER BY RAND() LIMIT {$limit}";
}
break;
}
@@ -143,8 +147,6 @@ class Draw extends CI_Controller
$count = $this->mdSyliveOrder->count($whereOrder);
$list = $result = [];
if ($count) {//判断抽奖名单
$defaultHead = 'https://qs.haodian.cn/web/images/project/H5-ShiYu/default-head.png';
//随机数据
$res = $this->db->query($sqlOrder)->result_array();
if ($res) {
@@ -173,41 +175,36 @@ class Draw extends CI_Controller
$this->show_json(400, "{$time}获取到抽奖人数{$count}人,不够选择中奖人数{$winNum}人,不能开始抽奖");
}
$data['list'] = $list;
//暗箱
if($activityId == 15 && in_array($winType, array(2,3)))
{
$list = array();
$sqlOrder = "SELECT id,userId,mobile,uname,totalPrice FROM lc_market_sylive_order WHERE activityId={$activityId} AND win=0 AND winType={$winType} AND status=1 ORDER BY RAND() LIMIT {$winNum}";
$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]);
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 = $defaultHead;
}
$list[] = ['headimg' => $headimg, 'name' => $name, 'tel' => $tel, 'id' => intval($v['id']), 'uname' => $v['uname'], 'mobile' => $v['mobile']];
}
}
}
}
//选择中奖人结果
shuffle($list);
$result = array_slice($list, 0, $winNum);
if($activityId == 6) //15
{
if($winType == 1)
{
$result = array(
array('headimg' => 'https://qs.haodian.cn/web/images/project/H5-ShiYu/default-head.png', 'name' => '9999', 'tel' => '138****9646', 'id' => 123,
'uname' => '9999', 'mobile' => '13860199646')
);
}
if($winType == 2)
{
$result = array(
array('headimg' => 'https://qs.haodian.cn/web/images/project/H5-ShiYu/default-head.png', 'name' => '手机', 'tel' => '138****9646', 'id' => 123,
'uname' => '手机', 'mobile' => '13860199646')
);
}
if($winType == 3)
{
$result = array(
array('headimg' => 'https://qs.haodian.cn/web/images/project/H5-ShiYu/default-head.png', 'name' => '19991', 'tel' => '138****9646', 'id' => 123,
'uname' => '19991', 'mobile' => '13860199646'),
array('headimg' => 'https://qs.haodian.cn/web/images/project/H5-ShiYu/default-head.png', 'name' => '19992', 'tel' => '138****9646', 'id' => 123,
'uname' => '19992', 'mobile' => '13860199646'),
array('headimg' => 'https://qs.haodian.cn/web/images/project/H5-ShiYu/default-head.png', 'name' => '19993', 'tel' => '138****9646', 'id' => 123,
'uname' => '19993', 'mobile' => '13860199646')
);
}
}
$msg = "{$time}获取到抽奖名单,可开始抽奖";
$data['result'] = $result;
$data['type'] = $winType;
@@ -251,6 +248,7 @@ class Draw extends CI_Controller
$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) {
$winNum++;
$resultSet[] = $v;