|
|
|
@ -14,6 +14,9 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service(value = "invoiceDistributeServiceImpl")
|
|
|
|
@ -52,31 +55,89 @@ public class InvoiceDistributeServiceImpl extends BaseService<InvoiceDistributeE
|
|
|
|
|
if (mainData == null) {
|
|
|
|
|
return BaseResult.getFailureMessageEntity("系统错误");
|
|
|
|
|
}
|
|
|
|
|
JSONArray detailArray = businessDataStr.getJSONArray("formson_0700");
|
|
|
|
|
JSONArray formson_0700 = businessDataStr.getJSONArray("formson_0700");
|
|
|
|
|
JSONArray formson_0332 = businessDataStr.getJSONArray("formson_0332");
|
|
|
|
|
|
|
|
|
|
//组装发送数据
|
|
|
|
|
JSONObject sendData = null;
|
|
|
|
|
try {
|
|
|
|
|
sendData = getSendData(mainData, detailArray);
|
|
|
|
|
if (mainData.getString("field0154") != null) {
|
|
|
|
|
if ("-6698829233380899499".equals(mainData.getString("field0154"))) {//是否红冲 否
|
|
|
|
|
sendData = getlzfpsqdsqSendData(mainData, formson_0700, formson_0332); //蓝字发票申请单申请
|
|
|
|
|
}
|
|
|
|
|
if ("-8073674727882144390".equals(mainData.getString("field0154"))) {//是否红冲 是
|
|
|
|
|
if (mainData.getString("field0165") != null) {
|
|
|
|
|
if ("-1414365591115381033".equals(mainData.getString("field0165"))) { //销方
|
|
|
|
|
sendData = gethzxxbsqdsqSendData(mainData, formson_0700, formson_0332);//红字信息表申请单申请
|
|
|
|
|
}
|
|
|
|
|
if ("3075360049544777325".equals(mainData.getString("field0165"))) { //购方
|
|
|
|
|
sendData = gethzfpsqdsqSendData(mainData, formson_0700, formson_0332);//红字发票申请单申请
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
logger.error("推送开票申请失败:组装数据失败:" + e.getMessage());
|
|
|
|
|
return BaseResult.getFailureMessageEntity("推送开票申请失败:组装数据失败");
|
|
|
|
|
}
|
|
|
|
|
if (sendData == null) {
|
|
|
|
|
logger.error("推送开票申请结束,该数据不需要推送");
|
|
|
|
|
return BaseResult.getSuccessMessageEntity("推送开票申请结束,该数据不需要推送");
|
|
|
|
|
}
|
|
|
|
|
//发送数据
|
|
|
|
|
logger.error("推送开票申请推送:" + sendData.toJSONString());
|
|
|
|
|
|
|
|
|
|
String tokenResult = HttpRequest.post(url).
|
|
|
|
|
header("appId", "800051").
|
|
|
|
|
header("apiCode", "8000510012").
|
|
|
|
|
header("publicKey", "ZJYAM2YFEIsIaI1e4wMagkS2Q7SFgGk0RvsPhEES45m/OVFCe7eDIk+3zDUT+v578prj").
|
|
|
|
|
header("secretKey", "lR6+uf94mvNMclAB43oIwmhJSMDzQaViTkfXLeNvmGdpLfbFiUvbgbU+p43zO25Zj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
|
|
|
|
|
String resultData = null;
|
|
|
|
|
if (mainData.getString("field0154") != null) {
|
|
|
|
|
if ("-6698829233380899499".equals(mainData.getString("field0154"))) {//是否红冲 否
|
|
|
|
|
//蓝字发票申请单申请
|
|
|
|
|
resultData = HttpRequest.post(url).
|
|
|
|
|
header("appId", "800060").
|
|
|
|
|
header("apiCode", "8000600000").
|
|
|
|
|
header("publicKey", "ZJYA7f8FzV219otH8zhkReiyyWpXswpbY/+StvC2em0hf59Ce7eDIk+3zDUT+v578prj").
|
|
|
|
|
header("secretKey", "xJ9J1Ev2F0faiJ/nQnCNklskAgtQp3QSm+ihO21uY/H0UADj0tSDPxmIhFfC4v6Fj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
|
|
|
|
|
body(sendData.toJSONString()).
|
|
|
|
|
execute().
|
|
|
|
|
body();
|
|
|
|
|
logger.error("推送开票申请返回:" + tokenResult);
|
|
|
|
|
JSONObject resoutJson = JSONObject.parseObject(tokenResult);
|
|
|
|
|
}
|
|
|
|
|
if ("-8073674727882144390".equals(mainData.getString("field0154"))) {//是否红冲 是
|
|
|
|
|
|
|
|
|
|
if (mainData.getString("field0165") != null) {
|
|
|
|
|
if ("-1414365591115381033".equals(mainData.getString("field0165"))) { //销方
|
|
|
|
|
//红字信息表申请单申请
|
|
|
|
|
resultData = HttpRequest.post(url).
|
|
|
|
|
header("appId", "800060").
|
|
|
|
|
header("apiCode", "8000600001").
|
|
|
|
|
header("publicKey", "ZJYA7f8FzV219otH8zhkReiyyWpXswpbY/+StvC2em0hf59Ce7eDIk+3zDUT+v578prj").
|
|
|
|
|
header("secretKey", "xJ9J1Ev2F0faiJ/nQnCNklskAgtQp3QSm+ihO21uY/H0UADj0tSDPxmIhFfC4v6Fj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
|
|
|
|
|
body(sendData.toJSONString()).
|
|
|
|
|
execute().
|
|
|
|
|
body();
|
|
|
|
|
}
|
|
|
|
|
if ("3075360049544777325".equals(mainData.getString("field0165"))) { //购方
|
|
|
|
|
//红字发票申请单申请
|
|
|
|
|
resultData = HttpRequest.post(url).
|
|
|
|
|
header("appId", "800060").
|
|
|
|
|
header("apiCode", "8000600002").
|
|
|
|
|
header("publicKey", "ZJYA7f8FzV219otH8zhkReiyyWpXswpbY/+StvC2em0hf59Ce7eDIk+3zDUT+v578prj").
|
|
|
|
|
header("secretKey", "xJ9J1Ev2F0faiJ/nQnCNklskAgtQp3QSm+ihO21uY/H0UADj0tSDPxmIhFfC4v6Fj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=").
|
|
|
|
|
body(sendData.toJSONString()).
|
|
|
|
|
execute().
|
|
|
|
|
body();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
logger.error("推送开票申请返回:" + resultData);
|
|
|
|
|
JSONObject resoutJson = JSONObject.parseObject(resultData);
|
|
|
|
|
if (resoutJson.getBoolean("flag")) {
|
|
|
|
|
InvoiceDistributeEntity invoiceDistributeEntity = new InvoiceDistributeEntity();
|
|
|
|
|
invoiceDistributeEntity.setId(mainData.getString("id"));
|
|
|
|
|
invoiceDistributeEntity.setField0206("1");
|
|
|
|
|
invoiceDistributeEntity.setField0215("申请单处理中");
|
|
|
|
|
invoiceDistributeEntity.setDataSourceCode("HT-OA");
|
|
|
|
|
iInvoiceDistributeDao.updataStatus(invoiceDistributeEntity);
|
|
|
|
|
return BaseResult.getSuccessMessageEntity("推送开票申请成功");
|
|
|
|
|
} else {
|
|
|
|
|
return BaseResult.getFailureMessageEntity("推送开票申请失败:" + resoutJson.getString("msg"));
|
|
|
|
@ -85,15 +146,329 @@ public class InvoiceDistributeServiceImpl extends BaseService<InvoiceDistributeE
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param mainData
|
|
|
|
|
* @param detailArray
|
|
|
|
|
* @return com.alibaba.fastjson.JSONObject
|
|
|
|
|
* @param formson_0700
|
|
|
|
|
* @param formson_0332
|
|
|
|
|
* @return JSONObject
|
|
|
|
|
* @Author lvleigang
|
|
|
|
|
* @Description 组装数据
|
|
|
|
|
* @Description 蓝字发票申请单申请 组装数据
|
|
|
|
|
* @Date 6:12 下午 2025/6/27
|
|
|
|
|
**/
|
|
|
|
|
private JSONObject getSendData(JSONObject mainData, JSONArray detailArray) throws ParseException {
|
|
|
|
|
JSONObject sendData = new JSONObject();
|
|
|
|
|
private JSONObject getlzfpsqdsqSendData(JSONObject mainData, JSONArray formson_0700,JSONArray formson_0332) throws ParseException {
|
|
|
|
|
|
|
|
|
|
return sendData;
|
|
|
|
|
JSONObject returnObject = new JSONObject();
|
|
|
|
|
JSONObject parent = new JSONObject();
|
|
|
|
|
JSONArray childrens = new JSONArray();
|
|
|
|
|
parent.put("serialNumber", mainData.getString("id"));
|
|
|
|
|
parent.put("companyCode", "");
|
|
|
|
|
parent.put("sellerTaxNo", mainData.getString("field0163"));
|
|
|
|
|
parent.put("templateId", "MB202504259111885691");
|
|
|
|
|
parent.put("businessNo", mainData.getString("field0117"));
|
|
|
|
|
parent.put("superiorBusinessNo", "");
|
|
|
|
|
parent.put("buyerName", mainData.getString("field0106"));
|
|
|
|
|
parent.put("buyerTaxNo", mainData.getString("field0105"));
|
|
|
|
|
parent.put("buyerAddrPhone", mainData.getOrDefault("field0100","") +" "+ mainData.getOrDefault("field0101",""));
|
|
|
|
|
String buyerBankAccount = (mainData.getString("field0103") == null ? "" : mainData.getString("field0103")).replaceAll(" ", "") + " " + (mainData.getString("field0102") == null ? "" : mainData.getString("field0102")).replaceAll(" ", "");
|
|
|
|
|
parent.put("buyerBankAccount", buyerBankAccount);
|
|
|
|
|
|
|
|
|
|
InvoiceDistributeEntity applyPerson = new InvoiceDistributeEntity();
|
|
|
|
|
applyPerson.setId(mainData.getString("field0115"));
|
|
|
|
|
applyPerson.setDataSourceCode("HT-OA");
|
|
|
|
|
List<InvoiceDistributeEntity> apply_person = iInvoiceDistributeDao.queryOrgerManber(applyPerson);
|
|
|
|
|
if(apply_person != null && apply_person.size() > 0){
|
|
|
|
|
parent.put("applyPerson", apply_person.get(0).getName());
|
|
|
|
|
}
|
|
|
|
|
parent.put("applyEmailNotice", "0");
|
|
|
|
|
parent.put("buyerEmailNotice", "0");
|
|
|
|
|
parent.put("workcode", "");
|
|
|
|
|
parent.put("otherEmail", stringAgg(formson_0700));
|
|
|
|
|
parent.put("buyerContact", "");
|
|
|
|
|
parent.put("buyerMobile", "");
|
|
|
|
|
parent.put("buyerRecvAddress", mainData.getString("field0126"));
|
|
|
|
|
parent.put("applicationRemark", "");
|
|
|
|
|
parent.put("attachments", "");
|
|
|
|
|
parent.put("notifyUrl", "");
|
|
|
|
|
parent.put("specialInvoiceMark", mainData.getString("field0167"));
|
|
|
|
|
parent.put("sellerName", mainData.getString("field0108"));
|
|
|
|
|
parent.put("sellerAddrPhone", "");
|
|
|
|
|
parent.put("sellerBankAccount", "");
|
|
|
|
|
JSONObject extFieldJSONObject = new JSONObject();
|
|
|
|
|
extFieldJSONObject.put("SystemOrg","OA");
|
|
|
|
|
parent.put("extFieldJSONObject",extFieldJSONObject);
|
|
|
|
|
JSONObject extendFieldsObj = new JSONObject();
|
|
|
|
|
extendFieldsObj.put("SystemOrg","OA");
|
|
|
|
|
parent.put("extendFields",extendFieldsObj);
|
|
|
|
|
JSONObject applicationForm = new JSONObject();
|
|
|
|
|
if(mainData.getString("field0109") != null){
|
|
|
|
|
if("-5467259512157286597".equals(mainData.getString("field0109"))){
|
|
|
|
|
applicationForm.put("invoiceType", "10");
|
|
|
|
|
}else if ("8203933372392623007".equals(mainData.getString("field0109"))){
|
|
|
|
|
applicationForm.put("invoiceType", "0");
|
|
|
|
|
}else if ("586969999836335692".equals(mainData.getString("field0109"))){
|
|
|
|
|
applicationForm.put("invoiceType", "21");
|
|
|
|
|
}else if ("-9065195408118165505".equals(mainData.getString("field0109"))){
|
|
|
|
|
applicationForm.put("invoiceType", "22");
|
|
|
|
|
}else {
|
|
|
|
|
applicationForm.put("invoiceType", null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
applicationForm.put("isPerson", "");
|
|
|
|
|
applicationForm.put("levyTaxType", "0");
|
|
|
|
|
applicationForm.put("deduction", "");
|
|
|
|
|
applicationForm.put("remark", mainData.getString("field0092"));
|
|
|
|
|
if (formson_0332 != null && formson_0332.size() > 0) {
|
|
|
|
|
for (int i = 0; i < formson_0332.size(); i++) {
|
|
|
|
|
JSONObject detaildata1 = formson_0332.getJSONObject(i);
|
|
|
|
|
JSONObject details = new JSONObject();
|
|
|
|
|
details.put("itemNo", "");
|
|
|
|
|
details.put("itemName", detaildata1.getString("field0080"));
|
|
|
|
|
details.put("taxCateCode", detaildata1.getString("field0153"));
|
|
|
|
|
details.put("spec", detaildata1.getString("field0083"));
|
|
|
|
|
details.put("unit", detaildata1.getString("field0219"));
|
|
|
|
|
details.put("quantity", detaildata1.getOrDefault("field0122",0));
|
|
|
|
|
details.put("unitPrice", detaildata1.getOrDefault("field0085",0));
|
|
|
|
|
// 如果数量是0,则单价也传0
|
|
|
|
|
if(null == detaildata1.getString("field0122")){
|
|
|
|
|
details.put("unitPrice", null);
|
|
|
|
|
}
|
|
|
|
|
details.put("price", detaildata1.getString("field0087"));
|
|
|
|
|
details.put("taxRate", detaildata1.getString("field0224"));
|
|
|
|
|
details.put("zeroFlag", "");
|
|
|
|
|
details.put("includeTaxTag", "0");
|
|
|
|
|
details.put("detailType", "0");
|
|
|
|
|
details.put("enjoyPreferentialFlag", "0");
|
|
|
|
|
details.put("preferentialPolicyType", "");
|
|
|
|
|
childrens.add(details);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
applicationForm.put("detailList", childrens);
|
|
|
|
|
JSONObject specialIndustryDTO = new JSONObject();
|
|
|
|
|
if ("03".equals(mainData.getString("field0167"))) {
|
|
|
|
|
specialIndustryDTO.put("place", mainData.getString("field0210"));
|
|
|
|
|
specialIndustryDTO.put("placeOfDetail", mainData.getString("field0211"));
|
|
|
|
|
specialIndustryDTO.put("constructionProjectName", mainData.getString("field0212"));
|
|
|
|
|
specialIndustryDTO.put("productNo", mainData.getString("field0186"));
|
|
|
|
|
specialIndustryDTO.put("crossDistinctCityFlag", mainData.getString("field0187"));
|
|
|
|
|
if("是".equals(mainData.getString("field0187"))){
|
|
|
|
|
specialIndustryDTO.put("kqysssxbgglbm", mainData.getString("field0185"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ("06".equals(mainData.getString("field0167"))) {
|
|
|
|
|
specialIndustryDTO.put("place", mainData.getString("field0210"));
|
|
|
|
|
specialIndustryDTO.put("placeOfDetail", mainData.getString("field0211"));
|
|
|
|
|
specialIndustryDTO.put("crossDistinctCityFlag", mainData.getString("field0187"));
|
|
|
|
|
specialIndustryDTO.put("certificateOfTitle", mainData.getString("field0213"));
|
|
|
|
|
specialIndustryDTO.put("areaUnit", mainData.getString("field0214"));
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
if(mainData.getString("field0208") != null){
|
|
|
|
|
specialIndustryDTO.put("startDate", sdf.format(mainData.getDate("field0208")));
|
|
|
|
|
}
|
|
|
|
|
if(mainData.getString("field0209") != null){
|
|
|
|
|
specialIndustryDTO.put("endDate", sdf.format(mainData.getDate("field0209")));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
parent.put("applicationForm", applicationForm);
|
|
|
|
|
parent.put("specialIndustryDTO", specialIndustryDTO);
|
|
|
|
|
returnObject.put("bodys", parent.toJSONString());
|
|
|
|
|
return returnObject;
|
|
|
|
|
}
|
|
|
|
|
public String stringAgg( JSONArray jsonArray) {
|
|
|
|
|
// 防御空输入:若JSONArray为null或空,直接返回空字符串
|
|
|
|
|
if (jsonArray == null || jsonArray.isEmpty()) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
// 遍历JSONArray中的每个JSONObject(对应一条formson_0700数据)
|
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
|
JSONObject jsonObj = jsonArray.getJSONObject(i);
|
|
|
|
|
if (jsonObj == null) {
|
|
|
|
|
continue; // 跳过空对象
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 提取field0217:若字段不存在或为null,视为空值
|
|
|
|
|
String fieldVal = jsonObj.getString("field0217");
|
|
|
|
|
// 过滤无效值(null、纯空格字符串)
|
|
|
|
|
if (fieldVal == null || fieldVal.trim().isEmpty()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 拼接逻辑:非第一个有效值时,先加';'分隔符
|
|
|
|
|
if (sb.length() > 0) {
|
|
|
|
|
sb.append(";");
|
|
|
|
|
}
|
|
|
|
|
sb.append(fieldVal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sb.toString();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* @param mainData
|
|
|
|
|
* @param formson_0700
|
|
|
|
|
* @param formson_0332
|
|
|
|
|
* @return JSONObject
|
|
|
|
|
* @Author lvleigang
|
|
|
|
|
* @Description 红字信息表申请单申请 组装数据
|
|
|
|
|
* @Date 6:12 下午 2025/6/27
|
|
|
|
|
**/
|
|
|
|
|
private JSONObject gethzxxbsqdsqSendData(JSONObject mainData, JSONArray formson_0700,JSONArray formson_0332) throws ParseException {
|
|
|
|
|
JSONObject returnObject = new JSONObject();
|
|
|
|
|
JSONArray childrens = new JSONArray();
|
|
|
|
|
JSONObject parent = new JSONObject();
|
|
|
|
|
parent.put("serialNumber", mainData.getString("id"));
|
|
|
|
|
parent.put("companyCode", "");
|
|
|
|
|
parent.put("sellerTaxNo", mainData.getString("field0163"));
|
|
|
|
|
parent.put("templateId", "MB20250623LJ");
|
|
|
|
|
parent.put("businessNo", mainData.getString("field0117"));
|
|
|
|
|
parent.put("originalSellerName", mainData.getString("field0108"));
|
|
|
|
|
parent.put("originalSellerTaxNo", mainData.getString("field0163"));
|
|
|
|
|
parent.put("buyerName", mainData.getString("field0106"));
|
|
|
|
|
parent.put("buyerTaxNo", mainData.getString("field0105"));
|
|
|
|
|
InvoiceDistributeEntity applyPerson = new InvoiceDistributeEntity();
|
|
|
|
|
applyPerson.setId(mainData.getString("field0115"));
|
|
|
|
|
applyPerson.setDataSourceCode("HT-OA");
|
|
|
|
|
List<InvoiceDistributeEntity> apply_person = iInvoiceDistributeDao.queryOrgerManber(applyPerson);
|
|
|
|
|
if(apply_person != null && apply_person.size() > 0){
|
|
|
|
|
parent.put("applyPerson", apply_person.get(0).getName());
|
|
|
|
|
}
|
|
|
|
|
parent.put("applyEmailNotice", "0");
|
|
|
|
|
parent.put("buyerEmailNotice", "0");
|
|
|
|
|
parent.put("otherEmail", stringAgg(formson_0700));
|
|
|
|
|
parent.put("applicationRemark", "");
|
|
|
|
|
parent.put("attachments", "");
|
|
|
|
|
parent.put("notifyUrl","");
|
|
|
|
|
JSONObject extFieldJSONObject = new JSONObject();
|
|
|
|
|
extFieldJSONObject.put("SystemOrg","OA");
|
|
|
|
|
parent.put("extFieldJSONObject",extFieldJSONObject);
|
|
|
|
|
JSONObject extendFieldsObj = new JSONObject();
|
|
|
|
|
extendFieldsObj.put("SystemOrg","OA");
|
|
|
|
|
parent.put("extendFields",extendFieldsObj);
|
|
|
|
|
JSONArray applicationForm = new JSONArray();
|
|
|
|
|
JSONObject applicationFormJson = new JSONObject();
|
|
|
|
|
if(mainData.getString("field0109") != null){
|
|
|
|
|
if("-5467259512157286597".equals(mainData.getString("field0109"))){
|
|
|
|
|
applicationFormJson.put("invoiceType", "10");
|
|
|
|
|
}else if ("8203933372392623007".equals(mainData.getString("field0109"))){
|
|
|
|
|
applicationFormJson.put("invoiceType", "0");
|
|
|
|
|
}else if ("586969999836335692".equals(mainData.getString("field0109"))){
|
|
|
|
|
applicationFormJson.put("invoiceType", "21");
|
|
|
|
|
}else if ("-9065195408118165505".equals(mainData.getString("field0109"))){
|
|
|
|
|
applicationFormJson.put("invoiceType", "22");
|
|
|
|
|
}else {
|
|
|
|
|
applicationFormJson.put("invoiceType", null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ("-1414365591115381033".equals(mainData.getString("field0165"))) { //销方
|
|
|
|
|
applicationFormJson.put("applicant", "2");
|
|
|
|
|
}
|
|
|
|
|
if ("3075360049544777325".equals(mainData.getString("field0165"))) { //购方
|
|
|
|
|
applicationFormJson.put("applicant", "1");
|
|
|
|
|
}
|
|
|
|
|
applicationFormJson.put("deductionStatus", "");
|
|
|
|
|
applicationFormJson.put("originalInvoiceCode", mainData.getString("field0157"));
|
|
|
|
|
applicationFormJson.put("originalInvoiceNumber", mainData.getString("field0158"));
|
|
|
|
|
applicationFormJson.put("originalInvoiceDate", mainData.getString("field0159"));
|
|
|
|
|
applicationFormJson.put("originalInvoicePrice", mainData.getString("field0160"));
|
|
|
|
|
//3320815801687101195 8075623800107716290 销货退回
|
|
|
|
|
//-8544387146720065507 8075623800107716290 开票有误
|
|
|
|
|
//3435351219724830575 8075623800107716290 服务中止
|
|
|
|
|
//-1893846937353040038 8075623800107716290 销售折让
|
|
|
|
|
if (mainData.getString("field0164") != null) {
|
|
|
|
|
if ("3320815801687101195".equals(mainData.getString("field0164"))) {
|
|
|
|
|
applicationFormJson.put("redFlushReason", "1");
|
|
|
|
|
}else if ("-8544387146720065507".equals(mainData.getString("field0164"))) {
|
|
|
|
|
applicationFormJson.put("redFlushReason", "2");
|
|
|
|
|
}else if ("3435351219724830575".equals(mainData.getString("field0164"))) {
|
|
|
|
|
applicationFormJson.put("redFlushReason", "3");
|
|
|
|
|
}else if ("-1893846937353040038".equals(mainData.getString("field0164"))) {
|
|
|
|
|
applicationFormJson.put("redFlushReason", "4");
|
|
|
|
|
}else {
|
|
|
|
|
applicationFormJson.put("redFlushReason", null);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
applicationFormJson.put("redFlushReason", null);
|
|
|
|
|
}
|
|
|
|
|
applicationFormJson.put("specialInvoiceMark", mainData.getString("field0167"));
|
|
|
|
|
applicationFormJson.put("redFlushType", "0");
|
|
|
|
|
applicationForm.add(applicationFormJson);
|
|
|
|
|
parent.put("applicationForm", applicationForm);
|
|
|
|
|
returnObject.put("bodys", parent.toJSONString());
|
|
|
|
|
return returnObject;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param mainData
|
|
|
|
|
* @param formson_0700
|
|
|
|
|
* @param formson_0332
|
|
|
|
|
* @return JSONObject
|
|
|
|
|
* @Author lvleigang
|
|
|
|
|
* @Description 红字发票申请单申请 组装数据
|
|
|
|
|
* @Date 6:12 下午 2025/6/27
|
|
|
|
|
**/
|
|
|
|
|
private JSONObject gethzfpsqdsqSendData(JSONObject mainData, JSONArray formson_0700,JSONArray formson_0332) throws ParseException {
|
|
|
|
|
com.alibaba.fastjson.JSONObject returnObject = new com.alibaba.fastjson.JSONObject();
|
|
|
|
|
com.alibaba.fastjson.JSONObject parent = new com.alibaba.fastjson.JSONObject();
|
|
|
|
|
parent.put("serialNumber", mainData.getString("id"));
|
|
|
|
|
parent.put("companyCode", "0");
|
|
|
|
|
parent.put("sellerTaxNo", mainData.getString("field0163"));
|
|
|
|
|
parent.put("templateId", "MB20250623F");
|
|
|
|
|
parent.put("businessNo", mainData.getString("field0117"));
|
|
|
|
|
parent.put("originalSuperiorBusinessNo", mainData.getString("field0156"));
|
|
|
|
|
parent.put("buyerName", mainData.getString("field0106"));
|
|
|
|
|
parent.put("buyerTaxNo", mainData.getString("field0105"));
|
|
|
|
|
parent.put("buyerAddrPhone", mainData.getOrDefault("field0100","") +" "+ mainData.getOrDefault("field0101",""));
|
|
|
|
|
String buyerBankAccount = (mainData.getString("field0103") == null ? "" : mainData.getString("field0103")).replaceAll(" ", "") + " " + (mainData.getString("field0102") == null ? "" : mainData.getString("field0102")).replaceAll(" ", "");
|
|
|
|
|
parent.put("buyerBankAccount", buyerBankAccount);
|
|
|
|
|
InvoiceDistributeEntity applyPerson = new InvoiceDistributeEntity();
|
|
|
|
|
applyPerson.setId(mainData.getString("field0115"));
|
|
|
|
|
applyPerson.setDataSourceCode("HT-OA");
|
|
|
|
|
List<InvoiceDistributeEntity> apply_person = iInvoiceDistributeDao.queryOrgerManber(applyPerson);
|
|
|
|
|
if(apply_person != null && apply_person.size() > 0){
|
|
|
|
|
parent.put("applyPerson", apply_person.get(0).getName());
|
|
|
|
|
}
|
|
|
|
|
parent.put("applyEmailNotice", "0");
|
|
|
|
|
parent.put("buyerEmailNotice", "0");
|
|
|
|
|
parent.put("otherEmail", stringAgg(formson_0700));
|
|
|
|
|
parent.put("buyerContact", "");
|
|
|
|
|
parent.put("buyerMobile", "");
|
|
|
|
|
parent.put("buyerRecvAddress", mainData.getString("field0126"));
|
|
|
|
|
parent.put("applicationRemark", "");
|
|
|
|
|
parent.put("attachments", "");
|
|
|
|
|
parent.put("notifyUrl", "");
|
|
|
|
|
parent.put("specialInvoiceMark", mainData.getString("field0167"));
|
|
|
|
|
parent.put("sellerName", mainData.getString("field0108"));
|
|
|
|
|
parent.put("sellerAddrPhone", "");
|
|
|
|
|
parent.put("sellerBankAccount", "");
|
|
|
|
|
com.alibaba.fastjson.JSONObject extFieldJSONObject = new com.alibaba.fastjson.JSONObject();
|
|
|
|
|
extFieldJSONObject.put("SystemOrg","OA");
|
|
|
|
|
parent.put("extFieldJSONObject",extFieldJSONObject);
|
|
|
|
|
com.alibaba.fastjson.JSONObject extendFieldsObj = new com.alibaba.fastjson.JSONObject();
|
|
|
|
|
extendFieldsObj.put("SystemOrg","OA");
|
|
|
|
|
parent.put("extendFields",extendFieldsObj);
|
|
|
|
|
com.alibaba.fastjson.JSONArray applicationForm = new com.alibaba.fastjson.JSONArray();
|
|
|
|
|
com.alibaba.fastjson.JSONObject applicationFormJson = new com.alibaba.fastjson.JSONObject();
|
|
|
|
|
if(mainData.getString("field0109") != null){
|
|
|
|
|
if("-5467259512157286597".equals(mainData.getString("field0109"))){
|
|
|
|
|
applicationFormJson.put("invoiceType", "10");
|
|
|
|
|
}else if ("8203933372392623007".equals(mainData.getString("field0109"))){
|
|
|
|
|
applicationFormJson.put("invoiceType", "0");
|
|
|
|
|
}else if ("586969999836335692".equals(mainData.getString("field0109"))){
|
|
|
|
|
applicationFormJson.put("invoiceType", "21");
|
|
|
|
|
}else if ("-9065195408118165505".equals(mainData.getString("field0109"))){
|
|
|
|
|
applicationFormJson.put("invoiceType", "22");
|
|
|
|
|
}else {
|
|
|
|
|
applicationFormJson.put("invoiceType", null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
applicationFormJson.put("originalInvoiceCode", mainData.getString("field0157"));
|
|
|
|
|
applicationFormJson.put("originalInvoiceNumber", mainData.getString("field0158"));
|
|
|
|
|
applicationFormJson.put("originalInvoiceDate", mainData.getString("field0159"));
|
|
|
|
|
applicationFormJson.put("originalInvoicePrice", mainData.getString("field0160"));
|
|
|
|
|
applicationFormJson.put("originalInvoiceCheckCode", null);
|
|
|
|
|
applicationFormJson.put("redLetterInfoSheetNo", mainData.getString("field0161"));
|
|
|
|
|
applicationFormJson.put("remark", mainData.getString("field0092"));
|
|
|
|
|
applicationForm.add(applicationFormJson);
|
|
|
|
|
parent.put("applicationForm", applicationForm);
|
|
|
|
|
returnObject.put("bodys", parent.toJSONString());
|
|
|
|
|
return returnObject;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|