Просмотр исходного кода

Merge branch 'master' of http://192.168.1.218:3000/lianghanqiang/ldt

lianghanqiang 4 лет назад
Родитель
Сommit
b3e98996a6
17 измененных файлов с 431 добавлено и 208 удалено
  1. 6 1
      src/main/java/org/springblade/common/enums/PaymentType.java
  2. 5 7
      src/main/java/org/springblade/gateway/common_gateway/controller/AppBillsController.java
  3. 0 4
      src/main/java/org/springblade/gateway/common_gateway/controller/PaymentController.java
  4. 75 0
      src/main/java/org/springblade/gateway/common_gateway/controller/WithdrawController.java
  5. 2 2
      src/main/java/org/springblade/gateway/mall_gateway/controller/MallYeePayProductController.java
  6. 2 2
      src/main/java/org/springblade/gateway/shop_gateway/controller/ShopYeePayProduceController.java
  7. 10 0
      src/main/java/org/springblade/ldt/bills/entity/Bills.java
  8. 5 0
      src/main/java/org/springblade/payment/callback/trade/UserPayCS.java
  9. 5 0
      src/main/java/org/springblade/payment/callback/trade/UserPayCallback.java
  10. 2 3
      src/main/java/org/springblade/payment/callback/trade/UserPointTransferWithdrawCallback.java
  11. 0 1
      src/main/java/org/springblade/payment/callback/trade/UserPointWithdrawCallback.java
  12. 0 13
      src/main/java/org/springblade/payment/plugin/Payment.java
  13. 13 3
      src/main/java/org/springblade/payment/plugin/PaymentBuilder.java
  14. 44 0
      src/main/java/org/springblade/payment/plugin/Withdraw.java
  15. 261 0
      src/main/java/org/springblade/payment/plugin/WithdrawPlugin.java
  16. 0 172
      src/main/java/org/springblade/payment/plugin/YeePayPlugin.java
  17. 1 0
      src/main/resources/application.yml

+ 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;

+ 5 - 7
src/main/java/org/springblade/gateway/common_gateway/controller/AppBillsController.java

@@ -55,9 +55,7 @@ public class AppBillsController {
 	@GetMapping("/list")
 	@ApiOperationSupport(order = 2)
 	@ApiOperation(value = "分页", notes = "传入bills")
-	public R<IPage<AppBillsVO>> list(Bills bills, Query query,String billType) {
-		String format = DateUtil.format(bills.getCreateTime(), "yyyy-MM");
-		bills.setCreateTime(null);
+	public R<IPage<AppBillsVO>> list(Bills bills, Query query,String billType,String format) {
 		QueryWrapper<Bills> queryWrapper = new QueryWrapper();
 		queryWrapper.lambda()
 			.eq(bills.getReceiveId()!=null,Bills::getReceiveId,bills.getReceiveId())
@@ -115,17 +113,17 @@ public class AppBillsController {
 
 		//获取统计数据
 		int count = billsService.count(Condition.getQueryWrapper(new Bills()).lambda()
-			.eq(Bills::getPayStatus,AppConstant.BillPayStatus.付款成功.name())
 			.eq(billStatisticsDTO.getPayId() != null, Bills::getPayId, billStatisticsDTO.getPayId())
 			.eq(billStatisticsDTO.getReceiveId() != null, Bills::getReceiveId, billStatisticsDTO.getReceiveId())
-			.between(Bills::getCreateTime, DateUtil.beginOfYear(billStatisticsDTO.getQueryDate()), DateUtil.endOfYear(billStatisticsDTO.getQueryDate())));
+			.between(Bills::getCreateTime, DateUtil.beginOfYear(billStatisticsDTO.getQueryDate()), DateUtil.endOfYear(billStatisticsDTO.getQueryDate()))
+			.and(wrapper -> wrapper.eq(Bills::getPayStatus, AppConstant.BillPayStatus.付款成功.name()).or().eq(Bills::getPayStatus, AppConstant.BillPayStatus.已完结.name())));
 
 		//获取合计多少元
 		QueryWrapper<Bills> billsQueryWrapper = Condition.getQueryWrapper(new Bills());
 		billsQueryWrapper.select("SUM(" + billStatisticsDTO.getQueryColumn() + ") as totalMoney")
 			.eq(billStatisticsDTO.getPayId() != null, "pay_id", billStatisticsDTO.getPayId())
 			.eq(billStatisticsDTO.getReceiveId() != null, "receive_id", billStatisticsDTO.getReceiveId())
-			.eq("pay_status", AppConstant.BillPayStatus.付款成功.name())
+			.and(wrapper -> wrapper.eq("pay_status", AppConstant.BillPayStatus.付款成功.name()).or().eq("pay_status", AppConstant.BillPayStatus.已完结.name()))
 			.between("create_time", DateUtil.beginOfYear(billStatisticsDTO.getQueryDate()), DateUtil.endOfYear(billStatisticsDTO.getQueryDate()));
 		Map<String, Object> map = billsService.getMap(billsQueryWrapper);
 		BigDecimal totalMoney = BigDecimal.ZERO;
@@ -136,9 +134,9 @@ public class AppBillsController {
 		QueryWrapper<Bills> queryWrapper = Condition.getQueryWrapper(new Bills());
 		queryWrapper.select("DATE_FORMAT(create_time, '%c') as month, sum("+billStatisticsDTO.getQueryColumn()+") as money")
 			.eq("DATE_FORMAT(create_time, '%Y')", year)
-			.eq("pay_status", AppConstant.BillPayStatus.付款成功.name())
 			.eq(billStatisticsDTO.getPayId() != null, "pay_id", billStatisticsDTO.getPayId())
 			.eq(billStatisticsDTO.getReceiveId() != null, "receive_id", billStatisticsDTO.getReceiveId())
+			.and(wrapper -> wrapper.eq("pay_status", AppConstant.BillPayStatus.付款成功.name()).or().eq("pay_status", AppConstant.BillPayStatus.已完结.name()))
 			.groupBy("month");
 
 		List<Map<String, Object>> listMaps = billsService.listMaps(queryWrapper);

+ 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;
 		}

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

@@ -0,0 +1,75 @@
+package org.springblade.gateway.common_gateway.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springblade.common.enums.PaymentType;
+import org.springblade.common.enums.ResCode;
+import org.springblade.common.enums.WithdrawType;
+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.PaymentBuilder;
+import org.springblade.payment.plugin.Withdraw;
+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
+ */
+@Slf4j
+@Api(tags = "提现模块")
+@RestController
+@RequestMapping("/withdraw")
+public class WithdrawController {
+
+	@Autowired
+	PaymentBuilder paymentBuilder;
+
+	@Autowired
+	YeePayService yeePayService;
+
+	@ApiOperation("提现")
+	@GetMapping("/{type}/{withdrawType}")
+	public R payOrder(@PathVariable String type, @PathVariable String withdrawType, @Validated PayParam payParam) {
+		//获取支付插件
+		Withdraw withdraw = pluginBuild(type);
+		//解析支付场景
+		WithdrawType scene = Optional.of(WithdrawType.valueOf(withdrawType))
+			.orElseThrow(() -> new ServiceException(ResCode.PAY_SCENE_ERROR));
+		switch (scene) {
+			case BALANCE_WITHDRAW:
+				return withdraw.userWithdraw(payParam);
+			case POINT_WITHDRAW:
+				return withdraw.userPointWithdraw(payParam);
+			default:
+				return null;
+		}
+	}
+
+	@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) {
+		log.info("PaymentType枚举值:{}", PaymentType.values());
+		return paymentBuilder.fetchWithdrawPlugin(
+			Optional.of(PaymentType.valueOf(paymentType))
+				.orElseThrow(() -> new ServiceException(ResCode.PAY_TYPE_ERROR))
+		);
+	}
+
+}

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

@@ -109,8 +109,8 @@ public class MallYeePayProductController {
 			.eq(ProductFee::getMerchantNo, productFee.getMerchantNo())
 			.eq(ProductFee::getApplicationNo, productFee.getApplicationNo()));
 		if(oldProductFee!=null){
-			log.error("数据:{}",oldProductFee);
-			oldProductFee.setRequestNo(productFee.getApplicationStatus());
+			log.error("修改前数据:{}",oldProductFee);
+			oldProductFee.setApplicationStatus(productFee.getApplicationStatus());
 			oldProductFee.setAgreementSignUrl(productFee.getAgreementSignUrl());
 			oldProductFee.setAuditOpinion(productFee.getAuditOpinion());
 			oldProductFee.setProgressDescription(productFee.getProgressDescription());

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

@@ -108,8 +108,8 @@ public class ShopYeePayProduceController {
 			.eq(ProductFee::getMerchantNo, productFee.getMerchantNo())
 			.eq(ProductFee::getApplicationNo, productFee.getApplicationNo()));
 		if(oldProductFee!=null){
-			log.error("数据:{}",oldProductFee);
-			oldProductFee.setRequestNo(productFee.getApplicationStatus());
+			log.error("修改前数据:{}",oldProductFee);
+			oldProductFee.setApplicationStatus(productFee.getApplicationStatus());
 			oldProductFee.setAgreementSignUrl(productFee.getAgreementSignUrl());
 			oldProductFee.setAuditOpinion(productFee.getAuditOpinion());
 			oldProductFee.setProgressDescription(productFee.getProgressDescription());

+ 10 - 0
src/main/java/org/springblade/ldt/bills/entity/Bills.java

@@ -172,4 +172,14 @@ public class Bills extends TenantEntity {
 	 */
 	@ApiModelProperty(value = "支付方式")
 	private String payWay;
+
+
+	/**
+	 * 实际到账
+	 * 涉及现金支付就取receiveNumTotald的值,
+	 * 不涉及到现金支付就取cost的值
+	 */
+	@ApiModelProperty(value = "实际到账")
+	private BigDecimal actualIncome;
+
 }

+ 5 - 0
src/main/java/org/springblade/payment/callback/trade/UserPayCS.java

@@ -106,6 +106,11 @@ public class UserPayCS {
 				bills.setMerchantFee(merchantFee);
 				bills.setReceiveNumYp(ypSettleAmount);
 				bills.setReceiveNumTotal(bills.getBalanceNum().add(bills.getPointNum().add(ypSettleAmount)));
+				if (Objects.isNull(bills.getReceiveNumTotal())) {
+					bills.setActualIncome(bills.getCost());
+				}else{
+					bills.setActualIncome(bills.getReceiveNumTotal());
+				}
 			}
 			//账单的总积分服务费
 			bills.setPointFee(balanceBillFee.add(pointBillFee));

+ 5 - 0
src/main/java/org/springblade/payment/callback/trade/UserPayCallback.java

@@ -121,6 +121,11 @@ public class UserPayCallback {
 			bills.setMerchantFee(merchantFee);
 			bills.setReceiveNumYp(ypSettleAmount);
 			bills.setReceiveNumTotal(bills.getBalanceNum().add(bills.getPointNum().add(ypSettleAmount)));
+			if (Objects.isNull(bills.getReceiveNumTotal())) {
+				bills.setActualIncome(bills.getCost());
+			}else{
+				bills.setActualIncome(bills.getReceiveNumTotal());
+			}
 		}catch(Exception e) {
 			log.error(String.format("商户支付回调查询订单异常,%s",bills.getId()));
 		}

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

@@ -46,7 +46,6 @@ public class UserPointTransferWithdrawCallback {
 	private YeePayConst yeePayConst;
 
 	@EventListener
-	@Transactional
 	public void PaySuccess(UserPointTransferWithdrawEvent userPointTransferWithdrawEvent) {
 		SuccessParams successParams = userPointTransferWithdrawEvent.getSuccessParams();
 		Long withdrawRecId = successParams.getWithdrawRecId();
@@ -63,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);
@@ -85,6 +84,6 @@ public class UserPointTransferWithdrawCallback {
 			.withdrawRecId(withdrawRec.getId())
 			.build();
 
-		PaymentCache.putSuccessParams(Convert.toStr(notifySuccessParams.getWithdrawRecId()), notifySuccessParams);
+		PaymentCache.putSuccessParams(Convert.toStr(requestNo), notifySuccessParams);
 	}
 }

+ 0 - 1
src/main/java/org/springblade/payment/callback/trade/UserPointWithdrawCallback.java

@@ -34,7 +34,6 @@ public class UserPointWithdrawCallback {
 	private IShopService shopService;
 
 	@EventListener
-	@Transactional
 	public void PaySuccess(UserPointWithdrawEvent userPointWithdrawEvent) {
 		SuccessParams successParams = userPointWithdrawEvent.getSuccessParams();
 

+ 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;
+	}
+}

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

@@ -0,0 +1,261 @@
+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;
+	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(null);
+	}
+
+	/**
+	 * @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 - 172
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,115 +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
-	@Transactional
-	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:
@@ -329,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