Commit f9445154 authored by zhangfeng's avatar zhangfeng

feat(wealth): 创建/批量创建银行收款明细

parent 7cf76af0
......@@ -120,13 +120,13 @@ CREATE TABLE `jiedao`.`ecw_receipt_log` (
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '收款单日志' ROW_FORMAT = DYNAMIC;
ALTER TABLE `jiedao`.`ecw_receivable` ADD COLUMN `write_off_amount` decimal(10, 2) NOT NULL COMMENT '核销金额' AFTER `remark`;
ALTER TABLE `jiedao`.`ecw_receivable` ADD COLUMN `base_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '基准金额' AFTER `write_off_amount`;
ALTER TABLE `jiedao`.`ecw_receivable` ADD COLUMN `base_amount` decimal(15, 2) NULL DEFAULT NULL COMMENT '基准金额' AFTER `remark`;
ALTER TABLE `jiedao`.`ecw_receivable` ADD COLUMN `base_currency_id` int NULL DEFAULT NULL COMMENT '基准币种' AFTER `base_amount`;
ALTER TABLE `jiedao`.`ecw_receivable` MODIFY COLUMN `exchange_rate` decimal(10, 6) NULL DEFAULT NULL COMMENT '汇率' AFTER `fee_type`;
ALTER TABLE `jiedao`.`ecw_receivable` ADD COLUMN `write_off_amount` decimal(15, 2) NOT NULL DEFAULT 0.00 COMMENT '核销金额' AFTER `base_currency_id`;
ALTER TABLE `jiedao`.`ecw_receivable` MODIFY COLUMN `exchange_rate` decimal(15, 6) NULL DEFAULT NULL COMMENT '汇率' AFTER `fee_type`;
ALTER TABLE `jiedao`.`ecw_receivable` ADD INDEX `key_receipt_id`(`deleted` ASC, `receipt_id` ASC) USING BTREE;
......
......@@ -160,6 +160,11 @@ public class ReceivableDO extends BaseDO {
* 核销金额
*/
private BigDecimal writeOffAmount;
/**
* 基准核销金额
*/
@TableField(exist = false)
private BigDecimal writeOffBaseAmount;
/**
* 基准金额
*/
......
......@@ -111,4 +111,6 @@ public interface ErrorCodeConstants {
ErrorCode RECEIVABLE_WRITE_OFF_ING_NO_NEED_TO_PACK = new ErrorCode(1004520038, "wealth.receivable_write_off_ing_no_need_to_pack");
ErrorCode RECEIPT_ITEM_RECEIVABLE_WRITE_OFF_LIST_EMPTY = new ErrorCode(1004520041, "收款明细对应的应收明细核销记录为空");
ErrorCode RECEIPT_ITEM_BATCH_ERROR = new ErrorCode(1004520042, "批量导入收款明细存在错误");
ErrorCode RECEIPT_ITEM_BATCH_WARN = new ErrorCode(1004520043, "批量导入收款明细存在警告");
}
......@@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.wealth.dal.dataobject.receipt.ReceiptDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptApproval.ReceiptApprovalDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptItem.ReceiptItemDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receivable.ReceivableDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receivable.ReceivableWriteOffRecordDO;
import cn.iocoder.yudao.module.wealth.dal.mysql.receipt.ReceiptMapper;
import cn.iocoder.yudao.module.wealth.dal.mysql.receiptItem.ReceiptItemMapper;
import cn.iocoder.yudao.module.wealth.enums.ReceiptItemStatusEnum;
......@@ -288,6 +289,19 @@ public class FinanceReceiptApproveService {
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_PART_ING.getValue());
}
receiptMapper.updateById(updateReceipt);
// 将应收明细的核销状态和核销金额重置
List<ReceivableDO> receivableDOS = receivableService.selectList("receipt_id", receiptItemDO.getReceiptId());
for (ReceivableDO receivableDO : receivableDOS) {
ReceivableWriteOffRecordDO receivableWriteOffRecordDO = receivableService.getReceivableWriteOffRecord(receivableDO.getId(), receiptItemDO.getId());
if (null != receivableWriteOffRecordDO) {
BigDecimal writeOffCurrent = receivableWriteOffRecordDO.getWriteOffAmount().divide(receivableDO.getExchangeRate());
receivableDO.setWriteOffAmount(receivableDO.getWriteOffAmount().subtract(writeOffCurrent));
}
if (receivableDO.getWriteOffAmount().compareTo(BigDecimal.ZERO) <= 0) {
receivableDO.setState(0);
}
}
receivableService.updateBatchById(receivableDOS);
receiptService.updateReceiptItemStatus(receiptItemDO.getReceiptId());
} else if (result == BpmProcessInstanceResultEnum.REJECT.getResult()) {
updateReceiptItem.setStatus(ReceiptItemStatusEnum.WRITE_OFF.getValue());
......
......@@ -630,6 +630,13 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
} else {
receivableInItemVO.setWriteOffAmount(receivableWriteOffRecordDO.getWriteOffAmount());
}
BigDecimal totalWriteOffAmount = receivableWriteOffRecordMapper.getTotalAmountForReceivable(receivableInItemVO.getId());
if (totalWriteOffAmount == null) {
receivableInItemVO.setWriteOffAmountUsd(BigDecimal.ZERO);
} else {
receivableInItemVO.setWriteOffAmountUsd(totalWriteOffAmount.subtract(receivableInItemVO.getWriteOffAmount()));
}
receivableInItemVO.setNotWriteOffAmountUsd(receivableInItemVO.getBaseAmount().subtract(receivableInItemVO.getWriteOffAmountUsd()));
}
return receivableInItemVOS;
}
......
package cn.iocoder.yudao.module.wealth.vo.receiptAccount;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Data
@Builder
@ApiModel("管理后台 - 批量收款信息创建 Request VO")
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = false)
public class ReceiptItemBatchCreateReqVO {
@ApiModelProperty(value = "订单号/提单号")
@ExcelProperty("订单号/提单号")
......@@ -53,4 +60,12 @@ public class ReceiptItemBatchCreateReqVO {
@ApiModelProperty(value = "备注")
@ExcelProperty("备注")
private String remark;
@ApiModelProperty(value = "收款账号名称")
@ExcelIgnore
private String accountName;
@ApiModelProperty(value = "收款账号银行名称")
@ExcelIgnore
private String accountBankName;
}
......@@ -16,6 +16,9 @@ public class ReceivableInItemVO {
@ApiModelProperty(value = "主键", required = true)
private Long id;
@ApiModelProperty(value = "流水号")
private String serialNumber;
@ApiModelProperty(value = "收款单id")
private Long receiptId;
......
......@@ -299,17 +299,13 @@ public class ReceiptItemController {
.remark("非必填")
.build());
// 输出
ExcelUtils.write(response, "批量银行收款信息导入模板.xls", "银行收款信息", ReceiptItemBatchCreateReqVO.class, list);
ExcelUtils.write(response, "批量银行收款信息导入模板.xlsx", "银行收款信息", ReceiptItemBatchCreateReqVO.class, list);
}
@PostMapping(value = "/import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ApiOperation("批量银行收款信息导入")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "Excel 文件", required = true, dataTypeClass = MultipartFile.class)
})
public CommonResult<List<ReceiptItemBatchRespVO>> receiptAccountImport(@RequestParam("file") MultipartFile file, @RequestParam(value = "ignoreItem") Boolean ignoreItem) throws IOException {
public CommonResult<List<ReceiptItemBatchRespVO>> receiptAccountImport(@RequestPart("file") MultipartFile file, @RequestParam(value = "ignoreItem") Boolean ignoreItem) throws IOException {
List<ReceiptItemBatchCreateReqVO> list = ExcelUtils.read(file, ReceiptItemBatchCreateReqVO.class);
return success(receiptItemService.receiptItemImport(list, ignoreItem));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment