一个service管理多个service

global.dao.dbcp.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- 全局数据访问模型 -->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="
	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
	http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-3.0.xsd">

	<!-- =================== G4Studio平台数据源配置 ================== -->
	<!-- Apache Commons DBCP 数据源   
	<bean id="dataSourceG4" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
		<property name="driverClassName" value="${pmpf.jdbc.driverClassName}" />
		<property name="url" value="${pmpf.jdbc.url}" />
		<property name="username" value="${pmpf.jdbc.username}" />
		<property name="password" value="${pmpf.jdbc.password}" />
		<property name="initialSize" value="10" />
		<property name="maxActive" value="30" />
		<property name="maxIdle" value="15" />
		<property name="minIdle" value="5" />
		<property name="removeAbandoned" value="true" />
		<property name="removeAbandonedTimeout" value="60" />
		<property name="maxWait" value="10000" />
		<property name="logAbandoned" value="true" />
	</bean>
	--> 
	<!-- Alibaba Druid 数据源 -->
	<bean id="dataSourceG4" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
		<property name="url" value="${pmpf.jdbc.url}" />
		<property name="username" value="${pmpf.jdbc.username}" />
		<property name="password" value="${pmpf.jdbc.password}" />
		<!-- 配置初始化大小、最小、最大 -->
		<property name="initialSize" value="${pmpf.jdbc.initialSize}" />
		<property name="maxActive" value="${pmpf.jdbc.maxActive}" />
		<property name="minIdle" value="${pmpf.jdbc.minIdle}" />
		<!-- 配置获取连接等待超时的时间 -->
		<property name="maxWait" value="${pmpf.jdbc.maxWait}" />
		<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
		<property name="minEvictableIdleTimeMillis" value="${pmpf.jdbc.minEvictableIdleTimeMillis}" />
		<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
		<property name="timeBetweenEvictionRunsMillis" value="${pmpf.jdbc.timeBetweenEvictionRunsMillis}" />

		<property name="validationQuery" value="${pmpf.jdbc.validationQuery}" />
		<property name="testWhileIdle" value="${pmpf.jdbc.testWhileIdle}" />
		<property name="testOnBorrow" value="${pmpf.jdbc.testOnBorrow}" />
		<property name="testOnReturn" value="${pmpf.jdbc.testOnReturn}" />
		<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
		<property name="poolPreparedStatements" value="${pmpf.jdbc.poolPreparedStatements}" />
		<property name="maxPoolPreparedStatementPerConnectionSize" value="${pmpf.jdbc.maxPoolPreparedStatementPerConnectionSize}" />

		<!-- 配置监控统计拦截的filters -->
		<property name="filters" value="${pmpf.jdbc.filters}" /> 
		<!-- 关闭长时间不使用的连接超时时间,单位秒 -->
		<property name="removeAbandoned" value="${pmpf.jdbc.removeAbandoned}" />
		<property name="removeAbandonedTimeout" value="${pmpf.jdbc.removeAbandonedTimeout}" />
		<property name="logAbandoned" value="${pmpf.jdbc.logAbandoned}" />
	</bean>
	
	<!-- JNDI 数据源 
	<bean id="dataSourceG4" class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiName">
			<value>${global.datasource}</value>
		</property>
	</bean>
	-->
	
	 <!-- 配置平台层面的qlmapClientFactory -->
	<bean id="sqlMapClientG4" class="org.g4studio.core.orm.xibatis.support.SqlMapClientFactoryBean">
		<property name="configLocations">
			<list>
				<value>config/g4/g4.sqlmap.xml</value>
				<value>classpath*:config/app/*.sqlmap.xml</value>
			</list>
		</property>
		<property name="dataSource" ref="dataSourceG4" />
	</bean>
	<!-- 配置平台层面的G4Reader -->
	<bean id="g4Reader" class="org.g4studio.core.model.dao.impl.ReaderImpl">
		<property name="sqlMapClient" ref="sqlMapClientG4" />
	</bean>
	<!-- 配置平台层面的G4Dao -->
	<bean id="g4Dao" class="org.g4studio.core.model.dao.impl.DaoImpl">
		<property name="sqlMapClient" ref="sqlMapClientG4" />
	</bean>

	<!-- JDBC事务管理器配置 -->
	<bean id="transactionManagerG4" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource">
			<ref bean="dataSourceG4" />
		</property>
	</bean>
	<!-- 配置事务代理的基类 -->
	<bean id="baseTransactionProxyG4" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
		<property name="transactionManager">
			<ref bean="transactionManagerG4" />
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="save*">PROPAGATION_REQUIRED,-Exception</prop>
				<prop key="do*">PROPAGATION_REQUIRED,-Exception</prop>
				<prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop>
				<prop key="del*">PROPAGATION_REQUIRED,-Exception</prop>
				<prop key="drop*">PROPAGATION_REQUIRED,-Exception</prop>
				<prop key="update*">PROPAGATION_REQUIRED,-Exception</prop>
				<prop key="edit*">PROPAGATION_REQUIRED,-Exception</prop>
				<prop key="modify*">PROPAGATION_REQUIRED,-Exception</prop>
				<prop key="call*">PROPAGATION_REQUIRED,-Exception</prop>
				<prop key="get*">PROPAGATION_REQUIRED,-Exception</prop>
				<prop key="query*">PROPAGATION_REQUIRED,-Exception</prop>
				<prop key="batch*">PROPAGATION_REQUIRED,-Exception</prop>
				<prop key="*">PROPAGATION_SUPPORTS,-Exception</prop>
			</props>
		</property>
	</bean>

</beans>

pmpf.service.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="
	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

	
	<!-- 退款处理-->
	<bean id="refundManageService" parent="baseTransactionProxyG4">
		<property name="target">
			<bean class="com.saicfc.pmpf.internal.manage.service.impl.RefundManageServiceImpl">
				<property name="g4Dao" ref="g4Dao" />
				<property name="refundInfoExpServiceMap">
					<map>
						<entry key="ICBC"  value-ref="icbcRefundManageService"/>
						<entry key="CEB" value-ref="cebRefundManageService"/>
						<entry key="BOC" value-ref="bocRefundManageService"/>
						<entry key="CCB" value-ref="ccbRefundManageService"/>
						<entry key="BOCOM" value-ref="bocomRefundManageService"/>
						<entry key="CIB" value-ref="cibRefundManageService"/>
						<entry key="CMB" value-ref="cmbRefundManageService"/>
						<entry key="CITIC" value-ref="citicRefundManageService"/>
					</map>
				</property>
			</bean>
		</property>
	</bean>
	
	<!-- 工商银行退款导出管理-->
	<bean id="icbcRefundManageService" parent="baseTransactionProxyG4">
		<property name="target">
			<bean class="com.saicfc.pmpf.internal.manage.renfund.impl.ICBCRefundInfoExportServiceImpl">
				<property name="g4Dao" ref="g4Dao" />
			</bean>
		</property>
	</bean>
	
	<!-- 光大银行退款导出管理-->
	<bean id="cebRefundManageService" parent="baseTransactionProxyG4">
		<property name="target">
			<bean class="com.saicfc.pmpf.internal.manage.renfund.impl.CEBRefundInfoExportServiceImpl">
				<property name="g4Dao" ref="g4Dao" />
			</bean>
		</property>
	</bean>
	
	<!-- 中国银行退款导出管理-->
	<bean id="bocRefundManageService" parent="baseTransactionProxyG4">
		<property name="target">
			<bean class="com.saicfc.pmpf.internal.manage.renfund.impl.BOCRefundInfoExportServiceImpl">
				<property name="g4Dao" ref="g4Dao" />
			</bean>
		</property>
	</bean>
	
	<!-- 建设银行退款导出管理-->
	<bean id="ccbRefundManageService" parent="baseTransactionProxyG4">
		<property name="target">
			<bean class="com.saicfc.pmpf.internal.manage.renfund.impl.CCBRefundInfoExportServiceImpl">
				<property name="g4Dao" ref="g4Dao" />
			</bean>
		</property>
	</bean>
	
	<!-- 交通银行退款导出管理-->
	<bean id="bocomRefundManageService" parent="baseTransactionProxyG4">
		<property name="target">
			<bean class="com.saicfc.pmpf.internal.manage.renfund.impl.BOCOMRefundInfoExportServiceImpl">
				<property name="g4Dao" ref="g4Dao" />
			</bean>
		</property>
	</bean>
	
	<!-- 兴业银行退款导出管理-->
	<bean id="cibRefundManageService" parent="baseTransactionProxyG4">
		<property name="target">
			<bean class="com.saicfc.pmpf.internal.manage.renfund.impl.CIBRefundInfoExportServiceImpl">
				<property name="g4Dao" ref="g4Dao" />
			</bean>
		</property>
	</bean>
	
	<!-- 招商银行退款导出管理-->
	<bean id="cmbRefundManageService" parent="baseTransactionProxyG4">
		<property name="target">
			<bean class="com.saicfc.pmpf.internal.manage.renfund.impl.CMBRefundInfoExportServiceImpl">
				<property name="g4Dao" ref="g4Dao" />
			</bean>
		</property>
	</bean>
	
	<!-- 中信银行退款导出管理-->
	<bean id="citicRefundManageService" parent="baseTransactionProxyG4">
		<property name="target">
			<bean class="com.saicfc.pmpf.internal.manage.renfund.impl.CITICRefundInfoExportServiceImpl">
				<property name="g4Dao" ref="g4Dao" />
			</bean>
		</property>
	</bean>
	
</beans>


RefundManageService.java

/**
 * 
 */
package com.saicfc.pmpf.internal.manage.service;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;

import org.g4studio.core.metatype.Dto;

/**
 * 退款处理
 * @author lizhiyong
 * @version $Id: RefundManageService.java, v 0.1
		2014年7月7日 下午1:33:34 Exp $
 */
public interface RefundManageService {

    
    /**
     * 配置导出的详细信息
     * @param channelCode
     *                 渠道代码
     * @param paymentMap
     *                 订单信息
     * @param map
     *           退款信息
     * @return
     * @throws Exception 
     */
    @SuppressWarnings("rawtypes")
    public LinkedHashMap getExportDetailInfo(String channelCode, HashMap paymentMap, HashMap refundMap) throws Exception;

    /**
     * 设置导出文件头部信息
     * @param channelCode  渠道代码
     * @return
     * @throws Exception 
     */
    @SuppressWarnings("rawtypes")
    public LinkedHashMap getExportTile(String channelCode) throws Exception;
    
    /**
     * 上传网银格式文件的最大数目
     * @param channelCode
     * @return
     */
    public int maxCount(String channelCode);
    
    
}

RefundManageServiceImpl.java

/**
 * 
 */
package com.saicfc.pmpf.internal.manage.service.impl;

import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.g4studio.core.metatype.Dto;
import org.g4studio.core.metatype.impl.BaseDto;
import org.g4studio.core.model.service.impl.BizServiceImpl;

import com.saicfc.pmpf.internal.manage.renfund.RefundInfoExportService;
import com.saicfc.pmpf.internal.manage.service.RefundManageService;
import com.saicfc.pmpf.internal.manage.utils.CommonUtils;
import com.saicfc.pmpf.internal.manage.utils.Contants;
import com.saicfc.pmpf.internal.manage.utils.DateUtil;

/**
 * 退款处理
 * @author lizhiyong
 * @version $Id: RefundManageServiceImpl.java, v 0.1
		2014年7月7日 下午1:33:49 Exp $
 */
public class RefundManageServiceImpl extends BizServiceImpl implements RefundManageService {

    private Log                                  logger = LogFactory.getLog(getClass());

    private Map<String, RefundInfoExportService> refundInfoExpServiceMap;

    public void setRefundInfoExpServiceMap(Map<String, RefundInfoExportService> refundInfoExpServiceMap) {
        this.refundInfoExpServiceMap = refundInfoExpServiceMap;
    }

    @SuppressWarnings("rawtypes")
    @Override
    public LinkedHashMap getExportDetailInfo(String channelCode, HashMap paymentMap, HashMap refundMap)
                                                                                                 throws Exception {
        try {
            return this.refundInfoExpServiceMap.get(channelCode).getExportDetailInfo(paymentMap,
                refundMap);
        } catch (Exception e) {
            throw e;
        }
    }

    @SuppressWarnings("rawtypes")
    @Override
    public LinkedHashMap getExportTile(String channelCode) throws Exception {
        try {
            return this.refundInfoExpServiceMap.get(channelCode).getExportTile();
        } catch (Exception e) {
            throw e;
        }
    }

    @Override
    public int maxCount(String channelCode) {
        return this.refundInfoExpServiceMap.get(channelCode).maxCount();
    }
}


RefundInfoExportService.java

package com.saicfc.pmpf.internal.manage.renfund;

import java.util.HashMap;
import java.util.LinkedHashMap;

/**
 * 退款导出网银格式文件service
 * @author lizhiyong
 * @version $Id: RefundInfoExportService.java, v 0.1
		2014年9月10日 下午4:06:26 Exp $
 */
public interface RefundInfoExportService {

    /**
     * 配置导出的详细信息
     * @param channelCode
     *                 渠道代码
     * @param paymentMap
     *                 订单信息
     * @param map
     *           退款信息
     * @return
     */
    @SuppressWarnings("rawtypes")
    public LinkedHashMap getExportDetailInfo(HashMap paymentMap, HashMap refundMap);

    /**
     * 设置导出文件头部信息
     * @param channelCode  渠道代码
     * @return
     */
    @SuppressWarnings("rawtypes")
    public LinkedHashMap getExportTile();

    /**
     * 设置最大导出条数
     * @param channelCode
     * @return
     */
    int maxCount();

    
}

ICBCRefundInfoExportServiceImpl.java

package com.saicfc.pmpf.internal.manage.renfund.impl;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;

import org.g4studio.core.model.service.impl.BizServiceImpl;

import com.saicfc.pmpf.internal.manage.renfund.RefundInfoExportService;
import com.saicfc.pmpf.internal.manage.utils.DateUtil;

public class ICBCRefundInfoExportServiceImpl extends BizServiceImpl implements
                                                                   RefundInfoExportService {

    /**
     * 配置工商银行导出的详细信息
     * @param channelCode
     * @param paymentMap
     * @param map
     * @return 
     * @see com.saicfc.pmpf.internal.manage.renfund.RefundInfoExportService#getExportDetailInfo(java.lang.String, java.util.HashMap, java.util.HashMap)
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Override
    public LinkedHashMap getExportDetailInfo(HashMap paymentMap, HashMap refundMap) {
        LinkedHashMap datamMap = new LinkedHashMap();
        String orderTime = DateUtil.convertDateToString("yyyyMMdd",
            (Date) paymentMap.get("orderTime"));
        String channelOrderNo = (String) paymentMap.get("channelOrderNo");
        datamMap.put("1", channelOrderNo);
        datamMap.put("2", orderTime);
        BigDecimal amount = (BigDecimal) refundMap.get("amount");
        String amountString = amount.divide(new BigDecimal(10)).toPlainString();
        datamMap.put("3", amountString);
        datamMap.put("4", refundMap.get("remark") != null ? refundMap.get("remark") : "");
        datamMap.put("5", "");
        return datamMap;
    }

    /**
     * 设置工商银行导出文件头部信息
     * @param channelCode
     * @return 
     * @see com.saicfc.pmpf.internal.manage.renfund.RefundInfoExportService#getExportTile(java.lang.String)
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Override
    public LinkedHashMap getExportTile() {
        LinkedHashMap map = new LinkedHashMap();
        map.put("1", "订单号");
        map.put("2", "支付日期");
        map.put("3", "退货现金金额(整数金额 单位:分)");
        map.put("4", "退货原因");
        map.put("5", "退货积分商户金额(整数金额  单位 : 分)");
        return map;
    }

    @Override
    public int maxCount() {
        return 0;
    }

}


你可能感兴趣的:(service)