All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.yes.tools.pay.module.request.CToBRefundRequest Maven / Gradle / Ivy

There is a newer version: 2.0.4
Show newest version
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 CToBRefundRequest extends BaseRequest {
    private static final long serialVersionUID = 522565152886671814L;
    //报文系统预留字段
    private String srcReserve;
    //终端号
    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.billNo = payConfig.getSourceSn() + this.billNo;
        this.billDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd");
        int sum = this.subOrders.stream().mapToInt(CToBRefundRequest.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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy