Quellcode durchsuchen

修改余额提现

july vor 4 Jahren
Ursprung
Commit
943f35a123

+ 11 - 1
src/main/java/org/springblade/gateway/common_gateway/controller/WithdrawController.java

@@ -54,7 +54,17 @@ public class WithdrawController {
 		}
 	}
 
-	@ApiOperation(value = "提现回调")
+	@ApiOperation(value = "余额提现回调")
+	@RequestMapping(value = "/csUrl/{withdrawType}", method = {RequestMethod.GET, RequestMethod.POST})
+	public String balanceCallback(HttpServletRequest request, @PathVariable String withdrawType) {
+		System.out.println("我是回调:");
+		//获取支付插件
+		Withdraw payment = pluginBuild(withdrawType);
+		payment.csUrl(request);
+		return "SUCCESS";
+	}
+
+	@ApiOperation(value = "积分提现回调")
 	@RequestMapping(value = "/callback/{withdrawType}", method = {RequestMethod.GET, RequestMethod.POST})
 	public String callback(HttpServletRequest request, @PathVariable String withdrawType) {
 		System.out.println("我是回调:");

+ 14 - 1
src/main/java/org/springblade/payment/plugin/Withdraw.java

@@ -16,12 +16,18 @@ public interface Withdraw {
 	String CALLBACK_DOMAIN = "https://ldt.guosen-fumao.cn/api";
 
 	String CALLBACK_PREFIX = "/withdraw/callback/";
+	String CSURL_PREFIX = "/withdraw/csurl/";
 
 	/**
-	 * 支付回调
+	 * 积分提现回调
 	 */
 	void callback(HttpServletRequest request);
 
+	/**
+	 * 余额提现回调
+	 */
+	void csUrl(HttpServletRequest request);
+
 	/**
 	 * 用户提现
 	 *
@@ -41,4 +47,11 @@ public interface Withdraw {
 	default String callbackUrl(String paymentType) {
 		return CALLBACK_DOMAIN + CALLBACK_PREFIX + paymentType;
 	}
+
+	/**
+	 * 获取回调地址
+	 */
+	default String csUrl(String paymentType) {
+		return CALLBACK_DOMAIN + CSURL_PREFIX + paymentType;
+	}
 }

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

@@ -76,7 +76,26 @@ public class WithdrawPlugin implements Withdraw {
 
 		SuccessParams successParams = PaymentCache.getSuccessParams(jsonObject.getString("requestNo"));
 
-		Assert.notNull(successParams, "提现订单超时,请重新提交!!");
+		Assert.notNull(successParams, "积分提现订单超时,请重新提交!!");
+		successParams.setRes(jsonObject);
+		successParams.setStatus(
+			"SUCCESS".equals(jsonObject.getString("status")) ?
+				SuccessParams.PAY_STATUS_SUCCESS :
+				SuccessParams.PAY_STATUS_FAIL);
+		//处理付款后业务流程
+		paymentService.success(successParams);
+	}
+
+	@Override
+	public void csUrl(HttpServletRequest request) {
+		log.info("易宝网关支付回调: map" + JSON.toJSONString(request.getParameterMap()));
+
+		JSONObject jsonObject = yeePayService.deCodeNotifyData(request.getParameterMap().get("cipherText")[0]);
+		log.info("易宝网关支付解密回调密文:" + jsonObject.toJSONString());
+
+		SuccessParams successParams = PaymentCache.getSuccessParams(jsonObject.getString("settleRequestNo"));
+
+		Assert.notNull(successParams, "余额提现订单超时,请重新提交!!");
 		successParams.setRes(jsonObject);
 		successParams.setStatus(
 			"SUCCESS".equals(jsonObject.getString("status")) ?
@@ -88,24 +107,45 @@ public class WithdrawPlugin implements Withdraw {
 
 	@Override
 	public R userWithdraw(PayParam payParam) {
-		WithdrawRec withdrawRecord = withdrawRecService.getById(payParam.getOrderId());
-		Assert.notNull(withdrawRecord, "提现申请查询失败,无此申请信息!");
+		WithdrawRec withdrawRec = withdrawRecService.getById(payParam.getOrderId());
+		Assert.notNull(withdrawRec, "提现申请查询失败,无此申请信息!");
 
-		Shop shop = shopService.getOne(Wrappers.<Shop>lambdaQuery().select(Shop::getMerchantNo).eq(Shop::getId, withdrawRecord.getOwnerId()));
-		Assert.notNull(withdrawRecord, "提现申请查询失败,无此申请商户信息!");
+		Shop shop = shopService.getOne(Wrappers.<Shop>lambdaQuery().select(Shop::getMerchantNo).eq(Shop::getId, withdrawRec.getOwnerId()));
+		Assert.notNull(withdrawRec, "提现申请查询失败,无此申请商户信息!");
 
+		String settleRequestNo = IdUtil.simpleUUID();
 		SettleSelfSettleApplyDto settleSelfSettleApplyDto = SettleSelfSettleApplyDto.builder()
 			.parentMerchantNo(yeePayConst.getPlatformServiceNo())
 			.merchantNo(shop.getMerchantNo())
-			.settleRequestNo(IdUtil.simpleUUID())
-			.notifyUrl(callbackUrl(PaymentType.YEE_PAY_WITHDRAW.name()))
+			.settleRequestNo(settleRequestNo)
+			.notifyUrl(csUrl(PaymentType.YEE_PAY_WITHDRAW.name()))
 			.operatePeriod(YeepayApiConstant.operatePeriod.ALL)
 			.build();
 		YopResponse yopResponse = yeepaySaasService.settleSelfSettleApply(settleSelfSettleApplyDto);
 		JSONObject res = JSON.parseObject(yopResponse.getStringResult());
 		if (!Objects.equals(res.getString("code"), "000000")) {
+
+			withdrawRec.setWithdrawStatus(WithdrawStatus.FAIL.getValue());
+			withdrawRec.setFailReason(res.getString("message"));
+			withdrawRec.setResponseJson(res.toJSONString());
+			withdrawRecService.saveOrUpdate(withdrawRec);
+
+			bladeLogger.info("userWithdraw-结算", res.toJSONString());
 			throw new ServiceException(res.getString("message"));
 		}
+
+		//支付参数
+		SuccessParams successParams = SuccessParams.builder()
+			.orderType(OrderType.USER_WITHDRAW.name())
+			.status(WithdrawStatus.WAITING.getValue())
+			.userId(withdrawRec.getOwnerId())
+			.totalPrice(withdrawRec.getActualPrice())
+			.shopId(withdrawRec.getOwnerId())
+			.tenantId(withdrawRec.getTenantId())
+			.withdrawRecId(withdrawRec.getId())
+			.build();
+		PaymentCache.putSuccessParams(Convert.toStr(settleRequestNo), successParams);
+
 		return R.data(res);
 	}
 

+ 1 - 0
src/main/resources/application.yml

@@ -203,6 +203,7 @@ blade:
       - /mall/yeepay/product/fee/modifyProductFeeNotify
       - /shop/yeepay/product/fee/modifyProductFeeNotify
       - /withdraw/callback/**
+      - /withdraw/csurl/**
     #授权认证配置
     auth:
       - method: ALL