Browse Source

nc 推送 优化

LAPTOP-FO2T5SIU\35838 5 months ago
parent
commit
d414674912

+ 2 - 0
pro-base/src/main/java/com/idea/invoice/controller/InvoiceManageController.java

@@ -98,6 +98,8 @@ public class InvoiceManageController extends BaseController {
     @PostMapping(value = "add", produces = {"application/json;charset=UTF-8"})
     @ResponseBody
     public AjaxResult add(InvoiceManageDto record) {
+        // 预收款发票
+        record.setType("1");
         int result = modelService.add(record);
         return result(result);
     }

+ 23 - 27
pro-base/src/main/java/com/idea/invoice/service/InvoiceManageService.java

@@ -10,10 +10,9 @@ import com.github.pagehelper.PageInfo;
 import com.idea.buildManage.mapper.ParkInfoMapper;
 import com.idea.buildManage.mapper.ParkRoomExtendMapper;
 import com.idea.buildManage.mapper.ParkRoomMapper;
-import com.idea.buildManage.model.ParkFloorDisc;
-import com.idea.buildManage.model.ParkInfo;
-import com.idea.buildManage.model.ParkRoom;
+import com.idea.buildManage.model.*;
 import com.idea.buildManage.response.ParkRoomResponse;
+import com.idea.buildManage.service.MaterialManageService;
 import com.idea.customerManagement.dto.ContractManageDto;
 import com.idea.customerManagement.mapper.BuyerMapper;
 import com.idea.customerManagement.mapper.CustomerManagementMapper;
@@ -85,6 +84,8 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
     private ParkInfoMapper parkInfoMapper;
     @Autowired
     private BuyerMapper buyerMapper;
+    @Autowired
+    private MaterialManageService materialManageService;
 
 
     @Override
@@ -473,6 +474,11 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
 
         String result = "";
         InvoiceManage newRecord = selectByPrimaryKey(model.getId());
+        // 已推送状态
+        if("1".equals(newRecord.getSendStatus())){
+            throw new RuntimeException("提交失败,开票状态发生变化");
+        }
+
         // 查询客户管理信息
         CustomerManagement customerManagement = customerManagementMapper.selectByPrimaryKey(model.getCustomerManagementId());
         // 查询小区信息
@@ -482,28 +488,18 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
         ParkRoomResponse roomResponse = roomExtendMapper.getFullName(customerManagement.getHouseId());
         // 物料
         String material = "";
-        if (parkInfo.getGroupName().equals("惠景家园")) {
-            switch (model.getInvoiceTax()) {
-                case "0.09":
-                    material = InvoiceConstant.INVOICE_MATERIAL_gycqrjjy;
-                    break;
-                case "0.05":
-                    material = InvoiceConstant.INVOICE_MATERIAL_hjjy;
-                    break;
-                case "0":
-                    material = InvoiceConstant.INVOICE_MATERIAL_hjjylsl;
-                    break;
+        MaterialManageExample materialManageExample = new MaterialManageExample();
+        materialManageExample.createCriteria().andGroupIdEqualTo(customerManagement.getGroupId());
+        List<MaterialManage> materialManages = materialManageService.selectByExample(materialManageExample);
+
+        for(MaterialManage materialManage : materialManages){
+            if(materialManage.getTax().equals(model.getInvoiceTax())){
+                material = materialManage.getMaterial();
             }
         }
-        if (parkInfo.getGroupName().equals("黄石嘉园")) {
-            switch (model.getInvoiceTax()) {
-                case "0.09":
-                    material = InvoiceConstant.INVOICE_MATERIAL_hsjy;
-                    break;
-                case "0":
-                    material = InvoiceConstant.INVOICE_MATERIAL_hsjylsl;
-                    break;
-            }
+
+        if(StringUtils.isEmpty(material)){
+            throw new RuntimeException("未找到匹配的物料,请先设置物料");
         }
 
         String def26 = "江苏省无锡市";
@@ -545,7 +541,7 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
         ar_recbill.put("def24", "0"); //征税方式,必填,默认0
         ar_recbill.put("def26", def26); //不动产地址 必填
         ar_recbill.put("def25", "N"); // 跨地市标志,必填,Y--是;N---否
-        ar_recbill.put("def27", "Y"); // 是否完全收款,非必填,Y--是;N---否
+        ar_recbill.put("def27", def27); // 是否完全收款,非必填,Y--是;N---否
         json.put("ar_recbill", ar_recbill);
 
         JSONArray ar_recitem = new JSONArray();
@@ -564,8 +560,9 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
         ar_recitemJson.put("material", material); //物料
         ar_recitem.add(ar_recitemJson);
         json.put("ar_recitem", ar_recitem);
+        log.info("推送开票传参:{}", json.toJSONString());
         result = InvoiceUtil.recbillAdd(json);
-
+        log.info("推送开票结果:{}", json.toJSONString());
         return result;
 
     }
@@ -581,8 +578,7 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
         // 推送前校验状态
         for (InvoiceManageDto model : list) {
             InvoiceManage invoiceManage = selectByPrimaryKey(model.getId());
-            if (null != invoiceManage && !InvoiceConstant.INVOICE_STATUS_WAIT.equals(invoiceManage.getInvoiceStatus())
-                    && !InvoiceConstant.INVOICE_STATUS_ERROR.equals(invoiceManage.getInvoiceStatus())) {
+            if (null != invoiceManage && "1".equals(invoiceManage.getSendStatus())) {
                 return AjaxResult.error(504, "提交失败,开票状态发生变化");
             }
         }

+ 0 - 5
pro-base/src/main/java/com/idea/invoice/util/InvoiceUtil.java

@@ -230,7 +230,6 @@ public class InvoiceUtil {
         String token = InvoiceUtil.getToken(util);
         util.setApiUrl("nccloud/api/wxyy/arap/paybill/saveandcommit");
 
-        log.info("付款单接口_退款单传参:{}", json.toJSONString());
         String result = util.getAPIRetrun(token, json.toJSONString());
         log.info("付款单接口_退款单:{}", result);
         return result;
@@ -245,9 +244,7 @@ public class InvoiceUtil {
         APICurUtils util = new APICurUtils();
         String token = InvoiceUtil.getToken(util);
         util.setApiUrl("nccloud/api/wxyy/arap/recbill/saveandcommit");
-        log.info("应收接口-收入结转单传参:{}", json.toJSONString());
         String result = util.getAPIRetrun(token, json.toJSONString());
-        log.info("应收接口-收入结转单:{}", result);
         return result;
     }
 
@@ -261,7 +258,6 @@ public class InvoiceUtil {
         APICurUtils util = new APICurUtils();
         String token = InvoiceUtil.getToken(util);
         util.setApiUrl("nccloud/api/wxyy/arap/gatheringbill/saveandcommit");
-        log.info("收款单接口-新增提交传参:{}", json.toJSONString());
         String result = util.getAPIRetrun(token, json.toJSONString());
         log.info("收款单接口-新增提交结果:{}", result);
         return result;
@@ -303,7 +299,6 @@ public class InvoiceUtil {
         APICurUtils util = new APICurUtils();
         String token = InvoiceUtil.getToken(util);
         util.setApiUrl("nccloud/api/wxyy/arap/gatheringbill/saveandcommit");
-        log.info("单据提交——转账单传参:{}", json.toJSONString());
         String result = util.getAPIRetrun(token, json.toJSONString());
         log.info("单据提交——转账单结果:{}", result);
         return result;

+ 8 - 0
pro-base/src/main/java/com/idea/paymentManagement/dto/RefundManageDto.java

@@ -3,6 +3,8 @@ package com.idea.paymentManagement.dto;
 import com.idea.paymentManagement.model.RefundManage;
 import lombok.Data;
 
+import java.util.Date;
+
 @Data
 public class RefundManageDto extends RefundManage {
 
@@ -27,4 +29,10 @@ public class RefundManageDto extends RefundManage {
 
     private String batchNumber;
 
+    private Integer ncSubmitStatus;
+
+    private Date ncSubmitDate;
+
+    private String ncSubmitName;
+
 }

+ 1 - 0
pro-base/src/main/java/com/idea/paymentManagement/service/RefundManageService.java

@@ -182,6 +182,7 @@ public class RefundManageService implements BaseService<RefundManage, RefundMana
             detail.setRefundManageId(id);
             detail.setCreatedId(userId);
             detail.setCreatedAt(date);
+            detail.setNcSubmitStatus(0);
             refundDetailService.insertSelective(detail);
             // 收款记录 更新退款状态
             String[] split = detail.getPayLogId().split(",");

+ 212 - 207
pro-base/src/main/java/com/idea/transactionRecordManage/service/TransactionRecordService.java

@@ -271,115 +271,118 @@ public class TransactionRecordService {
         for (PayLog payLog : payLogs) {
             try {
 
-                if (customerMap.containsKey(payLog.getCustomerManagementId())) {
-                    CustomerManagement customerManagement = customerMap.get(payLog.getCustomerManagementId());
-                    // 项目档案编码
-                    String def10 = "";
-                    if (parkInfoMap.containsKey(customerManagement.getGroupId())) {
-                        def10 = parkInfoMap.get(customerManagement.getGroupId()).getArchiveCode();
-                    }
-                    // 组织机构编码
-                    String pk_org = "";
-                    if (parkInfoMap.containsKey(customerManagement.getGroupId())) {
-                        pk_org = parkInfoMap.get(customerManagement.getGroupId()).getOrganizationalCode();
-                    }
-                    String pk_subjcode = "";
-                    // 定金
-                    if (payLog.getContentType() == 1) {
-                        pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ001;
-                    }
-                    // 首付
-                    if (payLog.getContentType() == 2) {
-                        pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ002;
-                    }
-                    // 银行按揭
-                    if (payLog.getContentType() == 3) {
-                        pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ006;
-                    }
-                    // 专项维修资金
-                    if (payLog.getContentType() == 4) {
-                        pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ015;
-                    }
-                    // 楼款
-                    if (payLog.getContentType() == 5) {
-                        pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ003;
-                    }
-                    // 补差款
-                    if (payLog.getContentType() == 6) {
-                        pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ004;
-                    }
-                    // 意向金
-                    if (payLog.getContentType() == 7) {
-                        pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ026;
-                    }
-
-                    String pk_balatype = "";
-                    // 现金
-                    if (payLog.getPaymentMethod() == 1) {
-                        pk_balatype = InvoiceConstant.INVOICE_PAYMENT_METHOD_0;
-                    }
-                    // 支付宝
-                    if (payLog.getPaymentMethod() == 2) {
-                        pk_balatype = InvoiceConstant.INVOICE_PAYMENT_METHOD_4;
-                    }
-                    // 微信
-                    if (payLog.getPaymentMethod() == 3) {
-                        pk_balatype = InvoiceConstant.INVOICE_PAYMENT_METHOD_4;
-                    }
-                    // 银行卡
-                    if (payLog.getPaymentMethod() == 3) {
-                        pk_balatype = InvoiceConstant.INVOICE_PAYMENT_METHOD_4;
-                    }
-
-
-                    JSONObject json = new JSONObject();
-                    JSONObject ar_gatherbill = new JSONObject();
-                    String srcsystemid = payLog.getId();
-                    String billdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
-                    ar_gatherbill.put("srcsystemid", srcsystemid); //外系统标识,必选
-                    ar_gatherbill.put("pk_tradetype", InvoiceConstant.INVOICE_BUSINESS_F2_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", customerManagement.getBuyerIdentityCard()); //客商的纳税人识别号
-                    ar_gatheritemJson.put("money_cr", payLog.getPayMoney()); //金额,必选
-                    ar_gatheritemJson.put("taxrate", "0"); //税率,必选,数字——3/10/6````
-                    ar_gatheritemJson.put("pk_balatype", pk_balatype); //结算方式,必选,看云文档结算方式
-                    ar_gatheritemJson.put("pk_recpaytype", "001"); //付款业务类型传默认值“001”
-                    ar_gatheritemJson.put("prepay", "1"); //收款性质应收款时传"0",收款性质预收款时传"1"
-                    ar_gatheritemJson.put("recaccount", payLog.getBankNumber()); //收款银行账号,必填
-                    ar_gatheritemJson.put("scomment", customerManagement.getBuyerName()); //客户名称,必选
-                    ar_gatheritemJson.put("pk_subjcode", pk_subjcode); //收款类型
-                    ar_gatheritemJson.put("checktype", InvoiceConstant.INVOICE_RECEIPT_TYPE_3); //票据类型,必选,看云文档票据类型
-                    ar_gatheritemJson.put("checkno", payLog.getSerialNumber()); //票据号,必选
-                    ar_gatheritemJson.put("def9", InvoiceConstant.INVOICE_BUSINESS_FORMAT_001); //业态,必选,看云文档业态
-                    ar_gatheritemJson.put("def11", payLog.getHouseId()); //转出前房号编码,收除了诚意金之外的首期等需要选
-                    ar_gatheritemJson.put("def10", def10); //项目档案编码,看云文档项目档案对照
-                    // TODO: 2024/11/22 银行流水号 待定 暂时不传
+                // 只有未推送或推送失败的才进行推送
+                if(payLog.getNcSubmitStatus() == null || payLog.getNcSubmitStatus() == 0 || payLog.getNcSubmitStatus() == 2) {
+                    if (customerMap.containsKey(payLog.getCustomerManagementId())) {
+                        CustomerManagement customerManagement = customerMap.get(payLog.getCustomerManagementId());
+                        // 项目档案编码
+                        String def10 = "";
+                        if (parkInfoMap.containsKey(customerManagement.getGroupId())) {
+                            def10 = parkInfoMap.get(customerManagement.getGroupId()).getArchiveCode();
+                        }
+                        // 组织机构编码
+                        String pk_org = "";
+                        if (parkInfoMap.containsKey(customerManagement.getGroupId())) {
+                            pk_org = parkInfoMap.get(customerManagement.getGroupId()).getOrganizationalCode();
+                        }
+                        String pk_subjcode = "";
+                        // 定金
+                        if (payLog.getContentType() == 1) {
+                            pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ001;
+                        }
+                        // 首付
+                        if (payLog.getContentType() == 2) {
+                            pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ002;
+                        }
+                        // 银行按揭
+                        if (payLog.getContentType() == 3) {
+                            pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ006;
+                        }
+                        // 专项维修资金
+                        if (payLog.getContentType() == 4) {
+                            pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ015;
+                        }
+                        // 楼款
+                        if (payLog.getContentType() == 5) {
+                            pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ003;
+                        }
+                        // 补差款
+                        if (payLog.getContentType() == 6) {
+                            pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ004;
+                        }
+                        // 意向金
+                        if (payLog.getContentType() == 7) {
+                            pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ026;
+                        }
+
+                        String pk_balatype = "";
+                        // 现金
+                        if (payLog.getPaymentMethod() == 1) {
+                            pk_balatype = InvoiceConstant.INVOICE_PAYMENT_METHOD_0;
+                        }
+                        // 支付宝
+                        if (payLog.getPaymentMethod() == 2) {
+                            pk_balatype = InvoiceConstant.INVOICE_PAYMENT_METHOD_4;
+                        }
+                        // 微信
+                        if (payLog.getPaymentMethod() == 3) {
+                            pk_balatype = InvoiceConstant.INVOICE_PAYMENT_METHOD_4;
+                        }
+                        // 银行卡
+                        if (payLog.getPaymentMethod() == 3) {
+                            pk_balatype = InvoiceConstant.INVOICE_PAYMENT_METHOD_4;
+                        }
+
+
+                        JSONObject json = new JSONObject();
+                        JSONObject ar_gatherbill = new JSONObject();
+                        String srcsystemid = payLog.getId();
+                        String billdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
+                        ar_gatherbill.put("srcsystemid", srcsystemid); //外系统标识,必选
+                        ar_gatherbill.put("pk_tradetype", InvoiceConstant.INVOICE_BUSINESS_F2_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", customerManagement.getBuyerIdentityCard()); //客商的纳税人识别号
+                        ar_gatheritemJson.put("money_cr", payLog.getPayMoney()); //金额,必选
+                        ar_gatheritemJson.put("taxrate", "0"); //税率,必选,数字——3/10/6````
+                        ar_gatheritemJson.put("pk_balatype", pk_balatype); //结算方式,必选,看云文档结算方式
+                        ar_gatheritemJson.put("pk_recpaytype", "001"); //付款业务类型传默认值“001”
+                        ar_gatheritemJson.put("prepay", "1"); //收款性质应收款时传"0",收款性质预收款时传"1"
+                        ar_gatheritemJson.put("recaccount", payLog.getBankNumber()); //收款银行账号,必填
+                        ar_gatheritemJson.put("scomment", customerManagement.getBuyerName()); //客户名称,必选
+                        ar_gatheritemJson.put("pk_subjcode", pk_subjcode); //收款类型
+                        ar_gatheritemJson.put("checktype", InvoiceConstant.INVOICE_RECEIPT_TYPE_3); //票据类型,必选,看云文档票据类型
+                        ar_gatheritemJson.put("checkno", payLog.getSerialNumber()); //票据号,必选
+                        ar_gatheritemJson.put("def9", InvoiceConstant.INVOICE_BUSINESS_FORMAT_001); //业态,必选,看云文档业态
+                        ar_gatheritemJson.put("def11", payLog.getHouseId()); //转出前房号编码,收除了诚意金之外的首期等需要选
+                        ar_gatheritemJson.put("def10", def10); //项目档案编码,看云文档项目档案对照
+                        // TODO: 2024/11/22 银行流水号 待定 暂时不传
 //        ar_gatheritemJson.put("top_billid", pkInformerId); //到账通知生单时,(银行流水中返回的id,见5.2.10到账通知认领查询pk_informer字段)
-                    ar_gatheritem.add(ar_gatheritemJson);
-                    json.put("ar_gatheritem", ar_gatheritem);
+                        ar_gatheritem.add(ar_gatheritemJson);
+                        json.put("ar_gatheritem", ar_gatheritem);
+
+                        log.info("收款凭证推送详情:{}", json.toJSONString());
+
+                        String result = InvoiceUtil.gatheringbillAdd(json);
+                        JSONObject jsonObject = JSONObject.parseObject(result);
+                        if (jsonObject.getString("success").equals("true")) {
+                            payLog.setNcSubmitStatus(1);
+                        } else {
+                            payLog.setNcSubmitStatus(2);
+                        }
+                        payLog.setNcJson(result);
+                        payLog.setNcSubmitDate(new Date());
+                        payLog.setNcSubmitName(ShiroUtils.getUser().getTruename());
+                        payLogMapper.updateByPrimaryKeySelective(payLog);
 
-                    log.info("收款凭证推送详情:{}", json.toJSONString());
-
-                    String result = InvoiceUtil.gatheringbillAdd(json);
-                    JSONObject jsonObject = JSONObject.parseObject(result);
-                    if (jsonObject.getString("success").equals("true")) {
-                        payLog.setNcSubmitStatus(1);
-                    } else {
-                        payLog.setNcSubmitStatus(2);
                     }
-                    payLog.setNcJson(result);
-                    payLog.setNcSubmitDate(new Date());
-                    payLog.setNcSubmitName(ShiroUtils.getUser().getTruename());
-                    payLogMapper.updateByPrimaryKeySelective(payLog);
-
                 }
 
             } catch (Exception e) {
@@ -423,108 +426,110 @@ public class TransactionRecordService {
         List<RefundManageDto> refundManages = modelMapper.refundListByIds(model);
         for (RefundManageDto refundManage : refundManages) {
             try {
-                if (customerMap.containsKey(refundManage.getCustomerManagementId())) {
-                    CustomerManagement customerManagement = customerMap.get(refundManage.getCustomerManagementId());
-
-                    String billdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
-                    // 项目档案编码
-                    String def10 = "";
-                    if (parkInfoMap.containsKey(customerManagement.getGroupId())) {
-                        def10 = parkInfoMap.get(customerManagement.getGroupId()).getArchiveCode();
-                    }
-                    // 组织机构编码
-                    String pk_org = "";
-                    if (parkInfoMap.containsKey(customerManagement.getGroupId())) {
-                        pk_org = parkInfoMap.get(customerManagement.getGroupId()).getOrganizationalCode();
-                    }
-                    String pk_subjcode = "";
-                    // 定金
-                    if (refundManage.getContentType() == 1) {
-                        pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ001;
-                    }
-                    // 首付
-                    if (refundManage.getContentType() == 2) {
-                        pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ002;
-                    }
-                    // 银行按揭
-                    if (refundManage.getContentType() == 3) {
-                        pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ006;
-                    }
-                    // 专项维修资金
-                    if (refundManage.getContentType() == 4) {
-                        pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ015;
-                    }
-                    // 楼款
-                    if (refundManage.getContentType() == 5) {
-                        pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ003;
+                // 只有未推送或推送失败的退款记录才推送
+                if(refundManage.getNcSubmitStatus() == null || refundManage.getNcSubmitStatus() == 0 || refundManage.getNcSubmitStatus() == 2){
+                    if (customerMap.containsKey(refundManage.getCustomerManagementId())) {
+                        CustomerManagement customerManagement = customerMap.get(refundManage.getCustomerManagementId());
+
+                        String billdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
+                        // 项目档案编码
+                        String def10 = "";
+                        if (parkInfoMap.containsKey(customerManagement.getGroupId())) {
+                            def10 = parkInfoMap.get(customerManagement.getGroupId()).getArchiveCode();
+                        }
+                        // 组织机构编码
+                        String pk_org = "";
+                        if (parkInfoMap.containsKey(customerManagement.getGroupId())) {
+                            pk_org = parkInfoMap.get(customerManagement.getGroupId()).getOrganizationalCode();
+                        }
+                        String pk_subjcode = "";
+                        // 定金
+                        if (refundManage.getContentType() == 1) {
+                            pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ001;
+                        }
+                        // 首付
+                        if (refundManage.getContentType() == 2) {
+                            pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ002;
+                        }
+                        // 银行按揭
+                        if (refundManage.getContentType() == 3) {
+                            pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ006;
+                        }
+                        // 专项维修资金
+                        if (refundManage.getContentType() == 4) {
+                            pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ015;
+                        }
+                        // 楼款
+                        if (refundManage.getContentType() == 5) {
+                            pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ003;
+                        }
+                        // 补差款
+                        if (refundManage.getContentType() == 6) {
+                            pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ004;
+                        }
+                        // 意向金
+                        if (refundManage.getContentType() == 7) {
+                            pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ026;
+                        }
+
+                        String checktype = InvoiceConstant.INVOICE_RECEIPT_TYPE_3;
+                        // 如对应项目的客户,未开预收款发票的退款,则为收据;开了预收款发票则为发票
+                        if (map.containsKey(refundManage.getCustomerManagementId())) {
+                            checktype = InvoiceConstant.INVOICE_RECEIPT_TYPE_2;
+                        }
+
+
+                        JSONObject json = new JSONObject();
+                        JSONObject ap_paybill = new JSONObject();
+                        String srcsystemid = IdUtil.simpleUUID();
+                        ap_paybill.put("srcsystemid", srcsystemid); //外系统标识,必选
+                        ap_paybill.put("pk_tradetype", InvoiceConstant.INVOICE_BUSINESS_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", customerManagement.getBuyerName()); //客户名称,必选
+                        ap_payitemJson.put("pk_subjcode", pk_subjcode); //收支项目编码,必选
+                        ap_payitemJson.put("objtype", "0"); //0=客户,1=供应商--判断customer和supplier是否必填,必选
+                        ap_payitemJson.put("customer", customerManagement.getBuyerIdentityCard()); //客商的纳税人识别号
+                        ap_payitemJson.put("money_de", refundManage.getActualRefundAmount()); //金额,必选
+                        ap_payitemJson.put("taxrate", "0"); //税率,必选,无税传0
+                        ap_payitemJson.put("pk_balatype", "4"); //结算方式,必选,默认是4
+                        ap_payitemJson.put("pk_recpaytype", "001"); //付款业务类型传默认值“001”
+                        ap_payitemJson.put("prepay", "0"); //默认值0
+                        ap_payitemJson.put("payaccount", refundManage.getBankNumber()); //付款银行账号,必选
+                        ap_payitemJson.put("checktype", checktype); //票据类型,必选,看云文档票据类型
+                        // TODO: 2024/11/22 退款的记录 是汇合的多笔的 票据号待定
+                        ap_payitemJson.put("checkno", IdUtil.simpleUUID()); //票据号,必选
+                        ap_payitemJson.put("def11", refundManage.getHouseId()); //转出前房号编码,必选
+                        ap_payitemJson.put("def9", "001"); //业态,必选,看云文档业态
+                        ap_payitemJson.put("def10", def10); //项目档案编码,看云文档项目档案对照
+                        ap_payitem.add(ap_payitemJson);
+                        json.put("ap_payitem", ap_payitem);
+
+                        log.info("退款凭证推送详情:{}", json.toJSONString());
+
+                        RefundDetail detail = new RefundDetail();
+                        detail.setId(refundManage.getRefundDetailId());
+
+                        String result = InvoiceUtil.paybillAdd(json);
+                        JSONObject jsonObject = JSONObject.parseObject(result);
+
+                        if (jsonObject.getString("success").equals("true")) {
+                            detail.setNcSubmitStatus(1);
+                        } else {
+                            detail.setNcSubmitStatus(2);
+                        }
+                        detail.setNcJson(result);
+                        detail.setNcSubmitDate(new Date());
+                        detail.setNcSubmitName(ShiroUtils.getUser().getTruename());
+                        refundDetailMapper.updateByPrimaryKeySelective(detail);
                     }
-                    // 补差款
-                    if (refundManage.getContentType() == 6) {
-                        pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ004;
-                    }
-                    // 意向金
-                    if (refundManage.getContentType() == 7) {
-                        pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ026;
-                    }
-
-                    String checktype = InvoiceConstant.INVOICE_RECEIPT_TYPE_3;
-                    // 如对应项目的客户,未开预收款发票的退款,则为收据;开了预收款发票则为发票
-                    if (map.containsKey(refundManage.getCustomerManagementId())) {
-                        checktype = InvoiceConstant.INVOICE_RECEIPT_TYPE_2;
-                    }
-
-
-                    JSONObject json = new JSONObject();
-                    JSONObject ap_paybill = new JSONObject();
-                    String srcsystemid = IdUtil.simpleUUID();
-                    ap_paybill.put("srcsystemid", srcsystemid); //外系统标识,必选
-                    ap_paybill.put("pk_tradetype", InvoiceConstant.INVOICE_BUSINESS_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", customerManagement.getBuyerName()); //客户名称,必选
-                    ap_payitemJson.put("pk_subjcode", pk_subjcode); //收支项目编码,必选
-                    ap_payitemJson.put("objtype", "0"); //0=客户,1=供应商--判断customer和supplier是否必填,必选
-                    ap_payitemJson.put("customer", customerManagement.getBuyerIdentityCard()); //客商的纳税人识别号
-                    ap_payitemJson.put("money_de", refundManage.getActualRefundAmount()); //金额,必选
-                    ap_payitemJson.put("taxrate", "0"); //税率,必选,无税传0
-                    ap_payitemJson.put("pk_balatype", "4"); //结算方式,必选,默认是4
-                    ap_payitemJson.put("pk_recpaytype", "001"); //付款业务类型传默认值“001”
-                    ap_payitemJson.put("prepay", "0"); //默认值0
-                    ap_payitemJson.put("payaccount", refundManage.getBankNumber()); //付款银行账号,必选
-                    ap_payitemJson.put("checktype", checktype); //票据类型,必选,看云文档票据类型
-                    // TODO: 2024/11/22 退款的记录 是汇合的多笔的 票据号待定
-                    ap_payitemJson.put("checkno", IdUtil.simpleUUID()); //票据号,必选
-                    ap_payitemJson.put("def11", refundManage.getHouseId()); //转出前房号编码,必选
-                    ap_payitemJson.put("def9", "001"); //业态,必选,看云文档业态
-                    ap_payitemJson.put("def10", def10); //项目档案编码,看云文档项目档案对照
-                    ap_payitem.add(ap_payitemJson);
-                    json.put("ap_payitem", ap_payitem);
-
-                    log.info("退款凭证推送详情:{}", json.toJSONString());
-
-                    RefundDetail detail = new RefundDetail();
-                    detail.setId(refundManage.getRefundDetailId());
-
-                    String result = InvoiceUtil.paybillAdd(json);
-                    JSONObject jsonObject = JSONObject.parseObject(result);
-
-                    if (jsonObject.getString("success").equals("true")) {
-                        detail.setNcSubmitStatus(1);
-                    } else {
-                        detail.setNcSubmitStatus(2);
-                    }
-                    detail.setNcJson(result);
-                    detail.setNcSubmitDate(new Date());
-                    detail.setNcSubmitName(ShiroUtils.getUser().getTruename());
-                    refundDetailMapper.updateByPrimaryKeySelective(detail);
                 }
-
             } catch (Exception e) {
                 log.error("退款凭证推送报错", e);
             }
@@ -560,7 +565,7 @@ public class TransactionRecordService {
         List<NccRecordVo> list = modelMapper.convertRecord(model);
         for (NccRecordVo record : list) {
             // 剔除已提交的记录
-            if (record.getNcSubmitStatus() != 1) {
+            if (record.getNcSubmitStatus() == null || record.getNcSubmitStatus() == 0 || record.getNcSubmitStatus() == 2) {
                 convertRecordSubmitInfo(record,customerMap,parkInfoMap);
             }
         }

+ 10 - 7
pro-base/src/main/resources/mybatis/transactionRecord/TransactionRecord.xml

@@ -98,7 +98,7 @@
     <select id="refundListByIds" resultType="com.idea.paymentManagement.dto.RefundManageDto">
         SELECT
             d.*,
-            ifnull(d.nc_submit_status,0) as nc_submit_status,
+            d.id refundDetailId,
             d.actual_refund_amount money,
             r.customer_management_id,
             r.house_id,
@@ -111,12 +111,15 @@
                 LEFT JOIN refund_manage r ON d.refund_manage_id = r.id
                 LEFT JOIN frame_user u on u.id = d.created_id
                 LEFT JOIN park_room pr on pr.id = r.house_id
-        <if test="idList != null">
-            AND d.id in
-            <foreach collection="idList" open="(" close=")" separator="," item="item">
-                #{item}
-            </foreach>
-        </if>
+        <where>
+            <if test="idList != null">
+                AND d.id in
+                <foreach collection="idList" open="(" close=")" separator="," item="item">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+
     </select>
 
     <select id="convertRecord" resultType="com.idea.transactionRecordManage.vo.NccRecordVo">