外部系统生成单据号接口

说明

“外部系统生成”时,第三方提供外部生成单据号接口,按照第三方自己的单据号生成规则生成。

特别约束

限制特殊字符的输入

请求类型

POST

请求参数

{
  "legalEntCode": "公司抬头企业编号(内码)",
  "legalInvoiceTitle": "公司抬头",
  "legalEntBizCode" : "公司抬头业务编码(外码)"
}

Java示例代码

package com.example.demo.dtos;

import lombok.Data;

@Data
public class ExternalFormCodeRequest {
    private String legalEntCode;
    private String legalEntBizCode;
    private String legalInvoiceTitle;
}

请求头

Content-Type application/json

响应参数

注意:第三方接口返回结果请严格按照如下结构进行返回。

{
  "success":true,
  "errorMsg":"xxxxx",
  "data":{
      "abbreviation":"单据号"
  }
}

Java示例代码

package com.example.demo.dtos;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;

@Data
public class ResponseDto<D> {

    boolean success;
    String errorMsg;
    D data;

    public static <T> ResponseDto<T> ack(boolean success, T data) {
        var dto = new ResponseDto<T>();
        dto.success = success;
        dto.data = data;

        return dto;
    }

    public static String stringify(Object object) {
        ObjectMapper mapper = new ObjectMapper();
        try {
            return mapper.writeValueAsString(object);
        } catch (Exception e) {
            System.out.println(e);
        }

        return null;
    }

    @Override
    public String toString() {
        return stringify(this);
    }
}
package com.example.demo.dtos;

import lombok.Data;

@Data
public class CodeWrapper {
    String abbreviation;
    public CodeWrapper(String abbreviation) {
        this.abbreviation = abbreviation;
    }
}
@RestController
public class TestController {
    @PostMapping("/web/generateCode")
    public ResponseDto<?> saveRolesForEnt(@RequestBody ExternalFormCodeRequest dto) {
        return ResponseDto.ack(true, new CodeWrapper("code"));
    }
}
Copyright © 杭州每刻科技有限公司 www.maycur.com all right reserved,powered by Gitbook该文件修订时间: 2024-11-20 10:52:00

results matching ""

    No results matching ""

    results matching ""

      No results matching ""