|
@@ -13,6 +13,9 @@ import com.idea.customerManagement.model.Buyer;
|
|
|
import com.idea.customerManagement.model.BuyerExample;
|
|
|
import com.idea.customerManagement.model.CustomerManagement;
|
|
|
import com.idea.customerManagement.service.BuyerService;
|
|
|
+import com.idea.invoice.mapper.InvoiceManageMapper;
|
|
|
+import com.idea.invoice.model.InvoiceManage;
|
|
|
+import com.idea.invoice.model.InvoiceManageExample;
|
|
|
import com.idea.invoice.util.InvoiceConstant;
|
|
|
import com.idea.invoice.util.InvoiceUtil;
|
|
|
import com.idea.paymentManagement.dto.RefundManageDto;
|
|
@@ -32,13 +35,12 @@ import com.rockstar.util.MD5Util;
|
|
|
import com.rockstar.util.SnowflakeIdWorker;
|
|
|
import com.rockstar.util.StringUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -58,6 +60,8 @@ public class TransactionRecordService {
|
|
|
private RefundDetailMapper refundDetailMapper;
|
|
|
@Autowired
|
|
|
private IntentionalDepositMapper intentionalDepositMapper;
|
|
|
+ @Autowired
|
|
|
+ private InvoiceManageMapper invoiceManageMapper;
|
|
|
|
|
|
/**
|
|
|
* 收款记录
|
|
@@ -224,6 +228,24 @@ public class TransactionRecordService {
|
|
|
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();
|
|
@@ -240,27 +262,22 @@ public class TransactionRecordService {
|
|
|
JSONObject ar_gatheritemJson = new JSONObject();
|
|
|
ar_gatheritemJson.put("srcsystemid", srcsystemid); //外系统子表标识
|
|
|
ar_gatheritemJson.put("objtype", "0"); //0=客户,1=供应商--判断customer和supplier是否必填,必选
|
|
|
- // TODO: 2024/11/19 客商的纳税人识别号 待定
|
|
|
- ar_gatheritemJson.put("customer", ""); //客商的纳税人识别号
|
|
|
+ ar_gatheritemJson.put("customer", customerManagement.getBuyerIdentityCard()); //客商的纳税人识别号
|
|
|
ar_gatheritemJson.put("money_cr", payLog.getPayMoney()); //金额,必选
|
|
|
- // TODO: 2024/11/19 税率待定
|
|
|
- ar_gatheritemJson.put("taxrate", ""); //税率,必选,数字——3/10/6````
|
|
|
- // TODO: 2024/11/19 结算方式 待定
|
|
|
- ar_gatheritemJson.put("pk_balatype", ""); //结算方式,必选,看云文档结算方式
|
|
|
+ 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("invoiceno","fphm"); //发票号码,非必选
|
|
|
ar_gatheritemJson.put("scomment", buyer.getName()); //客户名称,必选
|
|
|
ar_gatheritemJson.put("pk_subjcode", pk_subjcode); //收款类型
|
|
|
- // TODO: 2024/11/19 票据类型 待定
|
|
|
ar_gatheritemJson.put("checktype", InvoiceConstant.INVOICE_RECEIPT_TYPE_3); //票据类型,必选,看云文档票据类型
|
|
|
ar_gatheritemJson.put("checkno", payLog.getSerialNumber()); //票据号,必选
|
|
|
ar_gatheritemJson.put("def9", InvoiceConstant.INVOICE_BUSINESS_FORMAT_001); //业态,必选,看云文档业态
|
|
|
- // TODO: 2024/11/19 房间户编号? 待定
|
|
|
- ar_gatheritemJson.put("def11", ""); //转出前房号编码,收除了诚意金之外的首期等需要选
|
|
|
+ ar_gatheritemJson.put("def11", payLog.getHouseId()); //转出前房号编码,收除了诚意金之外的首期等需要选
|
|
|
// TODO: 2024/11/14 项目档案编码 待定
|
|
|
- ar_gatheritemJson.put("def10", InvoiceConstant.INVOICE_PROJECT_CODE_mwjyAdk); //项目档案编码,看云文档项目档案对照
|
|
|
+ ar_gatheritemJson.put("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);
|
|
@@ -293,16 +310,19 @@ public class TransactionRecordService {
|
|
|
*/
|
|
|
public int refundRecordSubmit(String collectionDateFrom, String collectionDateTo) {
|
|
|
|
|
|
- Map<String, String> cusIdMap = buyerService.getCusIdMap();
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ InvoiceManageExample invoiceManageExample = new InvoiceManageExample();
|
|
|
+ invoiceManageExample.createCriteria().andTypeEqualTo("1").andInvoiceStatusEqualTo("2");
|
|
|
+ List<InvoiceManage> invoiceManages = invoiceManageMapper.selectByExample(invoiceManageExample);
|
|
|
+ if(CollectionUtils.isNotEmpty(invoiceManages)){
|
|
|
+ map = invoiceManages.stream().collect(Collectors.toMap(InvoiceManage::getCustomerManagementId, InvoiceManage::getId));
|
|
|
+ }
|
|
|
|
|
|
List<RefundManageDto> refundManages = modelMapper.refundListByDate(collectionDateFrom, collectionDateTo);
|
|
|
for (RefundManageDto refundManage : refundManages){
|
|
|
+
|
|
|
+ CustomerManagement customerManagement = customerManagementMapper.selectByPrimaryKey(refundManage.getCustomerManagementId());
|
|
|
String billdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
|
|
|
- String number = SnowflakeIdWorker.getUUID();
|
|
|
- String scomment = "";
|
|
|
- if (cusIdMap.containsKey(refundManage.getCustomerManagementId())){
|
|
|
- scomment = cusIdMap.get(refundManage.getCustomerManagementId());
|
|
|
- }
|
|
|
|
|
|
String pk_subjcode = "";
|
|
|
// 定金
|
|
@@ -334,6 +354,13 @@ public class TransactionRecordService {
|
|
|
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();
|
|
@@ -347,23 +374,21 @@ public class TransactionRecordService {
|
|
|
JSONArray ap_payitem = new JSONArray();
|
|
|
JSONObject ap_payitemJson = new JSONObject();
|
|
|
ap_payitemJson.put("srcsystemid", srcsystemid); //外系统子表标识
|
|
|
- ap_payitemJson.put("scomment", scomment); //客户名称,必选
|
|
|
+ ap_payitemJson.put("scomment", customerManagement.getBuyerName()); //客户名称,必选
|
|
|
ap_payitemJson.put("pk_subjcode", pk_subjcode); //收支项目编码,必选
|
|
|
ap_payitemJson.put("objtype", "0"); //0=客户,1=供应商--判断customer和supplier是否必填,必选
|
|
|
- // TODO: 2024/11/19 纳税人识别号 待定
|
|
|
- ap_payitemJson.put("customer", ""); //客商的纳税人识别号
|
|
|
+ ap_payitemJson.put("customer", customerManagement.getBuyerIdentityCard()); //客商的纳税人识别号
|
|
|
ap_payitemJson.put("money_de", refundManage.getActualRefundAmount()); //金额,必选
|
|
|
- // TODO: 2024/11/19 税率待定
|
|
|
- ap_payitemJson.put("taxrate", ""); //税率,必选,无税传0
|
|
|
+ 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()); //付款银行账号,必选
|
|
|
- // TODO: 2024/11/19 票据类型 待定
|
|
|
- ap_payitemJson.put("checktype", ""); //票据类型,必选,看云文档票据类型
|
|
|
- ap_payitemJson.put("checkno", number); //票据号,必选
|
|
|
- // TODO: 2024/11/19 房间户编号? 待定
|
|
|
- ap_payitemJson.put("def11", ""); //转出前房号编码,必选
|
|
|
+ // TODO: 2024/11/22 安居的退款账号 待定
|
|
|
+ ap_payitemJson.put("payaccount", ""); //付款银行账号,必选
|
|
|
+ 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"); //业态,必选,看云文档业态
|
|
|
// TODO: 2024/11/19 项目档案 待定
|
|
|
ap_payitemJson.put("def10", ""); //项目档案编码,看云文档项目档案对照
|
|
@@ -407,13 +432,30 @@ public class TransactionRecordService {
|
|
|
for (IntentionalDepositDto intentionalDeposit : intentionalDeposits){
|
|
|
String billdate = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
|
|
|
String number = SnowflakeIdWorker.getUUID();
|
|
|
- String scomment = "";
|
|
|
- if (cusIdMap.containsKey(intentionalDeposit.getCustomerManagementId())){
|
|
|
- scomment = cusIdMap.get(intentionalDeposit.getCustomerManagementId());
|
|
|
+
|
|
|
+ CustomerManagement customerManagement = customerManagementMapper.selectByPrimaryKey(intentionalDeposit.getCustomerManagementId());
|
|
|
+
|
|
|
+ // 目前只有意向金转定金
|
|
|
+ String pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ001;
|
|
|
+
|
|
|
+ String pk_balatype = "";
|
|
|
+ // 现金
|
|
|
+ if(intentionalDeposit.getPaymentMethod() == 1){
|
|
|
+ pk_balatype = InvoiceConstant.INVOICE_PAYMENT_METHOD_0;
|
|
|
+ }
|
|
|
+ // 支付宝
|
|
|
+ if(intentionalDeposit.getPaymentMethod() == 2){
|
|
|
+ pk_balatype = InvoiceConstant.INVOICE_PAYMENT_METHOD_4;
|
|
|
+ }
|
|
|
+ // 微信
|
|
|
+ if(intentionalDeposit.getPaymentMethod() == 3){
|
|
|
+ pk_balatype = InvoiceConstant.INVOICE_PAYMENT_METHOD_4;
|
|
|
+ }
|
|
|
+ // 银行卡
|
|
|
+ if(intentionalDeposit.getPaymentMethod() == 3){
|
|
|
+ pk_balatype = InvoiceConstant.INVOICE_PAYMENT_METHOD_4;
|
|
|
}
|
|
|
|
|
|
- // 目前只有意向金
|
|
|
- String pk_subjcode = InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ026;
|
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
JSONObject ar_gatherbill = new JSONObject();
|
|
@@ -429,22 +471,19 @@ public class TransactionRecordService {
|
|
|
JSONObject ar_gatheritemJson = new JSONObject();
|
|
|
ar_gatheritemJson.put("srcsystemid", srcsystemid); //外系统子表标识
|
|
|
ar_gatheritemJson.put("objtype", "0"); //0=客户,1=供应商--判断customer和supplier是否必填,必选
|
|
|
- // TODO: 2024/11/20 客商纳税人识别号 待定
|
|
|
- ar_gatheritemJson.put("customer", ""); //客商的纳税人识别号
|
|
|
+ ar_gatheritemJson.put("customer", customerManagement.getBuyerIdentityCard()); //客商的纳税人识别号
|
|
|
ar_gatheritemJson.put("money_cr", intentionalDeposit.getReceivedAmount()); //金额,必选
|
|
|
// TODO: 2024/11/20 税率 待定
|
|
|
ar_gatheritemJson.put("taxrate", ""); //税率,必选,数字——3/10/6````
|
|
|
- // TODO: 2024/11/20 结算方式 待定
|
|
|
- ar_gatheritemJson.put("pk_balatype", "0"); //结算方式,必选,看云文档结算方式
|
|
|
+ ar_gatheritemJson.put("pk_balatype", pk_balatype); //结算方式,必选,看云文档结算方式
|
|
|
ar_gatheritemJson.put("pk_recpaytype", "001"); //付款业务类型传默认值“001”
|
|
|
ar_gatheritemJson.put("prepay", "0"); //收款性质应收款时传"0",收款性质预收款时传"1"
|
|
|
// TODO: 2024/11/20 意向金暂无收款账号 待定
|
|
|
ar_gatheritemJson.put("recaccount", ""); //收款银行账号,必填
|
|
|
// ar_gatheritemJson.put("invoiceno","fphm"); //发票号码,非必选
|
|
|
- ar_gatheritemJson.put("scomment", scomment); //客户名称,必选
|
|
|
- ar_gatheritemJson.put("pk_subjcode", InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ001); //收支项目编码,必选,看云文档收支项目对照
|
|
|
- // TODO: 2024/11/20 房间户编号待定
|
|
|
- ar_gatheritemJson.put("def11", ""); //转出前房号编码,必选
|
|
|
+ ar_gatheritemJson.put("scomment", customerManagement.getBuyerName()); //客户名称,必选
|
|
|
+ ar_gatheritemJson.put("pk_subjcode", pk_subjcode); //收支项目编码,必选,看云文档收支项目对照
|
|
|
+ ar_gatheritemJson.put("def11", intentionalDeposit.getHouseId()); //转出前房号编码,必选
|
|
|
ar_gatheritemJson.put("def9", InvoiceConstant.INVOICE_BUSINESS_FORMAT_001); //业态,必选,看云文档业态
|
|
|
// ar_gatheritemJson.put("def12", ""); //转出后房号编码,换房业务时要选
|
|
|
ar_gatheritemJson.put("def14", InvoiceConstant.INVOICE_PAYMENT_TYPE_AJ026); //原收支项目编码,定金转违约金项目时 必选
|
|
@@ -453,7 +492,7 @@ public class TransactionRecordService {
|
|
|
ar_gatheritemJson.put("checktype", InvoiceConstant.INVOICE_RECEIPT_TYPE_3); //票据类型,必选,看云文档票据类型
|
|
|
ar_gatheritemJson.put("checkno", intentionalDeposit.getSerialNumber()); //票据号,必选
|
|
|
// TODO: 2024/11/14 具体编码 未定
|
|
|
- ar_gatheritemJson.put("def10", InvoiceConstant.INVOICE_MATERIAL_djjy); //项目档案编码,看云文档项目档案对照
|
|
|
+ ar_gatheritemJson.put("def10", ""); //项目档案编码,看云文档项目档案对照
|
|
|
ar_gatheritem.add(ar_gatheritemJson);
|
|
|
json.put("ar_gatheritem", ar_gatheritem);
|
|
|
|