首页 > 代码库 > 一个service管理多个service

一个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=http://www.mamicode.com/"${pmpf.jdbc.driverClassName}" />>
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管理多个service