转账(未完成)
This commit is contained in:
parent
9842c59084
commit
55bced1bb0
|
@ -1,8 +1,8 @@
|
|||
package com.ruoyi.common.pay.wx.domain;
|
||||
|
||||
import com.ruoyi.common.pay.wx.domain.enums.TransferScene;
|
||||
import com.wechat.pay.java.service.transferbatch.model.TransferDetailInput;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 可批量转账的接口
|
||||
|
@ -12,33 +12,28 @@ import java.math.BigDecimal;
|
|||
public interface BatchTransferAble {
|
||||
|
||||
/**
|
||||
* 转账场景
|
||||
* 转账总金额
|
||||
*/
|
||||
TransferScene transferScene();
|
||||
|
||||
/**
|
||||
* 转账到账账号
|
||||
*/
|
||||
String transferAccountNo();
|
||||
|
||||
/**
|
||||
* 转账金额
|
||||
*/
|
||||
BigDecimal transferAmount();
|
||||
Long transferTotalAmount();
|
||||
|
||||
/**
|
||||
* 转账外部订单号
|
||||
*/
|
||||
String transferOutBatchNo();
|
||||
|
||||
/**
|
||||
* 转账备注
|
||||
*/
|
||||
String transferBatchRemark();
|
||||
|
||||
/**
|
||||
* 转账名称
|
||||
*/
|
||||
String transferBatchName();
|
||||
|
||||
/**
|
||||
* 转账备注
|
||||
*/
|
||||
String transferBatchRemark();
|
||||
|
||||
|
||||
/**
|
||||
* 转账明细
|
||||
*/
|
||||
List<TransferDetailInput> transferDetailList();
|
||||
}
|
||||
|
|
|
@ -120,17 +120,14 @@ public class WxPayServiceImpl implements WxPayService {
|
|||
*/
|
||||
@Override
|
||||
public InitiateBatchTransferResponse batchTransfer(BatchTransferAble bill) {
|
||||
// 转账明细列表
|
||||
List<TransferDetailInput> transferDetailList = this.buildTransferDetailList(bill.transferAmount(), bill.transferAccountNo(), bill.transferScene());
|
||||
// 发起转账请求
|
||||
InitiateBatchTransferRequest request = new InitiateBatchTransferRequest();
|
||||
request.setAppid(wxPayConfig.getAppId());
|
||||
request.setOutBatchNo(bill.transferOutBatchNo());
|
||||
request.setBatchName(bill.transferBatchName());
|
||||
request.setBatchRemark(bill.transferBatchRemark());
|
||||
request.setTotalAmount(getTransferAmount(bill.transferAmount()));
|
||||
request.setTotalNum(transferDetailList.size());
|
||||
request.setTransferDetailList(transferDetailList);
|
||||
request.setTotalAmount(bill.transferTotalAmount());
|
||||
request.setTotalNum(bill.transferDetailList().size());
|
||||
request.setTransferDetailList(bill.transferDetailList());
|
||||
return transferBatchService.initiateBatchTransfer(request);
|
||||
}
|
||||
|
||||
|
@ -179,7 +176,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|||
BigDecimal detailPayAmount = payAmount.compareTo(limitAmount) > 0 ? limitAmount : payAmount; // 当前明细转账的金额
|
||||
TransferDetailInput input = new TransferDetailInput();
|
||||
input.setOutDetailNo(String.valueOf(SnowFlakeUtil.newId()));
|
||||
input.setTransferAmount(getTransferAmount(detailPayAmount));
|
||||
input.setTransferAmount(detailPayAmount.longValue());
|
||||
input.setTransferRemark(transferScene.getRemark());
|
||||
input.setOpenid(openId);
|
||||
transferDetailList.add(input);
|
||||
|
@ -207,10 +204,6 @@ public class WxPayServiceImpl implements WxPayService {
|
|||
return res;
|
||||
}
|
||||
|
||||
private Long getTransferAmount(BigDecimal money) {
|
||||
return money.multiply(new BigDecimal(100)).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验签并解析
|
||||
* @param request 请求
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.ruoyi.ss.account.domain.enums;
|
||||
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constants.ChannelConstants;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
@ -22,9 +21,9 @@ public enum AccountType {
|
|||
OFFLINE_IMAGE("4", "线下图片", ChannelConstants.QR_CODE_ID);
|
||||
|
||||
|
||||
private final String type;
|
||||
private final String name;
|
||||
private final Long channelId;
|
||||
private final String type; // 类型
|
||||
private final String name; // 名称
|
||||
private final Long channelId; // 渠道id
|
||||
|
||||
public static AccountType parse(String type) {
|
||||
for (AccountType obj : AccountType.values()) {
|
||||
|
|
|
@ -429,7 +429,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<update id="changeTimeoutStatus">
|
||||
update sm_device
|
||||
set status = '1'
|
||||
where expire_time <= now()
|
||||
where expire_time <= now() and status = '2'
|
||||
<if test="deviceId != null">
|
||||
and device_id = #{deviceId}
|
||||
</if>
|
||||
|
|
|
@ -468,9 +468,11 @@ public class DeviceServiceImpl implements DeviceService
|
|||
}
|
||||
|
||||
// 如果没有过期,则延迟至过期时间继续查询
|
||||
scheduledExecutorService.schedule(() -> {
|
||||
freshStatus(device.getDeviceId());
|
||||
}, between.getSeconds() , TimeUnit.SECONDS);
|
||||
if (between.getSeconds() > 0) {
|
||||
scheduledExecutorService.schedule(() -> {
|
||||
freshStatus(device.getDeviceId());
|
||||
}, between.getSeconds() , TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,7 @@ import java.math.BigDecimal;
|
|||
*/
|
||||
@ApiModel
|
||||
@Data
|
||||
public class TransactionBillVO extends TransactionBill implements BatchTransferAble {
|
||||
public class TransactionBillVO extends TransactionBill {
|
||||
@ApiModelProperty("用户名称")
|
||||
@JsonView(JsonViewProfile.App.class)
|
||||
private String userName;
|
||||
|
@ -55,51 +55,4 @@ public class TransactionBillVO extends TransactionBill implements BatchTransferA
|
|||
return time * unit.getConversion();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账场景
|
||||
*/
|
||||
@Override
|
||||
public TransferScene transferScene() {
|
||||
return TransferScene.WITHDRAW;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账到账账号
|
||||
*/
|
||||
@Override
|
||||
public String transferAccountNo() {
|
||||
return getAccountNo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账金额
|
||||
*/
|
||||
@Override
|
||||
public BigDecimal transferAmount() {
|
||||
return getArrivalAmount();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账外部订单号
|
||||
*/
|
||||
@Override
|
||||
public String transferOutBatchNo() {
|
||||
return getBillNo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账备注
|
||||
*/
|
||||
@Override
|
||||
public String transferBatchRemark() {
|
||||
return String.format("用户%s提现%f元", getUserName(), getArrivalAmount());
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账名称
|
||||
*/
|
||||
@Override
|
||||
public String transferBatchName() {
|
||||
return "提现";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,16 +39,16 @@ import com.ruoyi.ss.transactionBill.domain.enums.*;
|
|||
import com.ruoyi.ss.transactionBill.mapper.TransactionBillMapper;
|
||||
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
|
||||
import com.ruoyi.ss.transactionBill.service.TransactionBillValidator;
|
||||
import com.ruoyi.ss.transfer.domain.TransferVO;
|
||||
import com.ruoyi.ss.transfer.service.TransferConverter;
|
||||
import com.ruoyi.ss.transfer.service.TransferService;
|
||||
import com.ruoyi.ss.user.domain.SmUserVo;
|
||||
import com.ruoyi.common.enums.ServiceType;
|
||||
import com.ruoyi.ss.user.mapper.SmUserMapper;
|
||||
import com.ruoyi.ss.user.service.ISmUserService;
|
||||
import com.ruoyi.common.pay.wx.service.WxPayService;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import com.ruoyi.task.bill.BillDelayedManager;
|
||||
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
|
||||
import com.wechat.pay.java.service.payments.model.Transaction;
|
||||
import com.wechat.pay.java.service.transferbatch.model.InitiateBatchTransferResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
@ -93,13 +93,14 @@ public class TransactionBillServiceImpl implements TransactionBillService {
|
|||
private ISmUserService userService;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
private TransferService transferService;
|
||||
|
||||
@Autowired
|
||||
private TransferConverter transferConverter;
|
||||
|
||||
@Autowired
|
||||
private BillDelayedManager billDelayedManager;
|
||||
|
||||
@Autowired
|
||||
private SmUserMapper smUserMapper;
|
||||
|
||||
@Autowired
|
||||
private RedisLock redisLock;
|
||||
|
@ -468,8 +469,8 @@ public class TransactionBillServiceImpl implements TransactionBillService {
|
|||
// 线上打款,发起打款
|
||||
if (WithdrawType.ONLINE.getType().equals(dto.getWithdrawType())) {
|
||||
TransactionBillVO withdraw = this.selectWithdrawById(dto.getBillId());
|
||||
int pay = this.startPayOnline(withdraw);
|
||||
ServiceUtil.assertion(pay != 1, "发起打款失败");
|
||||
boolean pay = this.startPayOnline(withdraw);
|
||||
ServiceUtil.assertion(!pay, "发起打款失败");
|
||||
}
|
||||
|
||||
return update;
|
||||
|
@ -484,25 +485,27 @@ public class TransactionBillServiceImpl implements TransactionBillService {
|
|||
/**
|
||||
* 提现线上打款
|
||||
*/
|
||||
private int startPayOnline(TransactionBillVO bill) {
|
||||
private boolean startPayOnline(TransactionBillVO bill) {
|
||||
ServiceUtil.assertion(bill == null, "单据不存在");
|
||||
ServiceUtil.assertion(TransactionBillStatus.WITHDRAW_PASSED.getStatus().equals(bill.getStatus()), "当前提现单据状态异常");
|
||||
ServiceUtil.assertion(StringUtils.isBlank(bill.getAccountNo()), "提现账号异常");
|
||||
|
||||
// 微信
|
||||
if (TransactionBillPayType.WECHAT.getType().equals(bill.getChannelId())) {
|
||||
// 生成转账单
|
||||
TransferVO vo = transferConverter.toVo(bill);
|
||||
|
||||
InitiateBatchTransferResponse res = wxPayService.batchTransfer(bill);
|
||||
Boolean result = transactionTemplate.execute(status -> {
|
||||
// 插入数据
|
||||
int insert = transferService.insertWithDetail(vo);
|
||||
ServiceUtil.assertion(insert != 1, "新增转账单失败");
|
||||
|
||||
// TODO 更新微信批次明细单号
|
||||
// transactionBillMapper.updateSmTransactionBill(billId, transferDetailList.stream().map(TransferDetailInput::getOutDetailNo).collect(Collectors.toList()));
|
||||
log.debug(String.valueOf(res));
|
||||
// 发起转账
|
||||
boolean requestResult = transferService.requestTransfer(vo.getBatchNo());
|
||||
ServiceUtil.assertion(!requestResult, "发起转账失败");
|
||||
|
||||
} else {
|
||||
throw new ServiceException("其他打款渠道正在开发中");
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
return 1;
|
||||
return result != null && result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package com.ruoyi.ss.transfer.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 转账对象 ss_transfer
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-08-09
|
||||
*/
|
||||
@Data
|
||||
public class Transfer extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long batchId;
|
||||
|
||||
@Excel(name = "批次单号")
|
||||
@ApiModelProperty("批次单号")
|
||||
private String batchNo;
|
||||
|
||||
@Excel(name = "转账账户类型")
|
||||
@ApiModelProperty("转账账户类型")
|
||||
private String accountType;
|
||||
|
||||
@Excel(name = "业务类型")
|
||||
@ApiModelProperty("业务类型")
|
||||
private String bstType;
|
||||
|
||||
@Excel(name = "业务ID")
|
||||
@ApiModelProperty("业务ID")
|
||||
private Long bstId;
|
||||
|
||||
@Excel(name = "状态")
|
||||
@ApiModelProperty("状态")
|
||||
private String status;
|
||||
|
||||
@Excel(name = "批次名称")
|
||||
@ApiModelProperty("批次名称")
|
||||
private String batchName;
|
||||
|
||||
@Excel(name = "批次备注")
|
||||
@ApiModelProperty("批次备注")
|
||||
private String batchRemark;
|
||||
|
||||
@ApiModelProperty("批次总金额(元)")
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.ruoyi.ss.transfer.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/8/9
|
||||
*/
|
||||
@Data
|
||||
public class TransferQuery extends TransferVO{
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package com.ruoyi.ss.transfer.domain;
|
||||
|
||||
import com.ruoyi.common.pay.wx.domain.BatchTransferAble;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetailVO;
|
||||
import com.wechat.pay.java.service.transferbatch.model.TransferDetailInput;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/8/9
|
||||
*/
|
||||
@Data
|
||||
public class TransferVO extends Transfer implements BatchTransferAble {
|
||||
|
||||
@ApiModelProperty("转账明细列表")
|
||||
private List<TransferDetailVO> detailList;
|
||||
|
||||
/**
|
||||
* 转账总金额
|
||||
*/
|
||||
@Override
|
||||
public Long transferTotalAmount() {
|
||||
return new BigDecimal(100).multiply(this.getTotalAmount()).longValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账外部订单号
|
||||
*/
|
||||
@Override
|
||||
public String transferOutBatchNo() {
|
||||
return getBatchNo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账备注
|
||||
*/
|
||||
@Override
|
||||
public String transferBatchRemark() {
|
||||
return getBatchRemark();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账名称
|
||||
*/
|
||||
@Override
|
||||
public String transferBatchName() {
|
||||
return getBatchName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转账明细
|
||||
*/
|
||||
@Override
|
||||
public List<TransferDetailInput> transferDetailList() {
|
||||
return this.toTransferDetailInput(this.getDetailList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 转为明细
|
||||
*/
|
||||
private List<TransferDetailInput> toTransferDetailInput(List<TransferDetailVO> detailList) {
|
||||
if (CollectionUtils.isEmptyElement(detailList)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<TransferDetailInput> result = new ArrayList<>();
|
||||
BigDecimal decimal100 = new BigDecimal(100);
|
||||
for (TransferDetailVO detail : detailList) {
|
||||
TransferDetailInput inputDetail = new TransferDetailInput();
|
||||
inputDetail.setOutDetailNo(detail.getDetailNo());
|
||||
inputDetail.setTransferAmount(detail.getAmount().multiply(decimal100).longValue());
|
||||
inputDetail.setTransferRemark(detail.getRemark());
|
||||
inputDetail.setOpenid(detail.getAccountNo());
|
||||
inputDetail.setUserName(detail.getUserName());
|
||||
result.add(inputDetail);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.ruoyi.ss.transfer.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 转账业务类型
|
||||
* @author wjh
|
||||
* 2024/8/9
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum TransferBstType {
|
||||
|
||||
WITHDRAW("1", "提现");
|
||||
|
||||
private final String type;
|
||||
private final String name;
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.ruoyi.ss.transfer.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/8/9
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum TransferStatus {
|
||||
|
||||
TRANSFER_ING("1", "转账中"),
|
||||
TRANSFER_SUCCESS("2", "已转账"),
|
||||
TRANSFER_PART_SUCCESS("3", "部分成功"),
|
||||
TRANSFER_FAIL("4", "转账失败");
|
||||
|
||||
private final String status;
|
||||
private final String msg;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package com.ruoyi.ss.transfer.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.ss.transfer.domain.Transfer;
|
||||
import com.ruoyi.ss.transfer.domain.TransferVO;
|
||||
import com.ruoyi.ss.transfer.domain.TransferQuery;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 转账Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-08-09
|
||||
*/
|
||||
public interface TransferMapper
|
||||
{
|
||||
/**
|
||||
* 查询转账
|
||||
*
|
||||
* @param batchId 转账主键
|
||||
* @return 转账
|
||||
*/
|
||||
public TransferVO selectTransferByBatchId(Long batchId);
|
||||
|
||||
/**
|
||||
* 查询转账列表
|
||||
*
|
||||
* @param query 转账
|
||||
* @return 转账集合
|
||||
*/
|
||||
public List<TransferVO> selectTransferList(@Param("query")TransferQuery query);
|
||||
|
||||
/**
|
||||
* 新增转账
|
||||
*
|
||||
* @param transfer 转账
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertTransfer(Transfer transfer);
|
||||
|
||||
/**
|
||||
* 修改转账
|
||||
*
|
||||
* @param transfer 转账
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateTransfer(@Param("data") Transfer transfer);
|
||||
|
||||
/**
|
||||
* 删除转账
|
||||
*
|
||||
* @param batchId 转账主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTransferByBatchId(Long batchId);
|
||||
|
||||
/**
|
||||
* 批量删除转账
|
||||
*
|
||||
* @param batchIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTransferByBatchIds(Long[] batchIds);
|
||||
|
||||
/**
|
||||
* 批次单号查询
|
||||
*/
|
||||
TransferVO selectByBatchNo(String batchNo);
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ss.transfer.mapper.TransferMapper">
|
||||
|
||||
<resultMap type="TransferVO" id="TransferResult" autoMapping="true" />
|
||||
|
||||
<sql id="selectTransferVo">
|
||||
select
|
||||
st.batch_id,
|
||||
st.batch_no,
|
||||
st.account_type,
|
||||
st.bst_type,
|
||||
st.bst_id,
|
||||
st.status,
|
||||
st.batch_name,
|
||||
st.batch_remark,
|
||||
st.create_time,
|
||||
st.total_amount
|
||||
from ss_transfer st
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
<if test="query.batchId != null "> and st.batch_id = #{query.batchId}</if>
|
||||
<if test="query.batchNo != null and query.batchNo != ''"> and st.batch_no = #{query.batchNo}</if>
|
||||
<if test="query.accountType != null and query.accountType != ''"> and st.account_type = #{query.accountType}</if>
|
||||
<if test="query.bstType != null and query.bstType != ''"> and st.bst_type = #{query.bstType}</if>
|
||||
<if test="query.bstId != null "> and st.bst_id = #{query.bstId}</if>
|
||||
<if test="query.status != null and query.status != ''"> and st.status = #{query.status}</if>
|
||||
<if test="query.batchName != null and query.batchName != ''"> and st.batch_name like concat('%', #{query.batchName}, '%')</if>
|
||||
<if test="query.batchRemark != null and query.batchRemark != ''"> and st.batch_remark like concat('%', #{query.batchRemark}, '%')</if>
|
||||
</sql>
|
||||
|
||||
<select id="selectTransferList" parameterType="TransferQuery" resultMap="TransferResult">
|
||||
<include refid="selectTransferVo"/>
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectTransferByBatchId" parameterType="Long" resultMap="TransferResult">
|
||||
<include refid="selectTransferVo"/>
|
||||
where st.batch_id = #{batchId}
|
||||
</select>
|
||||
|
||||
<select id="selectByBatchNo" resultMap="TransferResult">
|
||||
<include refid="selectTransferVo"/>
|
||||
where st.batch_no = #{batchNo}
|
||||
</select>
|
||||
|
||||
<insert id="insertTransfer" parameterType="Transfer" useGeneratedKeys="true" keyProperty="batchId">
|
||||
<selectKey keyProperty="batchId" order="AFTER" resultType="Long">
|
||||
SELECT LAST_INSERT_ID();
|
||||
</selectKey>
|
||||
insert into ss_transfer
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="batchNo != null and batchNo != ''">batch_no,</if>
|
||||
<if test="accountType != null and accountType != ''">account_type,</if>
|
||||
<if test="bstType != null and bstType != ''">bst_type,</if>
|
||||
<if test="bstId != null">bst_id,</if>
|
||||
<if test="status != null and status != ''">`status`,</if>
|
||||
<if test="batchName != null and batchName != ''">batch_name,</if>
|
||||
<if test="batchRemark != null and batchRemark != ''">batch_remark,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="totalAmount != null">total_amount,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="batchNo != null and batchNo != ''">#{batchNo},</if>
|
||||
<if test="accountType != null and accountType != ''">#{accountType},</if>
|
||||
<if test="bstType != null and bstType != ''">#{bstType},</if>
|
||||
<if test="bstId != null">#{bstId},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="batchName != null and batchName != ''">#{batchName},</if>
|
||||
<if test="batchRemark != null and batchRemark != ''">#{batchRemark},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="totalAmount != null">#{totalAmount},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateTransfer" parameterType="Transfer">
|
||||
update ss_transfer
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="data.batchNo != null and data.batchNo != ''">batch_no = #{data.batchNo},</if>
|
||||
<if test="data.accountType != null and data.accountType != ''">account_type = #{data.accountType},</if>
|
||||
<if test="data.bstType != null and data.bstType != ''">bst_type = #{data.bstType},</if>
|
||||
<if test="data.bstId != null">bst_id = #{data.bstId},</if>
|
||||
<if test="data.status != null and data.status != ''">`status` = #{data.status},</if>
|
||||
<if test="data.batchName != null and data.batchName != ''">batch_name = #{data.batchName},</if>
|
||||
<if test="data.batchRemark != null and data.batchRemark != ''">batch_remark = #{data.batchRemark},</if>
|
||||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||
<if test="data.totalAmount != null">total_amount = #{data.totalAmount},</if>
|
||||
</trim>
|
||||
where batch_id = #{data.batchId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteTransferByBatchId" parameterType="Long">
|
||||
delete from ss_transfer where batch_id = #{batchId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteTransferByBatchIds" parameterType="String">
|
||||
delete from ss_transfer where batch_id in
|
||||
<foreach item="batchId" collection="array" open="(" separator="," close=")">
|
||||
#{batchId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -0,0 +1,16 @@
|
|||
package com.ruoyi.ss.transfer.service;
|
||||
|
||||
import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO;
|
||||
import com.ruoyi.ss.transfer.domain.TransferVO;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/8/9
|
||||
*/
|
||||
public interface TransferConverter {
|
||||
|
||||
/**
|
||||
* 提现转为转账单VO
|
||||
*/
|
||||
TransferVO toVo(TransactionBillVO bill);
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package com.ruoyi.ss.transfer.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.ss.transfer.domain.Transfer;
|
||||
import com.ruoyi.ss.transfer.domain.TransferVO;
|
||||
import com.ruoyi.ss.transfer.domain.TransferQuery;
|
||||
|
||||
/**
|
||||
* 转账Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-08-09
|
||||
*/
|
||||
public interface TransferService
|
||||
{
|
||||
/**
|
||||
* 查询转账
|
||||
*
|
||||
* @param batchId 转账主键
|
||||
* @return 转账
|
||||
*/
|
||||
public TransferVO selectTransferByBatchId(Long batchId);
|
||||
|
||||
/**
|
||||
* 查询转账列表
|
||||
*
|
||||
* @param transfer 转账
|
||||
* @return 转账集合
|
||||
*/
|
||||
public List<TransferVO> selectTransferList(TransferQuery transfer);
|
||||
|
||||
/**
|
||||
* 新增转账
|
||||
*
|
||||
* @param transfer 转账
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertTransfer(Transfer transfer);
|
||||
|
||||
/**
|
||||
* 修改转账
|
||||
*
|
||||
* @param transfer 转账
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateTransfer(Transfer transfer);
|
||||
|
||||
/**
|
||||
* 批量删除转账
|
||||
*
|
||||
* @param batchIds 需要删除的转账主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTransferByBatchIds(Long[] batchIds);
|
||||
|
||||
/**
|
||||
* 删除转账信息
|
||||
*
|
||||
* @param batchId 转账主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTransferByBatchId(Long batchId);
|
||||
|
||||
/**
|
||||
* 插入数据,包含明细
|
||||
*/
|
||||
int insertWithDetail(TransferVO vo);
|
||||
|
||||
/**
|
||||
* 发起转账
|
||||
* @param batchNo 批次单号
|
||||
* @return 是否发起成功
|
||||
*/
|
||||
boolean requestTransfer(String batchNo);
|
||||
|
||||
/**
|
||||
* 根据批次单号查询
|
||||
* @param batchNo
|
||||
*/
|
||||
TransferVO selectByBatchNo(String batchNo);
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package com.ruoyi.ss.transfer.service.impl;
|
||||
|
||||
import com.ruoyi.ss.account.domain.enums.AccountType;
|
||||
import com.ruoyi.ss.channelWithdraw.domain.ChannelWithdrawVO;
|
||||
import com.ruoyi.ss.channelWithdraw.service.ChannelWithdrawService;
|
||||
import com.ruoyi.ss.transactionBill.domain.vo.TransactionBillVO;
|
||||
import com.ruoyi.ss.transfer.domain.Transfer;
|
||||
import com.ruoyi.ss.transfer.domain.TransferVO;
|
||||
import com.ruoyi.ss.transfer.domain.enums.TransferBstType;
|
||||
import com.ruoyi.ss.transfer.domain.enums.TransferStatus;
|
||||
import com.ruoyi.ss.transfer.service.TransferConverter;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetail;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetailVO;
|
||||
import com.ruoyi.ss.transferDetail.domain.enums.TransferDetailStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/8/9
|
||||
*/
|
||||
@Service
|
||||
public class TransferConverterImpl implements TransferConverter {
|
||||
|
||||
@Autowired
|
||||
private ChannelWithdrawService channelWithdrawService;
|
||||
|
||||
|
||||
/**
|
||||
* 提现转为转账单VO
|
||||
*/
|
||||
@Override
|
||||
public TransferVO toVo(TransactionBillVO bill) {
|
||||
if (bill == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 渠道
|
||||
ChannelWithdrawVO channel = channelWithdrawService.selectChannelWithdrawByChannelId(bill.getChannelId());
|
||||
|
||||
// 拼接数据
|
||||
TransferVO vo = new TransferVO();
|
||||
// 渠道转为账户类型
|
||||
if (channel != null) {
|
||||
AccountType accountType = AccountType.parse(channel.getAccountType());
|
||||
if (accountType != null) {
|
||||
vo.setAccountType(accountType.getType());
|
||||
}
|
||||
}
|
||||
vo.setBstType(TransferBstType.WITHDRAW.getType());
|
||||
vo.setBstId(bill.getBillId());
|
||||
vo.setStatus(TransferStatus.TRANSFER_ING.getStatus());
|
||||
vo.setBatchName("提现转账");
|
||||
vo.setBatchRemark(String.format("提现申请%s转账", bill.getBillNo()));
|
||||
vo.setTotalAmount(bill.getArrivalAmount());
|
||||
|
||||
// 生成明细
|
||||
List<TransferDetailVO> detailList = new ArrayList<>();
|
||||
TransferDetailVO detail = new TransferDetailVO();
|
||||
detail.setStatus(TransferDetailStatus.TRANSFER_ING.getStatus());
|
||||
detail.setAmount(bill.getArrivalAmount());
|
||||
detail.setAccountNo(bill.getAccountNo());
|
||||
detailList.add(detail);
|
||||
vo.setDetailList(detailList);
|
||||
|
||||
return vo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
package com.ruoyi.ss.transfer.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.SnowFlakeUtil;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetailVO;
|
||||
import com.ruoyi.ss.transferDetail.service.ITransferDetailService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.ss.transfer.mapper.TransferMapper;
|
||||
import com.ruoyi.ss.transfer.domain.Transfer;
|
||||
import com.ruoyi.ss.transfer.domain.TransferVO;
|
||||
import com.ruoyi.ss.transfer.domain.TransferQuery;
|
||||
import com.ruoyi.ss.transfer.service.TransferService;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
/**
|
||||
* 转账Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-08-09
|
||||
*/
|
||||
@Service
|
||||
public class TransferServiceImpl implements TransferService
|
||||
{
|
||||
@Autowired
|
||||
private TransferMapper transferMapper;
|
||||
|
||||
@Autowired
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
@Autowired
|
||||
private ITransferDetailService transferDetailService;
|
||||
|
||||
/**
|
||||
* 查询转账
|
||||
*
|
||||
* @param batchId 转账主键
|
||||
* @return 转账
|
||||
*/
|
||||
@Override
|
||||
public TransferVO selectTransferByBatchId(Long batchId)
|
||||
{
|
||||
return transferMapper.selectTransferByBatchId(batchId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询转账列表
|
||||
*
|
||||
* @param transfer 转账
|
||||
* @return 转账
|
||||
*/
|
||||
@Override
|
||||
public List<TransferVO> selectTransferList(TransferQuery transfer)
|
||||
{
|
||||
return transferMapper.selectTransferList(transfer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增转账
|
||||
*
|
||||
* @param transfer 转账
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertTransfer(Transfer transfer)
|
||||
{
|
||||
transfer.setCreateTime(DateUtils.getNowDate());
|
||||
transfer.setBatchNo(String.valueOf(SnowFlakeUtil.newId()));
|
||||
return transferMapper.insertTransfer(transfer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改转账
|
||||
*
|
||||
* @param transfer 转账
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateTransfer(Transfer transfer)
|
||||
{
|
||||
return transferMapper.updateTransfer(transfer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除转账
|
||||
*
|
||||
* @param batchIds 需要删除的转账主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteTransferByBatchIds(Long[] batchIds)
|
||||
{
|
||||
return transferMapper.deleteTransferByBatchIds(batchIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除转账信息
|
||||
*
|
||||
* @param batchId 转账主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteTransferByBatchId(Long batchId)
|
||||
{
|
||||
return transferMapper.deleteTransferByBatchId(batchId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertWithDetail(TransferVO vo) {
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
int insert = this.insertTransfer(vo);
|
||||
ServiceUtil.assertion(insert != 1, "新增转账失败");
|
||||
|
||||
if (CollectionUtils.isNotEmptyElement(vo.getDetailList())) {
|
||||
for (TransferDetailVO detail : vo.getDetailList()) {
|
||||
detail.setTransferId(vo.getBatchId());
|
||||
}
|
||||
int batch = transferDetailService.batchInsert(vo.getDetailList());
|
||||
ServiceUtil.assertion(batch != vo.getDetailList().size(), "新增转账明细失败");
|
||||
}
|
||||
|
||||
return insert;
|
||||
});
|
||||
|
||||
return result == null ? 0 : result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requestTransfer(String batchNo) {
|
||||
TransferVO transfer = this.selectByBatchNo(batchNo);
|
||||
return this.requestTransfer(transfer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求转账
|
||||
*/
|
||||
private boolean requestTransfer(TransferVO transfer) {
|
||||
if (transfer == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO 请求转账
|
||||
transactionTemplate.execute(status -> {
|
||||
|
||||
// TODO 修改状态
|
||||
|
||||
|
||||
// TODO 发起转账
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransferVO selectByBatchNo(String batchNo) {
|
||||
return transferMapper.selectByBatchNo(batchNo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.ruoyi.ss.transferDetail.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 转账明细对象 ss_transfer_detail
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-08-09
|
||||
*/
|
||||
@Data
|
||||
public class TransferDetail extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long detailId;
|
||||
|
||||
@Excel(name = "转账明细单号")
|
||||
@ApiModelProperty("转账明细单号")
|
||||
private String detailNo;
|
||||
|
||||
@Excel(name = "转账批次ID")
|
||||
@ApiModelProperty("转账批次ID")
|
||||
private Long transferId;
|
||||
|
||||
@Excel(name = "明细状态")
|
||||
@ApiModelProperty("明细状态")
|
||||
private String status;
|
||||
|
||||
@Excel(name = "转账金额", readConverterExp = "元=")
|
||||
@ApiModelProperty("转账金额")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Excel(name = "收款用户账号")
|
||||
@ApiModelProperty("收款用户账号")
|
||||
private String accountNo;
|
||||
|
||||
@Excel(name = "收款用户姓名")
|
||||
@ApiModelProperty("收款用户姓名")
|
||||
private String userName;
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.ruoyi.ss.transferDetail.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/8/9
|
||||
*/
|
||||
@Data
|
||||
public class TransferDetailQuery extends TransferDetailVO{
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.ruoyi.ss.transferDetail.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/8/9
|
||||
*/
|
||||
@Data
|
||||
public class TransferDetailVO extends TransferDetail{
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.ruoyi.ss.transferDetail.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 转账明细状态
|
||||
* @author wjh
|
||||
* 2024/8/9
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum TransferDetailStatus {
|
||||
|
||||
TRANSFER_ING("1", "转账中"),
|
||||
TRANSFER_SUCCESS("2", "已转账"),
|
||||
TRANSFER_FAIL("3", "转账失败");
|
||||
|
||||
private final String status;
|
||||
private final String msg;
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package com.ruoyi.ss.transferDetail.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetail;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetailVO;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetailQuery;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 转账明细Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-08-09
|
||||
*/
|
||||
public interface TransferDetailMapper
|
||||
{
|
||||
/**
|
||||
* 查询转账明细
|
||||
*
|
||||
* @param detailId 转账明细主键
|
||||
* @return 转账明细
|
||||
*/
|
||||
public TransferDetailVO selectTransferDetailByDetailId(Long detailId);
|
||||
|
||||
/**
|
||||
* 查询转账明细列表
|
||||
*
|
||||
* @param query 转账明细
|
||||
* @return 转账明细集合
|
||||
*/
|
||||
public List<TransferDetailVO> selectTransferDetailList(@Param("query")TransferDetailQuery query);
|
||||
|
||||
/**
|
||||
* 新增转账明细
|
||||
*
|
||||
* @param transferDetail 转账明细
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertTransferDetail(TransferDetail transferDetail);
|
||||
|
||||
/**
|
||||
* 修改转账明细
|
||||
*
|
||||
* @param transferDetail 转账明细
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateTransferDetail(@Param("data") TransferDetail transferDetail);
|
||||
|
||||
/**
|
||||
* 删除转账明细
|
||||
*
|
||||
* @param detailId 转账明细主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTransferDetailByDetailId(Long detailId);
|
||||
|
||||
/**
|
||||
* 批量删除转账明细
|
||||
*
|
||||
* @param detailIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTransferDetailByDetailIds(Long[] detailIds);
|
||||
|
||||
/**
|
||||
* 批量新增
|
||||
*/
|
||||
int batchInsert(@Param("list") List<TransferDetailVO> list);
|
||||
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ss.transferDetail.mapper.TransferDetailMapper">
|
||||
|
||||
<resultMap type="TransferDetailVO" id="TransferDetailResult" autoMapping="true" />
|
||||
|
||||
<sql id="selectTransferDetailVo">
|
||||
select
|
||||
std.detail_id,
|
||||
std.detail_no,
|
||||
std.transfer_id,
|
||||
std.status,
|
||||
std.amount,
|
||||
std.remark,
|
||||
std.account_no,
|
||||
std.user_name,
|
||||
std.create_time
|
||||
from ss_transfer_detail std
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
<if test="query.detailId != null "> and std.detail_id = #{query.detailId}</if>
|
||||
<if test="query.detailNo != null and query.detailNo != ''"> and std.detail_no like concat('%', #{query.detailNo}, '%')</if>
|
||||
<if test="query.transferId != null "> and std.transfer_id = #{query.transferId}</if>
|
||||
<if test="query.status != null and query.status != ''"> and std.status = #{query.status}</if>
|
||||
<if test="query.remark != null and query.remark != ''"> and std.remark like concat('%', #{query.remark}, '%')</if>
|
||||
<if test="query.accountNo != null and query.accountNo != ''"> and std.account_no like concat('%', #{query.accountNo}, '%')</if>
|
||||
<if test="query.userName != null and query.userName != ''"> and std.user_name like concat('%', #{query.userName}, '%')</if>
|
||||
</sql>
|
||||
|
||||
<select id="selectTransferDetailList" parameterType="TransferDetailQuery" resultMap="TransferDetailResult">
|
||||
<include refid="selectTransferDetailVo"/>
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectTransferDetailByDetailId" parameterType="Long" resultMap="TransferDetailResult">
|
||||
<include refid="selectTransferDetailVo"/>
|
||||
where std.detail_id = #{detailId}
|
||||
</select>
|
||||
|
||||
<insert id="insertTransferDetail" parameterType="TransferDetail" useGeneratedKeys="true" keyProperty="detailId">
|
||||
insert into ss_transfer_detail
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="detailNo != null and detailNo != ''">detail_no,</if>
|
||||
<if test="transferId != null">transfer_id,</if>
|
||||
<if test="status != null and status != ''">`status`,</if>
|
||||
<if test="amount != null">amount,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="accountNo != null and accountNo != ''">account_no,</if>
|
||||
<if test="userName != null">user_name,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="detailNo != null and detailNo != ''">#{detailNo},</if>
|
||||
<if test="transferId != null">#{transferId},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="amount != null">#{amount},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="accountNo != null and accountNo != ''">#{accountNo},</if>
|
||||
<if test="userName != null">#{userName},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
<insert id="batchInsert">
|
||||
insert into ss_transfer_detail(
|
||||
detail_no,
|
||||
transfer_id,
|
||||
status,
|
||||
amount,
|
||||
remark,
|
||||
account_no,
|
||||
user_name,
|
||||
create_time
|
||||
)
|
||||
values
|
||||
<foreach collection="list" item="i" separator=",">
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="i.detailNo != null and i.detailNo != ''">#{i.detailNo},</if>
|
||||
<if test="i.detailNo == null or i.detailNo == ''">default,</if>
|
||||
<if test="i.transferId != null">#{i.transferId},</if>
|
||||
<if test="i.transferId == null">default,</if>
|
||||
<if test="i.status != null and i.status != ''">#{i.status},</if>
|
||||
<if test="i.status == null or i.status == ''">default,</if>
|
||||
<if test="i.amount != null">#{i.amount},</if>
|
||||
<if test="i.amount == null">default,</if>
|
||||
<if test="i.remark != null and i.remark != ''">#{i.remark},</if>
|
||||
<if test="i.remark == null or i.remark == ''">default,</if>
|
||||
<if test="i.accountNo != null and i.accountNo != ''">#{i.accountNo},</if>
|
||||
<if test="i.accountNo == null or i.accountNo == ''">default,</if>
|
||||
<if test="i.userName != null">#{i.userName},</if>
|
||||
<if test="i.userName == null">default,</if>
|
||||
<if test="i.createTime != null">#{i.createTime},</if>
|
||||
<if test="i.createTime == null">default,</if>
|
||||
</trim>
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateTransferDetail" parameterType="TransferDetail">
|
||||
update ss_transfer_detail
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="data.detailNo != null and data.detailNo != ''">detail_no = #{data.detailNo},</if>
|
||||
<if test="data.transferId != null">transfer_id = #{data.transferId},</if>
|
||||
<if test="data.status != null and data.status != ''">`status` = #{data.status},</if>
|
||||
<if test="data.amount != null">amount = #{data.amount},</if>
|
||||
<if test="data.remark != null and data.remark != ''">remark = #{data.remark},</if>
|
||||
<if test="data.accountNo != null and data.accountNo != ''">account_no = #{data.accountNo},</if>
|
||||
<if test="data.userName != null">user_name = #{data.userName},</if>
|
||||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||
</trim>
|
||||
where detail_id = #{data.detailId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteTransferDetailByDetailId" parameterType="Long">
|
||||
delete from ss_transfer_detail where detail_id = #{detailId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteTransferDetailByDetailIds" parameterType="String">
|
||||
delete from ss_transfer_detail where detail_id in
|
||||
<foreach item="detailId" collection="array" open="(" separator="," close=")">
|
||||
#{detailId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -0,0 +1,70 @@
|
|||
package com.ruoyi.ss.transferDetail.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetail;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetailVO;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetailQuery;
|
||||
|
||||
/**
|
||||
* 转账明细Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-08-09
|
||||
*/
|
||||
public interface ITransferDetailService
|
||||
{
|
||||
/**
|
||||
* 查询转账明细
|
||||
*
|
||||
* @param detailId 转账明细主键
|
||||
* @return 转账明细
|
||||
*/
|
||||
public TransferDetailVO selectTransferDetailByDetailId(Long detailId);
|
||||
|
||||
/**
|
||||
* 查询转账明细列表
|
||||
*
|
||||
* @param transferDetail 转账明细
|
||||
* @return 转账明细集合
|
||||
*/
|
||||
public List<TransferDetailVO> selectTransferDetailList(TransferDetailQuery transferDetail);
|
||||
|
||||
/**
|
||||
* 新增转账明细
|
||||
*
|
||||
* @param transferDetail 转账明细
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertTransferDetail(TransferDetail transferDetail);
|
||||
|
||||
/**
|
||||
* 修改转账明细
|
||||
*
|
||||
* @param transferDetail 转账明细
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateTransferDetail(TransferDetail transferDetail);
|
||||
|
||||
/**
|
||||
* 批量删除转账明细
|
||||
*
|
||||
* @param detailIds 需要删除的转账明细主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTransferDetailByDetailIds(Long[] detailIds);
|
||||
|
||||
/**
|
||||
* 删除转账明细信息
|
||||
*
|
||||
* @param detailId 转账明细主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteTransferDetailByDetailId(Long detailId);
|
||||
|
||||
/**
|
||||
* 批量新增
|
||||
* @param list
|
||||
*/
|
||||
int batchInsert(List<TransferDetailVO> list);
|
||||
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
package com.ruoyi.ss.transferDetail.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.SnowFlakeUtil;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.ss.transferDetail.mapper.TransferDetailMapper;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetail;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetailVO;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetailQuery;
|
||||
import com.ruoyi.ss.transferDetail.service.ITransferDetailService;
|
||||
|
||||
/**
|
||||
* 转账明细Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-08-09
|
||||
*/
|
||||
@Service
|
||||
public class TransferDetailServiceImpl implements ITransferDetailService
|
||||
{
|
||||
@Autowired
|
||||
private TransferDetailMapper transferDetailMapper;
|
||||
|
||||
/**
|
||||
* 查询转账明细
|
||||
*
|
||||
* @param detailId 转账明细主键
|
||||
* @return 转账明细
|
||||
*/
|
||||
@Override
|
||||
public TransferDetailVO selectTransferDetailByDetailId(Long detailId)
|
||||
{
|
||||
return transferDetailMapper.selectTransferDetailByDetailId(detailId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询转账明细列表
|
||||
*
|
||||
* @param transferDetail 转账明细
|
||||
* @return 转账明细
|
||||
*/
|
||||
@Override
|
||||
public List<TransferDetailVO> selectTransferDetailList(TransferDetailQuery transferDetail)
|
||||
{
|
||||
return transferDetailMapper.selectTransferDetailList(transferDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增转账明细
|
||||
*
|
||||
* @param transferDetail 转账明细
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertTransferDetail(TransferDetail transferDetail)
|
||||
{
|
||||
setBaseInfo(transferDetail);
|
||||
return transferDetailMapper.insertTransferDetail(transferDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改转账明细
|
||||
*
|
||||
* @param transferDetail 转账明细
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateTransferDetail(TransferDetail transferDetail)
|
||||
{
|
||||
return transferDetailMapper.updateTransferDetail(transferDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除转账明细
|
||||
*
|
||||
* @param detailIds 需要删除的转账明细主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteTransferDetailByDetailIds(Long[] detailIds)
|
||||
{
|
||||
return transferDetailMapper.deleteTransferDetailByDetailIds(detailIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除转账明细信息
|
||||
*
|
||||
* @param detailId 转账明细主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteTransferDetailByDetailId(Long detailId)
|
||||
{
|
||||
return transferDetailMapper.deleteTransferDetailByDetailId(detailId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchInsert(List<TransferDetailVO> list) {
|
||||
if (CollectionUtils.isEmptyElement(list)) {
|
||||
return 0;
|
||||
}
|
||||
for (TransferDetailVO detail : list) {
|
||||
this.setBaseInfo(detail);
|
||||
}
|
||||
return transferDetailMapper.batchInsert(list);
|
||||
}
|
||||
|
||||
private void setBaseInfo(TransferDetail detail) {
|
||||
detail.setDetailNo(String.valueOf(SnowFlakeUtil.newId()));
|
||||
detail.setCreateTime(DateUtils.getNowDate());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package com.ruoyi.web.controller.ss;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.ss.transfer.domain.Transfer;
|
||||
import com.ruoyi.ss.transfer.domain.TransferVO;
|
||||
import com.ruoyi.ss.transfer.domain.TransferQuery;
|
||||
import com.ruoyi.ss.transfer.service.TransferService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 转账Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-08-09
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ss/transfer")
|
||||
public class TransferController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private TransferService transferService;
|
||||
|
||||
/**
|
||||
* 查询转账列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:transfer:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(TransferQuery query)
|
||||
{
|
||||
startPage();
|
||||
startOrderBy();
|
||||
List<TransferVO> list = transferService.selectTransferList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出转账列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:transfer:export')")
|
||||
@Log(title = "转账", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, TransferQuery query)
|
||||
{
|
||||
List<TransferVO> list = transferService.selectTransferList(query);
|
||||
ExcelUtil<TransferVO> util = new ExcelUtil<TransferVO>(TransferVO.class);
|
||||
util.exportExcel(response, list, "转账数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取转账详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:transfer:query')")
|
||||
@GetMapping(value = "/{batchId}")
|
||||
public AjaxResult getInfo(@PathVariable("batchId") Long batchId)
|
||||
{
|
||||
return success(transferService.selectTransferByBatchId(batchId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增转账
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:transfer:add')")
|
||||
@Log(title = "转账", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody Transfer transfer)
|
||||
{
|
||||
return toAjax(transferService.insertTransfer(transfer));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改转账
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:transfer:edit')")
|
||||
@Log(title = "转账", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody Transfer transfer)
|
||||
{
|
||||
return toAjax(transferService.updateTransfer(transfer));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除转账
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:transfer:remove')")
|
||||
@Log(title = "转账", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{batchIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] batchIds)
|
||||
{
|
||||
return toAjax(transferService.deleteTransferByBatchIds(batchIds));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package com.ruoyi.web.controller.ss;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetail;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetailVO;
|
||||
import com.ruoyi.ss.transferDetail.domain.TransferDetailQuery;
|
||||
import com.ruoyi.ss.transferDetail.service.ITransferDetailService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 转账明细Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-08-09
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ss/transferDetail")
|
||||
public class TransferDetailController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ITransferDetailService transferDetailService;
|
||||
|
||||
/**
|
||||
* 查询转账明细列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:transferDetail:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(TransferDetailQuery query)
|
||||
{
|
||||
startPage();
|
||||
startOrderBy();
|
||||
List<TransferDetailVO> list = transferDetailService.selectTransferDetailList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出转账明细列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:transferDetail:export')")
|
||||
@Log(title = "转账明细", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, TransferDetailQuery query)
|
||||
{
|
||||
List<TransferDetailVO> list = transferDetailService.selectTransferDetailList(query);
|
||||
ExcelUtil<TransferDetailVO> util = new ExcelUtil<TransferDetailVO>(TransferDetailVO.class);
|
||||
util.exportExcel(response, list, "转账明细数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取转账明细详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:transferDetail:query')")
|
||||
@GetMapping(value = "/{detailId}")
|
||||
public AjaxResult getInfo(@PathVariable("detailId") Long detailId)
|
||||
{
|
||||
return success(transferDetailService.selectTransferDetailByDetailId(detailId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增转账明细
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:transferDetail:add')")
|
||||
@Log(title = "转账明细", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody TransferDetail transferDetail)
|
||||
{
|
||||
return toAjax(transferDetailService.insertTransferDetail(transferDetail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改转账明细
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:transferDetail:edit')")
|
||||
@Log(title = "转账明细", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody TransferDetail transferDetail)
|
||||
{
|
||||
return toAjax(transferDetailService.updateTransferDetail(transferDetail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除转账明细
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:transferDetail:remove')")
|
||||
@Log(title = "转账明细", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{detailIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] detailIds)
|
||||
{
|
||||
return toAjax(transferDetailService.deleteTransferDetailByDetailIds(detailIds));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user