package com.pz.merchant.service.impl; import com.pz.common.utils.spring.SpringUtils; import com.pz.merchant.service.ISonOrderService; import com.pz.system.service.impl.*; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; import java.util.HashMap; /** * 子订单业务构造器 * <p>created in 2023/9/12 10:08 * * @author WangMin * @version 1.0 */ @Component @ConditionalOnBean({ StoreOrderServiceImpl.class, DbwzOrderServiceImpl.class, YypzOrderServiceImpl.class, ZqghOrderServiceImpl.class, DbmyOrderServiceImpl.class, ZyphOrderServiceImpl.class, DbghOrderServiceImpl.class}) public class SonOrderServiceBuilder { private HashMap<Integer, ISonOrderService> sonOrderHashMap; @PostConstruct public void loadSonOrderService() { DbwzOrderServiceImpl dbwzOrderService = SpringUtils.getBean(DbwzOrderServiceImpl.class); YypzOrderServiceImpl yypzOrderService = SpringUtils.getBean(YypzOrderServiceImpl.class); ZqghOrderServiceImpl zqghOrderService = SpringUtils.getBean(ZqghOrderServiceImpl.class); DbmyOrderServiceImpl dbmyOrderService = SpringUtils.getBean(DbmyOrderServiceImpl.class); ZyphOrderServiceImpl zyphOrderService = SpringUtils.getBean(ZyphOrderServiceImpl.class); DbghOrderServiceImpl dbghOrderService = SpringUtils.getBean(DbghOrderServiceImpl.class); StoreOrderServiceImpl storeOrderService = SpringUtils.getBean(StoreOrderServiceImpl.class); sonOrderHashMap = new HashMap<>(8); sonOrderHashMap.put(0, storeOrderService); sonOrderHashMap.put(1, yypzOrderService); sonOrderHashMap.put(2, dbghOrderService); sonOrderHashMap.put(3, dbwzOrderService); sonOrderHashMap.put(4, zyphOrderService); sonOrderHashMap.put(5, dbmyOrderService); sonOrderHashMap.put(6, zqghOrderService); } /** * 根据业务ID获取对应子订单业务 * * @param businessId 业务ID * @return 子订单业务 */ public ISonOrderService getSonOrderService(int businessId) { return sonOrderHashMap.get(businessId); } }