| 
					
				 | 
			
			
				@ -1,10 +1,13 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.jw.base.service.order; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.order.BusinessOrderDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.order.BusinessOrderRefundDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.order.dao.BusinessOrderDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.order.dao.BusinessOrderRefundDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.pay.service.CloudCarePayService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.ResponseContant; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.PageEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -13,6 +16,7 @@ import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.jdbc.core.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Map; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -30,6 +34,10 @@ public class PayService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BusinessOrderDao businessOrderDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BusinessOrderRefundDao businessOrderRefundDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private BasePatientDao patientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private CloudCarePayService payService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 订单列表 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -133,8 +141,14 @@ public class PayService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ( null== businessOrderDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             result.put(ResponseContant.resultFlag, ResponseContant.fail); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             result.put(ResponseContant.resultMsg, "订单不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put(ResponseContant.resultFlag, ResponseContant.fail); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put(ResponseContant.resultMsg, "订单不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (patientDO==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put(ResponseContant.resultFlag, ResponseContant.fail); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put(ResponseContant.resultMsg, "患者不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ( 3 != businessOrderDO.getStatus()){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -158,7 +172,8 @@ public class PayService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject agreeRefund(String orderNo){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject agreeRefund(String orderNo) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ( null== businessOrderDO){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -171,18 +186,34 @@ public class PayService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put(ResponseContant.resultMsg, "订单未申请退款或已退款,无法操作"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (patientDO==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put(ResponseContant.resultFlag, ResponseContant.fail); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put(ResponseContant.resultMsg, "患者不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        BusinessOrderRefundDO businessOrderRefundDO = businessOrderRefundDao.selectByOrderNo(orderNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (null == businessOrderRefundDO){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put(ResponseContant.resultFlag, ResponseContant.fail); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put(ResponseContant.resultMsg, "订单不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (businessOrderRefundDO.getStatus()!=1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put(ResponseContant.resultFlag, ResponseContant.fail); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put(ResponseContant.resultMsg, "订单已处理"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        businessOrderDO.setStatus(4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        businessOrderRefundDO.setStatus(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //退款流程 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        payService.orderRefund(orderNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        businessOrderRefundDO.setStatus(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        businessOrderDao.save(businessOrderDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        businessOrderRefundDao.save(businessOrderRefundDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put(ResponseContant.resultFlag, ResponseContant.fail); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        result.put(ResponseContant.resultMsg, "success"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 |