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

业务员新增邮费设置

<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
namespace app\portal\controller;
use cmf\controller\WeChatBaseController;
use think\Db;
class OrderpageController extends WeChatBaseController{
/**
* 显示平台订单页
*/
public function order_page(){
$indet_id = $this -> request -> param();
$uid = cmf_get_current_user_id();
if(!empty($indet_id['address_id'])){
$address = Db::name('address') -> where('id',$indet_id['address_id']) -> find();
$this -> assign('address',$address);
$this -> assign('address_id',$indet_id['address_id']);
}else{
$address = Db::name('address') -> where("uid=".$uid." and default_address=1 and delete_time = 0") -> find();
if(empty($address)){
$this -> assign('address',4);
$this -> assign('address_id','');
}else{
$indet_data = Db::name('indent') -> where("id",$indet_id['indet_id']) -> find();
if($indet_data['state'] == 4){
$indet_data_update['id'] = $indet_id['indet_id'];
$indet_data_update['indent_address'] = $address['id'];
$indet_data_update['name'] = $address['name'];
$indet_data_update['phone'] = $address['phone'];
Db::name('indent') -> update($indet_data_update);
}
$this -> assign('address',$address);
$this -> assign('address_id',$address['id']);
}
}
$data = Db::name('indent_goods') -> where('indent_id',$indet_id['indet_id']) -> select() -> toArray();
foreach ($data as $key => $val){
$pricing = explode('.',$val['pricing']);
$data[$key]['pricing0'] = $pricing[0];
$data[$key]['pricing1'] = $pricing[1];
}
$money = Db::name('indent') -> where('id',$indet_id['indet_id']) -> find();
$this -> assign('money',$money['money']);
$this -> assign('data',$data);
$this -> assign('indent_id',$indet_id['indet_id']);
$this -> assign('type',5);
return $this -> fetch();
}
/**
* 显示业务员统一订单页mmmmm
*/
public function order_salesman_ty(){
$indet_id = $this -> request -> param();
$data = Db::name('indent_goods') -> where('indent_id',$indet_id['indet_id']) -> select() -> toArray();
foreach ($data as $key => $val){
$pricing = explode('.',$val['price']);
$data[$key]['price0'] = $pricing[0];
$data[$key]['price1'] = $pricing[1];
}
$money = Db::name('indent') -> where('id',$indet_id['indet_id']) -> find();
$money['money'] = explode('.',$money['money']);
$this -> assign('money',$money['money']);
$this -> assign('data',$data);
$courier = Db::name('money_ratio') -> where('id',1) -> find();
$this -> assign('courier',$courier['courier']);
$this -> assign('indent_id',$indet_id['indet_id']);
//判断这个用户所属哪个业务员
$uid = cmf_get_current_user_id();
$user = Db::name('my_user') -> where('uid',$uid) -> find();
//当当前用户为老师时
if($user['status'] == 3){
$salesman = Db::name('my_user') -> where('id',$user['pid']) -> find();
}
//当前用户为学生时
if($user['status'] == 4){
$teacher = Db::name('my_user') -> where('id',$user['pid']) -> find();
$salesman = Db::name('my_user') -> where('id',$teacher['pid']) -> find();
}
//查询这个用户下添加的学校
$school = Db::name('school') -> where("uid",!empty($salesman['uid']) ? $salesman['uid'] : 0) -> select() -> toArray();
if(!empty($school)){
$grade_class = Db::name('grade_class') -> where("school_id",$school[0]['id']) -> select();
foreach ($grade_class as $key => $val){
$class = explode('-',$val['class']);
for($i=$class[0];$i<=$class[1];$i++){
$grade_class_show[] = $val['grade'].' - '.$i."班";
}
}
}
$this -> assign('school',$school);
$this -> assign('grade_class_show',!empty($grade_class_show) ? $grade_class_show : '');
return $this -> fetch();
}
/**
* 商品数量加一
*/
public function shop_cart_numadd(){
$id = $_POST['id'];
$data = Db::name('indent_goods') -> where('id',$id) -> find();
if($data['number']<200){
$res = Db::name('indent_goods') -> where('id',$id) -> setInc('number');
$indent_id = Db::name('indent_goods') -> where('id',$id) -> find();
Db::name('indent') -> where('id',$indent_id['indent_id']) -> setInc('money',$_POST['price']);
}
return true;
}
/**
* 商品数量减一
*/
public function shop_cart_numdec(){
$id = $_POST['id'];
$data = Db::name('indent_goods') -> where('id',$id) -> find();
if($data['number']>1){
Db::name('indent_goods') -> where('id',$id) -> setDec('number');
$indent_id = Db::name('indent_goods') -> where('id',$id) -> find();
Db::name('indent') -> where('id',$indent_id['indent_id']) -> setDec('money',$_POST['price']);
}
return true;
}
/**
* 显示业务员快递订单页
*/
public function order_salesman_kd(){
$uid = cmf_get_current_user_id();
$indent_id = $this -> request -> param();
$money = Db::name('indent') -> where("id =".$indent_id['indet_id']) -> find();
$indent_goods_data = Db::name('indent_goods') -> where('indent_id',$indent_id['indet_id']) -> select();
$this -> assign('data',$indent_goods_data);
$courier = Db::name('money_ratio') -> where('id',1) -> find();
$this -> assign('courier',$courier['courier']);
$money['money'] = $money['money']+$courier['courier'];
$this -> assign('money',$money['money']);
if(empty($indent_id['address_id'])){
$address = Db::name('address') -> where("uid=".$uid." and default_address=1 and delete_time = 0") -> find();
}else{
$address = Db::name('address') -> where('id',$indent_id['address_id']) -> find();
}
if(empty($address)){
$this -> assign('address',4);
}else{
$indet_data = Db::name('indent') -> where("id",$indent_id['indet_id']) -> find();
if($indet_data['state'] == 4){
$indet_data_update['id'] = $indent_id['indet_id'];
$indet_data_update['indent_address'] = $address['id'];
$indet_data_update['name'] = $address['name'];
$indet_data_update['phone'] = $address['phone'];
$indet_data_update['region'] = $address['region'];
$indet_data_update['region_detail'] = $address['detailed'];
Db::name('indent') -> update($indet_data_update);
}
$this -> assign('address',$address);
}
$this -> assign('indet_id',$indent_id['indet_id']);
return $this -> fetch();
}
/**
* 业务员快递去支付
*/
public function salesman_go_pay(){
$_POST['is_courier'] = 2;
$data_update = Db::name('indent') -> update($_POST);
return true;
}
/**
* 取消支付时
*/
public function cancel_pay(){
$indent_id = $this -> request -> param();
$data = Db::name('indent') -> where('id',$indent_id['id']) -> find();
$money_ratio = Db::name('money_ratio') -> where('id',1) -> find();
/* if($data['indent_type'] == 2 && $data['is_courier'] == 2){
Db::name('indent') -> where('id',$indent_id['id']) -> setDec('money',$money_ratio['courier']);
}*/
$this -> redirect('index/index');
}
/**
* 平台商品去支付时 更新买家留言
*/
public function goods_leave_word_update(){
$param = $this->request->param();
$param['is_courier'] = 2;
$address = Db::name('address')->where('id',$param['indent_address'])->find();
if(!$address) {
return false;
}
$param['name'] = $address['name'];
$param['phone'] = $address['phone'];
$data = Db::name('indent') -> update($param);
return true;
}
/**
* 点击学校时获取年级班级
*/
public function get_grade_class(){
$school_id = $_POST['id'];
$grade_class = Db::name('grade_class') -> where("school_id",$school_id) -> select() -> toArray();
if(!empty($grade_class)){
foreach ($grade_class as $key => $val){
$class = explode('-',$val['class']);
for($i=$class[0];$i<=$class[1];$i++){
$grade_class_show[] = $val['grade'].' - '.$i."班";
}
}
return json_encode($grade_class_show);
}else{
return false;
}
}
/**
* 业务员统一配送页去支付
*/
public function salesman_ty_go_pay(){
$_POST['is_courier'] = 1;
$class = explode('-',$_POST['grade']);
$_POST['grade'] = trim($class[0]);
$_POST['class'] = trim($class[1]);
$indent_data['id'] = $_POST['id'];
$indent_data['region'] = $_POST['region'];
$indent_data['name'] = $_POST['name'];
$indent_data['phone'] = $_POST['phone'];
$indent_data['is_courier'] = $_POST['is_courier'];
$indent_data['school'] = $_POST['school'];
$indent_data['grade'] = $_POST['grade'];
$indent_data['class'] = $_POST['class'];
$indent_data['leave_word'] = $_POST['leave_word'];
$data = Db::name('indent') -> update($indent_data);
if($data){
return true;
}else{
return false;
}
}
/**
* 显示收货地址
*/
public function go_add_address(){
$indent_id = $this -> request -> param();
$uid = cmf_get_current_user_id();
$data = Db::name('address') -> where("delete_time = 0 and uid =".$uid) -> select() -> toArray();
$this -> assign('indent_id',$indent_id['indet_id']);
$this -> assign('data',$data);
if(!empty($indent_id['type'])){
$this -> assign('type',5);
}else{
$this -> assign('type',6);
}
return $this -> fetch();
}
/**
* 获取学校
*/
public function get_school(){
$user_id = $this->request->param('user_id');
if(empty($user_id)){
$user_id = cmf_get_current_user_id();
}
$my_user = Db::name('my_user')->where('uid',$user_id)->find();
if($my_user['status'] == 3){
$my_user2 = Db::name('my_user')->where('id',$my_user['pid'])->find();
}else{
$my_user3 = Db::name('my_user')->where('id',$my_user['pid'])->find();
$my_user2 = Db::name('my_user') -> where('id',$my_user3['pid']) -> find();
}
$area = $this->request->param('area',0);
if(empty($area)){
$this->error('缺少必要参数');
}
$where['region'] = ['like',"%$area%"];
$where['uid'] = ['eq',$my_user2['uid']];
$data = Db::name('school')->where($where)->select()->toArray();
//循环组建新数据
foreach ($data as $key=>$val){
$datas[$key]['value'] = $val['id'];
$datas[$key]['text'] = $val['school'];
}
if(!empty($datas)){
return json_encode($datas);
}else{
return false;
}
// $this->success('SUCCESS','',$datas);
}
/**
* 新增地址页
*/
public function add_shop_address(){
if($this -> request -> isPost()){
$uid = cmf_get_current_user_id();
$_POST['uid'] = $uid;
$add = Db::name('address') -> insert($_POST);
if($add){
return true;
}else{
return false;
}
}else{
$indent_id = $this -> request -> param();
$this -> assign('indent_id',$indent_id['indet_id']);
if($indent_id['type']==5){
$this -> assign('type',5);
}else{
$this -> assign('type',6);
}
return $this -> fetch();
}
}
/**
* 编辑地址
*/
public function address_edit(){
if($this -> request -> isPost()){
$data_update = Db::name('address') -> update($_POST);
if($data_update){
return true;
}else{
return false;
}
}else{
$id = $this -> request -> param();
$data = Db::name('address') -> where('id',$id['id']) -> find();
$this -> assign('data',$data);
$this -> assign('indent_id',$id['indet_id']);
if($id['type']==5){
$this -> assign('type',5);
}else{
$this -> assign('type',6);
}
return $this -> fetch();
}
}
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
namespace app\portal\controller;
use cmf\controller\WeChatBaseController;
use think\Db;
class OrderpageController extends WeChatBaseController{
/**
* 显示平台订单页
*/
public function order_page(){
$indet_id = $this -> request -> param();
$uid = cmf_get_current_user_id();
if(!empty($indet_id['address_id'])){
$address = Db::name('address') -> where('id',$indet_id['address_id']) -> find();
$this -> assign('address',$address);
$this -> assign('address_id',$indet_id['address_id']);
}else{
$address = Db::name('address') -> where("uid=".$uid." and default_address=1 and delete_time = 0") -> find();
if(empty($address)){
$this -> assign('address',4);
$this -> assign('address_id','');
}else{
$indet_data = Db::name('indent') -> where("id",$indet_id['indet_id']) -> find();
if($indet_data['state'] == 4){
$indet_data_update['id'] = $indet_id['indet_id'];
$indet_data_update['indent_address'] = $address['id'];
$indet_data_update['name'] = $address['name'];
$indet_data_update['phone'] = $address['phone'];
Db::name('indent') -> update($indet_data_update);
}
$this -> assign('address',$address);
$this -> assign('address_id',$address['id']);
}
}
$data = Db::name('indent_goods') -> where('indent_id',$indet_id['indet_id']) -> select() -> toArray();
foreach ($data as $key => $val){
$pricing = explode('.',$val['pricing']);
$data[$key]['pricing0'] = $pricing[0];
$data[$key]['pricing1'] = $pricing[1];
}
$money = Db::name('indent') -> where('id',$indet_id['indet_id']) -> find();
$this -> assign('money',$money['money']);
$this -> assign('data',$data);
$this -> assign('indent_id',$indet_id['indet_id']);
$this -> assign('type',5);
return $this -> fetch();
}
/**
* 显示业务员统一订单页mmmmm
*/
public function order_salesman_ty(){
$indet_id = $this -> request -> param();
$data = Db::name('indent_goods') -> where('indent_id',$indet_id['indet_id']) -> select() -> toArray();
foreach ($data as $key => $val){
$pricing = explode('.',$val['price']);
$data[$key]['price0'] = $pricing[0];
$data[$key]['price1'] = $pricing[1];
}
// 获取订单金额
$money = Db::name('indent') -> where('id',$indet_id['indet_id']) -> find();
$money['money'] = explode('.',$money['money']);
$this -> assign('money',$money['money']);
$this -> assign('data',$data);
//判断这个用户所属哪个业务员
$uid = cmf_get_current_user_id();
$user = Db::name('my_user') -> where('uid',$uid) -> find();
//当当前用户为老师时
if($user['status'] == 3){
$salesman = Db::name('my_user') -> where('id',$user['pid']) -> find();
}
//当前用户为学生时
if($user['status'] == 4){
$teacher = Db::name('my_user') -> where('id',$user['pid']) -> find();
$salesman = Db::name('my_user') -> where('id',$teacher['pid']) -> find();
}
// 查询业务员是否设置过邮费
$user_postage = Db::name('user_postage')->where('user_id',$salesman['uid'])->find();
if($user_postage) {
$courier = $user_postage['money'];
} else {
$courier = Db::name('money_ratio') -> where('id',1) -> value('courier');
}
$this -> assign('courier',$courier);
$this -> assign('indent_id',$indet_id['indet_id']);
//查询这个用户下添加的学校
$school = Db::name('school') -> where("uid",!empty($salesman['uid']) ? $salesman['uid'] : 0) -> select() -> toArray();
if(!empty($school)){
$grade_class = Db::name('grade_class') -> where("school_id",$school[0]['id']) -> select();
foreach ($grade_class as $key => $val){
$class = explode('-',$val['class']);
for($i=$class[0];$i<=$class[1];$i++){
$grade_class_show[] = $val['grade'].' - '.$i."班";
}
}
}
$this -> assign('school',$school);
$this -> assign('grade_class_show',!empty($grade_class_show) ? $grade_class_show : '');
return $this -> fetch();
}
/**
* 商品数量加一
*/
public function shop_cart_numadd(){
$id = $_POST['id'];
$data = Db::name('indent_goods') -> where('id',$id) -> find();
if($data['number']<200){
$res = Db::name('indent_goods') -> where('id',$id) -> setInc('number');
$indent_id = Db::name('indent_goods') -> where('id',$id) -> find();
Db::name('indent') -> where('id',$indent_id['indent_id']) -> setInc('money',$_POST['price']);
}
return true;
}
/**
* 商品数量减一
*/
public function shop_cart_numdec(){
$id = $_POST['id'];
$data = Db::name('indent_goods') -> where('id',$id) -> find();
if($data['number']>1){
Db::name('indent_goods') -> where('id',$id) -> setDec('number');
$indent_id = Db::name('indent_goods') -> where('id',$id) -> find();
Db::name('indent') -> where('id',$indent_id['indent_id']) -> setDec('money',$_POST['price']);
}
return true;
}
/**
* 显示业务员快递订单页
*/
public function order_salesman_kd(){
$uid = cmf_get_current_user_id();
$indent_id = $this -> request -> param();
$money = Db::name('indent') -> where("id =".$indent_id['indet_id']) -> find();
$indent_goods_data = Db::name('indent_goods') -> where('indent_id',$indent_id['indet_id']) -> select();
$this -> assign('data',$indent_goods_data);
//判断这个用户所属哪个业务员
$user = Db::name('my_user') -> where('uid',$uid) -> find();
//当当前用户为老师时
if($user['status'] == 3){
$salesman = Db::name('my_user') -> where('id',$user['pid']) -> find();
}
//当前用户为学生时
if($user['status'] == 4){
$teacher = Db::name('my_user') -> where('id',$user['pid']) -> find();
$salesman = Db::name('my_user') -> where('id',$teacher['pid']) -> find();
}
// 查询业务员是否设置过邮费
$user_postage = Db::name('user_postage')->where('user_id',$salesman['uid'])->find();
if($user_postage) {
$courier = $user_postage['money'];
} else {
$courier = Db::name('money_ratio') -> where('id',1) -> value('courier');
}
$this -> assign('courier',$courier);
$money['money'] = $money['money']+$courier;
$this -> assign('money',$money['money']);
if(empty($indent_id['address_id'])){
$address = Db::name('address') -> where("uid=".$uid." and default_address=1 and delete_time = 0") -> find();
}else{
$address = Db::name('address') -> where('id',$indent_id['address_id']) -> find();
}
if(empty($address)){
$this -> assign('address',4);
}else{
$indet_data = Db::name('indent') -> where("id",$indent_id['indet_id']) -> find();
if($indet_data['state'] == 4){
$indet_data_update['id'] = $indent_id['indet_id'];
$indet_data_update['indent_address'] = $address['id'];
$indet_data_update['name'] = $address['name'];
$indet_data_update['phone'] = $address['phone'];
$indet_data_update['region'] = $address['region'];
$indet_data_update['region_detail'] = $address['detailed'];
Db::name('indent') -> update($indet_data_update);
}
$this -> assign('address',$address);
}
$this -> assign('indet_id',$indent_id['indet_id']);
return $this -> fetch();
}
/**
* 业务员快递去支付
*/
public function salesman_go_pay(){
$_POST['is_courier'] = 2;
$data_update = Db::name('indent') -> update($_POST);
return true;
}
/**
* 取消支付时
*/
public function cancel_pay(){
$indent_id = $this -> request -> param();
$data = Db::name('indent') -> where('id',$indent_id['id']) -> find();
$money_ratio = Db::name('money_ratio') -> where('id',1) -> find();
/* if($data['indent_type'] == 2 && $data['is_courier'] == 2){
Db::name('indent') -> where('id',$indent_id['id']) -> setDec('money',$money_ratio['courier']);
}*/
$this -> redirect('index/index');
}
/**
* 平台商品去支付时 更新买家留言
*/
public function goods_leave_word_update(){
$param = $this->request->param();
$param['is_courier'] = 2;
$address = Db::name('address')->where('id',$param['indent_address'])->find();
if(!$address) {
return false;
}
$param['name'] = $address['name'];
$param['phone'] = $address['phone'];
$data = Db::name('indent') -> update($param);
return true;
}
/**
* 点击学校时获取年级班级
*/
public function get_grade_class(){
$school_id = $_POST['id'];
$grade_class = Db::name('grade_class') -> where("school_id",$school_id) -> select() -> toArray();
if(!empty($grade_class)){
foreach ($grade_class as $key => $val){
$class = explode('-',$val['class']);
for($i=$class[0];$i<=$class[1];$i++){
$grade_class_show[] = $val['grade'].' - '.$i."班";
}
}
return json_encode($grade_class_show);
}else{
return false;
}
}
/**
* 业务员统一配送页去支付
*/
public function salesman_ty_go_pay(){
$_POST['is_courier'] = 1;
$class = explode('-',$_POST['grade']);
$_POST['grade'] = trim($class[0]);
$_POST['class'] = trim($class[1]);
$indent_data['id'] = $_POST['id'];
$indent_data['region'] = $_POST['region'];
$indent_data['name'] = $_POST['name'];
$indent_data['phone'] = $_POST['phone'];
$indent_data['is_courier'] = $_POST['is_courier'];
$indent_data['school'] = $_POST['school'];
$indent_data['grade'] = $_POST['grade'];
$indent_data['class'] = $_POST['class'];
$indent_data['leave_word'] = $_POST['leave_word'];
$data = Db::name('indent') -> update($indent_data);
if($data){
return true;
}else{
return false;
}
}
/**
* 显示收货地址
*/
public function go_add_address(){
$indent_id = $this -> request -> param();
$uid = cmf_get_current_user_id();
$data = Db::name('address') -> where("delete_time = 0 and uid =".$uid) -> select() -> toArray();
$this -> assign('indent_id',$indent_id['indet_id']);
$this -> assign('data',$data);
if(!empty($indent_id['type'])){
$this -> assign('type',5);
}else{
$this -> assign('type',6);
}
return $this -> fetch();
}
/**
* 获取学校
*/
public function get_school(){
$user_id = $this->request->param('user_id');
if(empty($user_id)){
$user_id = cmf_get_current_user_id();
}
$my_user = Db::name('my_user')->where('uid',$user_id)->find();
if($my_user['status'] == 3){
$my_user2 = Db::name('my_user')->where('id',$my_user['pid'])->find();
}else{
$my_user3 = Db::name('my_user')->where('id',$my_user['pid'])->find();
$my_user2 = Db::name('my_user') -> where('id',$my_user3['pid']) -> find();
}
$area = $this->request->param('area',0);
if(empty($area)){
$this->error('缺少必要参数');
}
$where['region'] = ['like',"%$area%"];
$where['uid'] = ['eq',$my_user2['uid']];
$data = Db::name('school')->where($where)->select()->toArray();
//循环组建新数据
foreach ($data as $key=>$val){
$datas[$key]['value'] = $val['id'];
$datas[$key]['text'] = $val['school'];
}
if(!empty($datas)){
return json_encode($datas);
}else{
return false;
}
// $this->success('SUCCESS','',$datas);
}
/**
* 新增地址页
*/
public function add_shop_address(){
if($this -> request -> isPost()){
$uid = cmf_get_current_user_id();
$_POST['uid'] = $uid;
$add = Db::name('address') -> insert($_POST);
if($add){
return true;
}else{
return false;
}
}else{
$indent_id = $this -> request -> param();
$this -> assign('indent_id',$indent_id['indet_id']);
if($indent_id['type']==5){
$this -> assign('type',5);
}else{
$this -> assign('type',6);
}
return $this -> fetch();
}
}
/**
* 编辑地址
*/
public function address_edit(){
if($this -> request -> isPost()){
$data_update = Db::name('address') -> update($_POST);
if($data_update){
return true;
}else{
return false;
}
}else{
$id = $this -> request -> param();
$data = Db::name('address') -> where('id',$id['id']) -> find();
$this -> assign('data',$data);
$this -> assign('indent_id',$id['indet_id']);
if($id['type']==5){
$this -> assign('type',5);
}else{
$this -> assign('type',6);
}
return $this -> fetch();
}
}
}
\ No newline at end of file
... ...
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
namespace app\portal\controller;
use cmf\controller\WeChatBaseController;
use EasyWeChat\Foundation\Application;
use think\Db;
class sendAPI {
public $data; //发送数据
public $timeout = 30; //超时
private $apiUrl; //发送地址
private $username; //用户名
private $password; //密码
function __construct($url, $username, $password) {
$this->apiUrl = $url;
$this->username = $username;
$this->password = $password;
}
private function httpGet() {
$url = $this->apiUrl . '?' . http_build_query($this->data);
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_URL, $url);
$res = curl_exec($curl);
if (curl_errno($curl)) {
echo 'Error GET '.curl_error($curl);
}
curl_close($curl);
return $res;
}
private function httpPost(){ // 模拟提交数据函数
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $this->apiUrl); // 要访问的地址
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
curl_setopt($curl, CURLOPT_POST, true); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($this->data)); // Post提交的数据包
curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_HEADER, false); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // 获取的信息以文件流的形式返回
$result = curl_exec($curl); // 执行操作
if (curl_errno($curl)) {
echo 'Error POST'.curl_error($curl);
}
curl_close($curl); // 关键CURL会话
return $result; // 返回数据
}
/**
* @param $type|提交类型 POST/GET
* @param $isTranscoding|是否需要转 $isTranscoding 是否需要转utf-8 默认 false
* @return mixed
*/
public function sendSMS($type, $isTranscoding = false) {
$this->data['content'] = $isTranscoding === true ? mb_convert_encoding($this->data['content'], "UTF-8") : $this->data['content'];
$this->data['username'] = $this->username;
$this->data['tkey'] = date('YmdHis');
$this->data['password'] = md5(md5($this->password) . $this->data['tkey']);
return $type == "POST" ? $this->httpPost() : $this->httpGet();
}
}
class PersonalcenterController extends WeChatBaseController{
/**
* 显示个人中心页
*/
public function personal_center(){
$uid = cmf_get_current_user_id();
$my_user_status = Db::name('my_user') -> where('uid',$uid) -> find();
$weixin = Db::name('user') -> where('id',$uid) -> find();
$this -> assign('weixin',$weixin);
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){
if($my_user_status['status'] == 0){
$this -> assign('status',0);
}
if($my_user_status['status'] == 1 || $my_user_status['status'] == 5 || $my_user_status['status'] == 6){
$this -> assign('status',1);
}
if($my_user_status['status'] == 3){
$this -> assign('status',3);
}
if($my_user_status['status'] == 4){
$this -> assign('status',4);
}
return $this -> fetch();
}
//业务员个人中心页
if($my_user_status['status'] == 2){
$this -> assign('weixin',$weixin);
return $this -> fetch('personalcenter/salesman_center');
}
}
/**
* 完善个人信息页
*/
public function perfect_information(){
$uid = cmf_get_current_user_id();
$my_user_status = Db::name('my_user') -> where('uid',$uid) -> find();
if($my_user_status['status'] == 2){
$this -> redirect('Personalcenter/personal_center');
}else{
if($my_user_status['status'] == 1){
$this -> assign('status',1);
}
if($my_user_status['status'] == 5){
$this -> assign('status',5);
}
if($my_user_status['status'] == 6){
$this -> assign('status',6);
}
$weixin = Db::name('user') -> where('id',$uid) -> find();
$this -> assign('weixin',$weixin);
return $this -> fetch();
}
}
/**
* 我的收藏页
*/
public function personal_collect(){
$uid = cmf_get_current_user_id();
$data = Db::name('collect') -> where("uid =".$uid) -> select() -> toArray();
if(!empty($data)){
foreach($data as $key => $val){
$collect_goods = Db::name('goods') -> where("id =".$val['goods_id']) -> where("is_out = 1") -> find();
if($collect_goods != null){
$data_goods[] = $collect_goods;
}
}
if(!empty($data_goods)){
foreach ($data_goods as $key => $val){
$price = explode('.',$val['price']);
$pricing = explode('.',$val['pricing']);
$data_goods[$key]['price0'] = $price[0];
$data_goods[$key]['price1'] = $price[1];
$data_goods[$key]['pricing0'] = $pricing[0];
$data_goods[$key]['pricing1'] = $pricing[1];
}
}else{
$data_goods = '';
}
}else{
$data_goods = '';
}
if(!empty($data_goods)){
$data_count = count($data_goods);
}else{
$data_count = 0;
}
$this -> assign('data_count',$data_count);
$this -> assign('data_goods',$data_goods);
return $this -> fetch();
}
/**
* 填写个人信息页
*/
public function add_information(){
$options=config('wechat_config');
$app = new Application($options);
$js = $app->js;
$jssdk=$js->config(array('chooseImage','uploadImage'), false,false,true);
$this->assign('jssdk',$jssdk);
return $this -> fetch();
}
/**
* 浏览记录
*/
public function browsing_history(){
$uid = cmf_get_current_user_id();
$data = Db::name('browsing_history') -> where("uid =".$uid) -> select();
foreach($data as $key => $val){
$browsing_history_goods = Db::name('goods') -> where('id',$val['goods_id']) -> where("is_out = 1") -> find();
if($browsing_history_goods != null){
$data_goods[] = $browsing_history_goods;
}
}
if(!empty($data_goods)){
foreach($data_goods as $key => $val){
$price = explode('.',$val['price']);
$classification_name = Db::name('classification') -> where('id',$val['classify_id']) -> find();
$data_goods[$key]['classification_name'] = $classification_name['name'];
$data_goods[$key]['price0'] = $price[0];
$data_goods[$key]['price1'] = $price[1];
}
}else{
$data_goods = '';
}
$this -> assign('data_goods',$data_goods);
return $this -> fetch();
}
/**
* 收货地址页
*/
public function shop_address(){
$uid = cmf_get_current_user_id();
$data = Db::name('address') -> where("delete_time = 0 and uid =".$uid) -> select() -> toArray();
$this -> assign('data',$data);
return $this -> fetch();
}
/**
* 新增地址页
*/
public function add_shop_address(){
if($this -> request -> isPost()){
$uid = cmf_get_current_user_id();
$_POST['uid'] = $uid;
$add = Db::name('address') -> insert($_POST);
if($add){
return true;
}else{
return false;
}
}else{
return $this -> fetch();
}
}
/**
* 设置默认地址
*/
public function set_default_address(){
$uid = cmf_get_current_user_id();
Db::name('address') -> where('uid',$uid) -> update(['default_address'=>0]);
$data = Db::name('address') -> where('id',$_POST['id']) -> update(['default_address'=>1]);
if($data){
return true;
}else{
return false;
}
}
/**
* 删除地址
*/
public function address_del(){
$delete_time = time();
$data = Db::name('address') -> where('id',$_POST['id']) -> update(['delete_time'=>$delete_time]);
if($data){
return true;
}else{
return false;
}
}
/**
* 编辑地址
*/
public function address_edit(){
if($this -> request -> isPost()){
$data_update = Db::name('address') -> update($_POST);
if($data_update){
return true;
}else{
return false;
}
}else{
$id = $this -> request -> param();
$data = Db::name('address') -> where('id',$id['id']) -> find();
$this -> assign('data',$data);
return $this -> fetch();
}
}
/**
* 发送短信
*/
public function send_message(){
$url = "http://www.ztsms.cn/sendNSms.do";//提交地址
$username = 'xuekaowuyou';//用户名
$password = 'Cxz307312';//原密码
$sendAPI = new sendAPI($url, $username, $password);
$key = '';
$pattern='1234567890';
for( $i=0; $i<6; $i++ ) {
$key .= $pattern[mt_rand(0, 9)];
}
session('code',$key);
$rand_name = "验证码:".$key."【学考无忧】";
$phone = $_POST['phone'];
$data = array(
'content' => $rand_name,//短信内容
'mobile' => $phone,//手机号码
'productid' => '676767',//产品id
'xh' => ''//小号
);
$sendAPI->data = $data;//初始化数据包
$return = $sendAPI->sendSMS('POST');//GET or POST
if($return){
return true;
}else{
return false;
}
}
/**
* 添加审核信息
*/
public function add_audit(){
$code = session('code');
if($code == $_POST['code']){
//判断是否提交过
$id_num = $_POST['id_num'];
$id_number = Db::name('sale_audit') -> where("id_number = '$id_num' ") -> find();
if(!empty($id_number)){
return 4;
}
$data['name'] = $_POST['name'];
$data['phone'] = $_POST['phone'];
$data['id_number'] = $_POST['id_num'];
$data['img_front'] = $_POST['img0'];
$data['img_back'] = $_POST['img1'];
$data['create_time'] = time();
$data['uid'] = cmf_get_current_user_id();
$inser = Db::name('sale_audit') -> insert($data);
if($inser){
Db::name('my_user') -> where('uid',$data['uid']) -> update(['status'=>5,'phone'=>$data['phone']]);
return 1;
}else{
return 2;
}
}else{
return 3;
}
}
/**
* 我的钱包页
*/
public function my_wallet(){
$uid = cmf_get_current_user_id();
$balance = Db::name('my_user') -> where("uid",$uid) -> find();
$b_money = $balance['balance'];
$b_money = sprintf("%.2f",$b_money);
$this -> assign('b_money',$b_money);
$money_income = Db::name("money_income") -> where('uid',$uid) -> select();
$cumulative_money = 0;
foreach ($money_income as $key => $val){
$cumulative_money += $val['money'];
}
$cumulative_moneyss = $cumulative_money;
$cumulative_moneyss = sprintf("%.2f",$cumulative_moneyss);
$this -> assign('cumulative_moneyss',$cumulative_moneyss);
$cumulative_money = $cumulative_money-$cumulative_money*0.006;
$cumulative_money = sprintf("%.2f",$cumulative_money);
$money_ratio = Db::name('money_ratio') -> where('id',1) -> find();
$money_ratio['platform_ratio'] = $money_ratio['platform_ratio']*100;
$money_ratio['platform_ratio'] = $money_ratio['platform_ratio'].'%';
$this -> assign('money_ratio',$money_ratio);
$this -> assign('cumulative_money',$cumulative_money);
$money_expend = Db::name('money_expend') -> where('uid='.$uid." and state=0") -> select();
$money = 0;
foreach ($money_expend as $key => $val){
$money += $val['money'];
}
$tax_money = $money/(1-0.006);
$money = number_format($money,2);
$balance['balance'] = $balance['balance'] - $balance['balance']*0.006-$tax_money;
$balance['balance'] = sprintf("%.2f", $balance['balance']);
if($balance['balance'] <= 0){
$balance['balance'] = 0;
}
$this -> assign('balance',$balance['balance']);
$this -> assign('status',$balance['status']);
$this -> assign('money',$money);
return $this -> fetch();
}
/**
* 将提现金额存入支出明细表
*/
public function add_money_expend(){
$_POST['uid'] = cmf_get_current_user_id();
$_POST['create_time'] = time();
$_POST['state'] = 0;
$user_balance = Db::name('my_user') -> where('uid',$_POST['uid']) -> find();
$user_money_expend = Db::name('money_expend') -> where("uid=".$_POST['uid']." and state =0") -> select();
$money_expend = $_POST['money'];
$my_money_expend = 0;
foreach ($user_money_expend as $key => $val){
$my_money_expend += $val['money'];
}
$tax_money = $my_money_expend/(1-0.006);
$user_balance['balance'] = $user_balance['balance']-$user_balance['balance']*0.006-$tax_money;
if($money_expend > $user_balance['balance'] ){
return false;
}else{
$data = Db::name('money_expend') -> insert($_POST);
$money_expend = Db::name('money_expend') -> where('uid='.$_POST['uid']." and state=0") -> select();
$money = 0;
foreach ($money_expend as $key => $val){
$money += $val['money'];
}
$money = number_format($money,2);
if($data){
return $money;
}else{
return false;
}
}
}
/**
* 邀请名单
*/
public function invitation_list(){
$uid = cmf_get_current_user_id();
$my_user = Db::name('my_user') -> where('uid',$uid) -> find();
if($my_user['status'] == 3){
$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();
if(!empty($student)){
foreach ($student as $key => $val){
$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();
$name = $val['user_nickname'];
$avatar = $val['avatar'];
$cumulative_money = 0;
foreach ($student[$key]['indent'] as $key1 => $val1){
$student[$key]['indent'][$key1]['user_name'] = $name;
$student[$key]['indent'][$key1]['avatar'] = $avatar;
$money_income = Db::name('money_income') -> where("indent_id =".$val1['id']." and uid = ".$uid) -> select() -> toArray();
$money = 0;
foreach ($money_income as $key2 => $val2){
$money += $val2['money'];
}
$student[$key]['indent'][$key1]['total_money'] = number_format($money,2);
$cumulative_money += $money;
}
$student[$key]['cumulative_money'] = number_format($cumulative_money,2);
}
}else{
$student = null;
}
$this -> assign('type',3);
$this -> assign('student',$student);
}elseif ($my_user['status'] == 2){
//查找业务员下级老师
$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();
if(!empty($teacher)){
foreach ($teacher as $key => $val){
$money_income = Db::name('money_income') -> where("uid",$val['uid']) -> select();
$total_commission = 0;
foreach ($money_income as $key1 => $val1){
$total_commission += $val1['money'];
}
$teacher[$key]['total_commission'] = $total_commission;
//查找老师下面的学生
$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();
if(!empty($teacher[$key]['student'])){
foreach ($teacher[$key]['student'] as $key2 => $val2){
$teacher[$key]['student'][$key2]['indent'] = Db::name('indent') -> where('uid',$val2['uid']) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();
$student_indent_money = 0;
foreach ($teacher[$key]['student'][$key2]['indent'] as $key3 => $val3){
$student_money_income = Db::name('money_income') -> where("indent_id =".$val3['id']." and uid = ".$val['uid']) -> select() -> toArray();
$student_money_income_money = 0;
foreach ($student_money_income as $key4 => $val4){
$student_money_income_money += $val4['money'];
}
$teacher[$key]['student'][$key2]['indent']['student_money_income_money'] = $student_money_income_money;
$student_indent_money += $student_money_income_money;
}
$teacher[$key]['student'][$key2]['indent_money'] = $student_indent_money;
}
}
}
}else{
$teacher = null;
}
$this -> assign('type',2);
$this -> assign('teacher',$teacher);
}
return $this -> fetch();
}
/**
* 收入记录
*/
public function income_record(){
$uid = cmf_get_current_user_id();
$get = $this -> request -> param();
$my_user = Db::name('my_user') -> where('uid',$uid) -> find();
//搜索老师下级学生用户
$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();
foreach ($student as $key => $val){
if(!empty($get['startime']) && !empty($get['endtime'])){
$startime = strtotime($get['startime']);
$endtime = strtotime($get['endtime'])+86400;
$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();
}else{
$data[$key] = Db::name('indent') -> where('uid',$val['uid']) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();
}
$name = $val['user_nickname'];
$avatar = $val['avatar'];
if(count($data[$key])!=0){
foreach ($data[$key] as $key1 => $val1){
$book_name = Db::name('indent_goods') -> where("indent_id",$val1['id']) -> find();
$data[$key][$key1]['user_name'] = $name;
$data[$key][$key1]['avatar'] = $avatar;
$data[$key][$key1]['book_name'] = $book_name['book_name'];
$money_income = Db::name('money_income') -> where("indent_id =".$val1['id']." and uid = ".$uid) -> select() -> toArray();
$money = 0;
foreach ($money_income as $key2 => $val2){
$money += $val2['money'];
}
$data[$key][$key1]['total_money'] = number_format($money,2);
$res[] = $data[$key][$key1];
}
}
}
if(empty($res)){
$res = array();
}
// $this -> assign('res',$res);
//搜索老师用户
$teacher_avatar = Db::name('user') -> where('id',$uid) -> find();
if(!empty($get['startime']) && !empty($get['endtime'])){
$startime = strtotime($get['startime']);
$endtime = strtotime($get['endtime'])+86400;
$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();
}else{
$teacher = Db::name('indent') -> where('uid',$uid) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();
}
foreach($teacher as $key => $val){
$teacher_book_name = Db::name('indent_goods') -> where("indent_id",$val['id']) -> find();
$teacher_data[$key]['user_name'] = $teacher_avatar['user_nickname'];
$teacher_data[$key]['avatar'] = $teacher_avatar['avatar'];
$teacher_data[$key]['book_name'] = $teacher_book_name['book_name'];
$tea_money_income = Db::name('money_income') -> where("indent_id =".$val['id']." and uid = ".$uid) -> select() -> toArray();
$money = 0;
foreach ($tea_money_income as $key2 => $val2){
$money += $val2['money'];
}
$teacher_data[$key]['total_money'] = number_format($money,2) ;
$teacher_data[$key]['indent_type'] = $val['indent_type'];
$teacher_data[$key]['create_time'] = $val['create_time'];
$my_res[] = $teacher_data[$key];
}
if(empty($my_res)){
$my_res = array();
}
$aaaa = array_merge($res,$my_res);
$bb = array_column($aaaa,'create_time');
$cc = array_multisort($bb,SORT_DESC,$aaaa);
if(count($res)!=0 || count($my_res)!=0){
foreach ($aaaa as $key=>$val){
if($val['indent_type'] == 1){
$pingtai[] = $val;
}else{
$yewu[] = $val;
}
}
if(empty($pingtai)){
$this -> assign('pingtai',array());
}else{
$this -> assign('pingtai',$pingtai);
}
if(empty($yewu)){
$this -> assign('yewu',array());
}else{
$this -> assign('yewu',$yewu);
}
}else{
$this -> assign('pingtai',array());
$this -> assign('yewu',array());
}
// $this -> assign('res',$aaaa);
// $this -> assign('my_res',$my_res);
return $this -> fetch();
}
/**
* 提现明细
*/
public function withdrawal_subsidiary(){
$uid = cmf_get_current_user_id();
$data = Db::name('money_expend')
-> where('uid='.$uid)
-> where("state = 1 or state = 2")
-> order("create_time desc")
-> select();
$this -> assign('data',$data);
return $this -> fetch();
}
/**
* 显示商场盈利
*/
public function mall_profit(){
$uid = cmf_get_current_user_id();
$my_user = Db::name('my_user') -> where('uid',$uid) -> find();
if($my_user['status'] == 2){
$res = $this -> request -> param();
if(count($res) != 0){
$where = [
'a.indent_type' => 2,
'a.salesman_uid' => $uid,
];
if($res['school'] != ''){
$where['a.school'] = $res['school'];
}
if($res['grade'] != ''){
$school_grade_class = explode('-',$res['grade']);
$where['a.grade'] = trim($school_grade_class[0]);
$where['a.class'] = trim($school_grade_class[1]);
}
if($res['is_courier'] != ''){
if($res['is_courier'] == '统一配送'){
$where['a.is_courier'] = 1;
}
if($res['is_courier'] == '快递配送'){
$where['a.is_courier'] = 2;
}
}
if($res['start_time'] != '' && $res['end_time'] != ''){
$start_time = strtotime($res['start_time']);
$end_time = strtotime($res['end_time']);
$where['a.pay_time'] = [['>=',$start_time],['<=',$end_time]];
}
/*$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();*/
$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();
if(count($indent_money)!=0){
foreach ($indent_money as $key => $val){
$indent_money[$key]['book_name'] = Db::name('indent_goods') -> where('indent_id',$val['id']) -> select() -> toArray();
}
}
$this -> assign('indent_goods',$indent_money);
}else{
/*$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();*/
$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();
if(count($indent_goods)!=0){
foreach ($indent_goods as $key => $val){
$indent_goods[$key]['book_name'] = Db::name('indent_goods') -> where('indent_id',$val['id']) -> select() -> toArray();
}
}
$this -> assign('indent_goods',$indent_goods);
// $indent_money = Db::name('money_income') -> where("uid =".$uid) -> select();
$indent_money = $indent_goods;
}
$total_money = 0;
foreach ($indent_money as $key => $val){
$total_money += $val['money'];
}
//保留两位小数
$total_money = number_format($total_money,2);
// $total_money = $total_money-$total_money*0.006;
$this -> assign('total_money',$total_money);
//显示学校年级
$school = Db::name('school') -> where('uid',$uid) -> select() -> toArray();
$schools = [];
$grade_class_show = [];
if(count($school) != 0){
$grade_class = Db::name('grade_class') -> where("school_id",$school[0]['id']) -> select();
foreach ($grade_class as $key => $val){
$class = explode('-',$val['class']);
for($i=$class[0];$i<=$class[1];$i++){
$grade_class_show[] = $val['grade'].' - '.$i."班";
}
}
foreach ($school as $key => $val){
$schools[$key]['value'] = $val['id'];
$schools[$key]['text'] = $val['school'];
}
}
$this -> assign('school',json_encode($schools));
$this -> assign('grade_class_show',$grade_class_show);
//显示平台盈利
//查询业务员下级所有老师的订单
$teacher_user = Db::name('my_user') -> where("pid",$my_user['id']) -> select() -> toArray();
foreach ($teacher_user as $key => $val){
$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();
foreach ($teacher_indent[$key] as $key1 => $val1){
$money_income = Db::name('money_income') -> where("indent_id=".$val1['id']." and uid=".$my_user['uid']) -> select();
foreach ($money_income as $key3 => $val3){
$platform_money[] = $val3;
}
}
}
//查询老师下学生的订单
foreach ($teacher_user as $key => $val){
//查询老师下的所有学生
$student[$key] = Db::name('my_user') -> where("pid",$val['id']) -> select();
//查询学生的所有订单
foreach ($student[$key] as $key1 => $val1){
$student_indent[$key1] = Db::name('indent') -> where("indent_type=1 and uid=".$val1['uid']) -> where("state = 2 or state = 3 or state = 5") -> select();
//查询学生订单下属于业务员的收入记录
foreach ($student_indent[$key1] as $key2 => $val2){
$student_money_income = Db::name('money_income') -> where("indent_id=".$val2['id']." and uid=".$my_user['uid']) -> select();
foreach ($student_money_income as $key3 => $val3){
$platform_money[] = $val3;
}
}
}
}
if(empty($platform_money)){
$platform_money = null;
}
$this -> assign('platform_money',$platform_money);
}else{
$this -> error('非业务员不能进去此页');
}
return $this -> fetch();
}
/**
* 点击学校时获取年级班级
*/
public function get_grade_class(){
$school_id = $_POST['id'];
$grade_class = Db::name('grade_class') -> where("school_id",$school_id) -> select() -> toArray();
if(!empty($grade_class)){
foreach ($grade_class as $key => $val){
$class = explode('-',$val['class']);
for($i=$class[0];$i<=$class[1];$i++){
$grade_class_show[] = $val['grade'].' - '.$i."班";
}
}
foreach ($grade_class_show as $key => $val){
$grade_class_shows[$key]['value'] = $key;
$grade_class_shows[$key]['text'] = $val;
}
return json_encode($grade_class_shows);
}else{
return false;
}
}
/**
* 但图片上传
*/
public function image_one_up(){
$file = request()->file('avatar');
// 移动到框架应用根目录/public/uploads/ 目录下
if($file){
$info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');
if($info){
// 成功上传后 获取上传信息
// 输出 jpg
$image = $info->getSaveName();
$this->apiResponse(1,'成功',$image);
// 输出 20160820/42a79759f284b767dfcb2a0197904287.jpg
}else{
// 上传失败获取错误信息
echo $file->getError();
}
}
}
public function apiResponse($code = '', $msg = '',$data = array()){
header('Access-Control-Allow-Origin: *');
header('Content-Type:application/json; charset=utf-8');
$result = array(
'code'=>$code,
'msg'=>$msg,
'data'=>$data,
);
die(json_encode($result,JSON_UNESCAPED_UNICODE));
}
/**
*判断是否首次提现
*/
public function id_first_withdrawal(){
$uid = cmf_get_current_user_id();
$my_user = Db::name('my_user') -> where('uid',$uid) -> find();
if($my_user['is_withdrawal'] == '1'){
return true;
}else{
return false;
}
}
/**
* 首次提现手机验证码判断
*/
public function is_money_code(){
$uid = cmf_get_current_user_id();
$code = session('code');
if($code == $_POST['yzm']){
$user = Db::name('my_user') -> where('uid',$uid) -> find();
if(empty($user['phone'])){
Db::name('my_user') -> where('uid',$uid) -> update(['phone'=>$_POST['phone']]);
}
Db::name('my_user') -> where('uid',$uid) -> update(['is_withdrawal'=>2]);
return true;
}else{
return false;
}
}
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
namespace app\portal\controller;
use cmf\controller\WeChatBaseController;
use EasyWeChat\Foundation\Application;
use think\Db;
class sendAPI {
public $data; //发送数据
public $timeout = 30; //超时
private $apiUrl; //发送地址
private $username; //用户名
private $password; //密码
function __construct($url, $username, $password) {
$this->apiUrl = $url;
$this->username = $username;
$this->password = $password;
}
private function httpGet() {
$url = $this->apiUrl . '?' . http_build_query($this->data);
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_URL, $url);
$res = curl_exec($curl);
if (curl_errno($curl)) {
echo 'Error GET '.curl_error($curl);
}
curl_close($curl);
return $res;
}
private function httpPost(){ // 模拟提交数据函数
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $this->apiUrl); // 要访问的地址
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
curl_setopt($curl, CURLOPT_POST, true); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($this->data)); // Post提交的数据包
curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_HEADER, false); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // 获取的信息以文件流的形式返回
$result = curl_exec($curl); // 执行操作
if (curl_errno($curl)) {
echo 'Error POST'.curl_error($curl);
}
curl_close($curl); // 关键CURL会话
return $result; // 返回数据
}
/**
* @param $type|提交类型 POST/GET
* @param $isTranscoding|是否需要转 $isTranscoding 是否需要转utf-8 默认 false
* @return mixed
*/
public function sendSMS($type, $isTranscoding = false) {
$this->data['content'] = $isTranscoding === true ? mb_convert_encoding($this->data['content'], "UTF-8") : $this->data['content'];
$this->data['username'] = $this->username;
$this->data['tkey'] = date('YmdHis');
$this->data['password'] = md5(md5($this->password) . $this->data['tkey']);
return $type == "POST" ? $this->httpPost() : $this->httpGet();
}
}
class PersonalcenterController extends WeChatBaseController{
/**
* 显示个人中心页
*/
public function personal_center(){
$uid = cmf_get_current_user_id();
$my_user_status = Db::name('my_user') -> where('uid',$uid) -> find();
$weixin = Db::name('user') -> where('id',$uid) -> find();
$this -> assign('weixin',$weixin);
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){
if($my_user_status['status'] == 0){
$this -> assign('status',0);
}
if($my_user_status['status'] == 1 || $my_user_status['status'] == 5 || $my_user_status['status'] == 6){
$this -> assign('status',1);
}
if($my_user_status['status'] == 3){
$this -> assign('status',3);
}
if($my_user_status['status'] == 4){
$this -> assign('status',4);
}
return $this -> fetch();
}
//业务员个人中心页
if($my_user_status['status'] == 2){
$this -> assign('weixin',$weixin);
return $this -> fetch('personalcenter/salesman_center');
}
}
/**
* 完善个人信息页
*/
public function perfect_information(){
$uid = cmf_get_current_user_id();
$my_user_status = Db::name('my_user') -> where('uid',$uid) -> find();
if($my_user_status['status'] == 2){
$this -> redirect('Personalcenter/personal_center');
}else{
if($my_user_status['status'] == 1){
$this -> assign('status',1);
}
if($my_user_status['status'] == 5){
$this -> assign('status',5);
}
if($my_user_status['status'] == 6){
$this -> assign('status',6);
}
$weixin = Db::name('user') -> where('id',$uid) -> find();
$this -> assign('weixin',$weixin);
return $this -> fetch();
}
}
/**
* 我的收藏页
*/
public function personal_collect(){
$uid = cmf_get_current_user_id();
$data = Db::name('collect') -> where("uid =".$uid) -> select() -> toArray();
if(!empty($data)){
foreach($data as $key => $val){
$collect_goods = Db::name('goods') -> where("id =".$val['goods_id']) -> where("is_out = 1") -> find();
if($collect_goods != null){
$data_goods[] = $collect_goods;
}
}
if(!empty($data_goods)){
foreach ($data_goods as $key => $val){
$price = explode('.',$val['price']);
$pricing = explode('.',$val['pricing']);
$data_goods[$key]['price0'] = $price[0];
$data_goods[$key]['price1'] = $price[1];
$data_goods[$key]['pricing0'] = $pricing[0];
$data_goods[$key]['pricing1'] = $pricing[1];
}
}else{
$data_goods = '';
}
}else{
$data_goods = '';
}
if(!empty($data_goods)){
$data_count = count($data_goods);
}else{
$data_count = 0;
}
$this -> assign('data_count',$data_count);
$this -> assign('data_goods',$data_goods);
return $this -> fetch();
}
/**
* 填写个人信息页
*/
public function add_information(){
$options=config('wechat_config');
$app = new Application($options);
$js = $app->js;
$jssdk=$js->config(array('chooseImage','uploadImage'), false,false,true);
$this->assign('jssdk',$jssdk);
return $this -> fetch();
}
/**
* 浏览记录
*/
public function browsing_history(){
$uid = cmf_get_current_user_id();
$data = Db::name('browsing_history') -> where("uid =".$uid) -> select();
foreach($data as $key => $val){
$browsing_history_goods = Db::name('goods') -> where('id',$val['goods_id']) -> where("is_out = 1") -> find();
if($browsing_history_goods != null){
$data_goods[] = $browsing_history_goods;
}
}
if(!empty($data_goods)){
foreach($data_goods as $key => $val){
$price = explode('.',$val['price']);
$classification_name = Db::name('classification') -> where('id',$val['classify_id']) -> find();
$data_goods[$key]['classification_name'] = $classification_name['name'];
$data_goods[$key]['price0'] = $price[0];
$data_goods[$key]['price1'] = $price[1];
}
}else{
$data_goods = '';
}
$this -> assign('data_goods',$data_goods);
return $this -> fetch();
}
/**
* 收货地址页
*/
public function shop_address(){
$uid = cmf_get_current_user_id();
$data = Db::name('address') -> where("delete_time = 0 and uid =".$uid) -> select() -> toArray();
$this -> assign('data',$data);
return $this -> fetch();
}
/**
* 新增地址页
*/
public function add_shop_address(){
if($this -> request -> isPost()){
$uid = cmf_get_current_user_id();
$_POST['uid'] = $uid;
$add = Db::name('address') -> insert($_POST);
if($add){
return true;
}else{
return false;
}
}else{
return $this -> fetch();
}
}
/**
* 设置默认地址
*/
public function set_default_address(){
$uid = cmf_get_current_user_id();
Db::name('address') -> where('uid',$uid) -> update(['default_address'=>0]);
$data = Db::name('address') -> where('id',$_POST['id']) -> update(['default_address'=>1]);
if($data){
return true;
}else{
return false;
}
}
/**
* 删除地址
*/
public function address_del(){
$delete_time = time();
$data = Db::name('address') -> where('id',$_POST['id']) -> update(['delete_time'=>$delete_time]);
if($data){
return true;
}else{
return false;
}
}
/**
* 编辑地址
*/
public function address_edit(){
if($this -> request -> isPost()){
$data_update = Db::name('address') -> update($_POST);
if($data_update){
return true;
}else{
return false;
}
}else{
$id = $this -> request -> param();
$data = Db::name('address') -> where('id',$id['id']) -> find();
$this -> assign('data',$data);
return $this -> fetch();
}
}
/**
* 发送短信
*/
public function send_message(){
$url = "http://www.ztsms.cn/sendNSms.do";//提交地址
$username = 'xuekaowuyou';//用户名
$password = 'Cxz307312';//原密码
$sendAPI = new sendAPI($url, $username, $password);
$key = '';
$pattern='1234567890';
for( $i=0; $i<6; $i++ ) {
$key .= $pattern[mt_rand(0, 9)];
}
session('code',$key);
$rand_name = "验证码:".$key."【学考无忧】";
$phone = $_POST['phone'];
$data = array(
'content' => $rand_name,//短信内容
'mobile' => $phone,//手机号码
'productid' => '676767',//产品id
'xh' => ''//小号
);
$sendAPI->data = $data;//初始化数据包
$return = $sendAPI->sendSMS('POST');//GET or POST
if($return){
return true;
}else{
return false;
}
}
/**
* 添加审核信息
*/
public function add_audit(){
$code = session('code');
if($code == $_POST['code']){
//判断是否提交过
$id_num = $_POST['id_num'];
$id_number = Db::name('sale_audit') -> where("id_number = '$id_num' ") -> find();
if(!empty($id_number)){
return 4;
}
$data['name'] = $_POST['name'];
$data['phone'] = $_POST['phone'];
$data['id_number'] = $_POST['id_num'];
$data['img_front'] = $_POST['img0'];
$data['img_back'] = $_POST['img1'];
$data['create_time'] = time();
$data['uid'] = cmf_get_current_user_id();
$inser = Db::name('sale_audit') -> insert($data);
if($inser){
Db::name('my_user') -> where('uid',$data['uid']) -> update(['status'=>5,'phone'=>$data['phone']]);
return 1;
}else{
return 2;
}
}else{
return 3;
}
}
/**
* 我的钱包页
*/
public function my_wallet(){
$uid = cmf_get_current_user_id();
$balance = Db::name('my_user') -> where("uid",$uid) -> find();
$b_money = $balance['balance'];
$b_money = sprintf("%.2f",$b_money);
$this -> assign('b_money',$b_money);
$money_income = Db::name("money_income") -> where('uid',$uid) -> select();
$cumulative_money = 0;
foreach ($money_income as $key => $val){
$cumulative_money += $val['money'];
}
$cumulative_moneyss = $cumulative_money;
$cumulative_moneyss = sprintf("%.2f",$cumulative_moneyss);
$this -> assign('cumulative_moneyss',$cumulative_moneyss);
$cumulative_money = $cumulative_money-$cumulative_money*0.006;
$cumulative_money = sprintf("%.2f",$cumulative_money);
$money_ratio = Db::name('money_ratio') -> where('id',1) -> find();
$money_ratio['platform_ratio'] = $money_ratio['platform_ratio']*100;
$money_ratio['platform_ratio'] = $money_ratio['platform_ratio'].'%';
$this -> assign('money_ratio',$money_ratio);
$this -> assign('cumulative_money',$cumulative_money);
$money_expend = Db::name('money_expend') -> where('uid='.$uid." and state=0") -> select();
$money = 0;
foreach ($money_expend as $key => $val){
$money += $val['money'];
}
$tax_money = $money/(1-0.006);
$money = number_format($money,2);
$balance['balance'] = $balance['balance'] - $balance['balance']*0.006-$tax_money;
$balance['balance'] = sprintf("%.2f", $balance['balance']);
if($balance['balance'] <= 0){
$balance['balance'] = 0;
}
$this -> assign('balance',$balance['balance']);
$this -> assign('status',$balance['status']);
$this -> assign('money',$money);
return $this -> fetch();
}
/**
* 将提现金额存入支出明细表
*/
public function add_money_expend(){
$_POST['uid'] = cmf_get_current_user_id();
$_POST['create_time'] = time();
$_POST['state'] = 0;
$user_balance = Db::name('my_user') -> where('uid',$_POST['uid']) -> find();
$user_money_expend = Db::name('money_expend') -> where("uid=".$_POST['uid']." and state =0") -> select();
$money_expend = $_POST['money'];
$my_money_expend = 0;
foreach ($user_money_expend as $key => $val){
$my_money_expend += $val['money'];
}
$tax_money = $my_money_expend/(1-0.006);
$user_balance['balance'] = $user_balance['balance']-$user_balance['balance']*0.006-$tax_money;
if($money_expend > $user_balance['balance'] ){
return false;
}else{
$data = Db::name('money_expend') -> insert($_POST);
$money_expend = Db::name('money_expend') -> where('uid='.$_POST['uid']." and state=0") -> select();
$money = 0;
foreach ($money_expend as $key => $val){
$money += $val['money'];
}
$money = number_format($money,2);
if($data){
return $money;
}else{
return false;
}
}
}
/**
* 邀请名单
*/
public function invitation_list(){
$uid = cmf_get_current_user_id();
$my_user = Db::name('my_user') -> where('uid',$uid) -> find();
if($my_user['status'] == 3){
$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();
if(!empty($student)){
foreach ($student as $key => $val){
$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();
$name = $val['user_nickname'];
$avatar = $val['avatar'];
$cumulative_money = 0;
foreach ($student[$key]['indent'] as $key1 => $val1){
$student[$key]['indent'][$key1]['user_name'] = $name;
$student[$key]['indent'][$key1]['avatar'] = $avatar;
$money_income = Db::name('money_income') -> where("indent_id =".$val1['id']." and uid = ".$uid) -> select() -> toArray();
$money = 0;
foreach ($money_income as $key2 => $val2){
$money += $val2['money'];
}
$student[$key]['indent'][$key1]['total_money'] = number_format($money,2);
$cumulative_money += $money;
}
$student[$key]['cumulative_money'] = number_format($cumulative_money,2);
}
}else{
$student = null;
}
$this -> assign('type',3);
$this -> assign('student',$student);
}elseif ($my_user['status'] == 2){
//查找业务员下级老师
$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();
if(!empty($teacher)){
foreach ($teacher as $key => $val){
$money_income = Db::name('money_income') -> where("uid",$val['uid']) -> select();
$total_commission = 0;
foreach ($money_income as $key1 => $val1){
$total_commission += $val1['money'];
}
$teacher[$key]['total_commission'] = $total_commission;
//查找老师下面的学生
$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();
if(!empty($teacher[$key]['student'])){
foreach ($teacher[$key]['student'] as $key2 => $val2){
$teacher[$key]['student'][$key2]['indent'] = Db::name('indent') -> where('uid',$val2['uid']) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();
$student_indent_money = 0;
foreach ($teacher[$key]['student'][$key2]['indent'] as $key3 => $val3){
$student_money_income = Db::name('money_income') -> where("indent_id =".$val3['id']." and uid = ".$val['uid']) -> select() -> toArray();
$student_money_income_money = 0;
foreach ($student_money_income as $key4 => $val4){
$student_money_income_money += $val4['money'];
}
$teacher[$key]['student'][$key2]['indent']['student_money_income_money'] = $student_money_income_money;
$student_indent_money += $student_money_income_money;
}
$teacher[$key]['student'][$key2]['indent_money'] = $student_indent_money;
}
}
}
}else{
$teacher = null;
}
$this -> assign('type',2);
$this -> assign('teacher',$teacher);
}
return $this -> fetch();
}
/**
* 收入记录
*/
public function income_record(){
$uid = cmf_get_current_user_id();
$get = $this -> request -> param();
$my_user = Db::name('my_user') -> where('uid',$uid) -> find();
//搜索老师下级学生用户
$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();
foreach ($student as $key => $val){
if(!empty($get['startime']) && !empty($get['endtime'])){
$startime = strtotime($get['startime']);
$endtime = strtotime($get['endtime'])+86400;
$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();
}else{
$data[$key] = Db::name('indent') -> where('uid',$val['uid']) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();
}
$name = $val['user_nickname'];
$avatar = $val['avatar'];
if(count($data[$key])!=0){
foreach ($data[$key] as $key1 => $val1){
$book_name = Db::name('indent_goods') -> where("indent_id",$val1['id']) -> find();
$data[$key][$key1]['user_name'] = $name;
$data[$key][$key1]['avatar'] = $avatar;
$data[$key][$key1]['book_name'] = $book_name['book_name'];
$money_income = Db::name('money_income') -> where("indent_id =".$val1['id']." and uid = ".$uid) -> select() -> toArray();
$money = 0;
foreach ($money_income as $key2 => $val2){
$money += $val2['money'];
}
$data[$key][$key1]['total_money'] = number_format($money,2);
$res[] = $data[$key][$key1];
}
}
}
if(empty($res)){
$res = array();
}
// $this -> assign('res',$res);
//搜索老师用户
$teacher_avatar = Db::name('user') -> where('id',$uid) -> find();
if(!empty($get['startime']) && !empty($get['endtime'])){
$startime = strtotime($get['startime']);
$endtime = strtotime($get['endtime'])+86400;
$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();
}else{
$teacher = Db::name('indent') -> where('uid',$uid) -> where("state = 2 or state = 3 or state = 5") -> select() -> toArray();
}
foreach($teacher as $key => $val){
$teacher_book_name = Db::name('indent_goods') -> where("indent_id",$val['id']) -> find();
$teacher_data[$key]['user_name'] = $teacher_avatar['user_nickname'];
$teacher_data[$key]['avatar'] = $teacher_avatar['avatar'];
$teacher_data[$key]['book_name'] = $teacher_book_name['book_name'];
$tea_money_income = Db::name('money_income') -> where("indent_id =".$val['id']." and uid = ".$uid) -> select() -> toArray();
$money = 0;
foreach ($tea_money_income as $key2 => $val2){
$money += $val2['money'];
}
$teacher_data[$key]['total_money'] = number_format($money,2) ;
$teacher_data[$key]['indent_type'] = $val['indent_type'];
$teacher_data[$key]['create_time'] = $val['create_time'];
$my_res[] = $teacher_data[$key];
}
if(empty($my_res)){
$my_res = array();
}
$aaaa = array_merge($res,$my_res);
$bb = array_column($aaaa,'create_time');
$cc = array_multisort($bb,SORT_DESC,$aaaa);
if(count($res)!=0 || count($my_res)!=0){
foreach ($aaaa as $key=>$val){
if($val['indent_type'] == 1){
$pingtai[] = $val;
}else{
$yewu[] = $val;
}
}
if(empty($pingtai)){
$this -> assign('pingtai',array());
}else{
$this -> assign('pingtai',$pingtai);
}
if(empty($yewu)){
$this -> assign('yewu',array());
}else{
$this -> assign('yewu',$yewu);
}
}else{
$this -> assign('pingtai',array());
$this -> assign('yewu',array());
}
// $this -> assign('res',$aaaa);
// $this -> assign('my_res',$my_res);
return $this -> fetch();
}
/**
* 提现明细
*/
public function withdrawal_subsidiary(){
$uid = cmf_get_current_user_id();
$data = Db::name('money_expend')
-> where('uid='.$uid)
-> where("state = 1 or state = 2")
-> order("create_time desc")
-> select();
$this -> assign('data',$data);
return $this -> fetch();
}
/**
* 显示商场盈利
*/
public function mall_profit(){
$uid = cmf_get_current_user_id();
$my_user = Db::name('my_user') -> where('uid',$uid) -> find();
if($my_user['status'] == 2){
$res = $this -> request -> param();
if(count($res) != 0){
$where = [
'a.indent_type' => 2,
'a.salesman_uid' => $uid,
];
if($res['school'] != ''){
$where['a.school'] = $res['school'];
}
if($res['grade'] != ''){
$school_grade_class = explode('-',$res['grade']);
$where['a.grade'] = trim($school_grade_class[0]);
$where['a.class'] = trim($school_grade_class[1]);
}
if($res['is_courier'] != ''){
if($res['is_courier'] == '统一配送'){
$where['a.is_courier'] = 1;
}
if($res['is_courier'] == '快递配送'){
$where['a.is_courier'] = 2;
}
}
if($res['start_time'] != '' && $res['end_time'] != ''){
$start_time = strtotime($res['start_time']);
$end_time = strtotime($res['end_time']);
$where['a.pay_time'] = [['>=',$start_time],['<=',$end_time]];
}
/*$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();*/
$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();
if(count($indent_money)!=0){
foreach ($indent_money as $key => $val){
$indent_money[$key]['book_name'] = Db::name('indent_goods') -> where('indent_id',$val['id']) -> select() -> toArray();
}
}
$this -> assign('indent_goods',$indent_money);
}else{
/*$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();*/
$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();
if(count($indent_goods)!=0){
foreach ($indent_goods as $key => $val){
$indent_goods[$key]['book_name'] = Db::name('indent_goods') -> where('indent_id',$val['id']) -> select() -> toArray();
}
}
$this -> assign('indent_goods',$indent_goods);
// $indent_money = Db::name('money_income') -> where("uid =".$uid) -> select();
$indent_money = $indent_goods;
}
$total_money = 0;
foreach ($indent_money as $key => $val){
$total_money += $val['money'];
}
//保留两位小数
$total_money = number_format($total_money,2);
// $total_money = $total_money-$total_money*0.006;
$this -> assign('total_money',$total_money);
//显示学校年级
$school = Db::name('school') -> where('uid',$uid) -> select() -> toArray();
$schools = [];
$grade_class_show = [];
if(count($school) != 0){
$grade_class = Db::name('grade_class') -> where("school_id",$school[0]['id']) -> select();
foreach ($grade_class as $key => $val){
$class = explode('-',$val['class']);
for($i=$class[0];$i<=$class[1];$i++){
$grade_class_show[] = $val['grade'].' - '.$i."班";
}
}
foreach ($school as $key => $val){
$schools[$key]['value'] = $val['id'];
$schools[$key]['text'] = $val['school'];
}
}
$this -> assign('school',json_encode($schools));
$this -> assign('grade_class_show',$grade_class_show);
//显示平台盈利
//查询业务员下级所有老师的订单
$teacher_user = Db::name('my_user') -> where("pid",$my_user['id']) -> select() -> toArray();
foreach ($teacher_user as $key => $val){
$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();
foreach ($teacher_indent[$key] as $key1 => $val1){
$money_income = Db::name('money_income') -> where("indent_id=".$val1['id']." and uid=".$my_user['uid']) -> select();
foreach ($money_income as $key3 => $val3){
$platform_money[] = $val3;
}
}
}
//查询老师下学生的订单
foreach ($teacher_user as $key => $val){
//查询老师下的所有学生
$student[$key] = Db::name('my_user') -> where("pid",$val['id']) -> select();
//查询学生的所有订单
foreach ($student[$key] as $key1 => $val1){
$student_indent[$key1] = Db::name('indent') -> where("indent_type=1 and uid=".$val1['uid']) -> where("state = 2 or state = 3 or state = 5") -> select();
//查询学生订单下属于业务员的收入记录
foreach ($student_indent[$key1] as $key2 => $val2){
$student_money_income = Db::name('money_income') -> where("indent_id=".$val2['id']." and uid=".$my_user['uid']) -> select();
foreach ($student_money_income as $key3 => $val3){
$platform_money[] = $val3;
}
}
}
}
if(empty($platform_money)){
$platform_money = null;
}
$this -> assign('platform_money',$platform_money);
}else{
$this -> error('非业务员不能进去此页');
}
return $this -> fetch();
}
/**
* 点击学校时获取年级班级
*/
public function get_grade_class(){
$school_id = $_POST['id'];
$grade_class = Db::name('grade_class') -> where("school_id",$school_id) -> select() -> toArray();
if(!empty($grade_class)){
foreach ($grade_class as $key => $val){
$class = explode('-',$val['class']);
for($i=$class[0];$i<=$class[1];$i++){
$grade_class_show[] = $val['grade'].' - '.$i."班";
}
}
foreach ($grade_class_show as $key => $val){
$grade_class_shows[$key]['value'] = $key;
$grade_class_shows[$key]['text'] = $val;
}
return json_encode($grade_class_shows);
}else{
return false;
}
}
/**
* 但图片上传
*/
public function image_one_up(){
$file = request()->file('avatar');
// 移动到框架应用根目录/public/uploads/ 目录下
if($file){
$info = $file->move(ROOT_PATH . 'public' . DS . 'uploads');
if($info){
// 成功上传后 获取上传信息
// 输出 jpg
$image = $info->getSaveName();
$this->apiResponse(1,'成功',$image);
// 输出 20160820/42a79759f284b767dfcb2a0197904287.jpg
}else{
// 上传失败获取错误信息
echo $file->getError();
}
}
}
public function apiResponse($code = '', $msg = '',$data = array()){
header('Access-Control-Allow-Origin: *');
header('Content-Type:application/json; charset=utf-8');
$result = array(
'code'=>$code,
'msg'=>$msg,
'data'=>$data,
);
die(json_encode($result,JSON_UNESCAPED_UNICODE));
}
/**
*判断是否首次提现
*/
public function id_first_withdrawal(){
$uid = cmf_get_current_user_id();
$my_user = Db::name('my_user') -> where('uid',$uid) -> find();
if($my_user['is_withdrawal'] == '1'){
return true;
}else{
return false;
}
}
/**
* 首次提现手机验证码判断
*/
public function is_money_code(){
$uid = cmf_get_current_user_id();
$code = session('code');
if($code == $_POST['yzm']){
$user = Db::name('my_user') -> where('uid',$uid) -> find();
if(empty($user['phone'])){
Db::name('my_user') -> where('uid',$uid) -> update(['phone'=>$_POST['phone']]);
}
Db::name('my_user') -> where('uid',$uid) -> update(['is_withdrawal'=>2]);
return true;
}else{
return false;
}
}
public function salesman_postage() {
if($this->request->isAjax()) {
$user_id = cmf_get_current_user_id();
$money = $this->request->param('money');
$my_user = Db::name('my_user')->where('uid',$user_id)->find();
if($my_user['status'] != 2) {
$this->error('无法访问该页面');
}
if(empty($money)) {
$this->error('请设置邮费金额');
}
// 获取业务员配置的邮费,如未配置过,则新增一条记录
$user_postage = Db::name('user_postage')->where('user_id',$user_id)->find();
if(!$user_postage) {
$insert = [
'user_id' => $user_id,
'money' => $money,
'createtime' => time(),
'updatetime' => time()
];
$result = Db::name('user_postage')->insertGetId($insert);
} else {
$result = true;
if($money != $user_postage['money']) {
$update = [
'id' => $user_postage['id'],
'money' => $money,
'updatetime' => time()
];
$result = Db::name('user_postage')->update($update);
}
}
if(!$result) {
$this->error('邮费设置失败');
}
$this->success('邮费设置成功');
} else {
$user_id = cmf_get_current_user_id();
$my_user = Db::name('my_user')->where('uid',$user_id)->find();
if($my_user['status'] != 2) {
$this->error('无法访问该页面');
}
// 获取业务员配置的邮费,如未配置过,则使用平台配置的邮费
$user_postage = Db::name('user_postage')->where('user_id',$user_id)->find();
if(!$user_postage) {
$postage_money = Db::name('money_ratio')->where('id',1)->value('courier');
} else {
$postage_money = $user_postage['money'];
}
$this->assign('money',$postage_money);
return $this->fetch();
}
}
}
\ No newline at end of file
... ...
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>学考无忧-确认订单</title>
<link rel="stylesheet" href="__TMPL__/public/assets/css/reset.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/base.css">
<style>
.order_address {
padding-bottom: 0.26rem;
background-repeat: no-repeat;
background-image: url("__TMPL__/public/assets/images/32.png");
background-position: bottom;
background-size: 100% 0.06rem;
background-color: white;
}
.yw_wayActive {
border: 0;
background-size: 100% 100%;
background-image: url('__TMPL__/public/assets/images/71.png');
}
</style>
</head>
<body>
<div class="order_box">
<!-- 顶部 -->
<div class="order_top">
<a href="{:url('shopcart/shop_cart')}">
<img src="__TMPL__/public/assets/images/left.png" alt="">
</a>
<p>订单确认</p>
</div>
<!-- 地址 -->
<div class="order_address">
<!-- 暂无 -->
<if condition="$address eq 4">
<div class="order_addressNo">
<div class="order_adImg">
<img src="__TMPL__/public/assets/images/31.png" alt="">
</div>
<p class="order_addressGo">暂无默认收货地址,<a href="{:url('Orderpage/go_add_address',array('indet_id'=>$indet_id))}">去添加</a></p>
</div>
<else/>
<div class="order_addressYes">
<div class="or_addressYesImg1">
<img src="__TMPL__/public/assets/images/38.png" alt="">
</div>
<div class="or_addressYesTxt1">
<div class="or_addressYesTxt2">
<div class="or_addressName" id="name">{$address.name}</div>
<p class="or_addressPhone" id="phone">{$address.phone}</p>
</div>
<p class="or_address_detailed" id="detailed">{$address.region}{$address.detailed}</p>
</div>
<div class="or_addressYesImg2">
<a href="{:url('Orderpage/go_add_address',array('indet_id'=>$indet_id))}">
<img src="__TMPL__/public/assets/images/29.png" alt="">
</a>
</div>
</div>
</if>
</div>
<!-- 订单信息 -->
<div class="order_news">
<!-- 配送方式 -->
<div class="yw_way">
<h3>配送方式</h3>
<div class="yw_way2">
<div class="yw_way2Li " onclick="go_unified()">统一配送</div>
<div class="yw_way2Li yw_wayActive">快递配送({$courier}元)</div>
</div>
</div>
<h1 class="order_newsTit">订单信息</h1>
<ul class="order_newsUl">
<volist name="data" id="vo">
<li>
<div class="order_newsImg">
<img src="{:cmf_get_image_url($vo.thumbnail)}" alt="">
</div>
<div class="order_newsCon">
<div class="order_newsTxt1 txt-cut">{$vo.book_name}</div>
<div class="order_newsTxt2">×<span>{$vo.number}</span></div>
<div class="order_newsTxt3">
<p class="de_topTxt1_1"><span>{$vo.price}</span></p>
<p class="de_topTxt1_2"><span>{$vo.pricing}</span></p>
<div class="order_newsNum">
<div class="order_newsJian" onclick="jian({$vo.id},{$vo.price})">-</div>
<input class="order_newsnum" type="text" readonly="readonly" value="{$vo.number}">
<div class="order_newsJia" onclick="jia({$vo.id},{$vo.price})">+</div>
</div>
</div>
</div>
</li>
</volist>
</ul>
</div>
<!-- 支付方式/配送方式 -->
<div class="order_Etc">
<div class="order_Etc1">
<p class="order_EtcTxt">支付方式</p>
<img class="order_EtcImg" src="__TMPL__/public/assets/images/34.png" alt="">
</div>
<div class="order_Etc1">
<p class="order_EtcTxt">配送方式</p>
<span class="order_EtcTxt2">快递</span>
</div>
<div class="order_Etc2">
<p class="order_EtcTxt">买家留言</p>
<textarea placeholder="在此填写您的留言" id="liuyan"></textarea>
</div>
</div>
<!-- 底部 -->
<div class="order_bottom">
<div class="order_bottom1">
<p class="order_bottomHe">合计金额:</p>
<p class="de_topTxt1_1 zoji"><span id="money">{$money}</span></p>
</div>
<div class="order_bottom2" onclick="go_pay()">立即支付</div>
</div>
</div>
<script src="__TMPL__/public/assets/js/base.js"></script>
<script src="__TMPL__/public/assets/js/jquery.js"></script>
<script>
/**
* 点击统一配送
*/
function go_unified(){
window.location.href = "{:url('Orderpage/order_salesman_ty')}?indet_id="+{$indet_id};
}
/**
*点击去支付
*/
function go_pay(){
indnet_id = "{$indet_id}";
$.post("{:url('Order/is_my_salesman')}",{indent_id:indnet_id},function(data){
if(data){
name = $('#name').text();
phone = $('#phone').text();
detailed = $('#detailed').text();
if(name == ''){
alert('收货地址不能为空');
}else if(phone == ''){
alert('收货地址不能为空');
}else if(detailed == ''){
alert('收货地址不能为空');
}else{
liuyan = $('#liuyan').val();
indet_id = {$indet_id};
money = $('#money').text();
$.post("{:url('Orderpage/salesman_go_pay')}",{leave_word:liuyan,id:indet_id,money:money},function(data){
if(data){
window.location.href = "{:url('Pay/index',array('id'=>$indet_id))}";
}else{
alert('更新订单失败');
}
});
}
}else{
alert('不再此区域销售');
}
});
}
/**
*点击加一
*/
function jia(id,price){
$.post("{:url('Orderpage/shop_cart_numadd')}",{id:id,price:price},function(data){
});
}
/**
* 点击减一
*/
function jian(id,price){
$.post("{:url('Orderpage/shop_cart_numdec')}",{id:id,price:price},function(data){
});
}
</script>
<script>
$(document).ready(function() {
// 配送方式
$('.yw_way2 div').click(function() {
$(this).addClass('yw_wayActive').siblings().removeClass('yw_wayActive');
})
$(".order_newsNum div").on("click", function(evt) {
if ($(this).text() == "-") {
var count = parseInt($(this).next().val());
if (count > 1) {
count -= 1;
$(this).next().val(count);
} else {
alert("商品数量最少为1");
}
$(this).parents(".order_newsCon").find(".order_newsTxt2 span").text(count);
} else {
var count = parseInt($(this).prev().val());
if (count < 200) {
count += 1;
$(this).prev().val(count);
} else {
alert("商品数量最多为200");
}
$(this).parents(".order_newsCon").find(".order_newsTxt2 span").text(count);
}
var price = parseFloat($(this).parents(".order_newsTxt3").children(".de_topTxt1_1").text().split("¥")[1]);
calcTotal2();
});
// 计算总计
function calcTotal2() {
var checkBoxes = $(".sh_cartround img");
var priceSpans = $(".order_newsTxt3 .de_topTxt1_1 span");
var countInputs = $(".order_newsNum .order_newsnum");
var totalCount = 0;
var totalPrice = {$courier};
for (var i = 0; i < priceSpans.length; i += 1) {
// 强调: jQuery对象使用下标运算或get方法会还原成原生的JavaScript对象
var price = parseFloat($(priceSpans[i]).text());
var count = parseInt($(countInputs[i]).val());
totalCount += count;
totalPrice += price * count;
}
$(".zoji span").html(totalPrice.toFixed(2));
}
})
</script>
</body>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>学考无忧-确认订单</title>
<link rel="stylesheet" href="__TMPL__/public/assets/css/reset.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/base.css">
<style>
.order_address {
padding-bottom: 0.26rem;
background-repeat: no-repeat;
background-image: url("__TMPL__/public/assets/images/32.png");
background-position: bottom;
background-size: 100% 0.06rem;
background-color: white;
}
.yw_wayActive {
border: 0;
background-size: 100% 100%;
background-image: url('__TMPL__/public/assets/images/71.png');
}
.order_addressYes {
padding-top: 1.5rem;
margin-top: 0;
}
</style>
</head>
<body>
<div class="order_box">
<!-- 顶部 -->
<div class="order_top">
<a href="{:url('shopcart/shop_cart')}">
<img src="__TMPL__/public/assets/images/left.png" alt="">
</a>
<p>订单确认</p>
</div>
<!-- 地址 -->
<div class="order_address">
<!-- 暂无 -->
<if condition="$address eq 4">
<div class="order_addressNo">
<div class="order_adImg">
<img src="__TMPL__/public/assets/images/31.png" alt="">
</div>
<p class="order_addressGo">暂无默认收货地址,<a href="{:url('Orderpage/go_add_address',array('indet_id'=>$indet_id))}">去添加</a></p>
</div>
<else/>
<div class="order_addressYes">
<div class="or_addressYesImg1">
<img src="__TMPL__/public/assets/images/38.png" alt="">
</div>
<div class="or_addressYesTxt1">
<div class="or_addressYesTxt2">
<div class="or_addressName" id="name">{$address.name}</div>
<p class="or_addressPhone" id="phone">{$address.phone}</p>
</div>
<p class="or_address_detailed" id="detailed">{$address.region}{$address.detailed}</p>
</div>
<div class="or_addressYesImg2">
<a href="{:url('Orderpage/go_add_address',array('indet_id'=>$indet_id))}">
<img src="__TMPL__/public/assets/images/29.png" alt="">
</a>
</div>
</div>
</if>
</div>
<!-- 订单信息 -->
<div class="order_news">
<!-- 配送方式 -->
<div class="yw_way">
<h3>配送方式</h3>
<div class="yw_way2">
<div class="yw_way2Li " onclick="go_unified()">统一配送</div>
<div class="yw_way2Li yw_wayActive">快递配送({$courier}元)</div>
</div>
</div>
<h1 class="order_newsTit">订单信息</h1>
<ul class="order_newsUl">
<volist name="data" id="vo">
<li>
<div class="order_newsImg">
<img src="{:cmf_get_image_url($vo.thumbnail)}" alt="">
</div>
<div class="order_newsCon">
<div class="order_newsTxt1 txt-cut">{$vo.book_name}</div>
<div class="order_newsTxt2">×<span>{$vo.number}</span></div>
<div class="order_newsTxt3">
<p class="de_topTxt1_1"><span>{$vo.price}</span></p>
<p class="de_topTxt1_2"><span>{$vo.pricing}</span></p>
<div class="order_newsNum">
<div class="order_newsJian" onclick="jian({$vo.id},{$vo.price})">-</div>
<input class="order_newsnum" type="text" readonly="readonly" value="{$vo.number}">
<div class="order_newsJia" onclick="jia({$vo.id},{$vo.price})">+</div>
</div>
</div>
</div>
</li>
</volist>
</ul>
</div>
<!-- 支付方式/配送方式 -->
<div class="order_Etc">
<div class="order_Etc1">
<p class="order_EtcTxt">支付方式</p>
<img class="order_EtcImg" src="__TMPL__/public/assets/images/34.png" alt="">
</div>
<div class="order_Etc1">
<p class="order_EtcTxt">配送方式</p>
<span class="order_EtcTxt2">快递</span>
</div>
<div class="order_Etc2">
<p class="order_EtcTxt">买家留言</p>
<textarea placeholder="在此填写您的留言" id="liuyan"></textarea>
</div>
</div>
<!-- 底部 -->
<div class="order_bottom">
<div class="order_bottom1">
<p class="order_bottomHe">合计金额:</p>
<p class="de_topTxt1_1 zoji"><span id="money">{$money}</span></p>
</div>
<div class="order_bottom2" onclick="go_pay()">立即支付</div>
</div>
</div>
<script src="__TMPL__/public/assets/js/base.js"></script>
<script src="__TMPL__/public/assets/js/jquery.js"></script>
<script>
/**
* 点击统一配送
*/
function go_unified(){
window.location.href = "{:url('Orderpage/order_salesman_ty')}?indet_id="+{$indet_id};
}
/**
*点击去支付
*/
function go_pay(){
indnet_id = "{$indet_id}";
$.post("{:url('Order/is_my_salesman')}",{indent_id:indnet_id},function(data){
if(data){
name = $('#name').text();
phone = $('#phone').text();
detailed = $('#detailed').text();
if(name == ''){
alert('收货地址不能为空');
}else if(phone == ''){
alert('收货地址不能为空');
}else if(detailed == ''){
alert('收货地址不能为空');
}else{
liuyan = $('#liuyan').val();
indet_id = {$indet_id};
money = $('#money').text();
$.post("{:url('Orderpage/salesman_go_pay')}",{leave_word:liuyan,id:indet_id,money:money},function(data){
if(data){
window.location.href = "{:url('Pay/index',array('id'=>$indet_id))}";
}else{
alert('更新订单失败');
}
});
}
}else{
alert('不再此区域销售');
}
});
}
/**
*点击加一
*/
function jia(id,price){
$.post("{:url('Orderpage/shop_cart_numadd')}",{id:id,price:price},function(data){
});
}
/**
* 点击减一
*/
function jian(id,price){
$.post("{:url('Orderpage/shop_cart_numdec')}",{id:id,price:price},function(data){
});
}
</script>
<script>
$(document).ready(function() {
// 配送方式
$('.yw_way2 div').click(function() {
$(this).addClass('yw_wayActive').siblings().removeClass('yw_wayActive');
})
$(".order_newsNum div").on("click", function(evt) {
if ($(this).text() == "-") {
var count = parseInt($(this).next().val());
if (count > 1) {
count -= 1;
$(this).next().val(count);
} else {
alert("商品数量最少为1");
}
$(this).parents(".order_newsCon").find(".order_newsTxt2 span").text(count);
} else {
var count = parseInt($(this).prev().val());
if (count < 200) {
count += 1;
$(this).prev().val(count);
} else {
alert("商品数量最多为200");
}
$(this).parents(".order_newsCon").find(".order_newsTxt2 span").text(count);
}
var price = parseFloat($(this).parents(".order_newsTxt3").children(".de_topTxt1_1").text().split("¥")[1]);
calcTotal2();
});
// 计算总计
function calcTotal2() {
var checkBoxes = $(".sh_cartround img");
var priceSpans = $(".order_newsTxt3 .de_topTxt1_1 span");
var countInputs = $(".order_newsNum .order_newsnum");
var totalCount = 0;
var totalPrice = {$courier};
for (var i = 0; i < priceSpans.length; i += 1) {
// 强调: jQuery对象使用下标运算或get方法会还原成原生的JavaScript对象
var price = parseFloat($(priceSpans[i]).text());
var count = parseInt($(countInputs[i]).val());
totalCount += count;
totalPrice += price * count;
}
$(".zoji span").html(totalPrice.toFixed(2));
}
})
</script>
</body>
</html>
\ No newline at end of file
... ...
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>学考无忧-我的-管理页面</title>
<link rel="stylesheet" href="__TMPL__/public/assets/css/reset.css" />
<link rel="stylesheet" href="__TMPL__/public/assets/css/log.css" />
</head>
<body>
<div class="log_top">
<!-- 顶部 -->
<div class=" order_top log_top">
<p style="color:white">订单确认</p>
</div>
<!-- 头像 -->
<div class="log_top_buddha">
<div class="log_top_buddha_img">
<img src="{$weixin.avatar}" alt="" style="border-radius: 50%;" />
</div>
<div class="log_top_buddha_contant">
<div class="log_top_buddha_contant_one">
{$weixin.user_nickname}
</div>
</div>
</div>
</div>
<!-- 列表1 -->
<div class="log_one_list">
<a href="{:url('Salesmangoods/salesman_goods')}">
<div class="log_one_list_one">
<div class="log_one_list_left">
<div class="log_one_list_img">
<img src="__TMPL__/public/assets/images/shangpin.png" alt="" />
</div>
<div class="log_one_list_word">
商品管理
</div>
</div>
<div class="log_one_list_right">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
</div>
</div>
</a>
<a href="{:url('OrderSalesman/get_all')}">
<div class="log_one_list_one">
<div class="log_one_list_left">
<div class="log_one_list_img">
<img src="__TMPL__/public/assets/images/dingdan.png" alt="" />
</div>
<div class="log_one_list_word">
订单管理
</div>
</div>
<div class="log_one_list_right">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
</div>
</div>
</a>
<a href="{:url('School/school')}">
<div class="log_one_list_one">
<div class="log_one_list_left">
<div class="log_one_list_img">
<img src="__TMPL__/public/assets/images/school.png" alt="" />
</div>
<div class="log_one_list_word">
学校管理
</div>
</div>
<div class="log_one_list_right">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
</div>
</div>
</a>
<a href="{:url('Personalcenter/my_wallet')}">
<div class="log_one_list_one">
<div class="log_one_list_left">
<div class="log_one_list_img">
<img src="__TMPL__/public/assets/images/49.png" alt="" />
</div>
<div class="log_one_list_word">
我的钱包
</div>
</div>
<div class="log_one_list_right">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
</div>
</div>
</a>
<a href="{:url('share/index')}">
<div class="log_one_list_one">
<div class="log_one_list_left">
<div class="log_one_list_img">
<img src="__TMPL__/public/assets/images/47.png" alt="" />
</div>
<div class="log_one_list_word">
商城分享
</div>
</div>
<div class="log_one_list_right">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
</div>
</div>
</a>
</div>
<!-- 底部一级导航 -->
<div class="in_bottom">
<ul>
<a href="{:url('Index/index')}">
<li>
<img src="__TMPL__/public/assets/images/22.png" alt="" />
<p>首页</p>
</li>
</a>
<a href="{:url('Classify/classify')}">
<li>
<img src="__TMPL__/public/assets/images/16.png" alt="" />
<p>分类</p>
</li>
</a>
<a href="{:url('Shopcart/shop_cart')}">
<li>
<img src="__TMPL__/public/assets/images/17.png" alt="" />
<p>购物车</p>
</li>
</a>
<li>
<img src="__TMPL__/public/assets/images/19.png" alt="" />
<p style="color:#FF7700;">我的</p>
</li>
</ul>
</div>
<script src="__TMPL__/public/assets/js/jquery.js"></script>
<script src="__TMPL__/public/assets/js/base.js"></script>
<script>
$(".log_top_buddha_btn").click(function() {
$(this).css({
display: "none"
});
$(".log_top_buddha_contant").toggle();
});
</script>
</body>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>学考无忧-我的-管理页面</title>
<link rel="stylesheet" href="__TMPL__/public/assets/css/reset.css" />
<link rel="stylesheet" href="__TMPL__/public/assets/css/log.css" />
</head>
<body>
<div class="log_top">
<!-- 顶部 -->
<div class=" order_top log_top">
<p style="color:white">订单确认</p>
</div>
<!-- 头像 -->
<div class="log_top_buddha">
<div class="log_top_buddha_img">
<img src="{$weixin.avatar}" alt="" style="border-radius: 50%;" />
</div>
<div class="log_top_buddha_contant">
<div class="log_top_buddha_contant_one">
{$weixin.user_nickname}
</div>
</div>
</div>
</div>
<!-- 列表1 -->
<div class="log_one_list">
<a href="{:url('Salesmangoods/salesman_goods')}">
<div class="log_one_list_one">
<div class="log_one_list_left">
<div class="log_one_list_img">
<img src="__TMPL__/public/assets/images/shangpin.png" alt="" />
</div>
<div class="log_one_list_word">
商品管理
</div>
</div>
<div class="log_one_list_right">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
</div>
</div>
</a>
<a href="{:url('Personalcenter/salesman_postage')}">
<div class="log_one_list_one">
<div class="log_one_list_left">
<div class="log_one_list_img">
<img src="__TMPL__/public/assets/images/postage.png" alt="" />
</div>
<div class="log_one_list_word">
邮费设置
</div>
</div>
<div class="log_one_list_right">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
</div>
</div>
</a>
<a href="{:url('OrderSalesman/get_all')}">
<div class="log_one_list_one">
<div class="log_one_list_left">
<div class="log_one_list_img">
<img src="__TMPL__/public/assets/images/dingdan.png" alt="" />
</div>
<div class="log_one_list_word">
订单管理
</div>
</div>
<div class="log_one_list_right">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
</div>
</div>
</a>
<a href="{:url('School/school')}">
<div class="log_one_list_one">
<div class="log_one_list_left">
<div class="log_one_list_img">
<img src="__TMPL__/public/assets/images/school.png" alt="" />
</div>
<div class="log_one_list_word">
学校管理
</div>
</div>
<div class="log_one_list_right">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
</div>
</div>
</a>
<a href="{:url('Personalcenter/my_wallet')}">
<div class="log_one_list_one">
<div class="log_one_list_left">
<div class="log_one_list_img">
<img src="__TMPL__/public/assets/images/49.png" alt="" />
</div>
<div class="log_one_list_word">
我的钱包
</div>
</div>
<div class="log_one_list_right">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
</div>
</div>
</a>
<a href="{:url('share/index')}">
<div class="log_one_list_one">
<div class="log_one_list_left">
<div class="log_one_list_img">
<img src="__TMPL__/public/assets/images/47.png" alt="" />
</div>
<div class="log_one_list_word">
商城分享
</div>
</div>
<div class="log_one_list_right">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
</div>
</div>
</a>
</div>
<!-- 底部一级导航 -->
<div class="in_bottom">
<ul>
<a href="{:url('Index/index')}">
<li>
<img src="__TMPL__/public/assets/images/22.png" alt="" />
<p>首页</p>
</li>
</a>
<a href="{:url('Classify/classify')}">
<li>
<img src="__TMPL__/public/assets/images/16.png" alt="" />
<p>分类</p>
</li>
</a>
<a href="{:url('Shopcart/shop_cart')}">
<li>
<img src="__TMPL__/public/assets/images/17.png" alt="" />
<p>购物车</p>
</li>
</a>
<li>
<img src="__TMPL__/public/assets/images/19.png" alt="" />
<p style="color:#FF7700;">我的</p>
</li>
</ul>
</div>
<script src="__TMPL__/public/assets/js/jquery.js"></script>
<script src="__TMPL__/public/assets/js/base.js"></script>
<script>
$(".log_top_buddha_btn").click(function() {
$(this).css({
display: "none"
});
$(".log_top_buddha_contant").toggle();
});
</script>
</body>
</html>
\ No newline at end of file
... ...
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>学考无忧-邮费设置</title>
<link rel="stylesheet" href="__TMPL__/public/assets/css/mui.min.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/mui.picker.min.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/reset.css" />
<link rel="stylesheet" href="__TMPL__/public/assets/css/log.css" />
<style>
.mui-poppicker-header,
.mui-picker {
background-color: white;
}
.mui-btn-blue,
.mui-btn-primary,
input[type=submit] {
background-color: #FF7700;
border: 0;
}
.mui-pciker-list li.highlight {
color: #FF7700;
}
.mui-toast-container {
bottom: 50%;
}
</style>
</head>
<body>
<div class="log_top_co">
<!-- 顶部 -->
<div class=" order_top log_top_co">
<a href="{:url('personalcenter/personal_center')}">
<img src="__TMPL__/public/assets/images/left.png" alt="" />
</a>
<p>邮费设置</p>
</div>
</div>
<div class="school_ooo">
<!-- 地址信息 -->
<div class="log_four_input">
<div class="log_four_input_one">
<div class="log_four_input_one_left">
邮费
</div>
<div class="log_four_input_one_center">
<input type="number" placeholder="请录入邮费" id="money" value="{$money}"/>
</div>
<div class="log_four_input_one_right">
<img src="__TMPL__/public/assets/images/29.png" alt="" />
</div>
</div>
</div>
</div>
<!-- 按钮 -->
<div class="log_seven_btn">
<div class="log_seven_btn_contant" onclick="my_postage()">
确定
</div>
</div>
<script src="__TMPL__/public/assets/js/jquery.js"></script>
<script src="__TMPL__/public/assets/js/base.js"></script>
<script src="__TMPL__/public/assets/js/mui.min.js"></script>
<script src="__TMPL__/public/assets/js/mui.picker.min.js"></script>
<script>
var money;
/**
*点击确定提交
*/
function my_postage(){
money = $('#money').val();
if(money == ''){
alert('请输入邮费');
}else{
$.post("{:url('personalcenter/salesman_postage')}",{money:money},function(data){
mui.toast(data.msg);
if(data){
setTimeout(function () {
window.location.href="{:url('personalcenter/personal_center')}";
},1000);
}
});
}
}
</script>
</body>
</html>
\ No newline at end of file
... ...