用户提现-第三方支付提现,功能完善
This commit is contained in:
parent
17734e7a3d
commit
5ee07ec34d
@ -9,12 +9,18 @@ import cn.lili.common.security.context.UserContext;
|
|||||||
import cn.lili.common.vo.ResultMessage;
|
import cn.lili.common.vo.ResultMessage;
|
||||||
import cn.lili.modules.member.entity.dos.Member;
|
import cn.lili.modules.member.entity.dos.Member;
|
||||||
import cn.lili.modules.member.service.MemberService;
|
import cn.lili.modules.member.service.MemberService;
|
||||||
|
import cn.lili.modules.system.entity.dos.Setting;
|
||||||
|
import cn.lili.modules.system.entity.dto.WithdrawalSetting;
|
||||||
|
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||||
|
import cn.lili.modules.system.entity.vo.WithdrawalSettingVO;
|
||||||
|
import cn.lili.modules.system.service.SettingService;
|
||||||
import cn.lili.modules.verification.entity.enums.VerificationEnums;
|
import cn.lili.modules.verification.entity.enums.VerificationEnums;
|
||||||
import cn.lili.modules.verification.service.VerificationService;
|
import cn.lili.modules.verification.service.VerificationService;
|
||||||
import cn.lili.modules.wallet.entity.dos.MemberWallet;
|
import cn.lili.modules.wallet.entity.dos.MemberWallet;
|
||||||
import cn.lili.modules.wallet.entity.vo.MemberWalletVO;
|
import cn.lili.modules.wallet.entity.vo.MemberWalletVO;
|
||||||
import cn.lili.modules.wallet.service.MemberWalletService;
|
import cn.lili.modules.wallet.service.MemberWalletService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.google.gson.Gson;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
@ -24,7 +30,6 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.validation.constraints.Max;
|
import javax.validation.constraints.Max;
|
||||||
import javax.validation.constraints.Min;
|
|
||||||
import javax.validation.constraints.Pattern;
|
import javax.validation.constraints.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,6 +59,9 @@ public class MemberWalletBuyerController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private VerificationService verificationService;
|
private VerificationService verificationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SettingService settingService;
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation(value = "查询会员预存款余额")
|
@ApiOperation(value = "查询会员预存款余额")
|
||||||
public ResultMessage<MemberWalletVO> get() {
|
public ResultMessage<MemberWalletVO> get() {
|
||||||
@ -64,6 +72,31 @@ public class MemberWalletBuyerController {
|
|||||||
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
|
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/withdrawalSettingVO")
|
||||||
|
@ApiOperation(value = "获取提现设置VO")
|
||||||
|
public ResultMessage<Object> minPrice() {
|
||||||
|
Setting setting = settingService.get(SettingEnum.WITHDRAWAL_SETTING.name());
|
||||||
|
WithdrawalSetting withdrawalSetting = new Gson().fromJson(setting.getSettingValue(), WithdrawalSetting.class);
|
||||||
|
|
||||||
|
WithdrawalSettingVO withdrawalSettingVO = new WithdrawalSettingVO();
|
||||||
|
withdrawalSettingVO.setMinPrice(withdrawalSetting.getMinPrice());
|
||||||
|
withdrawalSettingVO.setFee(withdrawalSetting.getFee());
|
||||||
|
withdrawalSettingVO.setType(withdrawalSetting.getType());
|
||||||
|
return ResultUtil.data(withdrawalSettingVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreventDuplicateSubmissions
|
||||||
|
@PostMapping(value = "/withdrawal")
|
||||||
|
@ApiOperation(value = "会员中心余额提现")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "price", value = "提现金额", required = true, dataType = "double", paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "realName", value = "真实姓名", required = true, dataType = "String", paramType = "query"),
|
||||||
|
@ApiImplicitParam(name = "connectNumber", value = "第三方登录账号", required = true, dataType = "String", paramType = "query")
|
||||||
|
})
|
||||||
|
public ResultMessage<Boolean> withdrawal(@Max(value = 9999, message = "充值金额单次最多允许提现9999元") Double price, @RequestParam String realName, @RequestParam String connectNumber) {
|
||||||
|
return ResultUtil.data(memberWalletService.applyWithdrawal(price, realName, connectNumber));
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/set-password")
|
@PostMapping(value = "/set-password")
|
||||||
@ApiOperation(value = "设置支付密码")
|
@ApiOperation(value = "设置支付密码")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ -120,15 +153,4 @@ public class MemberWalletBuyerController {
|
|||||||
return memberWalletService.checkPassword();
|
return memberWalletService.checkPassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@PreventDuplicateSubmissions
|
|
||||||
@PostMapping(value = "/withdrawal")
|
|
||||||
@ApiOperation(value = "会员中心余额提现")
|
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "price", value = "提现金额", required = true, dataType = "double", paramType = "query")
|
|
||||||
})
|
|
||||||
public ResultMessage<Boolean> withdrawal(@Max(value = 9999, message = "充值金额单次最多允许提现9999元") @Min(value = 1, message = "充值金额单次最少提现金额为1元") Double price) {
|
|
||||||
return ResultUtil.data(memberWalletService.applyWithdrawal(price));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package cn.lili.event.impl;
|
package cn.lili.event.impl;
|
||||||
|
|
||||||
|
|
||||||
import cn.lili.event.MemberRegisterEvent;
|
import cn.lili.event.MemberWithdrawalEvent;
|
||||||
import cn.lili.modules.member.entity.dos.Member;
|
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.WithdrawStatusEnum;
|
||||||
import cn.lili.modules.wallet.service.MemberWalletService;
|
import cn.lili.modules.wallet.service.MemberWalletService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -14,14 +17,31 @@ import org.springframework.stereotype.Service;
|
|||||||
* @since 2020-07-03 11:20
|
* @since 2020-07-03 11:20
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class MemberWalletExecute implements MemberRegisterEvent {
|
public class MemberWalletExecute implements MemberWithdrawalEvent {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MemberWalletService memberWalletService;
|
private MemberWalletService memberWalletService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void memberRegister(Member member) {
|
public void memberWithdrawal(MemberWithdrawalMessage memberWithdrawalMessage) {
|
||||||
// 有些情况下,会同时创建一个member_id的两条数据
|
switch (WithdrawStatusEnum.valueOf(memberWithdrawalMessage.getStatus())) {
|
||||||
// memberWalletService.save(member.getId(),member.getUsername());
|
case VIA_AUDITING:
|
||||||
|
memberWalletService.withdrawal(memberWithdrawalMessage.getMemberWithdrawApplyId());
|
||||||
|
break;
|
||||||
|
case SUCCESS:
|
||||||
|
//提现成功扣减冻结金额
|
||||||
|
memberWalletService.reduceFrozen(
|
||||||
|
new MemberWalletUpdateDTO(memberWithdrawalMessage.getPrice(), memberWithdrawalMessage.getMemberId(), "提现成功,余额提现", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()));
|
||||||
|
break;
|
||||||
|
case ERROR:
|
||||||
|
//需要从冻结金额扣减到余额
|
||||||
|
memberWalletService.increaseWithdrawal(new MemberWalletUpdateDTO(memberWithdrawalMessage.getPrice(), memberWithdrawalMessage.getMemberId(), "提现失败,提现金额解冻到余额", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()));
|
||||||
|
break;
|
||||||
|
case FAIL_AUDITING:
|
||||||
|
//需要从冻结金额扣减到余额
|
||||||
|
memberWalletService.increaseWithdrawal(new MemberWalletUpdateDTO(memberWithdrawalMessage.getPrice(), memberWithdrawalMessage.getMemberId(), "审核拒绝,提现金额解冻到余额", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name()));
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import cn.lili.modules.order.order.service.OrderService;
|
|||||||
import cn.lili.modules.order.trade.entity.enums.AfterSaleStatusEnum;
|
import cn.lili.modules.order.trade.entity.enums.AfterSaleStatusEnum;
|
||||||
import cn.lili.modules.order.trade.entity.enums.AfterSaleTypeEnum;
|
import cn.lili.modules.order.trade.entity.enums.AfterSaleTypeEnum;
|
||||||
import cn.lili.modules.wallet.entity.dto.MemberWithdrawalMessage;
|
import cn.lili.modules.wallet.entity.dto.MemberWithdrawalMessage;
|
||||||
import cn.lili.modules.wallet.entity.enums.MemberWithdrawalDestinationEnum;
|
|
||||||
import cn.lili.modules.wallet.entity.enums.WithdrawStatusEnum;
|
import cn.lili.modules.wallet.entity.enums.WithdrawStatusEnum;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -179,60 +178,30 @@ public class NoticeMessageExecute implements TradeEvent, OrderStatusChangeEvent,
|
|||||||
public void memberWithdrawal(MemberWithdrawalMessage memberWithdrawalMessage) {
|
public void memberWithdrawal(MemberWithdrawalMessage memberWithdrawalMessage) {
|
||||||
NoticeMessageDTO noticeMessageDTO = new NoticeMessageDTO();
|
NoticeMessageDTO noticeMessageDTO = new NoticeMessageDTO();
|
||||||
noticeMessageDTO.setMemberId(memberWithdrawalMessage.getMemberId());
|
noticeMessageDTO.setMemberId(memberWithdrawalMessage.getMemberId());
|
||||||
//如果提现状态为申请则发送申请提现站内消息
|
Map<String, String> params = new HashMap<>(2);
|
||||||
if (memberWithdrawalMessage.getStatus().equals(WithdrawStatusEnum.APPLY.name())) {
|
switch (WithdrawStatusEnum.valueOf(memberWithdrawalMessage.getStatus())) {
|
||||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_CREATE);
|
case APPLY:
|
||||||
Map<String, String> params = new HashMap<>(2);
|
//如果提现状态为申请则发送申请提现站内消息
|
||||||
params.put("price", memberWithdrawalMessage.getPrice().toString());
|
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_CREATE);
|
||||||
noticeMessageDTO.setParameter(params);
|
break;
|
||||||
//发送提现申请成功消息
|
case FAIL_AUDITING:
|
||||||
noticeMessageService.noticeMessage(noticeMessageDTO);
|
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_AUDIT_ERROR);
|
||||||
}
|
break;
|
||||||
//如果提现状态为通过则发送审核通过站内消息
|
case SUCCESS:
|
||||||
if (memberWithdrawalMessage.getStatus().equals(WithdrawStatusEnum.VIA_AUDITING.name())) {
|
|
||||||
//如果提现到余额
|
|
||||||
if (memberWithdrawalMessage.getDestination().equals(MemberWithdrawalDestinationEnum.WALLET.name())) {
|
|
||||||
//组织参数
|
|
||||||
Map<String, String> params = new HashMap<>(2);
|
|
||||||
params.put("income", memberWithdrawalMessage.getPrice().toString());
|
|
||||||
noticeMessageDTO.setParameter(params);
|
|
||||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_SUCCESS);
|
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_SUCCESS);
|
||||||
//发送提现成功消息
|
break;
|
||||||
noticeMessageService.noticeMessage(noticeMessageDTO);
|
case ERROR:
|
||||||
params.put("income", memberWithdrawalMessage.getPrice().toString());
|
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_ERROR);
|
||||||
params.put("expenditure", "0");
|
break;
|
||||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_CHANGE);
|
case VIA_AUDITING:
|
||||||
noticeMessageDTO.setParameter(params);
|
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_AUDIT_SUCCESS);
|
||||||
//发送余额变动消息
|
default:
|
||||||
noticeMessageService.noticeMessage(noticeMessageDTO);
|
break;
|
||||||
}
|
|
||||||
//如果提现到微信
|
|
||||||
if (memberWithdrawalMessage.getDestination().equals(MemberWithdrawalDestinationEnum.WECHAT.name())) {
|
|
||||||
Map<String, String> params = new HashMap<>(2);
|
|
||||||
params.put("income", memberWithdrawalMessage.getPrice().toString());
|
|
||||||
noticeMessageDTO.setParameter(params);
|
|
||||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_WEICHAT_SUCCESS);
|
|
||||||
//发送提现成功消息
|
|
||||||
noticeMessageService.noticeMessage(noticeMessageDTO);
|
|
||||||
|
|
||||||
params.put("income", "0");
|
|
||||||
params.put("expenditure", memberWithdrawalMessage.getPrice().toString());
|
|
||||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_CHANGE);
|
|
||||||
noticeMessageDTO.setParameter(params);
|
|
||||||
//发送余额变动消息
|
|
||||||
noticeMessageService.noticeMessage(noticeMessageDTO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//如果提现状态为拒绝则发送审核拒绝站内消息
|
|
||||||
if (memberWithdrawalMessage.getStatus().equals(WithdrawStatusEnum.FAIL_AUDITING.name())) {
|
|
||||||
noticeMessageDTO.setNoticeMessageNodeEnum(NoticeMessageNodeEnum.WALLET_WITHDRAWAL_ERROR);
|
|
||||||
Map<String, String> params = new HashMap<>(2);
|
|
||||||
params.put("price", memberWithdrawalMessage.getPrice().toString());
|
|
||||||
noticeMessageDTO.setParameter(params);
|
|
||||||
//发送提现申请成功消息
|
|
||||||
noticeMessageService.noticeMessage(noticeMessageDTO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
params.put("price", memberWithdrawalMessage.getPrice().toString());
|
||||||
|
noticeMessageDTO.setParameter(params);
|
||||||
|
//发送提现申请消息
|
||||||
|
noticeMessageService.noticeMessage(noticeMessageDTO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,8 +257,9 @@ public enum ResultCode {
|
|||||||
WALLET_WITHDRAWAL_FROZEN_AMOUNT_INSUFFICIENT(34006, "冻结金额不足,无法处理提现申请请求!"),
|
WALLET_WITHDRAWAL_FROZEN_AMOUNT_INSUFFICIENT(34006, "冻结金额不足,无法处理提现申请请求!"),
|
||||||
WALLET_ERROR_INSUFFICIENT(34003, "零钱提现失败!"),
|
WALLET_ERROR_INSUFFICIENT(34003, "零钱提现失败!"),
|
||||||
WALLET_REMARK_ERROR(34004, "请填写审核备注!"),
|
WALLET_REMARK_ERROR(34004, "请填写审核备注!"),
|
||||||
WALLET_EXIT_ERROR(34000, "钱包已存在,无法重复创建"),
|
WALLET_EXIT_ERROR(34005, "钱包已存在,无法重复创建"),
|
||||||
WALLET_APPLY_ERROR(34005, "提现申请异常!"),
|
WALLET_APPLY_ERROR(34006, "提现申请异常!"),
|
||||||
|
WALLET_APPLY_MIN_PRICE_ERROR(34007, "提现最低提现金额错误!"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 评价
|
* 评价
|
||||||
|
@ -83,7 +83,6 @@ public class DistributionCashServiceImpl extends ServiceImpl<DistributionCashMap
|
|||||||
MemberWithdrawalMessage memberWithdrawalMessage = new MemberWithdrawalMessage();
|
MemberWithdrawalMessage memberWithdrawalMessage = new MemberWithdrawalMessage();
|
||||||
memberWithdrawalMessage.setMemberId(distribution.getMemberId());
|
memberWithdrawalMessage.setMemberId(distribution.getMemberId());
|
||||||
memberWithdrawalMessage.setPrice(applyMoney);
|
memberWithdrawalMessage.setPrice(applyMoney);
|
||||||
memberWithdrawalMessage.setDestination(MemberWithdrawalDestinationEnum.WALLET.name());
|
|
||||||
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.APPLY.name());
|
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.APPLY.name());
|
||||||
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
|
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
|
||||||
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
|
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
|
||||||
@ -147,7 +146,6 @@ public class DistributionCashServiceImpl extends ServiceImpl<DistributionCashMap
|
|||||||
//组织会员提现审核消息
|
//组织会员提现审核消息
|
||||||
memberWithdrawalMessage.setMemberId(distribution.getMemberId());
|
memberWithdrawalMessage.setMemberId(distribution.getMemberId());
|
||||||
memberWithdrawalMessage.setPrice(distributorCash.getPrice());
|
memberWithdrawalMessage.setPrice(distributorCash.getPrice());
|
||||||
memberWithdrawalMessage.setDestination(MemberWithdrawalDestinationEnum.WALLET.name());
|
|
||||||
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
|
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
|
||||||
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
|
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
|
||||||
}
|
}
|
||||||
|
@ -48,10 +48,11 @@ public enum NoticeMessageNodeEnum {
|
|||||||
* 用户余额
|
* 用户余额
|
||||||
*/
|
*/
|
||||||
WALLET_CHANGE("余额账户变更通知"),
|
WALLET_CHANGE("余额账户变更通知"),
|
||||||
WALLET_WITHDRAWAL_CREATE("提现申请提交成功通知"),
|
WALLET_WITHDRAWAL_CREATE("余额提现申请提交成功通知"),
|
||||||
WALLET_WITHDRAWAL_SUCCESS("余额提现成功通知"),
|
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;
|
private final String description;
|
||||||
|
@ -54,7 +54,7 @@ public class NoticeMessageServiceImpl extends ServiceImpl<NoticeMessageTemplateM
|
|||||||
NoticeMessage noticeMessage = this.getOne(
|
NoticeMessage noticeMessage = this.getOne(
|
||||||
new LambdaQueryWrapper<NoticeMessage>()
|
new LambdaQueryWrapper<NoticeMessage>()
|
||||||
.eq(NoticeMessage::getNoticeNode
|
.eq(NoticeMessage::getNoticeNode
|
||||||
, noticeMessageDTO.getNoticeMessageNodeEnum().getDescription().trim()));
|
, noticeMessageDTO.getNoticeMessageNodeEnum().getDescription().trim()),false);
|
||||||
//如果通知类站内信开启的情况下
|
//如果通知类站内信开启的情况下
|
||||||
if (noticeMessage != null && noticeMessage.getNoticeStatus().equals(SwitchEnum.OPEN.name())) {
|
if (noticeMessage != null && noticeMessage.getNoticeStatus().equals(SwitchEnum.OPEN.name())) {
|
||||||
MemberMessage memberMessage = new MemberMessage();
|
MemberMessage memberMessage = new MemberMessage();
|
||||||
|
@ -145,13 +145,15 @@ public class CashierSupport {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户提现
|
* 用户提现
|
||||||
* @param paymentMethodEnum 支付渠道
|
*
|
||||||
|
* @param paymentMethodEnum 支付渠道
|
||||||
* @param memberWithdrawApply 用户提现申请
|
* @param memberWithdrawApply 用户提现申请
|
||||||
*/
|
*/
|
||||||
public void transfer(PaymentMethodEnum paymentMethodEnum, MemberWithdrawApply memberWithdrawApply){
|
public boolean transfer(PaymentMethodEnum paymentMethodEnum, MemberWithdrawApply memberWithdrawApply) {
|
||||||
Payment payment = (Payment) SpringContextUtil.getBean(paymentMethodEnum.getPlugin());
|
Payment payment = (Payment) SpringContextUtil.getBean(paymentMethodEnum.getPlugin());
|
||||||
payment.transfer(memberWithdrawApply);
|
return payment.transfer(memberWithdrawApply);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取收银台参数
|
* 获取收银台参数
|
||||||
*
|
*
|
||||||
|
@ -114,7 +114,7 @@ public interface Payment {
|
|||||||
/**
|
/**
|
||||||
* 提现
|
* 提现
|
||||||
*/
|
*/
|
||||||
default void transfer(MemberWithdrawApply memberWithdrawApply) {
|
default boolean transfer(MemberWithdrawApply memberWithdrawApply) {
|
||||||
throw new ServiceException(ResultCode.PAY_ERROR);
|
throw new ServiceException(ResultCode.PAY_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.alipay.api.AlipayApiException;
|
import com.alipay.api.AlipayApiException;
|
||||||
import com.alipay.api.domain.*;
|
import com.alipay.api.domain.*;
|
||||||
import com.alipay.api.internal.util.AlipaySignature;
|
import com.alipay.api.internal.util.AlipaySignature;
|
||||||
import com.alipay.api.request.AlipayFundTransUniTransferRequest;
|
|
||||||
import com.alipay.api.response.AlipayFundTransUniTransferResponse;
|
import com.alipay.api.response.AlipayFundTransUniTransferResponse;
|
||||||
import com.alipay.api.response.AlipayTradeRefundResponse;
|
import com.alipay.api.response.AlipayTradeRefundResponse;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -238,7 +237,7 @@ public class AliPayPlugin implements Payment {
|
|||||||
* @param memberWithdrawApply 会员提现申请
|
* @param memberWithdrawApply 会员提现申请
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void transfer(MemberWithdrawApply memberWithdrawApply) {
|
public boolean transfer(MemberWithdrawApply memberWithdrawApply) {
|
||||||
AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel();
|
AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel();
|
||||||
model.setOutBizNo(SnowFlake.createStr("T"));
|
model.setOutBizNo(SnowFlake.createStr("T"));
|
||||||
model.setRemark("用户提现");
|
model.setRemark("用户提现");
|
||||||
@ -255,10 +254,10 @@ public class AliPayPlugin implements Payment {
|
|||||||
model.setOrderTitle("用户提现");
|
model.setOrderTitle("用户提现");
|
||||||
//交互退款
|
//交互退款
|
||||||
try {
|
try {
|
||||||
AlipayFundTransUniTransferResponse alipayFundTransUniTransferResponse = AliPayApi.uniTransferToResponse(model,null);
|
AlipayFundTransUniTransferResponse alipayFundTransUniTransferResponse = AliPayApi.uniTransferToResponse(model, null);
|
||||||
log.error("支付宝退款,参数:{},支付宝响应:{}", JSONUtil.toJsonStr(model), JSONUtil.toJsonStr(alipayFundTransUniTransferResponse));
|
log.error("支付宝退款,参数:{},支付宝响应:{}", JSONUtil.toJsonStr(model), JSONUtil.toJsonStr(alipayFundTransUniTransferResponse));
|
||||||
if (alipayFundTransUniTransferResponse.isSuccess()) {
|
if (alipayFundTransUniTransferResponse.isSuccess()) {
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
log.error(alipayFundTransUniTransferResponse.getSubMsg());
|
log.error(alipayFundTransUniTransferResponse.getSubMsg());
|
||||||
}
|
}
|
||||||
@ -266,6 +265,7 @@ public class AliPayPlugin implements Payment {
|
|||||||
log.error("用户提现异常:", e);
|
log.error("用户提现异常:", e);
|
||||||
throw new ServiceException(ResultCode.PAY_ERROR);
|
throw new ServiceException(ResultCode.PAY_ERROR);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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.PaymentService;
|
||||||
import cn.lili.modules.payment.service.RefundLogService;
|
import cn.lili.modules.payment.service.RefundLogService;
|
||||||
import cn.lili.modules.system.entity.dos.Setting;
|
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.dto.payment.WechatPaymentSetting;
|
||||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||||
import cn.lili.modules.system.service.SettingService;
|
import cn.lili.modules.system.service.SettingService;
|
||||||
import cn.lili.modules.wallet.entity.dos.MemberWithdrawApply;
|
import cn.lili.modules.wallet.entity.dos.MemberWithdrawApply;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.google.gson.Gson;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -475,17 +477,21 @@ public class WechatPlugin implements Payment {
|
|||||||
* @param memberWithdrawApply 会员提现申请
|
* @param memberWithdrawApply 会员提现申请
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void transfer(MemberWithdrawApply memberWithdrawApply) {
|
public boolean transfer(MemberWithdrawApply memberWithdrawApply) {
|
||||||
|
|
||||||
try {
|
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(
|
Connect connect = connectService.queryConnect(
|
||||||
ConnectQueryDTO.builder().userId(UserContext.getCurrentUser().getId())
|
ConnectQueryDTO.builder().userId(memberWithdrawApply.getMemberId())
|
||||||
.unionType(ConnectEnum.WECHAT_OPEN_ID.name()).build()
|
.unionType(ConnectEnum.WECHAT_OPEN_ID.name()).build()
|
||||||
);
|
);
|
||||||
//根据自身情况设置AppId,此处我存放的是服务号的APPID,下方的openID需要对应此处的APPID配置
|
//构建提现,发起申请
|
||||||
TransferModel transferModel = new TransferModel()
|
TransferModel transferModel = new TransferModel()
|
||||||
.setAppid(setting.getServiceAppId())
|
.setAppid(withdrawalSetting.getWechatAppId())
|
||||||
.setOut_batch_no(SnowFlake.createStr("T"))
|
.setOut_batch_no(SnowFlake.createStr("T"))
|
||||||
.setBatch_name("用户提现")
|
.setBatch_name("用户提现")
|
||||||
.setBatch_remark("用户提现")
|
.setBatch_remark("用户提现")
|
||||||
@ -499,10 +505,6 @@ public class WechatPlugin implements Payment {
|
|||||||
transferDetailInput.setTransfer_amount(CurrencyUtil.fen(memberWithdrawApply.getApplyMoney()));
|
transferDetailInput.setTransfer_amount(CurrencyUtil.fen(memberWithdrawApply.getApplyMoney()));
|
||||||
transferDetailInput.setTransfer_remark("用户提现");
|
transferDetailInput.setTransfer_remark("用户提现");
|
||||||
transferDetailInput.setOpenid(connect.getUnionId());
|
transferDetailInput.setOpenid(connect.getUnionId());
|
||||||
// transferDetailInput.setUserName(
|
|
||||||
// "757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45");
|
|
||||||
// transferDetailInput.setUserIdCard(
|
|
||||||
// "8609cb22e1774a50a930e414cc71eca06121bcd266335cda230d24a7886a8d9f");
|
|
||||||
transferDetailListList.add(transferDetailInput);
|
transferDetailListList.add(transferDetailInput);
|
||||||
}
|
}
|
||||||
transferModel.setTransfer_detail_list(transferDetailListList);
|
transferModel.setTransfer_detail_list(transferDetailListList);
|
||||||
@ -511,17 +513,21 @@ public class WechatPlugin implements Payment {
|
|||||||
RequestMethodEnums.POST,
|
RequestMethodEnums.POST,
|
||||||
WechatDomain.CHINA.toString(),
|
WechatDomain.CHINA.toString(),
|
||||||
WechatApiEnum.TRANSFER_BATCHES.toString(),
|
WechatApiEnum.TRANSFER_BATCHES.toString(),
|
||||||
setting.getMchId(),
|
wechatPaymentSetting.getMchId(),
|
||||||
setting.getSerialNumber(),
|
wechatPaymentSetting.getSerialNumber(),
|
||||||
null,
|
null,
|
||||||
setting.getApiclient_key(),
|
wechatPaymentSetting.getApiclient_key(),
|
||||||
JSONUtil.toJsonStr(transferModel)
|
JSONUtil.toJsonStr(transferModel)
|
||||||
);
|
);
|
||||||
log.info("微信提现响应 {}", response);
|
log.info("微信提现响应 {}", response);
|
||||||
|
String body = response.getBody();
|
||||||
|
JSONObject jsonObject = JSONUtil.parseObj(body);
|
||||||
|
return jsonObject.getStr("batch_id") != null ? true : false;
|
||||||
//根据自身业务进行接下来的任务处理
|
//根据自身业务进行接下来的任务处理
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,28 @@ public class WithdrawalSetting implements Serializable {
|
|||||||
|
|
||||||
private static final long serialVersionUID = -3872782530832122976L;
|
private static final long serialVersionUID = -3872782530832122976L;
|
||||||
/**
|
/**
|
||||||
* 提现是否需要申请
|
* 提现最低金额
|
||||||
|
*/
|
||||||
|
private Double minPrice;
|
||||||
|
/**
|
||||||
|
* 提现手续费
|
||||||
|
*/
|
||||||
|
private Double fee;
|
||||||
|
/**
|
||||||
|
* 提现类型 WECHAT\ALI
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
/**
|
||||||
|
* 提现是否需要审核
|
||||||
*/
|
*/
|
||||||
private Boolean apply;
|
private Boolean apply;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信提现使用的APPID
|
||||||
|
*/
|
||||||
|
private String wechatAppId;
|
||||||
|
/**
|
||||||
|
* 微信APPID渠道
|
||||||
|
*/
|
||||||
|
private String wechatAppIdSource;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
}
|
@ -56,8 +56,14 @@ public class MemberWithdrawApply extends BaseEntity {
|
|||||||
@ApiModelProperty(value = "sn")
|
@ApiModelProperty(value = "sn")
|
||||||
private String sn;
|
private String sn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付宝提现时必填
|
||||||
|
*/
|
||||||
@ApiModelProperty(value = "真实姓名")
|
@ApiModelProperty(value = "真实姓名")
|
||||||
private String realName;
|
private String realName;
|
||||||
|
/**
|
||||||
|
* 支付宝登录账号
|
||||||
|
*/
|
||||||
@ApiModelProperty(value = "第三方平台账号")
|
@ApiModelProperty(value = "第三方平台账号")
|
||||||
private String connectNumber;
|
private String connectNumber;
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package cn.lili.modules.wallet.entity.dto;
|
package cn.lili.modules.wallet.entity.dto;
|
||||||
|
|
||||||
import cn.lili.modules.wallet.entity.enums.MemberWithdrawalDestinationEnum;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -13,6 +12,9 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class MemberWithdrawalMessage {
|
public class MemberWithdrawalMessage {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "提现申请ID")
|
||||||
|
private String memberWithdrawApplyId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "金额")
|
@ApiModelProperty(value = "金额")
|
||||||
private Double price;
|
private Double price;
|
||||||
|
|
||||||
@ -22,9 +24,4 @@ public class MemberWithdrawalMessage {
|
|||||||
@ApiModelProperty(value = "提现状态")
|
@ApiModelProperty(value = "提现状态")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/**
|
|
||||||
* @see MemberWithdrawalDestinationEnum
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "提现到哪里")
|
|
||||||
private String destination;
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,15 @@ public enum WithdrawStatusEnum {
|
|||||||
/**
|
/**
|
||||||
* 审核未通过
|
* 审核未通过
|
||||||
*/
|
*/
|
||||||
FAIL_AUDITING("审核未通过");
|
FAIL_AUDITING("审核未通过"),
|
||||||
|
/**
|
||||||
|
* 提现成功
|
||||||
|
*/
|
||||||
|
SUCCESS("提现成功"),
|
||||||
|
/**
|
||||||
|
* 提现失败
|
||||||
|
*/
|
||||||
|
ERROR("提现失败");
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@ package cn.lili.modules.wallet.service;
|
|||||||
|
|
||||||
import cn.lili.modules.member.entity.dos.Member;
|
import cn.lili.modules.member.entity.dos.Member;
|
||||||
import cn.lili.modules.wallet.entity.dos.MemberWallet;
|
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.dto.MemberWalletUpdateDTO;
|
||||||
import cn.lili.modules.wallet.entity.vo.MemberWalletVO;
|
import cn.lili.modules.wallet.entity.vo.MemberWalletVO;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
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();
|
Boolean checkPassword();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员注册添加会员预存款
|
* 会员注册添加会员余额钱包
|
||||||
*
|
*
|
||||||
* @param memberId 会员id
|
* @param memberId 会员id
|
||||||
* @param memberName 会员名称
|
* @param memberName 会员名称
|
||||||
@ -92,16 +92,18 @@ public interface MemberWalletService extends IService<MemberWallet> {
|
|||||||
* 用户提现
|
* 用户提现
|
||||||
*
|
*
|
||||||
* @param price 提现金额
|
* @param price 提现金额
|
||||||
|
* @param realName 真实姓名
|
||||||
|
* @param connectNumber 第三方账号
|
||||||
* @return 是否提现成功
|
* @return 是否提现成功
|
||||||
*/
|
*/
|
||||||
Boolean applyWithdrawal(Double price);
|
Boolean applyWithdrawal(Double price, String realName, String connectNumber);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提现公共方法,此方法供前端用户提现和后端提现使用
|
* 提现公共方法
|
||||||
*
|
*
|
||||||
* @param memberWithdrawApply 会员零钱提现申请
|
* @param withdrawApplyId 会员零钱提现Id
|
||||||
* @return 操作状态
|
* @return 操作状态
|
||||||
*/
|
*/
|
||||||
Boolean withdrawal(MemberWithdrawApply memberWithdrawApply);
|
Boolean withdrawal(String withdrawApplyId);
|
||||||
|
|
||||||
}
|
}
|
@ -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.MemberWalletUpdateDTO;
|
||||||
import cn.lili.modules.wallet.entity.dto.MemberWithdrawalMessage;
|
import cn.lili.modules.wallet.entity.dto.MemberWithdrawalMessage;
|
||||||
import cn.lili.modules.wallet.entity.enums.DepositServiceTypeEnum;
|
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.enums.WithdrawStatusEnum;
|
||||||
import cn.lili.modules.wallet.entity.vo.MemberWalletVO;
|
import cn.lili.modules.wallet.entity.vo.MemberWalletVO;
|
||||||
import cn.lili.modules.wallet.mapper.MemberWalletMapper;
|
import cn.lili.modules.wallet.mapper.MemberWalletMapper;
|
||||||
@ -248,71 +247,105 @@ public class MemberWalletServiceImpl extends ServiceImpl<MemberWalletMapper, Mem
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 提现方法
|
* 提现方法
|
||||||
* 1、先执行平台逻辑,平台逻辑成功后扣减第三方余额,顺序问题为了防止第三方提现成功,平台逻辑失败导致第三方零钱已提现,而我们商城余额未扣减
|
* 1、提现申请冻结用户的余额。
|
||||||
* 2、如果余额扣减失败 则抛出异常,事务回滚
|
* 2、判断是否需要平台审核。不需要审核则直接调用第三方提现,需要审核则审核通过后调用第三方提现
|
||||||
*
|
*
|
||||||
* @param price 提现金额
|
* @param price 提现金额
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Boolean applyWithdrawal(Double price) {
|
public Boolean applyWithdrawal(Double price, String realName, String connectNumber) {
|
||||||
MemberWithdrawalMessage memberWithdrawalMessage = new MemberWithdrawalMessage();
|
|
||||||
AuthUser authUser = UserContext.getCurrentUser();
|
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 memberWithdrawApply = new MemberWithdrawApply();
|
||||||
memberWithdrawApply.setMemberId(authUser.getId());
|
memberWithdrawApply.setMemberId(authUser.getId());
|
||||||
memberWithdrawApply.setMemberName(authUser.getNickName());
|
memberWithdrawApply.setMemberName(authUser.getNickName());
|
||||||
memberWithdrawApply.setApplyMoney(price);
|
memberWithdrawApply.setApplyMoney(price);
|
||||||
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.APPLY.name());
|
memberWithdrawApply.setRealName(realName);
|
||||||
memberWithdrawApply.setSn("W" + SnowFlake.getId());
|
memberWithdrawApply.setConnectNumber(connectNumber);
|
||||||
//校验该次提现是否需要审核,如果未进行配置 默认是需要审核
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
//发送余额提现申请消息
|
|
||||||
|
|
||||||
memberWithdrawalMessage.setMemberId(authUser.getId());
|
//判断提现是否需要审核
|
||||||
memberWithdrawalMessage.setPrice(price);
|
if (withdrawalSetting.getApply()) {
|
||||||
memberWithdrawalMessage.setDestination(MemberWithdrawalDestinationEnum.WECHAT.name());
|
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.APPLY.name());
|
||||||
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
|
} else {
|
||||||
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
|
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
|
@Override
|
||||||
public Boolean withdrawal(MemberWithdrawApply memberWithdrawApply) {
|
public Boolean withdrawal(String withdrawApplyId) {
|
||||||
|
MemberWithdrawApply memberWithdrawApply = memberWithdrawApplyService.getById(withdrawApplyId);
|
||||||
memberWithdrawApply.setInspectTime(new Date());
|
memberWithdrawApply.setInspectTime(new Date());
|
||||||
//保存或者修改零钱提现
|
|
||||||
this.memberWithdrawApplyService.saveOrUpdate(memberWithdrawApply);
|
//获取提现设置
|
||||||
//TODO 做成配置项目
|
Setting setting = settingService.get(SettingEnum.WITHDRAWAL_SETTING.name());
|
||||||
cashierSupport.transfer(PaymentMethodEnum.WECHAT,memberWithdrawApply);
|
WithdrawalSetting withdrawalSetting = new Gson().fromJson(setting.getSettingValue(), WithdrawalSetting.class);
|
||||||
|
|
||||||
|
//调用提现方法
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
//如果微信提现失败 则抛出异常 回滚数据
|
if ("WECHAT".equals(withdrawalSetting.getType())) {
|
||||||
if (!result) {
|
result = cashierSupport.transfer(PaymentMethodEnum.WECHAT, memberWithdrawApply);
|
||||||
throw new ServiceException(ResultCode.WALLET_ERROR_INSUFFICIENT);
|
} 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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,10 +7,7 @@ import cn.lili.common.properties.RocketmqCustomProperties;
|
|||||||
import cn.lili.common.utils.StringUtils;
|
import cn.lili.common.utils.StringUtils;
|
||||||
import cn.lili.common.vo.PageVO;
|
import cn.lili.common.vo.PageVO;
|
||||||
import cn.lili.modules.wallet.entity.dos.MemberWithdrawApply;
|
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.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.enums.WithdrawStatusEnum;
|
||||||
import cn.lili.modules.wallet.entity.vo.MemberWalletVO;
|
import cn.lili.modules.wallet.entity.vo.MemberWalletVO;
|
||||||
import cn.lili.modules.wallet.entity.vo.MemberWithdrawApplyQueryVO;
|
import cn.lili.modules.wallet.entity.vo.MemberWithdrawApplyQueryVO;
|
||||||
@ -69,36 +66,18 @@ public class MemberWithdrawApplyServiceImpl extends ServiceImpl<MemberWithdrawAp
|
|||||||
//如果审核通过 则微信直接提现,反之则记录审核状态
|
//如果审核通过 则微信直接提现,反之则记录审核状态
|
||||||
if (Boolean.TRUE.equals(result)) {
|
if (Boolean.TRUE.equals(result)) {
|
||||||
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.VIA_AUDITING.name());
|
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 {
|
} else {
|
||||||
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.FAIL_AUDITING.name());
|
|
||||||
//如果审核拒绝 审核备注必填
|
|
||||||
if (StringUtils.isEmpty(remark)) {
|
|
||||||
throw new ServiceException(ResultCode.WALLET_REMARK_ERROR);
|
|
||||||
}
|
|
||||||
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.FAIL_AUDITING.name());
|
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.FAIL_AUDITING.name());
|
||||||
//保存修改审核记录
|
//保存修改审核记录
|
||||||
this.updateById(memberWithdrawApply);
|
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.setMemberId(memberWithdrawApply.getMemberId());
|
||||||
memberWithdrawalMessage.setPrice(memberWithdrawApply.getApplyMoney());
|
memberWithdrawalMessage.setPrice(memberWithdrawApply.getApplyMoney());
|
||||||
memberWithdrawalMessage.setDestination(MemberWithdrawalDestinationEnum.WECHAT.name());
|
|
||||||
|
|
||||||
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
|
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
|
||||||
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
|
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
|
||||||
|
@ -2,7 +2,6 @@ package cn.lili.controller.other;
|
|||||||
|
|
||||||
import cn.lili.common.enums.ResultUtil;
|
import cn.lili.common.enums.ResultUtil;
|
||||||
import cn.lili.common.vo.ResultMessage;
|
import cn.lili.common.vo.ResultMessage;
|
||||||
import cn.lili.modules.payment.service.CorporateBankService;
|
|
||||||
import cn.lili.modules.search.service.EsGoodsIndexService;
|
import cn.lili.modules.search.service.EsGoodsIndexService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -25,12 +24,9 @@ import java.util.Map;
|
|||||||
@RequestMapping("/manager/other/elasticsearch")
|
@RequestMapping("/manager/other/elasticsearch")
|
||||||
public class ElasticsearchController {
|
public class ElasticsearchController {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CorporateBankService corporateBankService;
|
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public ResultMessage<String> corporateBankInit(int i) {
|
public ResultMessage<String> corporateBankInit(int i) {
|
||||||
corporateBankService.init(i);
|
|
||||||
return ResultUtil.success();
|
return ResultUtil.success();
|
||||||
}
|
}
|
||||||
@Autowired
|
@Autowired
|
||||||
|
Loading…
x
Reference in New Issue
Block a user