php关于五级分销的操作

外包公司,老板让写什么就写什么,接到一个外包项目,写一个五级分销
返佣是前四级都有返佣,返佣比例后台自己设置,用户到五级以后,如他相当于是七级,他上面四级才有返佣提成,一个是购买商品的提成,一个是下一级消费的提成,消费达到一定金额后,后台审核升一级,这样操作,还有就是你是七级,你四级上面的那个人没有返佣。代码很糙没有进行优化和封装
//返佣计算

      public  function money_fen($order_merchants_id='',$order_actual_price=''){
        $mer_data = Db::name('order_merchants')->where(['is_delete'=>'0','order_merchants_id'=>$order_merchants_id])->find();
        $order_goods_id = Db::name('order_goods')->where(['is_delete'=>'0','order_merchants_id'=>$order_merchants_id,'merchants_id'=>$mer_data['merchants_id']])->value('order_goods_id');
        $data['merchants_id'] = $mer_data['merchants_id'];
        $data['order_merchants_id']= $order_merchants_id;
        $data['order_goods_id'] = $order_goods_id;
        $member_id =  $mer_data['member_id'];
        $order_actual_price = $order_actual_price;
        $res = Db::name('comm_level')->where(['is_del'=>'0','user_id'=>$member_id])->find();
        $arr = unserialize($res['level_array']);
        if(!$arr){
            $data['settlement_price'] = $order_actual_price;

            $data['platform_ratio'] = '';
            $data['platform_amount'] = '';
            $res = Db::name('comm_level')->where(['is_del'=>'0','type'=>'2','user_id'=>$member_id])->find();
            if($res){
                $data['member_id'] = $member_id;
                $data['member_amount'] = ($res['my_commission']/100) * $order_actual_price;
                $data['member_ratio'] = $res['my_commission'];
            }else{
                $data['member_id'] = $member_id;
                $data['member_amount'] = '';
                $data['member_ratio'] ='';
            }

            $amount = Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$member_id])->value('amount');
            $amount +=($res['my_commission']/100) * $order_actual_price;
            $date['amount'] = $amount;
            Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$member_id])->update($date);

            $data['merchants_price'] = $order_actual_price - $data['member_amount'];
            $data['merchants_ratio'] = $data['merchants_price']/$order_actual_price;

            $data['amember_id'] = '';
            $data['aspread_ratio'] ='';
            $data['aspread_amount'] ='';

            $data['bmember_id'] = '';
            $data['bspread_tv_ratio'] ='';
            $data['bspread_tv_amount'] ='';

            $data['cmember_id'] = '';
            $data['cseller_ratio'] ='';
            $data['cseller_amount'] ='';

            $data['dmember_id'] = '';
            $data['dlevel_one_ratio'] ='';
            $data['dlevel_one_amount'] ='';

            $data['emember_id'] = '';
            $data['elevel_two_ratio'] ='';
            $data['elevel_two_amount'] ='';
            $data['date'] = '';
            $data['create_time'] = time();
            Db::name('order_goods_settlement')->insert($data);
        }else{
            $re = Db::name('commission')->where(['is_del'=>'0','level_id'=>$res['level_id']])->find();
            $username =Db::name('member')->where(['is_del'=>'1','member_id'=>$member_id])->value('username');
            $re1 =Db::name('commission')->field('commission')->where(['is_del'=>'0'])->select();
            $result = Db::name('order')->where(['member_id'=>$member_id,'is_delete'=>'0'])->sum('order_actual_price');
    //            $arr = unserialize($res['level_array']);
            $map['is_del'] = '0';
            $map['type'] = '2';
            $map['user_id'] = ['in',$arr];
            $list = Db::name('comm_level')
                ->field('user_id')
                ->where($map)
                ->select();
            $count =count($list);
            switch ($count){
                case 1:
                    $data['settlement_price'] = $order_actual_price;

                    $data['platform_ratio'] = '';
                    $data['platform_amount'] = '';
                    $res = Db::name('comm_level')->where(['is_del'=>'0','type'=>'2','user_id'=>$member_id])->find();
                    if($res){
                        $data['member_id'] = $member_id;
                        $data['member_amount'] = ($res['my_commission']/100) * $order_actual_price;
                        $data['member_ratio'] = $res['my_commission'];
                    }else{
                        $data['member_id'] = $member_id;
                        $data['member_amount'] = '';
                        $data['member_ratio'] ='';
                    }
//                    $data['member_id'] = $member_id;
//                    $data['member_amount'] = ($res['my_commission']/100) * $order_actual_price;
//                    $data['member_ratio'] = $res['my_commission'];
                    $amount = Db::name('member')->where(['is_del'=>'1','member_id'=>$member_id])->value('amount');
                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $date['amount'] = $amount;
                    Db::name('member')->where(['is_del'=>'1','member_id'=>$member_id])->update($date);


                    $data['amember_id'] = $list[0]['user_id'];
                    $data['aspread_ratio'] =$re1[3]['commission'];
                    $data['aspread_amount'] =($re1[3]['commission']/100) * $order_actual_price;
                    $amount = Db::name('member')->where(['is_del'=>'1','member_id'=>$list[0]['user_id']])->value('amount');
//                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $data1['amount'] = $amount + $data['aspread_amount'];
                    Db::name('member')->where(['is_del'=>'1','member_id'=>$list[0]['user_id']])->update($data1);
                    $data['bmember_id'] = '';
                    $data['bspread_tv_ratio'] ='';
                    $data['bspread_tv_amount'] ='';

                    $data['cmember_id'] = '';
                    $data['cseller_ratio'] ='';
                    $data['cseller_amount'] ='';

                    $data['dmember_id'] = '';
                    $data['dlevel_one_ratio'] ='';
                    $data['dlevel_one_amount'] ='';

                    $data['emember_id'] = '';
                    $data['elevel_two_ratio'] ='';
                    $data['elevel_two_amount'] ='';
                    $data['date'] = '';
                    $data['create_time'] = time();

                    $data['merchants_price'] = $order_actual_price - ($data['member_amount'] + $data['aspread_amount']);
                    $data['merchants_ratio'] = $data['merchants_price']/$order_actual_price;

                    Db::name('order_goods_settlement')->insert($data);
                    if($re['quota'] < $result){
                        $mobile_content = Db::name('system')->where(['id'=>'1'])->value('mobile_content');
                        $content = "用户名我【".$username."】".$mobile_content."【测试】";
                        $fx_mobile = Db::name('system')->where(['id'=>'1'])->value('$fx_mobile');
                        $mobile = $fx_mobile;
                        $gateway = $this->zhutong_sendSMS($content,$mobile);
                        $arr = explode(',',$gateway);
                        switch ($arr['0']){
                            case 1:
                                $date['mobile'] = $mobile;
                                $date['name'] = $username;
                                $date['state'] = 1;
                                $date['date'] = date('Y-m-d',time());
                                $date['intime'] = time();
                                Db::name("mobile_name")->insert($date);
                                //success('审核提醒发送成功');
                                break;
                            case 12:
                                error('提交号码错误!');
                                break;
                            case 13:
                                error('短信内容为空!');
                                break;
                            case 17:
                                error('一分钟内一个手机号只能发两次!');
                                break;
                            case 19:
                                error('号码为黑号!');
                                break;
                            case 26:
                                error('一小时内只能发五条!');
                                break;
                            case 27:
                                error('一天一手机号只能发20条');
                                break;
                            default:
                                error('发送失败!');
                        }
                    }

                    break;
                case 2:
                    $data['settlement_price'] = $order_actual_price;

                    $data['platform_ratio'] = '';
                    $data['platform_amount'] = '';

                    $res = Db::name('comm_level')->where(['is_del'=>'0','type'=>'2','user_id'=>$member_id])->find();
                    if($res){
                        $data['member_id'] = $member_id;
                        $data['member_amount'] = ($res['my_commission']/100) * $order_actual_price;
                        $data['member_ratio'] = $res['my_commission'];
                    }else{
                        $data['member_id'] = $member_id;
                        $data['member_amount'] = '';
                        $data['member_ratio'] ='';
                    }
//                    $data['member_id'] = $member_id;
//                    $data['member_amount'] = ($res['my_commission']/100) * $order_actual_price;
//                    $data['member_ratio'] = $res['my_commission'];
                    $amount = Db::name('member')->where(['is_del'=>'1','member_id'=>$member_id])->value('amount');
                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $date['amount'] = $amount + $data['aspread_amount'];
                    Db::name('member')->where(['is_del'=>'1','member_id'=>$member_id])->update($date);

                    $data['amember_id'] = $list[0]['user_id'];
                    $data['aspread_ratio'] =$re1[2]['commission'];
                    $data['aspread_amount'] =($re1[2]['commission']/100) * $order_actual_price;
                    $amount = Db::name('member')->where(['is_del'=>'1','member_id'=>$list[0]['user_id']])->value('amount');
//                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $data1['amount'] = $amount + $data['aspread_amount'];
                    Db::name('member')->where(['is_del'=>'1','member_id'=>$list[0]['user_id']])->update($data1);

                    $data['bmember_id'] = $list[1]['user_id'];
                    $data['bspread_tv_ratio'] =$re1[3]['commission'];
                    $data['bspread_tv_amount'] =($re1[3]['commission']/100) * $order_actual_price;
                    $amount = Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[1]['user_id']])->value('amount');
//                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $data2['amount'] = $amount + $data['bspread_tv_amount'];
                    Db::name('member')->where(['is_del'=>'1','member_id'=>$list[1]['user_id']])->update($data2);

                    $data['cmember_id'] = '';
                    $data['cseller_ratio'] ='';
                    $data['cseller_amount'] ='';

                    $data['dmember_id'] = '';
                    $data['dlevel_one_ratio'] ='';
                    $data['dlevel_one_amount'] ='';

                    $data['emember_id'] = '';
                    $data['elevel_two_ratio'] ='';
                    $data['elevel_two_amount'] ='';
                    $data['date'] = '';
                    $data['create_time'] = time();

                    $data['merchants_price'] = $order_actual_price - ($data['member_amount'] + $data['aspread_amount'] + $data['bspread_tv_amount']);
                    $data['merchants_ratio'] = $data['merchants_price']/$order_actual_price;

                    Db::name('order_goods_settlement')->insert($data);
                    if($re['quota'] < $result){
                        $mobile_content = Db::name('system')->where(['id'=>'1'])->value('mobile_content');
                        $content = "用户名我【".$username."】".$mobile_content."【测试】";
                        $mobile = '1872104417';
                        $gateway = $this->zhutong_sendSMS($content,$mobile);
                        $arr = explode(',',$gateway);
                        switch ($arr['0']){
                            case 1:
                                $date['mobile'] = $mobile;
                                $date['name'] = $username;
                                $date['state'] = 1;
                                $date['date'] = date('Y-m-d',time());
                                $date['intime'] = time();
                                Db::name("mobile_name")->insert($date);
                                //success('审核提醒发送成功');
                                break;
                            case 12:
                                error('提交号码错误!');
                                break;
                            case 13:
                                error('短信内容为空!');
                                break;
                            case 17:
                                error('一分钟内一个手机号只能发两次!');
                                break;
                            case 19:
                                error('号码为黑号!');
                                break;
                            case 26:
                                error('一小时内只能发五条!');
                                break;
                            case 27:
                                error('一天一手机号只能发20条');
                                break;
                            default:
                                error('发送失败!');
                        }
                    }
                    break;
                case 3:
                    $data['settlement_price'] = $order_actual_price;

                    $data['platform_ratio'] = '';
                    $data['platform_amount'] = '';
                    $res = Db::name('comm_level')->where(['is_del'=>'0','type'=>'2','user_id'=>$member_id])->find();
                    if($res){
                        $data['member_id'] = $member_id;
                        $data['member_amount'] = ($res['my_commission']/100) * $order_actual_price;
                        $data['member_ratio'] = $res['my_commission'];
                    }else{
                        $data['member_id'] = $member_id;
                        $data['member_amount'] = '';
                        $data['member_ratio'] ='';
                    }
//                    $data['member_id'] = $member_id;
//                    $data['member_amount'] = ($res['my_commission']/100) * $order_actual_price;
//                    $data['member_ratio'] = $res['my_commission'];
                    $amount = Db::name('member')->where(['is_del'=>'1','member_id'=>$member_id])->value('amount');
                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $date['amount'] = $amount;
                    Db::name('member')->where(['is_del'=>'1','member_id'=>$member_id])->update($date);

                    $data['amember_id'] = $list[0]['user_id'];
                    $data['aspread_ratio'] =$re1[1]['commission'];
                    $data['aspread_amount'] =($re1[1]['commission']/100) * $order_actual_price;
                    $amount = Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[0]['user_id']])->value('amount');
//                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $data1['amount'] = $amount + $data['aspread_amount'];
                    Db::name('member')->where(['is_del'=>'1','member_id'=>$list[0]['user_id']])->update($data1);

                    $data['bmember_id'] = $list[1]['user_id'];
                    $data['bspread_tv_ratio'] =$re1[2]['commission'];
                    $data['bspread_tv_amount'] =($re1[2]['commission']/100) * $order_actual_price;
                    $amount = Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[1]['user_id']])->value('amount');
//                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $data2['amount'] = $amount + $data['bspread_tv_amount'];
                    Db::name('member')->where(['is_del'=>'1','member_id'=>$list[1]['user_id']])->update($data2);

                    $data['cmember_id'] = $list[2]['user_id'];
                    $data['cseller_ratio'] =$re1[3]['commission'];
                    $data['cseller_amount'] =($re1[3]['commission']/100) * $order_actual_price;
                    $amount = Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[2]['user_id']])->value('amount');
//                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $data3['amount'] = $amount + $data['cseller_amount'];
                    Db::name('member')->where(['is_del'=>'1','member_id'=>$list[2]['user_id']])->update($data3);

                    $data['dmember_id'] = '';
                    $data['dlevel_one_ratio'] ='';
                    $data['dlevel_one_amount'] ='';

                    $data['emember_id'] = '';
                    $data['elevel_two_ratio'] ='';
                    $data['elevel_two_amount'] ='';
                    $data['date'] = '';
                    $data['create_time'] = time();

                    $data['merchants_price'] = $order_actual_price - ($data['member_amount'] + $data['aspread_amount'] + $data['bspread_tv_amount'] + $data['cseller_amount']);
                    $data['merchants_ratio'] = $data['merchants_price']/$order_actual_price;

                    Db::name('order_goods_settlement')->insert($data);
                    if($re['quota'] < $result){
                        $mobile_content = Db::name('system')->where(['id'=>'1'])->value('mobile_content');
                        $content = "用户名我【".$username."】".$mobile_content."【测试】";
                        $mobile = '187210441';
                        $gateway = $this->zhutong_sendSMS($content,$mobile);
                        $arr = explode(',',$gateway);
                        switch ($arr['0']){
                            case 1:
                                $date['mobile'] = $mobile;
                                $date['name'] = $username;
                                $date['state'] = 1;
                                $date['date'] = date('Y-m-d',time());
                                $date['intime'] = time();
                                Db::name("mobile_name")->insert($date);
                                //success('审核提醒发送成功');
                                break;
                            case 12:
                                error('提交号码错误!');
                                break;
                            case 13:
                                error('短信内容为空!');
                                break;
                            case 17:
                                error('一分钟内一个手机号只能发两次!');
                                break;
                            case 19:
                                error('号码为黑号!');
                                break;
                            case 26:
                                error('一小时内只能发五条!');
                                break;
                            case 27:
                                error('一天一手机号只能发20条');
                                break;
                            default:
                                error('发送失败!');
                        }
                    }
                    break;
                case 4:
                    $data['settlement_price'] = $order_actual_price;

                    $data['platform_ratio'] = '';
                    $data['platform_amount'] = '';
                    $res = Db::name('comm_level')->where(['is_del'=>'0','type'=>'2','user_id'=>$member_id])->find();
                    if($res){
                        $data['member_id'] = $member_id;
                        $data['member_amount'] = ($res['my_commission']/100) * $order_actual_price;
                        $data['member_ratio'] = $res['my_commission'];
                    }else{
                        $data['member_id'] = $member_id;
                        $data['member_amount'] = '';
                        $data['member_ratio'] ='';
                    }
//                    $data['member_id'] = $member_id;
//                    $data['member_amount'] = ($res['my_commission']/100) * $order_actual_price;
//                    $data['member_ratio'] = $res['my_commission'];
                    $amount = Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$member_id])->value('amount');
                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $date['amount'] = $amount;
                    Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$member_id])->update($date);

                    $data['amember_id'] = $list[0]['user_id'];
                    $data['aspread_ratio'] =$re1[0]['commission'];
                    $data['aspread_amount'] =($re1[0]['commission']/100) * $order_actual_price;
                    $amount = Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[0]['user_id']])->value('amount');
//                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $data1['amount'] = $amount + $data['aspread_amount'];
                    Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[0]['user_id']])->update($data1);

                    $data['bmember_id'] = $list[1]['user_id'];
                    $data['bspread_tv_ratio'] =$re1[1]['commission'];
                    $data['bspread_tv_amount'] =($re1[1]['commission']/100) * $order_actual_price;
                    $amount = Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[1]['user_id']])->value('amount');
//                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $data2['amount'] = $amount + $data['bspread_tv_amount'];
                    Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[1]['user_id']])->update($data2);

                    $data['cmember_id'] = $list[2]['user_id'];
                    $data['cseller_ratio'] =$re1[2]['commission'];
                    $data['cseller_amount'] =($re1[2]['commission']/100) * $order_actual_price;
                    $amount = Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[2]['user_id']])->value('amount');
//                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $data3['amount'] = $amount + $data['cseller_amount'];
                    Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[2]['user_id']])->update($data3);

                    $data['dmember_id'] = $list[3]['user_id'];
                    $data['dlevel_one_ratio'] =$re1[3]['commission'];
                    $data['dlevel_one_amount'] =($re1[3]['commission']/100) * $order_actual_price;
                    $amount = Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[3]['user_id']])->value('amount');
//                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $data4['amount'] = $amount + $data['dlevel_one_amount'];
                    Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[3]['user_id']])->update($data4);

                    $data['emember_id'] = '';
                    $data['elevel_two_ratio'] ='';
                    $data['elevel_two_amount'] ='';
                    $data['date'] = '';
                    $data['create_time'] = time();

                    $data['merchants_price'] = $order_actual_price - ($data['member_amount'] + $data['aspread_amount'] + $data['bspread_tv_amount'] + $data['cseller_amount'] + $data['dlevel_one_amount']);
                    $data['merchants_ratio'] = $data['merchants_price']/$order_actual_price;

                    Db::name('order_goods_settlement')->insert($data);
                    if($re['quota'] < $result){
                        $mobile_content = Db::name('system')->where(['id'=>'1'])->value('mobile_content');
                        $content = "用户名我【".$username."】".$mobile_content."【测试】";
                        $mobile = '1872104417';
                        $gateway = $this->zhutong_sendSMS($content,$mobile);
                        $arr = explode(',',$gateway);
                        switch ($arr['0']){
                            case 1:
                                $date['mobile'] = $mobile;
                                $date['name'] = $username;
                                $date['state'] = 1;
                                $date['date'] = date('Y-m-d',time());
                                $date['intime'] = time();
                                Db::name("mobile_name")->insert($date);
                                //success('审核提醒发送成功');
                                break;
                            case 12:
                                error('提交号码错误!');
                                break;
                            case 13:
                                error('短信内容为空!');
                                break;
                            case 17:
                                error('一分钟内一个手机号只能发两次!');
                                break;
                            case 19:
                                error('号码为黑号!');
                                break;
                            case 26:
                                error('一小时内只能发五条!');
                                break;
                            case 27:
                                error('一天一手机号只能发20条');
                                break;
                            default:
                                error('发送失败!');
                        }
                    }
                    break;
                default:
                    $data['settlement_price'] = $order_actual_price;

                    $data['platform_ratio'] = '';
                    $data['platform_amount'] = '';
                    $res = Db::name('comm_level')->where(['is_del'=>'0','type'=>'2','user_id'=>$member_id])->find();
                    if($res){
                        $data['member_id'] = $member_id;
                        $data['member_amount'] = ($res['my_commission']/100) * $order_actual_price;
                        $data['member_ratio'] = $res['my_commission'];
                    }else{
                        $data['member_id'] = $member_id;
                        $data['member_amount'] = '';
                        $data['member_ratio'] ='';
                    }
//                    $data['member_id'] = $member_id;
//                    $data['member_amount'] = ($res['my_commission']/100) * $order_actual_price;
//                    $data['member_ratio'] = $res['my_commission'];
                    $amount = Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$member_id])->value('amount');
                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $date['amount'] = $amount;
                    Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$member_id])->update($date);

                    $data['amember_id'] = $list[$count-4]['user_id'];
                    $data['aspread_ratio'] =$re1[0]['commission'];
                    $data['aspread_amount'] =($re1[0]['commission']/100) * $order_actual_price;
                    $amount = Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[$count-4]['user_id']])->value('amount');
//                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $data1['amount'] = $amount + $data['aspread_amount'];
                    Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[$count-4]['user_id']])->update($data1);

                    $data['bmember_id'] = $list[$count-3]['user_id'];
                    $data['bspread_tv_ratio'] =$re1[1]['commission'];
                    $data['bspread_tv_amount'] =($re1[1]['commission']/100) * $order_actual_price;
                    $amount = Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[$count-3]['user_id']])->value('amount');
//                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $data2['amount'] = $amount + $data['bspread_tv_amount'];
                    Db::name('member')->where(['is_del'=>'1','member_id'=>$list[$count-3]['user_id']])->update($data2);

                    $data['cmember_id'] = $list[$count-2]['user_id'];
                    $data['cseller_ratio'] =$re1[2]['commission'];
                    $data['cseller_amount'] =($re1[2]['commission']/100) * $order_actual_price;
                    $amount = Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[$count-2]['user_id']])->value('amount');
//                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $data3['amount'] = $amount + $data['cseller_amount'];
                    Db::name('member')->where(['is_del'=>'1','member_id'=>$list[$count-2]['user_id']])->update($data3);

                    $data['dmember_id'] = $list[$count-1]['user_id'];
                    $data['dlevel_one_ratio'] =$re1[3]['commission'];
                    $data['dlevel_one_amount'] =($re1[3]['commission']/100) * $order_actual_price;
                    $amount = Db::name('member')->where(['type'=>'1','is_del'=>'1','member_id'=>$list[$count-1]['user_id']])->value('amount');
//                    $amount +=($res['my_commission']/100) * $order_actual_price;
                    $data4['amount'] = $amount + $data['dlevel_one_amount'];
                    Db::name('member')->where(['is_del'=>'1','member_id'=>$list[$count-1]['user_id']])->update($data4);
                    $data['date'] = '';
                    $data['create_time'] = time();

                    $data['merchants_price'] = $order_actual_price - ($data['member_amount'] + $data['aspread_amount'] + $data['bspread_tv_amount'] + $data['cseller_amount'] + $data['dlevel_one_amount'] +  $data['elevel_two_amount']);
                    $data['merchants_ratio'] = $data['merchants_price']/$order_actual_price;
                    Db::name('order_goods_settlement')->insert($data);
                    if($re['quota'] < $result){
                        $mobile_content = Db::name('system')->where(['id'=>'1'])->value('mobile_content');
                        $content = "用户名我【".$username."】".$mobile_content."【测试】";
                        $mobile = '1872104417';
                        $gateway = $this->zhutong_sendSMS($content,$mobile);
                        $arr = explode(',',$gateway);
                        switch ($arr['0']){
                            case 1:
                                $date['mobile'] = $mobile;
                                $date['name'] = $username;
                                $date['state'] = 1;
                                $date['date'] = date('Y-m-d',time());
                                $date['intime'] = time();
                                Db::name("mobile_name")->insert($date);
                                //success('审核提醒发送成功');
                                break;
                            case 12:
                                error('提交号码错误!');
                                break;
                            case 13:
                                error('短信内容为空!');
                                break;
                            case 17:
                                error('一分钟内一个手机号只能发两次!');
                                break;
                            case 19:
                                error('号码为黑号!');
                                break;
                            case 26:
                                error('一小时内只能发五条!');
                                break;
                            case 27:
                                error('一天一手机号只能发20条');
                                break;
                            default:
                                error('发送失败!');
                        }
                    }
                    break;
            }

        }

    }
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值