|
@@ -2,22 +2,41 @@ package com.idea.invoice.service;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
+import com.idea.buildManage.mapper.ParkRoomExtendMapper;
|
|
|
|
+import com.idea.buildManage.mapper.ParkRoomMapper;
|
|
|
|
+import com.idea.buildManage.model.ParkFloorDisc;
|
|
|
|
+import com.idea.buildManage.model.ParkRoom;
|
|
|
|
+import com.idea.buildManage.response.ParkRoomResponse;
|
|
|
|
+import com.idea.customerManagement.dto.ContractManageDto;
|
|
|
|
+import com.idea.customerManagement.model.Buyer;
|
|
|
|
+import com.idea.customerManagement.model.BuyerExample;
|
|
|
|
+import com.idea.customerManagement.model.ContractManage;
|
|
|
|
+import com.idea.customerManagement.service.BuyerService;
|
|
|
|
+import com.idea.customerManagement.service.ContractManageService;
|
|
import com.idea.invoice.dto.InvoiceManageDto;
|
|
import com.idea.invoice.dto.InvoiceManageDto;
|
|
import com.idea.invoice.mapper.InvoiceManageExtendMapper;
|
|
import com.idea.invoice.mapper.InvoiceManageExtendMapper;
|
|
import com.idea.invoice.mapper.InvoiceManageMapper;
|
|
import com.idea.invoice.mapper.InvoiceManageMapper;
|
|
|
|
+import com.idea.invoice.model.InvoiceBank;
|
|
|
|
+import com.idea.invoice.model.InvoiceBankExample;
|
|
import com.idea.invoice.model.InvoiceManage;
|
|
import com.idea.invoice.model.InvoiceManage;
|
|
import com.idea.invoice.model.InvoiceManageExample;
|
|
import com.idea.invoice.model.InvoiceManageExample;
|
|
|
|
+import com.idea.invoice.util.InvoiceConstant;
|
|
import com.idea.paymentManagement.service.PayLogService;
|
|
import com.idea.paymentManagement.service.PayLogService;
|
|
import com.rockstar.common.base.BaseService;
|
|
import com.rockstar.common.base.BaseService;
|
|
import com.rockstar.frame.model.extend.DateTrans;
|
|
import com.rockstar.frame.model.extend.DateTrans;
|
|
import com.rockstar.frame.model.extend.Tablepar;
|
|
import com.rockstar.frame.model.extend.Tablepar;
|
|
import com.rockstar.shiro.util.ShiroUtils;
|
|
import com.rockstar.shiro.util.ShiroUtils;
|
|
|
|
+import com.rockstar.system.service.SysDictService;
|
|
|
|
+import com.rockstar.util.StringUtils;
|
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -30,7 +49,18 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
|
|
private InvoiceManageExtendMapper extendMapper;
|
|
private InvoiceManageExtendMapper extendMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private PayLogService payLogService;
|
|
private PayLogService payLogService;
|
|
-
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ContractManageService contractManageService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private BuyerService buyerService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ParkRoomExtendMapper roomExtendMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ParkRoomMapper parkRoomMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private InvoiceBankService invoiceBankService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysDictService sysDictService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public int deleteByPrimaryKey(String s) {
|
|
public int deleteByPrimaryKey(String s) {
|
|
@@ -105,13 +135,39 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
|
|
return new PageInfo<>(list);
|
|
return new PageInfo<>(list);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 新增预收款发票
|
|
|
|
+ * @param model
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
public int add(InvoiceManageDto model) {
|
|
public int add(InvoiceManageDto model) {
|
|
|
|
|
|
|
|
+ model.setId(IdUtil.simpleUUID());
|
|
|
|
+ model.setInvoiceStatus("0");
|
|
model.setCreateTime(new Date());
|
|
model.setCreateTime(new Date());
|
|
model.setCreateUser(ShiroUtils.getUserId());
|
|
model.setCreateUser(ShiroUtils.getUserId());
|
|
- return insertSelective(model);
|
|
|
|
|
|
+ int result = insertWithoutId(model);
|
|
|
|
+ // 预收款发票 新增后 推送
|
|
|
|
+ if(model.getType().equals("1")){
|
|
|
|
+ sendInvoice(model);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 推送开票
|
|
|
|
+ * @param model
|
|
|
|
+ */
|
|
|
|
+ public void sendInvoice(InvoiceManageDto model){
|
|
|
|
+ model.setSendStatus("1");
|
|
|
|
+ model.setSubmitTime(new Date());
|
|
|
|
+ model.setSubmitUser(ShiroUtils.getUserId());
|
|
|
|
+ updateByPrimaryKeySelective(model);
|
|
|
|
+ // TODO: 2024/10/17 等待接口 推送开票信息
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
public InvoiceManageDto getById(String id) {
|
|
public InvoiceManageDto getById(String id) {
|
|
InvoiceManage invoiceManage = selectByPrimaryKey(id);
|
|
InvoiceManage invoiceManage = selectByPrimaryKey(id);
|
|
InvoiceManageDto result = new InvoiceManageDto();
|
|
InvoiceManageDto result = new InvoiceManageDto();
|
|
@@ -147,6 +203,89 @@ public class InvoiceManageService implements BaseService<InvoiceManage, InvoiceM
|
|
return new PageInfo<>(list);
|
|
return new PageInfo<>(list);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 根据合同id查询
|
|
|
|
+ * @param contractId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public InvoiceManageDto getInfoByContract(String contractId){
|
|
|
|
+
|
|
|
|
+ InvoiceManageDto invoiceManage = new InvoiceManageDto();
|
|
|
|
+ // 合同信息
|
|
|
|
+ ContractManageDto contract = contractManageService.getById(contractId);
|
|
|
|
+ // 买受人信息
|
|
|
|
+ BuyerExample buyerExample = new BuyerExample();
|
|
|
|
+ buyerExample.setOrderByClause("order_num asc");
|
|
|
|
+ buyerExample.createCriteria().andCustomerManagementIdEqualTo(contract.getCustomerManagementId());
|
|
|
|
+ List<Buyer> buyers = buyerService.selectByExample(buyerExample);
|
|
|
|
+ Buyer buyer = buyers.get(0);
|
|
|
|
+ // 房间信息
|
|
|
|
+ ParkRoomResponse room = roomExtendMapper.getFullName(contract.getHouseId());
|
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
|
+ for(Buyer item : buyers){
|
|
|
|
+ if(item.getRelationship() != null){
|
|
|
|
+ builder.append(item.getName()).append("身份证号:").append(item.getIdentityCard()).append("\n");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ invoiceManage.setContractId(contractId);
|
|
|
|
+ invoiceManage.setCustomerManagementId(contract.getCustomerManagementId());
|
|
|
|
+ invoiceManage.setContractNumber(contract.getContractNumber());
|
|
|
|
+ invoiceManage.setRecordNumber(contract.getRecordNumber());
|
|
|
|
+ invoiceManage.setInvoiceHeaderName(buyer.getName());
|
|
|
|
+ invoiceManage.setInvoiceHeaderNumber(buyer.getIdentityCard());
|
|
|
|
+ // TODO: 2024/10/17 商品编码目前为空 对接接口后调整
|
|
|
|
+ invoiceManage.setInvoiceGoodsCode(InvoiceConstant.INVOICE_GOODS_CODE_ADVANCE_PAYMENT);
|
|
|
|
+ invoiceManage.setInvoiceGoodsName(room.getDiscName());
|
|
|
|
+ invoiceManage.setSpecifications(room.getBuildName()+ "-" + room.getRoomNo());
|
|
|
|
+ invoiceManage.setInvoiceCount(new BigDecimal(contract.getActualBuildArea().toString()));
|
|
|
|
+ invoiceManage.setInvoiceAmount(contract.getBuyerMoney());
|
|
|
|
+ invoiceManage.setInvoiceTax("0");
|
|
|
|
+ invoiceManage.setRemark(builder.toString());
|
|
|
|
+ return invoiceManage;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 查询对应的银行
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public JSONObject getBankTaxRateByFloor(String id) {
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ String result = "";
|
|
|
|
+ InvoiceManage invoiceManage = selectByPrimaryKey(id);
|
|
|
|
+ // 1-房款,2-专项维修资金
|
|
|
|
+ String paymentType = invoiceManage.getPaymentType();
|
|
|
|
+ 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(invoiceManage.getContractId());
|
|
|
|
+ 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(",");
|
|
|
|
+ List<String> suitCostTypes = Arrays.asList(invoiceBank.getSuitCostType().split(","));
|
|
|
|
+ List<String> taxRates = Arrays.asList(invoiceBank.getTaxRate().split(","));
|
|
|
|
+ for (String floor : floors) {
|
|
|
|
+ if (parkRoom.getDiscId().contains(floor)) {
|
|
|
|
+ result = invoiceBank.getBankName() + invoiceBank.getBankBranchName() + invoiceBank.getBankNumber();
|
|
|
|
+ jsonObject.put("invoiceSellerBank", result);
|
|
|
|
+ int index = suitCostTypes.indexOf(dictLabel);
|
|
|
|
+ String taxRate = taxRates.get(index);
|
|
|
|
+ jsonObject.put("invoiceTax", taxRate);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return jsonObject;
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|