浏览代码

Merge remote-tracking branch 'origin/master'

lianghanqiang 4 年之前
父节点
当前提交
02468af450

+ 26 - 3
src/main/java/org/springblade/common/cache/PlatformCache.java

@@ -15,10 +15,9 @@ import org.springblade.ldt.platform.service.IPlatformSettingService;
 import org.springblade.yeePay.common.YeepayProduct;
 import org.springblade.yeePay.entity.saas.InvitationDto;
 
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
+import java.util.*;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * @author: lianghanqiang
@@ -70,6 +69,30 @@ public class PlatformCache {
 		return null;
 	}
 
+	/**
+	 * 根据类型获取平台默认易宝的产品信息
+	 */
+	public static List<InvitationDto.ProductInfo> productInfo(YeepayProduct[] yeepayProduct) {
+		R res = CacheUtil.get(CacheNames.PLATFORM, PLATFORM_PREFIX, PlatformConst.YEEPAY_PRODUCT_INFO, R.class, false);
+		PlatformSetting platformSetting ;
+		if(Objects.isNull(res)){
+			platformSetting = getSetting(PlatformConst.YEEPAY_PRODUCT_INFO);
+		}else{
+			platformSetting = (PlatformSetting) res.getData();
+		}
+		List<InvitationDto.ProductInfo> productInfos = JSON.parseArray(platformSetting.getSettingValue(), InvitationDto.ProductInfo.class);
+		List<InvitationDto.ProductInfo> result = new LinkedList<>();
+		//所有产品码
+		Set<String> yeepayProductSet = Arrays.stream(yeepayProduct).map(YeepayProduct::name).collect(Collectors.toSet());
+		//遍历产品信息
+		for (InvitationDto.ProductInfo productInfo : productInfos) {
+			if(yeepayProductSet.contains(productInfo.getProductCode().name())){
+				result.add(productInfo);
+			}
+		}
+		return result;
+	}
+
 	private static PlatformSetting getSetting(String key) {
 		return platformSettingService.getOne(new QueryWrapper<PlatformSetting>().lambda()
 			.eq(PlatformSetting::getSettingKey, key));

+ 9 - 0
src/main/java/org/springblade/gateway/mall_gateway/controller/MallYeePayProductController.java

@@ -10,6 +10,8 @@ import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
+import org.springblade.common.cache.PlatformCache;
+import org.springblade.common.config.yeepay.OpenProduct;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.tenant.annotation.TenantIgnore;
 import org.springblade.core.tool.api.R;
@@ -132,4 +134,11 @@ public class MallYeePayProductController {
 		}
 		return R.data(0);
 	}
+
+	@ApiOperation("根据商户获取平台默认产品费率")
+	@GetMapping("getProductFeeByMall")
+	public R getProductFeeByShop(){
+		List<InvitationDto.ProductInfo> productInfos = PlatformCache.productInfo(OpenProduct.MERCHANT_PRODUCTS);
+		return R.data(productInfos);
+	}
 }

+ 9 - 1
src/main/java/org/springblade/gateway/shop_gateway/controller/ShopYeePayProduceController.java

@@ -10,10 +10,11 @@ import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.springblade.common.cache.PlatformCache;
+import org.springblade.common.config.yeepay.OpenProduct;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.tenant.annotation.TenantIgnore;
 import org.springblade.core.tool.api.R;
-import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.ldt.fee.entity.ProductFee;
 import org.springblade.ldt.fee.service.IProductFeeService;
 import org.springblade.ldt.shop.entity.Shop;
@@ -131,4 +132,11 @@ public class ShopYeePayProduceController {
 		}
 		return R.data(0);
 	}
+
+	@ApiOperation("根据商户获取平台默认产品费率")
+	@GetMapping("getProductFeeByShop")
+	public R getProductFeeByShop(){
+		List<InvitationDto.ProductInfo> productInfos = PlatformCache.productInfo(OpenProduct.MICRO_PRODUCTS);
+		return R.data(productInfos);
+	}
 }

+ 2 - 2
src/main/java/org/springblade/payment/plugin/WithdrawPlugin.java

@@ -133,7 +133,7 @@ public class WithdrawPlugin implements Withdraw{
 			.feeChargeSide(transferRec.getFeeChargeSide())
 			.notifyUrl(callbackUrl(PaymentType.YEE_PAY_WITHDRAW.name()))
 			.build();
-		/*transferOrderDto.setParentMerchantNo(yeePayConst.getPlatformServiceNo());
+		transferOrderDto.setParentMerchantNo(yeePayConst.getPlatformServiceNo());
 		YopResponse yopResponse = yeepaySaasService.transferOrder(transferOrderDto);
 		JSONObject res = JSON.parseObject(yopResponse.getStringResult());
 		if (!Objects.equals(res.getString("returnCode"), "UA00000")) {
@@ -155,7 +155,7 @@ public class WithdrawPlugin implements Withdraw{
 			default:
 				userPointWithdrawFail(transferRec, res);
 				break;
-		}*/
+		}
 
 		return R.data(null);
 	}