|
@@ -3,19 +3,25 @@ package com.ym.mec.biz.service.impl;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
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.CloudTeacherOrderDao;
|
|
|
|
+import com.ym.mec.biz.dal.dao.EmployeeDao;
|
|
import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
|
|
import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
|
|
import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
import com.ym.mec.biz.dal.dto.CloudTeacherOrderDto;
|
|
import com.ym.mec.biz.dal.dto.CloudTeacherOrderDto;
|
|
import com.ym.mec.biz.dal.dto.Mapper;
|
|
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.entity.*;
|
|
import com.ym.mec.biz.dal.enums.GroupType;
|
|
import com.ym.mec.biz.dal.enums.GroupType;
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
|
|
import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
|
|
|
|
+import com.ym.mec.biz.dal.enums.ReturnFeeEnum;
|
|
import com.ym.mec.biz.dal.enums.TenantOrderRecordEnum;
|
|
import com.ym.mec.biz.dal.enums.TenantOrderRecordEnum;
|
|
import com.ym.mec.biz.dal.page.CloudTeacherOrderQueryInfo;
|
|
import com.ym.mec.biz.dal.page.CloudTeacherOrderQueryInfo;
|
|
import com.ym.mec.biz.service.*;
|
|
import com.ym.mec.biz.service.*;
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
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.PageInfo;
|
|
import com.ym.mec.common.page.WrapperUtil;
|
|
import com.ym.mec.common.page.WrapperUtil;
|
|
import com.ym.mec.common.service.IdGeneratorService;
|
|
import com.ym.mec.common.service.IdGeneratorService;
|
|
@@ -24,6 +30,7 @@ import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
import com.ym.mec.util.date.DateUtil;
|
|
import com.ym.mec.util.date.DateUtil;
|
|
import jodd.util.StringUtil;
|
|
import jodd.util.StringUtil;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -34,6 +41,8 @@ import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
+import static com.ym.mec.biz.dal.enums.GroupType.GOODS_SELL;
|
|
|
|
+import static com.ym.mec.biz.dal.enums.GroupType.MEMBER;
|
|
import static com.ym.mec.biz.dal.enums.PeriodEnum.*;
|
|
import static com.ym.mec.biz.dal.enums.PeriodEnum.*;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@@ -59,6 +68,15 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
|
|
@Autowired
|
|
@Autowired
|
|
private SysConfigDao sysConfigDao;
|
|
private SysConfigDao sysConfigDao;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private EmployeeDao employeeDao;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysUserCashAccountLogService sysUserCashAccountLogService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public BaseDAO<Long, CloudTeacherOrder> getDAO() {
|
|
public BaseDAO<Long, CloudTeacherOrder> getDAO() {
|
|
return cloudTeacherOrderDao;
|
|
return cloudTeacherOrderDao;
|
|
@@ -115,7 +133,18 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
|
|
return pageInfo;
|
|
return pageInfo;
|
|
}
|
|
}
|
|
assert dataList != null;
|
|
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) {
|
|
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()));
|
|
TenantConfig tenantConfig = tenantConfigService.getOne(new QueryWrapper<TenantConfig>().eq("tenant_id_", cst.getTenantId()));
|
|
if (tenantConfig == null) {
|
|
if (tenantConfig == null) {
|
|
throw new Exception("未找到组织Id " + cst.getTenantId().toString() + "在 TenantConfig 表");
|
|
throw new Exception("未找到组织Id " + cst.getTenantId().toString() + "在 TenantConfig 表");
|
|
@@ -164,6 +193,10 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
|
|
throw new Exception("存在已经支付完成的学生,请重新选择");
|
|
throw new Exception("存在已经支付完成的学生,请重新选择");
|
|
}
|
|
}
|
|
Integer tenantId = null;
|
|
Integer tenantId = null;
|
|
|
|
+ List<CloudTeacherOrder> cloudTeacherOrders = cloudTeacherOrderDao.queryCloudTeacherOrderByIds(ids);
|
|
|
|
+ if (cloudTeacherOrders.stream().filter(next -> next.getStatus() == 4).collect(Collectors.toSet()).size() > 0) {
|
|
|
|
+ throw new Exception("存在已取消的学生,请重新选择");
|
|
|
|
+ }
|
|
BigDecimal sumAmount = new BigDecimal(0);
|
|
BigDecimal sumAmount = new BigDecimal(0);
|
|
for (CloudTeacherStudent cts : cloudTeacherStudents) {
|
|
for (CloudTeacherStudent cts : cloudTeacherStudents) {
|
|
if (cts.getAmount() == null) {
|
|
if (cts.getAmount() == null) {
|
|
@@ -353,4 +386,38 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
|
|
public String queryActiveOrderPage(Integer userId, Integer activeRemark, String remark) {
|
|
public String queryActiveOrderPage(Integer userId, Integer activeRemark, String remark) {
|
|
return cloudTeacherOrderDao.queryActiveOrderPage(userId, activeRemark, 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<Integer> idList = Arrays.stream(ids.split(",")).map(Integer::valueOf).collect(Collectors.toList());
|
|
|
|
+ int cancelNum = cloudTeacherOrderDao.cancelInactiveCloudTeacher(idList, cloudTeacherCancel.getCancelReason(),
|
|
|
|
+ sysUser.getId(), new Date(), tenantId);
|
|
|
|
+ if (cancelNum != idList.size()) {
|
|
|
|
+ throw new BizException("数据已更新,请刷新后重试");
|
|
|
|
+ }
|
|
|
|
+ List<CloudTeacherOrder> cloudTeacherOrders = cloudTeacherOrderDao.queryCloudTeacherOrderByIds(idList);
|
|
|
|
+ cloudTeacherOrders.stream().filter(next -> next.getAmount().compareTo(new BigDecimal(0)) != 0).forEach(next -> {
|
|
|
|
+ SysUserCashAccountLog sysUserCashAccountLog = new SysUserCashAccountLog();
|
|
|
|
+ sysUserCashAccountLog.setReturnFeeType(ReturnFeeEnum.MEMBER);
|
|
|
|
+ sysUserCashAccountLog.setOrganId(next.getOrganId());
|
|
|
|
+ sysUserCashAccountLog.setUserId(next.getStudentId());
|
|
|
|
+ sysUserCashAccountLog.setGroupType(MEMBER);
|
|
|
|
+ sysUserCashAccountLog.setComment(ReturnFeeEnum.MEMBER.getMsg());
|
|
|
|
+ sysUserCashAccountLog.setGroupId(String.valueOf(next.getId()));
|
|
|
|
+ sysUserCashAccountLog.setAmount(next.getAmount());
|
|
|
|
+ sysUserCashAccountLogService.insert(sysUserCashAccountLog);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
}
|
|
}
|