|
|
@@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.logging.log4j.util.Strings;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
@@ -59,13 +60,14 @@ public class SikuServiceImpl implements SikuService {
|
|
|
}else {
|
|
|
//供应商
|
|
|
String hzlx = UtilMap.getString(formData, "radioField_mketkvw7");
|
|
|
+ String freeType = UtilMap.getString(formData, "radioField_mmyoc59n");//free类别
|
|
|
|
|
|
partner.put("parentBizCode", "GYS");//所属分类业务编码
|
|
|
- partner.put("name", "Free".equals(hzlx) ? UtilMap.getString(formData,"textField_mkkixdd6") : UtilMap.getString(formData,"textField_mketkvv0"));//往来单位中文名
|
|
|
+ partner.put("name", "个人".equals(freeType) ? UtilMap.getString(formData,"textField_mkkixdd6") : UtilMap.getString(formData,"textField_mketkvv0"));//往来单位中文名
|
|
|
partner.put("partnerType", "供应商");//往来关系,可选值为:"供应商"、"客户"、"供应商,客户"(既是供应商又是客户的情况下以中文逗号分隔(供应商在前))
|
|
|
- partner.put("partnerProperty", "Free".equals(hzlx) ? "个体工商户" : "公司");//往来性质,可选值为:"公司"、"个体工商户"
|
|
|
+ partner.put("partnerProperty", "个人".equals(freeType) ? "个体工商户" : "公司");//往来性质,可选值为:"公司"、"个体工商户"
|
|
|
partner.put("businessCode", UtilMap.getString(formData,"serialNumberField_mketkvw4"));//往来单位编码,不超过50个字符
|
|
|
- partner.put("taxNumber", "Free".equals(hzlx) ? "" : UtilMap.getString(formData,"textField_mketkvxo"));//税务登记号,不超过200个字符
|
|
|
+ partner.put("taxNumber", "个人".equals(freeType) ? "" : UtilMap.getString(formData,"textField_mketkvxo"));//税务登记号,不超过200个字符
|
|
|
partner.put("readOnly", false);//是否只读,默认false。如果为true,那么在每刻系统中往来单位的所有信息(如权限范围、收款账户等)均无法修改。(接口更新操作不受限制)
|
|
|
partner.put("reMark", "");//往来单位备注
|
|
|
partner.put("enabled", "启用".equals(UtilMap.getString(formData,"radioField_mketkvw8")));//是否启用(true:启用;false:禁用)。若该参数为空,新增则默认为true,更新则保持系统内状态。
|
|
|
@@ -138,9 +140,10 @@ public class SikuServiceImpl implements SikuService {
|
|
|
application.put("bizCode", UtilMap.getString(formData,"serialNumberField_mknspz75"));//外部系统中的开票申请单业务编码。必须系统内唯一,用于判断开票申请单是否已导入。
|
|
|
|
|
|
application.put("clientBizCode",UtilMap.getString(formData,"textField_mkxpe3fj"));//收票方bizCode(客户的业务编码(云票系统内维护的))与收票方开票信息字段二选一必填
|
|
|
+ application.put("clientLegalEntityBizCode",UtilMap.getString(formData,"textField_mkddjwys"));//收票方抬头code,如果不传默认第一个(云票系统内维护的)
|
|
|
|
|
|
-// application.put("submitterBizCode","18857526310");//提交人工号,单据状态为审批中时必填 todo 暂时固定 周漂
|
|
|
-// application.put("applicantBizCode","18857526310");//开票申请人工号 todo 暂时固定 周漂
|
|
|
+ application.put("submitterBizCode","18857526310");//提交人工号,单据状态为审批中时必填 todo 暂时固定 周漂
|
|
|
+ application.put("applicantBizCode","18857526310");//开票申请人工号 todo 暂时固定 周漂
|
|
|
|
|
|
/*Map clientLegalEntityOaDto = new HashMap();//收票方开票信息(不在云票系统内维护的)与收票方bizCode(客户的业务编码)二选一必填且优先级高于收票方bizCode(客户的业务编码)(也就是当两字段都有值时,忽略客户的业务编码)
|
|
|
clientLegalEntityOaDto.put("invoiceTitle",UtilMap.getString(formData,"selectField_mkxmix7e"));//名称
|
|
|
@@ -150,7 +153,7 @@ public class SikuServiceImpl implements SikuService {
|
|
|
|
|
|
application.put("clientLegalEntityOaDto",clientLegalEntityOaDto);*/
|
|
|
|
|
|
- application.put("legalEntityBizCode",UtilMap.getString(formData,"textField_mm2wj87x"));//公司主体code(后续传税号)
|
|
|
+ application.put("legalEntityBizCode",UtilMap.getString(formData,"textField_mn4dhy5g"));//公司主体code(后续传税号)
|
|
|
application.put("estimatedDate",System.currentTimeMillis());//预计开票时间
|
|
|
String fplx = UtilMap.getString(formData, "selectField_mkdnuvem");//发票类型
|
|
|
String estimatedInvoiceType = "";
|
|
|
@@ -168,11 +171,12 @@ public class SikuServiceImpl implements SikuService {
|
|
|
|
|
|
application.put("phoneNumber",UtilMap.getString(formData,"textField_mkdo0azf"));//收票人电话
|
|
|
application.put("email",UtilMap.getString(formData,"textField_mkdo0azn"));//收票邮箱
|
|
|
+ application.put("autoSendMail",true);//是否自动发送邮件/短信,若传true且填写正确的收票邮箱/手机号,则在开票申请单完全开票后自动发邮件/短信。不填写收票邮箱/短信或传false时,将不会自动交付电子发票。
|
|
|
application.put("applicationComment",UtilMap.getString(formData,"textareaField_mkdo0aze"));//开票备注
|
|
|
|
|
|
Map item = new HashMap();
|
|
|
item.put("productBizCode","1001");//产品bizcode
|
|
|
- item.put("invoiceName",UtilMap.getString(formData,"textField_mkgarw4d"));//开票名称
|
|
|
+ item.put("invoiceName",UtilMap.getString(formData,"textField_mn4ajusx"));//开票名称
|
|
|
item.put("taxPercent",UtilMap.getDouble(formData,"numberField_mkgkboht")/100);//税率
|
|
|
item.put("forexName","CNY");//币种
|
|
|
item.put("exchangeRate",1);//外汇汇率
|
|
|
@@ -246,11 +250,12 @@ public class SikuServiceImpl implements SikuService {
|
|
|
} return estimatedInvoiceType;
|
|
|
}
|
|
|
|
|
|
+ @Async
|
|
|
@Override
|
|
|
public void invoiceWriteBack2(Map map) {
|
|
|
//获取发票信息
|
|
|
Map calloutParams = UtilMap.getMap(map, "calloutParams");
|
|
|
- String serviceType = UtilMap.getString(map, "serviceType");
|
|
|
+ String serviceType = UtilMap.getString(calloutParams, "serviceType");
|
|
|
Map bizData = UtilMap.getMap(calloutParams, "bizData");
|
|
|
|
|
|
if ("INVOICE_VAT_INVOICED_NOTIFY_AR".equals(serviceType)){
|
|
|
@@ -264,11 +269,11 @@ public class SikuServiceImpl implements SikuService {
|
|
|
String lsh = UtilMap.getString(documentCorrelates.get(0), "bizCode");//开票申请单编号
|
|
|
|
|
|
//回写宜搭
|
|
|
- Map formData = new HashMap();
|
|
|
- formData.put("radioField_mkxripcc","开票成功");
|
|
|
- formData.put("textField_mkxripc6",invoiceNumber);
|
|
|
- formData.put("textField_mm3aixk0",downloadPageUrl);
|
|
|
- formData.put("textareaField_mmlzqvn0","");
|
|
|
+ Map updateFormData = new HashMap();
|
|
|
+ updateFormData.put("radioField_mkxripcc","开票成功");
|
|
|
+ updateFormData.put("textField_mkxripc6",invoiceNumber);
|
|
|
+ updateFormData.put("textField_mm3aixk0",downloadPageUrl);
|
|
|
+ updateFormData.put("textareaField_mmlzqvn0","");
|
|
|
|
|
|
if (Strings.isNotBlank(pdfUrl)){
|
|
|
String fileName = invoiceNumber + ".pdf";
|
|
|
@@ -284,27 +289,42 @@ public class SikuServiceImpl implements SikuService {
|
|
|
attachmentField.put("previewUrl",previewUri);
|
|
|
attachmentField.put("url",downloadUri);
|
|
|
attachmentField.put("ext","pdf");
|
|
|
- formData.put("attachmentField_mkxripc5",Arrays.asList(attachmentField));
|
|
|
+ updateFormData.put("attachmentField_mkxripc5",Arrays.asList(attachmentField));
|
|
|
}
|
|
|
|
|
|
- ydClient.operateData(YDParam.builder()
|
|
|
+ Map data = ((List<Map>)ydClient.queryData(YDParam.builder()
|
|
|
.formInstanceId(bizCode)
|
|
|
.searchCondition(JSONObject.toJSONString(UtilMap.map("serialNumberField_mknspz75",lsh)))
|
|
|
.formUuid("FORM-A9A47B0365DB437F8F4C8E01B4468220K7GU")
|
|
|
- .formDataJson(JSONObject.toJSONString(formData))
|
|
|
- .build(), YDConf.FORM_OPERATION.upsert);
|
|
|
+ .build(), YDConf.FORM_QUERY.retrieve_list).getData()).get(0);
|
|
|
+
|
|
|
+ String formInstanceId = UtilMap.getString(data, "formInstanceId");
|
|
|
+
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .formInstanceId(formInstanceId)
|
|
|
+ .updateFormDataJson(JSONObject.toJSONString(updateFormData))
|
|
|
+ .build(), YDConf.FORM_OPERATION.update);
|
|
|
|
|
|
}else if ("INVOICE_APPLICATION_VAT_FAIL_NOTIFY_AR".equals(serviceType)){
|
|
|
//开票失败后回调
|
|
|
-
|
|
|
String invoiceErrorMsg = UtilMap.getString(bizData, "invoiceErrorMsg");
|
|
|
|
|
|
String bizCode = UtilMap.getString(bizData, "bizCode");
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ Map data = ((List<Map>)ydClient.queryData(YDParam.builder()
|
|
|
+ .formInstanceId(bizCode)
|
|
|
+ .searchCondition(JSONObject.toJSONString(UtilMap.map("serialNumberField_mknspz75",bizCode)))
|
|
|
+ .formUuid("FORM-A9A47B0365DB437F8F4C8E01B4468220K7GU")
|
|
|
+ .build(), YDConf.FORM_QUERY.retrieve_list).getData()).get(0);
|
|
|
|
|
|
+ String formInstanceId = UtilMap.getString(data, "formInstanceId");
|
|
|
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .formInstanceId(formInstanceId)
|
|
|
+ .updateFormDataJson(JSONObject.toJSONString(UtilMap.map("radioField_mkxripcc, textareaField_mmlzqvn0","开票失败",invoiceErrorMsg)))
|
|
|
+ .build(), YDConf.FORM_OPERATION.update);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -679,13 +699,18 @@ public class SikuServiceImpl implements SikuService {
|
|
|
customerObj.put("contacts",contacts);//联系人列表
|
|
|
|
|
|
List<Map> invoiceTitles = new ArrayList<>();
|
|
|
- Map invoiceTitle = new HashMap();
|
|
|
- invoiceTitle.put("invoiceTitle",UtilMap.getString(formData,"textField_mkddjwyr"));//发票抬头
|
|
|
- invoiceTitle.put("dutyParagraph",UtilMap.getString(formData,"textField_mkddjwys"));//税号
|
|
|
- invoiceTitle.put("bizCode",UtilMap.getString(formData,"textField_mkddjwys"));//业务编码
|
|
|
- invoiceTitle.put("bankBranchName",UtilMap.getString(formData,"textField_mkddjwyt"));//开户行
|
|
|
- invoiceTitle.put("account",UtilMap.getString(formData,"textField_mkddjwyu"));//银行账户
|
|
|
- invoiceTitles.add(invoiceTitle);
|
|
|
+
|
|
|
+ List<Map> invoiceList = UtilMap.getList(formData, "tableField_mn496ozf");
|
|
|
+ for (Map invoice : invoiceList) {
|
|
|
+ Map invoiceTitle = new HashMap();
|
|
|
+ invoiceTitle.put("invoiceTitle",UtilMap.getString(invoice,"textField_mkddjwyr"));//发票抬头
|
|
|
+ invoiceTitle.put("dutyParagraph",UtilMap.getString(invoice,"textField_mkddjwys"));//税号
|
|
|
+ invoiceTitle.put("bizCode",UtilMap.getString(invoice,"textField_mkddjwys"));//业务编码
|
|
|
+ invoiceTitle.put("bankBranchName",UtilMap.getString(invoice,"textField_mkddjwyt"));//开户行
|
|
|
+ invoiceTitle.put("account",UtilMap.getString(invoice,"textField_mkddjwyu"));//银行账户
|
|
|
+ invoiceTitles.add(invoiceTitle);
|
|
|
+ }
|
|
|
+
|
|
|
customerObj.put("invoiceTitles",invoiceTitles);//发票抬头列表
|
|
|
|
|
|
MkYpUtil.saveClient(Arrays.asList(customerObj));
|
|
|
@@ -693,6 +718,7 @@ public class SikuServiceImpl implements SikuService {
|
|
|
return McR.success();
|
|
|
}
|
|
|
|
|
|
+ @Async
|
|
|
@Override
|
|
|
public void invoiceWriteBack(Map map) {
|
|
|
Map calloutParams = UtilMap.getMap(map, "calloutParams");
|
|
|
@@ -740,6 +766,7 @@ public class SikuServiceImpl implements SikuService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Async
|
|
|
@Override
|
|
|
public void invoiceWriteBack3(Map map) {
|
|
|
String formCode = UtilMap.getString(map, "formCode");
|
|
|
@@ -755,7 +782,7 @@ public class SikuServiceImpl implements SikuService {
|
|
|
String[] split = formCode.split("-");
|
|
|
|
|
|
String bh = split[0];//采购需求编号/直接采购单编号
|
|
|
- String uuid = split[1];//子表uuid
|
|
|
+ int index = Integer.parseInt(split[1]);//子表索引
|
|
|
|
|
|
Map formData = UtilMap.getMap(map, "formData");
|
|
|
|
|
|
@@ -778,12 +805,47 @@ public class SikuServiceImpl implements SikuService {
|
|
|
|
|
|
Map ydFormData = UtilMap.getMap(data.get(0), "formData");
|
|
|
|
|
|
- List<Map> detailList = UtilMap.getList(ydFormData, "tableField_mkkmij56");
|
|
|
+ String type = UtilMap.getString(ydFormData, "radioField_mkkmij3b");
|
|
|
|
|
|
- for (Map detail : detailList) {
|
|
|
- if (uuid.equals(UtilMap.getString(detail, "textField_mmvhqm0q"))){
|
|
|
- detail.put("selectField_mmvhqm0p","已付款");
|
|
|
- break;
|
|
|
+ if ("常规需求".equals(type)){
|
|
|
+ List<Map> detailList = UtilMap.getList(ydFormData, "tableField_mkkmij56");
|
|
|
+
|
|
|
+ for (Map detail : detailList) {
|
|
|
+ if (index == UtilMap.getInt(detail, "numberField_mn36ykxx")){
|
|
|
+ Double jscb = UtilMap.getDouble(detail, "numberField_mkkmij5e");//结算成本
|
|
|
+ Double yfkje = UtilMap.getDouble(detail, "numberField_mmvqom6l");//已付款金额
|
|
|
+ String fkzt = UtilMap.getString(detail, "selectField_mmvhqm0p");//付款状态
|
|
|
+ if (yfkje + amt == jscb){
|
|
|
+ detail.put("selectField_mmvhqm0p","全部付款");
|
|
|
+ }else if (yfkje + amt < jscb && yfkje + amt > 0 && !"部分退款".equals(fkzt)){
|
|
|
+ detail.put("selectField_mmvhqm0p","部分付款");
|
|
|
+ }
|
|
|
+
|
|
|
+ detail.put("numberField_mmvqom6l",yfkje + amt);
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ List<Map> detailList = UtilMap.getList(ydFormData, "tableField_mkkmij61");
|
|
|
+
|
|
|
+ for (Map detail : detailList) {
|
|
|
+ if (index == UtilMap.getInt(detail, "numberField_mn36ykxz")){
|
|
|
+
|
|
|
+ Double jscb = UtilMap.getDouble(detail, "numberField_mkkmij6p");//结算成本
|
|
|
+ Double yfkje = UtilMap.getDouble(detail, "numberField_mmvqs9h6");//已付款金额
|
|
|
+ String fkzt = UtilMap.getString(detail, "selectField_mkkmij6a");//付款状态
|
|
|
+
|
|
|
+ if (yfkje + amt == jscb){
|
|
|
+ detail.put("selectField_mkkmij6a","全部付款");
|
|
|
+ }else if (yfkje + amt < jscb && yfkje + amt > 0 && !"部分退款".equals(fkzt)){
|
|
|
+ detail.put("selectField_mkkmij6a","部分付款");
|
|
|
+ }
|
|
|
+
|
|
|
+ detail.put("numberField_mmvqom6l",yfkje + amt);
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -793,7 +855,7 @@ public class SikuServiceImpl implements SikuService {
|
|
|
|
|
|
ydClient.operateData(YDParam.builder()
|
|
|
.formInstanceId(formInstanceId)
|
|
|
- .updateFormDataJson(JSONObject.toJSONString(ydFormData ))
|
|
|
+ .updateFormDataJson(JSONObject.toJSONString(ydFormData))
|
|
|
.build(), YDConf.FORM_OPERATION.update);
|
|
|
}else {
|
|
|
//直接采购结算单
|
|
|
@@ -804,9 +866,59 @@ public class SikuServiceImpl implements SikuService {
|
|
|
|
|
|
String formInstanceId = UtilMap.getString(data.get(0), "formInstanceId");
|
|
|
|
|
|
+ Map ydFormData = UtilMap.getMap(data.get(0), "formData");
|
|
|
+
|
|
|
+ String type = UtilMap.getString(ydFormData, "radioField_mkkmij3b");
|
|
|
+
|
|
|
+ if ("常规采购".equals(type)){
|
|
|
+ List<Map> detailList = UtilMap.getList(ydFormData, "tableField_mkkmij56");
|
|
|
+
|
|
|
+ for (Map detail : detailList) {
|
|
|
+ if (index == UtilMap.getInt(detail, "numberField_mn36ykxx")){
|
|
|
+ Double jscb = UtilMap.getDouble(detail, "numberField_mkkmij5e");//结算成本
|
|
|
+ Double yfkje = UtilMap.getDouble(detail, "numberField_mmvqom6k");//已付款金额
|
|
|
+ String fkzt = UtilMap.getString(detail, "selectField_mmvhtdy0");//付款状态
|
|
|
+ if (yfkje + amt == jscb){
|
|
|
+ detail.put("selectField_mmvhtdy0","全部付款");
|
|
|
+ }else if (yfkje + amt < jscb && yfkje + amt > 0 && !"部分退款".equals(fkzt)){
|
|
|
+ detail.put("selectField_mmvhtdy0","部分付款");
|
|
|
+ }
|
|
|
+
|
|
|
+ detail.put("numberField_mmvqom6k",yfkje + amt);
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ List<Map> detailList = UtilMap.getList(ydFormData, "tableField_mkkmij61");
|
|
|
+
|
|
|
+ for (Map detail : detailList) {
|
|
|
+ if (index == UtilMap.getInt(detail, "numberField_mn36ykxz")){
|
|
|
+
|
|
|
+ Double jscb = UtilMap.getDouble(detail, "numberField_mkkmij6p");//结算成本
|
|
|
+ Double yfkje = UtilMap.getDouble(detail, "numberField_mmvqom6l");//已付款金额
|
|
|
+ String fkzt = UtilMap.getString(detail, "selectField_mkkmij6a");//付款状态
|
|
|
+
|
|
|
+ if (yfkje + amt == jscb){
|
|
|
+ detail.put("selectField_mkkmij6a","全部付款");
|
|
|
+ }else if (yfkje + amt < jscb && yfkje + amt > 0 && !"部分退款".equals(fkzt)){
|
|
|
+ detail.put("selectField_mkkmij6a","部分付款");
|
|
|
+ }
|
|
|
+
|
|
|
+ detail.put("numberField_mmvqom6l",yfkje + amt);
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Double yzf = UtilMap.getDouble(ydFormData, "numberField_mkf2qumf");//已支付
|
|
|
+
|
|
|
+ ydFormData.put("numberField_mkf2qumf",yzf + amt);
|
|
|
+
|
|
|
ydClient.operateData(YDParam.builder()
|
|
|
.formInstanceId(formInstanceId)
|
|
|
- .updateFormDataJson(JSONObject.toJSONString(UtilMap.map("numberField_mkf2qumf",amt)))
|
|
|
+ .updateFormDataJson(JSONObject.toJSONString(ydFormData))
|
|
|
.build(), YDConf.FORM_OPERATION.update);
|
|
|
}
|
|
|
|