|
@@ -1,17 +1,22 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
|
|
|
+import com.alibaba.druid.sql.visitor.functions.If;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ym.mec.auth.api.entity.SysUserDevice;
|
|
|
+import com.ym.mec.biz.dal.dao.EmployeeDao;
|
|
|
import com.ym.mec.biz.dal.dao.FinancialExpenditureDao;
|
|
|
-import com.ym.mec.biz.dal.dto.FinancialExpenditureDto;
|
|
|
+import com.ym.mec.biz.dal.dao.OrganizationDao;
|
|
|
+import com.ym.mec.biz.dal.dto.*;
|
|
|
+import com.ym.mec.biz.dal.entity.Employee;
|
|
|
import com.ym.mec.biz.dal.entity.FinancialExpenditure;
|
|
|
-import com.ym.mec.biz.dal.enums.ExpenditureTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.FeeProjectEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.GoodsType;
|
|
|
-import com.ym.mec.biz.dal.enums.TemplateTypeEnum;
|
|
|
+import com.ym.mec.biz.dal.entity.Organization;
|
|
|
+import com.ym.mec.biz.dal.enums.*;
|
|
|
import com.ym.mec.biz.dal.page.FinancialExpenditureQueryInfo;
|
|
|
-import com.ym.mec.biz.service.FinancialExpenditureService;
|
|
|
+import com.ym.mec.biz.service.*;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
+import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.page.QueryInfo;
|
|
@@ -32,6 +37,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
import java.io.InputStream;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -40,6 +46,16 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
|
|
|
|
|
|
@Autowired
|
|
|
private FinancialExpenditureDao financialExpenditureDao;
|
|
|
+ @Autowired
|
|
|
+ private OrganizationDao organizationDao;
|
|
|
+ @Autowired
|
|
|
+ private EmployeeDao employeeDao;
|
|
|
+ @Autowired
|
|
|
+ private VipGroupService vipGroupService;
|
|
|
+ @Autowired
|
|
|
+ private GroupClassService groupClassService;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupService musicGroupService;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, FinancialExpenditure> getDAO() {
|
|
@@ -198,5 +214,305 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
|
|
|
return financialExpenditures;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void syncOaPayLog(Integer workOrderId) {
|
|
|
+ PWorkOrderInfo pWorkOrderInfo = financialExpenditureDao.getWorkOrderInfo(workOrderId);
|
|
|
+ if (pWorkOrderInfo != null){
|
|
|
+ Integer hasFinancial = financialExpenditureDao.findByBatchNoAndProcessNo(workOrderId);
|
|
|
+ if(hasFinancial != null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String formStructure = financialExpenditureDao.getFormStructure(workOrderId);
|
|
|
+ JSONObject formData = JSONObject.parseObject(financialExpenditureDao.getFormData(workOrderId));
|
|
|
+ OaFormStructureDto oaFormStructureDto = JSONObject.parseObject(formStructure, OaFormStructureDto.class);
|
|
|
+ List<OaInputDto> oaInputDtos = oaFormStructureDto.getList();
|
|
|
+ //课程退费和乐团退费需要单独处理
|
|
|
+ if(pWorkOrderInfo.getProcess().equals(22) || pWorkOrderInfo.getProcess().equals(19)){
|
|
|
+ List<FinancialExpenditure> financialExpenditureList = new ArrayList<>();
|
|
|
+ for (OaInputDto oaInputDto : oaInputDtos) {
|
|
|
+ if(!"子表单".equals(oaInputDto.getName())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String submitForm = oaInputDto.getModel();
|
|
|
+ List<HashMap> hashMaps = JSONObject.parseArray(formData.get(submitForm).toString(), HashMap.class);
|
|
|
+ for (HashMap hashMap : hashMaps) {
|
|
|
+ FinancialExpenditure financialExpenditure = new FinancialExpenditure();
|
|
|
+ financialExpenditure.setBatchNo(pWorkOrderInfo.getId().toString());
|
|
|
+ financialExpenditure.setFinancialProcessNo(pWorkOrderInfo.getId().toString());
|
|
|
+ List<OaColumnDto> columns = oaInputDto.getColumns();
|
|
|
+ if(columns != null && columns.size() > 0){
|
|
|
+ for (OaColumnDto column : columns) {
|
|
|
+ List<OaInputDto> columnList = column.getList();
|
|
|
+ if(columnList != null && columnList.size() > 0){
|
|
|
|
|
|
+ Employee employee = employeeDao.get(pWorkOrderInfo.getCreator());
|
|
|
+ List<SimpleUserDto> byIds = new ArrayList<>();
|
|
|
+ if(employee != null){
|
|
|
+ List<Integer> userIds = new ArrayList<>();
|
|
|
+ userIds.add(employee.getUserId());
|
|
|
+ byIds = employeeDao.findByIds(userIds);
|
|
|
+ }
|
|
|
+ if(employee != null){
|
|
|
+ if(byIds != null && byIds.size() > 0){
|
|
|
+ SimpleUserDto simpleUserDto = byIds.get(0);
|
|
|
+ financialExpenditure.setApplyUser(simpleUserDto.getUserName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (OaInputDto inputDto : columnList) {
|
|
|
+ String name = inputDto.getName();
|
|
|
+ if(name.contains("课程组编号")){
|
|
|
+ Object o = hashMap.get(inputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setVipGroupId(Long.parseLong(o.toString()));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(name.contains("课程类型")){
|
|
|
+ Object o = hashMap.get(inputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setGroupType(o.toString());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(name.contains("乐团编号")){
|
|
|
+ Object o = hashMap.get(inputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setMusicGroupId(o.toString());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(name.contains("退费项目")){
|
|
|
+ Object o = hashMap.get(inputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setReturnFeeType(o.toString());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(name.contains("学员编号")){
|
|
|
+ Object o = hashMap.get(inputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setStudentId(Integer.parseInt(o.toString()));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(name.contains("分部")){
|
|
|
+ Object o = hashMap.get(inputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ int organId = Integer.parseInt(o.toString());
|
|
|
+ Organization organization = organizationDao.get(organId);
|
|
|
+ if(organization != null){
|
|
|
+ financialExpenditure.setOrganId(organization.getId());
|
|
|
+ financialExpenditure.setOrganName(organization.getName());
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(name.contains("金额")){
|
|
|
+ Object o = hashMap.get(inputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setAmount(new BigDecimal(Double.parseDouble(o.toString())));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(name.contains("情况说明")){
|
|
|
+ Object o = hashMap.get(inputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setCause(o.toString());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(name.contains("支出类型")){
|
|
|
+ Object o = hashMap.get(inputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setType(ExpenditureTypeEnum.valueOfDesc(o.toString()));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(name.contains("费用类型")){
|
|
|
+ Object o = hashMap.get(inputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setFeeProject(FeeProjectEnum.valueOfDesc(o.toString()));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ financialExpenditureList.add(financialExpenditure);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //课程退费
|
|
|
+ if(pWorkOrderInfo.getProcess().equals(22)){
|
|
|
+ for (FinancialExpenditure financialExpenditure : financialExpenditureList) {
|
|
|
+ ReturnFeeDto returnFeeDto = new ReturnFeeDto();
|
|
|
+ returnFeeDto.setGroupType(GroupType.valueOfDesc(financialExpenditure.getGroupType()));
|
|
|
+ returnFeeDto.setAmount(financialExpenditure.getAmount());
|
|
|
+ returnFeeDto.setStudentId(financialExpenditure.getStudentId());
|
|
|
+ returnFeeDto.setConfirmReturnActivityGive(true);
|
|
|
+ returnFeeDto.setGroupId(financialExpenditure.getVipGroupId());
|
|
|
+ returnFeeDto.setVipGroupId(financialExpenditure.getVipGroupId());
|
|
|
+ if(returnFeeDto.getGroupType() == GroupType.VIP){
|
|
|
+ vipGroupService.applyRefundForStudentOa(returnFeeDto);
|
|
|
+ }else if(returnFeeDto.getGroupType() == GroupType.COMM || returnFeeDto.getGroupType() == GroupType.PRACTICE){
|
|
|
+ groupClassService.cancelGroupOa(returnFeeDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //退团
|
|
|
+ for (FinancialExpenditure financialExpenditure : financialExpenditureList) {
|
|
|
+ Boolean isRefundInstrumentFee = false;
|
|
|
+ Boolean isRefundTeachingAssistantsFee = false;
|
|
|
+ Boolean maintenanceFee = false;
|
|
|
+ String returnFeeType = financialExpenditure.getReturnFeeType();
|
|
|
+ if(StringUtils.isNotEmpty(returnFeeType)){
|
|
|
+ if(returnFeeType.contains("乐器")){
|
|
|
+ isRefundInstrumentFee = true;
|
|
|
+ }
|
|
|
+ if(returnFeeType.contains("乐保")){
|
|
|
+ maintenanceFee = true;
|
|
|
+ }
|
|
|
+ if(returnFeeType.contains("教辅")){
|
|
|
+ isRefundTeachingAssistantsFee = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ musicGroupService.directQuitMusicGroupOa(financialExpenditure.getMusicGroupId(), financialExpenditure.getStudentId(),
|
|
|
+ financialExpenditure.getCause(), isRefundInstrumentFee,
|
|
|
+ isRefundTeachingAssistantsFee, maintenanceFee, financialExpenditure.getAmount());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ financialExpenditureDao.batchInsert(financialExpenditureList);
|
|
|
+ }else {
|
|
|
+ FinancialExpenditure financialExpenditure = new FinancialExpenditure();
|
|
|
+ financialExpenditure.setBatchNo(workOrderId.toString());
|
|
|
+ financialExpenditure.setFinancialProcessNo(workOrderId.toString());
|
|
|
+ Employee employee = employeeDao.get(pWorkOrderInfo.getCreator());
|
|
|
+ Integer organId = financialExpenditureDao.getDeptId(pWorkOrderInfo.getDeptId());
|
|
|
+ Organization organization = organizationDao.get(organId);
|
|
|
+ if(organization != null){
|
|
|
+ financialExpenditure.setOrganId(organization.getId());
|
|
|
+ financialExpenditure.setOrganName(organization.getName());
|
|
|
+ }
|
|
|
+ if(employee != null){
|
|
|
+ List<Integer> userIds = new ArrayList<>();
|
|
|
+ userIds.add(employee.getUserId());
|
|
|
+ List<SimpleUserDto> byIds = employeeDao.findByIds(userIds);
|
|
|
+ if(byIds != null && byIds.size() > 0){
|
|
|
+ SimpleUserDto simpleUserDto = byIds.get(0);
|
|
|
+ financialExpenditure.setApplyUser(simpleUserDto.getUserName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (OaInputDto oaInputDto : oaInputDtos) {
|
|
|
+ String name = oaInputDto.getName();
|
|
|
+ if(name.contains("金额")){
|
|
|
+ Object o = formData.get(oaInputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setAmount(new BigDecimal(Double.parseDouble(o.toString())));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(name.contains("情况说明")){
|
|
|
+ Object o = formData.get(oaInputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setCause(o.toString());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(name.contains("支出类型")){
|
|
|
+ Object o = formData.get(oaInputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setType(ExpenditureTypeEnum.valueOfDesc(o.toString()));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(name.contains("费用类型")){
|
|
|
+ Object o = formData.get(oaInputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setFeeProject(FeeProjectEnum.valueOfDesc(o.toString()));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ financialExpenditureDao.insert(financialExpenditure);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void checkCourseReturnFee(Map<String,String> paramMap) {
|
|
|
+ String tplInfoId = paramMap.get("tplInfoId");
|
|
|
+ if(StringUtils.isEmpty(tplInfoId)){
|
|
|
+ throw new BizException("参数校验失败");
|
|
|
+ }
|
|
|
+ if(tplInfoId.equals("11") || tplInfoId.equals("8")){
|
|
|
+ JSONObject formData = JSONObject.parseObject(paramMap.get("formData"));
|
|
|
+ String formStructure = financialExpenditureDao.getTplInfo(tplInfoId);
|
|
|
+ OaFormStructureDto oaFormStructureDto = JSONObject.parseObject(formStructure, OaFormStructureDto.class);
|
|
|
+ List<OaInputDto> oaInputDtos = oaFormStructureDto.getList();
|
|
|
+ List<FinancialExpenditure> financialExpenditureList = new ArrayList<>();
|
|
|
+ for (OaInputDto oaInputDto : oaInputDtos) {
|
|
|
+ if(!"子表单".equals(oaInputDto.getName())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String submitForm = oaInputDto.getModel();
|
|
|
+ List<HashMap> hashMaps = JSONObject.parseArray(formData.get(submitForm).toString(), HashMap.class);
|
|
|
+ for (HashMap hashMap : hashMaps) {
|
|
|
+ FinancialExpenditure financialExpenditure = new FinancialExpenditure();
|
|
|
+ List<OaColumnDto> columns = oaInputDto.getColumns();
|
|
|
+ if(columns != null && columns.size() > 0){
|
|
|
+ for (OaColumnDto column : columns) {
|
|
|
+ List<OaInputDto> columnList = column.getList();
|
|
|
+ if(columnList != null && columnList.size() > 0){
|
|
|
+ for (OaInputDto inputDto : columnList) {
|
|
|
+ String name = inputDto.getName();
|
|
|
+ if(name.contains("课程组编号")){
|
|
|
+ Object o = hashMap.get(inputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setVipGroupId(Long.parseLong(o.toString()));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(name.contains("课程类型")){
|
|
|
+ Object o = hashMap.get(inputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setGroupType(o.toString());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(name.contains("乐团编号")){
|
|
|
+ Object o = hashMap.get(inputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setMusicGroupId(o.toString());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(name.contains("学员编号")){
|
|
|
+ Object o = hashMap.get(inputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setStudentId(Integer.parseInt(o.toString()));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }else if(name.contains("金额")){
|
|
|
+ Object o = hashMap.get(inputDto.getModel());
|
|
|
+ if(o != null){
|
|
|
+ financialExpenditure.setAmount(new BigDecimal(Double.parseDouble(o.toString())));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ financialExpenditureList.add(financialExpenditure);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //课程退费
|
|
|
+ if(tplInfoId.equals("11")){
|
|
|
+ for (FinancialExpenditure financialExpenditure : financialExpenditureList) {
|
|
|
+ ReturnFeeDto returnFeeDto = new ReturnFeeDto();
|
|
|
+ returnFeeDto.setGroupType(GroupType.valueOfDesc(financialExpenditure.getGroupType()));
|
|
|
+ returnFeeDto.setAmount(financialExpenditure.getAmount());
|
|
|
+ returnFeeDto.setStudentId(financialExpenditure.getStudentId());
|
|
|
+ returnFeeDto.setConfirmReturnActivityGive(true);
|
|
|
+ returnFeeDto.setGroupId(financialExpenditure.getVipGroupId());
|
|
|
+ returnFeeDto.setVipGroupId(financialExpenditure.getVipGroupId());
|
|
|
+ if(returnFeeDto.getGroupType() == GroupType.VIP){
|
|
|
+ vipGroupService.checkApplyRefundForStudentOa(returnFeeDto);
|
|
|
+ }else if(returnFeeDto.getGroupType() == GroupType.COMM || returnFeeDto.getGroupType() == GroupType.PRACTICE){
|
|
|
+ groupClassService.checkCancelGroupOa(returnFeeDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ for (FinancialExpenditure financialExpenditure : financialExpenditureList) {
|
|
|
+ musicGroupService.checkDirectQuitMusicGroupOa(financialExpenditure.getMusicGroupId(), financialExpenditure.getStudentId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|