|
|
@ -625,52 +625,58 @@ class Coach extends BaseModel |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getCoachLevel($caoch_id, $uniacid) |
|
|
|
public function getCoachLevel($caoch_id, $uniacid) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
$coach_model = new Coach(); |
|
|
|
|
|
|
|
|
|
|
|
$config_model = new Config(); |
|
|
|
$config_model = new Config(); |
|
|
|
|
|
|
|
|
|
|
|
$level_model = new CoachLevel(); |
|
|
|
$level_model = new CoachLevel(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$config = $config_model->dataInfo(['uniacid'=>$uniacid]); |
|
|
|
$coach = $coach_model->dataInfo(['id'=>$caoch_id]); |
|
|
|
|
|
|
|
if($coach['level']){ |
|
|
|
$level_cycle = $config['level_cycle']; |
|
|
|
$coach_level = $level_model->dataInfo(['id'=>$coach['level']]); |
|
|
|
|
|
|
|
}else{ |
|
|
|
$is_current = $config['is_current']; |
|
|
|
$config = $config_model->dataInfo(['uniacid'=>$uniacid]); |
|
|
|
//时长(分钟) |
|
|
|
|
|
|
|
$time_long = $level_model->getMinTimeLong($caoch_id,$level_cycle,$is_current); |
|
|
|
$level_cycle = $config['level_cycle']; |
|
|
|
//最低业绩 |
|
|
|
|
|
|
|
$price = $level_model->getMinPrice($caoch_id,$level_cycle,0,$is_current); |
|
|
|
$is_current = $config['is_current']; |
|
|
|
//加钟订单 |
|
|
|
//时长(分钟) |
|
|
|
$add_price = $level_model->getMinPrice($caoch_id,$level_cycle,1,$is_current); |
|
|
|
$time_long = $level_model->getMinTimeLong($caoch_id,$level_cycle,$is_current); |
|
|
|
//积分 |
|
|
|
//最低业绩 |
|
|
|
$integral = $level_model->getMinIntegral($caoch_id,$level_cycle,$is_current); |
|
|
|
$price = $level_model->getMinPrice($caoch_id,$level_cycle,0,$is_current); |
|
|
|
//在线时长 |
|
|
|
//加钟订单 |
|
|
|
$online_time = $level_model->getCoachOnline($caoch_id,$level_cycle,$is_current); |
|
|
|
$add_price = $level_model->getMinPrice($caoch_id,$level_cycle,1,$is_current); |
|
|
|
|
|
|
|
//积分 |
|
|
|
$level = $level_model->where(['uniacid' => $uniacid, 'status' => 1])->order('time_long,id desc')->select()->toArray(); |
|
|
|
$integral = $level_model->getMinIntegral($caoch_id,$level_cycle,$is_current); |
|
|
|
|
|
|
|
//在线时长 |
|
|
|
$coach_level = []; |
|
|
|
$online_time = $level_model->getCoachOnline($caoch_id,$level_cycle,$is_current); |
|
|
|
|
|
|
|
|
|
|
|
$add_balance = $price>0?$add_price/$price*100:0; |
|
|
|
$level = $level_model->where(['uniacid' => $uniacid, 'status' => 1])->order('time_long,id desc')->select()->toArray(); |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($level)) { |
|
|
|
$coach_level = []; |
|
|
|
|
|
|
|
|
|
|
|
foreach ($level as $key=>$value) { |
|
|
|
$add_balance = $price>0?$add_price/$price*100:0; |
|
|
|
//时长 |
|
|
|
|
|
|
|
$level_time_long = $key>0? $level[$key-1]['time_long']:0; |
|
|
|
if (!empty($level)) { |
|
|
|
|
|
|
|
|
|
|
|
if($time_long>=$level_time_long&&$price>=$value['price']&&$add_balance>=$value['add_balance']&&$integral>=$value['integral']&&$online_time>=$value['online_time']){ |
|
|
|
foreach ($level as $key=>$value) { |
|
|
|
|
|
|
|
//时长 |
|
|
|
$coach_level = $value; |
|
|
|
$level_time_long = $key>0? $level[$key-1]['time_long']:0; |
|
|
|
|
|
|
|
|
|
|
|
}elseif (empty($coach_level)) { |
|
|
|
if($time_long>=$level_time_long&&$price>=$value['price']&&$add_balance>=$value['add_balance']&&$integral>=$value['integral']&&$online_time>=$value['online_time']){ |
|
|
|
//都不符合给一个最低都等级 |
|
|
|
|
|
|
|
$coach_level = $value; |
|
|
|
$coach_level = $value; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}elseif (empty($coach_level)) { |
|
|
|
|
|
|
|
//都不符合给一个最低都等级 |
|
|
|
|
|
|
|
$coach_level = $value; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return !empty($coach_level)?$coach_level : []; |
|
|
|
return !empty($coach_level)?$coach_level : []; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|