demand: TMS系统 - 客户账单管理 - 收款明细查询 - 查询/导出细节调整
committer: heyu
This commit is contained in:
parent
576ebe6233
commit
830f42ba06
@ -20,15 +20,18 @@ import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @ClassName EmisSettlePayRecordMapper
|
||||
* @Description <p> 账单收退款记录 Mapper 接口 </p>
|
||||
* @Description
|
||||
* <p>
|
||||
* 账单收退款记录 Mapper 接口
|
||||
* </p>
|
||||
* @author linfso
|
||||
* @date 2024-07-21 13:31:24
|
||||
*/
|
||||
public interface EmisSettlePayRecordMapper extends BaseMapper<EmisSettlePayRecord>
|
||||
{
|
||||
public interface EmisSettlePayRecordMapper extends BaseMapper<EmisSettlePayRecord> {
|
||||
/**
|
||||
* 主键查询
|
||||
* @param id
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public EmisSettlePayRecord selectEmisSettlePayRecordById(Long id);
|
||||
@ -57,7 +60,6 @@ public interface EmisSettlePayRecordMapper extends BaseMapper<EmisSettlePayRecor
|
||||
*/
|
||||
public int checkUnique(EmisSettlePayRecord emisSettlePayRecord);
|
||||
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
@ -139,4 +141,12 @@ public interface EmisSettlePayRecordMapper extends BaseMapper<EmisSettlePayRecor
|
||||
* @return 发票申请备注映射
|
||||
*/
|
||||
List<Map<String, Object>> getInvoiceRemarksByPayIds(@Param("list") List<String> payIds);
|
||||
|
||||
/**
|
||||
* 根据支付ID列表获取账单开票状态
|
||||
*
|
||||
* @param payIds 支付ID列表
|
||||
* @return 账单开票状态映射
|
||||
*/
|
||||
List<Map<String, Object>> getBillOpenStatusByPayIds(@Param("list") List<String> payIds);
|
||||
}
|
||||
|
||||
@ -21,9 +21,9 @@ import java.util.List;
|
||||
public class EmisSettlePayRecordCustomExcelUtil {
|
||||
|
||||
private static final String[] HEADERS = {
|
||||
"交易时间", "收款来源", "收款账户", "支付类型", "缴款客户", "微信昵称", "运单号", "开票状态",
|
||||
"交易时间", "收款来源", "收款账户", "支付类型", "缴款客户", "微信昵称", "运单号",
|
||||
"账单金额", "开票金额", "支付金额", "理赔金额", "折让金额", "抵扣金额", "其他收费",
|
||||
"理赔原因", "折让原因", "抵扣原因", "其他原因", "备注"
|
||||
"理赔原因", "折让原因", "抵扣原因", "其他原因", "开票状态", "备注"
|
||||
};
|
||||
|
||||
private static final int[] COLUMN_WIDTHS = {
|
||||
@ -94,58 +94,57 @@ public class EmisSettlePayRecordCustomExcelUtil {
|
||||
// 运单号
|
||||
createCell(row, 6, data.getBillCodes() != null ? data.getBillCodes() : "", dataStyle);
|
||||
|
||||
// 开票状态
|
||||
// String invoiceStatusDesc = getInvoiceStatusDesc(data.getInvoiceStatus());
|
||||
createCell(row, 7, data.getInvoiceStatus(), dataStyle);
|
||||
|
||||
// 账单金额
|
||||
BigDecimal billAmount = data.getBillAmount() != null ? data.getBillAmount() : BigDecimal.ZERO;
|
||||
createCell(row, 8, billAmount, numberStyle);
|
||||
createCell(row, 7, billAmount, numberStyle);
|
||||
totalBillAmount = totalBillAmount.add(billAmount);
|
||||
|
||||
// 开票金额
|
||||
BigDecimal invoiceAmount = data.getInvoiceAmount() != null ? data.getInvoiceAmount() : BigDecimal.ZERO;
|
||||
createCell(row, 9, invoiceAmount, numberStyle);
|
||||
createCell(row, 8, invoiceAmount, numberStyle);
|
||||
totalInvoiceAmount = totalInvoiceAmount.add(invoiceAmount);
|
||||
|
||||
// 支付金额
|
||||
BigDecimal payMoney = data.getPayMoney() != null ? data.getPayMoney() : BigDecimal.ZERO;
|
||||
createCell(row, 10, payMoney, numberStyle);
|
||||
createCell(row, 9, payMoney, numberStyle);
|
||||
totalPayMoney = totalPayMoney.add(payMoney);
|
||||
|
||||
// 理赔金额
|
||||
BigDecimal satisfyMoney = data.getSatisfyMoney() != null ? data.getSatisfyMoney() : BigDecimal.ZERO;
|
||||
createCell(row, 11, satisfyMoney, numberStyle);
|
||||
createCell(row, 10, satisfyMoney, numberStyle);
|
||||
totalSatisfyMoney = totalSatisfyMoney.add(satisfyMoney);
|
||||
|
||||
// 折让金额
|
||||
BigDecimal allowanceMoney = data.getAllowanceMoney() != null ? data.getAllowanceMoney()
|
||||
: BigDecimal.ZERO;
|
||||
createCell(row, 12, allowanceMoney, numberStyle);
|
||||
createCell(row, 11, allowanceMoney, numberStyle);
|
||||
totalAllowanceMoney = totalAllowanceMoney.add(allowanceMoney);
|
||||
|
||||
// 抵扣金额
|
||||
BigDecimal deductionMoney = data.getDeductionMoney() != null ? data.getDeductionMoney()
|
||||
: BigDecimal.ZERO;
|
||||
createCell(row, 13, deductionMoney, numberStyle);
|
||||
createCell(row, 12, deductionMoney, numberStyle);
|
||||
totalDeductionMoney = totalDeductionMoney.add(deductionMoney);
|
||||
|
||||
// 其他收费
|
||||
BigDecimal otherMoney = data.getOtherMoney() != null ? data.getOtherMoney() : BigDecimal.ZERO;
|
||||
createCell(row, 14, otherMoney, numberStyle);
|
||||
createCell(row, 13, otherMoney, numberStyle);
|
||||
totalOtherMoney = totalOtherMoney.add(otherMoney);
|
||||
|
||||
// 理赔原因
|
||||
createCell(row, 15, data.getSatisfyReason() != null ? data.getSatisfyReason() : "", dataStyle);
|
||||
createCell(row, 14, data.getSatisfyReason() != null ? data.getSatisfyReason() : "", dataStyle);
|
||||
|
||||
// 折让原因
|
||||
createCell(row, 16, data.getAllowanceReason() != null ? data.getAllowanceReason() : "", dataStyle);
|
||||
createCell(row, 15, data.getAllowanceReason() != null ? data.getAllowanceReason() : "", dataStyle);
|
||||
|
||||
// 抵扣原因
|
||||
createCell(row, 17, data.getDeductionReason() != null ? data.getDeductionReason() : "", dataStyle);
|
||||
createCell(row, 16, data.getDeductionReason() != null ? data.getDeductionReason() : "", dataStyle);
|
||||
|
||||
// 其他原因
|
||||
createCell(row, 18, data.getOtherReason() != null ? data.getOtherReason() : "", dataStyle);
|
||||
createCell(row, 17, data.getOtherReason() != null ? data.getOtherReason() : "", dataStyle);
|
||||
|
||||
// 开票状态
|
||||
createCell(row, 18, data.getInvoiceStatus() != null ? data.getInvoiceStatus() : "", dataStyle);
|
||||
|
||||
// 备注
|
||||
createCell(row, 19, data.getRemark() != null ? data.getRemark() : "", dataStyle);
|
||||
@ -208,24 +207,6 @@ public class EmisSettlePayRecordCustomExcelUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取开票状态描述
|
||||
*/
|
||||
private static String getInvoiceStatusDesc(String invoiceStatus) {
|
||||
if (invoiceStatus == null)
|
||||
return "未开票";
|
||||
switch (invoiceStatus) {
|
||||
case "0":
|
||||
return "待开票";
|
||||
case "1":
|
||||
return "已开票";
|
||||
case "2":
|
||||
return "已开票";
|
||||
default:
|
||||
return "未开票";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建表头样式
|
||||
*/
|
||||
@ -365,12 +346,30 @@ public class EmisSettlePayRecordCustomExcelUtil {
|
||||
cell.setCellStyle(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化BigDecimal,去除尾部多余的0,避免科学计数法
|
||||
*/
|
||||
private static BigDecimal formatBigDecimal(BigDecimal value) {
|
||||
if (value == null) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
// 使用stripTrailingZeros()去除尾部0,然后使用toPlainString()避免科学计数法
|
||||
BigDecimal stripped = value.stripTrailingZeros();
|
||||
// 如果scale为负数,说明有尾随0被移除,需要重新构造
|
||||
if (stripped.scale() < 0) {
|
||||
stripped = stripped.setScale(0);
|
||||
}
|
||||
return stripped;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建数字单元格
|
||||
*/
|
||||
private static void createCell(Row row, int columnIndex, BigDecimal value, CellStyle style) {
|
||||
Cell cell = row.createCell(columnIndex);
|
||||
cell.setCellValue(value != null ? value.doubleValue() : 0.0);
|
||||
BigDecimal formattedValue = formatBigDecimal(value);
|
||||
// 使用toPlainString()避免科学计数法,然后转换为double
|
||||
cell.setCellValue(formattedValue.toPlainString());
|
||||
cell.setCellStyle(style);
|
||||
}
|
||||
|
||||
@ -404,13 +403,13 @@ public class EmisSettlePayRecordCustomExcelUtil {
|
||||
sumLabelCell.setCellStyle(labelStyle);
|
||||
|
||||
// 合计金额
|
||||
createCell(sumRow, 8, totalBillAmount, sumStyle);
|
||||
createCell(sumRow, 9, totalInvoiceAmount, sumStyle);
|
||||
createCell(sumRow, 10, totalPayMoney, sumStyle);
|
||||
createCell(sumRow, 11, totalSatisfyMoney, sumStyle);
|
||||
createCell(sumRow, 12, totalAllowanceMoney, sumStyle);
|
||||
createCell(sumRow, 13, totalDeductionMoney, sumStyle);
|
||||
createCell(sumRow, 14, totalOtherMoney, sumStyle);
|
||||
createCell(sumRow, 7, formatBigDecimal(totalBillAmount), sumStyle);
|
||||
createCell(sumRow, 8, formatBigDecimal(totalInvoiceAmount), sumStyle);
|
||||
createCell(sumRow, 9, formatBigDecimal(totalPayMoney), sumStyle);
|
||||
createCell(sumRow, 10, formatBigDecimal(totalSatisfyMoney), sumStyle);
|
||||
createCell(sumRow, 11, formatBigDecimal(totalAllowanceMoney), sumStyle);
|
||||
createCell(sumRow, 12, formatBigDecimal(totalDeductionMoney), sumStyle);
|
||||
createCell(sumRow, 13, formatBigDecimal(totalOtherMoney), sumStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -101,6 +101,11 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
return baseList;
|
||||
}
|
||||
|
||||
// 格式化基础数据中的所有BigDecimal字段
|
||||
for (EmisSettlePayRecord record : baseList) {
|
||||
formatAllBigDecimalFields(record);
|
||||
}
|
||||
|
||||
// 提取支付ID列表
|
||||
List<String> payIds = baseList.stream()
|
||||
.map(EmisSettlePayRecord::getPayId)
|
||||
@ -143,12 +148,21 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
|
||||
// 设置账单金额
|
||||
if (billAmountsMap.containsKey(payId)) {
|
||||
record.setBillAmount((BigDecimal) billAmountsMap.get(payId));
|
||||
BigDecimal billAmount = (BigDecimal) billAmountsMap.get(payId);
|
||||
if (billAmount != null) {
|
||||
record.setBillAmount(formatBigDecimal(billAmount));
|
||||
}
|
||||
}
|
||||
|
||||
// 设置开票金额
|
||||
if (invoiceAmountsMap.containsKey(payId)) {
|
||||
record.setInvoiceAmount((BigDecimal) invoiceAmountsMap.get(payId));
|
||||
BigDecimal invoiceAmount = (BigDecimal) invoiceAmountsMap.get(payId);
|
||||
if (invoiceAmount != null) {
|
||||
record.setInvoiceAmount(formatBigDecimal(invoiceAmount));
|
||||
}
|
||||
} else {
|
||||
// 如果开票金额为空,设置为0
|
||||
record.setInvoiceAmount(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
// 设置开票状态
|
||||
@ -160,6 +174,14 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
if (invoiceRemarksMap.containsKey(payId)) {
|
||||
record.setRemark((String) invoiceRemarksMap.get(payId));
|
||||
}
|
||||
|
||||
// 设置createSite,如果为空则设置为88888
|
||||
if (StringUtils.isBlank(record.getCreateSite())) {
|
||||
record.setCreateSite("88888");
|
||||
}
|
||||
|
||||
// 格式化所有BigDecimal字段,去除多余的0
|
||||
formatAllBigDecimalFields(record);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("并行查询扩展信息时发生异常", e);
|
||||
@ -181,12 +203,21 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
|
||||
// 设置账单金额
|
||||
if (billAmountsMap.containsKey(payId)) {
|
||||
record.setBillAmount((BigDecimal) billAmountsMap.get(payId));
|
||||
BigDecimal billAmount = (BigDecimal) billAmountsMap.get(payId);
|
||||
if (billAmount != null) {
|
||||
record.setBillAmount(formatBigDecimal(billAmount));
|
||||
}
|
||||
}
|
||||
|
||||
// 设置开票金额
|
||||
if (invoiceAmountsMap.containsKey(payId)) {
|
||||
record.setInvoiceAmount((BigDecimal) invoiceAmountsMap.get(payId));
|
||||
BigDecimal invoiceAmount = (BigDecimal) invoiceAmountsMap.get(payId);
|
||||
if (invoiceAmount != null) {
|
||||
record.setInvoiceAmount(formatBigDecimal(invoiceAmount));
|
||||
}
|
||||
} else {
|
||||
// 如果开票金额为空,设置为0
|
||||
record.setInvoiceAmount(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
// 设置开票状态
|
||||
@ -198,12 +229,71 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
if (invoiceRemarksMap.containsKey(payId)) {
|
||||
record.setRemark((String) invoiceRemarksMap.get(payId));
|
||||
}
|
||||
|
||||
// 设置createSite,如果为空则设置为88888
|
||||
if (StringUtils.isBlank(record.getCreateSite())) {
|
||||
record.setCreateSite("88888");
|
||||
}
|
||||
|
||||
// 格式化所有BigDecimal字段,去除多余的0
|
||||
formatAllBigDecimalFields(record);
|
||||
}
|
||||
}
|
||||
|
||||
return baseList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化BigDecimal,去除尾部多余的0,避免科学计数法
|
||||
*/
|
||||
private BigDecimal formatBigDecimal(BigDecimal value) {
|
||||
if (value == null) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
// 使用stripTrailingZeros()去除尾部0,然后使用toPlainString()避免科学计数法
|
||||
BigDecimal stripped = value.stripTrailingZeros();
|
||||
// 如果scale为负数,说明有尾随0被移除,需要重新构造
|
||||
if (stripped.scale() < 0) {
|
||||
stripped = stripped.setScale(0);
|
||||
}
|
||||
return stripped;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化EmisSettlePayRecord中所有BigDecimal字段,去除多余的0
|
||||
*/
|
||||
private void formatAllBigDecimalFields(EmisSettlePayRecord record) {
|
||||
if (record == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 格式化所有BigDecimal字段
|
||||
if (record.getPayMoney() != null) {
|
||||
record.setPayMoney(formatBigDecimal(record.getPayMoney()));
|
||||
}
|
||||
if (record.getRefundMoney() != null) {
|
||||
record.setRefundMoney(formatBigDecimal(record.getRefundMoney()));
|
||||
}
|
||||
if (record.getSatisfyMoney() != null) {
|
||||
record.setSatisfyMoney(formatBigDecimal(record.getSatisfyMoney()));
|
||||
}
|
||||
if (record.getAllowanceMoney() != null) {
|
||||
record.setAllowanceMoney(formatBigDecimal(record.getAllowanceMoney()));
|
||||
}
|
||||
if (record.getDeductionMoney() != null) {
|
||||
record.setDeductionMoney(formatBigDecimal(record.getDeductionMoney()));
|
||||
}
|
||||
if (record.getOtherMoney() != null) {
|
||||
record.setOtherMoney(formatBigDecimal(record.getOtherMoney()));
|
||||
}
|
||||
if (record.getBillAmount() != null) {
|
||||
record.setBillAmount(formatBigDecimal(record.getBillAmount()));
|
||||
}
|
||||
if (record.getInvoiceAmount() != null) {
|
||||
record.setInvoiceAmount(formatBigDecimal(record.getInvoiceAmount()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取运单号映射
|
||||
*/
|
||||
@ -255,12 +345,43 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
private Map<String, Object> getInvoiceStatusMap(List<String> payIds) {
|
||||
List<Map<String, Object>> invoiceStatusList = emisSettlePayRecordMapper.getInvoiceStatusByPayIds(payIds);
|
||||
Map<String, Object> result = new java.util.HashMap<>();
|
||||
|
||||
// 先处理查询到的开票状态
|
||||
for (Map<String, Object> map : invoiceStatusList) {
|
||||
String payId = (String) map.get("pay_id");
|
||||
if (payId != null) {
|
||||
result.put(payId, map.get("status"));
|
||||
}
|
||||
}
|
||||
|
||||
// 对于没有开票状态记录的payId,需要检查emis_settle_bill的open_bill_status
|
||||
List<String> missingPayIds = payIds.stream()
|
||||
.filter(payId -> !result.containsKey(payId))
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
|
||||
if (!CollectionUtils.isEmpty(missingPayIds)) {
|
||||
List<Map<String, Object>> billStatusList = emisSettlePayRecordMapper
|
||||
.getBillOpenStatusByPayIds(missingPayIds);
|
||||
for (Map<String, Object> map : billStatusList) {
|
||||
String payId = (String) map.get("pay_id");
|
||||
String openBillStatus = (String) map.get("open_bill_status");
|
||||
if (payId != null) {
|
||||
if ("3".equals(openBillStatus)) {
|
||||
result.put(payId, "不开票");
|
||||
} else {
|
||||
result.put(payId, "未开票");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 对于仍然没有状态的payId,设置为"未开票"
|
||||
for (String payId : missingPayIds) {
|
||||
if (!result.containsKey(payId)) {
|
||||
result.put(payId, "未开票");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -285,18 +406,15 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayBackRecordDtl> queryPayBackRecordList(EmisSettlePayRecord emisSettlePayRecord)
|
||||
{
|
||||
public List<PayBackRecordDtl> queryPayBackRecordList(EmisSettlePayRecord emisSettlePayRecord) {
|
||||
return emisSettlePayRecordMapper.queryPayBackRecordList(emisSettlePayRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayBackRecordDtl> queryNoPayBackRecordList(EmisSettlePayRecord emisSettlePayRecord)
|
||||
{
|
||||
public List<PayBackRecordDtl> queryNoPayBackRecordList(EmisSettlePayRecord emisSettlePayRecord) {
|
||||
return emisSettlePayRecordMapper.queryNoPayBackRecordList(emisSettlePayRecord);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查是否重复
|
||||
*
|
||||
@ -304,9 +422,8 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
* @return 数量
|
||||
*/
|
||||
@Override
|
||||
public int checkUnique(EmisSettlePayRecord emisSettlePayRecord)
|
||||
{
|
||||
return emisSettlePayRecordMapper.checkUnique(emisSettlePayRecord);
|
||||
public int checkUnique(EmisSettlePayRecord emisSettlePayRecord) {
|
||||
return emisSettlePayRecordMapper.checkUnique(emisSettlePayRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -316,7 +433,7 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertEmisSettlePayRecord(EmisSettlePayRecord emisSettlePayRecord,String payId) throws EmisBizError {
|
||||
public int insertEmisSettlePayRecord(EmisSettlePayRecord emisSettlePayRecord, String payId) throws EmisBizError {
|
||||
|
||||
// 非空校验
|
||||
checkParam(emisSettlePayRecord);
|
||||
@ -326,40 +443,38 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
|
||||
emisSettlePayRecord.setSettleBillNo(WaybillHelper.formatQueryValue(emisSettlePayRecord.getSettleBillNo()));
|
||||
// 多账单合并收款
|
||||
String [] settleBillNoArr = emisSettlePayRecord.getSettleBillNo().split(",");
|
||||
String[] settleBillNoArr = emisSettlePayRecord.getSettleBillNo().split(",");
|
||||
|
||||
for(int i=0;i<settleBillNoArr.length;i++) {
|
||||
for (int i = 0; i < settleBillNoArr.length; i++) {
|
||||
String settleBillNo = settleBillNoArr[i];
|
||||
if(!StringUtils.isEmpty(settleBillNo)) {
|
||||
EmisSettleBill emisSettleBill=emisSettleBillMapper.selectSettleBillBySettleBillNo(settleBillNo);
|
||||
if(
|
||||
!"1".equals(emisSettleBill.getBlConfirmSite())
|
||||
&& !"7".equals(emisSettlePayRecord.getPayType()) ){
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,"业务账单未确认,不允许收款!");
|
||||
if (!StringUtils.isEmpty(settleBillNo)) {
|
||||
EmisSettleBill emisSettleBill = emisSettleBillMapper.selectSettleBillBySettleBillNo(settleBillNo);
|
||||
if (!"1".equals(emisSettleBill.getBlConfirmSite())
|
||||
&& !"7".equals(emisSettlePayRecord.getPayType())) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "业务账单未确认,不允许收款!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 不重复的 id流水号
|
||||
// 如果支付单是空的则生成新的支付单
|
||||
if(StringUtils.isEmpty(payId)) {
|
||||
if (StringUtils.isEmpty(payId)) {
|
||||
payId = WaybillHelper.genPayId();
|
||||
}
|
||||
|
||||
emisSettlePayRecord.setPayId(payId);
|
||||
|
||||
// 退款时支付金额记录负值
|
||||
if("2".equals(emisSettlePayRecord.getRecType())){
|
||||
if ("2".equals(emisSettlePayRecord.getRecType())) {
|
||||
emisSettlePayRecord.setPayMoney(BigDecimal.ZERO.subtract(emisSettlePayRecord.getRefundMoney()));
|
||||
emisSettlePayRecord.setTradeDate(emisSettlePayRecord.getRefundDate());
|
||||
// emisSettlePayRecord.setPayType("1");
|
||||
// emisSettlePayRecord.setPayType("1");
|
||||
}
|
||||
|
||||
|
||||
// 插入账单和支付单关联关系
|
||||
for(int i=0;i<settleBillNoArr.length;i++) {
|
||||
for (int i = 0; i < settleBillNoArr.length; i++) {
|
||||
String settleBillNo = settleBillNoArr[i];
|
||||
if(!StringUtils.isEmpty(settleBillNo)) {
|
||||
if (!StringUtils.isEmpty(settleBillNo)) {
|
||||
|
||||
EmisSettlePayBillRel emisSettlePayBillRel = new EmisSettlePayBillRel();
|
||||
emisSettlePayBillRel.setPayId(payId);
|
||||
@ -369,8 +484,8 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
}
|
||||
|
||||
// 插入发票和收款的关系
|
||||
if(!CollectionUtils.isEmpty(emisSettlePayRecord.getPayInvoiceRelList())){
|
||||
for (EmisSettlePayInvoiceRel itemSettlePayInvoiceRel:emisSettlePayRecord.getPayInvoiceRelList()) {
|
||||
if (!CollectionUtils.isEmpty(emisSettlePayRecord.getPayInvoiceRelList())) {
|
||||
for (EmisSettlePayInvoiceRel itemSettlePayInvoiceRel : emisSettlePayRecord.getPayInvoiceRelList()) {
|
||||
itemSettlePayInvoiceRel.setPayId(payId);
|
||||
emisSettlePayInvoiceRelMapper.insertEmisSettlePayInvoiceRel(itemSettlePayInvoiceRel);
|
||||
// 更新收款状态
|
||||
@ -378,15 +493,13 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 记录收退款运单号
|
||||
List<EmisSettlePayRel> listRel=emisSettlePayRecord.getPayRelList();
|
||||
if(!CollectionUtils.isEmpty(listRel)){
|
||||
for (EmisSettlePayRel payRel:listRel
|
||||
) {
|
||||
List<EmisSettlePayRel> listRel = emisSettlePayRecord.getPayRelList();
|
||||
if (!CollectionUtils.isEmpty(listRel)) {
|
||||
for (EmisSettlePayRel payRel : listRel) {
|
||||
payRel.setId(null);
|
||||
payRel.setPayId(payId);
|
||||
if("2".equals(emisSettlePayRecord.getRecType())){
|
||||
if ("2".equals(emisSettlePayRecord.getRecType())) {
|
||||
payRel.setPayMoney(BigDecimal.ZERO.subtract(payRel.getPayMoney()));
|
||||
}
|
||||
emisSettlePayRelMapper.insertEmisSettlePayRel(payRel);
|
||||
@ -399,9 +512,9 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
emisSettlePayRecordMapper.insertEmisSettlePayRecord(emisSettlePayRecord);
|
||||
|
||||
// 重新计算账单收款信息
|
||||
for(int i=0;i<settleBillNoArr.length;i++) {
|
||||
for (int i = 0; i < settleBillNoArr.length; i++) {
|
||||
String settleBillNo = settleBillNoArr[i];
|
||||
if(!StringUtils.isEmpty(settleBillNo)) {
|
||||
if (!StringUtils.isEmpty(settleBillNo)) {
|
||||
emisSettleBillService.reCalcSettleBillPayStatus(settleBillNo);
|
||||
}
|
||||
}
|
||||
@ -409,11 +522,11 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
}
|
||||
|
||||
private static void checkParam(EmisSettlePayRecord emisSettlePayRecord) throws EmisBizError {
|
||||
if(StringUtils.isEmpty(emisSettlePayRecord.getSettleBillNo())){
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,"账单编号不能为空");
|
||||
if (StringUtils.isEmpty(emisSettlePayRecord.getSettleBillNo())) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "账单编号不能为空");
|
||||
}
|
||||
|
||||
if("1".equals(emisSettlePayRecord.getRecType())) {
|
||||
if ("1".equals(emisSettlePayRecord.getRecType())) {
|
||||
if (emisSettlePayRecord.getPayMoney() == null) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "收款金额不能为空");
|
||||
}
|
||||
@ -426,7 +539,7 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
if (emisSettlePayRecord.getTradeDate() == null) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "交易日期不能为空");
|
||||
}
|
||||
} else if("2".equals(emisSettlePayRecord.getRecType())) {
|
||||
} else if ("2".equals(emisSettlePayRecord.getRecType())) {
|
||||
if (emisSettlePayRecord.getRefundMoney() == null) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "退款金额不能为空");
|
||||
}
|
||||
@ -476,9 +589,9 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
@Override
|
||||
public int payRecordReturn(Long id) throws EmisBizError {
|
||||
|
||||
EmisSettlePayRecord payRecordOld=emisSettlePayRecordMapper.selectEmisSettlePayRecordById(id);
|
||||
if(payRecordOld==null){
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,"收款单不存在!");
|
||||
EmisSettlePayRecord payRecordOld = emisSettlePayRecordMapper.selectEmisSettlePayRecordById(id);
|
||||
if (payRecordOld == null) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL, "收款单不存在!");
|
||||
}
|
||||
|
||||
// 删除收款记录
|
||||
@ -497,8 +610,7 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateEmisSettlePayRecord(EmisSettlePayRecord emisSettlePayRecord)
|
||||
{
|
||||
public int updateEmisSettlePayRecord(EmisSettlePayRecord emisSettlePayRecord) {
|
||||
return emisSettlePayRecordMapper.updateEmisSettlePayRecord(emisSettlePayRecord);
|
||||
}
|
||||
|
||||
@ -509,8 +621,7 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteEmisSettlePayRecordByIds(Long[] ids)
|
||||
{
|
||||
public int deleteEmisSettlePayRecordByIds(Long[] ids) {
|
||||
return emisSettlePayRecordMapper.deleteEmisSettlePayRecordByIds(ids);
|
||||
}
|
||||
|
||||
@ -521,8 +632,7 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteEmisSettlePayRecordById(Long id)
|
||||
{
|
||||
public int deleteEmisSettlePayRecordById(Long id) {
|
||||
return emisSettlePayRecordMapper.deleteEmisSettlePayRecordById(id);
|
||||
}
|
||||
|
||||
@ -539,7 +649,8 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
List<EmisSettlePayRecord> exportList = selectEmisSettlePayRecordList(emisSettlePayRecord);
|
||||
|
||||
// 使用定制Excel工具类导出
|
||||
EmisSettlePayRecordCustomExcelUtil.exportCustomExcel(response, exportList, "收款明细定制导出_" + System.currentTimeMillis());
|
||||
EmisSettlePayRecordCustomExcelUtil.exportCustomExcel(response, exportList,
|
||||
"收款明细定制导出_" + System.currentTimeMillis());
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("定制导出收款明细失败", e);
|
||||
|
||||
@ -684,7 +684,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
WHEN invoice_amount = FLOOR(invoice_amount) THEN CAST(FLOOR(invoice_amount) AS CHAR)
|
||||
ELSE TRIM(TRAILING '0' FROM TRIM(TRAILING '.' FROM CAST(invoice_amount AS CHAR)))
|
||||
END,
|
||||
' ',
|
||||
'元 ',
|
||||
company_name
|
||||
)
|
||||
END
|
||||
@ -770,4 +770,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
group by espr.pay_id
|
||||
</select>
|
||||
|
||||
<!-- 根据支付ID列表获取账单开票状态 -->
|
||||
<select id="getBillOpenStatusByPayIds" parameterType="java.util.List" resultType="map">
|
||||
select
|
||||
espbr.pay_id,
|
||||
esb.open_bill_status
|
||||
from emis_settle_pay_bill_rel espbr
|
||||
left join emis_settle_bill esb on espbr.settle_bill_no = esb.settle_bill_no
|
||||
where espbr.del_flag = '0' and esb.del_flag = '0'
|
||||
and espbr.pay_id in
|
||||
<foreach collection="list" item="payId" open="(" separator="," close=")">
|
||||
#{payId}
|
||||
</foreach>
|
||||
group by espbr.pay_id
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user