Browse Source

领券

master
ZLW-PC\Administrator 7 years ago
parent
commit
5722c3643d
  1. 1
      app/Http/Controllers/Api/BonusController.php
  2. 4
      app/Http/Controllers/Api/UserController.php
  3. 3
      app/Http/Controllers/Weixin/BonusController.php
  4. 52
      app/Http/Controllers/Weixin/UserController.php
  5. 16
      app/Http/Model/Bonus.php
  6. 14
      app/Http/Model/User.php
  7. 7
      app/Http/Model/UserBonus.php
  8. 49
      resources/views/weixin/bonus/bonusList.blade.php
  9. 34
      resources/views/weixin/user/index.blade.php
  10. 1
      resources/views/weixin/user/userBonusList.blade.php
  11. 103
      resources/views/weixin/user/userDistribution.blade.php
  12. 4
      routes/web.php

1
app/Http/Controllers/Api/BonusController.php

@ -21,7 +21,6 @@ class BonusController extends CommonController
//参数
$data['limit'] = $request->input('limit', 10);
$data['offset'] = $request->input('offset', 0);
$data['user_id'] = Token::$uid;
$res = Bonus::getList($data);
if(!$res)

4
app/Http/Controllers/Api/UserController.php

@ -105,6 +105,10 @@ class UserController extends CommonController
$data['limit'] = $request->input('limit', 10);
$data['offset'] = $request->input('offset', 0);
if($request->input('parent_id', '')!=''){$data['parent_id'] = $request->input('parent_id');}
if($request->input('group_id', '')!=''){$data['group_id'] = $request->input('group_id');}
if($request->input('sex', '')!=''){$data['sex'] = $request->input('sex');}
$res = User::getList($data);
if(!$res)
{

3
app/Http/Controllers/Weixin/BonusController.php

@ -20,8 +20,7 @@ class BonusController extends CommonController
$postdata = array(
'limit' => $pagesize,
'offset' => $offset,
'access_token' => $_SESSION['weixin_user_info']['access_token']
'offset' => $offset
);
$url = env('APP_API_URL')."/bonus_list";
$res = curl_request($url,$postdata,'GET');

52
app/Http/Controllers/Weixin/UserController.php

@ -46,6 +46,56 @@ class UserController extends CommonController
return view('weixin.user.userinfo', $data);
}
//我的分销
public function userDistribution(Request $request)
{
//获取会员信息
$postdata = array(
'access_token' => $_SESSION['weixin_user_info']['access_token']
);
$url = env('APP_API_URL')."/user_info";
$res = curl_request($url,$postdata,'GET');
$data['user_info'] = $res['data'];
//获取直属下级会员列表
$pagesize = 10;
$offset = 0;
if(isset($_REQUEST['page'])){$offset = ($_REQUEST['page']-1)*$pagesize;}
$postdata = array(
'limit' => $pagesize,
'offset' => $offset,
'parent_id' => $_SESSION['weixin_user_info']['id'],
'access_token' => $_SESSION['weixin_user_info']['access_token']
);
$url = env('APP_API_URL')."/user_list";
$res = curl_request($url,$postdata,'GET');
$data['list'] = $res['data']['list'];
$data['totalpage'] = ceil($res['data']['count']/$pagesize);
if(isset($_REQUEST['page_ajax']) && $_REQUEST['page_ajax']==1)
{
$html = '';
if($res['data']['list'])
{
foreach($res['data']['list'] as $k => $v)
{
$html .= '<li><span class="goods_thumb" style="width:72px;height:72px;"><img style="width:72px;height:72px;" alt="'.$v['user_name'].'" src="'.$v['head_img'].'"></span>';
$html .= '<div class="goods_info"><p class="goods_tit">'.$v['user_name'].'</p>';
$html .= '<p style="line-height:24px;">佣金:'.$v['commission'].'</p>';
$html .= '<p style="line-height:24px;">注册时间:'.date('Y-m-d',$v['add_time']).'</p>';
$html .= '</div></li>';
}
}
exit(json_encode($html));
}
return view('weixin.user.userDistribution', $data);
}
//资金管理
public function userAccount(Request $request)
{
@ -260,7 +310,7 @@ class UserController extends CommonController
public function userBonusList(Request $request)
{
//商品列表
$pagesize = 1;
$pagesize = 10;
$offset = 0;
if(isset($_REQUEST['page'])){$offset = ($_REQUEST['page']-1)*$pagesize;}

16
app/Http/Model/Bonus.php

@ -30,16 +30,20 @@ class Bonus extends BaseModel
$model = $model->where($where);
$model = $model->where(function ($query) {
$query->where('num', '=', -1)->orWhere('num', '>', 0);
});
$model = $model->where(function ($query) {
$query->where('start_time', '<', date('Y-m-d H:i:s'))->where('end_time', '>', date('Y-m-d H:i:s'));
});
$res['count'] = $model->count();
$res['list'] = array();
if($res['count']>0)
{
$res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get()->toArray();
}
else
{
return false;
$res['list'] = $model->skip($offset)->take($limit)->orderBy('money','desc')->get();
}
return $res;
@ -47,7 +51,7 @@ class Bonus extends BaseModel
public static function getOne($id)
{
return self::where('id', $id)->first()->toArray();
return self::where('id', $id)->first();
}
public static function add(array $data)

14
app/Http/Model/User.php

@ -50,25 +50,27 @@ class User extends BaseModel
{
extract($param); //参数:limit,offset
$where = '';
$limit = isset($limit) ? $limit : 10;
$offset = isset($offset) ? $offset : 0;
$model = new User;
if(isset($group_id)){$where['group_id'] = $group_id;}
if(isset($parent_id)){$where['parent_id'] = $parent_id;}
if($where != '')
{
$model = $model->where($where);
}
if(isset($where)){$model = $model->where($where);}
$res['count'] = $model->count();
$res['list'] = array();
if($res['count']>0)
{
$res['list'] = $model->select('id','user_name','email','sex','money','point','mobile','nickname','add_time')->skip($offset)->take($limit)->orderBy('id','desc')->get()->toArray();
$res['list'] = $model->select('id','user_name','email','sex','money','commission','point','mobile','nickname','head_img','add_time')->skip($offset)->take($limit)->orderBy('id','desc')->get();
foreach($res['list'] as $k=>$v)
{
$res['list'][$k]['user_name'] = !empty($res['list'][$k]['mobile']) ? $res['list'][$k]['mobile'] : $res['list'][$k]['user_name'];
}
}
else
{

7
app/Http/Model/UserBonus.php

@ -63,7 +63,10 @@ class UserBonus extends BaseModel
public static function add(array $data)
{
if(!Bonus::where(['id'=>$data['bonus_id']])->where('num',-1)->first() && !Bonus::where(['id'=>$data['bonus_id']])->where('num','>',0)->first())
$bonus1 = Bonus::where(['id'=>$data['bonus_id']])->where('num',-1)->first();
$bonus2 = Bonus::where(['id'=>$data['bonus_id']])->where('num','>',0)->first();
if(!$bonus1 && !$bonus2)
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'亲,您来晚了啦,已被抢光了');
}
@ -73,7 +76,7 @@ class UserBonus extends BaseModel
$data['get_time'] = time(); //优惠券获取时间
if ($id = self::insertGetId($data))
{
DB::table('bonus')->where(array('id'=>$data['bonus_id']))->decrement('num', 1);
if(!$bonus1){DB::table('bonus')->where(array('id'=>$data['bonus_id']))->decrement('num', 1);}
return ReturnData::create(ReturnData::SUCCESS,$id);
}

49
resources/views/weixin/bonus/bonusList.blade.php

@ -6,6 +6,7 @@
<div class="classreturn loginsignup">
<div class="ds-in-bl return"><a href="javascript:history.back(-1);"><img src="<?php echo env('APP_URL'); ?>/images/weixin/return.png" alt="返回"></a></div>
<div class="ds-in-bl tit center"><span>领券中心</span></div>
<?php if(isset($_SESSION['weixin_user_info']['access_token'])){ ?><div class="ds-in-bl nav_menu"><a href="<?php echo route('weixin_user_bonus_list'); ?>" style="color:#999;">我的优惠券</a></div><?php } ?>
</div>
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/layer/mobile/layer.js"></script>
@ -19,11 +20,13 @@
<div class="bonus_list">
<?php if($list){foreach($list as $k=>$v){ ?>
<a href="javascript:;" onclick="getbonus(<?php echo $v['id']; ?>)">
<div class="flow-have-adr">
<p class="f-h-adr-title"><label><?php echo $v['bonus']['name']; ?></label><span class="ect-colory fr"><small>¥</small><?php echo $v['bonus']['money']; ?></span><div class="cl"></div></p>
<p class="f-h-adr-con">有效期至<?php echo $v['bonus']['end_time']; ?> <span class="fr">满<?php echo $v['bonus']['min_amount']; ?>可用</span></p>
<p class="f-h-adr-title"><label><?php echo $v['name']; ?></label><span class="ect-colory fr"><small>¥</small><?php echo $v['money']; ?></span><div class="cl"></div></p>
<p class="f-h-adr-con">有效期至<?php echo $v['end_time']; ?> <span class="fr">满<?php echo $v['min_amount']; ?>可用</span></p>
<!-- <div class="adr-edit-del">说明</div> -->
</div>
</a>
<?php }}else{ ?>
<div style="text-align:center;line-height:40px;color:#999;">暂无记录</div>
<?php } ?>
@ -87,6 +90,48 @@ $(function(){
}
});
});
function getbonus(bonus_id)
{
var url = '<?php echo env('APP_API_URL').'/user_bonus_add'; ?>';
var access_token = '<?php if(isset($_SESSION['weixin_user_info']['access_token'])){echo $_SESSION['weixin_user_info']['access_token'];} ?>';
if(access_token=='')
{
//提示
layer.open({
content: '请先登录'
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
setTimeout("location.href = '<?php echo route('weixin_login',array('return_url'=>route('weixin_bonus_list'))); ?>'",1000);
return false;
}
$.post(url,{bonus_id:bonus_id,access_token:access_token},function(res)
{
if(res.code==0)
{
//提示
layer.open({
content: '获取成功'
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
location.href = '<?php echo route('weixin_user_bonus_list'); ?>';
}
else
{
layer.open({
content: res.msg
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
}
},'json');
}
</script>
@include('weixin.common.footer')

34
resources/views/weixin/user/index.blade.php

@ -137,22 +137,22 @@
<!--资金管理-e-->
<div class="floor list7 mt10">
<div class="myorder p">
<div class="content30">
<a href="javascript:void(0);" onclick="alert('请购买商业正版哦!');">
<div class="order">
<div class="fl">
<img src="<?php echo env('APP_URL'); ?>/images/weixin/w1.png">
<span>我的分销</span>
</div>
<div class="fr">
<i class="Mright"></i>
</div>
<div class="myorder p">
<div class="content30">
<a href="<?php echo route('weixin_user_distribution'); ?>">
<div class="order">
<div class="fl">
<img src="<?php echo env('APP_URL'); ?>/images/weixin/w1.png">
<span>我的分销</span>
</div>
</a>
</div>
<div class="fr">
<i class="Mright"></i>
</div>
</div>
</a>
</div>
<div class="myorder p">
</div>
<div class="myorder p">
<div class="content30">
<a href="/index.php/Mobile/User/comment/status/1.html">
<div class="order">
@ -167,7 +167,7 @@
</a>
</div>
</div>
<div class="myorder p">
<!-- <div class="myorder p">
<div class="content30">
<a href="/index.php/Mobile/Goods/integralMall.html">
<div class="order">
@ -181,10 +181,10 @@
</div>
</a>
</div>
</div>
</div> -->
<div class="myorder p">
<div class="content30">
<a href="/index.php/Mobile/Activity/coupon_list.html">
<a href="<?php echo route('weixin_bonus_list',array('parent_id'=>$_SESSION['weixin_user_info']['id'])); ?>">
<div class="order">
<div class="fl">
<img src="<?php echo env('APP_URL'); ?>/images/weixin/w7.png">

1
resources/views/weixin/user/userBonusList.blade.php

@ -6,6 +6,7 @@
<div class="classreturn loginsignup">
<div class="ds-in-bl return"><a href="javascript:history.back(-1);"><img src="<?php echo env('APP_URL'); ?>/images/weixin/return.png" alt="返回"></a></div>
<div class="ds-in-bl tit center"><span>我的优惠券</span></div>
<div class="ds-in-bl nav_menu"><a href="<?php echo route('weixin_bonus_list'); ?>" style="color:#999;">领券</a></div>
</div>
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/layer/mobile/layer.js"></script>

103
resources/views/weixin/user/userDistribution.blade.php

@ -0,0 +1,103 @@
<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>我的分销</title><meta name="keywords" content="关键词"><meta name="description" content="描述"><meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
<link href="<?php echo env('APP_URL'); ?>/css/weixin/style.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/weixin/mobile.js"></script>
<link href="<?php echo env('APP_URL'); ?>/css/font-awesome.min.css" type="text/css" rel="stylesheet"></head><body>
<div class="classreturn loginsignup">
<div class="ds-in-bl return"><a href="javascript:history.back(-1);"><img src="<?php echo env('APP_URL'); ?>/images/weixin/return.png" alt="返回"></a></div>
<div class="ds-in-bl tit center"><span>我的分销</span></div>
</div>
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/layer/mobile/layer.js"></script>
<style>
.account{text-align:center;margin-top:30px;}
.account .icon{color:#FFCC00;font-size:100px;}
.account .money{color:#353535;font-size:36px;}
.account .tit{color:#000;font-size:18px;}
.banner_tit{font-size:18px;font-weight:400;background-color:#fff;color:#f23030;height:46px;line-height:46px;padding-left:10px;padding-right:10px;border-bottom:1px solid #eee;text-align:center;}
</style>
<div class="floor account">
<div class="icon"><i class="fa fa-diamond"></i></div>
<div class="tit">累积佣金</div>
<div class="money"><small></small><?php echo $user_info['commission']; ?></div>
</div>
<div class="floor">
<div class="banner_tit">- 我的推荐 -</div>
<?php if($list){ ?>
<ul class="goods_list_s cl">
<?php foreach($list as $k=>$v){ ?>
<li><span class="goods_thumb" style="width:72px;height:72px;"><img style="width:72px;height:72px;" alt="<?php echo $v['user_name']; ?>" src="<?php echo $v['head_img']; ?>"></span>
<div class="goods_info"><p class="goods_tit"><?php echo $v['user_name']; ?></p>
<p style="line-height:24px;">佣金:<?php echo $v['commission']; ?></p>
<p style="line-height:24px;">注册时间:<?php echo date('Y-m-d',$v['add_time']); ?></p>
</div></li>
<?php } ?>
</ul>
<?php }else{ ?>
<div style="text-align:center;line-height:40px;color:#999;">暂无记录</div>
<?php } ?>
</div>
<script>
$(function(){
var ajaxload = false;
var maxpage = false;
var startpage = 1;
var totalpage = <?php echo $totalpage; ?>;
var tmp_url = window.location.href;
msg = tmp_url.split("#");
tmp_url = msg[0];
$(window).scroll(function ()
{
var listheight = $(".goods_list_s").outerHeight();
if ($(document).scrollTop() + $(window).height() >= listheight)
{
if(startpage >= totalpage)
{
//$("#submit_bt_one").html("已是最后一页,没有更多数据!");
return false;
}
if(!ajaxload && !maxpage)
{
ajaxload = true;
//$("#submit_bt_one").html("努力加载中...");
var url = tmp_url;
var nextpage = startpage+1;
$.get(url,{page_ajax:1,page:nextpage},function(res)
{
if(res)
{
$(".goods_list_s").append(res);
startpage++;
if(startpage >= totalpage)
{
maxpage = true;
//$("#submit_bt_one").html("已是最后一页,没有更多数据!");
}
else
{
//$("#submit_bt_one").html("点击加载更多");
}
ajaxload = false;
}
else
{
//$("#submit_bt_one").html("请求失败,请稍候再试!");
ajaxload = false;
}
},'json');
}
}
});
});
</script>
@include('weixin.common.footer')
</body></html>

4
routes/web.php

@ -87,6 +87,7 @@ Route::group(['prefix' => 'weixin', 'namespace' => 'Weixin', 'middleware' => ['w
Route::get('/user_money_list', 'UserController@userMoneyList')->name('weixin_user_money_list');
Route::get('/user_point_list', 'UserController@userPointList')->name('weixin_user_point_list');
Route::get('/user_message_list', 'UserController@userMessageList')->name('weixin_user_message_list');
Route::get('/user_distribution', 'UserController@userDistribution')->name('weixin_user_distribution');
//用户充值
Route::get('/user_recharge', 'UserController@userRecharge')->name('weixin_user_recharge');
Route::get('/user_recharge_order', 'UserController@userRechargeOrder')->name('weixin_user_recharge_order');
@ -145,6 +146,8 @@ Route::group(['prefix' => 'dataapi', 'namespace' => 'Api', 'middleware' => ['web
Route::post('/wx_register', 'UserController@wxRegister'); //注册
Route::post('/wx_login', 'UserController@wxLogin'); //登录
Route::post('/wx_oauth_register', 'UserController@wxOauthRegister'); //微信授权注册登录
//可用的优惠券列表
Route::get('/bonus_list', 'BonusController@bonusList'); //可用获取的优惠券列表
});
//API接口路由,需token验证
@ -200,7 +203,6 @@ Route::group(['prefix' => 'dataapi', 'namespace' => 'Api', 'middleware' => ['web
Route::get('/user_available_bonus_list', 'UserBonusController@userAvailableBonusList'); //用户结算时获取可用优惠券列表
Route::get('/user_bonus_list', 'UserBonusController@userBonusList'); //用户优惠券列表
Route::post('/user_bonus_add', 'UserBonusController@userBonusAdd'); //用户获取优惠券
Route::get('/bonus_list', 'BonusController@bonusList'); //可用获取的优惠券列表
Route::post('/bonus_add', 'BonusController@bonusAdd'); //添加优惠券
Route::post('/bonus_update', 'BonusController@bonusUpdate'); //修改优惠券
Route::post('/bonus_delete', 'BonusController@bonusDelete'); //删除优惠券

Loading…
Cancel
Save