浏览代码

Merge remote-tracking branch 'origin/master'

周箭河 5 年之前
父节点
当前提交
0f762faa65

+ 13 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Goods.java

@@ -64,13 +64,16 @@ public class Goods {
 	private BigDecimal marketPrice;
 
 	/** 折扣价 */
-	@ApiModelProperty(value = "折扣价",required = false)
+	@ApiModelProperty(value = "商品零售价",required = false)
 	private BigDecimal discountPrice;
 
 	/** 团购价 */
 	@ApiModelProperty(value = "团购价",required = false)
 	private BigDecimal groupPurchasePrice;
 
+	@ApiModelProperty(value = "商品价格1")
+	private BigDecimal costPrice;
+
 	/** 协议成本价 */
 	@ApiModelProperty(value = "协议成本价",required = false)
 	private BigDecimal agreeCostPrice;
@@ -174,7 +177,15 @@ public class Goods {
         this.subjectIds = subjectIds;
     }
 
-    public String getGoodsCategoryName() {
+	public BigDecimal getCostPrice() {
+		return costPrice;
+	}
+
+	public void setCostPrice(BigDecimal costPrice) {
+		this.costPrice = costPrice;
+	}
+
+	public String getGoodsCategoryName() {
 		return goodsCategoryName;
 	}
 

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -1902,6 +1902,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                 courseSchedule.setTeacherId(teacherId);
                 courseSchedule.setActualTeacherId(teacherId);
                 courseSchedule.setOrganId(musicGroup.getOrganId());
+                courseSchedule.setClassGroupType(classGroup.getType().getCode());
                 courseScheduleDao.insert(courseSchedule);
                 courseScheduleList.add(courseSchedule);
                 times++;

+ 161 - 46
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -1,21 +1,154 @@
 package com.ym.mec.biz.service.impl;
 
+import static com.ym.mec.biz.dal.enums.GroupType.MUSIC;
+import static com.ym.mec.biz.dal.enums.GroupType.PRACTICE;
+import static com.ym.mec.biz.dal.enums.GroupType.VIP;
+import static com.ym.mec.biz.dal.enums.PracticeGroupType.CHARGE;
+import static com.ym.mec.biz.dal.enums.PracticeGroupType.FREE;
+import static com.ym.mec.biz.dal.enums.PracticeGroupType.TRIAL;
+
+import java.lang.reflect.InvocationTargetException;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.apache.commons.collections.ListUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.entity.SysUserRole;
-import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.dto.*;
-import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.dao.ClassGroupDao;
+import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
+import com.ym.mec.biz.dal.dao.ClassGroupTeacherMapperDao;
+import com.ym.mec.biz.dal.dao.ClassGroupTeacherSalaryDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleComplaintsDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleEvaluateDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleModifyLogDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleReviewDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleTeacherSalaryDao;
+import com.ym.mec.biz.dal.dao.CoursesGroupDao;
+import com.ym.mec.biz.dal.dao.CoursesGroupModifyLogDao;
+import com.ym.mec.biz.dal.dao.GroupDao;
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
+import com.ym.mec.biz.dal.dao.PracticeGroupDao;
+import com.ym.mec.biz.dal.dao.SchoolDao;
+import com.ym.mec.biz.dal.dao.StudentAttendanceDao;
+import com.ym.mec.biz.dal.dao.SubjectDao;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
+import com.ym.mec.biz.dal.dao.TeacherAttendanceDao;
+import com.ym.mec.biz.dal.dao.TeacherDao;
+import com.ym.mec.biz.dal.dao.TeacherDefaultMusicGroupSalaryDao;
+import com.ym.mec.biz.dal.dao.TeacherDefaultPracticeGroupSalaryDao;
+import com.ym.mec.biz.dal.dao.TeacherDefaultVipGroupSalaryDao;
+import com.ym.mec.biz.dal.dao.VipGroupDao;
+import com.ym.mec.biz.dal.dto.BatchInsertCoursesDto;
+import com.ym.mec.biz.dal.dto.ClassDateAdjustDto;
+import com.ym.mec.biz.dal.dto.CourseAttendanceDetailHeadInfoDto;
+import com.ym.mec.biz.dal.dto.CoursePostponeDto;
+import com.ym.mec.biz.dal.dto.CourseScheduleDto;
+import com.ym.mec.biz.dal.dto.CourseScheduleEndDto;
+import com.ym.mec.biz.dal.dto.CourseScheduleRateDto;
+import com.ym.mec.biz.dal.dto.CourseScheduleStudentDto;
+import com.ym.mec.biz.dal.dto.CourseTimeDto;
+import com.ym.mec.biz.dal.dto.CreateCourseScheduleDto;
+import com.ym.mec.biz.dal.dto.IntegerAndIntegerListDto;
+import com.ym.mec.biz.dal.dto.Mapper;
+import com.ym.mec.biz.dal.dto.StudentNameAndPhoneDto;
+import com.ym.mec.biz.dal.dto.TeacherAttendanceDto;
+import com.ym.mec.biz.dal.dto.TeacherClassCourseSchudeleDto;
+import com.ym.mec.biz.dal.dto.TeacherRemarkCommitDto;
+import com.ym.mec.biz.dal.dto.VipGroupApplyBaseInfoDto;
+import com.ym.mec.biz.dal.dto.VipGroupApplyDto;
+import com.ym.mec.biz.dal.dto.VipGroupCourseAdjustInfoDto;
+import com.ym.mec.biz.dal.entity.ClassGroup;
+import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
+import com.ym.mec.biz.dal.entity.ClassGroupTeacherMapper;
+import com.ym.mec.biz.dal.entity.ClassGroupTeacherSalary;
+import com.ym.mec.biz.dal.entity.CourseGenerateDto;
+import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
-import com.ym.mec.biz.dal.enums.*;
+import com.ym.mec.biz.dal.entity.CourseScheduleComplaints;
+import com.ym.mec.biz.dal.entity.CourseScheduleEvaluate;
+import com.ym.mec.biz.dal.entity.CourseScheduleModifyLog;
+import com.ym.mec.biz.dal.entity.CourseScheduleReview;
+import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
+import com.ym.mec.biz.dal.entity.CourseScheduleTeacherSalary;
+import com.ym.mec.biz.dal.entity.CoursesGroup;
+import com.ym.mec.biz.dal.entity.CoursesGroupModifyLog;
+import com.ym.mec.biz.dal.entity.Group;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.PracticeGroup;
+import com.ym.mec.biz.dal.entity.School;
+import com.ym.mec.biz.dal.entity.StudentAttendance;
+import com.ym.mec.biz.dal.entity.StudentCourseScheduleRecordDto;
+import com.ym.mec.biz.dal.entity.Subject;
+import com.ym.mec.biz.dal.entity.SysConfig;
+import com.ym.mec.biz.dal.entity.Teacher;
+import com.ym.mec.biz.dal.entity.TeacherAttendance;
+import com.ym.mec.biz.dal.entity.TeacherDefaultMusicGroupSalary;
+import com.ym.mec.biz.dal.entity.TeacherDefaultPracticeGroupSalary;
+import com.ym.mec.biz.dal.entity.TeacherDefaultVipGroupSalary;
+import com.ym.mec.biz.dal.entity.VipGroup;
+import com.ym.mec.biz.dal.enums.AuditStatusEnum;
+import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
+import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
+import com.ym.mec.biz.dal.enums.CourseStatusEnum;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.MessageTypeEnum;
+import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
+import com.ym.mec.biz.dal.enums.ParamEnum;
+import com.ym.mec.biz.dal.enums.SalarySettlementTypeEnum;
+import com.ym.mec.biz.dal.enums.StudentAttendanceStatusEnum;
+import com.ym.mec.biz.dal.enums.TeachModeEnum;
+import com.ym.mec.biz.dal.enums.TeachTypeEnum;
+import com.ym.mec.biz.dal.enums.VipGroupStatusEnum;
+import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.biz.dal.page.CourseScheduleQueryInfo;
 import com.ym.mec.biz.dal.page.EndCourseScheduleQueryInfo;
 import com.ym.mec.biz.dal.page.StudentCourseScheduleRecordQueryInfo;
 import com.ym.mec.biz.dal.page.VipGroupQueryInfo;
-import com.ym.mec.biz.event.source.StudentEventSource;
-import com.ym.mec.biz.service.*;
+import com.ym.mec.biz.service.ClassGroupService;
+import com.ym.mec.biz.service.ClassGroupTeacherMapperService;
+import com.ym.mec.biz.service.CourseHomeworkService;
+import com.ym.mec.biz.service.CourseScheduleService;
+import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
+import com.ym.mec.biz.service.CourseScheduleTeacherSalaryService;
+import com.ym.mec.biz.service.MusicGroupService;
+import com.ym.mec.biz.service.PracticeGroupService;
+import com.ym.mec.biz.service.SysConfigService;
+import com.ym.mec.biz.service.SysMessageService;
+import com.ym.mec.biz.service.VipGroupService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.ImGroupMember;
 import com.ym.mec.common.entity.ImGroupModel;
@@ -29,30 +162,6 @@ import com.ym.mec.util.collection.ListUtil;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.json.JsonUtil;
-import org.apache.commons.collections.ListUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Lazy;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.CollectionUtils;
-
-import java.lang.reflect.InvocationTargetException;
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static com.ym.mec.biz.dal.enums.GroupType.*;
-import static com.ym.mec.biz.dal.enums.PracticeGroupType.*;
 
 @Service
 public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSchedule> implements CourseScheduleService {
@@ -472,13 +581,13 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
 					String dateYmdStr = DateUtil.dateToString(calendar.getTime(), DateUtil.ISO_EXPANDED_DATE_FORMAT);
 
-					dateYmdStr = dateYmdStr + " " + courseTimeDto.getStartClassTime();
-					Date courseStartTime = DateUtil.stringToDate(dateYmdStr, "yyyy-MM-dd HH:mm");
+					String startTimeStr = dateYmdStr + " " + courseTimeDto.getStartClassTime();
+					Date courseStartTime = DateUtil.stringToDate(startTimeStr, "yyyy-MM-dd HH:mm");
 					courseSchedule.setStartClassTime(courseStartTime);
 
 					if (StringUtils.isNotBlank(courseTimeDto.getEndClassTime())) {
-						dateYmdStr = dateYmdStr + " " + courseTimeDto.getEndClassTime();
-						Date courseEndTime = DateUtil.stringToDate(dateYmdStr, "yyyy-MM-dd HH:mm");
+						String endTimeStr = dateYmdStr + " " + courseTimeDto.getEndClassTime();
+						Date courseEndTime = DateUtil.stringToDate(endTimeStr, "yyyy-MM-dd HH:mm");
 						courseSchedule.setEndClassTime(courseEndTime);
 
 						if (courseEndTime.before(courseStartTime)) {
@@ -1750,8 +1859,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                                 ||!preCourseSchedule.getEndClassTime().after(backCourseSchedule.getStartClassTime())) {
                             continue;
                         }
-                        if (!checkExistCourseSchedule
-                                && !courseScheduleIdsSet.contains(backCourseSchedule.getId())) {
+                        if (preCourseSchedule.equals(backCourseSchedule)) {
                             continue;
                         }
 
@@ -2103,7 +2211,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
         newNode:
         for (CourseSchedule newCourseSchedule : courseSchedules) {
-            for (CourseSchedule existCourseSchedule : existCourseSchedules) {
+            for (CourseSchedule existCourseSchedule : allCourseSchedules) {
                 if (newCourseSchedule.getEndClassTime().compareTo(existCourseSchedule.getStartClassTime()) <= 0) {
                     continue newNode;
                 }
@@ -2111,6 +2219,10 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                     continue;
                 }
 
+                if(newCourseSchedule.equals(existCourseSchedule)){
+                	continue;
+				}
+
                 boolean isTeacherRepeat = false;
                 boolean isStudentRepeat = false;
                 //检测老师冲突
@@ -2168,7 +2280,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                     continue;
                 }
 
-                if (existCourseSchedule.getClassGroupType().equals(ClassGroupTypeEnum.SNAP.getCode()) || existCourseSchedule.getClassGroupType().equals(ClassGroupTypeEnum.VIP.getCode())) {
+                if (ClassGroupTypeEnum.SNAP.getCode().equals(existCourseSchedule.getClassGroupType()) || ClassGroupTypeEnum.VIP.getCode().equals(existCourseSchedule.getClassGroupType())) {
                     throw new BizException(courseCheckInfo(newCourseSchedule, existCourseSchedule, existCourseScheduleIds, isTeacherRepeat?1:3));
                 }
 
@@ -2218,13 +2330,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
         errInfo.append("安排的课程存在冲突,");
         errInfo.append("冲突课程为:");
 
-        if (Objects.isNull(preCourseSchedule.getId()) && Objects.isNull(backCourseSchedule.getId())) {
-            errInfo.setLength(0);
-            errInfo.append("您设置的循环周期存在时间冲突");
-            return errInfo.toString();
-        }
-
-        CourseSchedule courseSchedule = new CourseSchedule();
+        CourseSchedule courseSchedule = null;
         if (Objects.nonNull(preCourseSchedule.getId()) && existCourseScheduleIds.contains(preCourseSchedule.getId())) {
             courseSchedule = preCourseSchedule;
         }
@@ -2232,6 +2338,12 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
             courseSchedule = backCourseSchedule;
         }
 
+		if (Objects.isNull(courseSchedule)) {
+			errInfo.setLength(0);
+			errInfo.append("您设置的循环周期存在时间冲突");
+			return errInfo.toString();
+		}
+
         String groupName = "";
 
         if (Objects.nonNull(courseSchedule.getId())) {
@@ -2984,7 +3096,10 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 			// 修改了主教/助教/课程状态,需修改考勤记录
 			List<TeacherAttendance> teacherAttendanceList = teacherAttendanceMap.get(courseScheduleId);
 
-			List<Integer> oldTeacherIdList = teacherAttendanceList.stream().map(TeacherAttendance::getTeacherId).distinct().collect(Collectors.toList());
+			List<Integer> oldTeacherIdList = new ArrayList<Integer>();
+			if(teacherAttendanceList != null){
+				oldTeacherIdList = teacherAttendanceList.stream().map(TeacherAttendance::getTeacherId).distinct().collect(Collectors.toList());
+			}
             List<Integer> newTeacherIdList = new ArrayList<>();
             newTeacherIdList.addAll(newCourseSchedule.getTeachingTeacherIdList());
             newTeacherIdList.add(newCourseSchedule.getActualTeacherId());

+ 26 - 38
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -80,26 +80,18 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 			}
 			existsGood.setStockCount(existsGood.getStockCount()+goods.getStockCount());
 			existsGood.setTaxStockCount(existsGood.getTaxStockCount()+existsGood.getTaxStockCount());
+			existsGood.setSellCount(0);
 			goodsDao.update(existsGood);
 		}else{
+			if(Objects.isNull(goods.getStockCount())){
+				goods.setStockCount(0);
+			}
+			if(Objects.isNull(goods.getTaxStockCount())){
+				goods.setTaxStockCount(0);
+			}
+			goods.setSellCount(0);
 			goodsDao.insert(goods);
-			existsGood=goods;
 		}
-
-		String batchNo = idGeneratorService.generatorId("payment") + "";
-
-		GoodsProcurement gp = new GoodsProcurement();
-		gp.setGoodsId(existsGood.getId());
-		gp.setGoodsCategoryId(goods.getGoodsCategoryId());
-		gp.setSupplyChannel(goods.getSupplyChannel());
-		gp.setDiscountPrice(goods.getDiscountPrice());
-		gp.setAgreeCostPrice(goods.getAgreeCostPrice());
-		gp.setStockCount(goods.getStockCount());
-		gp.setTaxStockCount(goods.getTaxStockCount());
-		gp.setOperatorId(operatorId);
-		gp.setBatchNo(batchNo);
-
-		goodsProcurementDao.insert(gp);
 	}
 
 	@Override
@@ -260,7 +252,8 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 			gp.setGoodsId(existsSnIdMap.get(goods.getSn()));
 			gp.setGoodsCategoryId(goods.getGoodsCategoryId());
 			gp.setSupplyChannel(goods.getSupplyChannel());
-			gp.setDiscountPrice(goods.getDiscountPrice());
+			gp.setDiscountPrice(goods.getCostPrice()
+			);
 			gp.setAgreeCostPrice(goods.getAgreeCostPrice());
 			gp.setStockCount(goods.getStockCount());
 			gp.setTaxStockCount(goods.getTaxStockCount());
@@ -349,8 +342,6 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 			return Collections.emptyList();
 		}
 
-		Map<Integer, Long> goodsSellNumMap = goodsIds.stream().collect(Collectors.groupingBy(s -> s, Collectors.counting()));
-
 		List<Goods> tempGoodsList = goodsDao.lockGoods(new ArrayList<>(goodsIds));
 		Map<Integer, Goods> idTempGoodsMap = tempGoodsList.stream().collect(Collectors.toMap(Goods::getId, g -> g));
 		List<GoodsProcurement> goodsProcurements = new ArrayList<>();
@@ -363,7 +354,6 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 				List<Integer> complementGoodsIds = Arrays.stream(tempGoods.getComplementGoodsIdList().split(",")).map(s -> Integer.valueOf(s)).collect(Collectors.toList());
 				childGoods = goodsDao.getGoodies(complementGoodsIds);
 			}
-			tempGoods.setSellCount((int) (tempGoods.getSellCount() + goodsSellNumMap.get(tempGoods.getId())));
 			for (Goods goods : childGoods) {
 				GoodsProcurement goodsProcurement = null;
 				if(StockType.INTERNAL.equals(goods.getStockType())||(StockType.ALL.equals(goods.getStockType())&&AccountType.INTERNAL.equals(accountType))){
@@ -380,6 +370,8 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 					}
 				}
 
+				goods.setSellCount(new AtomicInteger(goods.getSellCount()).incrementAndGet());
+
 				goodsDao.update(goods);
 				if(Objects.nonNull(goodsProcurement)){
 					goodsProcurementDao.update(goodsProcurement);
@@ -392,9 +384,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 
 				goodsProcurements.add(goodsProcurement);
 			}
-//			goodsDao.update(tempGoods);
 		}
-		goodsDao.batchUpdate(tempGoodsList);
 
 		List<SellOrder> sellOrders = new ArrayList<>();
 
@@ -413,6 +403,12 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 					sellOrder.setBatchNo(batchNoGoodsIdMapEntry.getKey());
 					GoodsProcurement goodsProcurement = goodsProcurementDao.getWithGoodsAndBatchNo(sellOrder.getGoodsId(), sellOrder.getBatchNo());
 					sellOrder.setSellCost(goodsProcurement.getDiscountPrice().multiply(new BigDecimal(sellOrder.getNum())));
+					Map<String, BigDecimal> CostMap = new HashMap<>();
+					CostMap.put("sellCost", goodsProcurement.getDiscountPrice());
+					if (Objects.nonNull(goodsProcurement.getAgreeCostPrice())) {
+						CostMap.put("SellCost2", goodsProcurement.getAgreeCostPrice());
+					}
+					sellOrder.setSellCost2(JSON.toJSONString(CostMap));
 					sellOrders.add(sellOrder);
 				}
 			}
@@ -431,6 +427,12 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 				sellOrder.setBatchNo(goodsProcurement.getBatchNo());
 				if(Objects.nonNull(goodsProcurement.getBatchNo())){
 					sellOrder.setSellCost(goodsProcurement.getDiscountPrice().multiply(new BigDecimal(sellOrder.getNum())));
+					Map<String, BigDecimal> CostMap = new HashMap<>();
+					CostMap.put("sellCost", goodsProcurement.getDiscountPrice());
+					if (Objects.nonNull(goodsProcurement.getAgreeCostPrice())) {
+						CostMap.put("SellCost2", goodsProcurement.getAgreeCostPrice());
+					}
+					sellOrder.setSellCost2(JSON.toJSONString(CostMap));
 				}
 				sellOrders.add(sellOrder);
 			}
@@ -455,9 +457,6 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 			}
 		});
 
-		List<Goods> goodsList = goodsDao.lockGoods(new ArrayList<>(goodsIdList));
-		Map<Integer, Goods> idGoodsMap = goodsList.stream().collect(Collectors.toMap(Goods::getId, g -> g));
-
 		for (SellOrder sellOrder : sellOrders) {
 			Goods goods = goodsDao.get(sellOrder.getGoodsId());
 			GoodsProcurement goodsProcurement = goodsProcurementDao.getWithGoodsAndBatchNo(sellOrder.getGoodsId(), sellOrder.getBatchNo());
@@ -472,21 +471,10 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 					goodsProcurement.setTaxStockSoldNum(new AtomicInteger(goodsProcurement.getTaxStockSoldNum()).addAndGet(-sellOrder.getNum()));
 				}
 			}
-			if(Objects.isNull(sellOrder.getParentGoodsId())){
-				goods.setSellCount(new AtomicInteger(goods.getSellCount()).addAndGet(-sellOrder.getNum()));
-			}
-			goodsDao.update(goods);
-			goodsProcurementDao.update(goodsProcurement);
-		}
+			goods.setSellCount(new AtomicInteger(goods.getSellCount()).addAndGet(-sellOrder.getNum()));
 
-		//处理组合商品
-		Map<Integer, Long> goodsNumMap = sellOrders.stream().filter(so -> Objects.nonNull(so.getParentGoodsId())).collect(Collectors.groupingBy(SellOrder::getParentGoodsId, Collectors.counting()));
-		for (Map.Entry<Integer, Long> goodsIdNumMapEntry : goodsNumMap.entrySet()) {
-			Goods goods = idGoodsMap.get(goodsIdNumMapEntry.getKey());
-			int childGoodsNum = sellOrders.stream().filter(so -> goodsIdNumMapEntry.getKey().equals(so.getParentGoodsId())).map(SellOrder::getGoodsId).collect(Collectors.toSet()).size();
-			int sellNum = (int) (goodsIdNumMapEntry.getValue()/childGoodsNum);
-			goods.setSellCount(new AtomicInteger(goods.getSellCount()).addAndGet(-sellNum));
 			goodsDao.update(goods);
+			goodsProcurementDao.update(goodsProcurement);
 		}
 	}
 

+ 21 - 24
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -136,14 +136,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         if (studentId == null) {
             throw new BizException("请指定学员");
         }
-        List<Integer> goodsIds = goodsSellDtos.stream().map(e -> e.getGoodsId()).collect(Collectors.toList());
-        Map<Integer, String> integerStringMap = getMap("goods", "id_", "type_", goodsIds, Integer.class, String.class);
-        goodsSellDtos.forEach(e->{
-            e.setGoodsType(integerStringMap.get(e.getGoodsId()));
-            if(StringUtils.isNotEmpty(e.getComplementGoodsIdList())){
-                e.setGoodsSellDtos(goodsService.queryGoodsSellDtos(e.getComplementGoodsIdList()));
-            }
-        });
+
         studentDao.lockUser(studentId);
         SysUser student = sysUserFeignService.queryUserById(studentId);
         //如果教务老师为空,代表学员自己创建的订单
@@ -165,9 +158,14 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
                 studentGoodsSell.setCooperationOrganId(musicGroup.getCooperationOrganId());
             }
         }
-
-        Map<Integer, BigDecimal> map = getMap("goods", "id_", "market_price_", goodsIds, Integer.class, BigDecimal.class);
+        List<Integer> goodsIds = goodsSellDtos.stream().map(e -> e.getGoodsId()).collect(Collectors.toList());
+        Map<Integer, String> integerStringMap = getMap("goods", "id_", "type_", goodsIds, Integer.class, String.class);
+        Map<Integer, BigDecimal> map = getMap("goods", "id_", "discount_price_", goodsIds, Integer.class, BigDecimal.class);
         for (GoodsSellDto goodsSellDto : goodsSellDtos) {
+            goodsSellDto.setGoodsType(integerStringMap.get(goodsSellDto.getGoodsId()));
+            if(StringUtils.isNotEmpty(goodsSellDto.getComplementGoodsIdList())){
+                goodsSellDto.setGoodsSellDtos(goodsService.queryGoodsSellDtos(goodsSellDto.getComplementGoodsIdList()));
+            }
             goodsSellDto.setGoodsPrice(map.get(goodsSellDto.getGoodsId()));
             goodsSellDto.setTotalGoodsPrice(map.get(goodsSellDto.getGoodsId()).multiply(new BigDecimal(goodsSellDto.getGoodsNum())));
         }
@@ -790,12 +788,13 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         //获取组合商品列表
         List<SellOrder> orderList = sellOrderList.stream().filter(sellOrder -> sellOrder.getParentGoodsId() != null).collect(Collectors.toList());
         Map<Integer, List<SellOrder>> orderListMap = orderList.stream().collect(Collectors.groupingBy(SellOrder::getParentGoodsId));
+
         //获取组合商品实际销售价,和单个商品总和价
         for (Integer integer : orderListMap.keySet()) {
             SellOrder sellOrder = orderListMap.get(integer).get(0);
             //获取组合商品销售总价
             GoodsSellDto goodsSellDto = collect.get(sellOrder.getParentGoodsId()).get(0);
-            BigDecimal parentTotalGoodsPrice = goodsSellDto.getTotalGoodsPrice();
+            BigDecimal parentTotalGoodsPrice = goodsSellDto.getTotalGoodsPrice().divide(new BigDecimal(goodsSellDto.getGoodsNum()));
             BigDecimal totalGoodsPrice = BigDecimal.ZERO;
             //获取单个商品销售总价
             for (GoodsSellDto sellDto : goodsSellDto.getGoodsSellDtos()) {
@@ -818,22 +817,20 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
 
             //获取组合商品销售总价
             GoodsSellDto goodsSellDto = collect.get(parentGoodsId).get(0);
-            BigDecimal divide = goodsSellDto.getTotalGoodsPrice();
+            BigDecimal divide = goodsSellDto.getGoodsPrice();
 
             //获取子商品明细map
             List<GoodsSellDto> sellDtos = goodsSellDto.getGoodsSellDtos();
             Map<Integer, List<GoodsSellDto>> subGoodsMap = sellDtos.stream().collect(Collectors.groupingBy(GoodsSellDto::getGoodsId));
-
-            List<SellOrder> sellOrders = orderListMap.get(parentGoodsId);
-            for (int i = 0; i < sellOrders.size(); i++) {
-                SellOrder sellOrder = sellOrders.get(i);
-                GoodsSellDto sellDto = subGoodsMap.get(sellOrder.getGoodsId()).get(0);
+            List<Integer> integers = new ArrayList<>(subGoodsMap.keySet());
+            for (int i = 0; i < integers.size(); i++) {
+                GoodsSellDto sellDto = subGoodsMap.get(integers.get(i)).get(0);
                 //获取比例
-                BigDecimal ratioAmount = sellDto.getTotalGoodsPrice().divide(divide, 2, BigDecimal.ROUND_HALF_UP);
+                BigDecimal ratioAmount = sellDto.getTotalGoodsPrice().divide(divide, 6, BigDecimal.ROUND_HALF_UP);
 
                 if(addTotalPrice.doubleValue() > 0l){
                     //如果是最后一件商品
-                    if(i == sellOrders.size() - 1){
+                    if(i == integers.size() - 1){
                         sellDto.setTotalGoodsPrice(sellDto.getTotalGoodsPrice().add(usableParentGoodsAddTotalPrice));
                     }else {
                         //获取分配的附加
@@ -844,7 +841,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
                     sellDto.setGoodsPrice(sellDto.getTotalGoodsPrice());
                 }else if(cutTotalPrice.doubleValue() > 0l){
                     //如果是最后一件商品
-                    if(i == sellOrders.size() - 1){
+                    if(i == integers.size() - 1){
                         sellDto.setTotalGoodsPrice(sellDto.getTotalGoodsPrice().subtract(usableParentGoodsCutTotalPrice));
                     }else {
                         //获取分配的组合减免金额
@@ -881,18 +878,18 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             if (goods.getAgreeCostPrice() != null) {
                 costMap.put("SellCost2", goods.getAgreeCostPrice());
             }
-            goodsSellDto.setTotalGoodsPrice(goodsSellDto.getGoodsPrice().multiply(new BigDecimal(sellOrder.getNum())));
+            BigDecimal multiply2 = goodsSellDto.getGoodsPrice().multiply(new BigDecimal(sellOrder.getNum()));
             //获取比例
-            BigDecimal ratioAmount = goodsSellDto.getTotalGoodsPrice().divide(totalAmount, 2, BigDecimal.ROUND_HALF_UP);
+            BigDecimal ratioAmount = multiply2.divide(totalAmount, 6, BigDecimal.ROUND_HALF_UP);
             //如果有减免金额
             if(marketAmount.doubleValue() > 0l){
                 //如果是最后一件商品
                 if(i == sellOrderList.size() - 1){
-                    goodsSellDto.setTotalGoodsPrice(goodsSellDto.getTotalGoodsPrice().subtract(usableMarketAmount));
+                    goodsSellDto.setTotalGoodsPrice(multiply2.subtract(usableMarketAmount));
                 }else {
                     //获取分配的减免金额
                     BigDecimal multiply = ratioAmount.multiply(marketAmount).setScale(2,BigDecimal.ROUND_HALF_UP);
-                    goodsSellDto.setTotalGoodsPrice(goodsSellDto.getTotalGoodsPrice().subtract(multiply));
+                    goodsSellDto.setTotalGoodsPrice(multiply2.subtract(multiply));
                     usableMarketAmount = usableMarketAmount.subtract(multiply);
                 }
             }

+ 13 - 4
mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml

@@ -55,24 +55,27 @@
         INSERT INTO goods
         (goods_category_id_,sn_,name_,brand_,specification_,image_,stock_count_,tax_stock_count_,sell_count_,market_price_,
         discount_price_,group_purchase_price_,brief_,desc_,is_new_,is_top_,status_,memo_,publish_time_,
-        complement_goods_id_list_,update_time_,create_time_,type_,agree_cost_price_,client_show_,stock_warning_)
+        complement_goods_id_list_,update_time_,create_time_,type_,agree_cost_price_,client_show_,stock_warning_,stock_type_)
         VALUES(#{goodsCategoryId},#{sn},#{name},#{brand},#{specification},#{image},#{stockCount},#{taxStockCount},#{sellCount},#{marketPrice},
         #{discountPrice},#{groupPurchasePrice},#{brief},#{desc},
         #{isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{memo},#{publishTime},#{complementGoodsIdList},now(),now(),#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{agreeCostPrice},
-        #{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
+        #{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+        #{stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
     </insert>
     <insert id="batchInsert">
         INSERT INTO goods
         (goods_category_id_,name_,brand_,specification_,image_,market_price_,
         discount_price_,group_purchase_price_,brief_,desc_,update_time_,create_time_,type_,agree_cost_price_,sn_,
-        stock_count_,tax_stock_count_,client_show_,stock_warning_)
+        stock_count_,tax_stock_count_,client_show_,stock_warning_,stock_type_)
         VALUES
         <foreach collection="goodsList" separator="," item="goods">
             (#{goods.goodsCategoryId},#{goods.name},#{goods.brand},#{goods.specification},#{goods.image},#{goods.marketPrice},
             #{goods.discountPrice},#{goods.groupPurchasePrice},#{goods.brief},#{goods.desc},now(),now(),
             #{goods.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{goods.agreeCostPrice},#{goods.sn},
-            #{goods.stockCount},#{goods.taxStockCount},#{goods.clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{goods.stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
+            #{goods.stockCount},#{goods.taxStockCount},#{goods.clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+            #{goods.stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+            #{goods.stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
         </foreach>
     </insert>
     <!-- 根据主键查询一条记录 -->
@@ -151,6 +154,9 @@
             <if test="stockWarning != null">
                 stock_warning_ = #{stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>
+            <if test="stockType != null">
+                stock_type_ = #{stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+            </if>
                 update_time_ = NOW()
         </set>
         WHERE id_ = #{id}
@@ -232,6 +238,9 @@
                 <if test="goods.stockWarning != null">
                     stock_warning_ = #{goods.stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
                 </if>
+                <if test="goods.stockType != null">
+                    stock_type_ = #{goods.stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+                </if>
                     update_time_ = NOW()
             </set>
             WHERE id_ = #{goods.id}

+ 4 - 2
mec-web/src/main/resources/columnMapper.ini

@@ -5,9 +5,10 @@
 商品类型 = type
 商品分类 = goodsCategoryName
 具体型号 = specification
-商品价格(元) = marketPrice
+商品市场价(元) = marketPrice
+商品零售价 = discountPrice
 商品团购价(元) = groupPurchasePrice
-商品采购价1(元) = discountPrice
+商品采购价1(元) = costPrice
 商品图片(插入一张图片) = image
 商品明细 = desc
 商品采购价2(元) = agreeCostPrice
@@ -19,6 +20,7 @@
 商品详情 = desc
 库存预警 = stockWarning
 
+
 [财务支出导入模板]
 财务流程编号 = financialProcessNo
 钉钉流程编号 = dingtalkProcessNo

二进制
mec-web/src/main/resources/excelTemplate/商品导入模板.xls