|
|
@@ -1,20 +1,43 @@
|
|
|
package com.idea.transactionRecordManage.service;
|
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.idea.buildManage.response.ParkRoomResponse;
|
|
|
+import com.idea.customerManagement.mapper.CustomerManagementMapper;
|
|
|
+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.util.InvoiceConstant;
|
|
|
+import com.idea.invoice.util.InvoiceUtil;
|
|
|
+import com.idea.paymentManagement.dto.RefundManageDto;
|
|
|
+import com.idea.paymentManagement.mapper.PayLogMapper;
|
|
|
+import com.idea.paymentManagement.mapper.RefundDetailMapper;
|
|
|
+import com.idea.paymentManagement.model.PayLog;
|
|
|
+import com.idea.paymentManagement.model.RefundDetail;
|
|
|
+import com.idea.paymentManagement.service.PayLogService;
|
|
|
import com.idea.transactionRecordManage.mapper.TransactionRecordMapper;
|
|
|
import com.idea.transactionRecordManage.vo.NccRecordVo;
|
|
|
+import com.idea.util.DateUtils;
|
|
|
+import com.rockstar.common.domain.AjaxResult;
|
|
|
import com.rockstar.frame.model.extend.Tablepar;
|
|
|
+import com.rockstar.shiro.util.ShiroUtils;
|
|
|
import com.rockstar.system.service.SysDictService;
|
|
|
+import com.rockstar.util.SnowflakeIdWorker;
|
|
|
import com.rockstar.util.StringUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
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;
|
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class TransactionRecordService {
|
|
|
|
|
|
@@ -22,6 +45,14 @@ public class TransactionRecordService {
|
|
|
private TransactionRecordMapper modelMapper;
|
|
|
@Autowired
|
|
|
private SysDictService sysDictService;
|
|
|
+ @Autowired
|
|
|
+ private CustomerManagementMapper customerManagementMapper;
|
|
|
+ @Autowired
|
|
|
+ private BuyerService buyerService;
|
|
|
+ @Autowired
|
|
|
+ private PayLogMapper payLogMapper;
|
|
|
+ @Autowired
|
|
|
+ private RefundDetailMapper refundDetailMapper;
|
|
|
|
|
|
/**
|
|
|
* 收款记录
|
|
|
@@ -64,4 +95,267 @@ public class TransactionRecordService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 退款记录
|
|
|
+ * @param tablepar
|
|
|
+ * @param model
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public PageInfo<NccRecordVo> refundRecord(Tablepar tablepar, NccRecordVo model) {
|
|
|
+
|
|
|
+ List<Map<String, String>> contentType = sysDictService.selectDictList("CONTENT_TYPE");
|
|
|
+ PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
|
|
|
+ if(StringUtils.isNotEmpty(model.getDiscIds())){
|
|
|
+ List<String> list = Arrays.asList(model.getDiscIds().split(","));
|
|
|
+ model.setDiscIdList(list);
|
|
|
+ }
|
|
|
+ // 收款记录
|
|
|
+ List<NccRecordVo> list = modelMapper.reFundRecord(model);
|
|
|
+ for (NccRecordVo recordVo : list) {
|
|
|
+ for(Map<String, String> map : contentType){
|
|
|
+ if(recordVo.getContentType().equals(map.get("value"))){
|
|
|
+ recordVo.setContentType(map.get("label"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PageInfo<NccRecordVo> pageInfo = new PageInfo<>(list);
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<NccRecordVo> refundRecordListAll(Tablepar tablepar, NccRecordVo model) {
|
|
|
+
|
|
|
+ List<Map<String, String>> contentType = sysDictService.selectDictList("CONTENT_TYPE");
|
|
|
+ if(StringUtils.isNotEmpty(model.getDiscIds())){
|
|
|
+ List<String> list = Arrays.asList(model.getDiscIds().split(","));
|
|
|
+ model.setDiscIdList(list);
|
|
|
+ }
|
|
|
+ // 收款记录
|
|
|
+ List<NccRecordVo> list = modelMapper.reFundRecord(model);
|
|
|
+ for (NccRecordVo recordVo : list) {
|
|
|
+ for(Map<String, String> map : contentType){
|
|
|
+ if(recordVo.getContentType().equals(map.get("value"))){
|
|
|
+ recordVo.setContentType(map.get("label"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 收款记录 ncc提交
|
|
|
+ * @param collectionDateFrom
|
|
|
+ * @param collectionDateTo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public int collectionRecordSubmit(String collectionDateFrom, String collectionDateTo){
|
|
|
+
|
|
|
+ List<PayLog> payLogs = modelMapper.listByDate(collectionDateFrom, collectionDateTo);
|
|
|
+ for(PayLog payLog : payLogs){
|
|
|
+ CustomerManagement customerManagement = customerManagementMapper.selectByPrimaryKey(payLog.getCustomerManagementId());
|
|
|
+ BuyerExample buyerExample = new BuyerExample();
|
|
|
+ buyerExample.setOrderByClause("order_num");
|
|
|
+ buyerExample.createCriteria().andCustomerManagementIdEqualTo(customerManagement.getId());
|
|
|
+ List<Buyer> buyers = buyerService.selectByExample(buyerExample);
|
|
|
+ Buyer buyer = buyers.get(0);
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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", InvoiceUtil.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是否必填,必选
|
|
|
+ // TODO: 2024/11/19 客商的纳税人识别号 待定
|
|
|
+ ar_gatheritemJson.put("customer", ""); //客商的纳税人识别号
|
|
|
+ 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("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", ""); //转出前房号编码,收除了诚意金之外的首期等需要选
|
|
|
+ // TODO: 2024/11/14 项目档案编码 待定
|
|
|
+ ar_gatheritemJson.put("def10", InvoiceConstant.INVOICE_PROJECT_CODE_mwjyAdk); //项目档案编码,看云文档项目档案对照
|
|
|
+// ar_gatheritemJson.put("top_billid", pkInformerId); //到账通知生单时,(银行流水中返回的id,见5.2.10到账通知认领查询pk_informer字段)
|
|
|
+ ar_gatheritem.add(ar_gatheritemJson);
|
|
|
+ json.put("ar_gatheritem", ar_gatheritem);
|
|
|
+
|
|
|
+ try {
|
|
|
+ String result = InvoiceUtil.gatheringbillAdd(json);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
+ if(jsonObject.getString("success").equals("true")){
|
|
|
+ payLog.setNcJson(result);
|
|
|
+ payLog.setNcSubmitStatus(1);
|
|
|
+ payLog.setNcSubmitDate(new Date());
|
|
|
+ payLog.setNcSubmitName(ShiroUtils.getLoginName());
|
|
|
+ payLogMapper.updateByPrimaryKeySelective(payLog);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("收款凭证推送报错",e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 退款记录推送
|
|
|
+ * @param collectionDateFrom
|
|
|
+ * @param collectionDateTo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public int refundRecordSubmit(String collectionDateFrom, String collectionDateTo) {
|
|
|
+
|
|
|
+ Map<String, String> cusIdMap = buyerService.getCusIdMap();
|
|
|
+
|
|
|
+ List<RefundManageDto> refundManages = modelMapper.refundListByDate(collectionDateFrom, collectionDateTo);
|
|
|
+ for (RefundManageDto refundManage : refundManages){
|
|
|
+ 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 = "";
|
|
|
+ // 定金
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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", InvoiceUtil.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", scomment); //客户名称,必选
|
|
|
+ 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("money_de", refundManage.getActualRefundAmount()); //金额,必选
|
|
|
+ // TODO: 2024/11/19 税率待定
|
|
|
+ ap_payitemJson.put("taxrate", ""); //税率,必选,无税传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", ""); //转出前房号编码,必选
|
|
|
+ ap_payitemJson.put("def9", "001"); //业态,必选,看云文档业态
|
|
|
+ // TODO: 2024/11/19 项目档案 待定
|
|
|
+ ap_payitemJson.put("def10", ""); //项目档案编码,看云文档项目档案对照
|
|
|
+ ap_payitem.add(ap_payitemJson);
|
|
|
+ json.put("ap_payitem", ap_payitem);
|
|
|
+
|
|
|
+ try {
|
|
|
+ String result = InvoiceUtil.paybillAdd(json);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
+ if(jsonObject.getString("success").equals("true")){
|
|
|
+
|
|
|
+ RefundDetail detail = new RefundDetail();
|
|
|
+ detail.setId(refundManage.getRefundDetailId());
|
|
|
+ detail.setNcJson(result);
|
|
|
+ detail.setNcSubmitStatus(1);
|
|
|
+ detail.setNcSubmitDate(new Date());
|
|
|
+ detail.setNcSubmitName(ShiroUtils.getLoginName());
|
|
|
+ refundDetailMapper.updateByPrimaryKeySelective(detail);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("退款凭证推送报错",e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|