package com.jeequan.jeepay.pay.ctrl.channel.alipay.model.response;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/*
* 支付宝SPI  接口返回对象
*
* @author zx
*
* @date 2023/3/7 10:35
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SpiBaseResponse {

    /** 业务响应码 **/
    @JSONField(name = "code")
    private String code;

    /** 业务响应信息 **/
    @JSONField(name = "msg")
    private String msg;

    /** 业务响应码 **/
    @JSONField(name = "sub_code")
    private String subCode;

    /** 业务响应信息 **/
    @JSONField(name = "sub_msg")
    private String subMsg;

    /** ISV 自定义错误 **/
    @JSONField(name = "error_code")
    private String errorCode;

    /** ISV 自定义错误描述 **/
    @JSONField(name = "error_desc")
    private String errorDesc;

    /** 业务处理成功 **/
    public static void ok(SpiBaseResponse response){
        response.setCode("10000");
        response.setMsg("Success");
    }

    /** 业务处理失败 **/
    public static SpiBaseResponse fail(String errCode, String errMsg){
        return new SpiBaseResponse("40004", "Business Failed", errCode, errMsg, errCode, errMsg);
    }

}
