|  | @@ -11,22 +11,26 @@ import java.util.List;
 | 
	
		
			
				|  |  |  import java.util.Map;
 | 
	
		
			
				|  |  |  import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dao.*;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.service.*;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  |  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 com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.GoodsDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.StudentPaymentRouteOrderDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.SysConfigDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.PageInfoOrder;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.SporadicChargeInfoDto;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.StudentPaymentOrderDto;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.Goods;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.enums.DealStatusEnum;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.enums.GroupType;
 | 
	
	
		
			
				|  | @@ -36,6 +40,22 @@ import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.enums.SporadicChargeTypeEnum;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.page.SporadicOrderQueryInfo;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.ChildrenDayReserveService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.DegreeRegistrationService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.MusicGroupService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.PayService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.PracticeGroupService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.ReplacementInstrumentActivityService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.SporadicChargeInfoService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.StudentInstrumentService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.StudentPaymentOrderService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.StudentPaymentRouteOrderService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.StudentRegistrationService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.StudentRepairService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.SubjectChangeService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.SysUserCashAccountService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.VipGroupService;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.dal.BaseDAO;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.exception.BizException;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.page.PageInfo;
 | 
	
	
		
			
				|  | @@ -80,6 +100,10 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 | 
	
		
			
				|  |  |      private DegreeRegistrationService degreeRegistrationService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private StudentPaymentRouteOrderDao studentPaymentRouteOrderDao;
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private IdGeneratorService idGeneratorService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
	
		
			
				|  | @@ -92,6 +116,10 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 | 
	
		
			
				|  |  |      private ReplacementInstrumentActivityService replacementInstrumentActivityService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private ChildrenDayReserveService childrenDayReserveService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private PayService payService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public BaseDAO<Long, StudentPaymentOrder> getDAO() {
 | 
	
	
		
			
				|  | @@ -99,6 +127,76 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | +    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | +	public Map createOrder(StudentPaymentOrder studentPaymentOrder, List<StudentPaymentOrderDetail> details, String payReceiver)
 | 
	
		
			
				|  |  | +			throws Exception {
 | 
	
		
			
				|  |  | +    	
 | 
	
		
			
				|  |  | +    	BigDecimal cashAmount = studentPaymentOrder.getActualAmount();
 | 
	
		
			
				|  |  | +    	BigDecimal expectAmount = studentPaymentOrder.getExpectAmount();
 | 
	
		
			
				|  |  | +    	BigDecimal balance = studentPaymentOrder.getBalancePaymentAmount();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		if (cashAmount.add(balance).compareTo(expectAmount) != 0) {
 | 
	
		
			
				|  |  | +			throw new BizException("支付金额不正确,请重试");
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String orderNo = idGeneratorService.generatorId("payment") + "";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		Date date = new Date();
 | 
	
		
			
				|  |  | +		studentPaymentOrder.setOrderNo(orderNo);
 | 
	
		
			
				|  |  | +		studentPaymentOrder.setExpectAmount(expectAmount);
 | 
	
		
			
				|  |  | +		studentPaymentOrder.setActualAmount(cashAmount);
 | 
	
		
			
				|  |  | +		studentPaymentOrder.setBalancePaymentAmount(balance);
 | 
	
		
			
				|  |  | +		studentPaymentOrder.setStatus(DealStatusEnum.ING);
 | 
	
		
			
				|  |  | +		studentPaymentOrder.setCreateTime(date);
 | 
	
		
			
				|  |  | +		studentPaymentOrder.setUpdateTime(date);
 | 
	
		
			
				|  |  | +		studentPaymentOrder.setVersion(0);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		studentPaymentOrder.setPaymentChannel("BALANCE");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		insert(studentPaymentOrder);
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		if(details != null && details.size() > 0){
 | 
	
		
			
				|  |  | +			for(StudentPaymentOrderDetail spod : details){
 | 
	
		
			
				|  |  | +				spod.setPaymentOrderId(studentPaymentOrder.getId());
 | 
	
		
			
				|  |  | +				spod.setCreateTime(date);
 | 
	
		
			
				|  |  | +				spod.setUpdateTime(date);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			
 | 
	
		
			
				|  |  | +			studentPaymentOrderDetailService.batchAdd(details);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		if (cashAmount.compareTo(BigDecimal.ZERO) == 0) {
 | 
	
		
			
				|  |  | +            studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
 | 
	
		
			
				|  |  | +            studentPaymentOrder.setRoutingOrganId(studentPaymentOrder.getOrganId());
 | 
	
		
			
				|  |  | +            studentPaymentOrder.setUpdateTime(date);
 | 
	
		
			
				|  |  | +            update(studentPaymentOrder);
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +			studentPaymentRouteOrderService.addRouteOrder(orderNo, studentPaymentOrder.getOrganId(), balance);
 | 
	
		
			
				|  |  | +			
 | 
	
		
			
				|  |  | +			callOrderCallBack(studentPaymentOrder);
 | 
	
		
			
				|  |  | +			
 | 
	
		
			
				|  |  | +			Map<String, String> notifyMap = new HashMap<>(4);
 | 
	
		
			
				|  |  | +			notifyMap.put("tradeState", "1");
 | 
	
		
			
				|  |  | +			notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
 | 
	
		
			
				|  |  | +			notifyMap.put("channelType", "");
 | 
	
		
			
				|  |  | +			notifyMap.put("orderNo", "");
 | 
	
		
			
				|  |  | +			updateOrder(notifyMap);
 | 
	
		
			
				|  |  | +			return notifyMap;
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		Map<String, Object> payMap = payService.getPayMap(cashAmount, balance, orderNo, baseApiUrl + "/api-student/studentOrder/notify", baseApiUrl
 | 
	
		
			
				|  |  | +				+ "/api-student/studentOrder/paymentResult?orderNo=" + studentPaymentOrder.getOrderNo(), studentPaymentOrder.getMemo(), studentPaymentOrder.getMemo(), studentPaymentOrder.getOrganId(), payReceiver);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
 | 
	
		
			
				|  |  | +		studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
 | 
	
		
			
				|  |  | +		studentPaymentOrder.setUpdateTime(date);
 | 
	
		
			
				|  |  | +		update(studentPaymentOrder);
 | 
	
		
			
				|  |  | +		return payMap;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Override
 | 
	
		
			
				|  |  |      public List<Goods> queryApplyGoodsList(String musicGroupId, OrderDetailTypeEnum type) {
 | 
	
		
			
				|  |  |          return studentPaymentOrderDao.queryApplyGoodsList(musicGroupId, type);
 | 
	
		
			
				|  |  |      }
 |