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

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

There is a newer version: 2.0.4
Show newest version
package org.yes.tools.pay.module.request;

import cn.hutool.core.date.DateUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.yes.tools.pay.config.PayConfig;

import java.util.Date;
import java.util.List;

@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public class CToBPayRequest extends BaseRequest {
    private static final long serialVersionUID = 522565152886671812L;

    //消息ID
    private String msgId;
    //请求系统预留字段
    private String srcReserve;
    //终端号
    private String tid;
    //	账单号 重要,参考二维码获取规范
    private String billNo;
    //二维码ID 针对需要自行生成二维码的情况
    private String qrCodeId;
    //账单日期 格式yyyy-MM-dd
    private String billDate;
    //账单描述 不超过128个汉字
    private String billDesc;
    //支付总金额 单位:分 若divisionFlag为true,则:
    //totalAmount =subOrders字段中的所有totalAmount值之和
    //platformAmount值 =goods中的所有subOrderAmount值之和。
    private Integer totalAmount;
    //分账标记
    private Boolean divisionFlag;
    //子订单信息
    private List subOrders;
    //支付结果通知地址
    private String notifyUrl;
    //平台商户分账金额,单位:分, 若分账标记传,则分账金额必传
    private Integer platformAmount;

    @Override
    public void checkAndSign(PayConfig payConfig) {
        this.billNo = payConfig.getSourceSn() + this.billNo;
        this.billDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd");
        this.divisionFlag = this.subOrders.size() > 0;
        int sum = this.subOrders.stream().mapToInt(PayRequest.SubOrder::getTotalAmount).sum();
        this.platformAmount = this.totalAmount - sum;
        super.checkAndSign(payConfig);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy