| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace App\Models;
- /**
- *
- */
- class AgentGrade extends BaseModel {
- protected $table = 'agent_grade';
- public $timestamps = false;
- //获取等级列表信息
- function getList($where='',$list=10){
- $data=$this;
- if(!empty($where)&&count($where)){
- $data->where($where);
- }
- $data=$data->orderBy('sort','desc')->paginate($list);
- if(!$data){
- return -8040411022;//没有数据
- }
- return $data->toArray();
- }
- //获取代理金额设置
- function getRatio(){
- $data=$this->get();
- if(!$data){
- return -8005144322;
- }
- return $data->toArray();
- }
- //更新比例
- function updateRatio($data,$id){
- $res=$this->where('id',$id)->update($data);
- if(!$res){
- return -8005344322;
- }
- return 1;
- }
- //获取全部等级列表
- function getAllGrade($where=''){
- $data=$this;
- if(!empty($where)&&count($where)){
- $data->where($where);
- }
- $data=$data->orderBy('grade_code','asc')->get();
- if(!$data){
- return -8040411022;//没有数据
- }
- return $data->toArray();
- }
- //获取代理默认提成比例
- function getGradeRatio($grade_code,$type){
- $ratio=$this->select('water_ratio','profit_ratio')->where('grade_code',$grade_code)->first();
- if(!$ratio){
- return -8060010022;//没有默认提成比例
- }
- $ratio=$ratio->toArray();
- //没有修改内容
- // return $ratio['water_ratio'];
- if($type==1){
- return $ratio['profit_ratio'];
- }else{
- return $ratio['water_ratio'];
- }
- }
- //代理名称获取
- function getGradeInfo($value,$num){
- $fild=$this->getFild($num);
- $data=$this->where($fild,$value)->first();
- if(!$data){
- return -8040411022;//没有数据
- }
- return $data->toArray();
- }
- //获取字段
- function getFild($num){
- $fild=array(
- '1'=>'id',
- '2'=>'grade_name',
- '3'=>'grade_code',
- );
- return $fild[$num];
- }
- }
|