|
@@ -1,28 +1,37 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.ym.mec.biz.dal.dao.ActivityUserMapperDao;
|
|
|
+import com.ym.mec.biz.dal.dao.VipGroupActivityDao;
|
|
|
import com.ym.mec.biz.dal.dto.ActivityQueryDto;
|
|
|
+import com.ym.mec.biz.dal.dto.ActivityStudentAdjustDto;
|
|
|
import com.ym.mec.biz.dal.dto.ActivityStudentDto;
|
|
|
import com.ym.mec.biz.dal.entity.ActivityUserMapper;
|
|
|
+import com.ym.mec.biz.dal.entity.VipGroupActivity;
|
|
|
import com.ym.mec.biz.dal.page.ActivityStudentQueryInfo;
|
|
|
import com.ym.mec.biz.service.ActivityUserMapperService;
|
|
|
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.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class ActivityUserMapperServiceImpl extends BaseServiceImpl<Integer, ActivityUserMapper> implements ActivityUserMapperService {
|
|
|
|
|
|
@Autowired
|
|
|
private ActivityUserMapperDao activityUserMapperDao;
|
|
|
+ @Autowired
|
|
|
+ private VipGroupActivityDao vipGroupActivityDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, ActivityUserMapper> getDAO() {
|
|
@@ -78,4 +87,63 @@ public class ActivityUserMapperServiceImpl extends BaseServiceImpl<Integer, Acti
|
|
|
pageInfo.setRows(dataList);
|
|
|
return pageInfo;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void add(List<ActivityStudentAdjustDto> activityStudentAdjustDtos) {
|
|
|
+ if(activityStudentAdjustDtos == null || activityStudentAdjustDtos.size() == 0){
|
|
|
+ throw new BizException("请选择学员");
|
|
|
+ }
|
|
|
+ Integer activityId = activityStudentAdjustDtos.get(0).getActivityId();
|
|
|
+ VipGroupActivity activity = vipGroupActivityDao.get(activityId);
|
|
|
+ if(activity == null){
|
|
|
+ throw new BizException("活动信息不存在");
|
|
|
+ }
|
|
|
+ if(activity.getActivityType() != 1){
|
|
|
+ throw new BizException("操作失败:只有课程活动支持此操作");
|
|
|
+ }
|
|
|
+ List<Integer> studentIds = activityStudentAdjustDtos.stream().map(e -> e.getUserId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ String courseType = activity.getCourseType();
|
|
|
+ Integer giveCourseNum = activity.getGiveCourseNum();
|
|
|
+ String giveCourseType = activity.getGiveCourseType();
|
|
|
+ List<ActivityUserMapper> activityUserMappers = new ArrayList<>();
|
|
|
+ for (ActivityStudentAdjustDto adjustDto : activityStudentAdjustDtos) {
|
|
|
+ int activityUserMapperNum = adjustDto.getCourseNum();
|
|
|
+ if(giveCourseNum != null && giveCourseNum > 0){
|
|
|
+ if(adjustDto.getGiveCourseNum() > activityUserMapperNum){
|
|
|
+ activityUserMapperNum = adjustDto.getGiveCourseNum();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(activityUserMapperNum <= 0){
|
|
|
+ throw new BizException("操作失败:加课次数不可为空");
|
|
|
+ }
|
|
|
+ for (int i = 0; i < activityUserMapperNum; i++) {
|
|
|
+ ActivityUserMapper activityUserMapper = new ActivityUserMapper();
|
|
|
+ activityUserMapper.setActivityId(activityId);
|
|
|
+ activityUserMapper.setUserId(adjustDto.getUserId());
|
|
|
+ activityUserMapper.setActualPrice(BigDecimal.ZERO);
|
|
|
+ activityUserMapper.setReturnFee(false);
|
|
|
+// activityUserMapper.setTeacherId();
|
|
|
+ if("VIP".equals(courseType)){
|
|
|
+ activityUserMapper.setVipFlag(1);
|
|
|
+ }else {
|
|
|
+ activityUserMapper.setPracticeFlag(1);
|
|
|
+ }
|
|
|
+ if(giveCourseNum != null && giveCourseNum > 0){
|
|
|
+ if("VIP".equals(giveCourseType)){
|
|
|
+ activityUserMapper.setGiveVipFlag(1);
|
|
|
+ }else {
|
|
|
+ activityUserMapper.setGivePracticeFlag(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void cut(Integer activityUserMapperId, String memo) {
|
|
|
+
|
|
|
+ }
|
|
|
}
|