|
@@ -1,12 +1,16 @@
|
|
|
package com.yonge.cooleshow.biz.dal.service.impl;
|
|
|
|
|
|
+import com.dayaedu.cbs.common.enums.EClientType;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.yonge.cooleshow.api.feign.MallPortalFeignService;
|
|
|
+import com.yonge.cooleshow.api.feign.dto.OmsOrderDetail;
|
|
|
import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.CourseGroup;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.ImGroup;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.ImGroupMember;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.ImUserFriend;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.Student;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.Teacher;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.UserOrder;
|
|
@@ -29,12 +33,10 @@ import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.yonge.toolset.thirdparty.user.realname.RealnameAuthenticationPlugin;
|
|
|
import com.yonge.toolset.utils.idcard.IdcardInfoExtractor;
|
|
|
import com.yonge.toolset.utils.idcard.IdcardValidator;
|
|
|
-import jodd.util.StringUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
@@ -92,6 +94,12 @@ public class SysUserServiceImpl implements SysUserService {
|
|
|
@Autowired
|
|
|
private UserAccountService userAccountService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MallPortalFeignService mallPortalFeignService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ImUserFriendService imUserFriendService;
|
|
|
+
|
|
|
@Override
|
|
|
public SysUserMapper getDao() {
|
|
|
return sysUserMapper;
|
|
@@ -233,20 +241,8 @@ public class SysUserServiceImpl implements SysUserService {
|
|
|
Long userId = sysUser.getId();
|
|
|
|
|
|
// 存在待支付、未确认收货、售后处理的订单
|
|
|
- Integer count = userOrderService.lambdaQuery()
|
|
|
- .eq(UserOrder::getUserId, userId)
|
|
|
- .in(UserOrder::getStatus, Arrays.asList(OrderStatusEnum.WAIT_PAY, OrderStatusEnum.PAYING, OrderStatusEnum.PAID))
|
|
|
- .count();
|
|
|
- if (count > 0) {
|
|
|
+ if(hasUnfinishedOrder(userId)){
|
|
|
errMsg.add("账户存在未支付、未确认收货、售后处理中的订单");
|
|
|
- } else {
|
|
|
- Integer refundCount = userOrderRefundService.lambdaQuery()
|
|
|
- .eq(UserOrderRefund::getUserId, userId)
|
|
|
- .eq(UserOrderRefund::getStatus, AuthStatusEnum.DOING)
|
|
|
- .count();
|
|
|
- if (refundCount > 0) {
|
|
|
- errMsg.add("账户存在未支付、未确认收货、售后处理中的订单");
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
Teacher teacher = teacherService.getById(userId);
|
|
@@ -292,34 +288,101 @@ public class SysUserServiceImpl implements SysUserService {
|
|
|
return errMsg;
|
|
|
}
|
|
|
|
|
|
+ private boolean hasUnfinishedOrder(Long userId) {
|
|
|
+ // 商城订单 0->待付款;1->待发货;2->已发货
|
|
|
+ HttpResponseResult<List<OmsOrderDetail>> httpResponseResult = mallPortalFeignService.queryOrderList("0,1,2", userId);
|
|
|
+ if (httpResponseResult == null) {
|
|
|
+ throw new BizException("检查订单信息失败");
|
|
|
+ }
|
|
|
+ List<OmsOrderDetail> data = httpResponseResult.getData();
|
|
|
+ if (!CollectionUtils.isEmpty(data)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 酷乐秀订单
|
|
|
+ Integer count = userOrderService.lambdaQuery()
|
|
|
+ .eq(UserOrder::getUserId, userId)
|
|
|
+ .in(UserOrder::getStatus, Arrays.asList(OrderStatusEnum.WAIT_PAY, OrderStatusEnum.PAYING))
|
|
|
+ .count();
|
|
|
+ if (count > 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ Integer refundCount = userOrderRefundService.lambdaQuery()
|
|
|
+ .eq(UserOrderRefund::getUserId, userId)
|
|
|
+ .eq(UserOrderRefund::getStatus, AuthStatusEnum.DOING)
|
|
|
+ .count();
|
|
|
+ return refundCount > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 账号注销,群聊处理
|
|
|
+ * 学生:退群,删除好友关系
|
|
|
+ * 老师:非机构群 群主,注销群,删除好友
|
|
|
+ */
|
|
|
@Override
|
|
|
- public void dismissFanImGroup(String phone) {
|
|
|
+ public void logoffQuitImGroup(String phone) {
|
|
|
SysUser sysUser = this.getDao().findUserByPhone(phone);
|
|
|
if (sysUser == null) {
|
|
|
return;
|
|
|
}
|
|
|
- Teacher teacher = teacherService.getById(sysUser.getId());
|
|
|
- if (teacher == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- List<ImGroupMember> groupMembers = imGroupMemberService.lambdaQuery()
|
|
|
- .eq(ImGroupMember::getUserId, sysUser.getId())
|
|
|
- .eq(ImGroupMember::getGroupRoleType, EImGroupMemberRoleType.Owner)
|
|
|
- .list();
|
|
|
- List<String> groupIdList = groupMembers.stream().map(ImGroupMember::getGroupId).collect(Collectors.toList());
|
|
|
- if (groupIdList.isEmpty()) {
|
|
|
- return;
|
|
|
+ Long userId = sysUser.getId();
|
|
|
+ Student student = studentService.getById(userId);
|
|
|
+ if (student != null) {
|
|
|
+ List<ImGroupMember> groupMembers = imGroupMemberService.lambdaQuery()
|
|
|
+ .eq(ImGroupMember::getUserId, sysUser.getId())
|
|
|
+ .eq(ImGroupMember::getGroupRoleType, EImGroupMemberRoleType.Member)
|
|
|
+ .list();
|
|
|
+ List<String> groupIdList = groupMembers.stream().map(ImGroupMember::getGroupId).collect(Collectors.toList());
|
|
|
+ // 退群
|
|
|
+ for (String groupId : groupIdList) {
|
|
|
+ try {
|
|
|
+ imGroupService.quit(groupId, userId, ClientEnum.STUDENT, true);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("学生注销退群失败->学生:" + userId + "," + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 删除好友
|
|
|
+ imUserFriendService.lambdaUpdate()
|
|
|
+ .eq(ImUserFriend::getUserId, userId)
|
|
|
+ .eq(ImUserFriend::getClientType, EClientType.STUDENT)
|
|
|
+ .remove();
|
|
|
+ imUserFriendService.lambdaUpdate()
|
|
|
+ .eq(ImUserFriend::getFriendId, userId)
|
|
|
+ .eq(ImUserFriend::getFriendType, EClientType.STUDENT)
|
|
|
+ .remove();
|
|
|
}
|
|
|
- Collection<ImGroup> imGroups = imGroupService.listByIds(groupIdList);
|
|
|
- List<String> groupIds = imGroups.stream().filter(next -> ImGroupType.FAN.equals(next.getType()) || ImGroupType.COURSE.equals(next.getType()))
|
|
|
- .map(ImGroup::getId).collect(Collectors.toList());
|
|
|
-
|
|
|
- for (String groupId : groupIds) {
|
|
|
- try {
|
|
|
- imGroupService.dismiss(groupId);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("群解散失败:" + groupId);
|
|
|
+
|
|
|
+
|
|
|
+ Teacher teacher = teacherService.getById(sysUser.getId());
|
|
|
+ if (teacher != null) {
|
|
|
+ List<ImGroupMember> groupMembers = imGroupMemberService.lambdaQuery()
|
|
|
+ .eq(ImGroupMember::getUserId, sysUser.getId())
|
|
|
+ .eq(ImGroupMember::getGroupRoleType, EImGroupMemberRoleType.Owner)
|
|
|
+ .list();
|
|
|
+ List<String> groupIdList = groupMembers.stream().map(ImGroupMember::getGroupId).collect(Collectors.toList());
|
|
|
+ if (groupIdList.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Collection<ImGroup> imGroups = imGroupService.listByIds(groupIdList);
|
|
|
+ List<String> groupIds = imGroups.stream().filter(next -> ImGroupType.FAN.equals(next.getType()) || ImGroupType.COURSE.equals(next.getType()))
|
|
|
+ .map(ImGroup::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ for (String groupId : groupIds) {
|
|
|
+ try {
|
|
|
+ imGroupService.dismiss(groupId);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("群解散失败:" + groupId);
|
|
|
+ }
|
|
|
}
|
|
|
+ // 删除好友
|
|
|
+ imUserFriendService.lambdaUpdate()
|
|
|
+ .eq(ImUserFriend::getUserId, userId)
|
|
|
+ .eq(ImUserFriend::getClientType, EClientType.TEACHER)
|
|
|
+ .remove();
|
|
|
+ imUserFriendService.lambdaUpdate()
|
|
|
+ .eq(ImUserFriend::getFriendId, userId)
|
|
|
+ .eq(ImUserFriend::getFriendType, EClientType.TEACHER)
|
|
|
+ .remove();
|
|
|
}
|
|
|
}
|
|
|
}
|