diff --git a/common/helpers/comm_helper.php b/common/helpers/comm_helper.php index d596fdbc..27097f7b 100644 --- a/common/helpers/comm_helper.php +++ b/common/helpers/comm_helper.php @@ -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; + } +} + /* * 随机码 */ diff --git a/common/models/market/Market_sylive_order_model.php b/common/models/market/Market_sylive_order_model.php index b6c25b8b..8285bebe 100644 --- a/common/models/market/Market_sylive_order_model.php +++ b/common/models/market/Market_sylive_order_model.php @@ -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]; diff --git a/common/third_party/b2m/sms.php b/common/third_party/b2m/sms.php index 3d7930ef..35c533c9 100755 --- a/common/third_party/b2m/sms.php +++ b/common/third_party/b2m/sms.php @@ -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);//加密结果 diff --git a/home/controllers/h5/market/Draw.php b/home/controllers/h5/market/Draw.php index 45f7daa1..dcd932ba 100644 --- a/home/controllers/h5/market/Draw.php +++ b/home/controllers/h5/market/Draw.php @@ -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)); } -} +} \ No newline at end of file diff --git a/home/views/h5/market/draw/index.php b/home/views/h5/market/draw/index.php index da9b05aa..b2d96eb7 100644 --- a/home/views/h5/market/draw/index.php +++ b/home/views/h5/market/draw/index.php @@ -20,6 +20,7 @@