|  | @@ -1,27 +1,47 @@
 | 
	
		
			
				|  |  |  package com.ym.mec.biz.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.StudentRepairDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.SysConfigDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.BasicUserDto;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.StudentRepair;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.SysConfig;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.SysUserCashAccount;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.DealStatusEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.GroupType;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.PayService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.StudentPaymentOrderService;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.service.StudentRepairService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.SysConfigService;
 | 
	
		
			
				|  |  |  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 org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | +import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import java.util.ArrayList;
 | 
	
		
			
				|  |  | -import java.util.HashMap;
 | 
	
		
			
				|  |  | -import java.util.List;
 | 
	
		
			
				|  |  | -import java.util.Map;
 | 
	
		
			
				|  |  | +import java.math.BigDecimal;
 | 
	
		
			
				|  |  | +import java.util.*;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @Service
 | 
	
		
			
				|  |  |  public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRepair> implements StudentRepairService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private StudentRepairDao studentRepairDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private PayService payService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private IdGeneratorService idGeneratorService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private SysConfigDao sysConfigDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private StudentPaymentOrderService studentPaymentOrderService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
	
		
			
				|  | @@ -45,4 +65,76 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
 | 
	
		
			
				|  |  |          pageInfo.setRows(dataList);
 | 
	
		
			
				|  |  |          return pageInfo;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | +    public Map addRepair(StudentRepair repairInfo) throws Exception {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        Date date = new Date();
 | 
	
		
			
				|  |  | +        BigDecimal amount = repairInfo.getAmount();
 | 
	
		
			
				|  |  | +        String orderNo = idGeneratorService.generatorId("payment") + "";
 | 
	
		
			
				|  |  | +        repairInfo.setTransNo(orderNo);
 | 
	
		
			
				|  |  | +        studentRepairDao.insert(repairInfo);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String channelType = "";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setUserId(repairInfo.getStudentId());
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setGroupType(GroupType.REPAIR);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setOrderNo(orderNo);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setType(OrderTypeEnum.REPAIR);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setExpectAmount(amount);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setActualAmount(amount);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setStatus(DealStatusEnum.ING);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setMusicGroupId(repairInfo.getId().toString());
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setPaymentChannel("BALANCE");
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setUpdateTime(date);
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setOrganId(repairInfo.getOrganId());
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setRoutingOrganId(repairInfo.getOrganId());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        studentPaymentOrderService.insert(studentPaymentOrder);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setVersion(0);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (amount.compareTo(BigDecimal.ZERO) == 0) {
 | 
	
		
			
				|  |  | +            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 baseApiUrl = sysConfigDao.findConfigValue(SysConfigService.EDU_TEACHER_BASE_URL);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        Map<String, BigDecimal> classFee = new HashMap<>();
 | 
	
		
			
				|  |  | +        classFee.put("course", BigDecimal.ZERO);
 | 
	
		
			
				|  |  | +        classFee.put("instrument", BigDecimal.ZERO);
 | 
	
		
			
				|  |  | +        classFee.put("accessories", BigDecimal.ZERO);
 | 
	
		
			
				|  |  | +        classFee.put("other", amount);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        Map payMap = payService.getPayMap(
 | 
	
		
			
				|  |  | +                amount,
 | 
	
		
			
				|  |  | +                orderNo,
 | 
	
		
			
				|  |  | +                baseApiUrl + "/api-web/studentOrder/notify",
 | 
	
		
			
				|  |  | +                baseApiUrl + "/api-web/studentOrder/paymentResult?orderNo=" + orderNo,
 | 
	
		
			
				|  |  | +                "乐器维修",
 | 
	
		
			
				|  |  | +                "乐器维修",
 | 
	
		
			
				|  |  | +                repairInfo.getStudentId(),
 | 
	
		
			
				|  |  | +                classFee,
 | 
	
		
			
				|  |  | +                repairInfo.getOrganId()
 | 
	
		
			
				|  |  | +        );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        Map<String, BigDecimal> routingFee = (Map<String, BigDecimal>) payMap.get("routingFee");
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setRoutingOrganId((Integer) payMap.get("routingOrganId"));
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setComAmount(routingFee.get("COM"));
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setPerAmount(routingFee.get("PER"));
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
 | 
	
		
			
				|  |  | +        studentPaymentOrder.setUpdateTime(date);
 | 
	
		
			
				|  |  | +        studentPaymentOrderService.update(studentPaymentOrder);
 | 
	
		
			
				|  |  | +        return payMap;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |