diff --git a/application/api/model/UserCp.php b/application/api/model/UserCp.php index ff72baf..4730822 100644 --- a/application/api/model/UserCp.php +++ b/application/api/model/UserCp.php @@ -248,20 +248,23 @@ class UserCp extends Model //添加一个记录 $pendant = db::name('vs_decorate_price')->where('id',$level['pendant_id'])->field('did,day')->find(); - $pendant_title = '装扮-'.$pendant['day'].'天-'.db::name('vs_decorate')->where('did',$pendant['did'])->value('title'); - $datas = [ - 'room_id' => $room_id, - 'from_user_id' => $from_user_id, - 'to_user_id' => $to_user_id, - 'gift_id' => 0, - 'num' => 0, - 'cp_zone_id' => $cp_zone_id, - 'exp' => 0, - 'exp_total' => 0, - 'remark' => '我们等级达到了'.$level['level'].'级,获得奖励'.$pendant_title, - 'createtime' => time(), - ]; - Db::name('user_cp_gift_log')->insert($datas); + if($pendant){ + $pendant_title = '装扮-'.$pendant['day'].'天-'.db::name('vs_decorate')->where('did',$pendant['did'])->value('title'); + $datas = [ + 'room_id' => $room_id, + 'from_user_id' => $from_user_id, + 'to_user_id' => $to_user_id, + 'gift_id' => 0, + 'num' => 0, + 'cp_zone_id' => $cp_zone_id, + 'exp' => 0, + 'exp_total' => 0, + 'remark' => '我们等级达到了'.$level['level'].'级,获得奖励'.$pendant_title, + 'createtime' => time(), + ]; + Db::name('user_cp_gift_log')->insert($datas); + } + } $data['exp'] = $yuan_exp + $exp; Db::name('user_cp_zone')->where(['id' => $cp_zone_id])->update($data);