public function order_pay(){
$order_id=I('get.order_id');
$user_id=session("user.user_id");
$pay_count=M('user')->where(array('user_id'=>$user_id))->getField('pay_count');//我的钱包
$order=M('order')->where(array('order_id'=>$order_id))->find();
$pay_time=time();
//dump($user_id);exit;
if($pay_count < $order['money'] ){
$this->error("你的钱包余额不足");
}else{
$aaa=M('order')->where(array('order_id'=>$order_id))->save(array('is_pay'=>1,'pay_time'=>$pay_time));
$bbb=M('user')->where(array('user_id'=>$user_id))->setDec('pay_count',$order['money']);
$ccc=M('user')->where(array('user_id'=>$user_id))->setInc('total_amount',$order['money']);//加个人累计业绩
$this->level_tuandui();
if($aaa&&$bbb&&$ccc){
$this->fen_yong($order['money'],$user_id,$order_id);
$this->success("支付成功",U('order/order_list'));
}
}
}
public function level_tuandui(){
//统计自己三个区下面的业绩
$lv1=M('parameter3')->where(array('id'=>1))->getField('yeji_zhi');
$lv2=M('parameter3')->where(array('id'=>2))->getField('yeji_zhi');
$lv3=M('parameter3')->where(array('id'=>3))->getField('yeji_zhi');
$lv4=M('parameter3')->where(array('id'=>4))->getField('yeji_zhi');
$lv5=M('parameter3')->where(array('id'=>5))->getField('yeji_zhi');
$data = M('user')->select();
foreach ($data as $key => $va) {
$user_id = $va['user_id'];
$where1['job'] = array('like',"%_$user_id_%");
$qu1=M('user')->where(array('section'=>1))->where($where1)->where($where)->sum('total_amount');
$qu2=M('user')->where(array('section'=>2))->where($where1)->where($where)->sum('total_amount');
$qu3=M('user')->where(array('section'=>3))->where($where1)->where($where)->sum('total_amount');
$qu_zong=$qu1 + $qu2 + $qu3;
//等级1
if($qu_zong >= $lv1 && $qu_zong < $lv2){
M('user')->where(array('user_id'=>$user_id))->save(array('grade'=>1));
}else
//等级2
if($qu_zong >= $lv2 && $qu_zong < $lv3 ){
M('user')->where(array('user_id'=>$user_id))->save(array('grade'=>2));
}
else
//等级3
if($qu_zong >= $lv3 && $qu_zong < $lv4){
M('user')->where(array('user_id'=>$user_id))->save(array('grade'=>3));
}
else
//等级4
if($qu_zong >= $lv4 && $qu_zong < $lv5){
M('user')->where(array('user_id'=>$user_id))->save(array('grade'=>4));
}
else
//等级5
if($qu_zong >= $lv5){
M('user')->where(array('user_id'=>$user_id))->save(array('grade'=>5));
}
}
}
点击查看更多内容
1人点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦