luckybag_1202
This commit is contained in:
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* Notes:福袋活动
|
||||
* Created on: 2021/11/25 15:16
|
||||
* Created by: dengbw
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Luckybag extends HD_Controller
|
||||
{
|
||||
private $giftBagAry = array(0 => '未领取', 1 => '已领取');
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('app/liche/app_liche_luckybag_users_model', 'mdLuckyBagUsers');
|
||||
$this->load->model('app/liche/app_liche_luckybag_log_model', 'mdLuckyBagLog');
|
||||
$this->load->service("app/user_service", array("app_id" => 1));
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->lists();
|
||||
}
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$params = $this->input->get();
|
||||
$params['page'] = $params['page'] ? intval($params['page']) : 1;
|
||||
$params['size'] = $params['size'] ? intval($params['size']) : 20;
|
||||
$lists = $users = $where = [];
|
||||
if ($params['name']) {
|
||||
$where["uid in (select id from lc_app_liche_users where nickname like '%{$params['name']}%')"] = null;
|
||||
}
|
||||
if ($params['mobile']) {
|
||||
$where["uid in (select id from lc_app_liche_users where mobile like '%{$params['mobile']}%')"] = null;
|
||||
}
|
||||
if (status_verify($params['lottery'])) {
|
||||
$where['lottery'] = $params['lottery'];
|
||||
} else {
|
||||
$params['lottery'] = '-99';
|
||||
}
|
||||
if (status_verify($params['gift_bag'])) {
|
||||
$where['gift_bag'] = $params['gift_bag'];
|
||||
} else {
|
||||
$params['gift_bag'] = '-99';
|
||||
}
|
||||
$count = $this->mdLuckyBagUsers->count($where);
|
||||
if ($count) {
|
||||
$res = $this->mdLuckyBagUsers->select($where, 'id desc', $params['page'], $params['size']);
|
||||
$uids = array_column($res, 'uid');
|
||||
$res_u = $this->user_service->select(array('id in (' . implode(',', $uids) . ')' => null), 'id DESC', 0, 0, 'id,nickname,mobile');
|
||||
foreach ($res_u as $key => $value) {
|
||||
$users[$value['id']] = array('nickname' => $value['nickname'], 'mobile' => $value['mobile']);
|
||||
}
|
||||
foreach ($res as $key => $value) {
|
||||
$setValue = array();
|
||||
$user = $users[$value['uid']];
|
||||
$setValue['id'] = $value['id'];
|
||||
$setValue['uid'] = $value['uid'];
|
||||
$setValue['nickname'] = $user['nickname'];
|
||||
$setValue['mobile'] = $user['mobile'];
|
||||
$setValue['lottery'] = $value['lottery'] ? $this->mdLuckyBagUsers->get_gift($value['lottery'], 1)['title'] : '未中奖';
|
||||
$setValue['gift_bag'] = $value['gift_bag'];
|
||||
$setValue['zhu_li_count'] = $this->mdLuckyBagLog->count(['uid' => $value['uid']]);
|
||||
$setValue['c_time'] = date('Y-m-d H:i:s', $value['c_time']);
|
||||
$lists[] = $setValue;
|
||||
}
|
||||
}
|
||||
$lotterys = $this->mdLuckyBagUsers->count(['lottery>' => 0]);
|
||||
$gift_bags = $this->mdLuckyBagUsers->count(['gift_bag' => 1]);
|
||||
$menuAry = array(array('id' => 1, 'title' => "中奖", 'value' => $lotterys, 'tag' => '人'),
|
||||
array('id' => 2, 'title' => "入门礼包", 'value' => $gift_bags, 'tag' => '人'));
|
||||
$ary['menuAry'] = $menuAry;
|
||||
$ary['lotteryAry'] = $this->mdLuckyBagUsers->get_gift(0, 1);
|
||||
$ary['giftBagAry'] = $this->giftBagAry;
|
||||
$this->data['ary'] = $ary;
|
||||
$this->data['lists'] = $lists;
|
||||
$this->data['params'] = $params;
|
||||
$this->data['_title'] = '福袋活动用户';
|
||||
$this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
|
||||
return $this->show_view('/app/liche/luckybag/lists', true);
|
||||
}
|
||||
|
||||
public function lists_log()
|
||||
{
|
||||
$params = $this->input->get();
|
||||
$params['page'] = $params['page'] ? intval($params['page']) : 1;
|
||||
$params['size'] = $params['size'] ? intval($params['size']) : 20;
|
||||
$uid = intval($params['uid']);
|
||||
$re_u = $this->user_service->get(array('id' => $uid));
|
||||
$nickname = $re_u['nickname'] ? $re_u['nickname'] : '未授权';
|
||||
$lists = $users = $where = [];
|
||||
$where['uid'] = $uid;
|
||||
$count = $this->mdLuckyBagLog->count($where);
|
||||
if ($count) {
|
||||
$res = $this->mdLuckyBagLog->select($where, 'id desc', $params['page'], $params['size']);
|
||||
$uids = array_column($res, 'cf_uid');
|
||||
$res_u = $this->user_service->select(array('id in (' . implode(',', $uids) . ')' => null), 'id DESC', 0, 0, 'id,nickname,mobile');
|
||||
foreach ($res_u as $key => $value) {
|
||||
$users[$value['id']] = array('nickname' => $value['nickname'], 'mobile' => $value['mobile']);
|
||||
}
|
||||
foreach ($res as $key => $value) {
|
||||
$setValue = array();
|
||||
$user = $users[$value['cf_uid']];
|
||||
$setValue['nickname'] = $user['nickname'];
|
||||
$setValue['mobile'] = $user['mobile'];
|
||||
$setValue['c_time'] = date('Y-m-d H:i:s', $value['c_time']);
|
||||
$lists[] = $setValue;
|
||||
}
|
||||
}
|
||||
$this->data['lists'] = $lists;
|
||||
$this->data['params'] = $params;
|
||||
$this->data['_title'] = $nickname . '_助力用户';
|
||||
$this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
|
||||
return $this->show_view('/app/liche/luckybag/lists_log', true);
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
}
|
||||
|
||||
public function edit_gift_bag()
|
||||
{
|
||||
$params = $this->input->post();
|
||||
$uid = intval($params['uid']);
|
||||
if (!$uid) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '非法参数!');
|
||||
}
|
||||
$re_u = $this->mdLuckyBagUsers->get(['uid' => $uid]);
|
||||
if (!$re_u) {
|
||||
throw new Hd_exception('无此用户!', API_CODE_FAIL);
|
||||
}
|
||||
$jsondata = $re_u['jsondata'] ? json_decode($re_u['jsondata'], true) : [];
|
||||
$jsondata['gift_bag_time'] = date('Y-m-d H:i:s');
|
||||
$this->mdLuckyBagUsers->update(['gift_bag' => 1, 'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE)], ['uid' => $uid]);
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '操作成功!');
|
||||
}
|
||||
|
||||
public function del()
|
||||
{
|
||||
}
|
||||
|
||||
public function batch()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ class Main extends HD_Controller
|
||||
$this->load->model('Subjects_model', 'subM');
|
||||
$this->load->model('bobing/bobing_user_model', 'mdBobingUser');
|
||||
$this->load->model('app/user_accountlog_model');
|
||||
$this->load->model('app/liche/app_liche_luckybag_users_model', 'mdLuckyBagUsers');
|
||||
}
|
||||
|
||||
public function index()
|
||||
@@ -65,6 +66,15 @@ class Main extends HD_Controller
|
||||
),
|
||||
);
|
||||
|
||||
$value = $this->mdLuckyBagUsers->count();
|
||||
$list[] = array(
|
||||
'title' => '福袋活动(人)',
|
||||
'value' => $value,
|
||||
'btns' => array(
|
||||
array('name' => '查看详情', 'url' => '/app/liche/luckybag'),
|
||||
),
|
||||
);
|
||||
|
||||
// $appConfig = $this->mdBobingUser->appConfig();
|
||||
// $value = $this->mdBobingUser->count(array('act_key' => $appConfig['act_key'], 'app_id' => $appConfig['app_id']));
|
||||
// $list[] = array(
|
||||
|
||||
@@ -68,10 +68,25 @@ class Channel extends HD_Controller
|
||||
}
|
||||
$params['page'] = $params['page'] ? intval($params['page']) : 1;
|
||||
$params['size'] = $params['size'] ? intval($params['size']) : 20;
|
||||
$re = $this->mdUsers->get(array('id' => $params['uid']));
|
||||
$result = $this->dataSelect($params);
|
||||
$count = $result['count'];
|
||||
$this->data['lists'] = $result['lists'];
|
||||
$this->data['params'] = $result['params'];
|
||||
$this->data['_title'] = $result['_title'];
|
||||
$this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
|
||||
return $this->show_view('/app/licheb/channel/lists_biz', true);
|
||||
}
|
||||
|
||||
private function dataSelect($params)
|
||||
{
|
||||
$lists = [];
|
||||
$where['lc_app_licheb_channel_biz.uid'] = $params['uid'];
|
||||
$where['lc_biz.status'] = 1;
|
||||
$_title = '门店列表';
|
||||
if ($params['uid']) {
|
||||
$where['lc_app_licheb_channel_biz.uid'] = $params['uid'];
|
||||
$re = $this->mdUsers->get(array('id' => $params['uid']));
|
||||
$re['uname'] && $_title = $re['uname'] . '_门店列表';
|
||||
}
|
||||
!$params['city_id'] && $params['city_id'] = '';
|
||||
!$params['county_id'] && $params['county_id'] = '';
|
||||
if ($params['biz_name']) {
|
||||
@@ -96,6 +111,7 @@ class Channel extends HD_Controller
|
||||
$this->db->where($where);
|
||||
$this->db->order_by('lc_app_licheb_channel_biz.id Desc');
|
||||
$this->db->limit($limit, $offset);
|
||||
!$params['uid'] && $this->db->group_by('lc_app_licheb_channel_biz.biz_id');
|
||||
$res = $this->db->get()->result_array();
|
||||
$county_id_arr = array_unique(array_column($res, 'county_id'));
|
||||
$Areas = $this->mdArea->get_map_by_county_ids($county_id_arr, 'city_name,county_name,county_id', 'county_id');
|
||||
@@ -110,14 +126,23 @@ class Channel extends HD_Controller
|
||||
$setValue['zbkhs'] = $this->mdCustomers->count(['biz_id' => $value['id'], 'status' => 3]);
|
||||
$setValue['orders'] = $this->mdOrders->count(['biz_id' => $value['id'], 'status>=' => 0, 'brand_id<>' => 3, 'biz_id<>' => 1]);
|
||||
$setValue['days'] = round((time() - $value['c_time']) / 3600 / 24) . '天';
|
||||
if (!$params['uid']) {
|
||||
$this->db->from('lc_app_licheb_channel_biz');
|
||||
$this->db->join('lc_app_licheb_users', "lc_app_licheb_users.id = lc_app_licheb_channel_biz.uid", 'left');
|
||||
$this->db->select('lc_app_licheb_users.uname');
|
||||
$this->db->where(['lc_app_licheb_channel_biz.biz_id' => $value['id']]);
|
||||
$res_u = $this->db->get()->result_array();
|
||||
$unames = $res_u ? implode(',', array_column($res_u, 'uname')) : '';
|
||||
$setValue['uname'] = $unames;
|
||||
}
|
||||
$lists[] = $setValue;
|
||||
}
|
||||
}
|
||||
$this->data['lists'] = $lists;
|
||||
$this->data['params'] = $params;
|
||||
$this->data['_title'] = $re['uname'] . '_门店列表';
|
||||
$this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
|
||||
return $this->show_view('/app/licheb/channel/lists_biz', true);
|
||||
$data['lists'] = $lists;
|
||||
$data['params'] = $params;
|
||||
$data['count'] = $count;
|
||||
$data['_title'] = $_title;
|
||||
return $data;
|
||||
}
|
||||
|
||||
//展示单条数据
|
||||
@@ -150,6 +175,37 @@ class Channel extends HD_Controller
|
||||
//导出数据列表
|
||||
public function export()
|
||||
{
|
||||
|
||||
$params = $this->input->get();
|
||||
$params['page'] = 1;
|
||||
$params['size'] = 10000;
|
||||
$data = $indexs = array();
|
||||
$result = $this->dataSelect($params);
|
||||
$fileName = $result['_title'] . '数据统计';
|
||||
foreach ($result['lists'] as $key => $value) {
|
||||
$temp['biz_name'] = $value['biz_name'];
|
||||
$temp['county_name'] = $value['county_name'];
|
||||
$temp['wjkhs'] = $value['wjkhs'];
|
||||
$temp['dtkhs'] = $value['dtkhs'];
|
||||
$temp['ddkhs'] = $value['ddkhs'];
|
||||
$temp['zbkhs'] = $value['zbkhs'];
|
||||
$temp['orders'] = $value['orders'];
|
||||
$temp['days'] = $value['days'];
|
||||
!$params['uid'] && $temp['uname'] = $value['uname'];
|
||||
$data[] = $temp;
|
||||
}
|
||||
$indexs = [
|
||||
'biz_name' => '门店',
|
||||
'county_name' => '地区',
|
||||
'wjkhs' => '未见客户数',
|
||||
'dtkhs' => '到店客户数',
|
||||
'ddkhs' => '订单客户数',
|
||||
"zbkhs" => "战败客户数",
|
||||
"orders" => "订单数",
|
||||
"days" => "创建时间",
|
||||
];
|
||||
!$params['uid'] && $indexs['uname'] = "渠道经理";
|
||||
array_unshift($data, $indexs);
|
||||
$this->load->library('excel');
|
||||
$this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<div class="am-g">
|
||||
<div class="col-sm-12">
|
||||
<?php foreach ($ary['menuAry'] as $key => $value) { ?>
|
||||
<a href="javascript:void(0)">
|
||||
<div class="col-sm-2">
|
||||
<div class="my-panel">
|
||||
<div class="text-center">
|
||||
<?= $value['title'] ?>
|
||||
</div>
|
||||
<div class="text-center" style="padding-top: 3px;">
|
||||
<span><?= $value['value'] ?></span> <?= $value['tag'] ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
<? } ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="coms-table-wrap mt10">
|
||||
<form id="vue-app" class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
|
||||
action="/app/liche/luckybag">
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w100">用户名称:</label>
|
||||
<div class="am-para-inline w150">
|
||||
<input type="text" name="name" value="<?= $params['name'] ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w100">手机号码:</label>
|
||||
<div class="am-para-inline w150">
|
||||
<input type="text" name="mobile" value="<?= $params['mobile'] ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w80">中奖:</label>
|
||||
<div class="am-para-inline w100">
|
||||
<select name="lottery">
|
||||
<option value="">全部</option>
|
||||
<?php foreach ($ary['lotteryAry'] as $key => $value) { ?>
|
||||
<option value="<?= $key ?>"
|
||||
<?= $key == $params['lottery'] ? 'selected' : '' ?>><?= $value['title'] ?></option>
|
||||
<? } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w100">入门礼包:</label>
|
||||
<div class="am-para-inline w100">
|
||||
<select name="gift_bag">
|
||||
<option value="">全部</option>
|
||||
<?php foreach ($ary['giftBagAry'] as $key => $value) { ?>
|
||||
<option value="<?= $key ?>"
|
||||
<?= $key == $params['gift_bag'] ? 'selected' : '' ?>><?= $value ?></option>
|
||||
<? } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="coms-table-bd">
|
||||
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
|
||||
<table class="am-table am-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="10%"><span>用户名称</span></th>
|
||||
<th width="10%"><span>手机号码</span></th>
|
||||
<th width="10%"><span>中奖</th>
|
||||
<th width="15%"><span>入门礼包</span></th>
|
||||
<th width="10%"><span>助力用户</span></th>
|
||||
<th width="10%"><span>创建时间</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? foreach ($lists as $v) { ?>
|
||||
<tr>
|
||||
<td><?= $v['nickname'] ?></td>
|
||||
<td><?= $v['mobile'] ?></td>
|
||||
<td><?= $v['lottery'] ?></td>
|
||||
<td>
|
||||
<? if ($v['gift_bag']) { ?>
|
||||
已领取
|
||||
<? } else { ?>
|
||||
<a href="javascript:void(0)" data-ajax="post"
|
||||
data-action="/app/liche/luckybag/edit_gift_bag"
|
||||
data-params-uid="<?= $v['uid'] ?>" class="am-btn am-btn-xs am-btn-danger">设为已领取</a>
|
||||
<? } ?>
|
||||
</td>
|
||||
<td><a class="am-btn am-btn-primary am-btn-xs"
|
||||
data-open="/app/liche/luckybag/lists_log?uid=<?= $v['uid'] ?>">
|
||||
<?= $v['zhu_li_count'] ?>人</a>
|
||||
</td>
|
||||
<td><?= $v['c_time'] ?></td>
|
||||
</tr>
|
||||
<? } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="coms-table-ft clearfix">
|
||||
<div class="coms-pagination fr mr20">
|
||||
<?php page_view($pager) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
.my-panel {
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.tab-active {
|
||||
background-color: #5cb85c;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.my-panel span {
|
||||
font-size: 20px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,28 @@
|
||||
<div class="coms-table-wrap mt10">
|
||||
<div class="coms-table-bd">
|
||||
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
|
||||
<table class="am-table am-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="10%"><span>用户名称</span></th>
|
||||
<th width="10%"><span>手机号码</span></th>
|
||||
<th width="10%"><span>助力时间</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($lists as $v) { ?>
|
||||
<tr>
|
||||
<td><?= $v['nickname'] ?></td>
|
||||
<td><?= $v['mobile'] ?></td>
|
||||
<td><?= $v['c_time'] ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="coms-table-ft clearfix">
|
||||
<div class="coms-pagination fr mr20">
|
||||
<?php page_view($pager) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -17,6 +17,9 @@
|
||||
<div class="am-form-group fl ml20">
|
||||
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
|
||||
</div>
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="button" id="export" class="am-btn am-btn-success am-btn-sm w100">导出</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="coms-table-bd">
|
||||
@@ -168,4 +171,7 @@
|
||||
$('#dealer').change(function () {
|
||||
$('#vue-app').submit();
|
||||
});
|
||||
$('#export').click(function () {
|
||||
window.location.href = '/app/licheb/channel/export';
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
<div class="am-form-group fl ml20">
|
||||
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
|
||||
</div>
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="button" id="export" class="am-btn am-btn-success am-btn-sm w100">导出</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="coms-table-bd">
|
||||
@@ -133,4 +136,15 @@
|
||||
$(function () {
|
||||
<?php page_script($pager) ?>
|
||||
});
|
||||
$('#export').click(function () {
|
||||
var count = <?=$pager['totle']?>;
|
||||
if (count > 10000) {
|
||||
layer.msg('单次导出数据不能超过10000');
|
||||
return false;
|
||||
}
|
||||
var href = $.menu.parseUri(window.location.href);
|
||||
var arr = href.split('?');
|
||||
href = '/app/licheb/channel/export?' + arr[1];
|
||||
window.location.href = href;
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
defined('WXAPP_APP') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Notes:福袋活动
|
||||
* Created on: 2021/11/25 15:16
|
||||
* Created by: dengbw
|
||||
*/
|
||||
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
|
||||
|
||||
class Luckybag extends Wxapp
|
||||
{
|
||||
private $activityTime = ['s_time' => '2021-11-01', 'e_time' => '2021-12-12', 'title' => '时间·2021-12-11/12'];
|
||||
|
||||
function __construct($inputs, $app_key)
|
||||
{
|
||||
parent::__construct($inputs, $app_key);
|
||||
$this->login_white = array();//登录白名单
|
||||
$this->check_status = array();//用户状态校验
|
||||
$this->check_mobile = array();//需要手机号
|
||||
$this->check_headimg = array();//授权微信信息
|
||||
$this->load->model('app/liche/app_liche_luckybag_users_model', 'mdLuckyBagUsers');
|
||||
$this->load->model('app/liche/app_liche_luckybag_log_model', 'mdLuckyBagLog');
|
||||
}
|
||||
|
||||
protected function get()
|
||||
{
|
||||
$params = $this->input_param();
|
||||
$lucky_bag_btn = ['title' => '拆福袋', 'status' => 0];
|
||||
if ($params['cf_uid'] && ($params['cf_uid'] != $this->myuid)) {//帮别人助力
|
||||
$set_uid = $params['cf_uid'];
|
||||
$user_btn = ['title' => '助力领领红包', 'status' => 1, 'type' => 1];
|
||||
$re_l = $this->mdLuckyBagLog->get(['uid' => $params['cf_uid'], 'cf_uid' => $this->myuid]);
|
||||
if ($re_l) {
|
||||
$user_btn['title'] = '已为TA助力过';
|
||||
$user_btn['status'] = 0;
|
||||
}
|
||||
$zhu_li_count = $this->mdLuckyBagLog->count(['uid' => $set_uid]);
|
||||
} else {
|
||||
$set_uid = $this->myuid;
|
||||
$user_btn = ['title' => '邀请好友助力领福袋', 'status' => 1, 'type' => 0];
|
||||
$zhu_li_count = $this->mdLuckyBagLog->count(['uid' => $this->myuid]);
|
||||
if ($this->myuid) {
|
||||
$re_u = $this->mdLuckyBagUsers->get(['uid' => $this->myuid]);
|
||||
if (!$re_u) {
|
||||
$this->mdLuckyBagUsers->add(['uid' => $this->myuid, 'c_time' => time()]);
|
||||
$re_u['lottery'] = 0;
|
||||
}
|
||||
if ($re_u['lottery'] > 0 || $zhu_li_count >= 3) {
|
||||
$title_lottery = $re_u['lottery'] > 0 ? '已拆福袋' : '拆福袋';
|
||||
$lucky_bag_btn = ['title' => $title_lottery, 'status' => 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
$list = $this->mdLuckyBagLog->db->select('b.nickname,b.headimg')
|
||||
->from('lc_app_liche_luckybag_log as a')
|
||||
->join('lc_app_liche_users as b', "b.id=a.cf_uid", 'left')
|
||||
->where(['a.uid' => $set_uid])
|
||||
->order_by('a.id Desc')
|
||||
->limit(3)
|
||||
->get()->result_array();
|
||||
$data = array(
|
||||
'title' => '哪吒汽车内购会',
|
||||
"bg" => array('color' => '#f8c33f', 'img' => 'https://qs.haodian.cn/wechat_app/liche/ningDeFD/bag-theme.jpg'),
|
||||
'lucky_bag' => ['img' => 'https://qs.haodian.cn/wechat_app/liche/ningDeFD/luckybag.png', 'title' => '哪吒汽车宁德时代内购会'
|
||||
, 'btn' => $lucky_bag_btn, 'time' => $this->activityTime['title']],
|
||||
'user' => ['btn' => $user_btn, 'zhu_li' => ['title' => "当前已有{$zhu_li_count}位好友帮忙", 'value' => $zhu_li_count, 'list' => $list]],
|
||||
'gift' => $this->mdLuckyBagUsers->get_gift(),
|
||||
'preferential' => ['https://qs.haodian.cn/wechat_app/liche/ningDeFD/policy.jpg'],
|
||||
);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:领取礼包
|
||||
* Created on: 2021/11/26 11:05
|
||||
* Created by: dengbw
|
||||
* @return mixed
|
||||
* @throws Hd_exception
|
||||
*/
|
||||
protected function put()
|
||||
{
|
||||
$this->check_game_date();
|
||||
if (!$this->myuid) {
|
||||
throw new Hd_exception('参数错误', API_CODE_FAIL);
|
||||
}
|
||||
$re_u = $this->mdLuckyBagUsers->get(['uid' => $this->myuid]);
|
||||
if (!$re_u) {
|
||||
throw new Hd_exception('无此用户,领取失败', API_CODE_FAIL);
|
||||
}
|
||||
$bag_title = '内购会入门礼包';
|
||||
if ($re_u['lottery'] > 0) {
|
||||
$lottery = $re_u['lottery'];
|
||||
$re_u['gift_bag'] && $bag_title = '内购会入门礼包(已领取)';
|
||||
} else {
|
||||
$zhu_li_count = $this->mdLuckyBagLog->count(['uid' => $this->myuid]);
|
||||
if ($zhu_li_count < 3) {
|
||||
throw new Hd_exception('还未集齐3位好友拆福袋', API_CODE_FAIL);
|
||||
}
|
||||
$lottery = rand(1, 3);
|
||||
$jsondata = $re_u['jsondata'] ? json_decode($re_u['jsondata'], true) : [];
|
||||
$jsondata['lottery_time'] = date('Y-m-d H:i:s');
|
||||
$this->mdLuckyBagUsers->update(['lottery' => $lottery, 'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE)]
|
||||
, ['uid' => $this->myuid]);
|
||||
}
|
||||
$gift_list[] = ['title' => $this->mdLuckyBagUsers->get_gift($lottery, 1)['tag'], 'img' => $this->mdLuckyBagUsers->get_gift($lottery, 0)['img']];
|
||||
$gift_list[] = ['title' => $bag_title, 'img' => 'https://qs.haodian.cn/wechat_app/liche/ningDeFD/gift-4.jpg'];
|
||||
$data['title'] = '恭喜您,领取成功!';
|
||||
$data['gift'] = ['title' => '恭喜获得:', 'list' => $gift_list];
|
||||
$data['content'] = '注:订车后时展示该活动页面,销售会将抽中的礼品,写入合同备注中,提车时兑现。';
|
||||
$data['btn'] = ['title' => '给好友送福袋', 'url' => '/pages/ningDeFD/index'];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:助力
|
||||
* Created on: 2021/11/26 11:05
|
||||
* Created by: dengbw
|
||||
* @return mixed
|
||||
* @throws Hd_exception
|
||||
*/
|
||||
protected function put_zhu_li()
|
||||
{
|
||||
$this->check_game_date();
|
||||
$params = $this->input_param();
|
||||
//$params['cf_uid'] = 2;
|
||||
if (!$params['cf_uid'] || !$this->myuid) {
|
||||
throw new Hd_exception('参数错误', API_CODE_FAIL);
|
||||
}
|
||||
if ($params['cf_uid'] == $this->myuid) {
|
||||
throw new Hd_exception('不能自己助力', API_CODE_FAIL);
|
||||
}
|
||||
$user = $this->app_user_model->get(['id' => $params['cf_uid']]);
|
||||
if (!$user) {
|
||||
throw new Hd_exception('无此用户,助力失败', API_CODE_FAIL);
|
||||
}
|
||||
$re_l = $this->mdLuckyBagLog->get(['uid' => $params['cf_uid'], 'cf_uid' => $this->myuid]);
|
||||
if ($re_l) {
|
||||
throw new Hd_exception('您已助力过了', API_CODE_FAIL);
|
||||
}
|
||||
$id = $this->mdLuckyBagLog->add(['uid' => $params['cf_uid'], 'cf_uid' => $this->myuid, 'c_time' => time()]);
|
||||
if (!$id) {
|
||||
throw new Hd_exception('助力失败', API_CODE_FAIL);
|
||||
}
|
||||
$data['title'] = '助力成功';
|
||||
$data['content'] = '恭喜您获得一个宁德时代内部员工专属福袋,只要您或者身边有要买新能源汽车的成功下单即可获得豪华礼品。小手一点,免费获得';
|
||||
$data['btn'] = ['title' => '去领取红包', 'url' => '/pages/ningDeFD/index'];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:助力用户
|
||||
* Created on: 2021/11/30 10:16
|
||||
* Created by: dengbw
|
||||
* @return array
|
||||
*/
|
||||
protected function get_zhu_li()
|
||||
{
|
||||
$params = $this->input_param();
|
||||
$set_uid = $params['cf_uid'] ? intval($params['cf_uid']) : $this->myuid;
|
||||
$params['page'] = $params['page'] ? intval($params['page']) : 1;
|
||||
$params['size'] = $params['size'] ? intval($params['size']) : 10;
|
||||
$list = [];
|
||||
$where = ['a.uid' => $set_uid];
|
||||
$total = $this->mdLuckyBagLog->db->select('a.uid')
|
||||
->from('lc_app_liche_luckybag_log as a')
|
||||
->join('lc_app_liche_users as b', "b.id=a.cf_uid", 'left')
|
||||
->where($where)
|
||||
->count_all_results();
|
||||
if ($total) {
|
||||
$offset = ($params['page'] - 1) * $params['size'];
|
||||
$limit = $params['size'];
|
||||
$list = $this->mdLuckyBagLog->db->select('b.nickname,b.headimg')
|
||||
->from('lc_app_liche_luckybag_log as a')
|
||||
->join('lc_app_liche_users as b', "b.id=a.cf_uid", 'left')
|
||||
->where($where)
|
||||
->order_by('a.id Desc')
|
||||
->limit($limit, $offset)
|
||||
->get()->result_array();
|
||||
}
|
||||
return ['list' => $list, 'total' => $total];
|
||||
}
|
||||
|
||||
protected function check_game_date()
|
||||
{
|
||||
$date = date('Y-m-d H:i');
|
||||
if ($this->activityTime['s_time'] . ' 00:00' > $date) {
|
||||
throw new Hd_exception('活动未开始', API_CODE_FAIL);
|
||||
}
|
||||
if ($this->activityTime['e_time'] . ' 23:59' < $date) {
|
||||
throw new Hd_exception('活动已结束', API_CODE_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
protected function post()
|
||||
{
|
||||
return $this->put();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Notes:福袋活动-助力表
|
||||
* Created on: 2021/11/25 12:45
|
||||
* Created by: dengbw
|
||||
*/
|
||||
class App_liche_luckybag_log_model extends HD_Model
|
||||
{
|
||||
private $table_name = 'lc_app_liche_luckybag_log';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->table_name, 'default');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Notes:福袋活动-用户表
|
||||
* Created on: 2021/11/25 12:45
|
||||
* Created by: dengbw
|
||||
*/
|
||||
class App_liche_luckybag_users_model extends HD_Model
|
||||
{
|
||||
private $table_name = 'lc_app_liche_luckybag_user';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->table_name, 'default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:红包礼品
|
||||
* Created on: 2021/11/26 17:22
|
||||
* Created by: dengbw
|
||||
* @param int $id
|
||||
* @param int $type
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function get_gift($id = 0, $type = 0)
|
||||
{
|
||||
if ($type == 0) {
|
||||
$content = '入场礼于活动期间抵达内购会现场即可领取内购礼提车时一同领取,权益可转让给亲友';
|
||||
$gift = [1 => ['title' => '内购礼:电视机+内购会入场礼包', 'content' => $content, 'img' => 'https://qs.haodian.cn/wechat_app/liche/ningDeFD/gift-1.jpg']
|
||||
, 2 => ['title' => '内购礼:电冰箱+内购会入场礼包', 'content' => $content, 'img' => 'https://qs.haodian.cn/wechat_app/liche/ningDeFD/gift-2.jpg']
|
||||
, 3 => ['title' => '内购礼:自行车+内购会入场礼包', 'content' => $content, 'img' => 'https://qs.haodian.cn/wechat_app/liche/ningDeFD/gift-3.jpg']];
|
||||
} else {
|
||||
$gift = [1 => ['title' => '电视机', 'tag' => '电视机一台'], 2 => ['title' => '电冰箱', 'tag' => '电冰箱一台']
|
||||
, 3 => ['title' => '自行车', 'tag' => '自行车一辆']];
|
||||
}
|
||||
return $id ? $gift[$id] : $gift;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user