|
@@ -3,11 +3,14 @@ package com.idea.invoice.util;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.idea.invoice.model.InvoiceManage;
|
|
|
+import com.idea.util.DateUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import nccloud.open.api.auto.token.cur.utils.APICurUtils;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
@Slf4j
|
|
@@ -30,22 +33,242 @@ public class InvoiceUtil {
|
|
|
|
|
|
public static final String password = "1234qwer!";
|
|
|
|
|
|
+ /**
|
|
|
+ * 组织编码
|
|
|
+ */
|
|
|
+ public static final String pk_org = "0102";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 自定义档案列表编码
|
|
|
+ */
|
|
|
+ public static final String pk_defdoclist = "CJ21";
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
- APICurUtils util = new APICurUtils();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取token
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static String getToken(APICurUtils util) throws Exception {
|
|
|
util.init(ip, port, biz_center, client_id, client_secret, pubKey, username, password);
|
|
|
String token = util.getToken();
|
|
|
System.out.println(" 获取token=========" + token);
|
|
|
+ return token;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 房间新增
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static void defdocAdd() throws Exception {
|
|
|
+ APICurUtils util = new APICurUtils();
|
|
|
+ String token = InvoiceUtil.getToken(util);
|
|
|
util.setApiUrl("nccloud/api/wxyy/uapbd/defdoc/add");
|
|
|
JSONObject json = new JSONObject();
|
|
|
- json.put("srcsystemid", IdUtil.simpleUUID());
|
|
|
+ json.put("srcsystemid", "1300419721555869696");
|
|
|
json.put("code","100");
|
|
|
- json.put("name","演示项目二-分期一-1号楼-一单元-901");
|
|
|
- json.put("pk_org","0102");
|
|
|
- json.put("pk_defdoclist","CJ21");
|
|
|
+ json.put("name","天鹅湖花园-一期-41-101");
|
|
|
+ json.put("pk_org",pk_org);
|
|
|
+ json.put("pk_defdoclist",pk_defdoclist);
|
|
|
+ String result = util.getAPIRetrun(token, json.toJSONString());
|
|
|
+ System.out.println(" 接口结果=========" + result);
|
|
|
+ log.info("房间新增:{}",result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 客户新增
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static void customerAdd() throws Exception {
|
|
|
+ APICurUtils util = new APICurUtils();
|
|
|
+ String token = InvoiceUtil.getToken(util);
|
|
|
+ util.setApiUrl("nccloud/api/wxyy/uapbd/customer/add");
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("srcsystemid", "a9eb2c6f3e1f4b36a93f06fdba1a7177");
|
|
|
+ json.put("name","客户测试");
|
|
|
+ json.put("pk_custclass","02"); //客户基本分类 ,,(默认是02),必选,01内部客户,02外部客户
|
|
|
+ json.put("custprop","0");//财务组织客户类型,必选,默认0
|
|
|
+ json.put("taxpayerid","tyxydm00001"); //统一社会信用代码,必选
|
|
|
+ String result = util.getAPIRetrun(token, json.toJSONString());
|
|
|
+ System.out.println(" 接口结果=========" + result);
|
|
|
+ log.info("客户新增:{}",result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 客户分配
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static void customerAssign() throws Exception {
|
|
|
+ APICurUtils util = new APICurUtils();
|
|
|
+ String token = InvoiceUtil.getToken(util);
|
|
|
+ util.setApiUrl("nccloud/api/wxyy/uapbd/customer/assign");
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("pk_org", pk_org);
|
|
|
+ json.put("ncid","");
|
|
|
+ String result = util.getAPIRetrun(token, json.toJSONString());
|
|
|
+ System.out.println(" 接口结果=========" + result);
|
|
|
+ log.info("客户分配:{}",result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 付款单接口_退款单
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static void paybillAdd() throws Exception {
|
|
|
+ APICurUtils util = new APICurUtils();
|
|
|
+ String token = InvoiceUtil.getToken(util);
|
|
|
+ util.setApiUrl("nccloud/api/wxyy/arap/paybill/saveandcommit");
|
|
|
+ String billdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+
|
|
|
+ JSONObject ap_paybill = new JSONObject();
|
|
|
+ String srcsystemid = IdUtil.simpleUUID();
|
|
|
+ ap_paybill.put("srcsystemid", srcsystemid); //外系统标识,必选
|
|
|
+ ap_paybill.put("pk_tradetype","F3-Cxx-06"); //交易类型,必选
|
|
|
+ ap_paybill.put("pk_org",pk_org); //组织编码,必选
|
|
|
+ ap_paybill.put("billdate",billdate); //单据日期
|
|
|
+ ap_paybill.put("def2",srcsystemid); //外系统单据号,必填,
|
|
|
+ json.put("ap_paybill",ap_paybill);
|
|
|
+
|
|
|
+ JSONArray ap_payitem = new JSONArray();
|
|
|
+ JSONObject ap_payitemJson = new JSONObject();
|
|
|
+ ap_payitemJson.put("srcsystemid",srcsystemid); //外系统子表标识
|
|
|
+ ap_payitemJson.put("scomment","小二"); //客户名称,必选
|
|
|
+ ap_payitemJson.put("pk_subjcode","MY001"); //收支项目编码,必选
|
|
|
+ ap_payitemJson.put("objtype","0"); //0=客户,1=供应商--判断customer和supplier是否必填,必选
|
|
|
+ ap_payitemJson.put("customer","91734"); //客商的纳税人识别号
|
|
|
+ ap_payitemJson.put("money_de","200"); //金额,必选
|
|
|
+ ap_payitemJson.put("taxrate","10"); //税率,必选,无税传0
|
|
|
+ ap_payitemJson.put("pk_balatype","3"); //结算方式,必选,使用默认账号付款则结算方式为银企直联
|
|
|
+ ap_payitemJson.put("pk_recpaytype","001"); //付款业务类型传默认值“001”
|
|
|
+ ap_payitemJson.put("prepay","0"); //默认值0
|
|
|
+ ap_payitemJson.put("payaccount","2019219219212323"); //付款银行账号,必选
|
|
|
+ ap_payitemJson.put("checktype","1"); //票据类型,必选,看云文档票据类型
|
|
|
+ ap_payitemJson.put("checkno","111"); //票据号,必选
|
|
|
+ // TODO: 2024/10/28 可能是新增房间返回的数据
|
|
|
+ ap_payitemJson.put("def11",""); //转出前房号编码,必选
|
|
|
+ ap_payitemJson.put("def9","001"); //业态,必选,看云文档业态
|
|
|
+ ap_payitemJson.put("def10",""); //项目档案编码,看云文档项目档案对照
|
|
|
+ ap_payitem.add(ap_payitemJson);
|
|
|
+ json.put("ap_payitem",ap_payitem);
|
|
|
+
|
|
|
String result = util.getAPIRetrun(token, json.toJSONString());
|
|
|
System.out.println(" 接口结果=========" + result);
|
|
|
+ log.info("付款单接口_退款单:{}",result);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 应收接口-收入结转单
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static void recbillAdd() throws Exception {
|
|
|
+ APICurUtils util = new APICurUtils();
|
|
|
+ String token = InvoiceUtil.getToken(util);
|
|
|
+ util.setApiUrl("nccloud/api/wxyy/arap/recbill/saveandcommit");
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+
|
|
|
+ JSONObject ar_recbill = new JSONObject();
|
|
|
+ String srcsystemid = IdUtil.simpleUUID();
|
|
|
+ String billdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
|
|
|
+ ar_recbill.put("srcsystemid", srcsystemid); //外系统标识,必选
|
|
|
+ ar_recbill.put("pk_tradetype","F3-Cxx-05"); //交易类型,必选
|
|
|
+ ar_recbill.put("pk_org",pk_org); //组织编码,必选
|
|
|
+ ar_recbill.put("billdate",billdate); //单据日期
|
|
|
+ ar_recbill.put("def2",srcsystemid); //外系统单据号,必填,
|
|
|
+ ar_recbill.put("def19","E05"); //特殊票种标识,默认是E05
|
|
|
+ ar_recbill.put("def20","0"); //征税方式
|
|
|
+ ar_recbill.put("def21","不动产地址"); //不动产地址,必填,字符串
|
|
|
+ ar_recbill.put("def22","N"); //不动产地址,必填,字符串
|
|
|
+ json.put("ar_recbill",ar_recbill);
|
|
|
+
|
|
|
+ JSONArray ar_recitem = new JSONArray();
|
|
|
+ JSONObject ar_recitemJson = new JSONObject();
|
|
|
+ ar_recitemJson.put("srcsystemid",srcsystemid); //外系统子表标识
|
|
|
+ ar_recitemJson.put("scomment",""); //摘要,非必选
|
|
|
+ ar_recitemJson.put("objtype","0"); //0=客户,1=供应商--判断customer和supplier是否必填,必选
|
|
|
+ ar_recitemJson.put("customer","91734"); //客商的纳税人识别号
|
|
|
+ ar_recitemJson.put("money_de","100"); //金额,必选
|
|
|
+ ar_recitemJson.put("taxrate","16"); //税率,必选,无税传0
|
|
|
+ ar_recitemJson.put("pk_subjcode","MY003"); //收支项目编码,非必选
|
|
|
+
|
|
|
+ // TODO: 2024/10/28 可能是新增房间返回的数据
|
|
|
+ ar_recitemJson.put("def11",""); //转出前房号编码,收除了诚意金之外的首期等需要选
|
|
|
+ ar_recitemJson.put("def9","001"); //业态,必选,看云文档业态
|
|
|
+ // TODO: 2024/10/28 没有
|
|
|
+ ar_recitemJson.put("def7",""); //房产工程项目,必选,看云文档
|
|
|
+ // TODO: 2024/10/28 没有
|
|
|
+ ar_recitemJson.put("def8",""); //楼栋,必选,看云文档
|
|
|
+ ar_recitemJson.put("material","XXX"); //物料
|
|
|
+ ar_recitem.add(ar_recitemJson);
|
|
|
+ json.put("ar_recitem",ar_recitem);
|
|
|
+
|
|
|
+ String result = util.getAPIRetrun(token, json.toJSONString());
|
|
|
+ System.out.println(" 接口结果=========" + result);
|
|
|
+ log.info("应收接口-收入结转单:{}",result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 收款单接口-新增提交
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static void gatheringbillAdd() throws Exception {
|
|
|
+ APICurUtils util = new APICurUtils();
|
|
|
+ String token = InvoiceUtil.getToken(util);
|
|
|
+ util.setApiUrl("nccloud/api/wxyy/arap/recbill/saveandcommit");
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+
|
|
|
+ JSONObject ar_gatherbill = new JSONObject();
|
|
|
+ String srcsystemid = IdUtil.simpleUUID();
|
|
|
+ String billdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
|
|
|
+ ar_gatherbill.put("srcsystemid", srcsystemid); //外系统标识,必选
|
|
|
+ ar_gatherbill.put("pk_tradetype","F3-Cxx-06"); //交易类型,必选
|
|
|
+ ar_gatherbill.put("pk_org",pk_org); //组织编码,必选
|
|
|
+ ar_gatherbill.put("billdate",billdate); //单据日期
|
|
|
+ ar_gatherbill.put("def2",srcsystemid); //外系统单据号,必填,
|
|
|
+ json.put("ar_gatherbill",ar_gatherbill);
|
|
|
+
|
|
|
+ JSONArray ar_gatheritem = new JSONArray();
|
|
|
+ JSONObject ar_gatheritemJson = new JSONObject();
|
|
|
+ ar_gatheritemJson.put("srcsystemid",srcsystemid); //外系统子表标识
|
|
|
+ ar_gatheritemJson.put("objtype","0"); //0=客户,1=供应商--判断customer和supplier是否必填,必选
|
|
|
+ ar_gatheritemJson.put("customer","91734"); //客商的纳税人识别号
|
|
|
+ ar_gatheritemJson.put("money_cr","200"); //金额,必选
|
|
|
+ ar_gatheritemJson.put("taxrate","10"); //税率,必选,数字——3/10/6````
|
|
|
+ ar_gatheritemJson.put("pk_balatype","3"); //结算方式,必选,看云文档收款类型
|
|
|
+ ar_gatheritemJson.put("pk_recpaytype","001"); //付款业务类型传默认值“001”
|
|
|
+ ar_gatheritemJson.put("prepay","0"); //收款性质应收款时传"0",收款性质预收款时传"1"
|
|
|
+ ar_gatheritemJson.put("recaccount","0407200000001648"); //收款银行账号,必填
|
|
|
+ ar_gatheritemJson.put("scomment","小二"); //客户名称,必选
|
|
|
+ ar_gatheritemJson.put("pk_subjcode","AJ001"); //收支项目编码,必选,看云文档收支项目对照
|
|
|
+ ar_gatheritemJson.put("checktype","1"); //票据类型,必选,看云文档票据类型
|
|
|
+ ar_gatheritemJson.put("checkno","111"); //票据号,必选
|
|
|
+ ar_gatheritemJson.put("def9","001"); //业态,必选,看云文档业态
|
|
|
+ // TODO: 2024/10/28 可能是新增房间返回的数据
|
|
|
+ ar_gatheritemJson.put("def11",""); //转出前房号编码,收除了诚意金之外的首期等需要选
|
|
|
+ // TODO: 2024/10/28 没有
|
|
|
+ ar_gatheritemJson.put("def10",""); //项目档案编码,看云文档项目档案对照
|
|
|
+ ar_gatheritem.add(ar_gatheritemJson);
|
|
|
+ json.put("ar_gatheritem",ar_gatheritem);
|
|
|
+
|
|
|
+ String result = util.getAPIRetrun(token, json.toJSONString());
|
|
|
+ System.out.println(" 接口结果=========" + result);
|
|
|
+ log.info("应收接口-收入结转单:{}",result);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|