Преглед изворни кода

Merge remote-tracking branch 'origin/master'

zt пре 7 месеци
родитељ
комит
ee6603393e

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

@@ -79,8 +79,8 @@ public class InvoiceManageController extends BaseController {
 
     @PostMapping(value = "getByContractId",produces = {"application/json;charset=UTF-8"})
     @ResponseBody
-    public Object getInfoByContract(String id){
-        InvoiceManageDto result = modelService.getInfoByContract(id);
+    public Object getInfoByContract(String id,String invoiceGoodsName,Integer payType){
+        InvoiceManageDto result = modelService.getInfoByContract(id,invoiceGoodsName,payType);
         return result;
     }
 
@@ -98,6 +98,22 @@ public class InvoiceManageController extends BaseController {
         return modelService.getBankTaxRateByFloor(id);
     }
 
+    /**
+     * 查询对应的银行
+     * @param contractId
+     * @param paymentType
+     * @return
+     */
+    @PostMapping(value = "getBankTaxRateByFloor_2",produces = {"application/json;charset=UTF-8"})
+    @ResponseBody
+    public Object getBankTaxRateByFloor(String contractId,String paymentType) {
+        if(!StringUtils.isNotEmpty(contractId)){
+            return AjaxResult.error(503, "参数不能为空");
+        }
+        return modelService.getBankTaxRateByFloor(contractId,paymentType);
+    }
+
+
     @PostMapping(value = "batchListVo",produces = {"application/json;charset=UTF-8"})
     @ResponseBody
     public List<InvoiceManageDto> batchListVo(String invoiceManages){

+ 2 - 0
pro-base/src/main/java/com/idea/invoice/dto/InvoiceManageDto.java

@@ -10,6 +10,8 @@ public class InvoiceManageDto extends InvoiceManage {
 
     private BigDecimal totalPrice;
 
+    private BigDecimal buyerMoney;
+
     private BigDecimal maintenanceTotalPrice;
 
     /**

+ 63 - 9
pro-base/src/main/java/com/idea/invoice/service/InvoiceManageService.java

@@ -2,6 +2,7 @@ package com.idea.invoice.service;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -23,6 +24,8 @@ import com.idea.invoice.mapper.InvoiceManageExtendMapper;
 import com.idea.invoice.mapper.InvoiceManageMapper;
 import com.idea.invoice.model.*;
 import com.idea.invoice.util.InvoiceConstant;
+import com.idea.paymentManagement.model.PayLog;
+import com.idea.paymentManagement.model.PayLogExample;
 import com.idea.paymentManagement.service.PayLogService;
 import com.rockstar.common.base.BaseService;
 import com.rockstar.common.domain.AjaxResult;
@@ -135,11 +138,10 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
         PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
         List<InvoiceManageDto> list = extendMapper.listByModel(model);
         for(InvoiceManageDto invoiceManage : list){
-            BigDecimal totalPrice = invoiceManage.getTotalPrice();
-            BigDecimal maintenanceTotalPrice = invoiceManage.getMaintenanceTotalPrice();
-            String money = payLogService.getMoneyByContractId(invoiceManage.getContractId(), null);
-            invoiceManage.setReceivableMoney(totalPrice.add(maintenanceTotalPrice));
-            invoiceManage.setReceivedMoney(new BigDecimal(money));
+//            String money = payLogService.getMoneyByContractId(invoiceManage.getContractId(), null);
+//            invoiceManage.setReceivedMoney(new BigDecimal(money));
+            // 预收款发票 已收金额
+            invoiceManage.setReceivedMoney(invoiceManage.getInvoiceAmount());
         }
         return new PageInfo<>(list);
     }
@@ -189,7 +191,7 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
             // 房款
             if(invoiceManage.getPaymentType().equals("1")){
                 money = payLogService.getMoneyByContractId(invoiceManage.getContractId(), 1);
-                invoiceManage.setReceivableMoney(invoiceManage.getTotalPrice());
+                invoiceManage.setReceivableMoney(invoiceManage.getBuyerMoney());
             }
             // 专项维修资金
             if(invoiceManage.getPaymentType().equals("2")){
@@ -206,7 +208,7 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
      * @param contractId
      * @return
      */
-    public InvoiceManageDto getInfoByContract(String contractId){
+    public InvoiceManageDto getInfoByContract(String contractId,String invoiceGoodsName,Integer payType){
 
         InvoiceManageDto invoiceManage = new InvoiceManageDto();
         // 合同信息
@@ -225,6 +227,19 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
                 builder.append(item.getName()).append("身份证号:").append(item.getIdentityCard()).append("\n");
             }
         }
+        PayLogExample payLogExample = new PayLogExample();
+        PayLogExample.Criteria criteria = payLogExample.createCriteria();
+        criteria.andContractIdEqualTo(contractId)
+                .andStatusEqualTo(0);
+        if(ObjectUtil.isNotNull(payType)){
+            criteria.andPayTypeEqualTo(payType);
+        }
+        List<PayLog> payLogs = payLogService.selectByExample(payLogExample);
+        BigDecimal money = BigDecimal.ZERO;
+        for(PayLog payLog : payLogs){
+            money = money.add(payLog.getPayMoney());
+        }
+
         invoiceManage.setContractId(contractId);
         invoiceManage.setCustomerManagementId(contract.getCustomerManagementId());
         invoiceManage.setContractNumber(contract.getContractNumber());
@@ -233,10 +248,10 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
         invoiceManage.setInvoiceHeaderNumber(buyer.getIdentityCard());
         // TODO: 2024/10/17 商品编码目前为空 对接接口后调整
         invoiceManage.setInvoiceGoodsCode(InvoiceConstant.INVOICE_GOODS_CODE_ADVANCE_PAYMENT);
-        invoiceManage.setInvoiceGoodsName(room.getDiscName());
+        invoiceManage.setInvoiceGoodsName(invoiceGoodsName + room.getGroupName());
         invoiceManage.setSpecifications(room.getBuildName()+ "-" + room.getRoomNo());
         invoiceManage.setInvoiceCount(new BigDecimal(contract.getActualBuildArea().toString()));
-        invoiceManage.setInvoiceAmount(contract.getBuyerMoney());
+        invoiceManage.setInvoiceAmount(money);
         invoiceManage.setInvoiceTax("0");
         invoiceManage.setRemark(builder.toString());
         return invoiceManage;
@@ -286,6 +301,45 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
         return jsonObject;
     }
 
+    /**
+     *
+     * @param contractId
+     * @param paymentType 1-房款,2-专项维修资金
+     * @return
+     */
+    public JSONObject getBankTaxRateByFloor(String contractId,String paymentType) {
+        JSONObject jsonObject = new JSONObject();
+        String result = "";
+        String dictLabel = sysDictService.getDictLabel("PAYMENT_TYPE", paymentType);
+        InvoiceBankExample example = new InvoiceBankExample();
+        example.createCriteria().andSuitCostTypeLike("%" + dictLabel + "%");
+        List<InvoiceBank> bankList = invoiceBankService.selectByExample(example);
+        if (CollectionUtils.isNotEmpty(bankList)) {
+            ContractManage parkContractManage = contractManageService.selectByPrimaryKey(contractId);
+            ParkRoom parkRoom = parkRoomMapper.selectByPrimaryKey(parkContractManage.getHouseId());
+            if (StringUtils.isNotEmpty(parkRoom.getDiscId())) {
+                for (InvoiceBank invoiceBank : bankList) {
+                    if (StringUtils.isNotEmpty(invoiceBank.getSuitFloor())) {
+                        String[] floors = invoiceBank.getSuitFloor().split(",");
+                        for (String floor : floors) {
+                            if (parkRoom.getDiscId().contains(floor)) {
+                                result = invoiceBank.getBankName() + invoiceBank.getBankBranchName() + invoiceBank.getBankNumber();
+                                jsonObject.put("invoiceSellerBank", result);
+                                // 预收款发票税率默认为0
+                                jsonObject.put("invoiceTax", "0");
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+
+        }
+
+        return jsonObject;
+    }
+
+
     /**
      * 批量开票列表
      * @param invoiceManages

+ 8 - 3
pro-base/src/main/java/com/idea/paymentManagement/service/MaintenanceFundsManagementService.java

@@ -145,13 +145,16 @@ public class MaintenanceFundsManagementService implements BaseService<Maintenanc
         Integer collectionStatus = contractManage.getFundCollectionStatus();
         // 完全收款
         if(collectionStatus == 2){
-            // 查询该合同是否已生成 正式发票
+            // 查询该合同是否已生成 正式发票 且类型是专项维修资金
             InvoiceManageExample invoiceManageExample = new InvoiceManageExample();
-            invoiceManageExample.createCriteria().andTypeEqualTo("2").andContractIdEqualTo(model.getContractId());
+            invoiceManageExample.createCriteria().andTypeEqualTo("2")
+                    .andContractIdEqualTo(model.getContractId())
+                    .andPaymentTypeEqualTo("2");
             List<InvoiceManage> invoiceManages = invoiceManageService.selectByExample(invoiceManageExample);
             if(CollectionUtils.isEmpty(invoiceManages)){
                 // 生成一条待推送的开票信息
-                InvoiceManage invoiceManage = invoiceManageService.getInfoByContract(model.getContractId());
+                InvoiceManage invoiceManage = invoiceManageService.getInfoByContract(model.getContractId(),
+                        "*不动产*&",2);
                 // 正式发票
                 invoiceManage.setType("2");
                 // 专项维修资金
@@ -160,6 +163,8 @@ public class MaintenanceFundsManagementService implements BaseService<Maintenanc
                 invoiceManage.setInvoiceStatus("0");
                 invoiceManage.setInvoiceTax(null);
                 invoiceManage.setRemark(null);
+                invoiceManage.setCreateUser(ShiroUtils.getUserId());
+                invoiceManage.setCreateTime(new Date());
                 invoiceManageService.insertSelective(invoiceManage);
             }
         }

+ 31 - 33
pro-base/src/main/java/com/idea/paymentManagement/service/PayLogService.java

@@ -106,22 +106,22 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
 
     @Override
     public int updateByExample(PayLog PayLog, PayLogExample PayLogExample) {
-        return 0;
+        return modelMapper.updateByExample(PayLog,PayLogExample);
     }
 
     @Override
     public List<PayLog> selectByExample(PayLogExample PayLogExample) {
-        return null;
+        return modelMapper.selectByExample(PayLogExample);
     }
 
     @Override
     public long countByExample(PayLogExample PayLogExample) {
-        return 0;
+        return modelMapper.countByExample(PayLogExample);
     }
 
     @Override
     public int deleteByExample(PayLogExample PayLogExample) {
-        return 0;
+        return modelMapper.deleteByExample(PayLogExample);
     }
 
 
@@ -152,38 +152,36 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
         ContractManage contractManage = contractManageMapper.selectByPrimaryKey(model.getContractId());
         if (model.getPayType() == 1) {
             String receivedMoneyStr = extendMapper.getMoneyByContractId(model.getContractId(), model.getPayType());
-            BigDecimal totalPrice = contractManage.getTotalPrice();
+            BigDecimal buyerMoney = contractManage.getBuyerMoney();
             BigDecimal receivedMoney = new BigDecimal(receivedMoneyStr);
-            if (receivedMoney.doubleValue() < totalPrice.doubleValue()) {
+            if (receivedMoney.doubleValue() < buyerMoney.doubleValue()) {
                 // 部分收款
                 contractManage.setCollectionStatus(1);
             } else {
                 // 全部收款
                 contractManage.setCollectionStatus(2);
 
-                // 查询合同的专项维修基础 收款情况
-                Integer fundCollectionStatus = contractManage.getFundCollectionStatus();
-                // 完全收款
-                if(fundCollectionStatus == 2){
-                    // 查询该合同是否已生成 正式发票
-                    InvoiceManageExample invoiceManageExample = new InvoiceManageExample();
-                    invoiceManageExample.createCriteria().andTypeEqualTo("1").andContractIdEqualTo(model.getContractId());
-                    List<InvoiceManage> invoiceManages = invoiceManageService.selectByExample(invoiceManageExample);
-                    if(CollectionUtils.isEmpty(invoiceManages)){
-                        // 新增待推送的开票信息
-                        InvoiceManageDto invoiceManage = invoiceManageService.getInfoByContract(model.getContractId());
-                        // 正式发票
-                        invoiceManage.setType("2");
-                        // 房款
-                        invoiceManage.setPaymentType("1");
-                        invoiceManage.setSendStatus("0");
-                        invoiceManage.setInvoiceStatus("0");
-                        invoiceManage.setInvoiceTax(null);
-                        invoiceManage.setRemark(null);
-                        invoiceManage.setCreateUser(ShiroUtils.getUserId());
-                        invoiceManage.setCreateTime(new Date());
-                        invoiceManageService.insertSelective(invoiceManage);
-                    }
+                // 查询该合同是否已生成 正式发票
+                InvoiceManageExample invoiceManageExample = new InvoiceManageExample();
+                invoiceManageExample.createCriteria().andTypeEqualTo("1")
+                        .andContractIdEqualTo(model.getContractId())
+                        .andPaymentTypeEqualTo("1");
+                List<InvoiceManage> invoiceManages = invoiceManageService.selectByExample(invoiceManageExample);
+                if(CollectionUtils.isEmpty(invoiceManages)){
+                    // 新增待推送的开票信息
+                    InvoiceManageDto invoiceManage = invoiceManageService.getInfoByContract(model.getContractId(),
+                            "*不动产*&",1);
+                    // 正式发票
+                    invoiceManage.setType("2");
+                    // 房款
+                    invoiceManage.setPaymentType("1");
+                    invoiceManage.setSendStatus("0");
+                    invoiceManage.setInvoiceStatus("0");
+                    invoiceManage.setInvoiceTax(null);
+                    invoiceManage.setRemark(null);
+                    invoiceManage.setCreateUser(ShiroUtils.getUserId());
+                    invoiceManage.setCreateTime(new Date());
+                    invoiceManageService.insertSelective(invoiceManage);
                 }
             }
         }
@@ -265,9 +263,9 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
         BigDecimal arrears = BigDecimal.ZERO;
         // 应收
         BigDecimal receivableMoney = BigDecimal.ZERO;
-        if(ObjectUtil.isNotNull(contractManage.getTotalPrice())){
-            arrears = contractManage.getTotalPrice().subtract(receivedMoney);
-            receivableMoney = contractManage.getTotalPrice();
+        if(ObjectUtil.isNotNull(contractManage.getBuyerMoney())){
+            arrears = contractManage.getBuyerMoney().subtract(receivedMoney);
+            receivableMoney = contractManage.getBuyerMoney();
         }
         payLogDto.setReceivableMoney(receivableMoney);
         payLogDto.setReceivedMoney(receivedMoney);
@@ -278,7 +276,7 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
     public PayLog getByContractId(String contractId, Integer payType) {
 
         PayLogExample payLogExample = new PayLogExample();
-        payLogExample.createCriteria().andContractIdEqualTo(contractId).andPayTypeEqualTo(payType);
+        payLogExample.createCriteria().andContractIdEqualTo(contractId).andPayTypeEqualTo(payType).andStatusEqualTo(0);
         List<PayLog> payLogs = modelMapper.selectByExample(payLogExample);
         return payLogs.get(0);
 

+ 2 - 1
pro-base/src/main/resources/mybatis/invoice/InvoiceManageExtendMapper.xml

@@ -5,7 +5,7 @@
 
   <select id="listByModel" resultType="com.idea.invoice.dto.InvoiceManageDto">
       select i.*,cm.id contractId,cm.contract_number,cm.record_number,cm.buyer_name,cm.house_name,
-             ifnull(cm.total_price,0) total_price,
+             ifnull(cm.buyer_money,0) buyer_money,
              ifnull(cm.maintenance_total_price,0) maintenance_total_price,
              cm.collection_status,cm.fund_collection_status
       from invoice_manage i
@@ -39,6 +39,7 @@
               and i.invoice_date &lt;= #{sendDateTo}
           </if>
       </where>
+      order by i.create_time desc
   </select>
 
 

+ 1 - 0
pro-base/src/main/resources/mybatis/paymentManagement/MaintenanceFundsManagementExtendMapper.xml

@@ -21,6 +21,7 @@
         and maintenance_funds_management.customer_management_id in (select customer_management_id from buyer where name like concat('%',#{buyerName},'%'))
       </if>
     </where>
+    order by created_at desc
   </select>
 
 

+ 5 - 3
pro-base/src/main/resources/mybatis/paymentManagement/PayLogExtendMapper.xml

@@ -16,8 +16,9 @@
   </select>
 
   <select id="listByModel" resultType="com.idea.customerManagement.dto.ContractManageDto">
-    select contract_manage.*, ifnull(sum(pay_log.pay_money),0) receivedMoney,
-           ifnull(contract_manage.total_price - sum(pay_log.pay_money),0) arrears
+    select contract_manage.*,
+           ifnull(sum(pay_log.pay_money),0) receivedMoney,
+           ifnull(contract_manage.buyer_money - sum(pay_log.pay_money),0) arrears
     from contract_manage
     left join pay_log on contract_manage.id = pay_log.contract_id and pay_log.pay_type = #{payType}
     <where>
@@ -32,7 +33,8 @@
         and contract_manage.customer_management_id in (select customer_management_id from buyer where name like concat('%',#{buyerName},'%'))
       </if>
     </where>
-    group by contract_manage.id
+      group by contract_manage.id
+      ORDER BY contract_manage.created_at DESC
   </select>