|  | @@ -0,0 +1,327 @@
 | 
	
		
			
				|  |  | +package com.ym.mec.biz.service.impl;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import com.ym.mec.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  | +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.enums.*;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.page.ChildrenReserveQueryInfo;
 | 
	
		
			
				|  |  | +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.service.IdGeneratorService;
 | 
	
		
			
				|  |  | +import com.ym.mec.common.service.impl.BaseServiceImpl;
 | 
	
		
			
				|  |  | +import com.ym.mec.util.collection.MapUtil;
 | 
	
		
			
				|  |  | +import com.ym.mec.util.date.DateUtil;
 | 
	
		
			
				|  |  | +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.*;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import java.util.List;
 | 
	
		
			
				|  |  | +import java.util.stream.Collectors;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +@Service
 | 
	
		
			
				|  |  | +public class ChildrenDayReserveServiceImpl extends BaseServiceImpl<Integer, ChildrenDayReserve> implements ChildrenDayReserveService {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ChildrenDayReserveDao childrenDayReserveDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private MusicGroupDao musicGroupDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private DegreeLevelFeeDao degreeLevelFeeDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private OrganizationDegreeCourseFeeDao organizationDegreeCourseFeeDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private StudentDao studentDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ChildrenDayDegreeDetailService childrenDayDegreeDetailService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private StudentPaymentOrderService studentPaymentOrderService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private SysConfigDao sysConfigDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private IdGeneratorService idGeneratorService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private PayService payService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public BaseDAO<Integer, ChildrenDayReserve> getDAO() {
 | 
	
		
			
				|  |  | +        return childrenDayReserveDao;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public ChildrenDayReserve addReserve(SysUser user, YesOrNoEnum status) {
 | 
	
		
			
				|  |  | +        Date nowTime = new Date();
 | 
	
		
			
				|  |  | +        String startTimeStr = sysConfigDao.findConfigValue("children_day_start_time");
 | 
	
		
			
				|  |  | +        Date startTime = DateUtil.stringToDate(startTimeStr);
 | 
	
		
			
				|  |  | +        if (startTime.compareTo(nowTime) > 0) {
 | 
	
		
			
				|  |  | +            throw new BizException("活动还未开始,谢谢关注");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        String endTimeStr = sysConfigDao.findConfigValue("children_day_end_time");
 | 
	
		
			
				|  |  | +        Date endTime = DateUtil.stringToDate(endTimeStr);
 | 
	
		
			
				|  |  | +        if (endTime.compareTo(nowTime) <= 0) {
 | 
	
		
			
				|  |  | +            throw new BizException("活动已结束,谢谢关注");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        ChildrenDayReserve hasOne = childrenDayReserveDao.getByUserId(user.getId());
 | 
	
		
			
				|  |  | +        if (hasOne != null) {
 | 
	
		
			
				|  |  | +            throw new BizException("您已预报名");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        studentDao.lockUser(user.getId());
 | 
	
		
			
				|  |  | +        MusicGroup studentLastMusicGroup = musicGroupDao.getStudentLastMusicGroup(user.getId());
 | 
	
		
			
				|  |  | +        ChildrenDayReserve childrenDayReserve = new ChildrenDayReserve();
 | 
	
		
			
				|  |  | +        childrenDayReserve.setUserId(user.getId());
 | 
	
		
			
				|  |  | +        childrenDayReserve.setOrganId(user.getOrganId());
 | 
	
		
			
				|  |  | +        childrenDayReserve.setIsReserve(status);
 | 
	
		
			
				|  |  | +        if (studentLastMusicGroup != null) {
 | 
	
		
			
				|  |  | +            childrenDayReserve.setCooperationOrganId(studentLastMusicGroup.getCooperationOrganId());
 | 
	
		
			
				|  |  | +            childrenDayReserve.setMusicGroupId(studentLastMusicGroup.getId());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        childrenDayReserveDao.insert(childrenDayReserve);
 | 
	
		
			
				|  |  | +        return childrenDayReserve;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public ChildrenDayReserve getUserReserve(Integer userId) {
 | 
	
		
			
				|  |  | +        return childrenDayReserveDao.getByUserId(userId);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public PageInfo<ChildrenStatisticsDto> queryStatisticsPage(ChildrenReserveQueryInfo queryInfo) {
 | 
	
		
			
				|  |  | +        PageInfo<ChildrenStatisticsDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
 | 
	
		
			
				|  |  | +        Map<String, Object> params = new HashMap<String, Object>();
 | 
	
		
			
				|  |  | +        MapUtil.populateMap(params, queryInfo);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<ChildrenStatisticsDto> dataList = null;
 | 
	
		
			
				|  |  | +        int count = childrenDayReserveDao.countChildrenStatistics(params);
 | 
	
		
			
				|  |  | +        if (count > 0) {
 | 
	
		
			
				|  |  | +            pageInfo.setTotal(count);
 | 
	
		
			
				|  |  | +            params.put("offset", pageInfo.getOffset());
 | 
	
		
			
				|  |  | +            dataList = childrenDayReserveDao.queryChildrenStatistics(params);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (count == 0) {
 | 
	
		
			
				|  |  | +            dataList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        pageInfo.setRows(dataList);
 | 
	
		
			
				|  |  | +        return pageInfo;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public DegreeFeeDto getFeeInfo(Integer organId) {
 | 
	
		
			
				|  |  | +        List<DegreeLevelFee> degreeLevelFee = degreeLevelFeeDao.getAll();
 | 
	
		
			
				|  |  | +        OrganizationDegreeCourseFee courseFee = organizationDegreeCourseFeeDao.getByOrganId(organId);
 | 
	
		
			
				|  |  | +        DegreeFeeDto degreeFeeDto = new DegreeFeeDto();
 | 
	
		
			
				|  |  | +        degreeFeeDto.setDegreeLevelFee(degreeLevelFee);
 | 
	
		
			
				|  |  | +        degreeFeeDto.setOrganizationDegreeCourseFee(courseFee);
 | 
	
		
			
				|  |  | +        return degreeFeeDto;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public PageInfo<ChildrenStatisticsDetailDto> queryStatisticsDetailPage(ChildrenReserveQueryInfo queryInfo) {
 | 
	
		
			
				|  |  | +        PageInfo<ChildrenStatisticsDetailDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
 | 
	
		
			
				|  |  | +        Map<String, Object> params = new HashMap<String, Object>();
 | 
	
		
			
				|  |  | +        MapUtil.populateMap(params, queryInfo);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<ChildrenStatisticsDetailDto> dataList = null;
 | 
	
		
			
				|  |  | +        int count = childrenDayReserveDao.countChildrenStatisticsDetail(params);
 | 
	
		
			
				|  |  | +        if (count > 0) {
 | 
	
		
			
				|  |  | +            pageInfo.setTotal(count);
 | 
	
		
			
				|  |  | +            params.put("offset", pageInfo.getOffset());
 | 
	
		
			
				|  |  | +            dataList = childrenDayReserveDao.queryChildrenStatisticsDetail(params);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (count == 0) {
 | 
	
		
			
				|  |  | +            dataList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        pageInfo.setRows(dataList);
 | 
	
		
			
				|  |  | +        return pageInfo;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | +    public Map pay(DegreePayDto degreePayDto) throws Exception {
 | 
	
		
			
				|  |  | +        studentDao.lockUser(degreePayDto.getUserId());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (degreePayDto.getTheoryLevel() != null && !degreePayDto.getTheoryCourse()) {
 | 
	
		
			
				|  |  | +            throw new BizException("参加乐理考试,请选乐理考级专项训练课");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //检查进行中的订单
 | 
	
		
			
				|  |  | +        List<ChildrenDayDegreeDetail> details = childrenDayDegreeDetailService.getByUserIdAndStatus(degreePayDto.getUserId(), 1);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //处理关闭订单
 | 
	
		
			
				|  |  | +        if (details.size() > 0 && degreePayDto.getRePay()) {
 | 
	
		
			
				|  |  | +            Long orderId = details.get(0).getOrderId();
 | 
	
		
			
				|  |  | +            StudentPaymentOrder oldOrder = studentPaymentOrderService.get(orderId);
 | 
	
		
			
				|  |  | +            if (oldOrder != null) {
 | 
	
		
			
				|  |  | +                oldOrder.setStatus(DealStatusEnum.FAILED);
 | 
	
		
			
				|  |  | +                oldOrder.setMemo("用户手动关闭");
 | 
	
		
			
				|  |  | +                studentPaymentOrderService.callOrderCallBack(oldOrder);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //检查已经购买的课程(不能重复)
 | 
	
		
			
				|  |  | +        details = childrenDayDegreeDetailService.getByUserIdAndStatus(degreePayDto.getUserId(), 2);
 | 
	
		
			
				|  |  | +        Set<Integer> detailTypes = details.stream().map(ChildrenDayDegreeDetail::getType).collect(Collectors.toSet());
 | 
	
		
			
				|  |  | +        if (degreePayDto.getVip1v1() && detailTypes.contains(3)) {
 | 
	
		
			
				|  |  | +            throw new BizException("您已购买过VIP 1V1课程,请勿重复选择");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (degreePayDto.getVip1v2() && detailTypes.contains(4)) {
 | 
	
		
			
				|  |  | +            throw new BizException("您已购买过VIP 1V2课程,请勿重复选择");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (degreePayDto.getTheoryCourse() && detailTypes.contains(5)) {
 | 
	
		
			
				|  |  | +            throw new BizException("您已购买过乐理考级专项训练课,请勿重复选择");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //检查器乐考级等级是否重复
 | 
	
		
			
				|  |  | +        if (degreePayDto.getMusicGradeLevel() != null) {
 | 
	
		
			
				|  |  | +            if (degreePayDto.getSubject() == null) {
 | 
	
		
			
				|  |  | +                throw new BizException("请选择考级声部");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            List<ChildrenDayDegreeDetail> hasList = details.stream().filter(e -> e.getType().equals(1)).filter(e -> e.getSubjectId().equals(degreePayDto.getSubject()))
 | 
	
		
			
				|  |  | +                    .filter(e -> e.getLevel().equals(degreePayDto.getMusicGradeLevel())).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +            if (hasList.size() > 0) {
 | 
	
		
			
				|  |  | +                throw new BizException("您已报考同声部同等级,请勿重复报考");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //检查乐理考级等级是否重复
 | 
	
		
			
				|  |  | +        if (degreePayDto.getTheoryLevel() != null) {
 | 
	
		
			
				|  |  | +            List<ChildrenDayDegreeDetail> hasList = details.stream().filter(e -> e.getType().equals(2))
 | 
	
		
			
				|  |  | +                    .filter(e -> e.getLevel().equals(degreePayDto.getMusicGradeLevel())).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +            if (hasList.size() > 0) {
 | 
	
		
			
				|  |  | +                throw new BizException("您已报考同等级乐理,请勿重复报考");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        ChildrenDayReserve userReserve = this.getUserReserve(degreePayDto.getUserId());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (userReserve == null) {
 | 
	
		
			
				|  |  | +            userReserve = this.addReserve(degreePayDto.getUser(), YesOrNoEnum.NO);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        degreePayDto.setReserveId(userReserve.getId());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //获取课程的价格
 | 
	
		
			
				|  |  | +        OrganizationDegreeCourseFee courseFee = organizationDegreeCourseFeeDao.getByOrganId(degreePayDto.getOrganId());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (courseFee == null) {
 | 
	
		
			
				|  |  | +            throw new BizException("刚前分部不参与,谢谢关注");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<DegreeLevelFee> degreeLevelFees = degreeLevelFeeDao.getAll();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //订单总金额
 | 
	
		
			
				|  |  | +        BigDecimal orderAmount = BigDecimal.ZERO;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //器乐考级费用
 | 
	
		
			
				|  |  | +        BigDecimal gradeFee = BigDecimal.ZERO;
 | 
	
		
			
				|  |  | +        if (degreePayDto.getMusicGradeLevel() != null) {
 | 
	
		
			
				|  |  | +            gradeFee = degreeLevelFees.stream().filter(e -> e.getLevel().equals(degreePayDto.getMusicGradeLevel())).map(DegreeLevelFee::getGrade).reduce(BigDecimal.ZERO, BigDecimal::add);
 | 
	
		
			
				|  |  | +            orderAmount = orderAmount.add(gradeFee);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //乐理考级费用
 | 
	
		
			
				|  |  | +        BigDecimal theoryLevelFee = BigDecimal.ZERO;
 | 
	
		
			
				|  |  | +        if (degreePayDto.getTheoryLevel() != null) {
 | 
	
		
			
				|  |  | +            theoryLevelFee = degreeLevelFees.stream().filter(e -> e.getLevel().equals(degreePayDto.getTheoryLevel())).map(DegreeLevelFee::getTheory).reduce(BigDecimal.ZERO, BigDecimal::add);
 | 
	
		
			
				|  |  | +            orderAmount = orderAmount.add(theoryLevelFee);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //VIP 1v1 1v2费用
 | 
	
		
			
				|  |  | +        BigDecimal vip1v1Fee = BigDecimal.ZERO;
 | 
	
		
			
				|  |  | +        if (degreePayDto.getVip1v1()) {
 | 
	
		
			
				|  |  | +            vip1v1Fee = courseFee.getVip1v1();
 | 
	
		
			
				|  |  | +            orderAmount = orderAmount.add(vip1v1Fee);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //VIP 1v2费用
 | 
	
		
			
				|  |  | +        BigDecimal vip1v2Fee = BigDecimal.ZERO;
 | 
	
		
			
				|  |  | +        if (degreePayDto.getVip1v2()) {
 | 
	
		
			
				|  |  | +            vip1v2Fee = courseFee.getVip1v2();
 | 
	
		
			
				|  |  | +            orderAmount = orderAmount.add(vip1v2Fee);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //乐理课费用
 | 
	
		
			
				|  |  | +        BigDecimal theoryCourseFee = BigDecimal.ZERO;
 | 
	
		
			
				|  |  | +        if (degreePayDto.getTheoryCourse()) {
 | 
	
		
			
				|  |  | +            theoryCourseFee = courseFee.getTheory();
 | 
	
		
			
				|  |  | +            orderAmount = orderAmount.add(theoryCourseFee);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (orderAmount.compareTo(degreePayDto.getAmount()) != 0) {
 | 
	
		
			
				|  |  | +            throw new BizException("价格不符,请核查");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String channelType = "";
 | 
	
		
			
				|  |  | +        Date nowDate = new Date();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        BigDecimal balance = BigDecimal.ZERO;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String orderNo = idGeneratorService.generatorId("payment") + "";
 | 
	
		
			
				|  |  | +        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setPaymentChannel("BALANCE");
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setUserId(degreePayDto.getUserId());
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setGroupType(GroupType.DEGREE);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setOrderNo(orderNo);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setType(OrderTypeEnum.DEGREE);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setExpectAmount(orderAmount);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setActualAmount(orderAmount);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setBalancePaymentAmount(balance);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setStatus(DealStatusEnum.ING);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setRemitFee(BigDecimal.ZERO);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setCourseRemitFee(BigDecimal.ZERO);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setOrganId(degreePayDto.getOrganId());
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setRoutingOrganId(degreePayDto.getOrganId());
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setCreateTime(nowDate);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setUpdateTime(nowDate);
 | 
	
		
			
				|  |  | +        studentPaymentOrderService.insert(studentPaymentOrder);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //添加购买详情
 | 
	
		
			
				|  |  | +        degreePayDto.setOrderId(studentPaymentOrder.getId());
 | 
	
		
			
				|  |  | +        childrenDayDegreeDetailService.addDegreeDetails(degreePayDto, gradeFee, theoryLevelFee, vip1v1Fee, vip1v2Fee, theoryCourseFee);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setVersion(0);
 | 
	
		
			
				|  |  | +        if (orderAmount.compareTo(BigDecimal.ZERO) == 0) {
 | 
	
		
			
				|  |  | +            studentPaymentRouteOrderService.addRouteOrder(orderNo, degreePayDto.getOrganId(), balance);
 | 
	
		
			
				|  |  | +            Map<String, String> notifyMap = new HashMap<>();
 | 
	
		
			
				|  |  | +            notifyMap.put("tradeState", "1");
 | 
	
		
			
				|  |  | +            notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
 | 
	
		
			
				|  |  | +            notifyMap.put("channelType", channelType);
 | 
	
		
			
				|  |  | +            notifyMap.put("orderNo", "");
 | 
	
		
			
				|  |  | +            studentPaymentOrderService.updateOrder(notifyMap);
 | 
	
		
			
				|  |  | +            return notifyMap;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String orderSubject = "6.1考级活动";
 | 
	
		
			
				|  |  | +        String receiver = "degree";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        Map payMap = payService.getPayMap(
 | 
	
		
			
				|  |  | +                orderAmount,
 | 
	
		
			
				|  |  | +                balance,
 | 
	
		
			
				|  |  | +                orderNo,
 | 
	
		
			
				|  |  | +                baseApiUrl + "/api-student/studentOrder/notify",
 | 
	
		
			
				|  |  | +                baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
 | 
	
		
			
				|  |  | +                orderSubject,
 | 
	
		
			
				|  |  | +                orderSubject,
 | 
	
		
			
				|  |  | +                degreePayDto.getOrganId(),
 | 
	
		
			
				|  |  | +                receiver
 | 
	
		
			
				|  |  | +        );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setOrganId(degreePayDto.getOrganId());
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setUpdateTime(nowDate);
 | 
	
		
			
				|  |  | +        studentPaymentOrderService.update(studentPaymentOrder);
 | 
	
		
			
				|  |  | +        return payMap;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +}
 |