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