作者 刘朕
1 个管道 的构建 通过 耗费 50 秒

业务员新增邮费设置

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 -namespace app\portal\controller;  
10 -  
11 -use cmf\controller\WeChatBaseController;  
12 -use think\Db;  
13 -  
14 -class OrderpageController extends WeChatBaseController{  
15 -  
16 - /**  
17 - * 显示平台订单页  
18 - */  
19 - public function order_page(){  
20 -  
21 - $indet_id = $this -> request -> param();  
22 - $uid = cmf_get_current_user_id();  
23 - if(!empty($indet_id['address_id'])){  
24 - $address = Db::name('address') -> where('id',$indet_id['address_id']) -> find();  
25 - $this -> assign('address',$address);  
26 - $this -> assign('address_id',$indet_id['address_id']);  
27 - }else{  
28 - $address = Db::name('address') -> where("uid=".$uid." and default_address=1 and delete_time = 0") -> find();  
29 - if(empty($address)){  
30 - $this -> assign('address',4);  
31 - $this -> assign('address_id','');  
32 - }else{  
33 - $indet_data = Db::name('indent') -> where("id",$indet_id['indet_id']) -> find();  
34 - if($indet_data['state'] == 4){  
35 - $indet_data_update['id'] = $indet_id['indet_id'];  
36 - $indet_data_update['indent_address'] = $address['id'];  
37 - $indet_data_update['name'] = $address['name'];  
38 - $indet_data_update['phone'] = $address['phone'];  
39 - Db::name('indent') -> update($indet_data_update);  
40 - }  
41 - $this -> assign('address',$address);  
42 - $this -> assign('address_id',$address['id']);  
43 - }  
44 - }  
45 -  
46 - $data = Db::name('indent_goods') -> where('indent_id',$indet_id['indet_id']) -> select() -> toArray();  
47 - foreach ($data as $key => $val){  
48 - $pricing = explode('.',$val['pricing']);  
49 - $data[$key]['pricing0'] = $pricing[0];  
50 - $data[$key]['pricing1'] = $pricing[1];  
51 - }  
52 - $money = Db::name('indent') -> where('id',$indet_id['indet_id']) -> find();  
53 - $this -> assign('money',$money['money']);  
54 - $this -> assign('data',$data);  
55 - $this -> assign('indent_id',$indet_id['indet_id']);  
56 - $this -> assign('type',5);  
57 - return $this -> fetch();  
58 -  
59 - }  
60 -  
61 - /**  
62 - * 显示业务员统一订单页mmmmm  
63 - */  
64 - public function order_salesman_ty(){  
65 -  
66 - $indet_id = $this -> request -> param();  
67 - $data = Db::name('indent_goods') -> where('indent_id',$indet_id['indet_id']) -> select() -> toArray();  
68 - foreach ($data as $key => $val){  
69 - $pricing = explode('.',$val['price']);  
70 - $data[$key]['price0'] = $pricing[0];  
71 - $data[$key]['price1'] = $pricing[1];  
72 - }  
73 - $money = Db::name('indent') -> where('id',$indet_id['indet_id']) -> find();  
74 - $money['money'] = explode('.',$money['money']);  
75 - $this -> assign('money',$money['money']);  
76 - $this -> assign('data',$data);  
77 - $courier = Db::name('money_ratio') -> where('id',1) -> find();  
78 - $this -> assign('courier',$courier['courier']);  
79 - $this -> assign('indent_id',$indet_id['indet_id']);  
80 - //判断这个用户所属哪个业务员  
81 - $uid = cmf_get_current_user_id();  
82 - $user = Db::name('my_user') -> where('uid',$uid) -> find();  
83 - //当当前用户为老师时  
84 - if($user['status'] == 3){  
85 - $salesman = Db::name('my_user') -> where('id',$user['pid']) -> find();  
86 - }  
87 - //当前用户为学生时  
88 - if($user['status'] == 4){  
89 - $teacher = Db::name('my_user') -> where('id',$user['pid']) -> find();  
90 - $salesman = Db::name('my_user') -> where('id',$teacher['pid']) -> find();  
91 - }  
92 - //查询这个用户下添加的学校  
93 - $school = Db::name('school') -> where("uid",!empty($salesman['uid']) ? $salesman['uid'] : 0) -> select() -> toArray();  
94 -  
95 - if(!empty($school)){  
96 - $grade_class = Db::name('grade_class') -> where("school_id",$school[0]['id']) -> select();  
97 -  
98 - foreach ($grade_class as $key => $val){  
99 - $class = explode('-',$val['class']);  
100 - for($i=$class[0];$i<=$class[1];$i++){  
101 - $grade_class_show[] = $val['grade'].' - '.$i."班";  
102 - }  
103 - }  
104 -  
105 - }  
106 -  
107 - $this -> assign('school',$school);  
108 - $this -> assign('grade_class_show',!empty($grade_class_show) ? $grade_class_show : '');  
109 - return $this -> fetch();  
110 -  
111 - }  
112 -  
113 - /**  
114 - * 商品数量加一  
115 - */  
116 - public function shop_cart_numadd(){  
117 -  
118 - $id = $_POST['id'];  
119 - $data = Db::name('indent_goods') -> where('id',$id) -> find();  
120 - if($data['number']<200){  
121 - $res = Db::name('indent_goods') -> where('id',$id) -> setInc('number');  
122 - $indent_id = Db::name('indent_goods') -> where('id',$id) -> find();  
123 - Db::name('indent') -> where('id',$indent_id['indent_id']) -> setInc('money',$_POST['price']);  
124 - }  
125 - return true;  
126 -  
127 - }  
128 -  
129 - /**  
130 - * 商品数量减一  
131 - */  
132 - public function shop_cart_numdec(){  
133 -  
134 - $id = $_POST['id'];  
135 - $data = Db::name('indent_goods') -> where('id',$id) -> find();  
136 - if($data['number']>1){  
137 - Db::name('indent_goods') -> where('id',$id) -> setDec('number');  
138 - $indent_id = Db::name('indent_goods') -> where('id',$id) -> find();  
139 - Db::name('indent') -> where('id',$indent_id['indent_id']) -> setDec('money',$_POST['price']);  
140 - }  
141 - return true;  
142 -  
143 - }  
144 -  
145 - /**  
146 - * 显示业务员快递订单页  
147 - */  
148 - public function order_salesman_kd(){  
149 -  
150 - $uid = cmf_get_current_user_id();  
151 - $indent_id = $this -> request -> param();  
152 - $money = Db::name('indent') -> where("id =".$indent_id['indet_id']) -> find();  
153 - $indent_goods_data = Db::name('indent_goods') -> where('indent_id',$indent_id['indet_id']) -> select();  
154 - $this -> assign('data',$indent_goods_data);  
155 - $courier = Db::name('money_ratio') -> where('id',1) -> find();  
156 - $this -> assign('courier',$courier['courier']);  
157 - $money['money'] = $money['money']+$courier['courier'];  
158 - $this -> assign('money',$money['money']);  
159 - if(empty($indent_id['address_id'])){  
160 - $address = Db::name('address') -> where("uid=".$uid." and default_address=1 and delete_time = 0") -> find();  
161 - }else{  
162 - $address = Db::name('address') -> where('id',$indent_id['address_id']) -> find();  
163 - }  
164 -  
165 - if(empty($address)){  
166 - $this -> assign('address',4);  
167 - }else{  
168 - $indet_data = Db::name('indent') -> where("id",$indent_id['indet_id']) -> find();  
169 - if($indet_data['state'] == 4){  
170 - $indet_data_update['id'] = $indent_id['indet_id'];  
171 - $indet_data_update['indent_address'] = $address['id'];  
172 - $indet_data_update['name'] = $address['name'];  
173 - $indet_data_update['phone'] = $address['phone'];  
174 - $indet_data_update['region'] = $address['region'];  
175 - $indet_data_update['region_detail'] = $address['detailed'];  
176 - Db::name('indent') -> update($indet_data_update);  
177 - }  
178 - $this -> assign('address',$address);  
179 - }  
180 - $this -> assign('indet_id',$indent_id['indet_id']);  
181 - return $this -> fetch();  
182 -  
183 - }  
184 -  
185 - /**  
186 - * 业务员快递去支付  
187 - */  
188 - public function salesman_go_pay(){  
189 -  
190 - $_POST['is_courier'] = 2;  
191 - $data_update = Db::name('indent') -> update($_POST);  
192 - return true;  
193 -  
194 - }  
195 -  
196 - /**  
197 - * 取消支付时  
198 - */  
199 - public function cancel_pay(){  
200 -  
201 - $indent_id = $this -> request -> param();  
202 - $data = Db::name('indent') -> where('id',$indent_id['id']) -> find();  
203 - $money_ratio = Db::name('money_ratio') -> where('id',1) -> find();  
204 - /* if($data['indent_type'] == 2 && $data['is_courier'] == 2){  
205 - Db::name('indent') -> where('id',$indent_id['id']) -> setDec('money',$money_ratio['courier']);  
206 - }*/  
207 - $this -> redirect('index/index');  
208 -  
209 - }  
210 -  
211 - /**  
212 - * 平台商品去支付时 更新买家留言  
213 - */  
214 - public function goods_leave_word_update(){  
215 - $param = $this->request->param();  
216 - $param['is_courier'] = 2;  
217 - $address = Db::name('address')->where('id',$param['indent_address'])->find();  
218 - if(!$address) {  
219 - return false;  
220 - }  
221 - $param['name'] = $address['name'];  
222 - $param['phone'] = $address['phone'];  
223 - $data = Db::name('indent') -> update($param);  
224 - return true;  
225 -  
226 - }  
227 -  
228 - /**  
229 - * 点击学校时获取年级班级  
230 - */  
231 - public function get_grade_class(){  
232 -  
233 - $school_id = $_POST['id'];  
234 - $grade_class = Db::name('grade_class') -> where("school_id",$school_id) -> select() -> toArray();  
235 - if(!empty($grade_class)){  
236 - foreach ($grade_class as $key => $val){  
237 - $class = explode('-',$val['class']);  
238 - for($i=$class[0];$i<=$class[1];$i++){  
239 - $grade_class_show[] = $val['grade'].' - '.$i."班";  
240 - }  
241 - }  
242 - return json_encode($grade_class_show);  
243 - }else{  
244 - return false;  
245 - }  
246 -  
247 - }  
248 -  
249 - /**  
250 - * 业务员统一配送页去支付  
251 - */  
252 - public function salesman_ty_go_pay(){  
253 -  
254 - $_POST['is_courier'] = 1;  
255 - $class = explode('-',$_POST['grade']);  
256 - $_POST['grade'] = trim($class[0]);  
257 - $_POST['class'] = trim($class[1]);  
258 - $indent_data['id'] = $_POST['id'];  
259 - $indent_data['region'] = $_POST['region'];  
260 - $indent_data['name'] = $_POST['name'];  
261 - $indent_data['phone'] = $_POST['phone'];  
262 - $indent_data['is_courier'] = $_POST['is_courier'];  
263 - $indent_data['school'] = $_POST['school'];  
264 - $indent_data['grade'] = $_POST['grade'];  
265 - $indent_data['class'] = $_POST['class'];  
266 - $indent_data['leave_word'] = $_POST['leave_word'];  
267 - $data = Db::name('indent') -> update($indent_data);  
268 - if($data){  
269 - return true;  
270 - }else{  
271 - return false;  
272 - }  
273 -  
274 - }  
275 -  
276 - /**  
277 - * 显示收货地址  
278 - */  
279 - public function go_add_address(){  
280 -  
281 - $indent_id = $this -> request -> param();  
282 - $uid = cmf_get_current_user_id();  
283 - $data = Db::name('address') -> where("delete_time = 0 and uid =".$uid) -> select() -> toArray();  
284 - $this -> assign('indent_id',$indent_id['indet_id']);  
285 - $this -> assign('data',$data);  
286 - if(!empty($indent_id['type'])){  
287 - $this -> assign('type',5);  
288 - }else{  
289 - $this -> assign('type',6);  
290 - }  
291 - return $this -> fetch();  
292 -  
293 - }  
294 -  
295 - /**  
296 - * 获取学校  
297 - */  
298 - public function get_school(){  
299 - $user_id = $this->request->param('user_id');  
300 - if(empty($user_id)){  
301 - $user_id = cmf_get_current_user_id();  
302 - }  
303 - $my_user = Db::name('my_user')->where('uid',$user_id)->find();  
304 - if($my_user['status'] == 3){  
305 - $my_user2 = Db::name('my_user')->where('id',$my_user['pid'])->find();  
306 - }else{  
307 - $my_user3 = Db::name('my_user')->where('id',$my_user['pid'])->find();  
308 - $my_user2 = Db::name('my_user') -> where('id',$my_user3['pid']) -> find();  
309 - }  
310 -  
311 - $area = $this->request->param('area',0);  
312 - if(empty($area)){  
313 - $this->error('缺少必要参数');  
314 - }  
315 - $where['region'] = ['like',"%$area%"];  
316 - $where['uid'] = ['eq',$my_user2['uid']];  
317 - $data = Db::name('school')->where($where)->select()->toArray();  
318 - //循环组建新数据  
319 - foreach ($data as $key=>$val){  
320 - $datas[$key]['value'] = $val['id'];  
321 - $datas[$key]['text'] = $val['school'];  
322 - }  
323 - if(!empty($datas)){  
324 - return json_encode($datas);  
325 - }else{  
326 - return false;  
327 - }  
328 -  
329 -// $this->success('SUCCESS','',$datas);  
330 - }  
331 -  
332 - /**  
333 - * 新增地址页  
334 - */  
335 - public function add_shop_address(){  
336 -  
337 - if($this -> request -> isPost()){  
338 - $uid = cmf_get_current_user_id();  
339 - $_POST['uid'] = $uid;  
340 - $add = Db::name('address') -> insert($_POST);  
341 - if($add){  
342 - return true;  
343 - }else{  
344 - return false;  
345 - }  
346 - }else{  
347 - $indent_id = $this -> request -> param();  
348 - $this -> assign('indent_id',$indent_id['indet_id']);  
349 - if($indent_id['type']==5){  
350 - $this -> assign('type',5);  
351 - }else{  
352 - $this -> assign('type',6);  
353 - }  
354 - return $this -> fetch();  
355 - }  
356 -  
357 - }  
358 -  
359 - /**  
360 - * 编辑地址  
361 - */  
362 - public function address_edit(){  
363 -  
364 - if($this -> request -> isPost()){  
365 - $data_update = Db::name('address') -> update($_POST);  
366 - if($data_update){  
367 - return true;  
368 - }else{  
369 - return false;  
370 - }  
371 - }else{  
372 - $id = $this -> request -> param();  
373 - $data = Db::name('address') -> where('id',$id['id']) -> find();  
374 - $this -> assign('data',$data);  
375 - $this -> assign('indent_id',$id['indet_id']);  
376 - if($id['type']==5){  
377 - $this -> assign('type',5);  
378 - }else{  
379 - $this -> assign('type',6);  
380 - }  
381 - return $this -> fetch();  
382 - }  
383 -  
384 - }  
385 -  
386 -  
387 -  
388 -  
389 -  
390 -  
391 -  
392 -  
393 -  
394 -  
395 -  
396 -  
397 -  
398 -  
399 - 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 +namespace app\portal\controller;
  10 +
  11 +use cmf\controller\WeChatBaseController;
  12 +use think\Db;
  13 +
  14 +class OrderpageController extends WeChatBaseController{
  15 +
  16 + /**
  17 + * 显示平台订单页
  18 + */
  19 + public function order_page(){
  20 +
  21 + $indet_id = $this -> request -> param();
  22 + $uid = cmf_get_current_user_id();
  23 + if(!empty($indet_id['address_id'])){
  24 + $address = Db::name('address') -> where('id',$indet_id['address_id']) -> find();
  25 + $this -> assign('address',$address);
  26 + $this -> assign('address_id',$indet_id['address_id']);
  27 + }else{
  28 + $address = Db::name('address') -> where("uid=".$uid." and default_address=1 and delete_time = 0") -> find();
  29 + if(empty($address)){
  30 + $this -> assign('address',4);
  31 + $this -> assign('address_id','');
  32 + }else{
  33 + $indet_data = Db::name('indent') -> where("id",$indet_id['indet_id']) -> find();
  34 + if($indet_data['state'] == 4){
  35 + $indet_data_update['id'] = $indet_id['indet_id'];
  36 + $indet_data_update['indent_address'] = $address['id'];
  37 + $indet_data_update['name'] = $address['name'];
  38 + $indet_data_update['phone'] = $address['phone'];
  39 + Db::name('indent') -> update($indet_data_update);
  40 + }
  41 + $this -> assign('address',$address);
  42 + $this -> assign('address_id',$address['id']);
  43 + }
  44 + }
  45 +
  46 + $data = Db::name('indent_goods') -> where('indent_id',$indet_id['indet_id']) -> select() -> toArray();
  47 + foreach ($data as $key => $val){
  48 + $pricing = explode('.',$val['pricing']);
  49 + $data[$key]['pricing0'] = $pricing[0];
  50 + $data[$key]['pricing1'] = $pricing[1];
  51 + }
  52 + $money = Db::name('indent') -> where('id',$indet_id['indet_id']) -> find();
  53 + $this -> assign('money',$money['money']);
  54 + $this -> assign('data',$data);
  55 + $this -> assign('indent_id',$indet_id['indet_id']);
  56 + $this -> assign('type',5);
  57 + return $this -> fetch();
  58 +
  59 + }
  60 +
  61 + /**
  62 + * 显示业务员统一订单页mmmmm
  63 + */
  64 + public function order_salesman_ty(){
  65 +
  66 + $indet_id = $this -> request -> param();
  67 + $data = Db::name('indent_goods') -> where('indent_id',$indet_id['indet_id']) -> select() -> toArray();
  68 + foreach ($data as $key => $val){
  69 + $pricing = explode('.',$val['price']);
  70 + $data[$key]['price0'] = $pricing[0];
  71 + $data[$key]['price1'] = $pricing[1];
  72 + }
  73 + // 获取订单金额
  74 + $money = Db::name('indent') -> where('id',$indet_id['indet_id']) -> find();
  75 + $money['money'] = explode('.',$money['money']);
  76 + $this -> assign('money',$money['money']);
  77 + $this -> assign('data',$data);
  78 + //判断这个用户所属哪个业务员
  79 + $uid = cmf_get_current_user_id();
  80 + $user = Db::name('my_user') -> where('uid',$uid) -> find();
  81 + //当当前用户为老师时
  82 + if($user['status'] == 3){
  83 + $salesman = Db::name('my_user') -> where('id',$user['pid']) -> find();
  84 + }
  85 + //当前用户为学生时
  86 + if($user['status'] == 4){
  87 + $teacher = Db::name('my_user') -> where('id',$user['pid']) -> find();
  88 + $salesman = Db::name('my_user') -> where('id',$teacher['pid']) -> find();
  89 + }
  90 + // 查询业务员是否设置过邮费
  91 + $user_postage = Db::name('user_postage')->where('user_id',$salesman['uid'])->find();
  92 + if($user_postage) {
  93 + $courier = $user_postage['money'];
  94 + } else {
  95 + $courier = Db::name('money_ratio') -> where('id',1) -> value('courier');
  96 + }
  97 +
  98 + $this -> assign('courier',$courier);
  99 + $this -> assign('indent_id',$indet_id['indet_id']);
  100 + //查询这个用户下添加的学校
  101 + $school = Db::name('school') -> where("uid",!empty($salesman['uid']) ? $salesman['uid'] : 0) -> select() -> toArray();
  102 +
  103 + if(!empty($school)){
  104 + $grade_class = Db::name('grade_class') -> where("school_id",$school[0]['id']) -> select();
  105 +
  106 + foreach ($grade_class as $key => $val){
  107 + $class = explode('-',$val['class']);
  108 + for($i=$class[0];$i<=$class[1];$i++){
  109 + $grade_class_show[] = $val['grade'].' - '.$i."班";
  110 + }
  111 + }
  112 +
  113 + }
  114 +
  115 + $this -> assign('school',$school);
  116 + $this -> assign('grade_class_show',!empty($grade_class_show) ? $grade_class_show : '');
  117 + return $this -> fetch();
  118 +
  119 + }
  120 +
  121 + /**
  122 + * 商品数量加一
  123 + */
  124 + public function shop_cart_numadd(){
  125 +
  126 + $id = $_POST['id'];
  127 + $data = Db::name('indent_goods') -> where('id',$id) -> find();
  128 + if($data['number']<200){
  129 + $res = Db::name('indent_goods') -> where('id',$id) -> setInc('number');
  130 + $indent_id = Db::name('indent_goods') -> where('id',$id) -> find();
  131 + Db::name('indent') -> where('id',$indent_id['indent_id']) -> setInc('money',$_POST['price']);
  132 + }
  133 + return true;
  134 +
  135 + }
  136 +
  137 + /**
  138 + * 商品数量减一
  139 + */
  140 + public function shop_cart_numdec(){
  141 +
  142 + $id = $_POST['id'];
  143 + $data = Db::name('indent_goods') -> where('id',$id) -> find();
  144 + if($data['number']>1){
  145 + Db::name('indent_goods') -> where('id',$id) -> setDec('number');
  146 + $indent_id = Db::name('indent_goods') -> where('id',$id) -> find();
  147 + Db::name('indent') -> where('id',$indent_id['indent_id']) -> setDec('money',$_POST['price']);
  148 + }
  149 + return true;
  150 +
  151 + }
  152 +
  153 + /**
  154 + * 显示业务员快递订单页
  155 + */
  156 + public function order_salesman_kd(){
  157 +
  158 + $uid = cmf_get_current_user_id();
  159 + $indent_id = $this -> request -> param();
  160 + $money = Db::name('indent') -> where("id =".$indent_id['indet_id']) -> find();
  161 + $indent_goods_data = Db::name('indent_goods') -> where('indent_id',$indent_id['indet_id']) -> select();
  162 + $this -> assign('data',$indent_goods_data);
  163 + //判断这个用户所属哪个业务员
  164 + $user = Db::name('my_user') -> where('uid',$uid) -> find();
  165 + //当当前用户为老师时
  166 + if($user['status'] == 3){
  167 + $salesman = Db::name('my_user') -> where('id',$user['pid']) -> find();
  168 + }
  169 + //当前用户为学生时
  170 + if($user['status'] == 4){
  171 + $teacher = Db::name('my_user') -> where('id',$user['pid']) -> find();
  172 + $salesman = Db::name('my_user') -> where('id',$teacher['pid']) -> find();
  173 + }
  174 + // 查询业务员是否设置过邮费
  175 + $user_postage = Db::name('user_postage')->where('user_id',$salesman['uid'])->find();
  176 + if($user_postage) {
  177 + $courier = $user_postage['money'];
  178 + } else {
  179 + $courier = Db::name('money_ratio') -> where('id',1) -> value('courier');
  180 + }
  181 + $this -> assign('courier',$courier);
  182 + $money['money'] = $money['money']+$courier;
  183 + $this -> assign('money',$money['money']);
  184 + if(empty($indent_id['address_id'])){
  185 + $address = Db::name('address') -> where("uid=".$uid." and default_address=1 and delete_time = 0") -> find();
  186 + }else{
  187 + $address = Db::name('address') -> where('id',$indent_id['address_id']) -> find();
  188 + }
  189 +
  190 + if(empty($address)){
  191 + $this -> assign('address',4);
  192 + }else{
  193 + $indet_data = Db::name('indent') -> where("id",$indent_id['indet_id']) -> find();
  194 + if($indet_data['state'] == 4){
  195 + $indet_data_update['id'] = $indent_id['indet_id'];
  196 + $indet_data_update['indent_address'] = $address['id'];
  197 + $indet_data_update['name'] = $address['name'];
  198 + $indet_data_update['phone'] = $address['phone'];
  199 + $indet_data_update['region'] = $address['region'];
  200 + $indet_data_update['region_detail'] = $address['detailed'];
  201 + Db::name('indent') -> update($indet_data_update);
  202 + }
  203 + $this -> assign('address',$address);
  204 + }
  205 + $this -> assign('indet_id',$indent_id['indet_id']);
  206 + return $this -> fetch();
  207 +
  208 + }
  209 +
  210 + /**
  211 + * 业务员快递去支付
  212 + */
  213 + public function salesman_go_pay(){
  214 +
  215 + $_POST['is_courier'] = 2;
  216 + $data_update = Db::name('indent') -> update($_POST);
  217 + return true;
  218 +
  219 + }
  220 +
  221 + /**
  222 + * 取消支付时
  223 + */
  224 + public function cancel_pay(){
  225 +
  226 + $indent_id = $this -> request -> param();
  227 + $data = Db::name('indent') -> where('id',$indent_id['id']) -> find();
  228 + $money_ratio = Db::name('money_ratio') -> where('id',1) -> find();
  229 + /* if($data['indent_type'] == 2 && $data['is_courier'] == 2){
  230 + Db::name('indent') -> where('id',$indent_id['id']) -> setDec('money',$money_ratio['courier']);
  231 + }*/
  232 + $this -> redirect('index/index');
  233 +
  234 + }
  235 +
  236 + /**
  237 + * 平台商品去支付时 更新买家留言
  238 + */
  239 + public function goods_leave_word_update(){
  240 + $param = $this->request->param();
  241 + $param['is_courier'] = 2;
  242 + $address = Db::name('address')->where('id',$param['indent_address'])->find();
  243 + if(!$address) {
  244 + return false;
  245 + }
  246 + $param['name'] = $address['name'];
  247 + $param['phone'] = $address['phone'];
  248 + $data = Db::name('indent') -> update($param);
  249 + return true;
  250 +
  251 + }
  252 +
  253 + /**
  254 + * 点击学校时获取年级班级
  255 + */
  256 + public function get_grade_class(){
  257 +
  258 + $school_id = $_POST['id'];
  259 + $grade_class = Db::name('grade_class') -> where("school_id",$school_id) -> select() -> toArray();
  260 + if(!empty($grade_class)){
  261 + foreach ($grade_class as $key => $val){
  262 + $class = explode('-',$val['class']);
  263 + for($i=$class[0];$i<=$class[1];$i++){
  264 + $grade_class_show[] = $val['grade'].' - '.$i."班";
  265 + }
  266 + }
  267 + return json_encode($grade_class_show);
  268 + }else{
  269 + return false;
  270 + }
  271 +
  272 + }
  273 +
  274 + /**
  275 + * 业务员统一配送页去支付
  276 + */
  277 + public function salesman_ty_go_pay(){
  278 +
  279 + $_POST['is_courier'] = 1;
  280 + $class = explode('-',$_POST['grade']);
  281 + $_POST['grade'] = trim($class[0]);
  282 + $_POST['class'] = trim($class[1]);
  283 + $indent_data['id'] = $_POST['id'];
  284 + $indent_data['region'] = $_POST['region'];
  285 + $indent_data['name'] = $_POST['name'];
  286 + $indent_data['phone'] = $_POST['phone'];
  287 + $indent_data['is_courier'] = $_POST['is_courier'];
  288 + $indent_data['school'] = $_POST['school'];
  289 + $indent_data['grade'] = $_POST['grade'];
  290 + $indent_data['class'] = $_POST['class'];
  291 + $indent_data['leave_word'] = $_POST['leave_word'];
  292 + $data = Db::name('indent') -> update($indent_data);
  293 + if($data){
  294 + return true;
  295 + }else{
  296 + return false;
  297 + }
  298 +
  299 + }
  300 +
  301 + /**
  302 + * 显示收货地址
  303 + */
  304 + public function go_add_address(){
  305 +
  306 + $indent_id = $this -> request -> param();
  307 + $uid = cmf_get_current_user_id();
  308 + $data = Db::name('address') -> where("delete_time = 0 and uid =".$uid) -> select() -> toArray();
  309 + $this -> assign('indent_id',$indent_id['indet_id']);
  310 + $this -> assign('data',$data);
  311 + if(!empty($indent_id['type'])){
  312 + $this -> assign('type',5);
  313 + }else{
  314 + $this -> assign('type',6);
  315 + }
  316 + return $this -> fetch();
  317 +
  318 + }
  319 +
  320 + /**
  321 + * 获取学校
  322 + */
  323 + public function get_school(){
  324 + $user_id = $this->request->param('user_id');
  325 + if(empty($user_id)){
  326 + $user_id = cmf_get_current_user_id();
  327 + }
  328 + $my_user = Db::name('my_user')->where('uid',$user_id)->find();
  329 + if($my_user['status'] == 3){
  330 + $my_user2 = Db::name('my_user')->where('id',$my_user['pid'])->find();
  331 + }else{
  332 + $my_user3 = Db::name('my_user')->where('id',$my_user['pid'])->find();
  333 + $my_user2 = Db::name('my_user') -> where('id',$my_user3['pid']) -> find();
  334 + }
  335 +
  336 + $area = $this->request->param('area',0);
  337 + if(empty($area)){
  338 + $this->error('缺少必要参数');
  339 + }
  340 + $where['region'] = ['like',"%$area%"];
  341 + $where['uid'] = ['eq',$my_user2['uid']];
  342 + $data = Db::name('school')->where($where)->select()->toArray();
  343 + //循环组建新数据
  344 + foreach ($data as $key=>$val){
  345 + $datas[$key]['value'] = $val['id'];
  346 + $datas[$key]['text'] = $val['school'];
  347 + }
  348 + if(!empty($datas)){
  349 + return json_encode($datas);
  350 + }else{
  351 + return false;
  352 + }
  353 +
  354 +// $this->success('SUCCESS','',$datas);
  355 + }
  356 +
  357 + /**
  358 + * 新增地址页
  359 + */
  360 + public function add_shop_address(){
  361 +
  362 + if($this -> request -> isPost()){
  363 + $uid = cmf_get_current_user_id();
  364 + $_POST['uid'] = $uid;
  365 + $add = Db::name('address') -> insert($_POST);
  366 + if($add){
  367 + return true;
  368 + }else{
  369 + return false;
  370 + }
  371 + }else{
  372 + $indent_id = $this -> request -> param();
  373 + $this -> assign('indent_id',$indent_id['indet_id']);
  374 + if($indent_id['type']==5){
  375 + $this -> assign('type',5);
  376 + }else{
  377 + $this -> assign('type',6);
  378 + }
  379 + return $this -> fetch();
  380 + }
  381 +
  382 + }
  383 +
  384 + /**
  385 + * 编辑地址
  386 + */
  387 + public function address_edit(){
  388 +
  389 + if($this -> request -> isPost()){
  390 + $data_update = Db::name('address') -> update($_POST);
  391 + if($data_update){
  392 + return true;
  393 + }else{
  394 + return false;
  395 + }
  396 + }else{
  397 + $id = $this -> request -> param();
  398 + $data = Db::name('address') -> where('id',$id['id']) -> find();
  399 + $this -> assign('data',$data);
  400 + $this -> assign('indent_id',$id['indet_id']);
  401 + if($id['type']==5){
  402 + $this -> assign('type',5);
  403 + }else{
  404 + $this -> assign('type',6);
  405 + }
  406 + return $this -> fetch();
  407 + }
  408 +
  409 + }
  410 +
  411 +
  412 +
  413 +
  414 +
  415 +
  416 +
  417 +
  418 +
  419 +
  420 +
  421 +
  422 +
  423 +
  424 +
400 } 425 }
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 -namespace app\portal\controller;  
10 -  
11 -use cmf\controller\WeChatBaseController;  
12 -use EasyWeChat\Foundation\Application;  
13 -use think\Db;  
14 -  
15 -class sendAPI {  
16 - public $data; //发送数据  
17 - public $timeout = 30; //超时  
18 - private $apiUrl; //发送地址  
19 - private $username; //用户名  
20 - private $password; //密码  
21 -  
22 - function __construct($url, $username, $password) {  
23 - $this->apiUrl = $url;  
24 - $this->username = $username;  
25 - $this->password = $password;  
26 - }  
27 -  
28 - private function httpGet() {  
29 - $url = $this->apiUrl . '?' . http_build_query($this->data);  
30 - $curl = curl_init();  
31 - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);  
32 - curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout);  
33 - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);  
34 - curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);  
35 - curl_setopt($curl, CURLOPT_URL, $url);  
36 - $res = curl_exec($curl);  
37 - if (curl_errno($curl)) {  
38 - echo 'Error GET '.curl_error($curl);  
39 - }  
40 - curl_close($curl);  
41 - return $res;  
42 - }  
43 -  
44 - private function httpPost(){ // 模拟提交数据函数  
45 - $curl = curl_init(); // 启动一个CURL会话  
46 - curl_setopt($curl, CURLOPT_URL, $this->apiUrl); // 要访问的地址  
47 - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查  
48 - curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在  
49 - curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器  
50 - curl_setopt($curl, CURLOPT_POST, true); // 发送一个常规的Post请求  
51 - curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($this->data)); // Post提交的数据包  
52 - curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout); // 设置超时限制防止死循环  
53 - curl_setopt($curl, CURLOPT_HEADER, false); // 显示返回的Header区域内容  
54 - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // 获取的信息以文件流的形式返回  
55 - $result = curl_exec($curl); // 执行操作  
56 - if (curl_errno($curl)) {  
57 - echo 'Error POST'.curl_error($curl);  
58 - }  
59 - curl_close($curl); // 关键CURL会话  
60 - return $result; // 返回数据  
61 - }  
62 -  
63 - /**  
64 - * @param $type|提交类型 POST/GET  
65 - * @param $isTranscoding|是否需要转 $isTranscoding 是否需要转utf-8 默认 false  
66 - * @return mixed  
67 - */  
68 - public function sendSMS($type, $isTranscoding = false) {  
69 - $this->data['content'] = $isTranscoding === true ? mb_convert_encoding($this->data['content'], "UTF-8") : $this->data['content'];  
70 - $this->data['username'] = $this->username;  
71 - $this->data['tkey'] = date('YmdHis');  
72 - $this->data['password'] = md5(md5($this->password) . $this->data['tkey']);  
73 - return $type == "POST" ? $this->httpPost() : $this->httpGet();  
74 - }  
75 -  
76 -}  
77 -  
78 -class PersonalcenterController extends WeChatBaseController{  
79 -  
80 - /**  
81 - * 显示个人中心页  
82 - */  
83 - public function personal_center(){  
84 -  
85 - $uid = cmf_get_current_user_id();  
86 - $my_user_status = Db::name('my_user') -> where('uid',$uid) -> find();  
87 - $weixin = Db::name('user') -> where('id',$uid) -> find();  
88 - $this -> assign('weixin',$weixin);  
89 - if($my_user_status['status'] == 0 || $my_user_status['status'] == 1 || $my_user_status['status'] == 3 || $my_user_status['status'] == 4 || $my_user_status['status'] == 5 || $my_user_status['status'] == 6){  
90 - if($my_user_status['status'] == 0){  
91 - $this -> assign('status',0);  
92 - }  
93 - if($my_user_status['status'] == 1 || $my_user_status['status'] == 5 || $my_user_status['status'] == 6){  
94 - $this -> assign('status',1);  
95 - }  
96 - if($my_user_status['status'] == 3){  
97 - $this -> assign('status',3);  
98 - }  
99 - if($my_user_status['status'] == 4){  
100 - $this -> assign('status',4);  
101 - }  
102 - return $this -> fetch();  
103 - }  
104 - //业务员个人中心页  
105 - if($my_user_status['status'] == 2){  
106 - $this -> assign('weixin',$weixin);  
107 - return $this -> fetch('personalcenter/salesman_center');  
108 - }  
109 -  
110 - }  
111 -  
112 - /**  
113 - * 完善个人信息页  
114 - */  
115 - public function perfect_information(){  
116 -  
117 - $uid = cmf_get_current_user_id();  
118 - $my_user_status = Db::name('my_user') -> where('uid',$uid) -> find();  
119 - if($my_user_status['status'] == 2){  
120 - $this -> redirect('Personalcenter/personal_center');  
121 - }else{  
122 - if($my_user_status['status'] == 1){  
123 - $this -> assign('status',1);  
124 - }  
125 - if($my_user_status['status'] == 5){  
126 - $this -> assign('status',5);  
127 - }  
128 - if($my_user_status['status'] == 6){  
129 - $this -> assign('status',6);  
130 - }  
131 - $weixin = Db::name('user') -> where('id',$uid) -> find();  
132 - $this -> assign('weixin',$weixin);  
133 - return $this -> fetch();  
134 - }  
135 -  
136 - }  
137 -  
138 -  
139 - /**  
140 - * 我的收藏页  
141 - */  
142 - public function personal_collect(){  
143 -  
144 - $uid = cmf_get_current_user_id();  
145 - $data = Db::name('collect') -> where("uid =".$uid) -> select() -> toArray();  
146 -  
147 - if(!empty($data)){  
148 - foreach($data as $key => $val){  
149 - $collect_goods = Db::name('goods') -> where("id =".$val['goods_id']) -> where("is_out = 1") -> find();  
150 - if($collect_goods != null){  
151 - $data_goods[] = $collect_goods;  
152 - }  
153 - }  
154 - if(!empty($data_goods)){  
155 - foreach ($data_goods as $key => $val){  
156 - $price = explode('.',$val['price']);  
157 - $pricing = explode('.',$val['pricing']);  
158 - $data_goods[$key]['price0'] = $price[0];  
159 - $data_goods[$key]['price1'] = $price[1];  
160 - $data_goods[$key]['pricing0'] = $pricing[0];  
161 - $data_goods[$key]['pricing1'] = $pricing[1];  
162 - }  
163 - }else{  
164 - $data_goods = '';  
165 - }  
166 - }else{  
167 - $data_goods = '';  
168 - }  
169 - if(!empty($data_goods)){  
170 - $data_count = count($data_goods);  
171 - }else{  
172 - $data_count = 0;  
173 - }  
174 - $this -> assign('data_count',$data_count);  
175 - $this -> assign('data_goods',$data_goods);  
176 - return $this -> fetch();  
177 -  
178 - }  
179 -  
180 - /**  
181 - * 填写个人信息页  
182 - */  
183 - public function add_information(){  
184 -  
185 - $options=config('wechat_config');  
186 - $app = new Application($options);  
187 - $js = $app->js;  
188 - $jssdk=$js->config(array('chooseImage','uploadImage'), false,false,true);  
189 - $this->assign('jssdk',$jssdk);  
190 - return $this -> fetch();  
191 -  
192 - }  
193 -  
194 -  
195 - /**  
196 - * 浏览记录  
197 - */  
198 - public function browsing_history(){  
199 -  
200 - $uid = cmf_get_current_user_id();  
201 - $data = Db::name('browsing_history') -> where("uid =".$uid) -> select();  
202 - foreach($data as $key => $val){  
203 - $browsing_history_goods = Db::name('goods') -> where('id',$val['goods_id']) -> where("is_out = 1") -> find();  
204 - if($browsing_history_goods != null){  
205 - $data_goods[] = $browsing_history_goods;  
206 - }  
207 - }  
208 - if(!empty($data_goods)){  
209 - foreach($data_goods as $key => $val){  
210 - $price = explode('.',$val['price']);  
211 - $classification_name = Db::name('classification') -> where('id',$val['classify_id']) -> find();  
212 - $data_goods[$key]['classification_name'] = $classification_name['name'];  
213 - $data_goods[$key]['price0'] = $price[0];  
214 - $data_goods[$key]['price1'] = $price[1];  
215 - }  
216 - }else{  
217 - $data_goods = '';  
218 - }  
219 - $this -> assign('data_goods',$data_goods);  
220 - return $this -> fetch();  
221 -  
222 - }  
223 -  
224 - /**  
225 - * 收货地址页  
226 - */  
227 - public function shop_address(){  
228 -  
229 - $uid = cmf_get_current_user_id();  
230 - $data = Db::name('address') -> where("delete_time = 0 and uid =".$uid) -> select() -> toArray();  
231 - $this -> assign('data',$data);  
232 - return $this -> fetch();  
233 -  
234 - }  
235 -  
236 - /**  
237 - * 新增地址页  
238 - */  
239 - public function add_shop_address(){  
240 -  
241 - if($this -> request -> isPost()){  
242 - $uid = cmf_get_current_user_id();  
243 - $_POST['uid'] = $uid;  
244 - $add = Db::name('address') -> insert($_POST);  
245 - if($add){  
246 - return true;  
247 - }else{  
248 - return false;  
249 - }  
250 - }else{  
251 - return $this -> fetch();  
252 - }  
253 -  
254 - }  
255 -  
256 - /**  
257 - * 设置默认地址  
258 - */  
259 - public function set_default_address(){  
260 -  
261 - $uid = cmf_get_current_user_id();  
262 - Db::name('address') -> where('uid',$uid) -> update(['default_address'=>0]);  
263 - $data = Db::name('address') -> where('id',$_POST['id']) -> update(['default_address'=>1]);  
264 - if($data){  
265 - return true;  
266 - }else{  
267 - return false;  
268 - }  
269 -  
270 - }  
271 -  
272 - /**  
273 - * 删除地址  
274 - */  
275 - public function address_del(){  
276 -  
277 - $delete_time = time();  
278 - $data = Db::name('address') -> where('id',$_POST['id']) -> update(['delete_time'=>$delete_time]);  
279 - if($data){  
280 - return true;  
281 - }else{  
282 - return false;  
283 - }  
284 -  
285 - }  
286 -  
287 - /**  
288 - * 编辑地址  
289 - */  
290 - public function address_edit(){  
291 -  
292 - if($this -> request -> isPost()){  
293 - $data_update = Db::name('address') -> update($_POST);  
294 - if($data_update){  
295 - return true;  
296 - }else{  
297 - return false;  
298 - }  
299 - }else{  
300 - $id = $this -> request -> param();  
301 - $data = Db::name('address') -> where('id',$id['id']) -> find();  
302 - $this -> assign('data',$data);  
303 - return $this -> fetch();  
304 - }  
305 -  
306 - }  
307 -  
308 - /**  
309 - * 发送短信  
310 - */  
311 - public function send_message(){  
312 -  
313 - $url = "http://www.ztsms.cn/sendNSms.do";//提交地址  
314 - $username = 'xuekaowuyou';//用户名  
315 - $password = 'Cxz307312';//原密码  
316 - $sendAPI = new sendAPI($url, $username, $password);  
317 - $key = '';  
318 - $pattern='1234567890';  
319 - for( $i=0; $i<6; $i++ ) {  
320 - $key .= $pattern[mt_rand(0, 9)];  
321 - }  
322 - session('code',$key);  
323 - $rand_name = "验证码:".$key."【学考无忧】";  
324 - $phone = $_POST['phone'];  
325 - $data = array(  
326 - 'content' => $rand_name,//短信内容  
327 - 'mobile' => $phone,//手机号码  
328 - 'productid' => '676767',//产品id  
329 - 'xh' => ''//小号  
330 - );  
331 - $sendAPI->data = $data;//初始化数据包  
332 - $return = $sendAPI->sendSMS('POST');//GET or POST  
333 - if($return){  
334 - return true;  
335 - }else{  
336 - return false;  
337 - }  
338 -  
339 - }  
340 -  
341 - /**  
342 - * 添加审核信息  
343 - */  
344 - public function add_audit(){  
345 -  
346 - $code = session('code');  
347 - if($code == $_POST['code']){  
348 - //判断是否提交过  
349 - $id_num = $_POST['id_num'];  
350 - $id_number = Db::name('sale_audit') -> where("id_number = '$id_num' ") -> find();  
351 - if(!empty($id_number)){  
352 - return 4;  
353 - }  
354 - $data['name'] = $_POST['name'];  
355 - $data['phone'] = $_POST['phone'];  
356 - $data['id_number'] = $_POST['id_num'];  
357 - $data['img_front'] = $_POST['img0'];  
358 - $data['img_back'] = $_POST['img1'];  
359 - $data['create_time'] = time();  
360 - $data['uid'] = cmf_get_current_user_id();  
361 - $inser = Db::name('sale_audit') -> insert($data);  
362 - if($inser){  
363 - Db::name('my_user') -> where('uid',$data['uid']) -> update(['status'=>5,'phone'=>$data['phone']]);  
364 - return 1;  
365 - }else{  
366 - return 2;  
367 - }  
368 - }else{  
369 - return 3;  
370 - }  
371 -  
372 - }  
373 -  
374 - /**  
375 - * 我的钱包页  
376 - */  
377 - public function my_wallet(){  
378 -  
379 - $uid = cmf_get_current_user_id();  
380 - $balance = Db::name('my_user') -> where("uid",$uid) -> find();  
381 - $b_money = $balance['balance'];  
382 - $b_money = sprintf("%.2f",$b_money);  
383 - $this -> assign('b_money',$b_money);  
384 -  
385 - $money_income = Db::name("money_income") -> where('uid',$uid) -> select();  
386 - $cumulative_money = 0;  
387 - foreach ($money_income as $key => $val){  
388 - $cumulative_money += $val['money'];  
389 - }  
390 - $cumulative_moneyss = $cumulative_money;  
391 - $cumulative_moneyss = sprintf("%.2f",$cumulative_moneyss);  
392 - $this -> assign('cumulative_moneyss',$cumulative_moneyss);  
393 - $cumulative_money = $cumulative_money-$cumulative_money*0.006;  
394 - $cumulative_money = sprintf("%.2f",$cumulative_money);  
395 - $money_ratio = Db::name('money_ratio') -> where('id',1) -> find();  
396 - $money_ratio['platform_ratio'] = $money_ratio['platform_ratio']*100;  
397 - $money_ratio['platform_ratio'] = $money_ratio['platform_ratio'].'%';  
398 - $this -> assign('money_ratio',$money_ratio);  
399 -  
400 - $this -> assign('cumulative_money',$cumulative_money);  
401 - $money_expend = Db::name('money_expend') -> where('uid='.$uid." and state=0") -> select();  
402 - $money = 0;  
403 - foreach ($money_expend as $key => $val){  
404 - $money += $val['money'];  
405 - }  
406 - $tax_money = $money/(1-0.006);  
407 - $money = number_format($money,2);  
408 -  
409 - $balance['balance'] = $balance['balance'] - $balance['balance']*0.006-$tax_money;  
410 - $balance['balance'] = sprintf("%.2f", $balance['balance']);  
411 - if($balance['balance'] <= 0){  
412 - $balance['balance'] = 0;  
413 - }  
414 - $this -> assign('balance',$balance['balance']);  
415 -  
416 - $this -> assign('status',$balance['status']);  
417 - $this -> assign('money',$money);  
418 - return $this -> fetch();  
419 -  
420 - }  
421 -  
422 - /**  
423 - * 将提现金额存入支出明细表  
424 - */  
425 - public function add_money_expend(){  
426 -  
427 - $_POST['uid'] = cmf_get_current_user_id();  
428 - $_POST['create_time'] = time();  
429 - $_POST['state'] = 0;  
430 - $user_balance = Db::name('my_user') -> where('uid',$_POST['uid']) -> find();  
431 - $user_money_expend = Db::name('money_expend') -> where("uid=".$_POST['uid']." and state =0") -> select();  
432 - $money_expend = $_POST['money'];  
433 - $my_money_expend = 0;  
434 - foreach ($user_money_expend as $key => $val){  
435 - $my_money_expend += $val['money'];  
436 - }  
437 - $tax_money = $my_money_expend/(1-0.006);  
438 - $user_balance['balance'] = $user_balance['balance']-$user_balance['balance']*0.006-$tax_money;  
439 - if($money_expend > $user_balance['balance'] ){  
440 - return false;  
441 - }else{  
442 - $data = Db::name('money_expend') -> insert($_POST);  
443 - $money_expend = Db::name('money_expend') -> where('uid='.$_POST['uid']." and state=0") -> select();  
444 - $money = 0;  
445 - foreach ($money_expend as $key => $val){  
446 - $money += $val['money'];  
447 - }  
448 - $money = number_format($money,2);  
449 - if($data){  
450 - return $money;  
451 - }else{  
452 - return false;  
453 - }  
454 - }  
455 -  
456 - }  
457 -  
458 - /**  
459 - * 邀请名单  
460 - */  
461 - public function invitation_list(){  
462 -  
463 - $uid = cmf_get_current_user_id();  
464 - $my_user = Db::name('my_user') -> where('uid',$uid) -> find();  
465 - if($my_user['status'] == 3){  
466 - $student = Db::name('my_user') -> alias('a') -> field("a.*,b.user_nickname,b.avatar") -> join("user b","a.uid = b.id",'LEFT') -> where("a.pid",$my_user['id']) -> select() -> toArray();  
467 - if(!empty($student)){  
468 - foreach ($student as $key => $val){  
469 - $student[$key]['indent'] = Db::name('indent') -> where('uid',$val['uid']) -> where("state = 2 or state = 3 or state = 5") -> order("pay_time desc") -> select() -> toArray();  
470 - $name = $val['user_nickname'];  
471 - $avatar = $val['avatar'];  
472 - $cumulative_money = 0;  
473 - foreach ($student[$key]['indent'] as $key1 => $val1){  
474 - $student[$key]['indent'][$key1]['user_name'] = $name;  
475 - $student[$key]['indent'][$key1]['avatar'] = $avatar;  
476 - $money_income = Db::name('money_income') -> where("indent_id =".$val1['id']." and uid = ".$uid) -> select() -> toArray();  
477 - $money = 0;  
478 - foreach ($money_income as $key2 => $val2){  
479 - $money += $val2['money'];  
480 - }  
481 - $student[$key]['indent'][$key1]['total_money'] = number_format($money,2);  
482 - $cumulative_money += $money;  
483 - }  
484 - $student[$key]['cumulative_money'] = number_format($cumulative_money,2);  
485 -  
486 - }  
487 - }else{  
488 - $student = null;  
489 - }  
490 - $this -> assign('type',3);  
491 - $this -> assign('student',$student);  
492 - }elseif ($my_user['status'] == 2){  
493 - //查找业务员下级老师  
494 - $teacher = Db::name('my_user') -> alias('a') -> field("a.*,b.user_nickname,b.avatar") -> join("user b","a.uid = b.id",'LEFT') -> where("a.pid",$my_user['id']) -> select() -> toArray();  
495 - if(!empty($teacher)){  
496 - foreach ($teacher as $key => $val){  
497 - $money_income = Db::name('money_income') -> where("uid",$val['uid']) -> select();  
498 - $total_commission = 0;  
499 - foreach ($money_income as $key1 => $val1){  
500 - $total_commission += $val1['money'];  
501 - }  
502 - $teacher[$key]['total_commission'] = $total_commission;  
503 - //查找老师下面的学生  
504 - $teacher[$key]['student'] = Db::name('my_user') -> alias('a') -> field("a.*,b.user_nickname,b.avatar") -> join("user b","a.uid = b.id",'LEFT') -> where("a.pid",$val['id']) -> select() -> toArray();  
505 - if(!empty($teacher[$key]['student'])){  
506 - foreach ($teacher[$key]['student'] as $key2 => $val2){  
507 - $teacher[$key]['student'][$key2]['indent'] = Db::name('indent') -> where('uid',$val2['uid']) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();  
508 - $student_indent_money = 0;  
509 - foreach ($teacher[$key]['student'][$key2]['indent'] as $key3 => $val3){  
510 - $student_money_income = Db::name('money_income') -> where("indent_id =".$val3['id']." and uid = ".$val['uid']) -> select() -> toArray();  
511 - $student_money_income_money = 0;  
512 - foreach ($student_money_income as $key4 => $val4){  
513 - $student_money_income_money += $val4['money'];  
514 - }  
515 - $teacher[$key]['student'][$key2]['indent']['student_money_income_money'] = $student_money_income_money;  
516 - $student_indent_money += $student_money_income_money;  
517 - }  
518 - $teacher[$key]['student'][$key2]['indent_money'] = $student_indent_money;  
519 - }  
520 - }  
521 - }  
522 - }else{  
523 - $teacher = null;  
524 - }  
525 - $this -> assign('type',2);  
526 - $this -> assign('teacher',$teacher);  
527 - }  
528 - return $this -> fetch();  
529 -  
530 - }  
531 -  
532 - /**  
533 - * 收入记录  
534 - */  
535 - public function income_record(){  
536 -  
537 - $uid = cmf_get_current_user_id();  
538 - $get = $this -> request -> param();  
539 - $my_user = Db::name('my_user') -> where('uid',$uid) -> find();  
540 - //搜索老师下级学生用户  
541 - $student = Db::name('my_user') -> alias('a') -> field("a.*,b.user_nickname,b.avatar") -> join("user b","a.uid = b.id",'LEFT') -> where("a.pid",$my_user['id']) -> select() -> toArray();  
542 - foreach ($student as $key => $val){  
543 - if(!empty($get['startime']) && !empty($get['endtime'])){  
544 - $startime = strtotime($get['startime']);  
545 - $endtime = strtotime($get['endtime'])+86400;  
546 - $data[$key] = Db::name('indent') -> where('uid',$val['uid']) -> where("state = 2 or state = 3 or state = 5") -> where("pay_time>=".$startime." and pay_time<=".$endtime) -> select() -> toArray();  
547 - }else{  
548 - $data[$key] = Db::name('indent') -> where('uid',$val['uid']) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();  
549 - }  
550 - $name = $val['user_nickname'];  
551 - $avatar = $val['avatar'];  
552 - if(count($data[$key])!=0){  
553 - foreach ($data[$key] as $key1 => $val1){  
554 - $book_name = Db::name('indent_goods') -> where("indent_id",$val1['id']) -> find();  
555 - $data[$key][$key1]['user_name'] = $name;  
556 - $data[$key][$key1]['avatar'] = $avatar;  
557 - $data[$key][$key1]['book_name'] = $book_name['book_name'];  
558 - $money_income = Db::name('money_income') -> where("indent_id =".$val1['id']." and uid = ".$uid) -> select() -> toArray();  
559 - $money = 0;  
560 - foreach ($money_income as $key2 => $val2){  
561 - $money += $val2['money'];  
562 - }  
563 - $data[$key][$key1]['total_money'] = number_format($money,2);  
564 - $res[] = $data[$key][$key1];  
565 - }  
566 - }  
567 -  
568 - }  
569 - if(empty($res)){  
570 - $res = array();  
571 - }  
572 -// $this -> assign('res',$res);  
573 - //搜索老师用户  
574 - $teacher_avatar = Db::name('user') -> where('id',$uid) -> find();  
575 - if(!empty($get['startime']) && !empty($get['endtime'])){  
576 - $startime = strtotime($get['startime']);  
577 - $endtime = strtotime($get['endtime'])+86400;  
578 - $teacher = Db::name('indent') -> where('uid',$uid) -> where("pay_time>=".$startime." and pay_time<=".$endtime) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();  
579 - }else{  
580 - $teacher = Db::name('indent') -> where('uid',$uid) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();  
581 - }  
582 -  
583 - foreach($teacher as $key => $val){  
584 - $teacher_book_name = Db::name('indent_goods') -> where("indent_id",$val['id']) -> find();  
585 - $teacher_data[$key]['user_name'] = $teacher_avatar['user_nickname'];  
586 - $teacher_data[$key]['avatar'] = $teacher_avatar['avatar'];  
587 - $teacher_data[$key]['book_name'] = $teacher_book_name['book_name'];  
588 - $tea_money_income = Db::name('money_income') -> where("indent_id =".$val['id']." and uid = ".$uid) -> select() -> toArray();  
589 - $money = 0;  
590 - foreach ($tea_money_income as $key2 => $val2){  
591 - $money += $val2['money'];  
592 - }  
593 - $teacher_data[$key]['total_money'] = number_format($money,2) ;  
594 - $teacher_data[$key]['indent_type'] = $val['indent_type'];  
595 - $teacher_data[$key]['create_time'] = $val['create_time'];  
596 - $my_res[] = $teacher_data[$key];  
597 - }  
598 - if(empty($my_res)){  
599 - $my_res = array();  
600 - }  
601 - $aaaa = array_merge($res,$my_res);  
602 - $bb = array_column($aaaa,'create_time');  
603 - $cc = array_multisort($bb,SORT_DESC,$aaaa);  
604 - if(count($res)!=0 || count($my_res)!=0){  
605 - foreach ($aaaa as $key=>$val){  
606 - if($val['indent_type'] == 1){  
607 - $pingtai[] = $val;  
608 - }else{  
609 - $yewu[] = $val;  
610 - }  
611 - }  
612 - if(empty($pingtai)){  
613 - $this -> assign('pingtai',array());  
614 - }else{  
615 - $this -> assign('pingtai',$pingtai);  
616 - }  
617 - if(empty($yewu)){  
618 - $this -> assign('yewu',array());  
619 - }else{  
620 - $this -> assign('yewu',$yewu);  
621 - }  
622 -  
623 - }else{  
624 - $this -> assign('pingtai',array());  
625 - $this -> assign('yewu',array());  
626 - }  
627 -// $this -> assign('res',$aaaa);  
628 -// $this -> assign('my_res',$my_res);  
629 - return $this -> fetch();  
630 -  
631 - }  
632 -  
633 - /**  
634 - * 提现明细  
635 - */  
636 - public function withdrawal_subsidiary(){  
637 -  
638 - $uid = cmf_get_current_user_id();  
639 - $data = Db::name('money_expend')  
640 - -> where('uid='.$uid)  
641 - -> where("state = 1 or state = 2")  
642 - -> order("create_time desc")  
643 - -> select();  
644 - $this -> assign('data',$data);  
645 - return $this -> fetch();  
646 -  
647 - }  
648 -  
649 - /**  
650 - * 显示商场盈利  
651 - */  
652 - public function mall_profit(){  
653 -  
654 - $uid = cmf_get_current_user_id();  
655 - $my_user = Db::name('my_user') -> where('uid',$uid) -> find();  
656 - if($my_user['status'] == 2){  
657 - $res = $this -> request -> param();  
658 - if(count($res) != 0){  
659 - $where = [  
660 - 'a.indent_type' => 2,  
661 - 'a.salesman_uid' => $uid,  
662 - ];  
663 - if($res['school'] != ''){  
664 - $where['a.school'] = $res['school'];  
665 - }  
666 - if($res['grade'] != ''){  
667 - $school_grade_class = explode('-',$res['grade']);  
668 - $where['a.grade'] = trim($school_grade_class[0]);  
669 - $where['a.class'] = trim($school_grade_class[1]);  
670 - }  
671 -  
672 - if($res['is_courier'] != ''){  
673 - if($res['is_courier'] == '统一配送'){  
674 - $where['a.is_courier'] = 1;  
675 - }  
676 - if($res['is_courier'] == '快递配送'){  
677 - $where['a.is_courier'] = 2;  
678 - }  
679 - }  
680 -  
681 - if($res['start_time'] != '' && $res['end_time'] != ''){  
682 - $start_time = strtotime($res['start_time']);  
683 - $end_time = strtotime($res['end_time']);  
684 - $where['a.pay_time'] = [['>=',$start_time],['<=',$end_time]];  
685 - }  
686 - /*$indent_goods = Db::name('indent') -> alias('a') -> field("a.*,b.indent_id,b.book_name,b.pricing,b.price,b.number,b.thumbnail") -> join('indent_goods b','a.id=b.indent_id','LEFT') -> where($where) -> where("a.state =2 or a.state=3 or a.state=5") -> select();*/  
687 - $indent_money = Db::name('indent') -> alias('a') -> field("a.id,a.order_number,a.pay_time,b.uid,b.money,b.type,b.book_num,b.indent_id,a.school,a.grade,a.class") -> join('money_income b','a.id=b.indent_id','LEFT') -> where($where) -> where("a.state =2 or a.state=3 or a.state=5") -> where("b.uid =".$uid) -> order('a.pay_time desc') -> select() -> toArray();  
688 -  
689 - if(count($indent_money)!=0){  
690 - foreach ($indent_money as $key => $val){  
691 - $indent_money[$key]['book_name'] = Db::name('indent_goods') -> where('indent_id',$val['id']) -> select() -> toArray();  
692 - }  
693 - }  
694 - $this -> assign('indent_goods',$indent_money);  
695 - }else{  
696 -  
697 - /*$indent_goods = Db::name('indent') -> alias('a') -> field("a.*,b.indent_id,b.book_name,b.pricing,b.price,b.number,b.thumbnail") -> join('indent_goods b','a.id=b.indent_id','LEFT') -> where('a.indent_type=2 and a.salesman_uid='.$uid) -> where("a.state =2 or a.state=3 or a.state=5") -> select();*/  
698 - $indent_goods = Db::name('indent') -> alias('a') -> field("a.id,a.order_number,a.pay_time,b.uid,b.money,b.type,b.book_num,b.indent_id") -> join('money_income b','a.id=b.indent_id','LEFT') -> where('a.indent_type=2 and a.salesman_uid='.$uid) -> where("a.state =2 or a.state=3 or a.state=5") -> where("b.uid =".$uid) -> order('a.pay_time desc') -> select() -> toArray();  
699 - if(count($indent_goods)!=0){  
700 - foreach ($indent_goods as $key => $val){  
701 - $indent_goods[$key]['book_name'] = Db::name('indent_goods') -> where('indent_id',$val['id']) -> select() -> toArray();  
702 - }  
703 - }  
704 -  
705 - $this -> assign('indent_goods',$indent_goods);  
706 -// $indent_money = Db::name('money_income') -> where("uid =".$uid) -> select();  
707 - $indent_money = $indent_goods;  
708 - }  
709 -  
710 - $total_money = 0;  
711 - foreach ($indent_money as $key => $val){  
712 - $total_money += $val['money'];  
713 - }  
714 - //保留两位小数  
715 - $total_money = number_format($total_money,2);  
716 -// $total_money = $total_money-$total_money*0.006;  
717 - $this -> assign('total_money',$total_money);  
718 -  
719 - //显示学校年级  
720 - $school = Db::name('school') -> where('uid',$uid) -> select() -> toArray();  
721 - $schools = [];  
722 - $grade_class_show = [];  
723 - if(count($school) != 0){  
724 - $grade_class = Db::name('grade_class') -> where("school_id",$school[0]['id']) -> select();  
725 - foreach ($grade_class as $key => $val){  
726 - $class = explode('-',$val['class']);  
727 - for($i=$class[0];$i<=$class[1];$i++){  
728 - $grade_class_show[] = $val['grade'].' - '.$i."班";  
729 - }  
730 - }  
731 - foreach ($school as $key => $val){  
732 - $schools[$key]['value'] = $val['id'];  
733 - $schools[$key]['text'] = $val['school'];  
734 - }  
735 - }  
736 - $this -> assign('school',json_encode($schools));  
737 - $this -> assign('grade_class_show',$grade_class_show);  
738 - //显示平台盈利  
739 - //查询业务员下级所有老师的订单  
740 - $teacher_user = Db::name('my_user') -> where("pid",$my_user['id']) -> select() -> toArray();  
741 - foreach ($teacher_user as $key => $val){  
742 - $teacher_indent[$key] = Db::name('indent') -> where("indent_type=1 and uid=".$val['uid']) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();  
743 - foreach ($teacher_indent[$key] as $key1 => $val1){  
744 - $money_income = Db::name('money_income') -> where("indent_id=".$val1['id']." and uid=".$my_user['uid']) -> select();  
745 - foreach ($money_income as $key3 => $val3){  
746 - $platform_money[] = $val3;  
747 - }  
748 - }  
749 - }  
750 - //查询老师下学生的订单  
751 - foreach ($teacher_user as $key => $val){  
752 - //查询老师下的所有学生  
753 - $student[$key] = Db::name('my_user') -> where("pid",$val['id']) -> select();  
754 - //查询学生的所有订单  
755 - foreach ($student[$key] as $key1 => $val1){  
756 - $student_indent[$key1] = Db::name('indent') -> where("indent_type=1 and uid=".$val1['uid']) -> where("state = 2 or state = 3 or state = 5") -> select();  
757 - //查询学生订单下属于业务员的收入记录  
758 - foreach ($student_indent[$key1] as $key2 => $val2){  
759 - $student_money_income = Db::name('money_income') -> where("indent_id=".$val2['id']." and uid=".$my_user['uid']) -> select();  
760 - foreach ($student_money_income as $key3 => $val3){  
761 - $platform_money[] = $val3;  
762 - }  
763 - }  
764 - }  
765 - }  
766 - if(empty($platform_money)){  
767 - $platform_money = null;  
768 - }  
769 - $this -> assign('platform_money',$platform_money);  
770 - }else{  
771 - $this -> error('非业务员不能进去此页');  
772 - }  
773 -  
774 -  
775 - return $this -> fetch();  
776 -  
777 - }  
778 -  
779 - /**  
780 - * 点击学校时获取年级班级  
781 - */  
782 - public function get_grade_class(){  
783 -  
784 - $school_id = $_POST['id'];  
785 - $grade_class = Db::name('grade_class') -> where("school_id",$school_id) -> select() -> toArray();  
786 - if(!empty($grade_class)){  
787 - foreach ($grade_class as $key => $val){  
788 - $class = explode('-',$val['class']);  
789 - for($i=$class[0];$i<=$class[1];$i++){  
790 - $grade_class_show[] = $val['grade'].' - '.$i."班";  
791 - }  
792 - }  
793 - foreach ($grade_class_show as $key => $val){  
794 - $grade_class_shows[$key]['value'] = $key;  
795 - $grade_class_shows[$key]['text'] = $val;  
796 - }  
797 - return json_encode($grade_class_shows);  
798 - }else{  
799 - return false;  
800 - }  
801 -  
802 - }  
803 -  
804 - /**  
805 - * 但图片上传  
806 - */  
807 - public function image_one_up(){  
808 -  
809 - $file = request()->file('avatar');  
810 -  
811 - // 移动到框架应用根目录/public/uploads/ 目录下  
812 - if($file){  
813 - $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');  
814 - if($info){  
815 - // 成功上传后 获取上传信息  
816 - // 输出 jpg  
817 - $image = $info->getSaveName();  
818 - $this->apiResponse(1,'成功',$image);  
819 - // 输出 20160820/42a79759f284b767dfcb2a0197904287.jpg  
820 - }else{  
821 - // 上传失败获取错误信息  
822 - echo $file->getError();  
823 - }  
824 - }  
825 -  
826 - }  
827 -  
828 - public function apiResponse($code = '', $msg = '',$data = array()){  
829 - header('Access-Control-Allow-Origin: *');  
830 - header('Content-Type:application/json; charset=utf-8');  
831 - $result = array(  
832 - 'code'=>$code,  
833 - 'msg'=>$msg,  
834 - 'data'=>$data,  
835 - );  
836 - die(json_encode($result,JSON_UNESCAPED_UNICODE));  
837 - }  
838 -  
839 - /**  
840 - *判断是否首次提现  
841 - */  
842 - public function id_first_withdrawal(){  
843 -  
844 - $uid = cmf_get_current_user_id();  
845 - $my_user = Db::name('my_user') -> where('uid',$uid) -> find();  
846 - if($my_user['is_withdrawal'] == '1'){  
847 - return true;  
848 - }else{  
849 - return false;  
850 - }  
851 -  
852 - }  
853 -  
854 - /**  
855 - * 首次提现手机验证码判断  
856 - */  
857 - public function is_money_code(){  
858 -  
859 - $uid = cmf_get_current_user_id();  
860 - $code = session('code');  
861 - if($code == $_POST['yzm']){  
862 - $user = Db::name('my_user') -> where('uid',$uid) -> find();  
863 - if(empty($user['phone'])){  
864 - Db::name('my_user') -> where('uid',$uid) -> update(['phone'=>$_POST['phone']]);  
865 - }  
866 - Db::name('my_user') -> where('uid',$uid) -> update(['is_withdrawal'=>2]);  
867 - return true;  
868 - }else{  
869 - return false;  
870 - }  
871 -  
872 - }  
873 -  
874 -  
875 -  
876 -  
877 -  
878 -  
879 -  
880 -  
881 -  
882 -  
883 -  
884 -  
885 -  
886 -  
887 - 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 +namespace app\portal\controller;
  10 +
  11 +use cmf\controller\WeChatBaseController;
  12 +use EasyWeChat\Foundation\Application;
  13 +use think\Db;
  14 +
  15 +class sendAPI {
  16 + public $data; //发送数据
  17 + public $timeout = 30; //超时
  18 + private $apiUrl; //发送地址
  19 + private $username; //用户名
  20 + private $password; //密码
  21 +
  22 + function __construct($url, $username, $password) {
  23 + $this->apiUrl = $url;
  24 + $this->username = $username;
  25 + $this->password = $password;
  26 + }
  27 +
  28 + private function httpGet() {
  29 + $url = $this->apiUrl . '?' . http_build_query($this->data);
  30 + $curl = curl_init();
  31 + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  32 + curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout);
  33 + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  34 + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  35 + curl_setopt($curl, CURLOPT_URL, $url);
  36 + $res = curl_exec($curl);
  37 + if (curl_errno($curl)) {
  38 + echo 'Error GET '.curl_error($curl);
  39 + }
  40 + curl_close($curl);
  41 + return $res;
  42 + }
  43 +
  44 + private function httpPost(){ // 模拟提交数据函数
  45 + $curl = curl_init(); // 启动一个CURL会话
  46 + curl_setopt($curl, CURLOPT_URL, $this->apiUrl); // 要访问的地址
  47 + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
  48 + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
  49 + curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
  50 + curl_setopt($curl, CURLOPT_POST, true); // 发送一个常规的Post请求
  51 + curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($this->data)); // Post提交的数据包
  52 + curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout); // 设置超时限制防止死循环
  53 + curl_setopt($curl, CURLOPT_HEADER, false); // 显示返回的Header区域内容
  54 + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // 获取的信息以文件流的形式返回
  55 + $result = curl_exec($curl); // 执行操作
  56 + if (curl_errno($curl)) {
  57 + echo 'Error POST'.curl_error($curl);
  58 + }
  59 + curl_close($curl); // 关键CURL会话
  60 + return $result; // 返回数据
  61 + }
  62 +
  63 + /**
  64 + * @param $type|提交类型 POST/GET
  65 + * @param $isTranscoding|是否需要转 $isTranscoding 是否需要转utf-8 默认 false
  66 + * @return mixed
  67 + */
  68 + public function sendSMS($type, $isTranscoding = false) {
  69 + $this->data['content'] = $isTranscoding === true ? mb_convert_encoding($this->data['content'], "UTF-8") : $this->data['content'];
  70 + $this->data['username'] = $this->username;
  71 + $this->data['tkey'] = date('YmdHis');
  72 + $this->data['password'] = md5(md5($this->password) . $this->data['tkey']);
  73 + return $type == "POST" ? $this->httpPost() : $this->httpGet();
  74 + }
  75 +
  76 +}
  77 +
  78 +class PersonalcenterController extends WeChatBaseController{
  79 +
  80 + /**
  81 + * 显示个人中心页
  82 + */
  83 + public function personal_center(){
  84 +
  85 + $uid = cmf_get_current_user_id();
  86 + $my_user_status = Db::name('my_user') -> where('uid',$uid) -> find();
  87 + $weixin = Db::name('user') -> where('id',$uid) -> find();
  88 + $this -> assign('weixin',$weixin);
  89 + if($my_user_status['status'] == 0 || $my_user_status['status'] == 1 || $my_user_status['status'] == 3 || $my_user_status['status'] == 4 || $my_user_status['status'] == 5 || $my_user_status['status'] == 6){
  90 + if($my_user_status['status'] == 0){
  91 + $this -> assign('status',0);
  92 + }
  93 + if($my_user_status['status'] == 1 || $my_user_status['status'] == 5 || $my_user_status['status'] == 6){
  94 + $this -> assign('status',1);
  95 + }
  96 + if($my_user_status['status'] == 3){
  97 + $this -> assign('status',3);
  98 + }
  99 + if($my_user_status['status'] == 4){
  100 + $this -> assign('status',4);
  101 + }
  102 + return $this -> fetch();
  103 + }
  104 + //业务员个人中心页
  105 + if($my_user_status['status'] == 2){
  106 + $this -> assign('weixin',$weixin);
  107 + return $this -> fetch('personalcenter/salesman_center');
  108 + }
  109 +
  110 + }
  111 +
  112 + /**
  113 + * 完善个人信息页
  114 + */
  115 + public function perfect_information(){
  116 +
  117 + $uid = cmf_get_current_user_id();
  118 + $my_user_status = Db::name('my_user') -> where('uid',$uid) -> find();
  119 + if($my_user_status['status'] == 2){
  120 + $this -> redirect('Personalcenter/personal_center');
  121 + }else{
  122 + if($my_user_status['status'] == 1){
  123 + $this -> assign('status',1);
  124 + }
  125 + if($my_user_status['status'] == 5){
  126 + $this -> assign('status',5);
  127 + }
  128 + if($my_user_status['status'] == 6){
  129 + $this -> assign('status',6);
  130 + }
  131 + $weixin = Db::name('user') -> where('id',$uid) -> find();
  132 + $this -> assign('weixin',$weixin);
  133 + return $this -> fetch();
  134 + }
  135 +
  136 + }
  137 +
  138 +
  139 + /**
  140 + * 我的收藏页
  141 + */
  142 + public function personal_collect(){
  143 +
  144 + $uid = cmf_get_current_user_id();
  145 + $data = Db::name('collect') -> where("uid =".$uid) -> select() -> toArray();
  146 +
  147 + if(!empty($data)){
  148 + foreach($data as $key => $val){
  149 + $collect_goods = Db::name('goods') -> where("id =".$val['goods_id']) -> where("is_out = 1") -> find();
  150 + if($collect_goods != null){
  151 + $data_goods[] = $collect_goods;
  152 + }
  153 + }
  154 + if(!empty($data_goods)){
  155 + foreach ($data_goods as $key => $val){
  156 + $price = explode('.',$val['price']);
  157 + $pricing = explode('.',$val['pricing']);
  158 + $data_goods[$key]['price0'] = $price[0];
  159 + $data_goods[$key]['price1'] = $price[1];
  160 + $data_goods[$key]['pricing0'] = $pricing[0];
  161 + $data_goods[$key]['pricing1'] = $pricing[1];
  162 + }
  163 + }else{
  164 + $data_goods = '';
  165 + }
  166 + }else{
  167 + $data_goods = '';
  168 + }
  169 + if(!empty($data_goods)){
  170 + $data_count = count($data_goods);
  171 + }else{
  172 + $data_count = 0;
  173 + }
  174 + $this -> assign('data_count',$data_count);
  175 + $this -> assign('data_goods',$data_goods);
  176 + return $this -> fetch();
  177 +
  178 + }
  179 +
  180 + /**
  181 + * 填写个人信息页
  182 + */
  183 + public function add_information(){
  184 +
  185 + $options=config('wechat_config');
  186 + $app = new Application($options);
  187 + $js = $app->js;
  188 + $jssdk=$js->config(array('chooseImage','uploadImage'), false,false,true);
  189 + $this->assign('jssdk',$jssdk);
  190 + return $this -> fetch();
  191 +
  192 + }
  193 +
  194 +
  195 + /**
  196 + * 浏览记录
  197 + */
  198 + public function browsing_history(){
  199 +
  200 + $uid = cmf_get_current_user_id();
  201 + $data = Db::name('browsing_history') -> where("uid =".$uid) -> select();
  202 + foreach($data as $key => $val){
  203 + $browsing_history_goods = Db::name('goods') -> where('id',$val['goods_id']) -> where("is_out = 1") -> find();
  204 + if($browsing_history_goods != null){
  205 + $data_goods[] = $browsing_history_goods;
  206 + }
  207 + }
  208 + if(!empty($data_goods)){
  209 + foreach($data_goods as $key => $val){
  210 + $price = explode('.',$val['price']);
  211 + $classification_name = Db::name('classification') -> where('id',$val['classify_id']) -> find();
  212 + $data_goods[$key]['classification_name'] = $classification_name['name'];
  213 + $data_goods[$key]['price0'] = $price[0];
  214 + $data_goods[$key]['price1'] = $price[1];
  215 + }
  216 + }else{
  217 + $data_goods = '';
  218 + }
  219 + $this -> assign('data_goods',$data_goods);
  220 + return $this -> fetch();
  221 +
  222 + }
  223 +
  224 + /**
  225 + * 收货地址页
  226 + */
  227 + public function shop_address(){
  228 +
  229 + $uid = cmf_get_current_user_id();
  230 + $data = Db::name('address') -> where("delete_time = 0 and uid =".$uid) -> select() -> toArray();
  231 + $this -> assign('data',$data);
  232 + return $this -> fetch();
  233 +
  234 + }
  235 +
  236 + /**
  237 + * 新增地址页
  238 + */
  239 + public function add_shop_address(){
  240 +
  241 + if($this -> request -> isPost()){
  242 + $uid = cmf_get_current_user_id();
  243 + $_POST['uid'] = $uid;
  244 + $add = Db::name('address') -> insert($_POST);
  245 + if($add){
  246 + return true;
  247 + }else{
  248 + return false;
  249 + }
  250 + }else{
  251 + return $this -> fetch();
  252 + }
  253 +
  254 + }
  255 +
  256 + /**
  257 + * 设置默认地址
  258 + */
  259 + public function set_default_address(){
  260 +
  261 + $uid = cmf_get_current_user_id();
  262 + Db::name('address') -> where('uid',$uid) -> update(['default_address'=>0]);
  263 + $data = Db::name('address') -> where('id',$_POST['id']) -> update(['default_address'=>1]);
  264 + if($data){
  265 + return true;
  266 + }else{
  267 + return false;
  268 + }
  269 +
  270 + }
  271 +
  272 + /**
  273 + * 删除地址
  274 + */
  275 + public function address_del(){
  276 +
  277 + $delete_time = time();
  278 + $data = Db::name('address') -> where('id',$_POST['id']) -> update(['delete_time'=>$delete_time]);
  279 + if($data){
  280 + return true;
  281 + }else{
  282 + return false;
  283 + }
  284 +
  285 + }
  286 +
  287 + /**
  288 + * 编辑地址
  289 + */
  290 + public function address_edit(){
  291 +
  292 + if($this -> request -> isPost()){
  293 + $data_update = Db::name('address') -> update($_POST);
  294 + if($data_update){
  295 + return true;
  296 + }else{
  297 + return false;
  298 + }
  299 + }else{
  300 + $id = $this -> request -> param();
  301 + $data = Db::name('address') -> where('id',$id['id']) -> find();
  302 + $this -> assign('data',$data);
  303 + return $this -> fetch();
  304 + }
  305 +
  306 + }
  307 +
  308 + /**
  309 + * 发送短信
  310 + */
  311 + public function send_message(){
  312 +
  313 + $url = "http://www.ztsms.cn/sendNSms.do";//提交地址
  314 + $username = 'xuekaowuyou';//用户名
  315 + $password = 'Cxz307312';//原密码
  316 + $sendAPI = new sendAPI($url, $username, $password);
  317 + $key = '';
  318 + $pattern='1234567890';
  319 + for( $i=0; $i<6; $i++ ) {
  320 + $key .= $pattern[mt_rand(0, 9)];
  321 + }
  322 + session('code',$key);
  323 + $rand_name = "验证码:".$key."【学考无忧】";
  324 + $phone = $_POST['phone'];
  325 + $data = array(
  326 + 'content' => $rand_name,//短信内容
  327 + 'mobile' => $phone,//手机号码
  328 + 'productid' => '676767',//产品id
  329 + 'xh' => ''//小号
  330 + );
  331 + $sendAPI->data = $data;//初始化数据包
  332 + $return = $sendAPI->sendSMS('POST');//GET or POST
  333 + if($return){
  334 + return true;
  335 + }else{
  336 + return false;
  337 + }
  338 +
  339 + }
  340 +
  341 + /**
  342 + * 添加审核信息
  343 + */
  344 + public function add_audit(){
  345 +
  346 + $code = session('code');
  347 + if($code == $_POST['code']){
  348 + //判断是否提交过
  349 + $id_num = $_POST['id_num'];
  350 + $id_number = Db::name('sale_audit') -> where("id_number = '$id_num' ") -> find();
  351 + if(!empty($id_number)){
  352 + return 4;
  353 + }
  354 + $data['name'] = $_POST['name'];
  355 + $data['phone'] = $_POST['phone'];
  356 + $data['id_number'] = $_POST['id_num'];
  357 + $data['img_front'] = $_POST['img0'];
  358 + $data['img_back'] = $_POST['img1'];
  359 + $data['create_time'] = time();
  360 + $data['uid'] = cmf_get_current_user_id();
  361 + $inser = Db::name('sale_audit') -> insert($data);
  362 + if($inser){
  363 + Db::name('my_user') -> where('uid',$data['uid']) -> update(['status'=>5,'phone'=>$data['phone']]);
  364 + return 1;
  365 + }else{
  366 + return 2;
  367 + }
  368 + }else{
  369 + return 3;
  370 + }
  371 +
  372 + }
  373 +
  374 + /**
  375 + * 我的钱包页
  376 + */
  377 + public function my_wallet(){
  378 +
  379 + $uid = cmf_get_current_user_id();
  380 + $balance = Db::name('my_user') -> where("uid",$uid) -> find();
  381 + $b_money = $balance['balance'];
  382 + $b_money = sprintf("%.2f",$b_money);
  383 + $this -> assign('b_money',$b_money);
  384 +
  385 + $money_income = Db::name("money_income") -> where('uid',$uid) -> select();
  386 + $cumulative_money = 0;
  387 + foreach ($money_income as $key => $val){
  388 + $cumulative_money += $val['money'];
  389 + }
  390 + $cumulative_moneyss = $cumulative_money;
  391 + $cumulative_moneyss = sprintf("%.2f",$cumulative_moneyss);
  392 + $this -> assign('cumulative_moneyss',$cumulative_moneyss);
  393 + $cumulative_money = $cumulative_money-$cumulative_money*0.006;
  394 + $cumulative_money = sprintf("%.2f",$cumulative_money);
  395 + $money_ratio = Db::name('money_ratio') -> where('id',1) -> find();
  396 + $money_ratio['platform_ratio'] = $money_ratio['platform_ratio']*100;
  397 + $money_ratio['platform_ratio'] = $money_ratio['platform_ratio'].'%';
  398 + $this -> assign('money_ratio',$money_ratio);
  399 +
  400 + $this -> assign('cumulative_money',$cumulative_money);
  401 + $money_expend = Db::name('money_expend') -> where('uid='.$uid." and state=0") -> select();
  402 + $money = 0;
  403 + foreach ($money_expend as $key => $val){
  404 + $money += $val['money'];
  405 + }
  406 + $tax_money = $money/(1-0.006);
  407 + $money = number_format($money,2);
  408 +
  409 + $balance['balance'] = $balance['balance'] - $balance['balance']*0.006-$tax_money;
  410 + $balance['balance'] = sprintf("%.2f", $balance['balance']);
  411 + if($balance['balance'] <= 0){
  412 + $balance['balance'] = 0;
  413 + }
  414 + $this -> assign('balance',$balance['balance']);
  415 +
  416 + $this -> assign('status',$balance['status']);
  417 + $this -> assign('money',$money);
  418 + return $this -> fetch();
  419 +
  420 + }
  421 +
  422 + /**
  423 + * 将提现金额存入支出明细表
  424 + */
  425 + public function add_money_expend(){
  426 +
  427 + $_POST['uid'] = cmf_get_current_user_id();
  428 + $_POST['create_time'] = time();
  429 + $_POST['state'] = 0;
  430 + $user_balance = Db::name('my_user') -> where('uid',$_POST['uid']) -> find();
  431 + $user_money_expend = Db::name('money_expend') -> where("uid=".$_POST['uid']." and state =0") -> select();
  432 + $money_expend = $_POST['money'];
  433 + $my_money_expend = 0;
  434 + foreach ($user_money_expend as $key => $val){
  435 + $my_money_expend += $val['money'];
  436 + }
  437 + $tax_money = $my_money_expend/(1-0.006);
  438 + $user_balance['balance'] = $user_balance['balance']-$user_balance['balance']*0.006-$tax_money;
  439 + if($money_expend > $user_balance['balance'] ){
  440 + return false;
  441 + }else{
  442 + $data = Db::name('money_expend') -> insert($_POST);
  443 + $money_expend = Db::name('money_expend') -> where('uid='.$_POST['uid']." and state=0") -> select();
  444 + $money = 0;
  445 + foreach ($money_expend as $key => $val){
  446 + $money += $val['money'];
  447 + }
  448 + $money = number_format($money,2);
  449 + if($data){
  450 + return $money;
  451 + }else{
  452 + return false;
  453 + }
  454 + }
  455 +
  456 + }
  457 +
  458 + /**
  459 + * 邀请名单
  460 + */
  461 + public function invitation_list(){
  462 +
  463 + $uid = cmf_get_current_user_id();
  464 + $my_user = Db::name('my_user') -> where('uid',$uid) -> find();
  465 + if($my_user['status'] == 3){
  466 + $student = Db::name('my_user') -> alias('a') -> field("a.*,b.user_nickname,b.avatar") -> join("user b","a.uid = b.id",'LEFT') -> where("a.pid",$my_user['id']) -> select() -> toArray();
  467 + if(!empty($student)){
  468 + foreach ($student as $key => $val){
  469 + $student[$key]['indent'] = Db::name('indent') -> where('uid',$val['uid']) -> where("state = 2 or state = 3 or state = 5") -> order("pay_time desc") -> select() -> toArray();
  470 + $name = $val['user_nickname'];
  471 + $avatar = $val['avatar'];
  472 + $cumulative_money = 0;
  473 + foreach ($student[$key]['indent'] as $key1 => $val1){
  474 + $student[$key]['indent'][$key1]['user_name'] = $name;
  475 + $student[$key]['indent'][$key1]['avatar'] = $avatar;
  476 + $money_income = Db::name('money_income') -> where("indent_id =".$val1['id']." and uid = ".$uid) -> select() -> toArray();
  477 + $money = 0;
  478 + foreach ($money_income as $key2 => $val2){
  479 + $money += $val2['money'];
  480 + }
  481 + $student[$key]['indent'][$key1]['total_money'] = number_format($money,2);
  482 + $cumulative_money += $money;
  483 + }
  484 + $student[$key]['cumulative_money'] = number_format($cumulative_money,2);
  485 +
  486 + }
  487 + }else{
  488 + $student = null;
  489 + }
  490 + $this -> assign('type',3);
  491 + $this -> assign('student',$student);
  492 + }elseif ($my_user['status'] == 2){
  493 + //查找业务员下级老师
  494 + $teacher = Db::name('my_user') -> alias('a') -> field("a.*,b.user_nickname,b.avatar") -> join("user b","a.uid = b.id",'LEFT') -> where("a.pid",$my_user['id']) -> select() -> toArray();
  495 + if(!empty($teacher)){
  496 + foreach ($teacher as $key => $val){
  497 + $money_income = Db::name('money_income') -> where("uid",$val['uid']) -> select();
  498 + $total_commission = 0;
  499 + foreach ($money_income as $key1 => $val1){
  500 + $total_commission += $val1['money'];
  501 + }
  502 + $teacher[$key]['total_commission'] = $total_commission;
  503 + //查找老师下面的学生
  504 + $teacher[$key]['student'] = Db::name('my_user') -> alias('a') -> field("a.*,b.user_nickname,b.avatar") -> join("user b","a.uid = b.id",'LEFT') -> where("a.pid",$val['id']) -> select() -> toArray();
  505 + if(!empty($teacher[$key]['student'])){
  506 + foreach ($teacher[$key]['student'] as $key2 => $val2){
  507 + $teacher[$key]['student'][$key2]['indent'] = Db::name('indent') -> where('uid',$val2['uid']) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();
  508 + $student_indent_money = 0;
  509 + foreach ($teacher[$key]['student'][$key2]['indent'] as $key3 => $val3){
  510 + $student_money_income = Db::name('money_income') -> where("indent_id =".$val3['id']." and uid = ".$val['uid']) -> select() -> toArray();
  511 + $student_money_income_money = 0;
  512 + foreach ($student_money_income as $key4 => $val4){
  513 + $student_money_income_money += $val4['money'];
  514 + }
  515 + $teacher[$key]['student'][$key2]['indent']['student_money_income_money'] = $student_money_income_money;
  516 + $student_indent_money += $student_money_income_money;
  517 + }
  518 + $teacher[$key]['student'][$key2]['indent_money'] = $student_indent_money;
  519 + }
  520 + }
  521 + }
  522 + }else{
  523 + $teacher = null;
  524 + }
  525 + $this -> assign('type',2);
  526 + $this -> assign('teacher',$teacher);
  527 + }
  528 + return $this -> fetch();
  529 +
  530 + }
  531 +
  532 + /**
  533 + * 收入记录
  534 + */
  535 + public function income_record(){
  536 +
  537 + $uid = cmf_get_current_user_id();
  538 + $get = $this -> request -> param();
  539 + $my_user = Db::name('my_user') -> where('uid',$uid) -> find();
  540 + //搜索老师下级学生用户
  541 + $student = Db::name('my_user') -> alias('a') -> field("a.*,b.user_nickname,b.avatar") -> join("user b","a.uid = b.id",'LEFT') -> where("a.pid",$my_user['id']) -> select() -> toArray();
  542 + foreach ($student as $key => $val){
  543 + if(!empty($get['startime']) && !empty($get['endtime'])){
  544 + $startime = strtotime($get['startime']);
  545 + $endtime = strtotime($get['endtime'])+86400;
  546 + $data[$key] = Db::name('indent') -> where('uid',$val['uid']) -> where("state = 2 or state = 3 or state = 5") -> where("pay_time>=".$startime." and pay_time<=".$endtime) -> select() -> toArray();
  547 + }else{
  548 + $data[$key] = Db::name('indent') -> where('uid',$val['uid']) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();
  549 + }
  550 + $name = $val['user_nickname'];
  551 + $avatar = $val['avatar'];
  552 + if(count($data[$key])!=0){
  553 + foreach ($data[$key] as $key1 => $val1){
  554 + $book_name = Db::name('indent_goods') -> where("indent_id",$val1['id']) -> find();
  555 + $data[$key][$key1]['user_name'] = $name;
  556 + $data[$key][$key1]['avatar'] = $avatar;
  557 + $data[$key][$key1]['book_name'] = $book_name['book_name'];
  558 + $money_income = Db::name('money_income') -> where("indent_id =".$val1['id']." and uid = ".$uid) -> select() -> toArray();
  559 + $money = 0;
  560 + foreach ($money_income as $key2 => $val2){
  561 + $money += $val2['money'];
  562 + }
  563 + $data[$key][$key1]['total_money'] = number_format($money,2);
  564 + $res[] = $data[$key][$key1];
  565 + }
  566 + }
  567 +
  568 + }
  569 + if(empty($res)){
  570 + $res = array();
  571 + }
  572 +// $this -> assign('res',$res);
  573 + //搜索老师用户
  574 + $teacher_avatar = Db::name('user') -> where('id',$uid) -> find();
  575 + if(!empty($get['startime']) && !empty($get['endtime'])){
  576 + $startime = strtotime($get['startime']);
  577 + $endtime = strtotime($get['endtime'])+86400;
  578 + $teacher = Db::name('indent') -> where('uid',$uid) -> where("pay_time>=".$startime." and pay_time<=".$endtime) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();
  579 + }else{
  580 + $teacher = Db::name('indent') -> where('uid',$uid) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();
  581 + }
  582 +
  583 + foreach($teacher as $key => $val){
  584 + $teacher_book_name = Db::name('indent_goods') -> where("indent_id",$val['id']) -> find();
  585 + $teacher_data[$key]['user_name'] = $teacher_avatar['user_nickname'];
  586 + $teacher_data[$key]['avatar'] = $teacher_avatar['avatar'];
  587 + $teacher_data[$key]['book_name'] = $teacher_book_name['book_name'];
  588 + $tea_money_income = Db::name('money_income') -> where("indent_id =".$val['id']." and uid = ".$uid) -> select() -> toArray();
  589 + $money = 0;
  590 + foreach ($tea_money_income as $key2 => $val2){
  591 + $money += $val2['money'];
  592 + }
  593 + $teacher_data[$key]['total_money'] = number_format($money,2) ;
  594 + $teacher_data[$key]['indent_type'] = $val['indent_type'];
  595 + $teacher_data[$key]['create_time'] = $val['create_time'];
  596 + $my_res[] = $teacher_data[$key];
  597 + }
  598 + if(empty($my_res)){
  599 + $my_res = array();
  600 + }
  601 + $aaaa = array_merge($res,$my_res);
  602 + $bb = array_column($aaaa,'create_time');
  603 + $cc = array_multisort($bb,SORT_DESC,$aaaa);
  604 + if(count($res)!=0 || count($my_res)!=0){
  605 + foreach ($aaaa as $key=>$val){
  606 + if($val['indent_type'] == 1){
  607 + $pingtai[] = $val;
  608 + }else{
  609 + $yewu[] = $val;
  610 + }
  611 + }
  612 + if(empty($pingtai)){
  613 + $this -> assign('pingtai',array());
  614 + }else{
  615 + $this -> assign('pingtai',$pingtai);
  616 + }
  617 + if(empty($yewu)){
  618 + $this -> assign('yewu',array());
  619 + }else{
  620 + $this -> assign('yewu',$yewu);
  621 + }
  622 +
  623 + }else{
  624 + $this -> assign('pingtai',array());
  625 + $this -> assign('yewu',array());
  626 + }
  627 +// $this -> assign('res',$aaaa);
  628 +// $this -> assign('my_res',$my_res);
  629 + return $this -> fetch();
  630 +
  631 + }
  632 +
  633 + /**
  634 + * 提现明细
  635 + */
  636 + public function withdrawal_subsidiary(){
  637 +
  638 + $uid = cmf_get_current_user_id();
  639 + $data = Db::name('money_expend')
  640 + -> where('uid='.$uid)
  641 + -> where("state = 1 or state = 2")
  642 + -> order("create_time desc")
  643 + -> select();
  644 + $this -> assign('data',$data);
  645 + return $this -> fetch();
  646 +
  647 + }
  648 +
  649 + /**
  650 + * 显示商场盈利
  651 + */
  652 + public function mall_profit(){
  653 +
  654 + $uid = cmf_get_current_user_id();
  655 + $my_user = Db::name('my_user') -> where('uid',$uid) -> find();
  656 + if($my_user['status'] == 2){
  657 + $res = $this -> request -> param();
  658 + if(count($res) != 0){
  659 + $where = [
  660 + 'a.indent_type' => 2,
  661 + 'a.salesman_uid' => $uid,
  662 + ];
  663 + if($res['school'] != ''){
  664 + $where['a.school'] = $res['school'];
  665 + }
  666 + if($res['grade'] != ''){
  667 + $school_grade_class = explode('-',$res['grade']);
  668 + $where['a.grade'] = trim($school_grade_class[0]);
  669 + $where['a.class'] = trim($school_grade_class[1]);
  670 + }
  671 +
  672 + if($res['is_courier'] != ''){
  673 + if($res['is_courier'] == '统一配送'){
  674 + $where['a.is_courier'] = 1;
  675 + }
  676 + if($res['is_courier'] == '快递配送'){
  677 + $where['a.is_courier'] = 2;
  678 + }
  679 + }
  680 +
  681 + if($res['start_time'] != '' && $res['end_time'] != ''){
  682 + $start_time = strtotime($res['start_time']);
  683 + $end_time = strtotime($res['end_time']);
  684 + $where['a.pay_time'] = [['>=',$start_time],['<=',$end_time]];
  685 + }
  686 + /*$indent_goods = Db::name('indent') -> alias('a') -> field("a.*,b.indent_id,b.book_name,b.pricing,b.price,b.number,b.thumbnail") -> join('indent_goods b','a.id=b.indent_id','LEFT') -> where($where) -> where("a.state =2 or a.state=3 or a.state=5") -> select();*/
  687 + $indent_money = Db::name('indent') -> alias('a') -> field("a.id,a.order_number,a.pay_time,b.uid,b.money,b.type,b.book_num,b.indent_id,a.school,a.grade,a.class") -> join('money_income b','a.id=b.indent_id','LEFT') -> where($where) -> where("a.state =2 or a.state=3 or a.state=5") -> where("b.uid =".$uid) -> order('a.pay_time desc') -> select() -> toArray();
  688 +
  689 + if(count($indent_money)!=0){
  690 + foreach ($indent_money as $key => $val){
  691 + $indent_money[$key]['book_name'] = Db::name('indent_goods') -> where('indent_id',$val['id']) -> select() -> toArray();
  692 + }
  693 + }
  694 + $this -> assign('indent_goods',$indent_money);
  695 + }else{
  696 +
  697 + /*$indent_goods = Db::name('indent') -> alias('a') -> field("a.*,b.indent_id,b.book_name,b.pricing,b.price,b.number,b.thumbnail") -> join('indent_goods b','a.id=b.indent_id','LEFT') -> where('a.indent_type=2 and a.salesman_uid='.$uid) -> where("a.state =2 or a.state=3 or a.state=5") -> select();*/
  698 + $indent_goods = Db::name('indent') -> alias('a') -> field("a.id,a.order_number,a.pay_time,b.uid,b.money,b.type,b.book_num,b.indent_id") -> join('money_income b','a.id=b.indent_id','LEFT') -> where('a.indent_type=2 and a.salesman_uid='.$uid) -> where("a.state =2 or a.state=3 or a.state=5") -> where("b.uid =".$uid) -> order('a.pay_time desc') -> select() -> toArray();
  699 + if(count($indent_goods)!=0){
  700 + foreach ($indent_goods as $key => $val){
  701 + $indent_goods[$key]['book_name'] = Db::name('indent_goods') -> where('indent_id',$val['id']) -> select() -> toArray();
  702 + }
  703 + }
  704 +
  705 + $this -> assign('indent_goods',$indent_goods);
  706 +// $indent_money = Db::name('money_income') -> where("uid =".$uid) -> select();
  707 + $indent_money = $indent_goods;
  708 + }
  709 +
  710 + $total_money = 0;
  711 + foreach ($indent_money as $key => $val){
  712 + $total_money += $val['money'];
  713 + }
  714 + //保留两位小数
  715 + $total_money = number_format($total_money,2);
  716 +// $total_money = $total_money-$total_money*0.006;
  717 + $this -> assign('total_money',$total_money);
  718 +
  719 + //显示学校年级
  720 + $school = Db::name('school') -> where('uid',$uid) -> select() -> toArray();
  721 + $schools = [];
  722 + $grade_class_show = [];
  723 + if(count($school) != 0){
  724 + $grade_class = Db::name('grade_class') -> where("school_id",$school[0]['id']) -> select();
  725 + foreach ($grade_class as $key => $val){
  726 + $class = explode('-',$val['class']);
  727 + for($i=$class[0];$i<=$class[1];$i++){
  728 + $grade_class_show[] = $val['grade'].' - '.$i."班";
  729 + }
  730 + }
  731 + foreach ($school as $key => $val){
  732 + $schools[$key]['value'] = $val['id'];
  733 + $schools[$key]['text'] = $val['school'];
  734 + }
  735 + }
  736 + $this -> assign('school',json_encode($schools));
  737 + $this -> assign('grade_class_show',$grade_class_show);
  738 + //显示平台盈利
  739 + //查询业务员下级所有老师的订单
  740 + $teacher_user = Db::name('my_user') -> where("pid",$my_user['id']) -> select() -> toArray();
  741 + foreach ($teacher_user as $key => $val){
  742 + $teacher_indent[$key] = Db::name('indent') -> where("indent_type=1 and uid=".$val['uid']) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();
  743 + foreach ($teacher_indent[$key] as $key1 => $val1){
  744 + $money_income = Db::name('money_income') -> where("indent_id=".$val1['id']." and uid=".$my_user['uid']) -> select();
  745 + foreach ($money_income as $key3 => $val3){
  746 + $platform_money[] = $val3;
  747 + }
  748 + }
  749 + }
  750 + //查询老师下学生的订单
  751 + foreach ($teacher_user as $key => $val){
  752 + //查询老师下的所有学生
  753 + $student[$key] = Db::name('my_user') -> where("pid",$val['id']) -> select();
  754 + //查询学生的所有订单
  755 + foreach ($student[$key] as $key1 => $val1){
  756 + $student_indent[$key1] = Db::name('indent') -> where("indent_type=1 and uid=".$val1['uid']) -> where("state = 2 or state = 3 or state = 5") -> select();
  757 + //查询学生订单下属于业务员的收入记录
  758 + foreach ($student_indent[$key1] as $key2 => $val2){
  759 + $student_money_income = Db::name('money_income') -> where("indent_id=".$val2['id']." and uid=".$my_user['uid']) -> select();
  760 + foreach ($student_money_income as $key3 => $val3){
  761 + $platform_money[] = $val3;
  762 + }
  763 + }
  764 + }
  765 + }
  766 + if(empty($platform_money)){
  767 + $platform_money = null;
  768 + }
  769 + $this -> assign('platform_money',$platform_money);
  770 + }else{
  771 + $this -> error('非业务员不能进去此页');
  772 + }
  773 +
  774 +
  775 + return $this -> fetch();
  776 +
  777 + }
  778 +
  779 + /**
  780 + * 点击学校时获取年级班级
  781 + */
  782 + public function get_grade_class(){
  783 +
  784 + $school_id = $_POST['id'];
  785 + $grade_class = Db::name('grade_class') -> where("school_id",$school_id) -> select() -> toArray();
  786 + if(!empty($grade_class)){
  787 + foreach ($grade_class as $key => $val){
  788 + $class = explode('-',$val['class']);
  789 + for($i=$class[0];$i<=$class[1];$i++){
  790 + $grade_class_show[] = $val['grade'].' - '.$i."班";
  791 + }
  792 + }
  793 + foreach ($grade_class_show as $key => $val){
  794 + $grade_class_shows[$key]['value'] = $key;
  795 + $grade_class_shows[$key]['text'] = $val;
  796 + }
  797 + return json_encode($grade_class_shows);
  798 + }else{
  799 + return false;
  800 + }
  801 +
  802 + }
  803 +
  804 + /**
  805 + * 但图片上传
  806 + */
  807 + public function image_one_up(){
  808 +
  809 + $file = request()->file('avatar');
  810 +
  811 + // 移动到框架应用根目录/public/uploads/ 目录下
  812 + if($file){
  813 + $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');
  814 + if($info){
  815 + // 成功上传后 获取上传信息
  816 + // 输出 jpg
  817 + $image = $info->getSaveName();
  818 + $this->apiResponse(1,'成功',$image);
  819 + // 输出 20160820/42a79759f284b767dfcb2a0197904287.jpg
  820 + }else{
  821 + // 上传失败获取错误信息
  822 + echo $file->getError();
  823 + }
  824 + }
  825 +
  826 + }
  827 +
  828 + public function apiResponse($code = '', $msg = '',$data = array()){
  829 + header('Access-Control-Allow-Origin: *');
  830 + header('Content-Type:application/json; charset=utf-8');
  831 + $result = array(
  832 + 'code'=>$code,
  833 + 'msg'=>$msg,
  834 + 'data'=>$data,
  835 + );
  836 + die(json_encode($result,JSON_UNESCAPED_UNICODE));
  837 + }
  838 +
  839 + /**
  840 + *判断是否首次提现
  841 + */
  842 + public function id_first_withdrawal(){
  843 +
  844 + $uid = cmf_get_current_user_id();
  845 + $my_user = Db::name('my_user') -> where('uid',$uid) -> find();
  846 + if($my_user['is_withdrawal'] == '1'){
  847 + return true;
  848 + }else{
  849 + return false;
  850 + }
  851 +
  852 + }
  853 +
  854 + /**
  855 + * 首次提现手机验证码判断
  856 + */
  857 + public function is_money_code(){
  858 +
  859 + $uid = cmf_get_current_user_id();
  860 + $code = session('code');
  861 + if($code == $_POST['yzm']){
  862 + $user = Db::name('my_user') -> where('uid',$uid) -> find();
  863 + if(empty($user['phone'])){
  864 + Db::name('my_user') -> where('uid',$uid) -> update(['phone'=>$_POST['phone']]);
  865 + }
  866 + Db::name('my_user') -> where('uid',$uid) -> update(['is_withdrawal'=>2]);
  867 + return true;
  868 + }else{
  869 + return false;
  870 + }
  871 +
  872 + }
  873 +
  874 +
  875 + public function salesman_postage() {
  876 + if($this->request->isAjax()) {
  877 + $user_id = cmf_get_current_user_id();
  878 + $money = $this->request->param('money');
  879 + $my_user = Db::name('my_user')->where('uid',$user_id)->find();
  880 + if($my_user['status'] != 2) {
  881 + $this->error('无法访问该页面');
  882 + }
  883 + if(empty($money)) {
  884 + $this->error('请设置邮费金额');
  885 + }
  886 + // 获取业务员配置的邮费,如未配置过,则新增一条记录
  887 + $user_postage = Db::name('user_postage')->where('user_id',$user_id)->find();
  888 + if(!$user_postage) {
  889 + $insert = [
  890 + 'user_id' => $user_id,
  891 + 'money' => $money,
  892 + 'createtime' => time(),
  893 + 'updatetime' => time()
  894 + ];
  895 + $result = Db::name('user_postage')->insertGetId($insert);
  896 + } else {
  897 + $result = true;
  898 + if($money != $user_postage['money']) {
  899 + $update = [
  900 + 'id' => $user_postage['id'],
  901 + 'money' => $money,
  902 + 'updatetime' => time()
  903 + ];
  904 + $result = Db::name('user_postage')->update($update);
  905 + }
  906 + }
  907 + if(!$result) {
  908 + $this->error('邮费设置失败');
  909 + }
  910 + $this->success('邮费设置成功');
  911 + } else {
  912 + $user_id = cmf_get_current_user_id();
  913 + $my_user = Db::name('my_user')->where('uid',$user_id)->find();
  914 + if($my_user['status'] != 2) {
  915 + $this->error('无法访问该页面');
  916 + }
  917 + // 获取业务员配置的邮费,如未配置过,则使用平台配置的邮费
  918 + $user_postage = Db::name('user_postage')->where('user_id',$user_id)->find();
  919 + if(!$user_postage) {
  920 + $postage_money = Db::name('money_ratio')->where('id',1)->value('courier');
  921 + } else {
  922 + $postage_money = $user_postage['money'];
  923 + }
  924 + $this->assign('money',$postage_money);
  925 + return $this->fetch();
  926 + }
  927 + }
  928 +
  929 +
  930 +
  931 +
  932 +
  933 +
  934 +
  935 +
  936 +
  937 +
  938 +
  939 +
888 } 940 }
1 -<!DOCTYPE html>  
2 -<html lang="en">  
3 -  
4 -<head>  
5 - <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">  
6 - <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />  
7 - <meta http-equiv="X-UA-Compatible" content="ie=edge">  
8 - <title>学考无忧-确认订单</title>  
9 - <link rel="stylesheet" href="__TMPL__/public/assets/css/reset.css">  
10 - <link rel="stylesheet" href="__TMPL__/public/assets/css/base.css">  
11 - <style>  
12 - .order_address {  
13 - padding-bottom: 0.26rem;  
14 - background-repeat: no-repeat;  
15 - background-image: url("__TMPL__/public/assets/images/32.png");  
16 - background-position: bottom;  
17 - background-size: 100% 0.06rem;  
18 - background-color: white;  
19 - }  
20 -  
21 - .yw_wayActive {  
22 - border: 0;  
23 - background-size: 100% 100%;  
24 - background-image: url('__TMPL__/public/assets/images/71.png');  
25 - }  
26 - </style>  
27 -</head>  
28 -  
29 -<body>  
30 - <div class="order_box">  
31 - <!-- 顶部 -->  
32 - <div class="order_top">  
33 - <a href="{:url('shopcart/shop_cart')}">  
34 - <img src="__TMPL__/public/assets/images/left.png" alt="">  
35 - </a>  
36 - <p>订单确认</p>  
37 - </div>  
38 - <!-- 地址 -->  
39 - <div class="order_address">  
40 - <!-- 暂无 -->  
41 - <if condition="$address eq 4">  
42 - <div class="order_addressNo">  
43 - <div class="order_adImg">  
44 - <img src="__TMPL__/public/assets/images/31.png" alt="">  
45 - </div>  
46 - <p class="order_addressGo">暂无默认收货地址,<a href="{:url('Orderpage/go_add_address',array('indet_id'=>$indet_id))}">去添加</a></p>  
47 - </div>  
48 - <else/>  
49 - <div class="order_addressYes">  
50 - <div class="or_addressYesImg1">  
51 - <img src="__TMPL__/public/assets/images/38.png" alt="">  
52 - </div>  
53 - <div class="or_addressYesTxt1">  
54 - <div class="or_addressYesTxt2">  
55 - <div class="or_addressName" id="name">{$address.name}</div>  
56 - <p class="or_addressPhone" id="phone">{$address.phone}</p>  
57 - </div>  
58 - <p class="or_address_detailed" id="detailed">{$address.region}{$address.detailed}</p>  
59 - </div>  
60 - <div class="or_addressYesImg2">  
61 - <a href="{:url('Orderpage/go_add_address',array('indet_id'=>$indet_id))}">  
62 - <img src="__TMPL__/public/assets/images/29.png" alt="">  
63 - </a>  
64 - </div>  
65 - </div>  
66 - </if>  
67 - </div>  
68 -  
69 - <!-- 订单信息 -->  
70 - <div class="order_news">  
71 - <!-- 配送方式 -->  
72 - <div class="yw_way">  
73 - <h3>配送方式</h3>  
74 - <div class="yw_way2">  
75 - <div class="yw_way2Li " onclick="go_unified()">统一配送</div>  
76 - <div class="yw_way2Li yw_wayActive">快递配送({$courier}元)</div>  
77 - </div>  
78 - </div>  
79 - <h1 class="order_newsTit">订单信息</h1>  
80 - <ul class="order_newsUl">  
81 - <volist name="data" id="vo">  
82 - <li>  
83 - <div class="order_newsImg">  
84 - <img src="{:cmf_get_image_url($vo.thumbnail)}" alt="">  
85 - </div>  
86 - <div class="order_newsCon">  
87 - <div class="order_newsTxt1 txt-cut">{$vo.book_name}</div>  
88 - <div class="order_newsTxt2">×<span>{$vo.number}</span></div>  
89 - <div class="order_newsTxt3">  
90 - <p class="de_topTxt1_1"><span>{$vo.price}</span></p>  
91 - <p class="de_topTxt1_2"><span>{$vo.pricing}</span></p>  
92 - <div class="order_newsNum">  
93 - <div class="order_newsJian" onclick="jian({$vo.id},{$vo.price})">-</div>  
94 - <input class="order_newsnum" type="text" readonly="readonly" value="{$vo.number}">  
95 - <div class="order_newsJia" onclick="jia({$vo.id},{$vo.price})">+</div>  
96 - </div>  
97 - </div>  
98 - </div>  
99 - </li>  
100 - </volist>  
101 - </ul>  
102 - </div>  
103 - <!-- 支付方式/配送方式 -->  
104 - <div class="order_Etc">  
105 - <div class="order_Etc1">  
106 - <p class="order_EtcTxt">支付方式</p>  
107 - <img class="order_EtcImg" src="__TMPL__/public/assets/images/34.png" alt="">  
108 - </div>  
109 - <div class="order_Etc1">  
110 - <p class="order_EtcTxt">配送方式</p>  
111 - <span class="order_EtcTxt2">快递</span>  
112 - </div>  
113 - <div class="order_Etc2">  
114 - <p class="order_EtcTxt">买家留言</p>  
115 - <textarea placeholder="在此填写您的留言" id="liuyan"></textarea>  
116 - </div>  
117 - </div>  
118 - <!-- 底部 -->  
119 - <div class="order_bottom">  
120 - <div class="order_bottom1">  
121 - <p class="order_bottomHe">合计金额:</p>  
122 - <p class="de_topTxt1_1 zoji"><span id="money">{$money}</span></p>  
123 - </div>  
124 - <div class="order_bottom2" onclick="go_pay()">立即支付</div>  
125 - </div>  
126 - </div>  
127 - <script src="__TMPL__/public/assets/js/base.js"></script>  
128 - <script src="__TMPL__/public/assets/js/jquery.js"></script>  
129 - <script>  
130 -  
131 - /**  
132 - * 点击统一配送  
133 - */  
134 - function go_unified(){  
135 - window.location.href = "{:url('Orderpage/order_salesman_ty')}?indet_id="+{$indet_id};  
136 - }  
137 -  
138 - /**  
139 - *点击去支付  
140 - */  
141 - function go_pay(){  
142 - indnet_id = "{$indet_id}";  
143 - $.post("{:url('Order/is_my_salesman')}",{indent_id:indnet_id},function(data){  
144 - if(data){  
145 - name = $('#name').text();  
146 - phone = $('#phone').text();  
147 - detailed = $('#detailed').text();  
148 - if(name == ''){  
149 - alert('收货地址不能为空');  
150 - }else if(phone == ''){  
151 - alert('收货地址不能为空');  
152 - }else if(detailed == ''){  
153 - alert('收货地址不能为空');  
154 - }else{  
155 - liuyan = $('#liuyan').val();  
156 - indet_id = {$indet_id};  
157 - money = $('#money').text();  
158 - $.post("{:url('Orderpage/salesman_go_pay')}",{leave_word:liuyan,id:indet_id,money:money},function(data){  
159 - if(data){  
160 - window.location.href = "{:url('Pay/index',array('id'=>$indet_id))}";  
161 - }else{  
162 - alert('更新订单失败');  
163 - }  
164 - });  
165 - }  
166 - }else{  
167 - alert('不再此区域销售');  
168 - }  
169 - });  
170 -  
171 - }  
172 -  
173 - /**  
174 - *点击加一  
175 - */  
176 - function jia(id,price){  
177 - $.post("{:url('Orderpage/shop_cart_numadd')}",{id:id,price:price},function(data){  
178 - });  
179 - }  
180 -  
181 - /**  
182 - * 点击减一  
183 - */  
184 - function jian(id,price){  
185 - $.post("{:url('Orderpage/shop_cart_numdec')}",{id:id,price:price},function(data){  
186 -  
187 - });  
188 - }  
189 - </script>  
190 - <script>  
191 - $(document).ready(function() {  
192 - // 配送方式  
193 - $('.yw_way2 div').click(function() {  
194 - $(this).addClass('yw_wayActive').siblings().removeClass('yw_wayActive');  
195 - })  
196 -  
197 - $(".order_newsNum div").on("click", function(evt) {  
198 - if ($(this).text() == "-") {  
199 - var count = parseInt($(this).next().val());  
200 - if (count > 1) {  
201 - count -= 1;  
202 - $(this).next().val(count);  
203 - } else {  
204 - alert("商品数量最少为1");  
205 - }  
206 - $(this).parents(".order_newsCon").find(".order_newsTxt2 span").text(count);  
207 - } else {  
208 - var count = parseInt($(this).prev().val());  
209 - if (count < 200) {  
210 - count += 1;  
211 - $(this).prev().val(count);  
212 - } else {  
213 - alert("商品数量最多为200");  
214 - }  
215 - $(this).parents(".order_newsCon").find(".order_newsTxt2 span").text(count);  
216 - }  
217 - var price = parseFloat($(this).parents(".order_newsTxt3").children(".de_topTxt1_1").text().split("¥")[1]);  
218 - calcTotal2();  
219 - });  
220 -  
221 - // 计算总计  
222 - function calcTotal2() {  
223 - var checkBoxes = $(".sh_cartround img");  
224 - var priceSpans = $(".order_newsTxt3 .de_topTxt1_1 span");  
225 - var countInputs = $(".order_newsNum .order_newsnum");  
226 - var totalCount = 0;  
227 - var totalPrice = {$courier};  
228 - for (var i = 0; i < priceSpans.length; i += 1) {  
229 - // 强调: jQuery对象使用下标运算或get方法会还原成原生的JavaScript对象  
230 - var price = parseFloat($(priceSpans[i]).text());  
231 - var count = parseInt($(countInputs[i]).val());  
232 - totalCount += count;  
233 - totalPrice += price * count;  
234 - }  
235 - $(".zoji span").html(totalPrice.toFixed(2));  
236 - }  
237 - })  
238 - </script>  
239 -</body>  
240 - 1 +<!DOCTYPE html>
  2 +<html lang="en">
  3 +
  4 +<head>
  5 + <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
  6 + <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
  7 + <meta http-equiv="X-UA-Compatible" content="ie=edge">
  8 + <title>学考无忧-确认订单</title>
  9 + <link rel="stylesheet" href="__TMPL__/public/assets/css/reset.css">
  10 + <link rel="stylesheet" href="__TMPL__/public/assets/css/base.css">
  11 + <style>
  12 + .order_address {
  13 + padding-bottom: 0.26rem;
  14 + background-repeat: no-repeat;
  15 + background-image: url("__TMPL__/public/assets/images/32.png");
  16 + background-position: bottom;
  17 + background-size: 100% 0.06rem;
  18 + background-color: white;
  19 + }
  20 +
  21 + .yw_wayActive {
  22 + border: 0;
  23 + background-size: 100% 100%;
  24 + background-image: url('__TMPL__/public/assets/images/71.png');
  25 + }
  26 + .order_addressYes {
  27 + padding-top: 1.5rem;
  28 + margin-top: 0;
  29 + }
  30 + </style>
  31 +</head>
  32 +
  33 +<body>
  34 + <div class="order_box">
  35 + <!-- 顶部 -->
  36 + <div class="order_top">
  37 + <a href="{:url('shopcart/shop_cart')}">
  38 + <img src="__TMPL__/public/assets/images/left.png" alt="">
  39 + </a>
  40 + <p>订单确认</p>
  41 + </div>
  42 + <!-- 地址 -->
  43 + <div class="order_address">
  44 + <!-- 暂无 -->
  45 + <if condition="$address eq 4">
  46 + <div class="order_addressNo">
  47 + <div class="order_adImg">
  48 + <img src="__TMPL__/public/assets/images/31.png" alt="">
  49 + </div>
  50 + <p class="order_addressGo">暂无默认收货地址,<a href="{:url('Orderpage/go_add_address',array('indet_id'=>$indet_id))}">去添加</a></p>
  51 + </div>
  52 + <else/>
  53 + <div class="order_addressYes">
  54 + <div class="or_addressYesImg1">
  55 + <img src="__TMPL__/public/assets/images/38.png" alt="">
  56 + </div>
  57 + <div class="or_addressYesTxt1">
  58 + <div class="or_addressYesTxt2">
  59 + <div class="or_addressName" id="name">{$address.name}</div>
  60 + <p class="or_addressPhone" id="phone">{$address.phone}</p>
  61 + </div>
  62 + <p class="or_address_detailed" id="detailed">{$address.region}{$address.detailed}</p>
  63 + </div>
  64 + <div class="or_addressYesImg2">
  65 + <a href="{:url('Orderpage/go_add_address',array('indet_id'=>$indet_id))}">
  66 + <img src="__TMPL__/public/assets/images/29.png" alt="">
  67 + </a>
  68 + </div>
  69 + </div>
  70 + </if>
  71 + </div>
  72 +
  73 + <!-- 订单信息 -->
  74 + <div class="order_news">
  75 + <!-- 配送方式 -->
  76 + <div class="yw_way">
  77 + <h3>配送方式</h3>
  78 + <div class="yw_way2">
  79 + <div class="yw_way2Li " onclick="go_unified()">统一配送</div>
  80 + <div class="yw_way2Li yw_wayActive">快递配送({$courier}元)</div>
  81 + </div>
  82 + </div>
  83 + <h1 class="order_newsTit">订单信息</h1>
  84 + <ul class="order_newsUl">
  85 + <volist name="data" id="vo">
  86 + <li>
  87 + <div class="order_newsImg">
  88 + <img src="{:cmf_get_image_url($vo.thumbnail)}" alt="">
  89 + </div>
  90 + <div class="order_newsCon">
  91 + <div class="order_newsTxt1 txt-cut">{$vo.book_name}</div>
  92 + <div class="order_newsTxt2">×<span>{$vo.number}</span></div>
  93 + <div class="order_newsTxt3">
  94 + <p class="de_topTxt1_1"><span>{$vo.price}</span></p>
  95 + <p class="de_topTxt1_2"><span>{$vo.pricing}</span></p>
  96 + <div class="order_newsNum">
  97 + <div class="order_newsJian" onclick="jian({$vo.id},{$vo.price})">-</div>
  98 + <input class="order_newsnum" type="text" readonly="readonly" value="{$vo.number}">
  99 + <div class="order_newsJia" onclick="jia({$vo.id},{$vo.price})">+</div>
  100 + </div>
  101 + </div>
  102 + </div>
  103 + </li>
  104 + </volist>
  105 + </ul>
  106 + </div>
  107 + <!-- 支付方式/配送方式 -->
  108 + <div class="order_Etc">
  109 + <div class="order_Etc1">
  110 + <p class="order_EtcTxt">支付方式</p>
  111 + <img class="order_EtcImg" src="__TMPL__/public/assets/images/34.png" alt="">
  112 + </div>
  113 + <div class="order_Etc1">
  114 + <p class="order_EtcTxt">配送方式</p>
  115 + <span class="order_EtcTxt2">快递</span>
  116 + </div>
  117 + <div class="order_Etc2">
  118 + <p class="order_EtcTxt">买家留言</p>
  119 + <textarea placeholder="在此填写您的留言" id="liuyan"></textarea>
  120 + </div>
  121 + </div>
  122 + <!-- 底部 -->
  123 + <div class="order_bottom">
  124 + <div class="order_bottom1">
  125 + <p class="order_bottomHe">合计金额:</p>
  126 + <p class="de_topTxt1_1 zoji"><span id="money">{$money}</span></p>
  127 + </div>
  128 + <div class="order_bottom2" onclick="go_pay()">立即支付</div>
  129 + </div>
  130 + </div>
  131 + <script src="__TMPL__/public/assets/js/base.js"></script>
  132 + <script src="__TMPL__/public/assets/js/jquery.js"></script>
  133 + <script>
  134 +
  135 + /**
  136 + * 点击统一配送
  137 + */
  138 + function go_unified(){
  139 + window.location.href = "{:url('Orderpage/order_salesman_ty')}?indet_id="+{$indet_id};
  140 + }
  141 +
  142 + /**
  143 + *点击去支付
  144 + */
  145 + function go_pay(){
  146 + indnet_id = "{$indet_id}";
  147 + $.post("{:url('Order/is_my_salesman')}",{indent_id:indnet_id},function(data){
  148 + if(data){
  149 + name = $('#name').text();
  150 + phone = $('#phone').text();
  151 + detailed = $('#detailed').text();
  152 + if(name == ''){
  153 + alert('收货地址不能为空');
  154 + }else if(phone == ''){
  155 + alert('收货地址不能为空');
  156 + }else if(detailed == ''){
  157 + alert('收货地址不能为空');
  158 + }else{
  159 + liuyan = $('#liuyan').val();
  160 + indet_id = {$indet_id};
  161 + money = $('#money').text();
  162 + $.post("{:url('Orderpage/salesman_go_pay')}",{leave_word:liuyan,id:indet_id,money:money},function(data){
  163 + if(data){
  164 + window.location.href = "{:url('Pay/index',array('id'=>$indet_id))}";
  165 + }else{
  166 + alert('更新订单失败');
  167 + }
  168 + });
  169 + }
  170 + }else{
  171 + alert('不再此区域销售');
  172 + }
  173 + });
  174 +
  175 + }
  176 +
  177 + /**
  178 + *点击加一
  179 + */
  180 + function jia(id,price){
  181 + $.post("{:url('Orderpage/shop_cart_numadd')}",{id:id,price:price},function(data){
  182 + });
  183 + }
  184 +
  185 + /**
  186 + * 点击减一
  187 + */
  188 + function jian(id,price){
  189 + $.post("{:url('Orderpage/shop_cart_numdec')}",{id:id,price:price},function(data){
  190 +
  191 + });
  192 + }
  193 + </script>
  194 + <script>
  195 + $(document).ready(function() {
  196 + // 配送方式
  197 + $('.yw_way2 div').click(function() {
  198 + $(this).addClass('yw_wayActive').siblings().removeClass('yw_wayActive');
  199 + })
  200 +
  201 + $(".order_newsNum div").on("click", function(evt) {
  202 + if ($(this).text() == "-") {
  203 + var count = parseInt($(this).next().val());
  204 + if (count > 1) {
  205 + count -= 1;
  206 + $(this).next().val(count);
  207 + } else {
  208 + alert("商品数量最少为1");
  209 + }
  210 + $(this).parents(".order_newsCon").find(".order_newsTxt2 span").text(count);
  211 + } else {
  212 + var count = parseInt($(this).prev().val());
  213 + if (count < 200) {
  214 + count += 1;
  215 + $(this).prev().val(count);
  216 + } else {
  217 + alert("商品数量最多为200");
  218 + }
  219 + $(this).parents(".order_newsCon").find(".order_newsTxt2 span").text(count);
  220 + }
  221 + var price = parseFloat($(this).parents(".order_newsTxt3").children(".de_topTxt1_1").text().split("¥")[1]);
  222 + calcTotal2();
  223 + });
  224 +
  225 + // 计算总计
  226 + function calcTotal2() {
  227 + var checkBoxes = $(".sh_cartround img");
  228 + var priceSpans = $(".order_newsTxt3 .de_topTxt1_1 span");
  229 + var countInputs = $(".order_newsNum .order_newsnum");
  230 + var totalCount = 0;
  231 + var totalPrice = {$courier};
  232 + for (var i = 0; i < priceSpans.length; i += 1) {
  233 + // 强调: jQuery对象使用下标运算或get方法会还原成原生的JavaScript对象
  234 + var price = parseFloat($(priceSpans[i]).text());
  235 + var count = parseInt($(countInputs[i]).val());
  236 + totalCount += count;
  237 + totalPrice += price * count;
  238 + }
  239 + $(".zoji span").html(totalPrice.toFixed(2));
  240 + }
  241 + })
  242 + </script>
  243 +</body>
  244 +
241 </html> 245 </html>
1 -<!DOCTYPE html>  
2 -<html lang="en">  
3 -  
4 -<head>  
5 - <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />  
6 - <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />  
7 - <meta http-equiv="X-UA-Compatible" content="ie=edge" />  
8 - <title>学考无忧-我的-管理页面</title>  
9 - <link rel="stylesheet" href="__TMPL__/public/assets/css/reset.css" />  
10 - <link rel="stylesheet" href="__TMPL__/public/assets/css/log.css" />  
11 -</head>  
12 -  
13 -<body>  
14 -<div class="log_top">  
15 - <!-- 顶部 -->  
16 - <div class=" order_top log_top">  
17 - <p style="color:white">订单确认</p>  
18 - </div>  
19 - <!-- 头像 -->  
20 - <div class="log_top_buddha">  
21 - <div class="log_top_buddha_img">  
22 - <img src="{$weixin.avatar}" alt="" style="border-radius: 50%;" />  
23 - </div>  
24 - <div class="log_top_buddha_contant">  
25 - <div class="log_top_buddha_contant_one">  
26 - {$weixin.user_nickname}  
27 - </div>  
28 - </div>  
29 - </div>  
30 -</div>  
31 -<!-- 列表1 -->  
32 -<div class="log_one_list">  
33 - <a href="{:url('Salesmangoods/salesman_goods')}">  
34 - <div class="log_one_list_one">  
35 - <div class="log_one_list_left">  
36 - <div class="log_one_list_img">  
37 - <img src="__TMPL__/public/assets/images/shangpin.png" alt="" />  
38 - </div>  
39 - <div class="log_one_list_word">  
40 - 商品管理  
41 - </div>  
42 - </div>  
43 - <div class="log_one_list_right">  
44 - <img src="__TMPL__/public/assets/images/29.png" alt="" />  
45 - </div>  
46 - </div>  
47 - </a>  
48 - <a href="{:url('OrderSalesman/get_all')}">  
49 - <div class="log_one_list_one">  
50 - <div class="log_one_list_left">  
51 - <div class="log_one_list_img">  
52 - <img src="__TMPL__/public/assets/images/dingdan.png" alt="" />  
53 - </div>  
54 - <div class="log_one_list_word">  
55 - 订单管理  
56 - </div>  
57 - </div>  
58 - <div class="log_one_list_right">  
59 - <img src="__TMPL__/public/assets/images/29.png" alt="" />  
60 - </div>  
61 - </div>  
62 - </a>  
63 - <a href="{:url('School/school')}">  
64 - <div class="log_one_list_one">  
65 - <div class="log_one_list_left">  
66 - <div class="log_one_list_img">  
67 - <img src="__TMPL__/public/assets/images/school.png" alt="" />  
68 - </div>  
69 - <div class="log_one_list_word">  
70 - 学校管理  
71 - </div>  
72 - </div>  
73 - <div class="log_one_list_right">  
74 - <img src="__TMPL__/public/assets/images/29.png" alt="" />  
75 - </div>  
76 - </div>  
77 - </a>  
78 - <a href="{:url('Personalcenter/my_wallet')}">  
79 - <div class="log_one_list_one">  
80 - <div class="log_one_list_left">  
81 - <div class="log_one_list_img">  
82 - <img src="__TMPL__/public/assets/images/49.png" alt="" />  
83 - </div>  
84 - <div class="log_one_list_word">  
85 - 我的钱包  
86 - </div>  
87 - </div>  
88 - <div class="log_one_list_right">  
89 - <img src="__TMPL__/public/assets/images/29.png" alt="" />  
90 - </div>  
91 - </div>  
92 - </a>  
93 - <a href="{:url('share/index')}">  
94 - <div class="log_one_list_one">  
95 - <div class="log_one_list_left">  
96 - <div class="log_one_list_img">  
97 - <img src="__TMPL__/public/assets/images/47.png" alt="" />  
98 - </div>  
99 - <div class="log_one_list_word">  
100 - 商城分享  
101 - </div>  
102 - </div>  
103 - <div class="log_one_list_right">  
104 - <img src="__TMPL__/public/assets/images/29.png" alt="" />  
105 - </div>  
106 - </div>  
107 - </a>  
108 -</div>  
109 -<!-- 底部一级导航 -->  
110 -<div class="in_bottom">  
111 - <ul>  
112 - <a href="{:url('Index/index')}">  
113 - <li>  
114 - <img src="__TMPL__/public/assets/images/22.png" alt="" />  
115 - <p>首页</p>  
116 - </li>  
117 - </a>  
118 - <a href="{:url('Classify/classify')}">  
119 - <li>  
120 - <img src="__TMPL__/public/assets/images/16.png" alt="" />  
121 - <p>分类</p>  
122 - </li>  
123 - </a>  
124 - <a href="{:url('Shopcart/shop_cart')}">  
125 - <li>  
126 - <img src="__TMPL__/public/assets/images/17.png" alt="" />  
127 - <p>购物车</p>  
128 - </li>  
129 - </a>  
130 - <li>  
131 - <img src="__TMPL__/public/assets/images/19.png" alt="" />  
132 - <p style="color:#FF7700;">我的</p>  
133 - </li>  
134 - </ul>  
135 -</div>  
136 -<script src="__TMPL__/public/assets/js/jquery.js"></script>  
137 -<script src="__TMPL__/public/assets/js/base.js"></script>  
138 -<script>  
139 - $(".log_top_buddha_btn").click(function() {  
140 - $(this).css({  
141 - display: "none"  
142 - });  
143 - $(".log_top_buddha_contant").toggle();  
144 - });  
145 -</script>  
146 -</body>  
147 - 1 +<!DOCTYPE html>
  2 +<html lang="en">
  3 +
  4 +<head>
  5 + <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
  6 + <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
  7 + <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  8 + <title>学考无忧-我的-管理页面</title>
  9 + <link rel="stylesheet" href="__TMPL__/public/assets/css/reset.css" />
  10 + <link rel="stylesheet" href="__TMPL__/public/assets/css/log.css" />
  11 +</head>
  12 +
  13 +<body>
  14 +<div class="log_top">
  15 + <!-- 顶部 -->
  16 + <div class=" order_top log_top">
  17 + <p style="color:white">订单确认</p>
  18 + </div>
  19 + <!-- 头像 -->
  20 + <div class="log_top_buddha">
  21 + <div class="log_top_buddha_img">
  22 + <img src="{$weixin.avatar}" alt="" style="border-radius: 50%;" />
  23 + </div>
  24 + <div class="log_top_buddha_contant">
  25 + <div class="log_top_buddha_contant_one">
  26 + {$weixin.user_nickname}
  27 + </div>
  28 + </div>
  29 + </div>
  30 +</div>
  31 +<!-- 列表1 -->
  32 +<div class="log_one_list">
  33 + <a href="{:url('Salesmangoods/salesman_goods')}">
  34 + <div class="log_one_list_one">
  35 + <div class="log_one_list_left">
  36 + <div class="log_one_list_img">
  37 + <img src="__TMPL__/public/assets/images/shangpin.png" alt="" />
  38 + </div>
  39 + <div class="log_one_list_word">
  40 + 商品管理
  41 + </div>
  42 + </div>
  43 + <div class="log_one_list_right">
  44 + <img src="__TMPL__/public/assets/images/29.png" alt="" />
  45 + </div>
  46 + </div>
  47 + </a>
  48 + <a href="{:url('Personalcenter/salesman_postage')}">
  49 + <div class="log_one_list_one">
  50 + <div class="log_one_list_left">
  51 + <div class="log_one_list_img">
  52 + <img src="__TMPL__/public/assets/images/postage.png" alt="" />
  53 + </div>
  54 + <div class="log_one_list_word">
  55 + 邮费设置
  56 + </div>
  57 + </div>
  58 + <div class="log_one_list_right">
  59 + <img src="__TMPL__/public/assets/images/29.png" alt="" />
  60 + </div>
  61 + </div>
  62 + </a>
  63 + <a href="{:url('OrderSalesman/get_all')}">
  64 + <div class="log_one_list_one">
  65 + <div class="log_one_list_left">
  66 + <div class="log_one_list_img">
  67 + <img src="__TMPL__/public/assets/images/dingdan.png" alt="" />
  68 + </div>
  69 + <div class="log_one_list_word">
  70 + 订单管理
  71 + </div>
  72 + </div>
  73 + <div class="log_one_list_right">
  74 + <img src="__TMPL__/public/assets/images/29.png" alt="" />
  75 + </div>
  76 + </div>
  77 + </a>
  78 + <a href="{:url('School/school')}">
  79 + <div class="log_one_list_one">
  80 + <div class="log_one_list_left">
  81 + <div class="log_one_list_img">
  82 + <img src="__TMPL__/public/assets/images/school.png" alt="" />
  83 + </div>
  84 + <div class="log_one_list_word">
  85 + 学校管理
  86 + </div>
  87 + </div>
  88 + <div class="log_one_list_right">
  89 + <img src="__TMPL__/public/assets/images/29.png" alt="" />
  90 + </div>
  91 + </div>
  92 + </a>
  93 + <a href="{:url('Personalcenter/my_wallet')}">
  94 + <div class="log_one_list_one">
  95 + <div class="log_one_list_left">
  96 + <div class="log_one_list_img">
  97 + <img src="__TMPL__/public/assets/images/49.png" alt="" />
  98 + </div>
  99 + <div class="log_one_list_word">
  100 + 我的钱包
  101 + </div>
  102 + </div>
  103 + <div class="log_one_list_right">
  104 + <img src="__TMPL__/public/assets/images/29.png" alt="" />
  105 + </div>
  106 + </div>
  107 + </a>
  108 + <a href="{:url('share/index')}">
  109 + <div class="log_one_list_one">
  110 + <div class="log_one_list_left">
  111 + <div class="log_one_list_img">
  112 + <img src="__TMPL__/public/assets/images/47.png" alt="" />
  113 + </div>
  114 + <div class="log_one_list_word">
  115 + 商城分享
  116 + </div>
  117 + </div>
  118 + <div class="log_one_list_right">
  119 + <img src="__TMPL__/public/assets/images/29.png" alt="" />
  120 + </div>
  121 + </div>
  122 + </a>
  123 +</div>
  124 +<!-- 底部一级导航 -->
  125 +<div class="in_bottom">
  126 + <ul>
  127 + <a href="{:url('Index/index')}">
  128 + <li>
  129 + <img src="__TMPL__/public/assets/images/22.png" alt="" />
  130 + <p>首页</p>
  131 + </li>
  132 + </a>
  133 + <a href="{:url('Classify/classify')}">
  134 + <li>
  135 + <img src="__TMPL__/public/assets/images/16.png" alt="" />
  136 + <p>分类</p>
  137 + </li>
  138 + </a>
  139 + <a href="{:url('Shopcart/shop_cart')}">
  140 + <li>
  141 + <img src="__TMPL__/public/assets/images/17.png" alt="" />
  142 + <p>购物车</p>
  143 + </li>
  144 + </a>
  145 + <li>
  146 + <img src="__TMPL__/public/assets/images/19.png" alt="" />
  147 + <p style="color:#FF7700;">我的</p>
  148 + </li>
  149 + </ul>
  150 +</div>
  151 +<script src="__TMPL__/public/assets/js/jquery.js"></script>
  152 +<script src="__TMPL__/public/assets/js/base.js"></script>
  153 +<script>
  154 + $(".log_top_buddha_btn").click(function() {
  155 + $(this).css({
  156 + display: "none"
  157 + });
  158 + $(".log_top_buddha_contant").toggle();
  159 + });
  160 +</script>
  161 +</body>
  162 +
148 </html> 163 </html>
  1 +<!DOCTYPE html>
  2 +<html lang="en">
  3 +
  4 +<head>
  5 + <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
  6 + <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
  7 + <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  8 + <title>学考无忧-邮费设置</title>
  9 + <link rel="stylesheet" href="__TMPL__/public/assets/css/mui.min.css">
  10 + <link rel="stylesheet" href="__TMPL__/public/assets/css/mui.picker.min.css">
  11 + <link rel="stylesheet" href="__TMPL__/public/assets/css/reset.css" />
  12 + <link rel="stylesheet" href="__TMPL__/public/assets/css/log.css" />
  13 + <style>
  14 + .mui-poppicker-header,
  15 + .mui-picker {
  16 + background-color: white;
  17 + }
  18 +
  19 + .mui-btn-blue,
  20 + .mui-btn-primary,
  21 + input[type=submit] {
  22 + background-color: #FF7700;
  23 + border: 0;
  24 + }
  25 +
  26 + .mui-pciker-list li.highlight {
  27 + color: #FF7700;
  28 + }
  29 + .mui-toast-container {
  30 + bottom: 50%;
  31 + }
  32 + </style>
  33 +</head>
  34 +
  35 +<body>
  36 +<div class="log_top_co">
  37 + <!-- 顶部 -->
  38 + <div class=" order_top log_top_co">
  39 + <a href="{:url('personalcenter/personal_center')}">
  40 + <img src="__TMPL__/public/assets/images/left.png" alt="" />
  41 + </a>
  42 + <p>邮费设置</p>
  43 + </div>
  44 +</div>
  45 +<div class="school_ooo">
  46 + <!-- 地址信息 -->
  47 + <div class="log_four_input">
  48 + <div class="log_four_input_one">
  49 + <div class="log_four_input_one_left">
  50 + 邮费
  51 + </div>
  52 + <div class="log_four_input_one_center">
  53 + <input type="number" placeholder="请录入邮费" id="money" value="{$money}"/>
  54 + </div>
  55 + <div class="log_four_input_one_right">
  56 + <img src="__TMPL__/public/assets/images/29.png" alt="" />
  57 + </div>
  58 + </div>
  59 + </div>
  60 +</div>
  61 +<!-- 按钮 -->
  62 +<div class="log_seven_btn">
  63 + <div class="log_seven_btn_contant" onclick="my_postage()">
  64 + 确定
  65 + </div>
  66 +</div>
  67 +<script src="__TMPL__/public/assets/js/jquery.js"></script>
  68 +<script src="__TMPL__/public/assets/js/base.js"></script>
  69 +<script src="__TMPL__/public/assets/js/mui.min.js"></script>
  70 +<script src="__TMPL__/public/assets/js/mui.picker.min.js"></script>
  71 +<script>
  72 + var money;
  73 + /**
  74 + *点击确定提交
  75 + */
  76 + function my_postage(){
  77 + money = $('#money').val();
  78 + if(money == ''){
  79 + alert('请输入邮费');
  80 + }else{
  81 + $.post("{:url('personalcenter/salesman_postage')}",{money:money},function(data){
  82 + mui.toast(data.msg);
  83 + if(data){
  84 + setTimeout(function () {
  85 + window.location.href="{:url('personalcenter/personal_center')}";
  86 + },1000);
  87 + }
  88 + });
  89 + }
  90 + }
  91 +</script>
  92 +</body>
  93 +
  94 +</html>