|
@@ -127,7 +127,6 @@ class MasterService extends BaseService
|
|
|
|
|
|
|
|
// 是否评分过
|
|
// 是否评分过
|
|
|
$info['is_score'] = 0;
|
|
$info['is_score'] = 0;
|
|
|
- $info['auth_uid'] = $userId;
|
|
|
|
|
$adviceInfo = MasterAdviceModel::where(['master_uid'=> $uid,'user_id'=> $userId,'status'=> 1])
|
|
$adviceInfo = MasterAdviceModel::where(['master_uid'=> $uid,'user_id'=> $userId,'status'=> 1])
|
|
|
->select(['id','score'])
|
|
->select(['id','score'])
|
|
|
->first();
|
|
->first();
|
|
@@ -139,6 +138,53 @@ class MasterService extends BaseService
|
|
|
return $info;
|
|
return $info;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function score($userId){
|
|
|
|
|
+ $params = request()->all();
|
|
|
|
|
+ $masterUid = isset($params['id'])? $params['id'] : 0;
|
|
|
|
|
+ $score = isset($params['score'])? intval($params['score']) : 0;
|
|
|
|
|
+ if($masterUid<=0){
|
|
|
|
|
+ return message('法师参数错误', false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if($score<=0 || $score>5){
|
|
|
|
|
+ return message('评分参数错误,请选择1-5评分', false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $masterInfo = $this->model::where(['user_id'=> $masterUid,'mark'=> 1,'status'=> 1])
|
|
|
|
|
+ ->select(['id','realname','status'])
|
|
|
|
|
+ ->first();
|
|
|
|
|
+ if(!$masterInfo){
|
|
|
|
|
+ return message('法师不存在或不可操作', false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 验证用户
|
|
|
|
|
+ $memberInfo = MemberModel::where(['id'=> $userId, 'mark'=> 1,'status'=> 1])
|
|
|
|
|
+ ->select(['id','openid','nickname'])
|
|
|
|
|
+ ->first();
|
|
|
|
|
+ if(!$memberInfo){
|
|
|
|
|
+ return message('您的账号不可操作或已冻结,请联系客服', false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 验证是否评分过
|
|
|
|
|
+ $adviceInfo = MasterAdviceModel::where(['master_uid'=> $masterUid,'user_id'=> $userId,'status'=> 1])
|
|
|
|
|
+ ->select(['id','user_id','score'])
|
|
|
|
|
+ ->first();
|
|
|
|
|
+ if(!$adviceInfo){
|
|
|
|
|
+ return message('您未咨询过无法评分,请先咨询法师', false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if($adviceInfo->score>0){
|
|
|
|
|
+ return message('您已经打过分,请不要重复操作', false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $adviceInfo->score = $score;
|
|
|
|
|
+ if($adviceInfo->save()){
|
|
|
|
|
+ return message('打分成功', true);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ return message('打分失败,请刷新重试', false);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 申请提交
|
|
* 申请提交
|
|
|
* @param $userId
|
|
* @param $userId
|