|
@@ -3,11 +3,15 @@ package com.ym.mec.biz.service.impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
+import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dao.CloudTeacherOrderDao;
|
|
|
+import com.ym.mec.biz.dal.dao.EmployeeDao;
|
|
|
import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
|
|
|
import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
|
import com.ym.mec.biz.dal.dto.CloudTeacherOrderDto;
|
|
|
import com.ym.mec.biz.dal.dto.Mapper;
|
|
|
+import com.ym.mec.biz.dal.dto.SimpleUserDto;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.enums.GroupType;
|
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
@@ -16,6 +20,7 @@ import com.ym.mec.biz.dal.enums.TenantOrderRecordEnum;
|
|
|
import com.ym.mec.biz.dal.page.CloudTeacherOrderQueryInfo;
|
|
|
import com.ym.mec.biz.service.*;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.page.WrapperUtil;
|
|
|
import com.ym.mec.common.service.IdGeneratorService;
|
|
@@ -24,6 +29,7 @@ import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import jodd.util.StringUtil;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -59,6 +65,12 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
|
|
|
@Autowired
|
|
|
private SysConfigDao sysConfigDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private EmployeeDao employeeDao;
|
|
|
+
|
|
|
@Override
|
|
|
public BaseDAO<Long, CloudTeacherOrder> getDAO() {
|
|
|
return cloudTeacherOrderDao;
|
|
@@ -115,7 +127,18 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
|
|
|
return pageInfo;
|
|
|
}
|
|
|
assert dataList != null;
|
|
|
+
|
|
|
+ Map<Integer, SimpleUserDto> empMapById = new HashMap<>();
|
|
|
+ List<Integer> operatorIdList = dataList.stream().map(CloudTeacherStudent::getOperator)
|
|
|
+ .distinct().collect(Collectors.toList());
|
|
|
+ if (!operatorIdList.isEmpty()) {
|
|
|
+ List<SimpleUserDto> byIds = employeeDao.findByIds(operatorIdList);
|
|
|
+ byIds.forEach(next -> empMapById.put(next.getUserId(), next));
|
|
|
+ }
|
|
|
for (CloudTeacherStudent cst : dataList) {
|
|
|
+ if (cst.getOperator() != null) {
|
|
|
+ cst.setOperatorName(empMapById.getOrDefault(cst.getOperator(), new SimpleUserDto()).getUserName());
|
|
|
+ }
|
|
|
TenantConfig tenantConfig = tenantConfigService.getOne(new QueryWrapper<TenantConfig>().eq("tenant_id_", cst.getTenantId()));
|
|
|
if (tenantConfig == null) {
|
|
|
throw new Exception("未找到组织Id " + cst.getTenantId().toString() + "在 TenantConfig 表");
|
|
@@ -353,4 +376,25 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
|
|
|
public String queryActiveOrderPage(Integer userId, Integer activeRemark, String remark) {
|
|
|
return cloudTeacherOrderDao.queryActiveOrderPage(userId, activeRemark, remark);
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public Boolean cancelInactive(CloudTeacherCancel cloudTeacherCancel,Integer tenantId) {
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ if (sysUser == null) {
|
|
|
+ throw new BizException("登录失效,请重新登录");
|
|
|
+ }
|
|
|
+ String ids = cloudTeacherCancel.getIds();
|
|
|
+ if (StringUtils.isEmpty(ids)) {
|
|
|
+ throw new BizException("未指定删除云教练");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> idList = Arrays.stream(ids.split(",")).map(Long::valueOf).collect(Collectors.toList());
|
|
|
+ int cancelNum = cloudTeacherOrderDao.cancelInactiveCloudTeacher(idList, cloudTeacherCancel.getCancelReason(),
|
|
|
+ sysUser.getId(), new Date(), tenantId);
|
|
|
+ if (cancelNum != idList.size()) {
|
|
|
+ throw new BizException("数据已更新,请刷新后重试");
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|