org.yes.tools.pay.module.request.RefundRequest Maven / Gradle / Ivy
package org.yes.tools.pay.module.request;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.yes.tools.pay.config.PayConfig;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public class RefundRequest extends BaseRequest {
private static final long serialVersionUID = 522565152886671849L;
//报文系统预留字段
private String srcReserve;
//商户订单号
private String merOrderId;
//终端号
private String tid;
//要退货的金额
private Integer refundAmount;
//平台商户退款分账金额
private Integer platformAmount;
//子订单信息
private List subOrders;
//退货说明
private String refundDesc;
//帐单号 ctob
private String billNo;
//账单时间 格式:yyyy-MM-dd ctob
private String billDate;
@Override
public void checkAndSign(PayConfig payConfig) {
this.merOrderId = payConfig.getSourceSn() + this.merOrderId;
this.billNo = payConfig.getSourceSn() + this.merOrderId;
this.billDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd");
int sum = this.subOrders.stream().mapToInt(RefundRequest.SubOrder::getTotalAmount).sum();
this.platformAmount = this.refundAmount - sum;
super.checkAndSign(payConfig);
}
@Data
@NoArgsConstructor
public static class SubOrder implements Serializable {
private static final long serialVersionUID = -1L;
//子商户号
private String mid;
//子商户分账金额
private Integer totalAmount;
}
}