Merge branch 'master' of http://114.215.101.231:8099/lihan/integral into lilijuan
正在显示
15 个修改的文件
包含
397 行增加
和
67 行删除
@@ -127,14 +127,23 @@ class FriendController extends HomeBaseController | @@ -127,14 +127,23 @@ class FriendController extends HomeBaseController | ||
127 | if ($total > 0) { | 127 | if ($total > 0) { |
128 | if (Db::name('user')->where(['id' => $uid])->setDec('balance', $total)) { | 128 | if (Db::name('user')->where(['id' => $uid])->setDec('balance', $total)) { |
129 | if (Db::name('user')->where(['id' => $friend_id])->setInc('balance', $total)) { | 129 | if (Db::name('user')->where(['id' => $friend_id])->setInc('balance', $total)) { |
130 | - //插入赠送记录日志log | 130 | + //记录日志log |
131 | $log = [ | 131 | $log = [ |
132 | - 'uid' => $friend_id, | ||
133 | - 'create_time' => time(), | ||
134 | - 'balance' => $total, | ||
135 | - 'type' => 3 | 132 | + 0 => [ |
133 | + 'uid' => $friend_id, | ||
134 | + 'create_time' => time(), | ||
135 | + 'balance' => $total, | ||
136 | + 'type' => 3 | ||
137 | + ], | ||
138 | + 1 => [ | ||
139 | + 'uid' => session('user.id'), | ||
140 | + 'create_time' => time(), | ||
141 | + 'balance' => $total, | ||
142 | + 'type' => 4 | ||
143 | + ] | ||
136 | ]; | 144 | ]; |
137 | - if (Db::name('zj_integral_log')->insert($log)) { | 145 | + |
146 | + if (Db::name('zj_integral_log')->insertAll($log)) { | ||
138 | Db::commit(); | 147 | Db::commit(); |
139 | $tag = true; | 148 | $tag = true; |
140 | } else { | 149 | } else { |
@@ -42,11 +42,6 @@ class IndexController extends HomeBaseController | @@ -42,11 +42,6 @@ class IndexController extends HomeBaseController | ||
42 | ]); | 42 | ]); |
43 | } | 43 | } |
44 | 44 | ||
45 | - //强制绑定手机页面 | ||
46 | - public function login() { | ||
47 | - return $this->fetch(); | ||
48 | - } | ||
49 | - | ||
50 | /** | 45 | /** |
51 | * 易连云打印机demo | 46 | * 易连云打印机demo |
52 | */ | 47 | */ |
@@ -9,23 +9,29 @@ | @@ -9,23 +9,29 @@ | ||
9 | namespace app\integral\controller; | 9 | namespace app\integral\controller; |
10 | use app\integral\model\IntegralModel; | 10 | use app\integral\model\IntegralModel; |
11 | use think\Db; | 11 | use think\Db; |
12 | -use cmf\controller\PayBaseController; | 12 | +use cmf\controller\NoneBaseController; |
13 | 13 | ||
14 | -class IntegralController extends PayBaseController | 14 | +class IntegralController extends NoneBaseController |
15 | { | 15 | { |
16 | - public function autoExecute() { | ||
17 | - $model = new IntegralModel; | ||
18 | - $give = Db::name('zj_integral_give')->where(['balance'=>['neq', 0]])->field('id,uid,balance,total,ratio')->select(); | ||
19 | - foreach ($give as $item) { | ||
20 | - $give_balance = (int)($item['total'] * $item['ratio'] / 100); | ||
21 | - $remain_balance = $item['balance'] - $give_balance; | ||
22 | - if($remain_balance < 0) { | ||
23 | - $give_balance = $remain_balance; | ||
24 | - $remain_balance = 0; | 16 | + public function autoExecuteIntegral() |
17 | + { | ||
18 | + $start = date('23:57'); | ||
19 | + $end = date('23:59'); | ||
20 | + $now = date('H:i'); | ||
21 | + if ($now >= $start && $now <= $end) { | ||
22 | + $model = new IntegralModel; | ||
23 | + $give = Db::name('zj_integral_give')->where(['balance' => ['neq', 0]])->field('id,uid,balance,total,ratio')->select(); | ||
24 | + foreach ($give as $item) { | ||
25 | + $give_balance = (int)($item['total'] * $item['ratio'] / 100); | ||
26 | + $remain_balance = $item['balance'] - $give_balance; | ||
27 | + if ($remain_balance < 0) { | ||
28 | + $give_balance = $remain_balance; | ||
29 | + $remain_balance = 0; | ||
30 | + } | ||
31 | + Db::name('user')->where(['id' => $item['uid']])->setInc('balance', $give_balance); | ||
32 | + $model->insertIntegralLog($item['id'], $item['uid'], time(), $give_balance, 1); | ||
33 | + $model->updateIntegralGive($item['id'], $remain_balance); | ||
25 | } | 34 | } |
26 | - Db::name('user')->where(['id'=>$item['uid']])->setInc('balance', $give_balance); | ||
27 | - $model->insertIntegralLog($item['id'], $item['uid'], time(), $give_balance, 1); | ||
28 | - $model->updateIntegralGive($item['id'], $remain_balance); | ||
29 | } | 35 | } |
30 | } | 36 | } |
31 | } | 37 | } |
app/login/controller/LoginController.php
0 → 100644
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: yhbr | ||
5 | + * Date: 2018/11/10 | ||
6 | + * Time: 9:50 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace app\login\controller; | ||
10 | + | ||
11 | + | ||
12 | +use cmf\controller\NoneBaseController; | ||
13 | + | ||
14 | +class LoginController extends NoneBaseController | ||
15 | +{ | ||
16 | + | ||
17 | + //强制绑定手机页面 | ||
18 | + public function login() { | ||
19 | + return $this->fetch(); | ||
20 | + } | ||
21 | + | ||
22 | +} |
@@ -7,10 +7,10 @@ | @@ -7,10 +7,10 @@ | ||
7 | */ | 7 | */ |
8 | 8 | ||
9 | namespace app\sms\controller; | 9 | namespace app\sms\controller; |
10 | -use cmf\controller\HomeBaseController; | 10 | +use cmf\controller\NoneBaseController; |
11 | use think\Db; | 11 | use think\Db; |
12 | 12 | ||
13 | -class SmsController extends HomeBaseController | 13 | +class SmsController extends NoneBaseController |
14 | { | 14 | { |
15 | public function sendSms() | 15 | public function sendSms() |
16 | { | 16 | { |
@@ -34,20 +34,52 @@ class SmsController extends HomeBaseController | @@ -34,20 +34,52 @@ class SmsController extends HomeBaseController | ||
34 | } | 34 | } |
35 | } | 35 | } |
36 | 36 | ||
37 | + //单纯发送验证码 | ||
37 | public function checkCode() | 38 | public function checkCode() |
38 | { | 39 | { |
39 | $mobile = request()->param('mobile'); | 40 | $mobile = request()->param('mobile'); |
40 | $code = request()->param('code'); | 41 | $code = request()->param('code'); |
41 | $data = Db::name('zj_code')->field('mobile,code,expire_time')->where(['mobile' => $mobile])->find(); | 42 | $data = Db::name('zj_code')->field('mobile,code,expire_time')->where(['mobile' => $mobile])->find(); |
42 | - if (time() > $data['expire_time']) { | ||
43 | - $this->success('验证码已过期,请重新发送', '', false); | 43 | + if (!empty($data)) { |
44 | + if (time() > $data['expire_time']) { | ||
45 | + $this->success('验证码已过期,请重新发送', '', false); | ||
46 | + } else { | ||
47 | + if ($code == $data['code'] && $code != null && $data['code'] != null && $mobile == $data['mobile']) { | ||
48 | + Db::name('zj_code')->where(['mobile' => $mobile])->update(['code' => '']); | ||
49 | + $this->success('身份信息核实成功', url(''), true); | ||
50 | + } else { | ||
51 | + $this->success('验证码有误', '', false); | ||
52 | + } | ||
53 | + } | ||
44 | } else { | 54 | } else { |
45 | - if ($code == $data['code'] && $code != null && $data['code'] != null && $mobile == $data['mobile']) { | ||
46 | - Db::name('zj_code')->where(['mobile' => $mobile])->update(['code' => '']); | ||
47 | - $this->success('身份信息核实成功', url(''), true); | 55 | + $this->success('验证码有误', '', false); |
56 | + } | ||
57 | + } | ||
58 | + | ||
59 | + //修改密码、个人信息时的校验(必须验证输入手机号和原绑定手机号一致) | ||
60 | + public function checkCodeS() | ||
61 | + { | ||
62 | + $mobile = request()->param('mobile'); | ||
63 | + $code = request()->param('code'); | ||
64 | + $data = Db::name('zj_code')->field('mobile,code,expire_time')->where(['mobile' => $mobile])->find(); | ||
65 | + $mobile = DB::name('user')->where(['id' => session('user.id')])->value('mobile'); | ||
66 | + if (!empty($data)) { | ||
67 | + if ($mobile == $data['mobile']) { | ||
68 | + if (time() > $data['expire_time']) { | ||
69 | + $this->success('验证码已过期,请重新发送', '', false); | ||
70 | + } else { | ||
71 | + if ($code == $data['code'] && $code != null && $data['code'] != null && $mobile == $data['mobile']) { | ||
72 | + Db::name('zj_code')->where(['mobile' => $mobile])->update(['code' => '']); | ||
73 | + $this->success('身份信息核实成功', url(''), true); | ||
74 | + } else { | ||
75 | + $this->success('验证码有误', '', false); | ||
76 | + } | ||
77 | + } | ||
48 | } else { | 78 | } else { |
49 | - $this->success('验证码有误', '', false); | 79 | + $this->success('请输入原始绑定手机号码', '', false); |
50 | } | 80 | } |
81 | + } else { | ||
82 | + $this->success('验证码有误', '', false); | ||
51 | } | 83 | } |
52 | } | 84 | } |
53 | 85 | ||
@@ -56,16 +88,20 @@ class SmsController extends HomeBaseController | @@ -56,16 +88,20 @@ class SmsController extends HomeBaseController | ||
56 | $mobile = request()->param('mobile'); | 88 | $mobile = request()->param('mobile'); |
57 | $code = request()->param('code'); | 89 | $code = request()->param('code'); |
58 | $data = Db::name('zj_code')->field('mobile,code,expire_time')->where(['mobile' => $mobile])->find(); | 90 | $data = Db::name('zj_code')->field('mobile,code,expire_time')->where(['mobile' => $mobile])->find(); |
59 | - if (time() > $data['expire_time']) { | ||
60 | - $this->success('验证码已过期,请重新发送', '', false); | ||
61 | - } else { | ||
62 | - if ($code == $data['code'] && $code != null && $data['code'] != null && $mobile == $data['mobile']) { | ||
63 | - Db::name('zj_code')->where(['mobile' => $mobile])->update(['code' => '']); | ||
64 | - Db::name('user')->update(['id' => session('user.id'), 'mobile' => $mobile]); | ||
65 | - $this->success('绑定成功', url(''), true); | 91 | + if (!empty($data)) { |
92 | + if (time() > $data['expire_time']) { | ||
93 | + $this->success('验证码已过期,请重新发送', '', false); | ||
66 | } else { | 94 | } else { |
67 | - $this->success('验证码有误', '', false); | 95 | + if ($code == $data['code'] && $code != null && $data['code'] != null && $mobile == $data['mobile']) { |
96 | + Db::name('zj_code')->where(['mobile' => $mobile])->update(['code' => '']); | ||
97 | + Db::name('user')->update(['id' => session('user.id'), 'mobile' => $mobile]); | ||
98 | + $this->success('绑定成功', url(''), true); | ||
99 | + } else { | ||
100 | + $this->success('验证码有误', '', false); | ||
101 | + } | ||
68 | } | 102 | } |
103 | + } else { | ||
104 | + $this->success('验证码有误', '', false); | ||
69 | } | 105 | } |
70 | } | 106 | } |
71 | 107 |
@@ -56,9 +56,9 @@ class AdminIndexController extends AdminBaseController | @@ -56,9 +56,9 @@ class AdminIndexController extends AdminBaseController | ||
56 | */ | 56 | */ |
57 | public function index() | 57 | public function index() |
58 | { | 58 | { |
59 | - $where = ['user_type'=>2]; | ||
60 | - $where1=[]; | ||
61 | - $where3=[]; | 59 | + $where = ['user_type' => 2]; |
60 | + $where1 = []; | ||
61 | + $where3 = []; | ||
62 | $param = request()->param(); | 62 | $param = request()->param(); |
63 | 63 | ||
64 | 64 | ||
@@ -67,28 +67,73 @@ class AdminIndexController extends AdminBaseController | @@ -67,28 +67,73 @@ class AdminIndexController extends AdminBaseController | ||
67 | $keyword = $param['keyword']; | 67 | $keyword = $param['keyword']; |
68 | $keywordComplex['mobile|id'] = $keyword; | 68 | $keywordComplex['mobile|id'] = $keyword; |
69 | } | 69 | } |
70 | - if (!empty($param['start_time'])){ | ||
71 | - $where['create_time']=['egt',strtotime($param['start_time'])]; | ||
72 | - } | ||
73 | - if (!empty($param['end_time'])){ | ||
74 | - $where1['create_time']=['elt',strtotime($param['end_time'])]; | 70 | + if (!empty($param['start_time'])) { |
71 | + $where['create_time'] = ['egt', strtotime($param['start_time'])]; | ||
72 | + } | ||
73 | + if (!empty($param['end_time'])) { | ||
74 | + $where1['create_time'] = ['elt', strtotime($param['end_time'])]; | ||
75 | } | 75 | } |
76 | - if (!empty($param['min'])){ | ||
77 | - $where['balance']=['egt',$param['min']]; | 76 | + if (!empty($param['min'])) { |
77 | + $where['balance'] = ['egt', $param['min']]; | ||
78 | } | 78 | } |
79 | - if (!empty($param['max'])){ | ||
80 | - $where1['balance']=['elt',$param['max']]; | 79 | + if (!empty($param['max'])) { |
80 | + $where1['balance'] = ['elt', $param['max']]; | ||
81 | } | 81 | } |
82 | 82 | ||
83 | $uid = (isset($param['uid'])) ? $param['uid'] : null; | 83 | $uid = (isset($param['uid'])) ? $param['uid'] : null; |
84 | //下级人员 | 84 | //下级人员 |
85 | - if($uid) { | 85 | + if ($uid) { |
86 | $where3['parent_id'] = ['eq', $uid]; | 86 | $where3['parent_id'] = ['eq', $uid]; |
87 | } | 87 | } |
88 | 88 | ||
89 | $usersQuery = Db::name('user'); | 89 | $usersQuery = Db::name('user'); |
90 | 90 | ||
91 | $list = $usersQuery->whereOr($keywordComplex)->where($where)->where($where1)->where($where3)->order("create_time DESC")->paginate(10); | 91 | $list = $usersQuery->whereOr($keywordComplex)->where($where)->where($where1)->where($where3)->order("create_time DESC")->paginate(10); |
92 | + //获取订单数和会员专区金额统计 | ||
93 | + foreach ($list as $k => $item) { | ||
94 | + $uid = $item['id']; | ||
95 | + $role = $item['role']; | ||
96 | + //如果此人为普通会员,只统计其金额总和 | ||
97 | + if ($role == 1) { | ||
98 | + $map = [ | ||
99 | + 'uid' => ['eq', $item['id']], | ||
100 | + 'pay_type' => ['eq', 3], | ||
101 | + 'step' => ['neq', 1] | ||
102 | + ]; | ||
103 | + $data = Db::name('zj_order')->where($map)->field('sum(whole) as whole,sum(whole_num) as whole_num')->select(); | ||
104 | + $whole = $data[0]['whole']; | ||
105 | + $whole_num = $data[0]['whole_num']; | ||
106 | + $total = $whole - $whole_num; | ||
107 | + } else { | ||
108 | + //先查此人的下级 | ||
109 | + $son_arr = Db::name('user')->where(['parent_id' => $item['id']])->field('id')->select()->toArray(); | ||
110 | + if (!empty($son_arr)) { | ||
111 | + $son_str = ''; | ||
112 | + foreach ($son_arr as $key => $v) { | ||
113 | + if ($key == count($son_arr) - 1) { | ||
114 | + $son_str .= $v['id']; | ||
115 | + } else { | ||
116 | + $son_str .= $v['id'] . ','; | ||
117 | + } | ||
118 | + } | ||
119 | + $map = [ | ||
120 | + 'uid' => ['in', $son_str], | ||
121 | + 'pay_type' => ['eq', 3], | ||
122 | + 'step' => ['neq', 1] | ||
123 | + ]; | ||
124 | + $data = Db::name('zj_order')->where($map)->field('sum(whole) as whole,sum(whole_num) as whole_num')->select(); | ||
125 | + $whole = $data[0]['whole']; | ||
126 | + $whole_num = $data[0]['whole_num']; | ||
127 | + $total = $whole - $whole_num; | ||
128 | + } else { | ||
129 | + $total = 0; | ||
130 | + } | ||
131 | + } | ||
132 | + $item['total'] = $total; | ||
133 | + $list[$k] = $item; | ||
134 | + } | ||
135 | + | ||
136 | + | ||
92 | // 获取分页显示 | 137 | // 获取分页显示 |
93 | $list->appends($param); | 138 | $list->appends($param); |
94 | $this->assign('start_time', isset($param['start_time']) ? $param['start_time'] : ''); | 139 | $this->assign('start_time', isset($param['start_time']) ? $param['start_time'] : ''); |
@@ -158,12 +203,13 @@ class AdminIndexController extends AdminBaseController | @@ -158,12 +203,13 @@ class AdminIndexController extends AdminBaseController | ||
158 | /** | 203 | /** |
159 | * 用户积分详情 | 204 | * 用户积分详情 |
160 | */ | 205 | */ |
161 | - public function balance(){ | ||
162 | - if ($this->request->param()){ | ||
163 | - $id=input('param.id'); | ||
164 | - $all=Db::name('zj_integral_log')->where('uid',$id)->paginate(20); | ||
165 | - $this->assign('list',$all); | ||
166 | - $this->assign('page',$all->render()); | 206 | + public function balance() |
207 | + { | ||
208 | + if ($this->request->param()) { | ||
209 | + $id = input('param.id'); | ||
210 | + $all = Db::name('zj_integral_log')->where('uid', $id)->paginate(20); | ||
211 | + $this->assign('list', $all); | ||
212 | + $this->assign('page', $all->render()); | ||
167 | return $this->fetch(); | 213 | return $this->fetch(); |
168 | } | 214 | } |
169 | } | 215 | } |
@@ -380,10 +380,13 @@ class CenterController extends HomeBaseController | @@ -380,10 +380,13 @@ class CenterController extends HomeBaseController | ||
380 | $type = request()->param('type'); | 380 | $type = request()->param('type'); |
381 | if ($type == 1) { | 381 | if ($type == 1) { |
382 | $title = '积分获取记录'; | 382 | $title = '积分获取记录'; |
383 | + $where['type'] = ['in', "1,3"]; | ||
383 | } else { | 384 | } else { |
384 | $title = '积分使用记录'; | 385 | $title = '积分使用记录'; |
386 | + $where['type'] = ['in', "2,4"]; | ||
385 | } | 387 | } |
386 | - $log = Db::name('zj_integral_log')->where(['uid' => session('user.id'), 'type' => $type])->order('create_time DESC')->select(); | 388 | + $where['uid'] = ['eq', session('user.id')]; |
389 | + $log = Db::name('zj_integral_log')->where($where)->order('create_time DESC')->select(); | ||
387 | return $this->fetch('integral_log', [ | 390 | return $this->fetch('integral_log', [ |
388 | 'log' => $log, | 391 | 'log' => $log, |
389 | 'title' => $title | 392 | 'title' => $title |
@@ -36,6 +36,7 @@ | @@ -36,6 +36,7 @@ | ||
36 | <th>下单量</th> | 36 | <th>下单量</th> |
37 | <th style="width:160px">{:lang('REGISTRATION_TIME')}</th> | 37 | <th style="width:160px">{:lang('REGISTRATION_TIME')}</th> |
38 | <th>积分余额</th> | 38 | <th>积分余额</th> |
39 | + <th>会员专区金额统计</th> | ||
39 | <th>{:lang('STATUS')}</th> | 40 | <th>{:lang('STATUS')}</th> |
40 | <th style="width: 450px;">{:lang('ACTIONS')}</th> | 41 | <th style="width: 450px;">{:lang('ACTIONS')}</th> |
41 | </tr> | 42 | </tr> |
@@ -52,6 +53,7 @@ | @@ -52,6 +53,7 @@ | ||
52 | <td>{$vo.order_count}</td> | 53 | <td>{$vo.order_count}</td> |
53 | <td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td> | 54 | <td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td> |
54 | <td>{$vo.balance}</td> | 55 | <td>{$vo.balance}</td> |
56 | + <td>{$vo.total}</td> | ||
55 | <td>{$user_statuses[$vo['user_status']]}</td> | 57 | <td>{$user_statuses[$vo['user_status']]}</td> |
56 | <td> | 58 | <td> |
57 | <neq name="vo.id" value="1"> | 59 | <neq name="vo.id" value="1"> |
@@ -65,7 +67,9 @@ | @@ -65,7 +67,9 @@ | ||
65 | </empty> | 67 | </empty> |
66 | <a href="{:url('balance',array('id'=>$vo['id']))}">查看积分详情</a> | | 68 | <a href="{:url('balance',array('id'=>$vo['id']))}">查看积分详情</a> | |
67 | <a href="{:url('admin/zj_order/index',array('uid'=>$vo.id))}">查看用户订单</a> | | 69 | <a href="{:url('admin/zj_order/index',array('uid'=>$vo.id))}">查看用户订单</a> | |
70 | + <if condition="$vo.parent_id eq ''"> | ||
68 | <a href="{:url('admin/User/role', ['uid'=>$vo['id']])}">变更角色</a> | 71 | <a href="{:url('admin/User/role', ['uid'=>$vo['id']])}">变更角色</a> |
72 | + </if> | ||
69 | <if condition="$vo['role'] eq '2'"> | <a href="{:url('user/adminIndex/index',['uid'=>$vo['id']])}">查看下级人员</a></if> | 73 | <if condition="$vo['role'] eq '2'"> | <a href="{:url('user/adminIndex/index',['uid'=>$vo['id']])}">查看下级人员</a></if> |
70 | <else/> | 74 | <else/> |
71 | <a style="color: #ccc;">{:lang('BLOCK_USER')}</a> | 75 | <a style="color: #ccc;">{:lang('BLOCK_USER')}</a> |
@@ -151,7 +151,7 @@ | @@ -151,7 +151,7 @@ | ||
151 | alert('请输入验证码'); | 151 | alert('请输入验证码'); |
152 | }else { | 152 | }else { |
153 | $.ajax({ | 153 | $.ajax({ |
154 | - url:"{:url('sms/Sms/checkCode')}", | 154 | + url:"{:url('sms/Sms/checkCodeS')}", |
155 | data:{ | 155 | data:{ |
156 | mobile:mobile, | 156 | mobile:mobile, |
157 | code:code | 157 | code:code |
@@ -151,7 +151,7 @@ | @@ -151,7 +151,7 @@ | ||
151 | alert('请输入验证码'); | 151 | alert('请输入验证码'); |
152 | }else { | 152 | }else { |
153 | $.ajax({ | 153 | $.ajax({ |
154 | - url:"{:url('sms/Sms/checkCode')}", | 154 | + url:"{:url('sms/Sms/checkCodeS')}", |
155 | data:{ | 155 | data:{ |
156 | mobile:mobile, | 156 | mobile:mobile, |
157 | code:code | 157 | code:code |
@@ -41,13 +41,16 @@ | @@ -41,13 +41,16 @@ | ||
41 | <div class="good_intergral"> | 41 | <div class="good_intergral"> |
42 | <p class="buy_good"> | 42 | <p class="buy_good"> |
43 | <if condition="$vo['type'] eq '1'"> | 43 | <if condition="$vo['type'] eq '1'"> |
44 | - 购买商品获得 | 44 | + 购买商品收入 |
45 | </if> | 45 | </if> |
46 | <if condition="$vo['type'] eq '2'"> | 46 | <if condition="$vo['type'] eq '2'"> |
47 | - 购买商品消费 | 47 | + 购买商品支出 |
48 | </if> | 48 | </if> |
49 | <if condition="$vo['type'] eq '3'"> | 49 | <if condition="$vo['type'] eq '3'"> |
50 | - 好友购买奖励 | 50 | + 好友赠送收入 |
51 | + </if> | ||
52 | + <if condition="$vo['type'] eq '4'"> | ||
53 | + 好友赠送支出 | ||
51 | </if> | 54 | </if> |
52 | </p> | 55 | </p> |
53 | <p class="good_date">{$vo.create_time|date='Y-m-d', ###}</p> | 56 | <p class="good_date">{$vo.create_time|date='Y-m-d', ###}</p> |
@@ -59,6 +59,10 @@ class HomeBaseController extends BaseController | @@ -59,6 +59,10 @@ class HomeBaseController extends BaseController | ||
59 | } | 59 | } |
60 | } | 60 | } |
61 | } | 61 | } |
62 | + }else { | ||
63 | + if(Db::name('user')->where(['id'=>session('user.id')])->value('mobile') == null) { | ||
64 | + $this->redirect(url('login/Login/login')); | ||
65 | + } | ||
62 | } | 66 | } |
63 | }else { | 67 | }else { |
64 | $this->error('请从微信浏览器打开'); | 68 | $this->error('请从微信浏览器打开'); |
1 | +<?php | ||
2 | +// +---------------------------------------------------------------------- | ||
3 | +// | bronet [ 以客户为中心 以奋斗者为本 ] | ||
4 | +// +---------------------------------------------------------------------- | ||
5 | +// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved. | ||
6 | +// +---------------------------------------------------------------------- | ||
7 | +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) | ||
8 | +// +--------------------------------------------------------------------- | ||
9 | +// | Author: Dean <zxxjjforever@163.com> | ||
10 | +// +---------------------------------------------------------------------- | ||
11 | +namespace cmf\controller; | ||
12 | + | ||
13 | +use app\user\model\UserModel; | ||
14 | +use think\Db; | ||
15 | +use app\admin\model\ThemeModel; | ||
16 | +use think\View; | ||
17 | + | ||
18 | +class NoneBaseController extends BaseController | ||
19 | +{ | ||
20 | + | ||
21 | + public function _initialize() | ||
22 | + { | ||
23 | + | ||
24 | + parent::_initialize(); // TODO: Change the autogenerated stub | ||
25 | + // 监听home_init | ||
26 | + hook('home_init'); | ||
27 | + parent::_initialize(); | ||
28 | + $siteInfo = cmf_get_site_info(); | ||
29 | + View::share('site_info', $siteInfo); | ||
30 | + } | ||
31 | + | ||
32 | + public function _initializeView() | ||
33 | + { | ||
34 | + $cmfThemePath = config('cmf_theme_path'); | ||
35 | + $cmfDefaultTheme = cmf_get_current_theme(); | ||
36 | + | ||
37 | + $themePath = "{$cmfThemePath}{$cmfDefaultTheme}"; | ||
38 | + | ||
39 | + $root = cmf_get_root(); | ||
40 | + //使cdn设置生效 | ||
41 | + $cdnSettings = cmf_get_option('cdn_settings'); | ||
42 | + if (empty($cdnSettings['cdn_static_root'])) { | ||
43 | + $viewReplaceStr = [ | ||
44 | + '__ROOT__' => $root, | ||
45 | + '__TMPL__' => "{$root}/{$themePath}", | ||
46 | + '__STATIC__' => "{$root}/static", | ||
47 | + '__WEB_ROOT__' => $root | ||
48 | + ]; | ||
49 | + } else { | ||
50 | + $cdnStaticRoot = rtrim($cdnSettings['cdn_static_root'], '/'); | ||
51 | + $viewReplaceStr = [ | ||
52 | + '__ROOT__' => $root, | ||
53 | + '__TMPL__' => "{$cdnStaticRoot}/{$themePath}", | ||
54 | + '__STATIC__' => "{$cdnStaticRoot}/static", | ||
55 | + '__WEB_ROOT__' => $cdnStaticRoot | ||
56 | + ]; | ||
57 | + } | ||
58 | + | ||
59 | + $viewReplaceStr = array_merge(config('view_replace_str'), $viewReplaceStr); | ||
60 | + config('template.view_base', "{$themePath}/"); | ||
61 | + config('view_replace_str', $viewReplaceStr); | ||
62 | + | ||
63 | + $themeErrorTmpl = "{$themePath}/error.html"; | ||
64 | + if (file_exists_case($themeErrorTmpl)) { | ||
65 | + config('dispatch_error_tmpl', $themeErrorTmpl); | ||
66 | + } | ||
67 | + | ||
68 | + $themeSuccessTmpl = "{$themePath}/success.html"; | ||
69 | + if (file_exists_case($themeSuccessTmpl)) { | ||
70 | + config('dispatch_success_tmpl', $themeSuccessTmpl); | ||
71 | + } | ||
72 | + | ||
73 | + | ||
74 | + } | ||
75 | + | ||
76 | + /** | ||
77 | + * 加载模板输出 | ||
78 | + * @access protected | ||
79 | + * @param string $template 模板文件名 | ||
80 | + * @param array $vars 模板输出变量 | ||
81 | + * @param array $replace 模板替换 | ||
82 | + * @param array $config 模板参数 | ||
83 | + * @return mixed | ||
84 | + */ | ||
85 | + protected function fetch($template = '', $vars = [], $replace = [], $config = []) | ||
86 | + { | ||
87 | + $template = $this->parseTemplate($template); | ||
88 | + $more = $this->getThemeFileMore($template); | ||
89 | + $this->assign('theme_vars', $more['vars']); | ||
90 | + $this->assign('theme_widgets', $more['widgets']); | ||
91 | + return parent::fetch($template, $vars, $replace, $config); | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * 自动定位模板文件 | ||
96 | + * @access private | ||
97 | + * @param string $template 模板文件规则 | ||
98 | + * @return string | ||
99 | + */ | ||
100 | + private function parseTemplate($template) | ||
101 | + { | ||
102 | + // 分析模板文件规则 | ||
103 | + $request = $this->request; | ||
104 | + // 获取视图根目录 | ||
105 | + if (strpos($template, '@')) { | ||
106 | + // 跨模块调用 | ||
107 | + list($module, $template) = explode('@', $template); | ||
108 | + } | ||
109 | + | ||
110 | + $viewBase = config('template.view_base'); | ||
111 | + | ||
112 | + if ($viewBase) { | ||
113 | + // 基础视图目录 | ||
114 | + $module = isset($module) ? $module : $request->module(); | ||
115 | + $path = $viewBase . ($module ? $module . DS : ''); | ||
116 | + } else { | ||
117 | + $path = isset($module) ? APP_PATH . $module . DS . 'view' . DS : config('template.view_path'); | ||
118 | + } | ||
119 | + | ||
120 | + $depr = config('template.view_depr'); | ||
121 | + if (0 !== strpos($template, '/')) { | ||
122 | + $template = str_replace(['/', ':'], $depr, $template); | ||
123 | + $controller = cmf_parse_name($request->controller()); | ||
124 | + if ($controller) { | ||
125 | + if ('' == $template) { | ||
126 | + // 如果模板文件名为空 按照默认规则定位 | ||
127 | + $template = str_replace('.', DS, $controller) . $depr . $request->action(); | ||
128 | + } elseif (false === strpos($template, $depr)) { | ||
129 | + $template = str_replace('.', DS, $controller) . $depr . $template; | ||
130 | + } | ||
131 | + } | ||
132 | + } else { | ||
133 | + $template = str_replace(['/', ':'], $depr, substr($template, 1)); | ||
134 | + } | ||
135 | + return $path . ltrim($template, '/') . '.' . ltrim(config('template.view_suffix'), '.'); | ||
136 | + } | ||
137 | + | ||
138 | + /** | ||
139 | + * 获取模板文件变量 | ||
140 | + * @param string $file | ||
141 | + * @param string $theme | ||
142 | + * @return array | ||
143 | + */ | ||
144 | + private function getThemeFileMore($file, $theme = "") | ||
145 | + { | ||
146 | + | ||
147 | + //TODO 增加缓存 | ||
148 | + $theme = empty($theme) ? cmf_get_current_theme() : $theme; | ||
149 | + | ||
150 | + // 调试模式下自动更新模板 | ||
151 | + if (APP_DEBUG) { | ||
152 | + $themeModel = new ThemeModel(); | ||
153 | + $themeModel->updateTheme($theme); | ||
154 | + } | ||
155 | + | ||
156 | + $themePath = config('cmf_theme_path'); | ||
157 | + $file = str_replace('\\', '/', $file); | ||
158 | + $file = str_replace('//', '/', $file); | ||
159 | + $file = str_replace(['.html', '.php', $themePath . $theme . "/"], '', $file); | ||
160 | + | ||
161 | + $files = Db::name('theme_file')->field('more')->where(['theme' => $theme])->where(function ($query) use ($file) { | ||
162 | + $query->where(['is_public' => 1])->whereOr(['file' => $file]); | ||
163 | + })->select(); | ||
164 | + | ||
165 | + $vars = []; | ||
166 | + $widgets = []; | ||
167 | + foreach ($files as $file) { | ||
168 | + $oldMore = json_decode($file['more'], true); | ||
169 | + if (!empty($oldMore['vars'])) { | ||
170 | + foreach ($oldMore['vars'] as $varName => $var) { | ||
171 | + $vars[$varName] = $var['value']; | ||
172 | + } | ||
173 | + } | ||
174 | + | ||
175 | + if (!empty($oldMore['widgets'])) { | ||
176 | + foreach ($oldMore['widgets'] as $widgetName => $widget) { | ||
177 | + | ||
178 | + $widgetVars = []; | ||
179 | + if (!empty($widget['vars'])) { | ||
180 | + foreach ($widget['vars'] as $varName => $var) { | ||
181 | + $widgetVars[$varName] = $var['value']; | ||
182 | + } | ||
183 | + } | ||
184 | + | ||
185 | + $widget['vars'] = $widgetVars; | ||
186 | + $widgets[$widgetName] = $widget; | ||
187 | + } | ||
188 | + } | ||
189 | + } | ||
190 | + | ||
191 | + return ['vars' => $vars, 'widgets' => $widgets]; | ||
192 | + } | ||
193 | + | ||
194 | + public function checkUserLogin() | ||
195 | + { | ||
196 | + $userId = cmf_get_current_user_id(); | ||
197 | + if (empty($userId)) { | ||
198 | + $this->error("用户尚未登录", url("user/login/index")); | ||
199 | + } | ||
200 | + } | ||
201 | + | ||
202 | +} |
@@ -8,7 +8,7 @@ class Doc | @@ -8,7 +8,7 @@ class Doc | ||
8 | 'version'=>'1.0.0', | 8 | 'version'=>'1.0.0', |
9 | 'copyright'=>'银河百荣科技', | 9 | 'copyright'=>'银河百荣科技', |
10 | 'controller' => [ | 10 | 'controller' => [ |
11 | - 'api\\index\\controller\\IndexController' | 11 | + 'api\\home\\controller\\IndexController' |
12 | ], | 12 | ], |
13 | 'password'=>'bronet', | 13 | 'password'=>'bronet', |
14 | 'static_path'=>'', | 14 | 'static_path'=>'', |
-
请 注册 或 登录 后发表评论