修改核销、订单售后
This commit is contained in:
parent
09e66734ce
commit
e01d3c4f74
@ -1,7 +1,12 @@
|
||||
package com.wzj.soopin.member.domain.po;
|
||||
|
||||
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
|
||||
@ -14,29 +19,75 @@ import java.time.LocalDateTime;
|
||||
* @author wzj
|
||||
* @date 2023-03-07
|
||||
*/
|
||||
@Schema(description="提现")
|
||||
@Data
|
||||
@TableName("ums_withdraw")
|
||||
@Builder(toBuilder = true)
|
||||
public class Withdraw extends BaseAudit {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 提现码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 会员id
|
||||
*/
|
||||
private Long memberId;
|
||||
|
||||
/**
|
||||
* 金额
|
||||
*/
|
||||
private BigDecimal money;
|
||||
|
||||
/**
|
||||
* 手续费
|
||||
*/
|
||||
private BigDecimal fee;
|
||||
|
||||
/**
|
||||
* 实际金额
|
||||
*/
|
||||
private BigDecimal actualMoney;
|
||||
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 审核人
|
||||
*/
|
||||
private Long auditBy;
|
||||
|
||||
/**
|
||||
* 审核时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime auditTime;
|
||||
|
||||
/**
|
||||
* 提现方式
|
||||
*/
|
||||
private Integer method;
|
||||
|
||||
/**
|
||||
* 审核状态
|
||||
*/
|
||||
private Integer auditStatus;
|
||||
|
||||
/**
|
||||
* 审核原因
|
||||
*/
|
||||
private String auditReason;
|
||||
}
|
||||
|
@ -1,7 +1,15 @@
|
||||
package com.wzj.soopin.member.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.wzj.soopin.member.domain.bo.WithdrawBO;
|
||||
import com.wzj.soopin.member.domain.po.Feedback;
|
||||
import com.wzj.soopin.member.domain.po.Withdraw;
|
||||
import com.wzj.soopin.member.domain.vo.FeedbackVO;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface IWithdrawService extends IService<Withdraw> {
|
||||
boolean audit(WithdrawBO bo);
|
||||
|
||||
boolean withdraw(Long id);
|
||||
}
|
||||
|
@ -1,11 +1,125 @@
|
||||
package com.wzj.soopin.member.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.wzj.soopin.member.domain.bo.WithdrawBO;
|
||||
import com.wzj.soopin.member.domain.po.Charge;
|
||||
import com.wzj.soopin.member.domain.po.MemberAccount;
|
||||
import com.wzj.soopin.member.domain.po.MemberAccountChangeRecord;
|
||||
import com.wzj.soopin.member.domain.po.Withdraw;
|
||||
import com.wzj.soopin.member.domain.vo.YishengAccountVO;
|
||||
import com.wzj.soopin.member.enums.MemberAccountChangeRecordChangeTypeEnum;
|
||||
import com.wzj.soopin.member.enums.MemberAccountChangeRecordSourceEnum;
|
||||
import com.wzj.soopin.member.enums.WithdrawAuditStatus;
|
||||
import com.wzj.soopin.member.enums.WithdrawStatus;
|
||||
import com.wzj.soopin.member.mapper.ChargeMapper;
|
||||
import com.wzj.soopin.member.mapper.MemberAccountMapper;
|
||||
import com.wzj.soopin.member.mapper.WithdrawMapper;
|
||||
import com.wzj.soopin.member.service.IWithdrawService;
|
||||
import com.wzj.soopin.member.service.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 会员封禁
|
||||
*
|
||||
* @author zcc
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class WithdrawServiceImpl extends ServiceImpl<WithdrawMapper, Withdraw> implements IWithdrawService {
|
||||
|
||||
private final IMemberAccountService memberAccountService;
|
||||
|
||||
/**
|
||||
* 易生账户充值服务
|
||||
*/
|
||||
private final IYishengService yishengService;
|
||||
|
||||
private final IMemberAccountChangeRecordService memberAccountChangeRecordService;
|
||||
|
||||
@Override
|
||||
public boolean audit(WithdrawBO bo) {
|
||||
Withdraw withdraw = getById(bo.getId());
|
||||
if (withdraw == null) {
|
||||
throw new RuntimeException("提现申请不存在");
|
||||
}
|
||||
if (!Objects.equals(WithdrawAuditStatus.PENDING.getCode(), withdraw.getAuditStatus())) {
|
||||
throw new RuntimeException("提现申请已处理");
|
||||
}
|
||||
withdraw = Withdraw.builder().id(bo.getId())
|
||||
.auditReason(bo.getAuditReason())
|
||||
.auditTime(LocalDateTime.now())
|
||||
.auditStatus(bo.getAuditStatus())
|
||||
.auditBy(LoginHelper.getUserId())
|
||||
.build();
|
||||
return this.updateById(withdraw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(Withdraw entity) {
|
||||
entity.setStatus(WithdrawStatus.WAITING.getCode());
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
public boolean withdraw(Long id) {
|
||||
Withdraw withdraw = getById(id);
|
||||
//获取用户余额信息
|
||||
MemberAccount memberAccount = memberAccountService.getById(withdraw.getMemberId());
|
||||
if (memberAccount == null) {
|
||||
throw new RuntimeException("用户不存在");
|
||||
}
|
||||
//检查当前用于的账户余额是否充足
|
||||
BigDecimal balance = memberAccount.getMoneyBalance();
|
||||
|
||||
if (balance.compareTo(withdraw.getMoney()) < 0) {
|
||||
throw new RuntimeException("用户余额不足");
|
||||
}
|
||||
//调用三方支付平台获取用户余额
|
||||
YishengAccountVO yishengAccountVO = yishengService.getYishengAccount(withdraw.getMemberId());
|
||||
|
||||
if (yishengAccountVO == null) {
|
||||
throw new RuntimeException("用户余额获取失败");
|
||||
}
|
||||
|
||||
BigDecimal yishengBalance = yishengAccountVO.getBalance();
|
||||
if (yishengBalance.compareTo(withdraw.getMoney()) < 0) {
|
||||
throw new RuntimeException("用户余额不足");
|
||||
}
|
||||
|
||||
if (!yishengBalance.equals(balance)) {
|
||||
throw new RuntimeException("用户余额不一致");
|
||||
}
|
||||
|
||||
//发起提现
|
||||
boolean chargeSuccess = yishengService.withdraw(withdraw.getMemberId(), withdraw.getMoney());
|
||||
|
||||
if (chargeSuccess) {
|
||||
//提现成功后,更新会员账户余额
|
||||
//从易生取,别用自己计算的
|
||||
//// TODO: 2025/6/21 测试的时候用计算的 测试完用易生的
|
||||
BigDecimal finalBalance = balance.subtract(withdraw.getMoney());
|
||||
yishengAccountVO = yishengService.getYishengAccount(withdraw.getMemberId());
|
||||
memberAccountService.updateById(memberAccount.toBuilder().moneyBalance(balance.subtract(finalBalance)).build());
|
||||
//生成账户变动记录bh
|
||||
MemberAccountChangeRecord memberAccountChangeRecord = MemberAccountChangeRecord.builder()
|
||||
.memberId(withdraw.getMemberId())
|
||||
.moneyBalance(finalBalance)
|
||||
.beforeBalance(balance)
|
||||
.afterBalance(yishengAccountVO.getBalance())
|
||||
.changeType(MemberAccountChangeRecordChangeTypeEnum.WITHDRAW.getCode())
|
||||
.changeDesc("提现")
|
||||
.source(MemberAccountChangeRecordSourceEnum.WITHDRAW.getCode()).build();
|
||||
memberAccountChangeRecordService.save(memberAccountChangeRecord);
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -138,6 +138,19 @@
|
||||
<version>1.4.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- RocketMQ -->
|
||||
<dependency>
|
||||
<groupId>org.apache.rocketmq</groupId>
|
||||
<artifactId>rocketmq-spring-boot-starter</artifactId>
|
||||
<version>2.2.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Messaging for RocketMQ -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-messaging</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
Loading…
x
Reference in New Issue
Block a user