[fix]修改发红包的逻辑
This commit is contained in:
parent
15d36d3ec4
commit
17cec18869
@ -238,6 +238,10 @@ public enum ResultCode {
|
||||
WITHDRAW_WALLET_ERROR(33002, "提现到钱包失败"),
|
||||
|
||||
|
||||
|
||||
PACKET_SINGLE_COUNT_ERROR(35000, "单聊红包数量只能为1"),
|
||||
|
||||
|
||||
/**
|
||||
* 售后
|
||||
*/
|
||||
|
@ -2,6 +2,7 @@ package org.dromara.common.core.exception;
|
||||
|
||||
import lombok.*;
|
||||
import org.dromara.common.core.constant.ResultCode;
|
||||
import org.dromara.common.core.exception.base.BaseException;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
|
@ -13,6 +13,7 @@ import com.wzj.soopin.order.mapper.RedPacketReceiveMapper;
|
||||
import com.wzj.soopin.transaction.service.IAccountBillService;
|
||||
import com.wzj.soopin.transaction.service.RedPacketService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.ResultCode;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.exception.base.BaseException;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
@ -66,7 +67,16 @@ public class RedPacketServiceImpl extends ServiceImpl<RedPacketMapper, RedPacket
|
||||
// 验证发送者余额
|
||||
BigDecimal balance = umsAccountMapper.getMoneyBalanceByMemberId(memberId);
|
||||
if (balance == null || balance.compareTo(request.getTotalAmount()) < 0) {
|
||||
throw new RuntimeException("账户余额不足,无法发送红包");
|
||||
throw new BaseException("账户余额不足,无法发送红包");
|
||||
}
|
||||
if(request.getChatType()==CHAT_TYPE_SINGLE){
|
||||
// 单聊校验接收者是否存在
|
||||
if(request.getReceiverId()==null){
|
||||
throw new ServiceException(ResultCode.USER_NOT_EXIST);
|
||||
}
|
||||
if(request.getTotalCount()==null || request.getTotalCount()>1){
|
||||
throw new BaseException(ResultCode.PACKET_SINGLE_COUNT_ERROR.message());
|
||||
}
|
||||
}
|
||||
|
||||
// 创建红包记录
|
||||
|
@ -131,6 +131,9 @@ public class WithdrawServiceImpl extends ServiceImpl<WithdrawMapper, Withdraw> i
|
||||
request.setTransferSceneId("1005");
|
||||
//用户的openId
|
||||
Member member=memberService.getById(withdraw.getMemberId());
|
||||
if(member==null){
|
||||
throw new ServiceException(ResultCode.USER_NOT_EXIST);
|
||||
}
|
||||
request.setOpenid(member.getOpenId());
|
||||
//收款用户姓名
|
||||
if (request.getTransferAmount() > 30) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user