yonge 3 năm trước cách đây
mục cha
commit
5a8f630f34

+ 23 - 8
cms/src/main/java/com/ym/mec/cms/interceptor/TenantInterceptor.java

@@ -3,6 +3,7 @@ package com.ym.mec.cms.interceptor;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 
 
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
 import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
@@ -11,11 +12,14 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.cms.dal.entity.TenantInfo;
 import com.ym.mec.cms.dal.entity.TenantInfo;
 import com.ym.mec.cms.service.TenantInfoService;
 import com.ym.mec.cms.service.TenantInfoService;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.common.tenant.TenantContextHolder;
 
 
 public class TenantInterceptor extends HandlerInterceptorAdapter {
 public class TenantInterceptor extends HandlerInterceptorAdapter {
 
 
 	private static final String DATA_SOURCE_ID = "datasourceId";
 	private static final String DATA_SOURCE_ID = "datasourceId";
+	
+	private static final String TENANT_ID = "tenantId";
 
 
 	@Autowired
 	@Autowired
 	@Lazy
 	@Lazy
@@ -27,16 +31,27 @@ public class TenantInterceptor extends HandlerInterceptorAdapter {
 	@Override
 	@Override
 	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
 	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
 		
 		
-		SysUser sysUser = sysUserFeignService.queryUserInfo();
-		
-		if(sysUser != null && sysUser.getId() != null){
-			TenantContextHolder.setTenantId(sysUser.getTenantId());
-			
-			TenantInfo tenantInfo = tenantInfoService.get(sysUser.getTenantId());
+		String tenantId = request.getParameter(TENANT_ID);
+
+        if (StringUtils.isBlank(tenantId)) {
+            tenantId = request.getHeader(TENANT_ID);
+        }
+
+        if (StringUtils.isBlank(tenantId)) {
+            SysUser sysUser = sysUserFeignService.queryUserInfo();
+            if (sysUser != null && sysUser.getTenantId() != null) {
+                tenantId = sysUser.getTenantId().toString();
+            }
+        }
+        if (StringUtils.isNotBlank(tenantId)) {
+            TenantContextHolder.setTenantId(Integer.parseInt(tenantId));
+            TenantInfo tenantInfo = tenantInfoService.get(Integer.parseInt(tenantId));
 			if(tenantInfo != null){
 			if(tenantInfo != null){
 				request.setAttribute(DATA_SOURCE_ID, tenantInfo.getDataSource());
 				request.setAttribute(DATA_SOURCE_ID, tenantInfo.getDataSource());
-			}
-		}
+			} else {
+                throw new BizException("机构信息异常,请联系管理员");
+            }
+        }
 		
 		
 		return true;
 		return true;
 	}
 	}

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysConfigService.java

@@ -385,6 +385,12 @@ public interface SysConfigService extends BaseService<Long, SysConfig> {
     //云教练试用时间最晚截止时间
     //云教练试用时间最晚截止时间
     String EXPERIENCE_MEMBERSHIP_END_TIME = "experience_membership_end_time";
     String EXPERIENCE_MEMBERSHIP_END_TIME = "experience_membership_end_time";
 
 
+    //小课收入是否由平台收款
+    String IS_OPEN_SMALL_CLASS_INCOME_TO_PLATFORM = "is_open_small_class_income_to_platform";
+
+    //平台收款账户
+    String PLATFORM_PAYEE_ACCOUNT = "platform_payee_account";
+
     /**
     /**
      * @return com.ym.mec.biz.dal.entity.SysConfig
      * @return com.ym.mec.biz.dal.entity.SysConfig
      * @params paramName
      * @params paramName

+ 12 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OrderPayOpsServiceImpl.java

@@ -28,9 +28,8 @@ import org.springframework.util.DigestUtils;
 
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.dal.entity.SysConfig;
-import com.ym.mec.biz.dal.entity.SysPaymentConfig;
 import com.ym.mec.biz.dal.entity.TenantConfig;
 import com.ym.mec.biz.dal.entity.TenantConfig;
 import com.ym.mec.biz.dal.entity.TenantOrderRecord;
 import com.ym.mec.biz.dal.entity.TenantOrderRecord;
 import com.ym.mec.biz.dal.entity.TenantPaymentOrder;
 import com.ym.mec.biz.dal.entity.TenantPaymentOrder;
@@ -76,6 +75,9 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
     private SysConfigService sysConfigService;
     private SysConfigService sysConfigService;
     
     
     @Autowired
     @Autowired
+    private SysConfigDao sysConfigDao;
+    
+    @Autowired
     private SysPaymentConfigService sysPaymentConfigService;
     private SysPaymentConfigService sysPaymentConfigService;
 
 
     //支付类型
     //支付类型
@@ -334,7 +336,7 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
                 // 实时分账
                 // 实时分账
     			if (amount.doubleValue() > 0) {
     			if (amount.doubleValue() > 0) {
     				
     				
-    				SysConfig config = sysConfigService.findByParamName("platform_collection_organ");
+    				/*SysConfig config = sysConfigService.findByParamName("platform_collection_organ");
     		        if (Objects.isNull(config)) {
     		        if (Objects.isNull(config)) {
     		            throw new BizException("平台收款账户没有设置[platform_collection_organ]");
     		            throw new BizException("平台收款账户没有设置[platform_collection_organ]");
     		        }
     		        }
@@ -343,10 +345,16 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
     	        	
     	        	
     	        	if(sysPaymentConfig == null || StringUtils.isBlank(sysPaymentConfig.getHfMerNo())){
     	        	if(sysPaymentConfig == null || StringUtils.isBlank(sysPaymentConfig.getHfMerNo())){
     	        		throw new BizException("分部[{}]没有设置收款账号", config.getParanValue());
     	        		throw new BizException("分部[{}]没有设置收款账号", config.getParanValue());
+    	        	}*/
+    				
+    				String platformAccount = sysConfigDao.findConfigValue(SysConfigService.PLATFORM_PAYEE_ACCOUNT);
+    	        	
+    	        	if(StringUtils.isBlank(platformAccount)){
+    	        		throw new BizException("平台收款账户查询失败");
     	        	}
     	        	}
     	        	
     	        	
     				Map<String, Object> divMember = new HashMap<>();
     				Map<String, Object> divMember = new HashMap<>();
-    				divMember.put("member_id", sysPaymentConfig.getHfMerNo());
+    				divMember.put("member_id", platformAccount);
     				divMember.put("amount", amount);
     				divMember.put("amount", amount);
     				divMember.put("fee_flag", "Y");
     				divMember.put("fee_flag", "Y");
     				divMemberList.add(divMember);
     				divMemberList.add(divMember);

+ 53 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java

@@ -28,10 +28,12 @@ import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
 import com.ym.mec.biz.dal.entity.SysConfig;
 import com.ym.mec.biz.dal.entity.SysConfig;
 import com.ym.mec.biz.dal.entity.SysPaymentConfig;
 import com.ym.mec.biz.dal.entity.SysPaymentConfig;
 import com.ym.mec.biz.dal.enums.FeeTypeEnum;
 import com.ym.mec.biz.dal.enums.FeeTypeEnum;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
 import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
 import com.ym.mec.biz.service.PayService;
 import com.ym.mec.biz.service.PayService;
 import com.ym.mec.biz.service.SellOrderService;
 import com.ym.mec.biz.service.SellOrderService;
 import com.ym.mec.biz.service.StudentPaymentOrderService;
 import com.ym.mec.biz.service.StudentPaymentOrderService;
+import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.biz.service.SysPaymentConfigService;
 import com.ym.mec.biz.service.SysPaymentConfigService;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.redis.service.RedisCache;
 import com.ym.mec.common.redis.service.RedisCache;
@@ -108,6 +110,49 @@ public class PayServiceImpl implements PayService {
             return unionPay;
             return unionPay;
         }
         }
         
         
+        //如果当前是买的小课/网管课
+		if (studentPaymentOrder.getType() == OrderTypeEnum.SMALL_CLASS_TO_BUY || studentPaymentOrder.getType() == OrderTypeEnum.PRACTICE_GROUP_BUY
+				|| studentPaymentOrder.getType() == OrderTypeEnum.PRACTICE_GROUP_RENEW) {
+			
+			// 是否由平台收款
+			String isPlatformCollection = sysConfigDao.findConfigValue(SysConfigService.IS_OPEN_SMALL_CLASS_INCOME_TO_PLATFORM);
+			
+			if (StringUtils.equals("1", isPlatformCollection)) {
+				Date date = new Date();
+	        	
+	        	String merNo = sysConfigDao.findConfigValue(SysConfigService.PLATFORM_PAYEE_ACCOUNT);
+	        	
+	        	if(StringUtils.isBlank(merNo)){
+	        		throw new BizException("平台收款账户查询失败");
+	        	}
+	        	
+	        	StudentPaymentRouteOrder studentPaymentRouteOrder = new StudentPaymentRouteOrder();
+	            studentPaymentRouteOrder.setOrderNo(orderNo);
+	            studentPaymentRouteOrder.setRouteOrganId(organId);
+	            studentPaymentRouteOrder.setFeeFlag("Y");
+	            studentPaymentRouteOrder.setRouteAmount(amount);
+	            studentPaymentRouteOrder.setRouteBalanceAmount(balanceAmount);
+	            studentPaymentRouteOrder.setMerNo(merNo);
+	            studentPaymentRouteOrder.setSaleAmount(BigDecimal.ZERO);
+	            studentPaymentRouteOrder.setServiceAmount(amount);
+	            studentPaymentRouteOrder.setCreateTime(date);
+	            studentPaymentRouteOrder.setUpdateTime(date);
+	            studentPaymentRouteOrderDao.insert(studentPaymentRouteOrder);
+	            
+	            Map<String, Object> unionPay = new HashMap<>();
+	            Map<String, Object> payMap = Payment.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody);
+	            
+	            PaymentChannelEnum payType = PaymentChannelEnum.ADAPAY;
+
+	            unionPay.put("orderNo", orderNo);
+	            unionPay.put("type", payType.getCode());
+	            unionPay.put("payMap", payMap);
+	            unionPay.put("routingMerNos", merNo);
+	            return unionPay;
+			}
+			
+		}
+        
         String usePaymentConfig = sysConfigDao.findConfigValue("use_payment_config");// 是否用收费配置(1:使用 0:不使用)
         String usePaymentConfig = sysConfigDao.findConfigValue("use_payment_config");// 是否用收费配置(1:使用 0:不使用)
         List<RouteScaleDto> routeScaleDtos = null;
         List<RouteScaleDto> routeScaleDtos = null;
         //使用配置开关
         //使用配置开关
@@ -145,7 +190,7 @@ public class PayServiceImpl implements PayService {
 	public Map<String, Object> getPayToPlatformMap(PaymentChannelEnum paymentChannel, BigDecimal amount, BigDecimal balanceAmount, String orderNo, String notifyUrl, String returnUrl,
 	public Map<String, Object> getPayToPlatformMap(PaymentChannelEnum paymentChannel, BigDecimal amount, BigDecimal balanceAmount, String orderNo, String notifyUrl, String returnUrl,
 			String orderSubject, String orderBody) throws Exception {
 			String orderSubject, String orderBody) throws Exception {
     	
     	
-    	SysConfig config = sysConfigDao.findByParamName("platform_collection_organ");
+    	/*SysConfig config = sysConfigDao.findByParamName("platform_collection_organ");
         if (Objects.isNull(config)) {
         if (Objects.isNull(config)) {
             throw new BizException("平台收款账户没有设置[platform_collection_organ]");
             throw new BizException("平台收款账户没有设置[platform_collection_organ]");
         }
         }
@@ -156,7 +201,13 @@ public class PayServiceImpl implements PayService {
     		throw new BizException("分部[{}]没有设置收款账号", config.getParanValue());
     		throw new BizException("分部[{}]没有设置收款账号", config.getParanValue());
     	}
     	}
     	
     	
-    	String payeeMerNo = sysPaymentConfig.getHfMerNo();
+    	String payeeMerNo = sysPaymentConfig.getHfMerNo();*/
+    	
+    	String payeeMerNo = sysConfigDao.findConfigValue(SysConfigService.PLATFORM_PAYEE_ACCOUNT);
+    	
+    	if(StringUtils.isBlank(payeeMerNo)){
+    		throw new BizException("平台收款账户查询失败");
+    	}
     	
     	
         Map<String, Object> payMap = null;
         Map<String, Object> payMap = null;