|
@@ -1,9 +1,22 @@
|
|
|
package com.winhc.repal.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.winhc.common.enums.CodeMsg;
|
|
|
+import com.winhc.common.exception.CommonException;
|
|
|
+import com.winhc.repal.entity.RepalGroupMember;
|
|
|
import com.winhc.repal.entity.RepalVip;
|
|
|
+import com.winhc.repal.enums.Dict;
|
|
|
+import com.winhc.repal.enums.RepalDynamicTypeEnum;
|
|
|
+import com.winhc.repal.enums.RepalVipSignEnum;
|
|
|
+import com.winhc.repal.model.bo.UserContextBO;
|
|
|
+import com.winhc.repal.model.dto.ReplyDTO;
|
|
|
import com.winhc.repal.repository.RepalVipMapper;
|
|
|
+import com.winhc.repal.service.RepalGroupMemberService;
|
|
|
import com.winhc.repal.service.RepalVipService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.winhc.repal.util.UserContextUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
@@ -13,6 +26,31 @@ import org.springframework.stereotype.Service;
|
|
|
*/
|
|
|
@Service
|
|
|
public class RepalVipServiceImpl extends ServiceImpl<RepalVipMapper, RepalVip> implements RepalVipService {
|
|
|
+ @Autowired
|
|
|
+ private RepalGroupMemberService repalGroupMemberService;
|
|
|
+ @Autowired
|
|
|
+ private RepalVipMapper repalVipMapper;
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean reply(ReplyDTO dto) {
|
|
|
+ if(dto.getCode() == null){
|
|
|
+ throw new CommonException(CodeMsg.VALIDATE_PARAMETER,"参数有误");
|
|
|
+ }
|
|
|
+ UserContextBO userContextBO = UserContextUtil.getUser();
|
|
|
+ //用户->组织
|
|
|
+ RepalGroupMember repalGroupMember = repalGroupMemberService.getOne(Wrappers.lambdaQuery(RepalGroupMember.class)
|
|
|
+ .eq(RepalGroupMember::getUserId,userContextBO.getUserId())
|
|
|
+ .eq(RepalGroupMember::getDeleted, Dict.DeletedStatusEnunm.否.getCode()),false);
|
|
|
+ if(repalGroupMember == null){
|
|
|
+ throw new CommonException(CodeMsg.FAILED,"组织不存在,回复失败");
|
|
|
+ }
|
|
|
+ //查找vip记录
|
|
|
+ RepalVip repalVip = getOne(Wrappers.lambdaQuery(RepalVip.class).eq(RepalVip::getRepalGroupId,repalGroupMember.getRepalGroupId()),false);
|
|
|
+ if(ObjectUtil.isNull(repalVip) || RepalVipSignEnum.无特权.getCode().equals(repalVip.getRepalVipSign())){
|
|
|
+ throw new CommonException(CodeMsg.FAILED,"特权过期或无特权,回复失败");
|
|
|
+ }
|
|
|
+ int count = repalVipMapper.replySomeCount(repalVip.getId(),dto.getCode());
|
|
|
|
|
|
+ return count > 0;
|
|
|
+ }
|
|
|
}
|