july пре 4 година
родитељ
комит
b5a9750af6

+ 6 - 1
src/main/java/org/springblade/common/enums/PaymentType.java

@@ -14,7 +14,12 @@ public enum PaymentType {
 	/**
 	 *	易宝支付
 	 **/
-	YEE_PAY("yeePay");
+	YEE_PAY("yeePay"),
+
+	/**
+	 * 易宝提现
+	 */
+	YEE_PAY_WITHDRAW("yeePay_withdraw");
 
 
 	String name;

+ 0 - 4
src/main/java/org/springblade/gateway/common_gateway/controller/PaymentController.java

@@ -57,10 +57,6 @@ public class PaymentController {
 				return payment.transfer(payParam);
 			case MINI_PROGRAM:
 				return payment.miniProgram(payParam);
-			case USER_WITHDRAW:
-				return payment.userWithdraw(payParam);
-			case USER_POINT_WITHDRAW:
-				return payment.userPointWithdraw(payParam);
 			default:
 				return null;
 		}

+ 81 - 0
src/main/java/org/springblade/gateway/common_gateway/controller/WithdrawController.java

@@ -0,0 +1,81 @@
+package org.springblade.gateway.common_gateway.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springblade.common.enums.PaymentScene;
+import org.springblade.common.enums.PaymentType;
+import org.springblade.common.enums.ResCode;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.tool.api.R;
+import org.springblade.payment.entity.PayParam;
+import org.springblade.payment.plugin.Payment;
+import org.springblade.payment.plugin.PaymentBuilder;
+import org.springblade.payment.plugin.Withdraw;
+import org.springblade.payment.plugin.WithdrawPlugin;
+import org.springblade.yeePay.service.YeePayService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Optional;
+
+/**
+ * @Author July
+ * @Description 提现模式
+ * @Date 2021/10/22 16:23
+ */
+@Api(tags = "提现模块")
+@RestController
+@RequestMapping("/withdraw")
+public class WithdrawController {
+
+	@Autowired
+	PaymentBuilder paymentBuilder;
+
+	@Autowired
+	YeePayService yeePayService;
+
+	@ApiOperation("提现")
+	@GetMapping("/{withdrawType}/{paymentScene}")
+	public R payOrder(@PathVariable String withdrawType, @PathVariable String paymentScene, @Validated PayParam payParam) {
+		//获取支付插件
+		Withdraw withdraw = pluginBuild(withdrawType);
+		//解析支付场景
+		PaymentScene scene = Optional.of(PaymentScene.valueOf(paymentScene))
+			.orElseThrow(() -> new ServiceException(ResCode.PAY_SCENE_ERROR));
+		switch (scene) {
+			case USER_WITHDRAW:
+				return withdraw.userWithdraw(payParam);
+			case USER_POINT_WITHDRAW:
+				return withdraw.userPointWithdraw(payParam);
+			default:
+				return null;
+		}
+	}
+
+	@GetMapping("support")
+	@ApiOperation("获取支付类型列表")
+	public R<PaymentType[]> getSupportList() {
+		return R.data(PaymentType.values());
+	}
+
+
+	@ApiOperation(value = "提现回调")
+	@RequestMapping(value = "/callback/{withdrawType}", method = {RequestMethod.GET, RequestMethod.POST})
+	public String callback(HttpServletRequest request, @PathVariable String withdrawType) {
+		System.out.println("我是回调:");
+		//获取支付插件
+		Withdraw payment = pluginBuild(withdrawType);
+		payment.callback(request);
+		return "SUCCESS";
+	}
+
+	private Withdraw pluginBuild(String paymentType) {
+		return paymentBuilder.fetchWithdrawPlugin(
+			Optional.of(PaymentType.valueOf(paymentType))
+				.orElseThrow(() -> new ServiceException(ResCode.PAY_TYPE_ERROR))
+		);
+	}
+
+}

+ 2 - 2
src/main/java/org/springblade/payment/callback/trade/UserPointTransferWithdrawCallback.java

@@ -62,7 +62,7 @@ public class UserPointTransferWithdrawCallback {
 			.bankAccountNo(withdrawRec.getReceiverAccountNo())
 			.receiveType(YeepayApiConstant.receiveType.valueOf(withdrawRec.getReceiveType()))
 			.orderAmount(successParams.getTotalPrice().toPlainString())
-			.notifyUrl(yeePayConst.getServiceUrl() + "/payment/callback/YEE_PAY")
+			.notifyUrl(yeePayConst.getServiceUrl() + "/withdraw/callback/YEE_PAY_WITHDRAW")
 			.build();
 		withdrawRec.setRequestNo(requestNo);
 		withdrawRecService.saveOrUpdate(withdrawRec);
@@ -84,6 +84,6 @@ public class UserPointTransferWithdrawCallback {
 			.withdrawRecId(withdrawRec.getId())
 			.build();
 
-		PaymentCache.putSuccessParams(Convert.toStr(notifySuccessParams.getWithdrawRecId()), notifySuccessParams);
+		PaymentCache.putSuccessParams(Convert.toStr(requestNo), notifySuccessParams);
 	}
 }

+ 0 - 13
src/main/java/org/springblade/payment/plugin/Payment.java

@@ -26,14 +26,6 @@ public interface Payment {
 	 */
 	R nativePay(PayParam payParam);
 
-	/**
-	 * 用户提现
-	 *
-	 * @param payParam
-	 * @return
-	 */
-	R userWithdraw(PayParam payParam);
-
 	/**
 	 * 收款码支付
 	 */
@@ -78,9 +70,4 @@ public interface Payment {
 
 	R miniProgram(PayParam payParam);
 
-	/**
-	 * 用户积分提现
-	 */
-	R userPointWithdraw(PayParam payParam);
-
 }

+ 13 - 3
src/main/java/org/springblade/payment/plugin/PaymentBuilder.java

@@ -6,7 +6,7 @@ import org.springframework.stereotype.Component;
 
 /**
  * @author: lianghanqiang
- * @description:  支付插件构造工厂
+ * @description: 支付插件构造工厂
  * @since: 7/29/21 -- 2:54 PM
  */
 @Component
@@ -14,13 +14,23 @@ import org.springframework.stereotype.Component;
 public class PaymentBuilder {
 
 	YeePayPlugin yeePayPlugin;
+	WithdrawPlugin withdrawPlugin;
 
-	public Payment fetchPaymentPlugin(PaymentType paymentType){
-		switch (paymentType){
+	public Payment fetchPaymentPlugin(PaymentType paymentType) {
+		switch (paymentType) {
 			case YEE_PAY:
 				return yeePayPlugin;
 			default:
 		}
 		return null;
 	}
+
+	public Withdraw fetchWithdrawPlugin(PaymentType paymentType) {
+		switch (paymentType) {
+			case YEE_PAY_WITHDRAW:
+				return withdrawPlugin;
+			default:
+		}
+		return null;
+	}
 }

+ 44 - 0
src/main/java/org/springblade/payment/plugin/Withdraw.java

@@ -0,0 +1,44 @@
+package org.springblade.payment.plugin;
+
+import org.springblade.core.tool.api.R;
+import org.springblade.payment.entity.PayParam;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author July
+ * @version 1.0.0
+ * @ClassName Withdraw.java
+ * @Description 提现插件抽象层
+ * @createTime 2021年10月22日 16:24:00
+ */
+public interface Withdraw {
+	String CALLBACK_DOMAIN = "https://ldt.guosen-fumao.cn/api";
+
+	String CALLBACK_PREFIX = "/withdraw/callback/";
+
+	/**
+	 * 支付回调
+	 */
+	void callback(HttpServletRequest request);
+
+	/**
+	 * 用户提现
+	 *
+	 * @param payParam
+	 * @return
+	 */
+	R userWithdraw(PayParam payParam);
+
+	/**
+	 * 用户积分提现
+	 */
+	R userPointWithdraw(PayParam payParam);
+
+	/**
+	 * 获取回调地址
+	 */
+	default String callbackUrl(String paymentType) {
+		return CALLBACK_DOMAIN + CALLBACK_PREFIX + paymentType;
+	}
+}

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

@@ -0,0 +1,263 @@
+package org.springblade.payment.plugin;
+
+import cn.hutool.core.convert.Convert;
+import cn.hutool.core.lang.Assert;
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.yeepay.yop.sdk.service.common.response.YopResponse;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springblade.common.cache.PaymentCache;
+import org.springblade.common.enums.OrderType;
+import org.springblade.common.enums.PaymentType;
+import org.springblade.common.enums.TransferStatus;
+import org.springblade.common.enums.WithdrawStatus;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.tool.api.R;
+import org.springblade.ldt.bills.entity.TransferRec;
+import org.springblade.ldt.bills.entity.WithdrawRec;
+import org.springblade.ldt.bills.service.IBillsService;
+import org.springblade.ldt.bills.service.ITransferRecService;
+import org.springblade.ldt.bills.service.IWithdrawRecService;
+import org.springblade.ldt.shop.entity.Shop;
+import org.springblade.ldt.shop.service.IShopService;
+import org.springblade.ldt.user.service.ILoginUserService;
+import org.springblade.payment.entity.PayParam;
+import org.springblade.payment.entity.SuccessParams;
+import org.springblade.payment.event.UserPointTransferWithdrawEvent;
+import org.springblade.payment.handle.entity.HandleTransferData;
+import org.springblade.payment.service.impl.PaymentService;
+import org.springblade.yeePay.common.YeePayConst;
+import org.springblade.yeePay.common.YeepayApiConstant;
+import org.springblade.yeePay.entity.saas.account.TransferB2bQueryDto;
+import org.springblade.yeePay.entity.saas.account.TransferOrderDto;
+import org.springblade.yeePay.entity.saas.settlement.SettleSelfSettleApplyDto;
+import org.springblade.yeePay.service.YeePayService;
+import org.springblade.yeePay.service.YeepaySaasService;
+import org.springframework.context.ApplicationEventPublisher;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Objects;
+import java.util.Set;
+
+/**
+ * @author July
+ * @version 1.0.0
+ * @ClassName WithdrawPlugin.java
+ * @Description 提现插件
+ * @createTime 2021年10月22日 16:26:00
+ */
+@Component
+@Slf4j
+@AllArgsConstructor
+public class WithdrawPlugin implements Withdraw{
+
+	YeePayService yeePayService;
+	IBillsService billsService;
+	ILoginUserService loginUserService;
+	PaymentService paymentService;
+	YeepaySaasService yeepaySaasService;
+	IWithdrawRecService withdrawRecService;
+	YeePayConst yeePayConst;
+	IShopService shopService;
+	ApplicationEventPublisher eventPublisher;
+	ITransferRecService transferRecService;
+
+	@Override
+	public void callback(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("requestNo"));
+
+		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 R userWithdraw(PayParam payParam) {
+		WithdrawRec withdrawRecord = withdrawRecService.getById(payParam.getOrderId());
+		Assert.notNull(withdrawRecord, "提现申请查询失败,无此申请信息!");
+
+		Shop shop = shopService.getOne(Wrappers.<Shop>lambdaQuery().select(Shop::getMerchantNo).eq(Shop::getId, withdrawRecord.getOwnerId()));
+		Assert.notNull(withdrawRecord, "提现申请查询失败,无此申请商户信息!");
+
+		SettleSelfSettleApplyDto settleSelfSettleApplyDto = SettleSelfSettleApplyDto.builder()
+			.parentMerchantNo(yeePayConst.getPlatformServiceNo())
+			.merchantNo(shop.getMerchantNo())
+			.settleRequestNo(IdUtil.simpleUUID())
+			.notifyUrl(callbackUrl(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")) {
+			throw new ServiceException(res.getString("message"));
+		}
+		return R.data(res);
+	}
+
+	/**
+	 * @param payParam:
+	 * @Return R
+	 * @Author July
+	 * @Description 用户积分提现
+	 * @Date 2021/10/19 16:09
+	 */
+	@Override
+	public R userPointWithdraw(PayParam payParam) {
+		TransferRec transferRec = transferRecService.getById(payParam.getOrderId());
+		Assert.notNull(transferRec, "订单查询失败,无此订单信息!");
+
+		//从平台转账到用户的易宝商户账号中
+		Shop shop = shopService.getById(transferRec.getOwnerId());
+		String requestNo = IdUtil.simpleUUID();
+		TransferOrderDto transferOrderDto = TransferOrderDto.builder()
+			.fromMerchantNo(yeePayConst.getPlatformServiceNo())
+			.toMerchantNo(shop.getMerchantNo())
+			.orderAmount(transferRec.getPrice().toPlainString())
+			.requestNo(requestNo)
+			.usage("用户积分提现转账!")
+			.feeChargeSide(transferRec.getFeeChargeSide())
+			.notifyUrl(callbackUrl(PaymentType.YEE_PAY_WITHDRAW.name()))
+			.build();
+		transferOrderDto.setParentMerchantNo(yeePayConst.getPlatformServiceNo());
+		YopResponse yopResponse = yeepaySaasService.transferOrder(transferOrderDto);
+		JSONObject res = JSON.parseObject(yopResponse.getStringResult());
+		if (!Objects.equals(res.getString("returnCode"), "UA00000")) {
+			userPointWithdrawFail(transferRec, res);
+			throw new ServiceException(res.getString("returnMsg"));
+		}
+
+		String transferStatus = res.getString("transferStatus");
+		switch (transferStatus) {
+			case "SUCCESS":
+				userPointWithdrawSuccess(res, transferRec, requestNo);
+				break;
+			case "REQUEST_RECEIVE":
+				PaymentCache.addTransferApply(HandleTransferData.builder()
+					.transferRec(transferRec)
+					.requestNo(requestNo)
+					.build());
+				break;
+			default:
+				userPointWithdrawFail(transferRec, res);
+				break;
+		}
+
+		return R.data(res);
+	}
+
+	/**
+	 * @param transferRec: 转账信息
+	 * @param res:         易宝返回数据
+	 * @Return void
+	 * @Author July
+	 * @Description 处理转账申请失败
+	 * @Date 2021/10/21 17:42
+	 */
+	private void userPointWithdrawFail(TransferRec transferRec, JSONObject res) {
+		//更新提现记录
+		WithdrawRec withdrawRec = withdrawRecService.getById(transferRec.getWithdrawId());
+		withdrawRec.setWithdrawStatus(WithdrawStatus.FAIL.getValue());
+		withdrawRec.setResponseJson(res.toJSONString());
+		withdrawRecService.saveOrUpdate(withdrawRec);
+
+		//更新转账记录
+		transferRec.setTransferStatus(TransferStatus.FAIL);
+		withdrawRec.setFailReason(res.toJSONString());
+		transferRecService.saveOrUpdate(transferRec);
+	}
+
+	/**
+	 * @param requestNo:   商户请求号
+	 * @param transferRec: 转账信息
+	 * @param res:         易宝返回数据
+	 * @Author July
+	 * @Description 处理转账成功发起提现申请
+	 * @Date 2021/10/21 17:42
+	 */
+	private void userPointWithdrawSuccess(JSONObject res, TransferRec transferRec, String requestNo) {
+
+		//更新转账记录
+		transferRec.setFee(res.getBigDecimal("fee"));
+		transferRec.setTransferStatus(TransferStatus.SUCCESS);
+		transferRec.setReceiveAmount(res.getBigDecimal("receiveAmount"));
+		transferRec.setRequestNo(requestNo);
+		transferRec.setResponseJson(res.toJSONString());
+		transferRec.setThirdOrderId(res.getString("orderNo"));
+		transferRecService.saveOrUpdate(transferRec);
+
+		//支付参数
+		SuccessParams successParams = SuccessParams.builder()
+			.orderType(OrderType.USER_POINT_TRANSFER_WITHDRAW.name())
+			.status(WithdrawStatus.WAITING.getValue())
+			.userId(transferRec.getOwnerId())
+			.totalPrice(transferRec.getReceiveAmount())
+			.shopId(transferRec.getOwnerId())
+			.tenantId(transferRec.getTenantId())
+			.withdrawRecId(transferRec.getWithdrawId())
+			.build();
+		PaymentCache.putSuccessParams(Convert.toStr(requestNo), successParams);
+
+		eventPublisher.publishEvent(new UserPointTransferWithdrawEvent(successParams));
+
+	}
+
+	/**
+	 * @Author July
+	 * @Description 处理用户积分提现的转账结果
+	 * @Date 2021/10/22 10:29
+	 */
+	@Scheduled(cron = "0 */1 * * * ?")
+	public void handleUserPointWithdrawTransferResult() {
+		Set<HandleTransferData> queue = PaymentCache.getTransferApplyList();
+		if (ObjectUtil.isNotEmpty(queue) && queue.size() > 0) {
+			log.info("定时任务开始,查询队列中的待处理的转账记录!,队列数:{}", queue.size());
+			queue.forEach(handleTransferData -> {
+				//查询分账结果
+				log.info("进行转账结果查询:{}", handleTransferData.getTransferRec().getId());
+				TransferRec transferRec = transferRecService.getById(handleTransferData.getTransferRec().getId());
+				Assert.notNull(transferRec, "转账订单查询失败,无此订单信息!" + transferRec.getId());
+
+				TransferB2bQueryDto transferB2bQueryDto = TransferB2bQueryDto.builder()
+					.parentMerchantNo(yeePayConst.getPlatformServiceNo())
+					.requestNo(handleTransferData.getRequestNo())
+					.build();
+				YopResponse yopResponse = yeepaySaasService.transferB2bQuery(transferB2bQueryDto);
+				JSONObject res = JSON.parseObject(yopResponse.getStringResult());
+				if (!Objects.equals(res.getString("returnCode"), "UA00000")) {
+					userPointWithdrawFail(transferRec, res);
+					throw new ServiceException(res.getString("returnMsg"));
+				}
+
+				String transferStatus = res.getString("transferStatus");
+				switch (transferStatus) {
+					case "SUCCESS":
+						userPointWithdrawSuccess(res, transferRec, handleTransferData.getRequestNo());
+						PaymentCache.completeTransferApply(handleTransferData);
+						break;
+					case "FAIL":
+						userPointWithdrawFail(transferRec, res);
+						break;
+					default:
+						break;
+				}
+			});
+		}
+	}
+}

+ 0 - 171
src/main/java/org/springblade/payment/plugin/YeePayPlugin.java

@@ -91,28 +91,7 @@ public class YeePayPlugin implements Payment {
 		return R.data(yeepaySaasService.payLinkOrder(payLinkOrderDto));
 	}
 
-	@Override
-	public R userWithdraw(PayParam payParam) {
-		WithdrawRec withdrawRecord = withdrawRecService.getById(payParam.getOrderId());
-		Assert.notNull(withdrawRecord, "提现申请查询失败,无此申请信息!");
-
-		Shop shop = shopService.getOne(Wrappers.<Shop>lambdaQuery().select(Shop::getMerchantNo).eq(Shop::getId, withdrawRecord.getOwnerId()));
-		Assert.notNull(withdrawRecord, "提现申请查询失败,无此申请商户信息!");
 
-		SettleSelfSettleApplyDto settleSelfSettleApplyDto = SettleSelfSettleApplyDto.builder()
-			.parentMerchantNo(yeePayConst.getPlatformServiceNo())
-			.merchantNo(shop.getMerchantNo())
-			.settleRequestNo(IdUtil.simpleUUID())
-			.notifyUrl(callbackUrl(PaymentType.YEE_PAY.name()))
-			.operatePeriod(YeepayApiConstant.operatePeriod.ALL)
-			.build();
-		YopResponse yopResponse = yeepaySaasService.settleSelfSettleApply(settleSelfSettleApplyDto);
-		JSONObject res = JSON.parseObject(yopResponse.getStringResult());
-		if (!Objects.equals(res.getString("code"), "000000")) {
-			throw new ServiceException(res.getString("message"));
-		}
-		return R.data(res);
-	}
 
 	@Override
 	public R payCode(PayParam payParam) {
@@ -191,114 +170,6 @@ public class YeePayPlugin implements Payment {
 		return R.data(JSON.parseObject(yopResponse.getStringResult()));
 	}
 
-	/**
-	 * @param payParam:
-	 * @Return R
-	 * @Author July
-	 * @Description 用户积分提现
-	 * @Date 2021/10/19 16:09
-	 */
-	@Override
-	public R userPointWithdraw(PayParam payParam) {
-		TransferRec transferRec = transferRecService.getById(payParam.getOrderId());
-		Assert.notNull(transferRec, "订单查询失败,无此订单信息!");
-
-		//从平台转账到用户的易宝商户账号中
-		Shop shop = shopService.getById(transferRec.getOwnerId());
-		String requestNo = IdUtil.simpleUUID();
-		TransferOrderDto transferOrderDto = TransferOrderDto.builder()
-			.fromMerchantNo(yeePayConst.getPlatformServiceNo())
-			.toMerchantNo(shop.getMerchantNo())
-			.orderAmount(transferRec.getPrice().toPlainString())
-			.requestNo(requestNo)
-			.usage("用户积分提现转账!")
-			.feeChargeSide(transferRec.getFeeChargeSide())
-			.notifyUrl(callbackUrl(PaymentType.YEE_PAY.name()))
-			.build();
-		transferOrderDto.setParentMerchantNo(yeePayConst.getPlatformServiceNo());
-		YopResponse yopResponse = yeepaySaasService.transferOrder(transferOrderDto);
-		JSONObject res = JSON.parseObject(yopResponse.getStringResult());
-		if (!Objects.equals(res.getString("returnCode"), "UA00000")) {
-			userPointWithdrawFail(transferRec, res);
-			throw new ServiceException(res.getString("returnMsg"));
-		}
-
-		String transferStatus = res.getString("transferStatus");
-		switch (transferStatus) {
-			case "SUCCESS":
-				userPointWithdrawSuccess(res, transferRec, requestNo);
-				break;
-			case "REQUEST_RECEIVE":
-				PaymentCache.addTransferApply(HandleTransferData.builder()
-					.transferRec(transferRec)
-					.requestNo(requestNo)
-					.build());
-				break;
-			default:
-				userPointWithdrawFail(transferRec, res);
-				break;
-		}
-
-		return R.data(res);
-	}
-
-	/**
-	 * @param transferRec: 转账信息
-	 * @param res:         易宝返回数据
-	 * @Return void
-	 * @Author July
-	 * @Description 处理转账申请失败
-	 * @Date 2021/10/21 17:42
-	 */
-	private void userPointWithdrawFail(TransferRec transferRec, JSONObject res) {
-		//更新提现记录
-		WithdrawRec withdrawRec = withdrawRecService.getById(transferRec.getWithdrawId());
-		withdrawRec.setWithdrawStatus(WithdrawStatus.FAIL.getValue());
-		withdrawRec.setResponseJson(res.toJSONString());
-		withdrawRecService.saveOrUpdate(withdrawRec);
-
-		//更新转账记录
-		transferRec.setTransferStatus(TransferStatus.FAIL);
-		withdrawRec.setFailReason(res.toJSONString());
-		transferRecService.saveOrUpdate(transferRec);
-	}
-
-	/**
-	 * @param requestNo:   商户请求号
-	 * @param transferRec: 转账信息
-	 * @param res:         易宝返回数据
-	 * @Author July
-	 * @Description 处理转账成功发起提现申请
-	 * @Date 2021/10/21 17:42
-	 */
-	private void userPointWithdrawSuccess(JSONObject res, TransferRec transferRec, String requestNo) {
-
-		//更新转账记录
-		transferRec.setFee(res.getBigDecimal("fee"));
-		transferRec.setTransferStatus(TransferStatus.SUCCESS);
-		transferRec.setReceiveAmount(res.getBigDecimal("receiveAmount"));
-		transferRec.setRequestNo(requestNo);
-		transferRec.setResponseJson(res.toJSONString());
-		transferRec.setThirdOrderId(res.getString("orderNo"));
-		transferRecService.saveOrUpdate(transferRec);
-
-		//支付参数
-		SuccessParams successParams = SuccessParams.builder()
-			.orderType(OrderType.USER_POINT_TRANSFER_WITHDRAW.name())
-			.status(WithdrawStatus.WAITING.getValue())
-			.userId(transferRec.getOwnerId())
-			.totalPrice(transferRec.getReceiveAmount())
-			.shopId(transferRec.getOwnerId())
-			.tenantId(transferRec.getTenantId())
-			.withdrawRecId(transferRec.getWithdrawId())
-			.build();
-		PaymentCache.putSuccessParams(Convert.toStr(successParams.getWithdrawRecId()), successParams);
-
-		eventPublisher.publishEvent(new UserPointTransferWithdrawEvent(successParams));
-
-	}
-
-
 	private void orderTypeHandle(MerchantInfo merchantInfo, OrderType orderType, Bills bills) {
 		switch (orderType) {
 			case WECHAT_PAY:
@@ -328,46 +199,4 @@ public class YeePayPlugin implements Payment {
 		}
 	}
 
-	/**
-	 * @Author July
-	 * @Description 处理用户积分提现的转账结果
-	 * @Date 2021/10/22 10:29
-	 */
-	@Scheduled(cron = "0 */1 * * * ?")
-	public void handleUserPointWithdrawTransferResult() {
-		Set<HandleTransferData> queue = PaymentCache.getTransferApplyList();
-		if (ObjectUtil.isNotEmpty(queue) && queue.size() > 0) {
-			log.info("定时任务开始,查询队列中的待处理的转账记录!,队列数:{}", queue.size());
-			queue.forEach(handleTransferData -> {
-				//查询分账结果
-				log.info("进行转账结果查询:{}", handleTransferData.getTransferRec().getId());
-				TransferRec transferRec = transferRecService.getById(handleTransferData.getTransferRec().getId());
-				Assert.notNull(transferRec, "转账订单查询失败,无此订单信息!" + transferRec.getId());
-
-				TransferB2bQueryDto transferB2bQueryDto = TransferB2bQueryDto.builder()
-					.parentMerchantNo(yeePayConst.getPlatformServiceNo())
-					.requestNo(handleTransferData.getRequestNo())
-					.build();
-				YopResponse yopResponse = yeepaySaasService.transferB2bQuery(transferB2bQueryDto);
-				JSONObject res = JSON.parseObject(yopResponse.getStringResult());
-				if (!Objects.equals(res.getString("returnCode"), "UA00000")) {
-					userPointWithdrawFail(transferRec, res);
-					throw new ServiceException(res.getString("returnMsg"));
-				}
-
-				String transferStatus = res.getString("transferStatus");
-				switch (transferStatus) {
-					case "SUCCESS":
-						userPointWithdrawSuccess(res, transferRec, handleTransferData.getRequestNo());
-						PaymentCache.completeTransferApply(handleTransferData);
-						break;
-					case "FAIL":
-						userPointWithdrawFail(transferRec, res);
-						break;
-					default:
-						break;
-				}
-			});
-		}
-	}
 }

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

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