|
|
@@ -1,5 +1,6 @@
|
|
|
package shop.alien.store.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
@@ -9,12 +10,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import shop.alien.entity.store.LifeUserExpert;
|
|
|
-import shop.alien.entity.store.LifeUserExpertOrder;
|
|
|
-import shop.alien.entity.store.LifeUserExpertWorks;
|
|
|
+import shop.alien.entity.store.*;
|
|
|
import shop.alien.entity.store.vo.ExpertGoodsTypeVo;
|
|
|
import shop.alien.entity.store.vo.LifeUserExpertOrderVo;
|
|
|
import shop.alien.entity.store.vo.LifeUserExpertVo;
|
|
|
+import shop.alien.mapper.LifeNoticeMapper;
|
|
|
import shop.alien.mapper.LifeUserExpertMapper;
|
|
|
import shop.alien.mapper.LifeUserExpertOrderMapper;
|
|
|
import shop.alien.mapper.LifeUserExpertWorksMapper;
|
|
|
@@ -24,8 +24,10 @@ import shop.alien.store.service.LifeUserExpertService;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.time.Period;
|
|
|
import java.time.ZoneId;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -46,6 +48,7 @@ public class LifeUserExpertServiceImpl extends ServiceImpl<LifeUserExpertMapper,
|
|
|
private final LifeUserExpertWorksMapper lifeUserExpertWorksMapper;
|
|
|
private final LifeUserExpertOrderService lifeUserExpertOrderService;
|
|
|
private final LifeUserExpertOrderMapper lifeUserExpertOrderMapper;
|
|
|
+ private final LifeNoticeMapper lifeNoticeMapper;
|
|
|
|
|
|
@Override
|
|
|
public IPage<LifeUserExpertVo> getUserExpertList(int page, int size, String userName, String expertCode, Integer userId) {
|
|
|
@@ -73,21 +76,54 @@ public class LifeUserExpertServiceImpl extends ServiceImpl<LifeUserExpertMapper,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean becomeExpert(Integer userId, String expertType) {
|
|
|
+ public boolean becomeExpert(Integer id, String userPhone ,String comment ,Integer expertStatus) {
|
|
|
LambdaQueryWrapper<LifeUserExpert> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(LifeUserExpert::getUserId, userId);
|
|
|
+ wrapper.eq(LifeUserExpert::getId, id);
|
|
|
wrapper.eq(LifeUserExpert::getDeleteFlag, 1);
|
|
|
- LifeUserExpert lifeUserExpert = lifeUserExpertMapper.selectIsExpert(userId);
|
|
|
+ LifeUserExpert lifeUserExpert = lifeUserExpertMapper.selectIsExpert(id);
|
|
|
if (lifeUserExpert != null) {
|
|
|
lifeUserExpert.setDeleteFlag(0);
|
|
|
- lifeUserExpert.setExpertType(expertType);
|
|
|
+ lifeUserExpert.setExpertStatus(expertStatus);
|
|
|
return lifeUserExpertMapper.updateExpert(lifeUserExpert);
|
|
|
}
|
|
|
LifeUserExpert expert = new LifeUserExpert();
|
|
|
- expert.setUserId(userId);
|
|
|
- expert.setExpertType(expertType);
|
|
|
- expert.setExpertCode(setExpertCode());
|
|
|
- return this.save(expert);
|
|
|
+ expert.setId(id);
|
|
|
+ expert.setExpertStatus(expertStatus);
|
|
|
+ if (expertStatus == 0){
|
|
|
+ expert.setExpertCode(setExpertCode());
|
|
|
+ } else if(expertStatus == 2){
|
|
|
+ expert.setExpertCode(null);
|
|
|
+ expert.setDeleteFlag(1);
|
|
|
+ }
|
|
|
+ LifeNotice lifeMessage = new LifeNotice();
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String formattedDate = LocalDateTime.now().format(formatter);
|
|
|
+ if (expertStatus == 0){
|
|
|
+ String text = "您在"+formattedDate+"提交的信息已经通过审核。恭喜您成为达人。";
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("message", text);
|
|
|
+ lifeMessage.setReceiverId("user_"+userPhone);
|
|
|
+ lifeMessage.setTitle("审核通过通知");
|
|
|
+ lifeMessage.setContext(jsonObject.toJSONString());
|
|
|
+ lifeMessage.setNoticeType(1);
|
|
|
+ lifeMessage.setIsRead(0);
|
|
|
+ lifeMessage.setDeleteFlag(0);
|
|
|
+ lifeMessage.setSenderId("system");
|
|
|
+ lifeNoticeMapper.insert(lifeMessage);
|
|
|
+ } else if (expertStatus == 2) {
|
|
|
+ String text = "您在"+formattedDate+"提交的信息未通过审核,拒绝原因:"+comment+"。请您重新填写信息后再次提交至平台审核。";
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("message", text);
|
|
|
+ lifeMessage.setReceiverId("user_"+userPhone);
|
|
|
+ lifeMessage.setTitle("审核失败通知");
|
|
|
+ lifeMessage.setContext(jsonObject.toJSONString());
|
|
|
+ lifeMessage.setNoticeType(1);
|
|
|
+ lifeMessage.setIsRead(0);
|
|
|
+ lifeMessage.setDeleteFlag(0);
|
|
|
+ lifeMessage.setSenderId("system");
|
|
|
+ lifeNoticeMapper.insert(lifeMessage);
|
|
|
+ }
|
|
|
+ return lifeUserExpertMapper.updateExpert(expert);
|
|
|
}
|
|
|
|
|
|
public Integer setExpertCode() {
|
|
|
@@ -308,4 +344,18 @@ public class LifeUserExpertServiceImpl extends ServiceImpl<LifeUserExpertMapper,
|
|
|
.sorted(Comparator.comparing(ExpertGoodsTypeVo::getTypeCount).reversed())
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<LifeUserExpertVo> getApplicationExpertList(int page, int size, String userName, String expertCode, Integer userId) {
|
|
|
+ QueryWrapper<LifeUserExpertVo> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.eq("expert.delete_flag", 0);
|
|
|
+ wrapper.eq("user.delete_flag", 0);
|
|
|
+ wrapper.eq(userId != null, "user.id", userId);
|
|
|
+ wrapper.eq( "expert.expert_status", 1);
|
|
|
+ wrapper.like(StringUtils.isNotEmpty(userName), "user.user_name", userName);
|
|
|
+ wrapper.like(StringUtils.isNotEmpty(expertCode), "expert.expert_code", expertCode);
|
|
|
+ wrapper.orderByDesc("accountMoney");
|
|
|
+ return lifeUserExpertMapper.getApplicationExpertList(new Page<>(page, size), wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
}
|