用户提现-第三方支付提现,功能完善

This commit is contained in:
pikachu1995@126.com
2023-03-01 10:59:27 +08:00
parent 17734e7a3d
commit 5ee07ec34d
20 changed files with 276 additions and 188 deletions

View File

@@ -257,8 +257,9 @@ public enum ResultCode {
WALLET_WITHDRAWAL_FROZEN_AMOUNT_INSUFFICIENT(34006, "冻结金额不足,无法处理提现申请请求!"),
WALLET_ERROR_INSUFFICIENT(34003, "零钱提现失败!"),
WALLET_REMARK_ERROR(34004, "请填写审核备注!"),
WALLET_EXIT_ERROR(34000, "钱包已存在,无法重复创建"),
WALLET_APPLY_ERROR(34005, "提现申请异常!"),
WALLET_EXIT_ERROR(34005, "钱包已存在,无法重复创建"),
WALLET_APPLY_ERROR(34006, "提现申请异常!"),
WALLET_APPLY_MIN_PRICE_ERROR(34007, "提现最低提现金额错误!"),
/**
* 评价

View File

@@ -83,7 +83,6 @@ public class DistributionCashServiceImpl extends ServiceImpl<DistributionCashMap
MemberWithdrawalMessage memberWithdrawalMessage = new MemberWithdrawalMessage();
memberWithdrawalMessage.setMemberId(distribution.getMemberId());
memberWithdrawalMessage.setPrice(applyMoney);
memberWithdrawalMessage.setDestination(MemberWithdrawalDestinationEnum.WALLET.name());
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.APPLY.name());
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
@@ -147,7 +146,6 @@ public class DistributionCashServiceImpl extends ServiceImpl<DistributionCashMap
//组织会员提现审核消息
memberWithdrawalMessage.setMemberId(distribution.getMemberId());
memberWithdrawalMessage.setPrice(distributorCash.getPrice());
memberWithdrawalMessage.setDestination(MemberWithdrawalDestinationEnum.WALLET.name());
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
}

View File

@@ -48,10 +48,11 @@ public enum NoticeMessageNodeEnum {
* 用户余额
*/
WALLET_CHANGE("余额账户变更通知"),
WALLET_WITHDRAWAL_CREATE("提现申请提交成功通知"),
WALLET_WITHDRAWAL_CREATE("余额提现申请提交成功通知"),
WALLET_WITHDRAWAL_SUCCESS("余额提现成功通知"),
WALLET_WITHDRAWAL_WEICHAT_SUCCESS("微信提现成功通知"),
WALLET_WITHDRAWAL_ERROR("提现申请驳回通知");
WALLET_WITHDRAWAL_ERROR("余额提现申请失败通知"),
WALLET_WITHDRAWAL_AUDIT_ERROR("余额提现申请驳回通知"),
WALLET_WITHDRAWAL_AUDIT_SUCCESS("余额提现申请通过通知");
private final String description;

View File

@@ -54,7 +54,7 @@ public class NoticeMessageServiceImpl extends ServiceImpl<NoticeMessageTemplateM
NoticeMessage noticeMessage = this.getOne(
new LambdaQueryWrapper<NoticeMessage>()
.eq(NoticeMessage::getNoticeNode
, noticeMessageDTO.getNoticeMessageNodeEnum().getDescription().trim()));
, noticeMessageDTO.getNoticeMessageNodeEnum().getDescription().trim()),false);
//如果通知类站内信开启的情况下
if (noticeMessage != null && noticeMessage.getNoticeStatus().equals(SwitchEnum.OPEN.name())) {
MemberMessage memberMessage = new MemberMessage();

View File

@@ -145,13 +145,15 @@ public class CashierSupport {
/**
* 用户提现
* @param paymentMethodEnum 支付渠道
*
* @param paymentMethodEnum 支付渠道
* @param memberWithdrawApply 用户提现申请
*/
public void transfer(PaymentMethodEnum paymentMethodEnum, MemberWithdrawApply memberWithdrawApply){
public boolean transfer(PaymentMethodEnum paymentMethodEnum, MemberWithdrawApply memberWithdrawApply) {
Payment payment = (Payment) SpringContextUtil.getBean(paymentMethodEnum.getPlugin());
payment.transfer(memberWithdrawApply);
return payment.transfer(memberWithdrawApply);
}
/**
* 获取收银台参数
*

View File

@@ -114,7 +114,7 @@ public interface Payment {
/**
* 提现
*/
default void transfer(MemberWithdrawApply memberWithdrawApply) {
default boolean transfer(MemberWithdrawApply memberWithdrawApply) {
throw new ServiceException(ResultCode.PAY_ERROR);
}

View File

@@ -31,7 +31,6 @@ import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.domain.*;
import com.alipay.api.internal.util.AlipaySignature;
import com.alipay.api.request.AlipayFundTransUniTransferRequest;
import com.alipay.api.response.AlipayFundTransUniTransferResponse;
import com.alipay.api.response.AlipayTradeRefundResponse;
import lombok.extern.slf4j.Slf4j;
@@ -238,7 +237,7 @@ public class AliPayPlugin implements Payment {
* @param memberWithdrawApply 会员提现申请
*/
@Override
public void transfer(MemberWithdrawApply memberWithdrawApply) {
public boolean transfer(MemberWithdrawApply memberWithdrawApply) {
AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel();
model.setOutBizNo(SnowFlake.createStr("T"));
model.setRemark("用户提现");
@@ -255,10 +254,10 @@ public class AliPayPlugin implements Payment {
model.setOrderTitle("用户提现");
//交互退款
try {
AlipayFundTransUniTransferResponse alipayFundTransUniTransferResponse = AliPayApi.uniTransferToResponse(model,null);
AlipayFundTransUniTransferResponse alipayFundTransUniTransferResponse = AliPayApi.uniTransferToResponse(model, null);
log.error("支付宝退款,参数:{},支付宝响应:{}", JSONUtil.toJsonStr(model), JSONUtil.toJsonStr(alipayFundTransUniTransferResponse));
if (alipayFundTransUniTransferResponse.isSuccess()) {
return true;
} else {
log.error(alipayFundTransUniTransferResponse.getSubMsg());
}
@@ -266,6 +265,7 @@ public class AliPayPlugin implements Payment {
log.error("用户提现异常:", e);
throw new ServiceException(ResultCode.PAY_ERROR);
}
return false;
}
/**

View File

@@ -39,11 +39,13 @@ import cn.lili.modules.payment.kit.plugin.wechat.model.*;
import cn.lili.modules.payment.service.PaymentService;
import cn.lili.modules.payment.service.RefundLogService;
import cn.lili.modules.system.entity.dos.Setting;
import cn.lili.modules.system.entity.dto.WithdrawalSetting;
import cn.lili.modules.system.entity.dto.payment.WechatPaymentSetting;
import cn.lili.modules.system.entity.enums.SettingEnum;
import cn.lili.modules.system.service.SettingService;
import cn.lili.modules.wallet.entity.dos.MemberWithdrawApply;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -475,17 +477,21 @@ public class WechatPlugin implements Payment {
* @param memberWithdrawApply 会员提现申请
*/
@Override
public void transfer(MemberWithdrawApply memberWithdrawApply) {
public boolean transfer(MemberWithdrawApply memberWithdrawApply) {
try {
WechatPaymentSetting setting = wechatPaymentSetting();
//获取提现设置
WithdrawalSetting withdrawalSetting = new Gson().fromJson(settingService.get(SettingEnum.WITHDRAWAL_SETTING.name()).getSettingValue(), WithdrawalSetting.class);
//获取微信设置
WechatPaymentSetting wechatPaymentSetting = wechatPaymentSetting();
//获取用户openId
Connect connect = connectService.queryConnect(
ConnectQueryDTO.builder().userId(UserContext.getCurrentUser().getId())
ConnectQueryDTO.builder().userId(memberWithdrawApply.getMemberId())
.unionType(ConnectEnum.WECHAT_OPEN_ID.name()).build()
);
//根据自身情况设置AppId,此处我存放的是服务号的APPID下方的openID需要对应此处的APPID配置
//构建提现,发起申请
TransferModel transferModel = new TransferModel()
.setAppid(setting.getServiceAppId())
.setAppid(withdrawalSetting.getWechatAppId())
.setOut_batch_no(SnowFlake.createStr("T"))
.setBatch_name("用户提现")
.setBatch_remark("用户提现")
@@ -499,10 +505,6 @@ public class WechatPlugin implements Payment {
transferDetailInput.setTransfer_amount(CurrencyUtil.fen(memberWithdrawApply.getApplyMoney()));
transferDetailInput.setTransfer_remark("用户提现");
transferDetailInput.setOpenid(connect.getUnionId());
// transferDetailInput.setUserName(
// "757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45");
// transferDetailInput.setUserIdCard(
// "8609cb22e1774a50a930e414cc71eca06121bcd266335cda230d24a7886a8d9f");
transferDetailListList.add(transferDetailInput);
}
transferModel.setTransfer_detail_list(transferDetailListList);
@@ -511,17 +513,21 @@ public class WechatPlugin implements Payment {
RequestMethodEnums.POST,
WechatDomain.CHINA.toString(),
WechatApiEnum.TRANSFER_BATCHES.toString(),
setting.getMchId(),
setting.getSerialNumber(),
wechatPaymentSetting.getMchId(),
wechatPaymentSetting.getSerialNumber(),
null,
setting.getApiclient_key(),
wechatPaymentSetting.getApiclient_key(),
JSONUtil.toJsonStr(transferModel)
);
log.info("微信提现响应 {}", response);
String body = response.getBody();
JSONObject jsonObject = JSONUtil.parseObj(body);
return jsonObject.getStr("batch_id") != null ? true : false;
//根据自身业务进行接下来的任务处理
} catch (Exception e) {
e.printStackTrace();
}
return false;
}

View File

@@ -15,7 +15,28 @@ public class WithdrawalSetting implements Serializable {
private static final long serialVersionUID = -3872782530832122976L;
/**
* 提现是否需要申请
* 提现最低金额
*/
private Double minPrice;
/**
* 提现手续费
*/
private Double fee;
/**
* 提现类型 WECHAT\ALI
*/
private String type;
/**
* 提现是否需要审核
*/
private Boolean apply;
/**
* 微信提现使用的APPID
*/
private String wechatAppId;
/**
* 微信APPID渠道
*/
private String wechatAppIdSource;
}

View File

@@ -0,0 +1,27 @@
package cn.lili.modules.system.entity.vo;
import lombok.Data;
/**
* 用户提现设置VO
*
* @author Bulbasaur
* @since 2023/3/1
*/
@Data
public class WithdrawalSettingVO {
/**
* 提现最低金额
*/
private Double minPrice;
/**
* 提现手续费
*/
private Double fee;
/**
* 提现类型 WECHAT\ALI
*/
private String type;
}

View File

@@ -56,8 +56,14 @@ public class MemberWithdrawApply extends BaseEntity {
@ApiModelProperty(value = "sn")
private String sn;
/**
* 支付宝提现时必填
*/
@ApiModelProperty(value = "真实姓名")
private String realName;
/**
* 支付宝登录账号
*/
@ApiModelProperty(value = "第三方平台账号")
private String connectNumber;

View File

@@ -1,6 +1,5 @@
package cn.lili.modules.wallet.entity.dto;
import cn.lili.modules.wallet.entity.enums.MemberWithdrawalDestinationEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -13,6 +12,9 @@ import lombok.Data;
@Data
public class MemberWithdrawalMessage {
@ApiModelProperty(value = "提现申请ID")
private String memberWithdrawApplyId;
@ApiModelProperty(value = "金额")
private Double price;
@@ -22,9 +24,4 @@ public class MemberWithdrawalMessage {
@ApiModelProperty(value = "提现状态")
private String status;
/**
* @see MemberWithdrawalDestinationEnum
*/
@ApiModelProperty(value = "提现到哪里")
private String destination;
}

View File

@@ -18,7 +18,15 @@ public enum WithdrawStatusEnum {
/**
* 审核未通过
*/
FAIL_AUDITING("审核未通过");
FAIL_AUDITING("审核未通过"),
/**
* 提现成功
*/
SUCCESS("提现成功"),
/**
* 提现失败
*/
ERROR("提现失败");
private String description;

View File

@@ -3,10 +3,10 @@ package cn.lili.modules.wallet.service;
import cn.lili.modules.member.entity.dos.Member;
import cn.lili.modules.wallet.entity.dos.MemberWallet;
import cn.lili.modules.wallet.entity.dos.MemberWithdrawApply;
import cn.lili.modules.wallet.entity.dto.MemberWalletUpdateDTO;
import cn.lili.modules.wallet.entity.vo.MemberWalletVO;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.bind.annotation.RequestParam;
/**
* 会员预存款业务层
@@ -80,7 +80,7 @@ public interface MemberWalletService extends IService<MemberWallet> {
Boolean checkPassword();
/**
* 会员注册添加会员预存款
* 会员注册添加会员余额钱包
*
* @param memberId 会员id
* @param memberName 会员名称
@@ -92,16 +92,18 @@ public interface MemberWalletService extends IService<MemberWallet> {
* 用户提现
*
* @param price 提现金额
* @param realName 真实姓名
* @param connectNumber 第三方账号
* @return 是否提现成功
*/
Boolean applyWithdrawal(Double price);
Boolean applyWithdrawal(Double price, String realName, String connectNumber);
/**
* 提现公共方法,此方法供前端用户提现和后端提现使用
* 提现公共方法
*
* @param memberWithdrawApply 会员零钱提现申请
* @param withdrawApplyId 会员零钱提现Id
* @return 操作状态
*/
Boolean withdrawal(MemberWithdrawApply memberWithdrawApply);
Boolean withdrawal(String withdrawApplyId);
}

View File

@@ -23,7 +23,6 @@ import cn.lili.modules.wallet.entity.dos.WalletLog;
import cn.lili.modules.wallet.entity.dto.MemberWalletUpdateDTO;
import cn.lili.modules.wallet.entity.dto.MemberWithdrawalMessage;
import cn.lili.modules.wallet.entity.enums.DepositServiceTypeEnum;
import cn.lili.modules.wallet.entity.enums.MemberWithdrawalDestinationEnum;
import cn.lili.modules.wallet.entity.enums.WithdrawStatusEnum;
import cn.lili.modules.wallet.entity.vo.MemberWalletVO;
import cn.lili.modules.wallet.mapper.MemberWalletMapper;
@@ -248,71 +247,105 @@ public class MemberWalletServiceImpl extends ServiceImpl<MemberWalletMapper, Mem
/**
* 提现方法
* 1、先执行平台逻辑,平台逻辑成功后扣减第三方余额,顺序问题为了防止第三方提现成功,平台逻辑失败导致第三方零钱已提现,而我们商城余额未扣减
* 2、如果余额扣减失败 则抛出异常,事务回滚
* 1、提现申请冻结用户的余额。
* 2、判断是否需要平台审核。不需要审核则直接调用第三方提现,需要审核则审核通过后调用第三方提现
*
* @param price 提现金额
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean applyWithdrawal(Double price) {
MemberWithdrawalMessage memberWithdrawalMessage = new MemberWithdrawalMessage();
public Boolean applyWithdrawal(Double price, String realName, String connectNumber) {
AuthUser authUser = UserContext.getCurrentUser();
//校验金额是否满足提现,因为是从余额扣减,所以校验的是余额
MemberWalletVO memberWalletVO = this.getMemberWallet(authUser.getId());
if (memberWalletVO.getMemberWallet() < price) {
throw new ServiceException(ResultCode.WALLET_WITHDRAWAL_INSUFFICIENT);
}
//获取提现设置
Setting setting = settingService.get(SettingEnum.WITHDRAWAL_SETTING.name());
WithdrawalSetting withdrawalSetting = new Gson().fromJson(setting.getSettingValue(), WithdrawalSetting.class);
//判断金额是否小于最低提现金额
if (price < withdrawalSetting.getMinPrice()) {
throw new ServiceException(ResultCode.WALLET_APPLY_MIN_PRICE_ERROR.message());
}
//构建审核参数
MemberWithdrawApply memberWithdrawApply = new MemberWithdrawApply();
memberWithdrawApply.setMemberId(authUser.getId());
memberWithdrawApply.setMemberName(authUser.getNickName());
memberWithdrawApply.setApplyMoney(price);
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.APPLY.name());
memberWithdrawApply.setSn("W" + SnowFlake.getId());
//校验该次提现是否需要审核,如果未进行配置 默认是需要审核
Setting setting = settingService.get(SettingEnum.WITHDRAWAL_SETTING.name());
if (setting != null) {
//如果不需要审核则审核自动通过
WithdrawalSetting withdrawalSetting = new Gson().fromJson(setting.getSettingValue(), WithdrawalSetting.class);
if (Boolean.FALSE.equals(withdrawalSetting.getApply())) {
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.VIA_AUDITING.name());
memberWithdrawApply.setInspectRemark("系统自动审核通过");
//校验金额是否满足提现,因为是从余额扣减,所以校验的是余额
MemberWalletVO memberWalletVO = this.getMemberWallet(memberWithdrawApply.getMemberId());
if (memberWalletVO.getMemberWallet() < price) {
throw new ServiceException(ResultCode.WALLET_WITHDRAWAL_INSUFFICIENT);
}
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.VIA_AUDITING.name());
//微信零钱提现
Boolean result = withdrawal(memberWithdrawApply);
if (Boolean.TRUE.equals(result)) {
this.reduce(new MemberWalletUpdateDTO(price, authUser.getId(), "余额提现成功", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()));
}
} else {
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.APPLY.name());
//扣减余额到冻结金额
this.reduceWithdrawal(new MemberWalletUpdateDTO(price, authUser.getId(), "提现金额已冻结,审核成功后到账", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()));
}
//发送余额提现申请消息
memberWithdrawApply.setRealName(realName);
memberWithdrawApply.setConnectNumber(connectNumber);
memberWithdrawalMessage.setMemberId(authUser.getId());
memberWithdrawalMessage.setPrice(price);
memberWithdrawalMessage.setDestination(MemberWithdrawalDestinationEnum.WECHAT.name());
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
//判断提现是否需要审核
if (withdrawalSetting.getApply()) {
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.APPLY.name());
} else {
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.VIA_AUDITING.name());
}
return memberWithdrawApplyService.save(memberWithdrawApply);
memberWithdrawApply.setSn("W" + SnowFlake.getId());
//添加提现申请记录
memberWithdrawApplyService.save(memberWithdrawApply);
//扣减余额到冻结金额
this.reduceWithdrawal(new MemberWalletUpdateDTO(price, authUser.getId(), "提现金额已冻结", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()));
//发送余额提现申请消息
MemberWithdrawalMessage memberWithdrawalMessage = new MemberWithdrawalMessage();
memberWithdrawalMessage.setMemberWithdrawApplyId(memberWithdrawApply.getId());
memberWithdrawalMessage.setStatus(memberWithdrawApply.getApplyStatus());
memberWithdrawalMessage.setMemberId(authUser.getId());
memberWithdrawalMessage.setPrice(price);
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
return true;
}
@Override
public Boolean withdrawal(MemberWithdrawApply memberWithdrawApply) {
public Boolean withdrawal(String withdrawApplyId) {
MemberWithdrawApply memberWithdrawApply = memberWithdrawApplyService.getById(withdrawApplyId);
memberWithdrawApply.setInspectTime(new Date());
//保存或者修改零钱提现
this.memberWithdrawApplyService.saveOrUpdate(memberWithdrawApply);
//TODO 做成配置项目
cashierSupport.transfer(PaymentMethodEnum.WECHAT,memberWithdrawApply);
//获取提现设置
Setting setting = settingService.get(SettingEnum.WITHDRAWAL_SETTING.name());
WithdrawalSetting withdrawalSetting = new Gson().fromJson(setting.getSettingValue(), WithdrawalSetting.class);
//调用提现方法
boolean result = true;
//如果微信提现失败 则抛出异常 回滚数据
if (!result) {
throw new ServiceException(ResultCode.WALLET_ERROR_INSUFFICIENT);
if ("WECHAT".equals(withdrawalSetting.getType())) {
result = cashierSupport.transfer(PaymentMethodEnum.WECHAT, memberWithdrawApply);
} else if ("ALI".equals(withdrawalSetting.getType())) {
result = cashierSupport.transfer(PaymentMethodEnum.ALIPAY, memberWithdrawApply);
}
//成功则扣减冻结金额
//失败则恢复冻结金额
if (result) {
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.SUCCESS.name());
} else {
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.ERROR.name());
}
//修改提现申请
this.memberWithdrawApplyService.updateById(memberWithdrawApply);
//发送余额提现申请消息
MemberWithdrawalMessage memberWithdrawalMessage = new MemberWithdrawalMessage();
memberWithdrawalMessage.setMemberWithdrawApplyId(memberWithdrawApply.getId());
memberWithdrawalMessage.setStatus(memberWithdrawApply.getApplyStatus());
memberWithdrawalMessage.setMemberId(memberWithdrawApply.getMemberId());
memberWithdrawalMessage.setPrice(memberWithdrawApply.getApplyMoney());
memberWithdrawalMessage.setStatus(memberWithdrawApply.getApplyStatus());
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
return result;
}

View File

@@ -7,10 +7,7 @@ import cn.lili.common.properties.RocketmqCustomProperties;
import cn.lili.common.utils.StringUtils;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.wallet.entity.dos.MemberWithdrawApply;
import cn.lili.modules.wallet.entity.dto.MemberWalletUpdateDTO;
import cn.lili.modules.wallet.entity.dto.MemberWithdrawalMessage;
import cn.lili.modules.wallet.entity.enums.DepositServiceTypeEnum;
import cn.lili.modules.wallet.entity.enums.MemberWithdrawalDestinationEnum;
import cn.lili.modules.wallet.entity.enums.WithdrawStatusEnum;
import cn.lili.modules.wallet.entity.vo.MemberWalletVO;
import cn.lili.modules.wallet.entity.vo.MemberWithdrawApplyQueryVO;
@@ -69,36 +66,18 @@ public class MemberWithdrawApplyServiceImpl extends ServiceImpl<MemberWithdrawAp
//如果审核通过 则微信直接提现,反之则记录审核状态
if (Boolean.TRUE.equals(result)) {
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.VIA_AUDITING.name());
//提现,微信提现成功后扣减冻结金额
Boolean bool = memberWalletService.withdrawal(memberWithdrawApply);
if (Boolean.TRUE.equals(bool)) {
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.VIA_AUDITING.name());
//保存修改审核记录
this.updateById(memberWithdrawApply);
//记录日志
memberWalletService.reduceFrozen(
new MemberWalletUpdateDTO(memberWithdrawApply.getApplyMoney(), memberWithdrawApply.getMemberId(), "审核通过,余额提现", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()))
;
} else {
//如果提现失败则无法审核
throw new ServiceException(ResultCode.WALLET_APPLY_ERROR);
}
} else {
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.FAIL_AUDITING.name());
//如果审核拒绝 审核备注必填
if (StringUtils.isEmpty(remark)) {
throw new ServiceException(ResultCode.WALLET_REMARK_ERROR);
}
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.FAIL_AUDITING.name());
//保存修改审核记录
this.updateById(memberWithdrawApply);
//需要从冻结金额扣减到余额
memberWalletService.increaseWithdrawal(new MemberWalletUpdateDTO(memberWithdrawApply.getApplyMoney(), memberWithdrawApply.getMemberId(), "审核拒绝,提现金额解冻到余额", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()));
}
//发送审核消息
memberWithdrawalMessage.setStatus(memberWithdrawApply.getApplyStatus());
memberWithdrawalMessage.setMemberWithdrawApplyId(memberWithdrawApply.getId());
memberWithdrawalMessage.setMemberId(memberWithdrawApply.getMemberId());
memberWithdrawalMessage.setPrice(memberWithdrawApply.getApplyMoney());
memberWithdrawalMessage.setDestination(MemberWithdrawalDestinationEnum.WECHAT.name());
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());