Commit 58c0ebfc authored by zhangfeng's avatar zhangfeng

feat(wealth): 财务报表

parent 14fe2bd5
......@@ -4,7 +4,7 @@ ALTER TABLE `ecw_bank_account` COLLATE = utf8mb4_general_ci;
ALTER TABLE `ecw_bank_account` ADD COLUMN `ba_country` bigint NULL DEFAULT NULL COMMENT '国家' AFTER `ba_type`;
ALTER TABLE `ecw_bank_account` ADD COLUMN `ba_income_belong` bigint NULL DEFAULT NULL COMMENT '归属' AFTER `ba_country`;
ALTER TABLE `ecw_bank_account` ADD COLUMN `ba_income_belong` int NULL DEFAULT NULL COMMENT '归属' AFTER `ba_country`;
ALTER TABLE `ecw_bank_account` ADD COLUMN `ba_currency` int NULL DEFAULT NULL COMMENT '币种' AFTER `ba_income_belong`;
......@@ -103,6 +103,8 @@ ALTER TABLE `ecw_receipt_item` ADD COLUMN `remark` varchar(500) CHARACTER SET ut
ALTER TABLE `ecw_receipt_item` ADD COLUMN `approval_time` datetime NULL DEFAULT NULL COMMENT '审核通过时间' AFTER `remark`;
ALTER TABLE `ecw_receipt_item` ADD COLUMN `account_id` bigint NULL DEFAULT NULL COMMENT '收款账号id' AFTER `receipt_id`;
ALTER TABLE `ecw_receipt_item` MODIFY COLUMN `rate` decimal(10, 6) NULL DEFAULT NULL COMMENT '收款汇率' AFTER `currency_id`;
CREATE TABLE `ecw_receipt_log` (
......@@ -128,20 +130,29 @@ ALTER TABLE `ecw_receivable` ADD COLUMN `write_off_amount` decimal(15, 2) NOT NU
ALTER TABLE `ecw_receivable` MODIFY COLUMN `exchange_rate` decimal(15, 6) NULL DEFAULT NULL COMMENT '汇率' AFTER `fee_type`;
ALTER TABLE `ecw_receivable` ADD COLUMN `dest_country_currency_id` bigint NULL DEFAULT NULL COMMENT '目的国相关币种id(用于报表,跟费用类型相关)' AFTER `fee_type`;
ALTER TABLE `ecw_receivable` ADD COLUMN `dest_country_rate` decimal(10, 6) NULL DEFAULT NULL COMMENT '目的国相关汇率(用于报表,跟费用类型相关)' AFTER `dest_country_currency_id`;
ALTER TABLE `ecw_receivable` ADD COLUMN `dest_country_sub_rate` decimal(10, 6) NULL DEFAULT NULL COMMENT '额外费用副币种汇率(用于报表,跟费用类型相关)' AFTER `dest_country_rate`;
ALTER TABLE `ecw_receivable` ADD INDEX `key_receipt_id`(`deleted` ASC, `receipt_id` ASC) USING BTREE;
CREATE TABLE `ecw_receivable_write_off_record` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
`order_id` bigint DEFAULT NULL COMMENT '订单id',
`receivable_id` bigint DEFAULT NULL COMMENT '应收款id',
`receipt_item_id` bigint DEFAULT NULL COMMENT '银行收款明细id',
`receivable_write_off_amount` decimal(10,2) DEFAULT NULL COMMENT '应收的核销金额',
`write_off_amount` decimal(10,2) DEFAULT NULL COMMENT '核销金额',
`income_belong` int DEFAULT NULL COMMENT '收入归属(0目的国,1始发国)',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`creator` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
`updater` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除标志',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='收款单日志';
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='收款明细与应收明细关联表';
SET FOREIGN_KEY_CHECKS=1;
......
......@@ -28,6 +28,67 @@ UPDATE ecw_receipt_item
SET approval_time = update_time
WHERE approval_time IS NULL AND `status` = 1;
# 刷新银行明细汇率,银行收款明细-币种≠应收所在自编号对应的核算币种,但是跟收款单-应收费用的币种相同
UPDATE ecw_receipt_item eri
SET eri.rate = (
SELECT era.write_off_rate
FROM ecw_receipt_account era
WHERE eri.receipt_id = era.receipt_id
AND era.currency_id = eri.currency_id
AND era.deleted = 0
AND era.write_off_rate IS NOT NULL
)
WHERE eri.`status` = 1
AND eri.deleted = 0
AND EXISTS (
SELECT 1
FROM ecw_receipt_account era
WHERE eri.receipt_id = era.receipt_id
AND era.currency_id = eri.currency_id
AND era.deleted = 0
AND era.write_off_rate IS NOT NULL
);
# 查询银行收款明细-币种≠应收所在自编号对应的核算币种,跟收款单-应收费用的币种也无法匹配
SELECT
eri.id,
eri.serial_number,
eri.receipt_id,
era.id aid,
eri.currency_id ic,
era.currency_id ac,
era.write_off_rate
FROM
ecw_receipt_item eri
LEFT JOIN ecw_receipt_account era ON eri.receipt_id = era.receipt_id
AND eri.currency_id = era.currency_id
AND era.deleted = 0
WHERE
eri.`status` = 1
AND eri.deleted = 0
AND era.id IS NULL;
# 刷新银行收款明细-币种≠应收所在自编号对应的核算币种,跟收款单-应收费用的币种也无法匹配
UPDATE ecw_receipt_item eri
JOIN (
SELECT
eri.id
FROM
ecw_receipt_item eri
LEFT JOIN ecw_receipt_account era
ON eri.receipt_id = era.receipt_id
AND eri.currency_id = era.currency_id
AND era.deleted = 0
WHERE
eri.`status` = 1
AND eri.deleted = 0
AND era.id IS NULL
) AS to_update ON eri.id = to_update.id
SET eri.rate = IFNULL((
SELECT eer.currency_rate
FROM ecw_exchange_rate eer
WHERE eer.source_currency_id = eri.currency_id
AND eer.target_currency_id = eri.write_off_currency_id
),1);
# 刷新银行明细审核核销币种
UPDATE ecw_receipt_item SET write_off_currency_id = 1 WHERE write_off_currency_id IS NULL;
......@@ -38,12 +99,20 @@ UPDATE ecw_receivable er
SET er.discount_total = 0 WHERE er.discount_total IS NULL;
# 刷新应收款汇率
# 应收明细币种=基准币种
UPDATE ecw_receivable er
SET er.exchange_rate = 1 WHERE er.exchange_rate IS NULL AND er.receipt_id IS NOT NULL AND er.currency_id = er.base_currency_id AND er.deleted = 0;
# 应收明细基准币种是美元
UPDATE ecw_receivable er
SET er.exchange_rate = ( SELECT era.write_off_rate FROM ecw_receipt_account era WHERE era.receipt_id = er.receipt_id AND era.currency_id = er.currency_id AND era.deleted = 0)
WHERE
er.receipt_id IS NOT NULL AND er.base_currency_id = 1 AND er.deleted = 0;
# 应收明细基准币种不是美元
UPDATE ecw_receivable er
SET er.exchange_rate = (SELECT eer.currency_rate FROM ecw_exchange_rate eer WHERE eer.source_currency_id = er.currency_id AND eer.target_currency_id = er.base_currency_id )
WHERE er.exchange_rate IS NULL AND er.receipt_id IS NOT NULL;
WHERE er.exchange_rate IS NULL AND er.receipt_id IS NOT NULL AND er.base_currency_id != 1 AND er.deleted = 0;
UPDATE ecw_receivable er
SET er.exchange_rate = 1 WHERE er.exchange_rate IS NULL AND er.receipt_id IS NOT NULL;
# 刷新应收款基准金额
UPDATE ecw_receivable er
......@@ -52,3 +121,11 @@ WHERE er.base_amount IS NULL AND er.receipt_id IS NOT NULL AND er.exchange_rate
# 修改收款单已核销待开票状态
UPDATE `ecw_receipt` SET `state` = 4 WHERE `state` = 5;
# 刷新应收明细账户ID
UPDATE ecw_receipt_item eri SET eri.account_id = (SELECT eba.id FROM ecw_bank_account eba WHERE eba.ba_account_name = eri.account_name AND eba.ba_bank_name = eri.account_bank_name AND eba.ba_account_num = eri.account_no AND eba.deleted = 0) WHERE eri.deleted = 0;
# 刷新收款明细-应收明细-收入归属
UPDATE ecw_receivable_write_off_record erwor SET erwor.income_belong =
(SELECT eba.ba_income_belong FROM ecw_receipt_item eri LEFT JOIN ecw_bank_account eba ON eri.account_id = eba.id WHERE erwor.receipt_item_id = eri.id);
\ No newline at end of file
......@@ -32,6 +32,20 @@ INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`,
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES ( 7, '审批银行收款明细', '7', 'receipt_link', 0, 'default', '', NULL, '1', '2025-01-02 17:35:17', '1', '2025-01-02 17:35:17', b'0', 'Approve Bank Receipt', NULL);
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES ( 8, '核销收款单', '8', 'receipt_link', 0, 'default', '', NULL, '1', '2025-01-02 17:35:36', '1', '2025-01-02 17:35:36', b'0', 'Write Off Receipt', NULL);
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES ( 9, '反核销收款单', '9', 'receipt_link', 0, 'default', '', NULL, '1', '2025-01-02 17:35:52', '1', '2025-01-02 17:35:52', b'0', 'Reject Write Off Receipt', NULL);
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES (0, '大于', '0', 'income_relation_symbol', 0, 'default', '', NULL, '1', '2025-01-09 13:43:35', '1', '2025-01-09 13:43:35', b'0', 'Greater than', 'supérieur à');
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES (1, '等于', '1', 'income_relation_symbol', 0, 'default', '', NULL, '1', '2025-01-09 13:44:18', '1', '2025-01-09 13:44:18', b'0', 'Equal', 'égal');
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES (2, '小于等于', '2', 'income_relation_symbol', 0, 'default', '', NULL, '1', '2025-01-09 13:46:19', '1', '2025-01-09 13:46:19', b'0', 'Less or equal', 'inférieur ou égal à');
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES (4, '开票资料消息', '4', 'internal_message_type', 0, 'default', '', NULL, '1', '2025-01-10 15:32:05', '1', '2025-01-10 15:32:05', b'0', 'Invoicing Data Message', ' Message d\'information sur la facturation');
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES (5, '开票消息', '5', 'internal_message_type', 0, 'default', '', NULL, '1', '2025-01-10 15:33:02', '1', '2025-01-10 15:33:02', b'0', 'Invoicing Message', 'Message de facturation');
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES (0, '未完成', '0', 'lading_Bill_Status_Data', 0, 'default', '', NULL, '2696', '2025-01-13 17:15:41', '2696', '2025-01-13 17:15:41', b'0', 'unfinished', 'To Be Continued.');
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES (1, '部分完成', '1', 'lading_Bill_Status_Data', 0, 'default', '', NULL, '2696', '2025-01-13 17:19:46', '2696', '2025-01-13 17:20:23', b'0', 'partly completed', 'Partiellement terminé en');
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES (2, '已完成', '2', 'lading_Bill_Status_Data', 0, 'default', '', NULL, '2696', '2025-01-13 17:20:59', '2696', '2025-01-13 17:20:59', b'0', 'completed', 'Déjà terminé avec');
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES (0, '目的国', '0', 'attribution_of_income', 0, 'default', '', NULL, '2696', '2025-01-14 16:25:16', '2696', '2025-01-14 16:25:16', b'0', 'country of destination', 'Pays de destination');
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES (1, '始发国', '1', 'attribution_of_income', 0, 'default', '', NULL, '2696', '2025-01-14 16:25:53', '2696', '2025-01-14 16:25:53', b'0', 'Country of origin', 'Pays de départ');
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES (0, '大于等于', 'gePickRatio', 'pickup_rate_comparison_symbols', 0, 'default', '', NULL, '1', '2025-01-15 18:15:04', '1', '2025-01-16 15:13:07', b'0', 'great than or equal to', 'Supérieur ou égal');
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES (1, '小于等于', 'lePickRatio', 'pickup_rate_comparison_symbols', 0, 'default', '', NULL, '1', '2025-01-15 18:16:04', '1', '2025-01-16 15:13:44', b'0', 'less than or equal to', 'Inférieur ou égal');
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES (2, '等于', 'eqPickRatio', 'pickup_rate_comparison_symbols', 0, 'default', '', NULL, '1', '2025-01-15 18:16:49', '1', '2025-01-16 15:12:40', b'0', 'equal to', 'égal à');
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `label_en`, `label_fr`) VALUES (3, '不等于', 'nePickRatio', 'pickup_rate_comparison_symbols', 0, 'default', '', NULL, '1', '2025-01-15 18:17:32', '1', '2025-01-16 15:14:01', b'0', 'not equal to', 'Pas égal à');
INSERT INTO `system_dict_type` (`name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ( '开票状态', 'invoicing_status', 0, NULL, '1', '2024-12-20 17:42:06', '1', '2024-12-20 17:42:06', b'0');
......@@ -40,9 +54,13 @@ INSERT INTO `system_dict_type` (`name`, `type`, `status`, `remark`, `creator`, `
INSERT INTO `system_dict_type` (`name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ( '开票环节', 'invoicing_link', 0, '用于日志记录', '1', '2024-12-26 13:48:05', '1', '2024-12-26 13:48:05', b'0');
INSERT INTO `system_dict_type` (`name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ( '收款单生成路径', 'receipt_generate_path', 0, NULL, '1', '2024-12-31 16:31:49', '1', '2024-12-31 16:31:49', b'0');
INSERT INTO `system_dict_type` (`name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ( '收款单日志环节', 'receipt_link', 0, NULL, '1', '2025-01-02 17:31:39', '1', '2025-01-02 17:31:39', b'0');
INSERT INTO `system_dict_type` (`name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ( '银行收支明细查询关系符号', 'income_relation_symbol', 0, NULL, '1', '2025-01-09 13:17:51', '1', '2025-01-09 13:18:11', b'0');
INSERT INTO `system_dict_type` (`name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ('提单制作', 'lading_Bill_Status_Data', 0, NULL, '2696', '2025-01-13 17:14:03', '2696', '2025-01-13 17:14:03', b'0');
INSERT INTO `system_dict_type` (`name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ('收入归属', 'attribution_of_income', 0, NULL, '2696', '2025-01-14 16:23:59', '2696', '2025-01-14 16:23:59', b'0');
INSERT INTO `system_dict_type` (`name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ('提货率比较符号', 'pickup_rate_comparison_symbols', 0, NULL, '1', '2025-01-15 18:12:22', '1', '2025-01-15 18:12:22', b'0');
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('银行账号', '', 2, 2, 1624, 'bankAccount', 'date-range', NULL, 0, '2696', '2025-01-14 16:39:59', '2696', '2025-01-14 16:39:59', b'0', b'1', 'Bank Account', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('费用明细', '', 2, 1, 1624, 'chargeDetails', 'druid', 'ecw/financial/chargeDetails', 0, '1', '2024-12-20 13:56:04', '1', '2024-12-20 13:56:04', b'0', b'1', 'chargeDetails', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('自动审批规则', '', 2, 1, 1624, 'setAutoApprovalRules', 'checkbox', 'ecw/financial/setAutoApprovalRules', 0, '1', '2024-12-20 16:34:19', '1', '2024-12-20 16:34:19', b'0', b'1', 'Automatic approval rules', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('申请开票', 'ecw:voucher:applyInvoice', 3, 13, 1634, '', '', '', 0, '1', '2024-12-23 09:24:01', '1', '2024-12-23 09:24:01', b'0', b'1', 'Apply for Invoice', b'0', NULL, NULL);
......@@ -52,15 +70,28 @@ INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('开票信息', 'ecw:voucher:invoiceInformation', 3, 4, 1634, '', '', '', 0, '1', '2024-12-23 09:46:53', '1', '2024-12-23 09:46:53', b'0', b'1', 'invoice information', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('导入银行收款信息', 'ecw:voucher:importBankCollectionInfo', 3, 2, 1634, '', '', '', 0, '1', '2024-12-23 10:23:51', '1', '2024-12-23 10:23:51', b'0', b'1', 'Import bank collection information', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('开票申请/修改', '', 2, 1, 1624, 'invoiceOperate', 'bug', 'ecw/financial/invoiceOperate', 0, '1', '2024-12-23 11:17:32', '1', '2024-12-23 11:17:32', b'0', b'0', 'invoice application/amendment', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('开票管理', '', 2, 2, 1624, 'invoiceManagement', 'order', 'ecw/financial/invoiceManagement', 0, '1', '2024-12-24 18:13:46', '1', '2024-12-24 18:13:46', b'0', b'1', 'invoiceManagement', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('开票管理', '', 2, 2, (SELECT tmp.id FROM(SELECT id FROM system_menu WHERE `name` = '银行账号')tmp), 'invoiceManagement', 'order', 'ecw/financial/invoiceManagement', 0, '1', '2024-12-24 18:13:46', '2696', '2025-01-14 16:44:06', b'0', b'1', 'invoiceManagement', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('收款数据审批列表', '', 2, 2, 1624, 'collectionApprovalList', 'clipboard', 'ecw/financial/collectionApprovalList', 0, '1', '2025-01-03 08:58:08', '1', '2025-01-03 08:58:08', b'0', b'1', 'collectionApprovalList', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('审批', 'ecw:collectionApprovalList:update', 3, 1, 2388, '', '', '', 0, '1', '2025-01-03 16:59:36', '1', '2025-01-03 16:59:36', b'0', b'1', 'approve', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('审批', 'ecw:collectionApprovalList:update', 3, 1, (SELECT tmp.id FROM(SELECT id FROM system_menu WHERE `name` = '收款数据审批列表')tmp), '', '', '', 0, '1', '2025-01-03 16:59:36', '1', '2025-01-03 16:59:36', b'0', b'1', 'approve', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('批量生成收款单', '', 2, 12, 1624, 'batchGenerateReceipt/:id', 'button', 'ecw/financial/batchGenerateReceipt', 0, '2696', '2025-01-08 09:57:18', '2696', '2025-01-09 10:53:46', b'0', b'0', 'batchGenerateReceipt', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('批量生成收款单列表', '', 2, 7, 1624, 'batchGenerateReceiptList', 'component', 'ecw/financial/batchGenerateReceiptList', 0, '2696', '2025-01-08 09:58:54', '2696', '2025-01-08 09:58:54', b'0', b'1', 'batchGenerateReceiptList', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('银行收支明细', '', 2, 1, 1624, 'bankBalanceDetails', 'dashboard', 'ecw/financial/bankBalanceDetails', 0, '2696', '2025-01-09 13:44:20', '2696', '2025-01-09 13:50:15', b'0', b'1', 'bank Balance Details', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('银行收支明细', '', 2, 2, (SELECT tmp.id FROM(SELECT id FROM system_menu WHERE `name` = '银行账号')tmp), 'bankBalanceDetails', 'dashboard', 'ecw/financial/bankBalanceDetails', 0, '2696', '2025-01-09 13:44:20', '2696', '2025-01-14 16:42:24', b'0', b'1', 'bank Balance Details', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('单个订单费用明细', '', 2, 4, 1624, 'orderItemCostDetails/:id/:drawee', 'theme', 'ecw/financial/orderItemCostDetails', 0, '2696', '2025-01-09 15:30:19', '2696', '2025-01-13 10:17:48', b'0', b'0', 'orderItemCostDetails', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('应收', '', 2, 1, 1624, 'receivable', 'component', NULL, 0, '2696', '2025-01-14 15:59:47', '2696', '2025-01-14 16:02:55', b'0', b'1', 'receivable', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('新应收报表', '', 2, 1, (SELECT tmp.id FROM(SELECT id FROM system_menu WHERE `name` = '应收')tmp), 'selfNoReportNew', 'skill', 'ecw/financial/selfNoReportNew', 0, '2696', '2025-01-13 13:52:48', '2696', '2025-01-14 16:04:41', b'0', b'1', 'selfNoReportNew', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('应付', '', 2, 2, 1624, 'accountsPayable', 'international', NULL, 0, '2696', '2025-01-14 16:48:14', '2696', '2025-01-14 16:48:14', b'0', b'1', 'accounts payable', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('佣金', '', 2, 5, 1624, 'commission', 'monitor', NULL, 0, '2696', '2025-01-14 16:56:29', '2696', '2025-01-14 16:56:29', b'0', b'1', 'commission', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('订单费用明细列表', '', 2, 5, (SELECT tmp.id FROM(SELECT id FROM system_menu WHERE `name` = '应收')tmp), 'selfNoReportDetailNew', 'example', 'ecw/financial/selfNoReportNew/selfNoReportDetailNew', 0, '1', '2025-01-15 13:51:19', '1', '2025-01-15 13:51:19', b'0', b'0', 'selfNoReportDetailNew', b'0', NULL, NULL);
UPDATE `system_menu` SET `name` = '银行账户', `permission` = '', `menu_type` = 2, `sort` = 9, `parent_id` = 1624, `path` = 'bank-account', `icon` = 'lock', `component` = 'ecw/bankAccount/index', `status` = 0, `creator` = '', `create_time` = '2022-05-09 11:40:51', `updater` = '1', `update_time` = '2024-12-20 13:36:45', `deleted` = b'0', `is_show_in_menu_bar` = b'1', `name_en` = 'Bank account management', `keepalive` = b'0', `redirect` = NULL, `badge_field` = NULL WHERE `id` = 1269;
UPDATE `system_dict_data` SET `status` = 1 WHERE `id` = 1784;
UPDATE `system_dict_data` SET `label` = '审批拒绝' WHERE `id` = 2096;
UPDATE `system_menu` SET `name` = '银行账户', `permission` = '', `menu_type` = 2, `sort` = 1, `parent_id` = (SELECT tmp.id FROM(SELECT id FROM system_menu WHERE `name` = '银行账号')tmp), `path` = 'bank-account', `icon` = 'lock', `component` = 'ecw/bankAccount/index', `status` = 0, `creator` = '', `create_time` = '2022-05-09 11:40:51', `updater` = '2696', `update_time` = '2025-01-14 16:41:12', `deleted` = b'0', `is_show_in_menu_bar` = b'1', `name_en` = 'Bank account management', `keepalive` = b'0', `redirect` = NULL, `badge_field` = NULL WHERE `id` = 1269;
UPDATE `system_menu` SET `name` = '应收款', `permission` = '', `menu_type` = 2, `sort` = 1, `parent_id` = (SELECT tmp.id FROM(SELECT id FROM system_menu WHERE `name` = '应收')tmp), `path` = 'receivable', `icon` = 'pay', `component` = 'ecw/financial/receivable', `status` = 0, `creator` = '1', `create_time` = '2022-07-15 16:29:28', `updater` = '2696', `update_time` = '2025-01-14 16:34:34', `deleted` = b'0', `is_show_in_menu_bar` = b'1', `name_en` = 'Receivables', `keepalive` = b'0', `redirect` = NULL, `badge_field` = NULL WHERE `id` = 1625;
UPDATE `system_menu` SET `name` = '应付款', `permission` = '', `menu_type` = 2, `sort` = 3, `parent_id` = (SELECT tmp.id FROM(SELECT id FROM system_menu WHERE `name` = '应付')tmp), `path` = 'payable', `icon` = 'pay', `component` = 'ecw/financial/payable', `status` = 0, `creator` = '1', `create_time` = '2022-07-15 16:31:12', `updater` = '2696', `update_time` = '2025-01-14 16:48:57', `deleted` = b'0', `is_show_in_menu_bar` = b'1', `name_en` = 'Accounts payable', `keepalive` = b'0', `redirect` = NULL, `badge_field` = NULL WHERE `id` = 1626;
UPDATE `system_menu` SET `name` = '收款单', `permission` = '', `menu_type` = 2, `sort` = 2, `parent_id` = (SELECT tmp.id FROM(SELECT id FROM system_menu WHERE `name` = '应收')tmp), `path` = 'voucher', `icon` = 'education', `component` = 'ecw/financial/voucher', `status` = 0, `creator` = '1', `create_time` = '2022-07-21 13:38:38', `updater` = '2696', `update_time` = '2025-01-14 16:36:53', `deleted` = b'0', `is_show_in_menu_bar` = b'1', `name_en` = 'receipt', `keepalive` = b'0', `redirect` = NULL, `badge_field` = NULL WHERE `id` = 1634;
UPDATE `system_menu` SET `name` = '付款单', `permission` = '', `menu_type` = 2, `sort` = 6, `parent_id` = (SELECT tmp.id FROM(SELECT id FROM system_menu WHERE `name` = '应付')tmp), `path` = 'paymentVoucher', `icon` = 'education', `component` = 'ecw/financial/paymentVoucher', `status` = 0, `creator` = '1', `create_time` = '2022-08-16 11:20:08', `updater` = '2696', `update_time` = '2025-01-14 16:50:06', `deleted` = b'0', `is_show_in_menu_bar` = b'1', `name_en` = 'Payment Doc', `keepalive` = b'0', `redirect` = NULL, `badge_field` = NULL WHERE `id` = 1656;
UPDATE `system_menu` SET `name` = '佣金应付款', `permission` = '', `menu_type` = 2, `sort` = 6, `parent_id` = (SELECT tmp.id FROM(SELECT id FROM system_menu WHERE `name` = '佣金' AND name_en = 'commission')tmp), `path` = 'commission-payable', `icon` = 'money', `component` = 'ecw/financial/commission-payable', `status` = 0, `creator` = '1', `create_time` = '2023-03-15 10:08:26', `updater` = '2696', `update_time` = '2025-01-14 16:57:21', `deleted` = b'0', `is_show_in_menu_bar` = b'1', `name_en` = 'commissionPayable', `keepalive` = b'0', `redirect` = NULL, `badge_field` = NULL WHERE `id` = 1940;
UPDATE `system_menu` SET `name` = '佣金付款单', `permission` = '', `menu_type` = 2, `sort` = 2, `parent_id` = (SELECT tmp.id FROM(SELECT id FROM system_menu WHERE `name` = '佣金' AND name_en = 'commission')tmp), `path` = 'commission-Payment', `icon` = 'dict', `component` = 'ecw/financial/commission-Payment', `status` = 0, `creator` = '115', `create_time` = '2023-04-06 17:04:03', `updater` = '2696', `update_time` = '2025-01-14 16:58:07', `deleted` = b'0', `is_show_in_menu_bar` = b'1', `name_en` = 'Commission Payment Document', `keepalive` = b'0', `redirect` = NULL, `badge_field` = NULL WHERE `id` = 2072;
UPDATE `system_menu` SET `name` = '应收报表', `permission` = '', `menu_type` = 2, `sort` = 0, `parent_id` = (SELECT tmp.id FROM(SELECT id FROM system_menu WHERE `name` = '应收')tmp), `path` = 'self_no_report', `icon` = 'button', `component` = 'ecw/financial/selfNoReport', `status` = 0, `creator` = '115', `create_time` = '2023-07-15 23:06:11', `updater` = '2696', `update_time` = '2025-01-14 16:00:54', `deleted` = b'0', `is_show_in_menu_bar` = b'1', `name_en` = 'Self No Report', `keepalive` = b'0', `redirect` = NULL, `badge_field` = NULL WHERE `id` = 2131;
UPDATE `system_menu` SET `name` = '银行收款明细', `permission` = '', `menu_type` = 2, `sort` = 13, `parent_id` = (SELECT tmp.id FROM(SELECT id FROM system_menu WHERE `name` = '银行账号')tmp), `path` = 'BankReceiptDetails', `icon` = 'education', `component` = 'report/BankReceiptDetails/index', `status` = 0, `creator` = '1', `create_time` = '2024-06-12 21:34:58', `updater` = '2696', `update_time` = '2025-01-14 16:45:56', `deleted` = b'0', `is_show_in_menu_bar` = b'1', `name_en` = 'Receipt Details', `keepalive` = b'0', `redirect` = NULL, `badge_field` = NULL WHERE `name` = '银行收款明细';
\ No newline at end of file
package cn.iocoder.yudao.framework.apollo.core.event.export;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ShipmentSummeryNewExcelExportPushEvent {
/**
* 操作用户
*/
private Long userId;
/**
* 端口
*/
private Integer userType;
/**
* 请求参数
*/
private String requestParams;
/**
* 国际化语言值,默认0中文, 具体取值I18nMessage.getLang()
*/
private Integer lang = 0;
/**
* 文件名称
*/
private String fileName;
/**
* 文件路径
*/
private String path;
/**
* 下载地址
*/
private String url;
/**
* 执行结果
*/
private String result;
@ApiModelProperty(value = "文件ID")
private Long fileId;
}
......@@ -189,6 +189,7 @@ public class CustomerApiImpl implements CustomerApi {
customerDTO.setName(customer.getName());
customerDTO.setNumber(customer.getNumber());
customerDTO.setPayerName(customer.getPayerName());
customerDTO.setDefaultBilling(customer.getDefaultBilling() ? 1 : 0);
return customerDTO;
}
}
......@@ -11,4 +11,11 @@ public interface BankApi {
* 根据银行账号id获取账号信息
*/
BankAccountDTO getBankAccountByAccountId(Long id);
/**
* 更新银行账号余额
* @param bankAccountDTO
* @param isAdd
*/
void updateBankAccountBalance(BankAccountDTO bankAccountDTO, boolean isAdd);
}
package cn.iocoder.yudao.module.ecw.api.bank.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BankAccountDTO {
@ApiModelProperty(value = "银行账号编号", required = true)
private Long id;
......
......@@ -45,4 +45,10 @@ public interface CurrencyApi {
*/
ExchangeRateRespDTO getCurrencyRateByCode(String sourceCode, String targetCode);
/**
* 获取所有汇率
* @return
*/
List<ExchangeRateRespDTO> getAllCurrencyRate();
}
......@@ -11,4 +11,6 @@ public class CustomerDTO {
private String name;
private String payerName;
private Integer defaultBilling;
}
......@@ -14,6 +14,18 @@ public class RegionDTO {
@ApiModelProperty(value = "英文")
private String titleEn;
@ApiModelProperty(value = "进口国运费币种")
private String importCurrency1;
@ApiModelProperty(value = "进口国清关费币种")
private String importCurrency2;
@ApiModelProperty(value = "进口国额外费用主币种 (匹配币种一致的金额)")
private String importCurrency3;
@ApiModelProperty(value = "进口国额外费用副币种 (未匹配主币种的金额统一转换为额外费用副币种金额)")
private String importCurrency4;
@ApiModelProperty(value = "进口国应收额币种")
private String importCurrency5;
}
......@@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.ecw.api.bank.dto.BankAccountDTO;
import cn.iocoder.yudao.module.ecw.convert.bankAccount.BankAccountConvert;
import cn.iocoder.yudao.module.ecw.dal.dataobject.bankAccount.BankAccountDO;
import cn.iocoder.yudao.module.ecw.dal.mysql.bankAccount.BankAccountMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -29,4 +30,21 @@ public class BankApiImpl implements BankApi {
BankAccountDO bankAccountDO = bankAccountMapper.selectById(id);
return BankAccountConvert.INSTANCE.convertDTO(bankAccountDO);
}
@Override
public void updateBankAccountBalance(BankAccountDTO bankAccountDTO, boolean isAdd) {
List<BankAccountDO> bankAccountDOS = bankAccountMapper.selectList(Wrappers.lambdaQuery(BankAccountDO.class)
.eq(BankAccountDO::getBaAccountName, bankAccountDTO.getBaAccountName())
.eq(BankAccountDO::getBaAccountNum, bankAccountDTO.getBaAccountNum())
.eq(BankAccountDO::getBaBankName, bankAccountDTO.getBaBankName()));
if (bankAccountDOS != null && !bankAccountDOS.isEmpty()) {
BankAccountDO bankAccountDO = bankAccountDOS.get(0);
if (isAdd) {
bankAccountDO.setBaBalance(bankAccountDO.getBaBalance().add(bankAccountDTO.getBaBalance()));
} else {
bankAccountDO.setBaBalance(bankAccountDO.getBaBalance().subtract(bankAccountDTO.getBaBalance()));
}
bankAccountMapper.updateById(bankAccountDO);
}
}
}
......@@ -195,4 +195,10 @@ public class CurrecyApiImpl implements CurrencyApi {
}
@Override
public List<ExchangeRateRespDTO> getAllCurrencyRate() {
List<ExchangeRateDO> exchangeRateDOS = exchangeRateService.selectList();
return ExchangeRateConvert.INSTANCE.convertList2(exchangeRateDOS);
}
}
......@@ -36,6 +36,10 @@ public class RegionApiImpl implements RegionApi {
regionDTO.setId(regionDO.getId());
regionDTO.setTitleZh(regionDO.getTitleZh());
regionDTO.setTitleEn(regionDO.getTitleEn());
regionDTO.setImportCurrency1(regionDO.getImportCurrency1());
regionDTO.setImportCurrency2(regionDO.getImportCurrency2());
regionDTO.setImportCurrency3(regionDO.getImportCurrency3());
regionDTO.setImportCurrency4(regionDO.getImportCurrency4());
regionDTO.setImportCurrency5(regionDO.getImportCurrency5());
return regionDTO;
}
......
......@@ -101,11 +101,6 @@ public class BankAccountServiceImpl implements BankAccountService {
vo.setBaCountryZh(baCountryDO.getTitleZh());
vo.setBaCountryEn(baCountryDO.getTitleEn());
}
if (vo.getBaIncomeBelong() != null) {
RegionDO baIncomeBelongDO = countryMap.get(vo.getBaIncomeBelong().longValue());
vo.setBaIncomeBelongZh(baIncomeBelongDO.getTitleZh());
vo.setBaIncomeBelongEn(baIncomeBelongDO.getTitleEn());
}
});
return voPageResult;
}
......
......@@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderItem.OrderItemDO;
import cn.iocoder.yudao.module.order.dto.OrderCostSummaryDto;
import cn.iocoder.yudao.module.order.dto.OrderExportBackDTO;
import cn.iocoder.yudao.module.order.dto.OrderBackInfoDto;
import cn.iocoder.yudao.module.order.dto.SearchBackDto;
......@@ -3368,4 +3369,6 @@ public interface OrderMapper extends AbstractMapper<OrderDO> {
void updateOrderCustomerAndSalesmanId(@Param("customerId")Long customerId,@Param("salesmanId") Long salesmanId,@Param("orderId") Long orderId);
StatisticsOrderVO statisticsPickUp(@Param("query") OrderQueryVO query);
List<OrderBackPageVO> containerOrderSummaryList(@Param("query") ContainerReportOrderQueryVO query);
}
......@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Objects;
@Data
@ApiModel("费用分组dto")
......@@ -16,4 +17,21 @@ public class FeeGroupDto {
private Long currencyId;
@ApiModelProperty("货币名称(只展示英文代码)")
private String currencyName;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FeeGroupDto that = (FeeGroupDto) o;
return Objects.equals(currencyId, that.currencyId);
}
@Override
public int hashCode() {
return Objects.hashCode(currencyId);
}
public void addAmount(BigDecimal amount) {
this.amount = this.amount.add(amount);
}
}
......@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.excel.convert.DictConvert;
import cn.iocoder.yudao.module.depository.dto.LogisticsInfoDto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -29,6 +30,7 @@ import static cn.iocoder.yudao.module.bpm.enums.DictTypeConstants.TRANSPORT_TYPE
*/
@Data
@ApiModel("订单费用汇总")
// TODO 表格index待调整
public class OrderCostSummaryDto {
@ExcelProperty(value = "序号", index = 0)
......@@ -73,7 +75,7 @@ public class OrderCostSummaryDto {
@ExcelIgnore
@ApiModelProperty(value = "是否控货")
private Boolean isCargoControl;
private Integer isCargoControl;
// @ExcelIgnore
@ExcelProperty(value = "订单入仓时间", index = 29)
......@@ -151,6 +153,14 @@ public class OrderCostSummaryDto {
@ApiModelProperty(value = "已收运费(货币分组列表转换字符串)")
private String writeOffFreightFeeGroup;
@ExcelIgnore
@ApiModelProperty(value = "未收运费货币分组列表")
private List<FeeGroupDto> notWriteOffFreightFeeGroupDtoList;
@ExcelProperty(value = "未收运费", index = 17)
@ApiModelProperty(value = "未收运费(货币分组列表转换字符串)")
private String notWriteOffFreightFeeGroup;
@ExcelIgnore
@ApiModelProperty(value = "实收清关费")
private BigDecimal netReceiptsClearanceFee;
......@@ -196,9 +206,17 @@ public class OrderCostSummaryDto {
private List<FeeGroupDto> writeOffClearanceFeeGroupDtoList;
@ExcelProperty(value = "已收清关费", index = 21)
@ApiModelProperty(value = "已收额外费用(货币分组列表转换字符串)")
@ApiModelProperty(value = "已收清关费用(货币分组列表转换字符串)")
private String writeOffClearanceFeeGroup;
@ExcelIgnore
@ApiModelProperty(value = "未收清关费货币分组列表")
private List<FeeGroupDto> notWriteOffClearanceFeeGroupDtoList;
@ExcelProperty(value = "未收清关费", index = 21)
@ApiModelProperty(value = "未收清关费用(货币分组列表转换字符串)")
private String notWriteOffClearanceFeeGroup;
@ExcelIgnore
@ApiModelProperty(value = "实收额外费用")
private BigDecimal netReceiptsOtherFee;
......@@ -247,6 +265,14 @@ public class OrderCostSummaryDto {
@ApiModelProperty(value = "已收额外费用(货币分组列表转换字符串)")
private String writeOffOtherFeeGroup;
@ExcelIgnore
@ApiModelProperty(value = "未收额外费用货币分组列表")
private List<FeeGroupDto> notWriteOffOtherFeeGroupDtoList;
@ExcelProperty(value = "未收额外费用", index = 99)
@ApiModelProperty(value = "未收额外费用(货币分组列表转换字符串)")
private String notWriteOffOtherFeeGroup;
@ExcelIgnore
@ApiModelProperty(value = "核销币种(总额计算统一币种,当币种有多个时,以美元计算,否则以当前单一币种计算)")
private Long writeOffCurrencyId;
......@@ -306,6 +332,14 @@ public class OrderCostSummaryDto {
@ApiModelProperty(value = "已收总金额(货币分组列表转换字符串)")
private String writeOffTotalFeeGroup;
@ExcelIgnore
@ApiModelProperty(value = "未收总金额货币分组列表")
private List<FeeGroupDto> notWriteOffTotalFeeGroupDtoList;
@ExcelProperty(value = "未收总金额", index = 99)
@ApiModelProperty(value = "未收总金额(货币分组列表转换字符串)")
private String notWriteOffTotalFeeGroup;
@ExcelProperty(value = "是否全部核销", index = 26)
@ApiModelProperty(value = "是否全部核销")
......@@ -514,6 +548,64 @@ public class OrderCostSummaryDto {
@ApiModelProperty(value = "订单状态")
private String statusMsg;
@ApiModelProperty(value = "财务2.2-提货率")
private BigDecimal pickRatio;
@ApiModelProperty(value = "财务2.2-提单制作状态 2已完成")
private Integer billOfLadingStatus;
@ExcelProperty("收货人客户id")
@ApiModelProperty(value = "财务2.2-收货人客户id")
private Long consigneeCustomerId;
@ExcelProperty("收货人客户编号")
@ApiModelProperty(value = "财务2.2-收货人客户编号")
private String consigneeCustomerNumber;
@ExcelProperty("收货人姓名")
@ApiModelProperty(value = "财务2.2-收货人姓名")
private String consigneeName;
@ExcelProperty("收货人姓名(英文)")
@ApiModelProperty(value = "财务2.2-收货人姓名(英文)")
private String consigneeNameEn;
@ExcelProperty("收货人手机")
@ApiModelProperty(value = "财务2.2-收货人手机")
private String consigneePhone;
@ExcelProperty("发货人姓名")
@ApiModelProperty(value = "财务2.2-发货人姓名")
private String consignorName;
@ExcelProperty("发货人客户id")
@ApiModelProperty(value = "财务2.2-发货人客户id")
private Long consignorCustomerId;
@ExcelProperty("发货人客户编号")
@ApiModelProperty(value = "财务2.2-发货人客户编号")
private String consignorCustomerNumber;
@ExcelProperty("发货人姓名(英文)")
@ApiModelProperty(value = "财务2.2-发货人姓名(英文)")
private String consignorNameEn;
@ExcelProperty("发货人手机")
@ApiModelProperty(value = "财务2.2-发货人手机")
private String consignorPhone;
@ApiModelProperty(value = "财务2.2-到港时间")
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date daogangTime;
@ApiModelProperty(value = "财务2.2-清关时间")
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date qingguanTime;
@ApiModelProperty(value = "财务2.2-已卸柜/出仓时间")
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date unloadTime;
public void setWriteOffProportion(BigDecimal writeOffProportion) {
this.writeOffProportion = writeOffProportion;
......@@ -529,4 +621,17 @@ public class OrderCostSummaryDto {
this.orderTypeName = orderType == 1 ? "否" : "是";
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
OrderCostSummaryDto that = (OrderCostSummaryDto) o;
return Objects.equals(orderId, that.orderId);
}
@Override
public int hashCode() {
return Objects.hashCode(orderId);
}
}
......@@ -416,4 +416,6 @@ public interface OrderQueryService {
* @return true 是拆单子订单 false 否
*/
boolean isSplitOrderChildren(OrderDO orderDO);
ContainerReportOrderPageResult<OrderCostSummaryDto> containerOrderSummary(ContainerReportOrderQueryVO query, PageVO page);
}
......@@ -99,6 +99,7 @@ import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
......@@ -2916,6 +2917,7 @@ public class OrderQueryServiceImpl implements OrderQueryService {
Map<Long, BigDecimal> totalReceivableFreightFeeGroupDtoMap = new HashMap<>();
Map<Long, BigDecimal> totalNetReceiptsFreightFeeGroupDtoMap = new HashMap<>();
Map<Long, BigDecimal> writeOffFreightFeeGroupDtoMap = new HashMap<>();
Map<Long, BigDecimal> notWriteOffFreightFeeGroupDtoMap = new HashMap<>();
long seaFreightCurrencyId = 1L;// 默认
BigDecimal totalReceivableClearanceFee = BigDecimal.ZERO; // 应收总清关费
......@@ -2924,6 +2926,7 @@ public class OrderQueryServiceImpl implements OrderQueryService {
Map<Long, BigDecimal> totalReceivableClearanceFeeGroupDtoMap = new HashMap<>();
Map<Long, BigDecimal> totalNetReceiptsClearanceFeeGroupDtoMap = new HashMap<>();
Map<Long, BigDecimal> writeOffClearanceFeeGroupDtoMap = new HashMap<>();
Map<Long, BigDecimal> notWriteOffClearanceFeeGroupDtoMap = new HashMap<>();
long clearanceFeeCurrencyId = 1L;// 默认
BigDecimal totalReceivableOtherFee = BigDecimal.ZERO; // 应收额外总费用
......@@ -2932,6 +2935,7 @@ public class OrderQueryServiceImpl implements OrderQueryService {
Map<Long, BigDecimal> totalNetReceiptsOtherFeeGroupDtoMap = new HashMap<>();
Map<Long, BigDecimal> totalDiscountOtherFeeGroupDtoMap = new HashMap<>();
Map<Long, BigDecimal> writeOffOtherFeeGroupDtoMap = new HashMap<>();
Map<Long, BigDecimal> notWriteOffOtherFeeGroupDtoMap = new HashMap<>();
long otherFeeCurrencyId = 1L;// 默认
BigDecimal receivableTotalAmount = BigDecimal.ZERO;// 应收总金额
......@@ -2940,6 +2944,7 @@ public class OrderQueryServiceImpl implements OrderQueryService {
Map<Long, BigDecimal> receivableTotalFeeGroupDtoMap = new HashMap<>();
Map<Long, BigDecimal> netReceiptsTotalFeeGroupDtoMap = new HashMap<>();
Map<Long, BigDecimal> writeOffTotalFeeGroupDtoMap = new HashMap<>();
Map<Long, BigDecimal> notWriteOffTotalFeeGroupDtoMap = new HashMap<>();
long writeOffAmountCurrencyId = 1L;// 默认
// 优惠
......@@ -2977,10 +2982,22 @@ public class OrderQueryServiceImpl implements OrderQueryService {
// TODO 应收运费费总额
// TODO 应收清关费总额
// TODO 应收订单总额 这里只会累加订单计价产生的运费与清关费,额外费用这里不累加,如果需要累加需要在应收单中去累加
BigDecimal seaFreight = orderItemBackVO.getSeaFreight().setScale(0, RoundingMode.HALF_UP);
BigDecimal receivableSeaFreight = orderItemBackVO.getReceivableSeaFreight().compareTo(BigDecimal.ZERO) == 0 ? seaFreight : orderItemBackVO.getReceivableSeaFreight();
BigDecimal clearanceFreight = orderItemBackVO.getClearanceFreight().setScale(0, RoundingMode.HALF_UP);
BigDecimal receivableClearanceFreight = orderItemBackVO.getReceivableClearanceFreight().compareTo(BigDecimal.ZERO) == 0 ? clearanceFreight : orderItemBackVO.getReceivableClearanceFreight();
BigDecimal seaFreight = orderItemBackVO.getSeaFreight() == null ? BigDecimal.ZERO : orderItemBackVO.getSeaFreight().setScale(0, RoundingMode.HALF_UP);
BigDecimal receivableSeaFreight;
if (orderItemBackVO.getReceivableSeaFreight() == null || orderItemBackVO.getReceivableSeaFreight().compareTo(BigDecimal.ZERO) == 0) {
receivableSeaFreight = seaFreight;
} else {
receivableSeaFreight = orderItemBackVO.getReceivableSeaFreight();
}
//BigDecimal receivableSeaFreight = orderItemBackVO.getReceivableSeaFreight().compareTo(BigDecimal.ZERO) == 0 ? seaFreight : orderItemBackVO.getReceivableSeaFreight();
BigDecimal clearanceFreight = orderItemBackVO.getClearanceFreight() == null ? BigDecimal.ZERO : orderItemBackVO.getClearanceFreight().setScale(0, RoundingMode.HALF_UP);
BigDecimal receivableClearanceFreight;
if (orderItemBackVO.getReceivableClearanceFreight() == null || orderItemBackVO.getReceivableClearanceFreight().compareTo(BigDecimal.ZERO) == 0) {
receivableClearanceFreight = clearanceFreight;
} else {
receivableClearanceFreight = orderItemBackVO.getReceivableClearanceFreight();
}
//BigDecimal receivableClearanceFreight = orderItemBackVO.getReceivableClearanceFreight().compareTo(BigDecimal.ZERO) == 0 ? clearanceFreight : orderItemBackVO.getReceivableClearanceFreight();
if (allCurrencyIds.size() > 1) {
// 当所有费用的货币不统一时,总的优惠金额需要统一转换成美元来累加处理
// 该订单下清关费多种货币,需要统一转换成美元来累加处理
......@@ -3102,22 +3119,42 @@ public class OrderQueryServiceImpl implements OrderQueryService {
BigDecimal discountFee = Objects.isNull(receivableDO.getDiscountTotal()) ? BigDecimal.ZERO : receivableDO.getDiscountTotal();
BigDecimal receivableFee = receivableDO.getTotalAmount();
BigDecimal netReceiptsFee = receivableDO.getTotalAmount().subtract(discountFee);
if (receivableDO.getState() == 1) {
// 核销中总金额
BigDecimal fee = netReceiptsFee.multiply(writeOffProportion);
if (writeOffTotalFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
writeOffTotalFeeGroupDtoMap.put(receivableDO.getCurrencyId(), fee.add(writeOffTotalFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
} else {
writeOffTotalFeeGroupDtoMap.put(receivableDO.getCurrencyId(), fee);
// 财务2.2-新增的核销金额
BigDecimal writeOffAmountActual = receivableDO.getWriteOffAmount() == null ? BigDecimal.ZERO : receivableDO.getWriteOffAmount();
BigDecimal notWriteOffAmount = BigDecimal.ZERO;
if (receivableDO.getState() != 2 || netReceiptsFee.compareTo(writeOffAmountActual) > 0) {
notWriteOffAmount = netReceiptsFee.subtract(writeOffAmountActual);
}
} else if (receivableDO.getState() == 2) {
// 已核销总金额
// 财务2.2-修改
if (writeOffTotalFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
writeOffTotalFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee.add(writeOffTotalFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
} else {
writeOffTotalFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee);
}
}
writeOffTotalFeeGroupDtoMap.put(receivableDO.getCurrencyId(), writeOffAmountActual.add(writeOffTotalFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
} else {
writeOffTotalFeeGroupDtoMap.put(receivableDO.getCurrencyId(), writeOffAmountActual);
}
// 计算未收
if (notWriteOffAmount.compareTo(BigDecimal.ZERO) > 0) {
if (notWriteOffTotalFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
notWriteOffTotalFeeGroupDtoMap.put(receivableDO.getCurrencyId(), notWriteOffAmount.add(notWriteOffTotalFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
} else {
notWriteOffTotalFeeGroupDtoMap.put(receivableDO.getCurrencyId(), notWriteOffAmount);
}
}
//if (receivableDO.getState() == 1) {
// // 核销中总金额
// BigDecimal fee = netReceiptsFee.multiply(writeOffProportion);
// if (writeOffTotalFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
// writeOffTotalFeeGroupDtoMap.put(receivableDO.getCurrencyId(), fee.add(writeOffTotalFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
// } else {
// writeOffTotalFeeGroupDtoMap.put(receivableDO.getCurrencyId(), fee);
// }
//} else if (receivableDO.getState() == 2) {
// // 已核销总金额
// if (writeOffTotalFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
// writeOffTotalFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee.add(writeOffTotalFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
// } else {
// writeOffTotalFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee);
// }
//}
// 应收单实收金额 = 应收单总额 - 收款优惠金额
ExchangeRateRespDTO exchangeRateRespDTO = exchangeRateRespDTOMap.get(receivableDO.getCurrencyId());
if (Objects.isNull(exchangeRateRespDTO)) {
......@@ -3183,23 +3220,36 @@ public class OrderQueryServiceImpl implements OrderQueryService {
} else {
totalNetReceiptsFreightFeeGroupDtoMap.put(currencyId, discountFee.setScale(0, RoundingMode.HALF_UP).negate());
}
if (receivableDO.getState() == 1) {
// 核销中的金额计算
BigDecimal fee = netReceiptsFee.multiply(writeOffProportion);
// 收款单运费已核销金额
if (writeOffFreightFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
writeOffFreightFeeGroupDtoMap.put(receivableDO.getCurrencyId(), fee.add(writeOffFreightFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
} else {
writeOffFreightFeeGroupDtoMap.put(receivableDO.getCurrencyId(), fee);
}
} else if (receivableDO.getState() == 2) {
// 收款单运费已核销金额
if (writeOffFreightFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
writeOffFreightFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee.add(writeOffFreightFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
} else {
writeOffFreightFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee);
}
}
writeOffFreightFeeGroupDtoMap.put(receivableDO.getCurrencyId(), writeOffAmountActual.add(writeOffFreightFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
} else {
writeOffFreightFeeGroupDtoMap.put(receivableDO.getCurrencyId(), writeOffAmountActual);
}
// 计算未收
if (notWriteOffAmount.compareTo(BigDecimal.ZERO) > 0) {
if (notWriteOffFreightFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
notWriteOffFreightFeeGroupDtoMap.put(receivableDO.getCurrencyId(), notWriteOffAmount.add(notWriteOffFreightFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
} else {
notWriteOffFreightFeeGroupDtoMap.put(receivableDO.getCurrencyId(), notWriteOffAmount);
}
}
//if (receivableDO.getState() == 1) {
// // 核销中的金额计算
// BigDecimal fee = netReceiptsFee.multiply(writeOffProportion);
// // 收款单运费已核销金额
// if (writeOffFreightFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
// writeOffFreightFeeGroupDtoMap.put(receivableDO.getCurrencyId(), fee.add(writeOffFreightFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
// } else {
// writeOffFreightFeeGroupDtoMap.put(receivableDO.getCurrencyId(), fee);
// }
//} else if (receivableDO.getState() == 2) {
// // 收款单运费已核销金额
// if (writeOffFreightFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
// writeOffFreightFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee.add(writeOffFreightFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
// } else {
// writeOffFreightFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee);
// }
//}
if (seaFreightCurrencyIds.size() > 1) {
// 该订单下运费多种货币,需要统一转换成美元来累加处理,实收运费减去收款单的优惠金额
totalNetReceiptsFreightFee = totalNetReceiptsFreightFee.subtract(discountFee.multiply(exchangeRateRespDTO.getCurrencyRate()).setScale(0, RoundingMode.HALF_UP));
......@@ -3215,22 +3265,35 @@ public class OrderQueryServiceImpl implements OrderQueryService {
} else {
totalNetReceiptsClearanceFeeGroupDtoMap.put(currencyId, discountFee.setScale(0, RoundingMode.HALF_UP).negate());
}
if (receivableDO.getState() == 1) {
// 核销中的金额计算
BigDecimal fee = netReceiptsFee.multiply(writeOffProportion);
if (writeOffClearanceFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
writeOffClearanceFeeGroupDtoMap.put(receivableDO.getCurrencyId(), fee.add(writeOffClearanceFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
} else {
writeOffClearanceFeeGroupDtoMap.put(receivableDO.getCurrencyId(), fee);
}
} else if (receivableDO.getState() == 2) {
// 收款单清关费已核销金额
if (writeOffClearanceFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
writeOffClearanceFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee.add(writeOffClearanceFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
} else {
writeOffClearanceFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee);
}
}
writeOffClearanceFeeGroupDtoMap.put(receivableDO.getCurrencyId(), writeOffAmountActual.add(writeOffClearanceFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
} else {
writeOffClearanceFeeGroupDtoMap.put(receivableDO.getCurrencyId(), writeOffAmountActual);
}
// 计算未收
if (notWriteOffAmount.compareTo(BigDecimal.ZERO) > 0) {
if (notWriteOffClearanceFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
notWriteOffClearanceFeeGroupDtoMap.put(receivableDO.getCurrencyId(), notWriteOffAmount.add(notWriteOffClearanceFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
} else {
notWriteOffClearanceFeeGroupDtoMap.put(receivableDO.getCurrencyId(), notWriteOffAmount);
}
}
//if (receivableDO.getState() == 1) {
// // 核销中的金额计算
// BigDecimal fee = netReceiptsFee.multiply(writeOffProportion);
// if (writeOffClearanceFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
// writeOffClearanceFeeGroupDtoMap.put(receivableDO.getCurrencyId(), fee.add(writeOffClearanceFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
// } else {
// writeOffClearanceFeeGroupDtoMap.put(receivableDO.getCurrencyId(), fee);
// }
//} else if (receivableDO.getState() == 2) {
// // 收款单清关费已核销金额
// if (writeOffClearanceFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
// writeOffClearanceFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee.add(writeOffClearanceFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
// } else {
// writeOffClearanceFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee);
// }
//}
// 清关费实收
if (clearanceFreightCurrencyIds.size() > 1) {
// 该订单下清关多种货币,需要统一转换成美元来累加处理,实收金额直接减去收款单优惠
......@@ -3259,23 +3322,36 @@ public class OrderQueryServiceImpl implements OrderQueryService {
} else {
totalNetReceiptsOtherFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee);
}
if (receivableDO.getState() == 1) {
// 核销中的金额计算
BigDecimal fee = netReceiptsFee.multiply(writeOffProportion);
// 额外已核销金额
if (writeOffOtherFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
writeOffOtherFeeGroupDtoMap.put(receivableDO.getCurrencyId(), fee.add(writeOffOtherFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
} else {
writeOffOtherFeeGroupDtoMap.put(receivableDO.getCurrencyId(), fee);
}
} else if (receivableDO.getState() == 2) {
// 额外已核销金额
if (writeOffOtherFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
writeOffOtherFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee.add(writeOffOtherFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
} else {
writeOffOtherFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee);
}
}
writeOffOtherFeeGroupDtoMap.put(receivableDO.getCurrencyId(), writeOffAmountActual.add(writeOffOtherFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
} else {
writeOffOtherFeeGroupDtoMap.put(receivableDO.getCurrencyId(), writeOffAmountActual);
}
// 计算未收
if (notWriteOffAmount.compareTo(BigDecimal.ZERO) > 0) {
if (notWriteOffOtherFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
notWriteOffOtherFeeGroupDtoMap.put(receivableDO.getCurrencyId(), notWriteOffAmount.add(notWriteOffOtherFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
} else {
notWriteOffOtherFeeGroupDtoMap.put(receivableDO.getCurrencyId(), notWriteOffAmount);
}
}
//if (receivableDO.getState() == 1) {
// // 核销中的金额计算
// BigDecimal fee = netReceiptsFee.multiply(writeOffProportion);
// // 额外已核销金额
// if (writeOffOtherFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
// writeOffOtherFeeGroupDtoMap.put(receivableDO.getCurrencyId(), fee.add(writeOffOtherFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
// } else {
// writeOffOtherFeeGroupDtoMap.put(receivableDO.getCurrencyId(), fee);
// }
//} else if (receivableDO.getState() == 2) {
// // 额外已核销金额
// if (writeOffOtherFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
// writeOffOtherFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee.add(writeOffOtherFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
// } else {
// writeOffOtherFeeGroupDtoMap.put(receivableDO.getCurrencyId(), netReceiptsFee);
// }
//}
// 收款单总应收金额
if (receivableTotalFeeGroupDtoMap.containsKey(receivableDO.getCurrencyId())) {
receivableTotalFeeGroupDtoMap.put(receivableDO.getCurrencyId(), receivableDO.getTotalAmount().add(receivableTotalFeeGroupDtoMap.get(receivableDO.getCurrencyId())));
......@@ -3332,6 +3408,12 @@ public class OrderQueryServiceImpl implements OrderQueryService {
this.convertFeeGroup(currencyRespDTOMap, writeOffFreightFeeGroupDtoMap, writeOffFreightFeeGroupDtoList, writeOffFreightFeeGroup);
summaryDto.setWriteOffFreightFeeGroupDtoList(writeOffFreightFeeGroupDtoList);
summaryDto.setWriteOffFreightFeeGroup(writeOffFreightFeeGroup.toString());
// 未收运费分组
StringBuilder notWriteOffFreightFeeGroup = new StringBuilder();
List<FeeGroupDto> notWriteOffFreightFeeGroupDtoList = new ArrayList<>();
this.convertFeeGroup(currencyRespDTOMap, notWriteOffFreightFeeGroupDtoMap, notWriteOffFreightFeeGroupDtoList, notWriteOffFreightFeeGroup);
summaryDto.setNotWriteOffFreightFeeGroupDtoList(notWriteOffFreightFeeGroupDtoList);
summaryDto.setNotWriteOffFreightFeeGroup(notWriteOffFreightFeeGroup.toString());
// 当应收金额为0时,赋予应收金额等于实收金额,拆单子拆单历史数据会有此类情况
totalNetReceiptsFreightFee = totalNetReceiptsFreightFee.setScale(0, RoundingMode.HALF_UP);
......@@ -3366,6 +3448,12 @@ public class OrderQueryServiceImpl implements OrderQueryService {
this.convertFeeGroup(currencyRespDTOMap, writeOffClearanceFeeGroupDtoMap, writeOffClearanceFeeGroupDtoList, writeOffClearanceFeeGroup);
summaryDto.setWriteOffClearanceFeeGroupDtoList(writeOffClearanceFeeGroupDtoList);
summaryDto.setWriteOffClearanceFeeGroup(writeOffClearanceFeeGroup.toString());
// 未收清关费分组
StringBuilder notWriteOffClearanceFeeGroup = new StringBuilder();
List<FeeGroupDto> notWriteOffClearanceFeeGroupDtoList = new ArrayList<>();
this.convertFeeGroup(currencyRespDTOMap, notWriteOffClearanceFeeGroupDtoMap, notWriteOffClearanceFeeGroupDtoList, notWriteOffClearanceFeeGroup);
summaryDto.setNotWriteOffClearanceFeeGroupDtoList(notWriteOffClearanceFeeGroupDtoList);
summaryDto.setNotWriteOffClearanceFeeGroup(notWriteOffClearanceFeeGroup.toString());
totalNetReceiptsClearanceFee = totalNetReceiptsClearanceFee.setScale(0, RoundingMode.HALF_UP);
totalReceivableClearanceFee = totalReceivableClearanceFee.compareTo(BigDecimal.ZERO) == 0 ? totalNetReceiptsClearanceFee : totalReceivableClearanceFee.setScale(0, RoundingMode.HALF_UP);
......@@ -3393,12 +3481,18 @@ public class OrderQueryServiceImpl implements OrderQueryService {
this.convertFeeGroup(currencyRespDTOMap, totalReceivableOtherFeeGroupDtoMap, totalNetReceiptsOtherFeeGroupDtoMap, discountOtherFeeGroupDtoList, discountOtherFeeGroup);
summaryDto.setDiscountOtherFeeGroupDtoList(discountOtherFeeGroupDtoList);
summaryDto.setDiscountOtherFeeGroup(discountOtherFeeGroup.toString());
// 已收清关费分组
// 已收额外费用分组
StringBuilder writeOffOtherFeeGroup = new StringBuilder();
List<FeeGroupDto> writeOffOtherFeeGroupDtoList = new ArrayList<>();
this.convertFeeGroup(currencyRespDTOMap, writeOffOtherFeeGroupDtoMap, writeOffOtherFeeGroupDtoList, writeOffOtherFeeGroup);
summaryDto.setWriteOffOtherFeeGroupDtoList(writeOffOtherFeeGroupDtoList);
summaryDto.setWriteOffOtherFeeGroup(writeOffOtherFeeGroup.toString());
// 未收额外费用分组
StringBuilder notWriteOffOtherFeeGroup = new StringBuilder();
List<FeeGroupDto> notWriteOffOtherFeeGroupDtoList = new ArrayList<>();
this.convertFeeGroup(currencyRespDTOMap, notWriteOffOtherFeeGroupDtoMap, notWriteOffOtherFeeGroupDtoList, notWriteOffOtherFeeGroup);
summaryDto.setNotWriteOffOtherFeeGroupDtoList(notWriteOffOtherFeeGroupDtoList);
summaryDto.setNotWriteOffOtherFeeGroup(notWriteOffOtherFeeGroup.toString());
totalReceivableOtherFee = totalReceivableOtherFee.setScale(0, RoundingMode.HALF_UP);
totalNetReceiptsOtherFee = totalNetReceiptsOtherFee.setScale(0, RoundingMode.HALF_UP);
......@@ -3436,6 +3530,12 @@ public class OrderQueryServiceImpl implements OrderQueryService {
this.convertFeeGroup(currencyRespDTOMap, writeOffTotalFeeGroupDtoMap, writeOffTotalFeeGroupDtoList, writeOffTotalFeeGroup);
summaryDto.setWriteOffTotalFeeGroupDtoList(writeOffTotalFeeGroupDtoList);
summaryDto.setWriteOffTotalFeeGroup(writeOffTotalFeeGroup.toString());
// 未收订单总额分组
StringBuilder notWriteOffTotalFeeGroup = new StringBuilder();
List<FeeGroupDto> notWriteOffTotalFeeGroupDtoList = new ArrayList<>();
this.convertFeeGroup(currencyRespDTOMap, notWriteOffTotalFeeGroupDtoMap, notWriteOffTotalFeeGroupDtoList, notWriteOffTotalFeeGroup);
summaryDto.setNotWriteOffTotalFeeGroupDtoList(notWriteOffTotalFeeGroupDtoList);
summaryDto.setNotWriteOffTotalFeeGroup(notWriteOffTotalFeeGroup.toString());
// 应收总额 - 实收总额 = 总优惠金额
summaryDto.setDiscountTotalAmount(summaryDto.getReceivableTotalAmount().subtract(summaryDto.getNetReceiptsTotalAmount()));
......@@ -3750,4 +3850,60 @@ public class OrderQueryServiceImpl implements OrderQueryService {
}
return Objects.nonNull(orderDO.getParentOrderId()) && orderDO.getParentOrderId() != 0L;
}
@Override
public ContainerReportOrderPageResult<OrderCostSummaryDto> containerOrderSummary(ContainerReportOrderQueryVO query, PageVO page) {
if (Objects.isNull(query.getLang())) {
query.setLang(I18nMessage.getLang());
}
ArrayList<Integer> orderType = new ArrayList<>();
if (query.getIsHeavyCargo() != null && query.getIsHeavyCargo()) {
orderType.add(2);
}
if (query.getIsPaoCargo() != null && query.getIsPaoCargo()) {
orderType.add(3);
}
query.setOrderType(orderType);
log.warn(I18nMessage.getLang().toString());
List<OrderBackPageVO> records = orderMapper.containerOrderSummaryList(query);
if (CollectionUtil.isEmpty(records)) {
return ContainerReportOrderPageResult.empty();
}
List<OrderCostSummaryDto> totalList = records.stream().map(back -> {
OrderCostSummaryDto orderCostSummaryDto = this.getOrderCostSummaryDto(null, back);
orderCostSummaryDto.setIsCargoControl(back.getIsCargoControl() ? 1 : 0);
return orderCostSummaryDto;
}).collect(Collectors.toList());
List<OrderCostSummaryDto> resultList = totalList.subList(page.getPage() - 1, Math.min(page.getPage() * page.getRows(), records.size()));
ContainerReportOrderPageResult<OrderCostSummaryDto> pageResult = new ContainerReportOrderPageResult(resultList, records.size(), page.getRows(), (long) page.getPage(), records.size() / page.getRows() + 1);
// 汇总全部
totalList.stream().forEach(orderCostSummaryDto -> {
boolean isInPage = resultList.contains(orderCostSummaryDto);
updateContainerReportFeeGroupList(pageResult.getReceivableTotalFeeGroupDtoList(), pageResult.getPageReceivableTotalFeeGroupDtoList(), isInPage, orderCostSummaryDto.getReceivableTotalFeeGroupDtoList());
updateContainerReportFeeGroupList(pageResult.getDiscountTotalFeeGroupDtoList(), pageResult.getPageDiscountTotalFeeGroupDtoList(), isInPage, orderCostSummaryDto.getDiscountTotalFeeGroupDtoList());
updateContainerReportFeeGroupList(pageResult.getNetReceiptsTotalFeeGroupDtoList(), pageResult.getPageNetReceiptsTotalFeeGroupDtoList(), isInPage, orderCostSummaryDto.getNetReceiptsTotalFeeGroupDtoList());
updateContainerReportFeeGroupList(pageResult.getWriteOffTotalFeeGroupDtoList(), pageResult.getPageWriteOffTotalFeeGroupDtoList(), isInPage, orderCostSummaryDto.getWriteOffTotalFeeGroupDtoList());
updateContainerReportFeeGroupList(pageResult.getNotWriteOffTotalFeeGroupDtoList(), pageResult.getPageNotWriteOffTotalFeeGroupDtoList(), isInPage, orderCostSummaryDto.getNotWriteOffTotalFeeGroupDtoList());
});
return pageResult;
}
private void updateContainerReportFeeGroupList(List<FeeGroupDto> totalList, List<FeeGroupDto> pageList, boolean isInPage, List<FeeGroupDto> feeGroupDtoList) {
for (FeeGroupDto feeGroupDto : feeGroupDtoList) {
int index = totalList.indexOf(feeGroupDto);
if (index > -1) {
totalList.get(index).addAmount(feeGroupDto.getAmount());
} else {
totalList.add(feeGroupDto);
}
if (isInPage) {
int indexPage = pageList.indexOf(feeGroupDto);
if (indexPage > -1) {
pageList.get(indexPage).addAmount(feeGroupDto.getAmount());
} else {
pageList.add(feeGroupDto);
}
}
}
}
}
package cn.iocoder.yudao.module.order.vo.order;
import cn.iocoder.yudao.module.order.dto.FeeGroupDto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Data
@ApiModel("分页结果")
public final class ContainerReportOrderPageResult<T> implements Serializable {
@ApiModelProperty(value = "数据", required = true)
private List<T> list;
@ApiModelProperty(value = "总量", required = true, example = "0")
private Long total = 0L;
@ApiModelProperty(value = "每页记录数", required = true, example = "10")
private Long rows = 10L;
@ApiModelProperty(value = "当前页数", required = true, example = "1")
private Long page = 1L;
@ApiModelProperty(value = "总页数", required = true, example = "0")
private Long pages = 0L;
@ApiModelProperty(value = "应收总金额货币分组列表")
private List<FeeGroupDto> receivableTotalFeeGroupDtoList = new ArrayList<>();
@ApiModelProperty(value = "优惠总金额货币分组列表")
private List<FeeGroupDto> discountTotalFeeGroupDtoList = new ArrayList<>();
@ApiModelProperty(value = "实收总金额货币分组列表")
private List<FeeGroupDto> netReceiptsTotalFeeGroupDtoList = new ArrayList<>();
@ApiModelProperty(value = "已收总金额货币分组列表")
private List<FeeGroupDto> writeOffTotalFeeGroupDtoList = new ArrayList<>();
@ApiModelProperty(value = "未收总金额货币分组列表")
private List<FeeGroupDto> notWriteOffTotalFeeGroupDtoList = new ArrayList<>();
@ApiModelProperty(value = "当页应收总金额货币分组列表")
private List<FeeGroupDto> pageReceivableTotalFeeGroupDtoList = new ArrayList<>();
@ApiModelProperty(value = "当页优惠总金额货币分组列表")
private List<FeeGroupDto> pageDiscountTotalFeeGroupDtoList = new ArrayList<>();
@ApiModelProperty(value = "当页实收总金额货币分组列表")
private List<FeeGroupDto> pageNetReceiptsTotalFeeGroupDtoList = new ArrayList<>();
@ApiModelProperty(value = "当页已收总金额货币分组列表")
private List<FeeGroupDto> pageWriteOffTotalFeeGroupDtoList = new ArrayList<>();
@ApiModelProperty(value = "当页未收总金额货币分组列表")
private List<FeeGroupDto> pageNotWriteOffTotalFeeGroupDtoList = new ArrayList<>();
public ContainerReportOrderPageResult() {
}
public ContainerReportOrderPageResult(List<T> list, long total) {
this.list = list;
this.total = total;
}
public ContainerReportOrderPageResult(List<T> list, long total, long rows, long page, long pages) {
this.list = list;
this.rows = rows;
this.page = page;
this.pages = pages;
this.total = total;
}
public ContainerReportOrderPageResult(long total) {
this.list = new ArrayList<>();
this.total = total;
}
public static <T> ContainerReportOrderPageResult<T> empty() {
return new ContainerReportOrderPageResult<>();
}
public static <T> ContainerReportOrderPageResult<T> empty(long total) {
return new ContainerReportOrderPageResult<>(total);
}
/****
* 分页转换
* @param pager
* @return
*/
public static <T> ContainerReportOrderPageResult<T> of(IPage<T> pager) {
return new ContainerReportOrderPageResult<>(pager.getRecords(), pager.getTotal(), pager.getSize(), pager.getCurrent(), pager.getPages());
}
/****
* 分页转换
* @param pager
* @return
*/
public static <T> ContainerReportOrderPageResult<T> of(PageInfo<T> pager) {
return new ContainerReportOrderPageResult<>(pager.getList(), pager.getTotal(), pager.getPageSize(), pager.getPageNum(), pager.getPages());
}
}
package cn.iocoder.yudao.module.order.vo.order;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
@ApiModel("管理后台 - 自编号报表订单查询 VO")
public class ContainerReportOrderQueryVO {
@ApiModelProperty(value = "自编号")
@NotBlank(message = "自编号不能为空")
private String containerNumber;
@ApiModelProperty(value = "订单编号")
private String orderNo;
@ApiModelProperty(value = "提单编号")
private String tidanNo;
@ApiModelProperty(value = "唛头")
private String marks;
@ApiModelProperty(value = "发货人客户编号,姓名、手机号搜索")
private String consignorKey;
@ApiModelProperty(value = "收货人客户编号,姓名、手机号搜索")
private String consigneeKey;
@ApiModelProperty(value = "始发仓IDs")
private List<Long> startWarehouseIds;
@ApiModelProperty(value = "目的仓IDs")
private List<Long> destWarehouseIds;
@ApiModelProperty(value = "目的国ids")
private List<Long> destCountryIds;
@ApiModelProperty(value = "目的地ids")
private List<Long> destCityIds;
@ApiModelProperty(value = "订单状态详情见字典:order_status")
private Integer status;
@ApiModelProperty(value = "是否重货")
private Boolean isHeavyCargo;
@ApiModelProperty(value = "是否泡货")
private Boolean isPaoCargo;
@ApiModelProperty(value = "订单类型")
private List<Integer> orderType;
@ApiModelProperty(value = "是否控货")
private Integer isCargoControl;
@ApiModelProperty(value = "不等于提货率")
private BigDecimal nePickRatio;
@ApiModelProperty(value = "小于等于提货率")
private BigDecimal lePickRatio;
@ApiModelProperty(value = "等于提货率")
private BigDecimal eqPickRatio;
@ApiModelProperty(value = "大于等于提货率")
private BigDecimal gePickRatio;
@ApiModelProperty(value = "开始放货锁定收货人到期时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date beginLockConsigneeTime;
@ApiModelProperty(value = "结束放货锁定收货人到期时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date endLockConsigneeTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始送货时间")
private Date beginDeliveryDate;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束送货时间")
private Date endDeliveryDate;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始入仓时间")
private Date beginRucangTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束入仓时间")
private Date endRucangTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始入仓记录时间")
private Date beginWarehouseInTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束入仓记录时间")
private Date endWarehouseInTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始到港时间")
private Date beginDaogangTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束到港时间")
private Date endDaogangTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始清关时间")
private Date beginQingguanTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束清关时间")
private Date endQingguanTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始已预装时间")
private Date beginPreLoadTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束已预装时间")
private Date endPreLoadTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始已装柜时间")
private Date beginLoadTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始出仓时间")
private Date beginOutboundTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束出仓时间")
private Date endOutboundTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始理货时间")
private Date beginTallyTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束理货时间")
private Date endTallyTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始出货时间")
private Date beginShippingTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束出货时间")
private Date endShippingTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束已装柜时间")
private Date endLoadTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始已卸柜时间")
private Date beginUnloadTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束已卸柜时间")
private Date endUnloadTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始提货时间")
private Date beginTakeTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束提货时间")
private Date endTakeTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始提货记录时间")
private Date beginPickUpTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束提货记录时间")
private Date endPickUpTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始拆单时间")
private Date beginSplitTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束拆单时间")
private Date endSplitTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始放货时间")
private Date beginReleaseTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束放货时间")
private Date endReleaseTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始复核时间")
private Date beginCheckTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束复核时间")
private Date endCheckTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始放货时间")
private Date beginPickTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束放货时间")
private Date endPickTime;
@ApiModelProperty(value = "语言")
private Integer lang;
}
package cn.iocoder.yudao.module.order.vo.order;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.common.util.spring.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.i18n.core.I18nMessage;
import cn.iocoder.yudao.module.order.dto.OrderRemindExceptionDto;
import cn.iocoder.yudao.module.order.enums.OrderAbnormalStateEnum;
......@@ -557,6 +558,15 @@ public class OrderBackPageVO {
@ApiModelProperty(value = "到仓重量")
private BigDecimal checkWeight;
@ApiModelProperty(value = "财务2.2-提单制作状态 2已完成")
private Integer billOfLadingStatus;
@ApiModelProperty(value = "财务2.2-到港时间")
private Date daogangTime;
@ApiModelProperty(value = "财务2.2-清关时间")
private Date qingguanTime;
public void setGuanLianOrderStatus(String guanLianOrderStatus) {
this.guanLianOrderStatus = guanLianOrderStatus;
......
......@@ -7594,5 +7594,176 @@
</if>
<include refid="orderQuery"/>
</select>
<select id="containerOrderSummaryList" resultType="cn.iocoder.yudao.module.order.vo.order.OrderBackPageVO">
SELECT
o.*,
w.start_warehouse_name,
w.dst_warehouse_name,
w.start_warehouse_id,
w.dst_warehouse_id,
bl.status as billOfLadingStatus,
norc.id as consignorCustomerId,
norc.number as consignorCustomerNumber,
norc.name as consignorName,
norc.name_en as consignorNameEn,
nor.phone as consignorPhone,
neeo.id as consigneeCustomerId,
neeo.name as consigneeName,
neeo.name_en as consigneeNameEn,
nee.phone as consigneePhone,
neeo.number as consigneeCustomerNumber,
(select su.nickname from system_user su where su.deleted = 0 and su.id = o.salesman_id) as salesman_name,
(select min(wi.`in_time`) from ecw_order_warehouse_in wi where wi.deleted = 0 and wi.order_id = o.order_id ) as in_time
FROM ecw_order o
LEFT JOIN (
SELECT
ewl.id AS line_id,
ew_start.id AS start_warehouse_id,
ew_dest.id AS dst_warehouse_id,
ew_start.title_zh AS start_title_zh,
IF( #{query.lang} = 0, ew_dest.title_zh, ew_dest.title_en ) AS dst_warehouse_name,
IF( #{query.lang} = 0, ew_start.title_zh, ew_start.title_en ) AS start_warehouse_name
FROM
ecw_warehouse_line ewl
LEFT JOIN ecw_warehouse ew_start ON ewl.start_warehouse_id = ew_start.id
LEFT JOIN ecw_warehouse ew_dest ON ewl.dest_warehouse_id = ew_dest.id
) w ON w.line_id = o.line_id
LEFT JOIN ecw_order_consignor nor on nor.order_id = o.order_id and nor.deleted = 0
LEFT JOIN ecw_order_consignee nee on nee.order_id = o.order_id and nee.deleted = 0
LEFT JOIN ecw_make_bill_of_lading bl on bl.order_id = o.order_id and bl.deleted = 0
LEFT JOIN ecw_customer norc on norc.id = nor.customer_id
LEFT JOIN ecw_customer neeo on neeo.id = nee.customer_id
WHERE o.`container_number` = #{query.containerNumber}
</select>
<sql id="containerOrderSummaryQuery">
<if test="query.orderNo != null and query.orderNo != '' ">
AND o.`order_no` like concat("%",concat(#{query.orderNo},"%"))
</if>
<if test="query.tidanNo != null and query.tidanNo != '' ">
AND o.`tidan_no` like concat("%",concat(#{query.tidanNo},"%"))
</if>
<if test="query.marks != null and query.marks != '' ">
AND o.`marks` like concat("%",concat(#{query.marks},"%"))
</if>
<if test="query.consignorKey != null and query.consignorKey != '' ">
AND (concat(IFNULL(nor.`name`,''),IFNULL(nor.`name_en`,''),IFNULL(nor.`phone`,'')) like
concat("%",concat(#{query.consignorKey},"%"))
OR nor.customer_id in (select c.id from ecw_customer c where c.number like
concat("%",concat(#{query.consignorKey},"%"))))
</if>
<if test="query.consigneeKey != null and query.consigneeKey != '' ">
AND (concat(IFNULL(nee.`name`,''),IFNULL(nee.`name_en`,''),IFNULL(nee.`phone`,'')) like
concat("%",concat(#{query.consigneeKey},"%"))
OR nee.customer_id in (select c.id from ecw_customer c where c.number like
concat("%",concat(#{query.consigneeKey},"%"))))
</if>
<if test="query.startWarehouseIds !=null and query.startWarehouseIds.size() > 0 and query.destWarehouseIds !=null and query.destWarehouseIds.size() > 0 ">
and (o.line_id in(
select whl.id
from ecw_warehouse_line whl
where whl.start_warehouse_id in
<foreach item='warehouseId' collection='query.startWarehouseIds' open='(' separator=',' close=')'>
#{warehouseId}
</foreach>
and whl.dest_warehouse_id in
<foreach item='destWarehouseId' collection='query.destWarehouseIds' open='(' separator=',' close=')'>
#{destWarehouseId}
</foreach>
))
</if>
<if test="query.startWarehouseIds !=null and query.startWarehouseIds.size() > 0 and (query.destWarehouseIds==null or query.destWarehouseIds.size() == 0) ">
and (o.line_id in(
select whl.id
from ecw_warehouse_line whl
where whl.start_warehouse_id in
<foreach item='warehouseId' collection='query.startWarehouseIds' open='(' separator=',' close=')'>
#{warehouseId}
</foreach>
))
</if>
<if test="(query.startWarehouseIds ==null or query.startWarehouseIds.size() == 0) and query.destWarehouseIds !=null and query.destWarehouseIds.size() > 0 ">
and (o.line_id in(
select whl.id
from ecw_warehouse_line whl
where whl.dest_warehouse_id in
<foreach item='destWarehouseId' collection='query.destWarehouseIds' open='(' separator=',' close=')'>
#{destWarehouseId}
</foreach>
))
</if>
<if test="query.destCountryIds != null and query.destCountryIds.size()>0 ">
AND ob.`objective_country_id` in
<foreach item='destCountryId' index='index' collection='query.destCountryIds' open='(' separator=',' close=')'>
#{destCountryId}
</foreach>
</if>
<if test="query.status != null">
AND o.`status` = #{query.status}
</if>
<if test="query.lePickRatio != null ">
AND o.pick_ratio <![CDATA[ <= ]]> #{query.lePickRatio}
</if>
<if test="query.gePickRatio != null ">
AND o.pick_ratio <![CDATA[ >= ]]> #{query.gePickRatio}
</if>
<if test="query.eqPickRatio != null ">
AND o.pick_ratio = #{query.eqPickRatio}
</if>
<if test="query.eqPickRatio != null ">
AND o.pick_ratio <![CDATA[ != ]]> #{query.eqPickRatio}
</if>
<if test="query.isCargoControl != null ">
AND o.is_cargo_control = #{query.isCargoControl}
</if>
<if test="query.orderType != null and query.orderType.size()>0 ">
AND o.`order_type` in
<foreach item='item' index='index' collection='query.orderType' open='(' separator=',' close=')'>
#{item}
</foreach>
</if>
<if test="query.beginRucangTime != null and query.endRucangTime != null ">
AND o.order_id in(select distinct wi.order_id from ecw_order_warehouse_in wi where wi.deleted = 0 and
wi.`in_time` between #{query.beginRucangTime} and #{query.endRucangTime})
</if>
<if test="query.beginQingguanTime != null and query.endQingguanTime != null ">
AND o.`qingguan_time` between #{query.beginQingguanTime} and #{query.endQingguanTime}
</if>
<if test="query.beginDaogangTime != null and query.endDaogangTime != null ">
AND o.`daogang_time` between #{query.beginDaogangTime} and #{query.endDaogangTime}
</if>
<if test="query.beginPreLoadTime != null and query.endPreLoadTime != null ">
AND o.`status` > 5 AND o.`pre_load_time` between #{query.beginPreLoadTime} and #{query.endPreLoadTime}
</if>
<if test="query.beginOutboundTime != null and query.endOutboundTime != null ">
AND o.`status` > 5 AND o.container_number in(select distinct b.self_no from ecw_box_air_checkout bc join ecw_box b ON bc.shipment_id = b.id
where b.deleted = 0 and bc.deleted = 0 and bc.`checkout_time` between #{query.beginOutboundTime} and #{query.endOutboundTime})
</if>
<if test="query.beginLoadTime != null and query.endLoadTime != null ">
AND o.`status` > 5 AND o.`load_time` between #{query.beginLoadTime} and #{query.endLoadTime}
</if>
<if test="query.beginUnloadTime != null and query.endUnloadTime != null ">
AND o.`status` > 5 AND o.`unload_time` between #{query.beginUnloadTime} and #{query.endUnloadTime}
</if>
<if test="query.beginTakeTime != null and query.endTakeTime != null ">
AND o.`status` > 19 AND o.`take_time` between #{query.beginTakeTime} and #{query.endTakeTime}
</if>
<if test="query.beginSplitTime != null and query.endSplitTime != null ">
AND o.`split_time` between #{query.beginSplitTime} and #{query.endSplitTime}
</if>
<if test="query.beginCreateTime != null and query.endCreateTime != null ">
AND o.`create_time` between #{query.beginCreateTime} and #{query.endCreateTime}
</if>
<if test="query.beginPickTime != null and query.endPickTime != null ">
AND o.order_id in(select distinct op.order_id from ecw_order_cargo_control_pick op where op.deleted = 0 and
op.status in(1,3) and op.`create_time` between #{query.beginPickTime} and #{query.endPickTime})
</if>
<if test="query.beginPickUpTime != null and query.endPickUpTime != null ">
AND o.order_no in(select distinct op.order_id from ecw_order_pickup op where op.deleted = 0 and
op.`create_time` between #{query.beginPickUpTime} and #{query.endPickUpTime})
</if>
<if test="query.beginWarehouseInTime != null and query.endWarehouseInTime != null ">
AND o.order_id in(select distinct wi.order_id from ecw_order_warehouse_in wi where wi.deleted = 0 and
wi.`update_time` between #{query.beginWarehouseInTime} and #{query.endWarehouseInTime})
</if>
</sql>
</mapper>
......@@ -8,6 +8,8 @@ import cn.iocoder.yudao.module.order.dto.OrderCostSummaryDto;
import cn.iocoder.yudao.module.order.dto.OrderDetailSummaryDto;
import cn.iocoder.yudao.module.order.service.order.OrderQueryService;
import cn.iocoder.yudao.module.order.service.orderException.OrderExceptionService;
import cn.iocoder.yudao.module.order.vo.order.ContainerReportOrderPageResult;
import cn.iocoder.yudao.module.order.vo.order.ContainerReportOrderQueryVO;
import cn.iocoder.yudao.module.order.vo.order.OrderBackPageVO;
import cn.iocoder.yudao.module.order.vo.order.OrderQueryVO;
import io.swagger.annotations.Api;
......@@ -17,10 +19,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
......@@ -81,4 +80,14 @@ public class OrderCountController {
return success(orderQueryService.orderDetailSummaryByOrderId(orderId));
}
@PostMapping("/containerNumber/orderSummary/new")
@ApiOperation("财务2.2-自编号的订单费用汇总")
public CommonResult<ContainerReportOrderPageResult<OrderCostSummaryDto>> orderSummaryNew(@RequestBody ContainerReportOrderQueryVO query, PageVO page) {
if (StringUtils.isBlank(query.getContainerNumber())) {
return error(CONTAINER_NUMBER_NOT_NULL);
}
ContainerReportOrderPageResult<OrderCostSummaryDto> summaryDtoPage = orderQueryService.containerOrderSummary(query, page);
return success(summaryDtoPage);
}
}
package cn.iocoder.yudao.module.shipment.listener;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.apollo.core.event.export.ShipmentSummeryNewExcelExportPushEvent;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.i18n.core.I18nMessage;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.ecw.api.currency.CurrencyApi;
import cn.iocoder.yudao.module.ecw.api.currency.dto.CurrencyRespDTO;
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
import cn.iocoder.yudao.module.infra.service.file.FileService;
import cn.iocoder.yudao.module.system.framework.ue.UeProperties;
import cn.iocoder.yudao.module.wealth.service.receivable.ReceivableService;
import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableBoxReportPageVO;
import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableBoxReportQueryVO;
import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableBoxReportVO;
import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableCurrencyAmount;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.fill.FillConfig;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.excel.constant.ExportConstant.DATA_FORMAT;
@Component("ShipmentSummeryNewExcelExportListener")
@AllArgsConstructor
@Slf4j
public class ShipmentSummeryNewExcelExportListener {
private ReceivableService receivableService;
private UeProperties ueProperties;
private FileService fileService;
private CurrencyApi currencyApi;
@EventListener(ShipmentSummeryNewExcelExportPushEvent.class)
public void shipmentSummeryNewExcelExportPushEvent(ShipmentSummeryNewExcelExportPushEvent event) {
if (StringUtils.isNotBlank(event.getRequestParams())) {
try {
PageVO page = new PageVO();
page.setRows(10000);
page.setPage(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATA_FORMAT);
String nowTime = formatter.format(LocalDateTime.now());
String dir = ueProperties.getTempDir().concat("/shipmentSummery/excel/new/");
File fileDir = new File(dir);
if (!fileDir.exists()) {
fileDir.mkdirs();
}
String fileName = event.getUserId().toString().concat(StrUtil.DASHED).concat(event.getUserType().toString()).concat(StrUtil.DASHED).concat(nowTime).concat("shipment_summery.xlsx");
JSONObject jsonObject = JSONObject.parseObject(event.getRequestParams());
String queryString = jsonObject.getString("query");
ReceivableBoxReportQueryVO query = JSONObject.parseObject(queryString, ReceivableBoxReportQueryVO.class);
ReceivableBoxReportVO boxPage = receivableService.getReceivableBoxReport(query, page);
List<ReceivableBoxReportPageVO> records = boxPage.getList();
Map headMap = new HashMap();
if (CollectionUtil.isNotEmpty(records)) {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream(ueProperties.getTemplatesUrl() + "/box_finance_new.xlsx");
String nameZh = "新自编号报表汇总统计";
String nameEn = "New Summary Statistics of Shipment";
String sheetName = I18nMessage.getLang() == 0 ? nameZh : nameEn;
List<Map<String, Object>> list = new ArrayList<>();
for (ReceivableBoxReportPageVO item : records) {
String jsTime = DateUtils.formatDate(item.getSlSettledTime());
Map<String, Object> map = new HashMap<>();
map.put("jsTime", jsTime);
map.put("selfNo", item.getSelfNo());
map.put("huizong", item.getReceivableTotalSummary());
map.put("jsBee", item.getReceivableTotalSettle());
map.put("yfFee", item.getReceivableDetailFreight());
map.put("qgfFee", item.getReceivableDetailClearance());
map.put("ewFee", item.getReceivableDetailOtherFee());
map.put("myfFee", item.getReceivableDestCountryFreight());
map.put("mqgfFee", item.getReceivableDestCountryClearance());
map.put("mewFee", item.getReceivableDestCountryOtherFee());
map.put("mewfFee", item.getReceivableDestCountryOtherFeeSub());
map.put("syfFee", item.getReceivableStartCountryFreight());
map.put("sqgfFee", item.getReceivableStartCountryClearance());
map.put("sewFee", item.getReceivableStartCountryOtherFee());
map.put("sewfFee", item.getReceivableStartCountryOtherFeeSub());
map.put("zyfFee", item.getReceivableDiscountFreight());
map.put("zqgfFee", item.getReceivableDiscountClearance());
map.put("zewFee", item.getReceivableDiscountOtherFee());
map.put("wyfFee", item.getReceivableUnsettledFreight());
map.put("wqgfFee", item.getReceivableUnsettledClearance());
map.put("wewFee", item.getReceivableUnsettledOtherFee());
map.put("hxbl", item.getWriteOffPercent() + "%");
Integer ladingBillStatus = item.getLadingBillStatus();
if (ladingBillStatus == null) {
map.put("tdzz", "");
} else if (ladingBillStatus == 0) {
map.put("tdzz", "未完成");
} else if (ladingBillStatus == 1) {
map.put("tdzz", "部分完成");
} else if (ladingBillStatus == 2) {
map.put("tdzz", "已完成");
}
map.put("dgsj", DateUtils.formatDate(item.getDgDate()));
map.put("qgsh", DateUtils.formatDate(item.getQgDate()));
map.put("xgsj", DateUtils.formatDate(item.getUlWarehouseTime()));
list.add(map);
}
ReceivableBoxReportVO.Amount pageAmount = boxPage.getPageAmount();
Map<Integer, CurrencyRespDTO> allCurrency = currencyApi.getAllCurrency();
headMap.put("totaHuizong", getHuizong(pageAmount.getReceivableTotalSummary(), allCurrency));
headMap.put("totalJsBee", getHuizong(pageAmount.getReceivableTotalSettle(), allCurrency));
headMap.put("totalYfFee", getHuizong(pageAmount.getReceivableDetailFreight(), allCurrency));
headMap.put("totalQgfFee", getHuizong(pageAmount.getReceivableDetailClearance(), allCurrency));
headMap.put("totalEwFee", getHuizong(pageAmount.getReceivableDetailOtherFee(), allCurrency));
headMap.put("totalMfyFee", getHuizong(pageAmount.getReceivableDestCountryFreight(), allCurrency));
headMap.put("totalMqgfFee", getHuizong(pageAmount.getReceivableDestCountryClearance(), allCurrency));
headMap.put("totalMewFee", getHuizong(pageAmount.getReceivableDestCountryOtherFee(), allCurrency));
headMap.put("totalMewfFee", getHuizong(pageAmount.getReceivableDestCountryOtherFeeSub(), allCurrency));
headMap.put("totalSyfFee", getHuizong(pageAmount.getReceivableStartCountryFreight(), allCurrency));
headMap.put("totalSqgfFee", getHuizong(pageAmount.getReceivableStartCountryClearance(), allCurrency));
headMap.put("totalSewFee", getHuizong(pageAmount.getReceivableStartCountryOtherFee(), allCurrency));
headMap.put("totalSewfFee", getHuizong(pageAmount.getReceivableStartCountryOtherFeeSub(), allCurrency));
headMap.put("totalZyfFee", getHuizong(pageAmount.getReceivableDiscountFreight(), allCurrency));
headMap.put("totalZqgfFee", getHuizong(pageAmount.getReceivableDiscountClearance(), allCurrency));
headMap.put("totalZewFee", getHuizong(pageAmount.getReceivableDiscountOtherFee(), allCurrency));
headMap.put("totalWyfFee", getHuizong(pageAmount.getReceivableUnsettledFreight(), allCurrency));
headMap.put("totalWqgfFee", getHuizong(pageAmount.getReceivableUnsettledClearance(), allCurrency));
headMap.put("totalWewFee", getHuizong(pageAmount.getReceivableUnsettledOtherFee(), allCurrency));
ExcelWriter excelWriter = EasyExcel.write(dir + fileName).withTemplate(inputStream).build();
WriteSheet sheet = EasyExcel.writerSheet(0).build();
sheet.setSheetName(sheetName);
FillConfig fillConfig = FillConfig.builder().forceNewRow(true).build();
excelWriter.fill(headMap, sheet);
excelWriter.fill(list, fillConfig, sheet);
excelWriter.finish();
inputStream.close();
} else {
ExcelWriter excelWriter = EasyExcel.write(dir + fileName).build();
WriteSheet sheet = EasyExcel.writerSheet(0).build();
excelWriter.write(null, sheet);
excelWriter.finish();
}
// 获取到临时文件
File file = new File(dir + fileName);
// 创建FileInputStream对象
FileInputStream fileInputStream = new FileInputStream(file);
// 读取文件内容
byte[] fileBytes = new byte[(int) file.length()];
fileInputStream.read(fileBytes);
// 关闭文件流
fileInputStream.close();
// 将文件上传到资源服务器
FileDO fileDO = fileService.createFile(dir, fileName, fileBytes);
event.setPath(fileDO.getPath());
event.setFileName(fileDO.getPath());
event.setUrl(fileDO.getUrl());
event.setFileId(fileDO.getId());
} catch (Exception e) {
// TODO 测试阶段打印堆栈错误信息,便于分析原因
e.printStackTrace();
event.setResult(e.getMessage());
}
} else {
event.setResult("param fail");
}
}
private String getHuizong(List<ReceivableCurrencyAmount> receivableTotalSummary,Map<Integer, CurrencyRespDTO> allCurrency) {
StringBuilder sb = new StringBuilder();
for (ReceivableCurrencyAmount receivableCurrencyAmount : receivableTotalSummary) {
sb.append(allCurrency.get(receivableCurrencyAmount.getCurrencyId().intValue()).getFuhao()).append(" ").append(receivableCurrencyAmount.getAmount()).append(", ");
}
return sb.substring(0, sb.length() - 2);
}
}
......@@ -22,6 +22,7 @@ import cn.iocoder.yudao.module.system.api.file.FileMakeApi;
import cn.iocoder.yudao.module.system.api.file.dto.FileMakeReqDTO;
import cn.iocoder.yudao.module.system.enums.download.DownloadTypeEnum;
import cn.iocoder.yudao.module.system.enums.sms.SmsNodeEnum;
import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableBoxReportQueryVO;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -359,4 +360,22 @@ public class BoxController {
fileMakeApi.sendFileMake(reqDTO);
return success("");
}
@GetMapping("/export-shipment-summary/new")
@ApiOperation("导出自编号汇总列表 Excel")
@OperateLog(type = EXPORT)
public CommonResult exportOrderSummaryNew(ReceivableBoxReportQueryVO query, HttpServletResponse response) throws Exception {
FileMakeReqDTO reqDTO = new FileMakeReqDTO();
JSONObject jsonObject = new JSONObject();
jsonObject.put("query", JSONObject.toJSONString(query));
reqDTO.setType(DownloadTypeEnum.SHIPMENT_SUMMERY_EXCEL_EXPORT_NEW.getType());
reqDTO.setName("新出货应收报表");
reqDTO.setFileSuffix("xlsx");
reqDTO.setTemporaryFile(true);
reqDTO.setUserType(2);
reqDTO.setLang(I18nMessage.getLang());
reqDTO.setRequestParams(jsonObject.toJSONString());
fileMakeApi.sendFileMake(reqDTO);
return success("");
}
}
......@@ -187,6 +187,11 @@ public enum DownloadTypeEnum implements IntArrayValuable {
*/
CUSTOMER_FOLLOWUP_EXPORT(34),
/**
* 新应收报表导出
*/
SHIPMENT_SUMMERY_EXCEL_EXPORT_NEW(35)
// ....自己补充
;
......
......@@ -347,6 +347,10 @@ public class DownloadLogServiceImpl extends AbstractService<DownloadLogMapper, D
case SHIPMENT_SUMMERY_EXCEL_EXPORT:
shipmentSummeryExcelExportPushEvent(downloadLog);
break;
//新自编号应收报表导出
case SHIPMENT_SUMMERY_EXCEL_EXPORT_NEW:
shipmentSummeryNewExcelExportPushEvent(downloadLog);
break;
case SHIPMENT_SEA_PRELOAD_EXCEL_EXPORT:
//海运预装单导出
shipmentSeaPreloadExcelExportPushEvent(downloadLog);
......@@ -465,6 +469,20 @@ public class DownloadLogServiceImpl extends AbstractService<DownloadLogMapper, D
downloadLog.setFileId(event.getFileId());
}
private void shipmentSummeryNewExcelExportPushEvent(DownloadLogDO downloadLog) {
ShipmentSummeryNewExcelExportPushEvent event = new ShipmentSummeryNewExcelExportPushEvent();
event.setUserId(downloadLog.getUserId());
event.setUserType(downloadLog.getUserType());
event.setLang(downloadLog.getLang());
event.setRequestParams(downloadLog.getRequestParams());
applicationContext.publishEvent(event);
downloadLog.setFileName(event.getFileName());
downloadLog.setPath(event.getPath());
downloadLog.setDownloadUrl(event.getUrl());
downloadLog.setResult(event.getResult());
downloadLog.setFileId(event.getFileId());
}
private void airBillReceivableExcelExportPushEvent(DownloadLogDO downloadLog) {
AirBillReceivableExcelExportPushEvent event = new AirBillReceivableExcelExportPushEvent();
event.setUserId(downloadLog.getUserId());
......
......@@ -34,6 +34,10 @@ public class ReceiptItemDO extends BaseDO {
* 收款单id
*/
private Long receiptId;
/**
* 收款账号id
*/
private Long accountId;
/**
* 收款账号
*/
......
......@@ -173,5 +173,16 @@ public class ReceivableDO extends BaseDO {
* 备注
*/
private String remark;
/**
* 目的国相关币种id(用于报表,跟费用类型相关)
*/
private Long destCountryCurrencyId;
/**
* 目的国相关汇率(用于报表,跟费用类型相关)
*/
private BigDecimal destCountryRate;
/**
* 额外费用副币种汇率(用于报表,跟费用类型相关)
*/
private BigDecimal destCountrySubRate;
}
......@@ -16,7 +16,10 @@ import java.math.BigDecimal;
public class ReceivableWriteOffRecordDO extends BaseDO {
@TableId
private Long id;
private Long orderId;
private Long receivableId;
private Long receiptItemId;
private BigDecimal writeOffAmount;
private BigDecimal receivableWriteOffAmount;
private Integer incomeBelong;
}
......@@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.wealth.vo.receiptItem.CurrencyAmount;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemQueryVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemReviewPageReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemReviewPageVO;
import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableIncomeBelong;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -17,6 +18,7 @@ import org.apache.ibatis.annotations.Select;
import java.math.BigDecimal;
import java.util.List;
import java.util.Set;
/**
* 收款单明细 Mapper
......@@ -99,4 +101,6 @@ public interface ReceiptItemMapper extends AbstractMapper<ReceiptItemDO> {
List<CurrencyAmount> countTotalActualAmount();
List<CurrencyAmount> countTotalWriteOffAmount();
List<ReceivableIncomeBelong> selectAllWriteOffItemByOrders(@Param("orderIds") Set<Long> orderIds);
}
......@@ -12,6 +12,7 @@ import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
/**
* 应收款 Mapper
......@@ -428,4 +429,12 @@ public interface ReceivableMapper extends AbstractMapper<ReceivableDO> {
IPage<BatchGenReceiptReceivablePageVO> batchGenReceiptReceivablePage(IPage<BatchGenReceiptReceivablePageVO> mpPage, @Param("query") BatchGenReceiptReceivablePageQueryVO query);
List<CurrencyAmount> batchGenReceiptReceivablAmount(@Param("query") BatchGenReceiptReceivablePageQueryVO query);
List<ReceivableBoxReportPageVO> getReceivableBoxPage(@Param("query") ReceivableBoxReportQueryVO query);
List<ReceivebleBoxRelationOrder> getReceivableBoxRelationOrders(@Param("shipmentIdList") List<Long> shipmentIdList);
List<ReceivableDO> selectBoxReceivablesByOrderIds(@Param("orderIds") Set<Long> orderIds);
List<Long> getAllBoxId();
}
\ No newline at end of file
package cn.iocoder.yudao.module.wealth.enums;
public interface BoxReportConstant {
/**
* 自编号数据汇总缓存key
*/
String BOX_AMOUNT_CACHE = "wealth:report:boxAmount:";
/**
* 报表查询结果缓存key
*/
String BOX_REPORT_QUERY_CACHE = "wealth:report:query";
/**
* 报表查询条件缓存key
*/
String BOX_REPORT_QUERY_CONDITION_CACHE = "wealth:report:condition";
/**
* 本年度报表缓存
*/
String BOX_REPORT_CURRENT_YEAR_CACHE = "wealth:report:currentYear";
}
......@@ -216,40 +216,6 @@ public class FinanceReceiptApproveService {
receiptService.recordLog(receiptDO.getId(), ReceiptLinkEnum.REJECT_WRITE_OFF_RECEIPT, comment, WorkFlowEmus.FINANCE_RECEIPT_WRITE_OFF_NO.getValue());
} else if (StrUtil.equals(WorkFlowEmus.FINANCE_RECEIPT_ITEM_WRITE_OFF.getKey(), bmpKey)) {
//收款单明细核销审核
//if (null == receiptApprovalDO.getReceiptItemId()) {
// throw exception(RECEIPT_ITEM_NOT_FOUND);
//}
//ReceiptItemDO receiptItemDO = receiptItemMapper.selectById(receiptApprovalDO.getReceiptItemId());
//if (null == receiptItemDO) {
// throw exception(RECEIPT_ITEM_NOT_FOUND);
//}
//ReceiptItemDO updateReceiptItem = new ReceiptItemDO();
//updateReceiptItem.setId(receiptItemDO.getId());
//updateReceiptItem.setBmpStatus(result);
//if (result == BpmProcessInstanceResultEnum.APPROVE.getResult()) {
// updateReceiptItem.setStatus(ReceiptItemStatusEnum.WRITE_OFF.getValue());
// updateReceiptItem.setApprovalTime(new Date());
// //判断收款单状态如果是待核销状态-变成部分核销状态,其它 状态不变
// ReceiptDO receiptDO = receiptMapper.selectById(receiptItemDO.getReceiptId());
// if (null != receiptDO && receiptDO.getState().equals(ReceiptStatusEnum.WRITE_OFF_WAITING.getValue())) {
// ReceiptDO updateReceipt = new ReceiptDO();
// updateReceipt.setId(receiptDO.getId());
// updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_PART_ING.getValue());
// receiptMapper.updateById(updateReceipt);
//
// //更新收该收款单下的应收为收款中状态
// LambdaUpdateWrapper<ReceivableDO> lambdaUpdateWrapper = new LambdaUpdateWrapper();
// lambdaUpdateWrapper.eq(ReceivableDO::getReceiptId, receiptDO.getId());
// lambdaUpdateWrapper.set(ReceivableDO::getState, 1);
// receivableService.update(lambdaUpdateWrapper);
// }
// receiptService.updateReceiptItemStatus(receiptItemDO.getReceiptId());
//} else if (result == BpmProcessInstanceResultEnum.REJECT.getResult()) {
// updateReceiptItem.setStatus(ReceiptItemStatusEnum.WRITE_OFF_APPROVE_REJECT.getValue());
//} else if (result == BpmProcessInstanceResultEnum.CANCEL.getResult()) {
// updateReceiptItem.setStatus(ReceiptItemStatusEnum.DRAFT.getValue());
//}
//receiptItemMapper.updateById(updateReceiptItem);
applicationContext.publishEvent(new ReceiptItemWriteOffEvent(receiptApprovalDO.getReceiptItemId(), result, comment));
} else if (StrUtil.equals(WorkFlowEmus.FINANCE_RECEIPT_ITEM_WRITE_OFF_NO.getKey(), bmpKey)) {
//收款单明细核销反审核
......@@ -301,6 +267,7 @@ public class FinanceReceiptApproveService {
receiptItemMapper.update(null, updateWrapper);
}
receiptService.recordLog(receiptItemDO.getReceiptId(), ReceiptLinkEnum.REJECT_BANK_RECEIPT, comment, WorkFlowEmus.FINANCE_RECEIPT_ITEM_WRITE_OFF_NO.getValue());
// TODO 更新银行账号余额
}
ReceiptApprovalDO updateReceiptApproval = new ReceiptApprovalDO();
updateReceiptApproval.setId(receiptApprovalDO.getId());
......
......@@ -740,7 +740,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
//bmpStatus
//PROCESS(1, "处理中"),APPROVE(2, "通过"),
//REJECT(3, "不通过"),CANCEL(4, "已取消");
long Item0 = listItem.stream().filter(i -> i.getStatus() == 0).filter(i -> i.getReceiptId() == ReceiptId).collect(Collectors.counting());
long Item0 = listItem.stream().filter(i -> i.getStatus() == 0 || i.getStatus() == 4).filter(i -> i.getReceiptId() == ReceiptId).collect(Collectors.counting());
long Item1 = listItem.stream().filter(i -> i.getStatus() == 1).filter(i -> i.getReceiptId() == ReceiptId).collect(Collectors.counting());
long Item2 = listItem.stream().filter(i -> i.getStatus() == 2).filter(i -> i.getReceiptId() == ReceiptId).collect(Collectors.counting());
long Item3 = listItem.stream().filter(i -> i.getStatus() == 3).filter(i -> i.getReceiptId() == ReceiptId).collect(Collectors.counting());
......@@ -1163,7 +1163,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
if (countItem == 0) {
receiptItemStatus = ReceiptItemStatusInReceiptEnum.NO_INPUT;
} else {
long draft = listItem.stream().filter(i -> Objects.equals(i.getStatus(), DRAFT.getValue())).count();
long draft = listItem.stream().filter(i -> Objects.equals(i.getStatus(), DRAFT.getValue()) || Objects.equals(i.getStatus(), WRITE_OFF_APPROVE_REJECT.getValue())).count();
long writeOff = listItem.stream().filter(i -> Objects.equals(i.getStatus(), WRITE_OFF.getValue())).count();
long writeOffApproving = listItem.stream().filter(i -> Objects.equals(i.getStatus(), WRITE_OFF_APPROVE_ING.getValue())).count();
long writeOffNoApproving = listItem.stream().filter(i -> Objects.equals(i.getStatus(), WRITE_OFF_NO_APPROVE_ING.getValue())).count();
......
......@@ -56,7 +56,7 @@ public class BankReceiptDetailsImpl implements BankReceiptDetailsService {
}
r.setAttrList(getFileList(r.getAttr()));
if(r.getCreateBpm()==null|| r.getCreator().isEmpty()) {
if (r.getCreateBpm() == null || r.getCreator().isEmpty()) {
r.setCreateBpm("");
} else {
Long l2 = Long.parseLong(r.getCreateBpm());
......@@ -70,6 +70,9 @@ public class BankReceiptDetailsImpl implements BankReceiptDetailsService {
@Override
public BankIncomePageResult<BankIncomeItemResp> getBankIncomeItemPage(BankIncomeItemReq req) {
if (req.getIsIncome() != null && req.getIsIncome() == 1) {
return BankIncomePageResult.empty();
}
IPage<BankIncomeItemResp> mpPage = MyBatisUtils.buildPage(req);
bankReceiptDetailsMapper.getBankIncomeItemPage(mpPage, req);
if (mpPage.getTotal() == 0) {
......
......@@ -122,10 +122,11 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
ReceiptItemDO receiptItem = ReceiptItemConvert.INSTANCE.convert(createReqVO);
receiptItem.setSerialNumber(wealthGenCodeUtils.generateReceiptItemCode());
receiptItemMapper.insert(receiptItem);
// 生成应收明细核销记录
BankAccountDTO account = bankApi.getBankAccountByAccountId(receiptItem.getAccountId());
Integer incomeBelong = account.getBaIncomeBelong();
for (ReceivableWriteOffReqVO receivableWriteOffReqVO : createReqVO.getReceivableWriteOffList()) {
receivableService.createWriteOffRecord(receivableWriteOffReqVO, receiptItem);
receivableService.createWriteOffRecord(receivableWriteOffReqVO, receiptItem, incomeBelong);
}
// TODO 校验当前收款单汇率是否过期,过期则更新为导入的汇率 没过期不更新?更新汇率后有效期是啥?
//if (receiptDO.getRateValidateDate().before(new Date())) {
......@@ -177,14 +178,15 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
}
// 删除之前的核销记录
receivableService.deleteWriteOffRecord(receiptItemDO);
// 生成应收明细核销记录
for (ReceivableWriteOffReqVO receivableWriteOffReqVO : updateReqVO.getReceivableWriteOffList()) {
receivableService.createWriteOffRecord(receivableWriteOffReqVO, receiptItemDO);
}
// 更新
ReceiptItemDO updateObj = ReceiptItemConvert.INSTANCE.convert(updateReqVO);
receiptItemMapper.updateById(updateObj);
BankAccountDTO account = bankApi.getBankAccountByAccountId(updateObj.getAccountId());
Integer incomeBelong = account.getBaIncomeBelong();
// 生成应收明细核销记录
for (ReceivableWriteOffReqVO receivableWriteOffReqVO : updateReqVO.getReceivableWriteOffList()) {
receivableService.createWriteOffRecord(receivableWriteOffReqVO, receiptItemDO, incomeBelong);
}
}
/*
......@@ -243,7 +245,7 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
@Override
@Transactional(rollbackFor = Exception.class)
public void verification(Long id, Integer bpmResult,String comment) {
public void verification(Long id, Integer bpmResult, String comment) {
//收款单明细核销审核
if (null == id) {
throw exception(RECEIPT_ITEM_NOT_FOUND);
......@@ -279,12 +281,18 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
receivableDO.setState(1);
ReceivableWriteOffRecordDO receivableWriteOffRecordDO = receivableService.getReceivableWriteOffRecord(receivableDO.getId(), receiptItemDO.getId());
if (null != receivableWriteOffRecordDO) {
BigDecimal writeOffCurrent = receivableWriteOffRecordDO.getWriteOffAmount().divide(receivableDO.getExchangeRate(),4, RoundingMode.HALF_UP);
BigDecimal writeOffCurrent = receivableWriteOffRecordDO.getWriteOffAmount().divide(receivableDO.getExchangeRate(), 4, RoundingMode.HALF_UP);
receivableDO.setWriteOffAmount(receivableDO.getWriteOffAmount().add(writeOffCurrent));
}
}
receivableService.updateBatchById(receivableDOS);
receiptService.updateReceiptItemStatus(receiptItemDO.getReceiptId());
// 更新银行账户余额
bankApi.updateBankAccountBalance(BankAccountDTO.builder()
.baAccountName(receiptItemDO.getAccountName())
.baAccountNum(receiptItemDO.getAccountNo())
.baBankName(receiptItemDO.getAccountBankName())
.baBalance(receiptItemDO.getAmount()).build(), true);
}
// 审核拒绝
else if (Objects.equals(bpmResult, BpmProcessInstanceResultEnum.REJECT.getResult())) {
......@@ -677,7 +685,7 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
});
throw exception(new ErrorCode(haveError ? 1004520042 : 1004520043, errorMsg.toString()));
}
ReceiptItemService proxy = (ReceiptItemService)AopContext.currentProxy();
ReceiptItemService proxy = (ReceiptItemService) AopContext.currentProxy();
for (ReceiptItemCreateReqVO receiptItemCreateReqVO : receiptItemCreateReqVOS) {
// 计算每条应收明细的核销金额
List<ReceivableInItemVO> listForCreateReceiptItem = receivableService.getListForCreateReceiptItem(receiptItemCreateReqVO.getReceiptId());
......@@ -741,8 +749,8 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
ReceiptItemBackVO itemBackVO = ReceiptItemConvert.INSTANCE.convert(receiptItemDO);
ReceiptDO receiptDO = receiptMapper.selectById(receiptItemDO.getReceiptId());
itemBackVO.setReceiptNo(receiptDO.getReceiptNo());
List<ReceivableInItemVO> listForCreateReceiptItem = receivableService.getReceivableByReceiptItem(receiptItemDO.getId());
itemBackVO.setReceivableList(listForCreateReceiptItem);
List<ReceivableInItemVO> receivableList = receivableService.getReceivableByReceiptItem(receiptItemDO.getId());
itemBackVO.setReceivableList(receivableList);
return itemBackVO;
}
......@@ -872,6 +880,7 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
// 生成创建明细
ReceiptItemCreateReqVO receiptItemCreateReqVO = new ReceiptItemCreateReqVO();
receiptItemCreateReqVO.setReceiptId(matchReceiptDO.getId());
receiptItemCreateReqVO.setAccountId(batchCreateReqVO.getAccountId());
receiptItemCreateReqVO.setAccountNo(batchCreateReqVO.getPayAccount());
receiptItemCreateReqVO.setAccountName(batchCreateReqVO.getAccountName());
receiptItemCreateReqVO.setAccountBankName(batchCreateReqVO.getAccountBankName());
......@@ -955,6 +964,7 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
if (null == account) {
return new ReceiptItemBatchRespVO(createReqVO.getOrderNo(), createReqVO.getPayer(), 0, "收款账号不存在");
}
createReqVO.setAccountId(account.getId());
createReqVO.setAccountName(account.getBaAccountName());
createReqVO.setAccountBankName(account.getBaBankName());
if (account.getBaCurrency() != null && !allCurrency.get(account.getBaCurrency()).getFuhao().equals(createReqVO.getPayCurrency())) {
......
......@@ -271,7 +271,7 @@ public interface ReceivableService extends IService<ReceivableDO> {
Long getDestCountryCurrencyId(Long orderId);
void createWriteOffRecord(ReceivableWriteOffReqVO receivableWriteOffReqVO, ReceiptItemDO receiptItem);
void createWriteOffRecord(ReceivableWriteOffReqVO receivableWriteOffReqVO, ReceiptItemDO receiptItem, Integer incomeBelong);
ReceivableWriteOffRecordDO getReceivableWriteOffRecord(Long receivableId, Long receiptItemId);
......@@ -282,4 +282,8 @@ public interface ReceivableService extends IService<ReceivableDO> {
List<ReceivableInItemVO> getReceivableByReceiptItem(Long receiptItemId);
ReceivablePageResult<BatchGenReceiptReceivablePageVO> batchGenReceiptReceivablePage(BatchGenReceiptReceivablePageQueryVO query, PageVO page);
ReceivableBoxReportVO getReceivableBoxReport(@Valid ReceivableBoxReportQueryVO query, PageVO page);
void updateBoxAmountCache(List<Long> shipmentIdList, boolean isForceUpdate);
}
package cn.iocoder.yudao.module.wealth.service.receivable;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.iocoder.boot.module.order.api.OrderApi;
import cn.iocoder.yudao.framework.apollo.core.event.Order.OrderOperateLogEvent;
import cn.iocoder.yudao.framework.apollo.core.vo.ApplyInfoVO;
......@@ -11,6 +12,7 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.service.AbstractService;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.framework.redis.helper.RedisHelper;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.ecw.api.currency.CurrencyApi;
......@@ -35,11 +37,17 @@ import cn.iocoder.yudao.module.wealth.service.receipt.ReceiptService;
import cn.iocoder.yudao.module.wealth.service.receivableDiscount.ReceivableDiscountService;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.CurrencyAmount;
import cn.iocoder.yudao.module.wealth.vo.receivable.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
......@@ -53,6 +61,7 @@ import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.wealth.enums.BoxReportConstant.*;
import static cn.iocoder.yudao.module.wealth.enums.ErrorCodeConstants.*;
/**
......@@ -62,6 +71,7 @@ import static cn.iocoder.yudao.module.wealth.enums.ErrorCodeConstants.*;
*/
@Service
@Validated
@Slf4j
public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, ReceivableDO> implements ReceivableService {
@Resource
......@@ -88,6 +98,8 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
private ReceivableWriteOffRecordMapper receivableWriteOffRecordMapper;
@Resource
private ReceiptItemMapper receiptItemMapper;
@Resource
private RedisHelper redisHelper;
@Override
public Long createReceivable(ReceivableCreateReqVO createReqVO) {
......@@ -103,8 +115,29 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
receivable.setCreator(creator);
receivable.setUpdateTime(new Date());
receivable.setUpdater(creator);
// 设置基准币种
receivable.setBaseCurrencyId(getDestCountryCurrencyId(createReqVO.getOrderId()));
// 设置相关币种
Long countryId = orderApi.getDestCountryByOrderId(createReqVO.getOrderId());
RegionDTO regionInfo = regionApi.getRegionById(countryId);
if (regionInfo != null) {
receivable.setBaseCurrencyId(Long.parseLong(regionInfo.getImportCurrency5()));
int feeType = getFeeType(receivable.getFeeType());
// 运费
if (feeType == 0) {
receivable.setDestCountryCurrencyId(Long.parseLong(regionInfo.getImportCurrency1()));
receivable.setDestCountryRate(currencyApi.getCurrencyRate(receivable.getCurrencyId(), receivable.getDestCountryCurrencyId()).getCurrencyRate());
}
// 清关费
if (feeType == 1) {
receivable.setDestCountryCurrencyId(Long.parseLong(regionInfo.getImportCurrency2()));
receivable.setDestCountryRate(currencyApi.getCurrencyRate(receivable.getCurrencyId(), receivable.getDestCountryCurrencyId()).getCurrencyRate());
}
// 额外费用
if (feeType == 2) {
receivable.setDestCountryCurrencyId(Long.parseLong(regionInfo.getImportCurrency3()));
receivable.setDestCountryRate(currencyApi.getCurrencyRate(receivable.getCurrencyId(), receivable.getDestCountryCurrencyId()).getCurrencyRate());
}
receivable.setDestCountrySubRate(currencyApi.getCurrencyRate(receivable.getCurrencyId(), Long.parseLong(regionInfo.getImportCurrency4())).getCurrencyRate());
}
this.save(receivable);
// 返回
return receivable.getId();
......@@ -580,11 +613,11 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
CustomerDTO customer;
if (vo.getDrawee().equals(1)) {
customer = customerApi.getCustomerInfo(vo.getConsignorId());
vo.setPayerId(vo.getConsignorId());
} else {
customer = customerApi.getCustomerInfo(vo.getConsigneeId());
vo.setPayerId(vo.getConsigneeId());
}
vo.setPayerId(customer.getId());
vo.setOpenInvoice(customer.getDefaultBilling());
vo.setCustomerName(customer.getName());
vo.setCustomerNo(customer.getNumber());
vo.setPayerName(vo.getPayerName());
......@@ -603,15 +636,25 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
}
@Override
public void createWriteOffRecord(ReceivableWriteOffReqVO receivableWriteOffReqVO, ReceiptItemDO receiptItem) {
public void createWriteOffRecord(ReceivableWriteOffReqVO receivableWriteOffReqVO, ReceiptItemDO receiptItem, Integer incomeBelong) {
ReceivableDO receivableDO = receivableMapper.selectById(receivableWriteOffReqVO.getReceivableId());
if (receivableDO == null) {
throw exception(RECEIVABLE_NOT_EXISTS);
}
BigDecimal receivableWriteOffAmount;
ExchangeRateRespDTO currencyRate = currencyApi.getCurrencyRate(receiptItem.getWriteOffCurrencyId(), receivableDO.getCurrencyId());
if (currencyRate == null) {
receivableWriteOffAmount = receivableWriteOffReqVO.getWriteOffAmount();
} else {
receivableWriteOffAmount = receivableWriteOffReqVO.getWriteOffAmount().multiply(currencyRate.getCurrencyRate());
}
ReceivableWriteOffRecordDO writeOffRecord = ReceivableWriteOffRecordDO.builder()
.receivableId(receivableWriteOffReqVO.getReceivableId())
.writeOffAmount(receivableWriteOffReqVO.getWriteOffAmount())
.receiptItemId(receiptItem.getId())
.incomeBelong(incomeBelong)
.receivableWriteOffAmount(receivableWriteOffAmount)
.orderId(receivableDO.getOrderId())
.build();
receivableWriteOffRecordMapper.insert(writeOffRecord);
}
......@@ -678,4 +721,571 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
public void deleteWriteOffRecord(ReceiptItemDO receiptItemDO) {
receivableWriteOffRecordMapper.deleteWriteOffRecord(receiptItemDO.getId());
}
@Override
public ReceivableBoxReportVO getReceivableBoxReport(ReceivableBoxReportQueryVO query, PageVO page) {
// 打开页面默认选择到港时间为本年度的数据,按结算时间倒序,卸柜/到仓时间倒序,清关时间倒序,到港时间倒序
ReceivableBoxReportVO receivableBoxReport = null;
Boolean isCurrentYearQuery = query.isEmpty();
if (isCurrentYearQuery) {
String currentYearVOCache = redisHelper.get(BOX_REPORT_CURRENT_YEAR_CACHE);
if (currentYearVOCache != null) {
receivableBoxReport = JSON.parseObject(currentYearVOCache, ReceivableBoxReportVO.class);
}
query.setBeginDaogangTime(DateUtil.beginOfYear(new Date()));
query.setEndDaogangTime(new Date());
}
// 查询报表缓存
String queryJson = JSON.toJSONString(query);
if (!query.getForceUpdateCache() && receivableBoxReport == null) {
receivableBoxReport = getReceivableBoxReportCache(queryJson);
}
if (receivableBoxReport != null) {
if (receivableBoxReport.getPage().intValue() == page.getPage() && receivableBoxReport.getRows() == page.getRows()) {
return receivableBoxReport;
}
// 如果只是分页条件不同,重新获取分页列表
receivableBoxReport.setPage(page.getPage().longValue());
receivableBoxReport.setRows((long) page.getRows());
List<ReceivableBoxReportPageVO> records = receivableMapper.getReceivableBoxPage(query);
List<ReceivableBoxReportPageVO> pageVOList = records.subList(page.getPage() - 1, Math.min(page.getPage() * page.getRows(), records.size()));
if (CollectionUtil.isEmpty(records) || CollectionUtil.isEmpty(pageVOList)) {
receivableBoxReport.setList(pageVOList);
return receivableBoxReport;
}
// 获取当页自编号对应的订单
List<Long> shipmentIdList = pageVOList.stream().map(ReceivableBoxReportPageVO::getId).collect(Collectors.toList());
List<ReceivebleBoxRelationOrder> relationOrders = receivableMapper.getReceivableBoxRelationOrders(shipmentIdList);
Map<Long, List<ReceivebleBoxRelationOrder>> relationOrderMap = relationOrders.stream().collect(Collectors.groupingBy(ReceivebleBoxRelationOrder::getShipmentId));
Map<Integer, CurrencyRespDTO> allCurrency = currencyApi.getAllCurrency();
List<ExchangeRateRespDTO> allCurrencyRate = currencyApi.getAllCurrencyRate();
ReceivableBoxReportVO.Amount pageAmount = new ReceivableBoxReportVO.Amount();
assembleReportAmount(pageVOList, relationOrderMap, allCurrencyRate, allCurrency, null, pageVOList, pageAmount);
receivableBoxReport.setList(pageVOList);
redisHelper.set(BOX_REPORT_QUERY_CACHE, JSON.toJSONString(receivableBoxReport));
return receivableBoxReport;
}
// 该查询条件所有的自编号列表
List<ReceivableBoxReportPageVO> records = receivableMapper.getReceivableBoxPage(query);
// 按查询条件排序
records.sort(Comparator.comparing(ReceivableBoxReportPageVO::getSlSettledTime).reversed()
.thenComparing(ReceivableBoxReportPageVO::getUlWarehouseTime).reversed()
.thenComparing(ReceivableBoxReportPageVO::getQgDate).reversed()
.thenComparing(ReceivableBoxReportPageVO::getDgDate).reversed());
List<ReceivableBoxReportPageVO> pageVOList = records.subList(page.getPage() - 1, Math.min(page.getPage() * page.getRows(), records.size()));
ReceivableBoxReportVO.ReceivableBoxReportVOBuilder voBuilder = ReceivableBoxReportVO.builder()
.list(pageVOList)
.total((long) records.size())
.rows((long) page.getRows())
.page((long) page.getPage())
.pages((long) (records.size() / page.getRows() + 1));
if (CollectionUtil.isEmpty(records)) {
return voBuilder.build();
}
// 获取所有自编号对应的订单
List<Long> shipmentIdList = records.stream().map(ReceivableBoxReportPageVO::getId).collect(Collectors.toList());
List<ReceivebleBoxRelationOrder> relationOrders = receivableMapper.getReceivableBoxRelationOrders(shipmentIdList);
Map<Long, List<ReceivebleBoxRelationOrder>> relationOrderMap = relationOrders.stream().collect(Collectors.groupingBy(ReceivebleBoxRelationOrder::getShipmentId));
Map<Integer, CurrencyRespDTO> allCurrency = currencyApi.getAllCurrency();
List<ExchangeRateRespDTO> allCurrencyRate = currencyApi.getAllCurrencyRate();
ReceivableBoxReportVO.Amount pageAmount = new ReceivableBoxReportVO.Amount();
ReceivableBoxReportVO.Amount queryAmount = new ReceivableBoxReportVO.Amount();
assembleReportAmount(records, relationOrderMap, allCurrencyRate, allCurrency, queryAmount, pageVOList, pageAmount);
ReceivableBoxReportVO reportVO = voBuilder
.pageAmount(pageAmount)
.queryAmount(queryAmount)
.build();
if (isCurrentYearQuery) {
redisHelper.set(BOX_REPORT_CURRENT_YEAR_CACHE, JSON.toJSONString(reportVO));
} else {
redisHelper.set(BOX_REPORT_QUERY_CONDITION_CACHE, queryJson);
redisHelper.set(BOX_REPORT_QUERY_CACHE, JSON.toJSONString(reportVO));
}
return reportVO;
}
/**
* 整合报表金额数据
*
* @param records
* @param relationOrderMap
* @param allCurrencyRate
* @param allCurrency
* @param queryAmount
* @param pageVOList
* @param pageAmount
*/
private void assembleReportAmount(List<ReceivableBoxReportPageVO> records, Map<Long, List<ReceivebleBoxRelationOrder>> relationOrderMap, List<ExchangeRateRespDTO> allCurrencyRate, Map<Integer, CurrencyRespDTO> allCurrency, ReceivableBoxReportVO.Amount queryAmount, List<ReceivableBoxReportPageVO> pageVOList, ReceivableBoxReportVO.Amount pageAmount) {
for (ReceivableBoxReportPageVO record : records) {
setLadingBillStatus(record);
ReceivableBoxAmount receivableBoxAmount;
String receivableBoxAmountCache = redisHelper.get(BOX_AMOUNT_CACHE + record.getId());
if (receivableBoxAmountCache != null) {
receivableBoxAmount = JSONObject.parseObject(receivableBoxAmountCache, ReceivableBoxAmount.class);
} else {
List<ReceivebleBoxRelationOrder> orders = relationOrderMap.get(record.getId());
if (CollectionUtil.isEmpty(orders)) {
continue;
}
Set<Long> orderIdSets = orders.stream().map(ReceivebleBoxRelationOrder::getOrderId).collect(Collectors.toSet());
RegionDTO regionInfo = regionApi.getRegionById(record.getDestCountryId());
if (null == regionInfo) {
continue;
}
// 查询该自编号所有的明细
List<ReceivableDO> boxReceivables = receivableMapper.selectBoxReceivablesByOrderIds(orderIdSets);
if (CollectionUtil.isEmpty(boxReceivables)) {
continue;
}
List<ReceivableIncomeBelong> receivableIncomeBelongs = receiptItemMapper.selectAllWriteOffItemByOrders(orderIdSets);
Map<Long, List<ReceivableIncomeBelong>> receivableIncomeBelongMap = new HashMap<>();
if (CollectionUtil.isNotEmpty(receivableIncomeBelongs)) {
// 根据明细id分组
receivableIncomeBelongMap = receivableIncomeBelongs.stream().collect(Collectors.groupingBy(ReceivableIncomeBelong::getReceivableId));
}
receivableBoxAmount = this.computeReceivableBoxSummary(boxReceivables, regionInfo, receivableIncomeBelongMap, allCurrencyRate);
redisHelper.set(BOX_AMOUNT_CACHE + record.getId(), JSONObject.toJSONString(receivableBoxAmount), 60 * 60 * 24);
}
// 整合数据给返回赋值
assembleRecord(receivableBoxAmount, record, allCurrency);
if (queryAmount != null) {
mergeAmount(queryAmount, receivableBoxAmount);
}
if (pageVOList.contains(record)) {
mergeAmount(pageAmount, receivableBoxAmount);
}
}
}
/**
* 更新某个自编号的缓存
*/
@Override
public void updateBoxAmountCache(List<Long> shipmentIdList, boolean isForceUpdate) {
if (CollectionUtil.isEmpty(shipmentIdList)) {
return;
}
List<ReceivebleBoxRelationOrder> relationOrders = receivableMapper.getReceivableBoxRelationOrders(shipmentIdList);
Map<Long, List<ReceivebleBoxRelationOrder>> relationOrderMap = relationOrders.stream().collect(Collectors.groupingBy(ReceivebleBoxRelationOrder::getShipmentId));
List<ExchangeRateRespDTO> allCurrencyRate = currencyApi.getAllCurrencyRate();
for (Long boxId : shipmentIdList) {
if (redisHelper.hasKey(BOX_AMOUNT_CACHE + boxId) && !isForceUpdate) {
continue;
}
List<ReceivebleBoxRelationOrder> orders = relationOrderMap.get(boxId);
if (CollectionUtil.isEmpty(orders)) {
continue;
}
Set<Long> orderIdSets = orders.stream().map(ReceivebleBoxRelationOrder::getOrderId).collect(Collectors.toSet());
RegionDTO regionInfo = regionApi.getRegionById(orders.get(0).getDestCountryId());
if (null == regionInfo) {
continue;
}
// 查询该自编号所有的明细
List<ReceivableDO> boxReceivables = receivableMapper.selectBoxReceivablesByOrderIds(orderIdSets);
if (CollectionUtil.isEmpty(boxReceivables)) {
continue;
}
List<ReceivableIncomeBelong> receivableIncomeBelongs = receiptItemMapper.selectAllWriteOffItemByOrders(orderIdSets);
Map<Long, List<ReceivableIncomeBelong>> receivableIncomeBelongMap = new HashMap<>();
if (CollectionUtil.isNotEmpty(receivableIncomeBelongs)) {
// 根据明细id分组
receivableIncomeBelongMap = receivableIncomeBelongs.stream().collect(Collectors.groupingBy(ReceivableIncomeBelong::getReceivableId));
}
ReceivableBoxAmount receivableBoxAmount = this.computeReceivableBoxSummary(boxReceivables, regionInfo, receivableIncomeBelongMap, allCurrencyRate);
redisHelper.set(BOX_AMOUNT_CACHE + boxId, JSONObject.toJSONString(receivableBoxAmount), 60 * 60 * 24);
}
}
/**
* 查询报表缓存
*/
private ReceivableBoxReportVO getReceivableBoxReportCache(String queryJson) {
String boxReportQueryConditionCache = redisHelper.get(BOX_REPORT_QUERY_CONDITION_CACHE);
if (boxReportQueryConditionCache != null) {
if (boxReportQueryConditionCache.equals(queryJson)) {
String boxReportCache = redisHelper.get(BOX_REPORT_QUERY_CACHE);
if (boxReportCache != null) {
return JSON.parseObject(boxReportCache, ReceivableBoxReportVO.class);
}
}
}
return null;
}
@Scheduled(cron = "0 0 0 * * ?")
public void updateBoxAmountCacheScheduled() {
List<Long> boxIds = receivableMapper.getAllBoxId();
updateBoxAmountCache(boxIds, true);
}
/**
* 计算自编号收款
*
* @param boxReceivables
* @param regionInfo
*/
private ReceivableBoxAmount computeReceivableBoxSummary(List<ReceivableDO> boxReceivables,
RegionDTO regionInfo,
Map<Long, List<ReceivableIncomeBelong>> receivableIncomeBelongMap,
List<ExchangeRateRespDTO> allCurrencyRate) {
Long freightCurrency = Long.valueOf(regionInfo.getImportCurrency1());
Long clearanceCurrency = Long.valueOf(regionInfo.getImportCurrency2());
Long otherFeeCurrency = Long.valueOf(regionInfo.getImportCurrency3());
Long otherSubCurrency = Long.valueOf(regionInfo.getImportCurrency4());
Long receivableCurrency = Long.valueOf(regionInfo.getImportCurrency5());
ReceivableBoxAmount receivableBoxAmount = new ReceivableBoxAmount(freightCurrency, clearanceCurrency, otherFeeCurrency, otherSubCurrency, receivableCurrency);
for (ReceivableDO boxReceivable : boxReceivables) {
// 应收款-汇总
ReceivableCurrencyAmount currencyAmount = new ReceivableCurrencyAmount(boxReceivable.getCurrencyId(), boxReceivable.getTaxAmount() == null ? boxReceivable.getTotalAmount() : boxReceivable.getTaxAmount().subtract(boxReceivable.getDiscountTotal() == null ? BigDecimal.ZERO : boxReceivable.getDiscountTotal()));
int index = receivableBoxAmount.receivableTotalSummary.indexOf(currencyAmount);
if (index >= 0) {
receivableBoxAmount.receivableTotalSummary.get(index).addAmount(currencyAmount.getAmount());
} else {
receivableBoxAmount.receivableTotalSummary.add(currencyAmount);
}
// 应收款-结算币种
if (boxReceivable.getCurrencyId().equals(receivableCurrency)) {
receivableBoxAmount.receivableTotalSettle.addAmount(currencyAmount.getAmount());
} else {
receivableBoxAmount.receivableTotalSettle.addAmount(currencyAmount.getAmount().multiply(getExchangeRate(allCurrencyRate, boxReceivable.getCurrencyId(), receivableCurrency)));
}
// 判断属于哪种费用 0运费,1 清关费,2 额外费用
Integer feeType = this.getFeeType(boxReceivable.getFeeType());
// TODO 折扣金额计算的成交单价和原价暂时不知道哪拿,先只取优惠金额
BigDecimal discount = boxReceivable.getDiscountTotal() == null ? BigDecimal.ZERO : boxReceivable.getDiscountTotal();
BigDecimal notWrittenOff = Objects.equals(boxReceivable.getWriteOffAmount(), BigDecimal.ZERO) ? currencyAmount.getAmount() : currencyAmount.getAmount().subtract(boxReceivable.getWriteOffAmount());
BigDecimal freightRate = getExchangeRate(allCurrencyRate, boxReceivable.getCurrencyId(), freightCurrency);
BigDecimal clearanceRate = getExchangeRate(allCurrencyRate, boxReceivable.getCurrencyId(), clearanceCurrency);
BigDecimal otherFeeRate = getExchangeRate(allCurrencyRate, boxReceivable.getCurrencyId(), otherFeeCurrency);
BigDecimal otherSubRate = getExchangeRate(allCurrencyRate, freightCurrency, otherSubCurrency);
List<ReceivableIncomeBelong> receivableIncomeBelongs = receivableIncomeBelongMap.get(boxReceivable.getId());
switch (feeType) {
case 0:
if (boxReceivable.getCurrencyId().equals(freightCurrency)) {
receivableBoxAmount.receivableDetailFreight.addAmount(currencyAmount.getAmount());
receivableBoxAmount.receivableDiscountFreight.addAmount(discount);
receivableBoxAmount.receivableUnsettledFreight.addAmount(notWrittenOff);
} else {
receivableBoxAmount.receivableDetailFreight.addAmount(currencyAmount.getAmount().multiply(boxReceivable.getDestCountryRate() != null ? boxReceivable.getDestCountryRate() : freightRate));
receivableBoxAmount.receivableDiscountFreight.addAmount(discount.multiply(boxReceivable.getDestCountryRate() != null ? boxReceivable.getDestCountryRate() : freightRate));
receivableBoxAmount.receivableUnsettledFreight.addAmount(notWrittenOff.multiply(boxReceivable.getDestCountryRate() != null ? boxReceivable.getDestCountryRate() : freightRate));
}
// 计算始发国或目的国实收
if (receivableIncomeBelongs != null) {
for (ReceivableIncomeBelong receivableIncomeBelong : receivableIncomeBelongs) {
if (receivableIncomeBelong.getIncomeBelong() == 1) {
receivableBoxAmount.receivableStartCountryFreight.addAmount(receivableIncomeBelong.getWriteOffAmount().multiply(boxReceivable.getDestCountryRate() != null ? boxReceivable.getDestCountryRate() : freightRate));
} else if (receivableIncomeBelong.getIncomeBelong() == 0) {
receivableBoxAmount.receivableDestCountryFreight.addAmount(receivableIncomeBelong.getWriteOffAmount().multiply(boxReceivable.getDestCountryRate() != null ? boxReceivable.getDestCountryRate() : freightRate));
}
}
}
break;
case 1:
if (boxReceivable.getCurrencyId().equals(clearanceCurrency)) {
receivableBoxAmount.receivableDetailClearance.addAmount(currencyAmount.getAmount());
receivableBoxAmount.receivableDiscountClearance.addAmount(discount);
receivableBoxAmount.receivableUnsettledClearance.addAmount(notWrittenOff);
} else {
receivableBoxAmount.receivableDetailClearance.addAmount(currencyAmount.getAmount().multiply(boxReceivable.getDestCountryRate() != null ? boxReceivable.getDestCountryRate() : clearanceRate));
receivableBoxAmount.receivableDiscountClearance.addAmount(discount.multiply(boxReceivable.getDestCountryRate() != null ? boxReceivable.getDestCountryRate() : clearanceRate));
receivableBoxAmount.receivableUnsettledClearance.addAmount(notWrittenOff.multiply(boxReceivable.getDestCountryRate() != null ? boxReceivable.getDestCountryRate() : clearanceRate));
}
// 计算始发国或目的国实收
if (receivableIncomeBelongs != null) {
for (ReceivableIncomeBelong receivableIncomeBelong : receivableIncomeBelongs) {
if (receivableIncomeBelong.getIncomeBelong() == 1) {
receivableBoxAmount.receivableStartCountryClearance.addAmount(receivableIncomeBelong.getWriteOffAmount().multiply(boxReceivable.getDestCountryRate() != null ? boxReceivable.getDestCountryRate() : clearanceRate));
} else if (receivableIncomeBelong.getIncomeBelong() == 0) {
receivableBoxAmount.receivableDestCountryClearance.addAmount(receivableIncomeBelong.getWriteOffAmount().multiply(boxReceivable.getDestCountryRate() != null ? boxReceivable.getDestCountryRate() : clearanceRate));
}
}
}
break;
case 2:
if (boxReceivable.getCurrencyId().equals(otherFeeCurrency)) {
receivableBoxAmount.receivableDetailOtherFee.addAmount(currencyAmount.getAmount());
receivableBoxAmount.receivableDiscountOtherFee.addAmount(discount);
receivableBoxAmount.receivableUnsettledOtherFee.addAmount(notWrittenOff);
} else {
receivableBoxAmount.receivableDetailOtherFee.addAmount(currencyAmount.getAmount().multiply(boxReceivable.getDestCountryRate() != null ? boxReceivable.getDestCountryRate() : otherFeeRate));
receivableBoxAmount.receivableDiscountOtherFee.addAmount(discount.multiply(boxReceivable.getDestCountryRate() != null ? boxReceivable.getDestCountryRate() : otherFeeRate));
receivableBoxAmount.receivableUnsettledOtherFee.addAmount(notWrittenOff.multiply(boxReceivable.getDestCountryRate() != null ? boxReceivable.getDestCountryRate() : otherFeeRate));
}
// 计算始发国或目的国实收
if (receivableIncomeBelongs != null) {
for (ReceivableIncomeBelong receivableIncomeBelong : receivableIncomeBelongs) {
if (receivableIncomeBelong.getIncomeBelong() == 1) {
receivableBoxAmount.receivableStartCountryOtherFee.addAmount(receivableIncomeBelong.getWriteOffAmount().multiply(boxReceivable.getDestCountryRate() != null ? boxReceivable.getDestCountryRate() : otherFeeRate));
receivableBoxAmount.receivableStartCountryOtherFeeSub.addAmount(receivableIncomeBelong.getWriteOffAmount().multiply(boxReceivable.getDestCountrySubRate() != null ? boxReceivable.getDestCountrySubRate() : otherSubRate));
} else if (receivableIncomeBelong.getIncomeBelong() == 0) {
receivableBoxAmount.receivableDestCountryOtherFee.addAmount(receivableIncomeBelong.getWriteOffAmount().multiply(boxReceivable.getDestCountryRate() != null ? boxReceivable.getDestCountryRate() : otherFeeRate));
receivableBoxAmount.receivableDestCountryOtherFeeSub.addAmount(receivableIncomeBelong.getWriteOffAmount().multiply(boxReceivable.getDestCountrySubRate() != null ? boxReceivable.getDestCountrySubRate() : otherSubRate));
}
}
}
break;
default:
break;
}
}
return receivableBoxAmount;
}
private void mergeAmount(ReceivableBoxReportVO.Amount resAmount, ReceivableBoxAmount receivableBoxAmount) {
List<ReceivableCurrencyAmount> pageReceivableTotalSummary = resAmount.getReceivableTotalSummary();
for (ReceivableCurrencyAmount receivableCurrencyAmount : receivableBoxAmount.receivableTotalSummary) {
if (pageReceivableTotalSummary.contains(receivableCurrencyAmount)) {
pageReceivableTotalSummary.get(pageReceivableTotalSummary.indexOf(receivableCurrencyAmount)).addAmount(receivableCurrencyAmount.getAmount());
} else {
pageReceivableTotalSummary.add(receivableCurrencyAmount);
}
}
List<ReceivableCurrencyAmount> pageReceivableTotalSettle = resAmount.getReceivableTotalSettle();
if (pageReceivableTotalSettle.contains(receivableBoxAmount.receivableTotalSettle)) {
pageReceivableTotalSettle.get(pageReceivableTotalSettle.indexOf(receivableBoxAmount.receivableTotalSettle)).addAmount(receivableBoxAmount.receivableTotalSettle.getAmount());
} else {
pageReceivableTotalSettle.add(receivableBoxAmount.receivableTotalSettle);
}
List<ReceivableCurrencyAmount> pageReceivableDetailFreight = resAmount.getReceivableDetailFreight();
if (pageReceivableDetailFreight.contains(receivableBoxAmount.receivableDetailFreight)) {
pageReceivableDetailFreight.get(pageReceivableDetailFreight.indexOf(receivableBoxAmount.receivableDetailFreight)).addAmount(receivableBoxAmount.receivableDetailFreight.getAmount());
} else {
pageReceivableDetailFreight.add(receivableBoxAmount.receivableDetailFreight);
}
List<ReceivableCurrencyAmount> pageReceivableDetailClearance = resAmount.getReceivableDetailClearance();
if (pageReceivableDetailClearance.contains(receivableBoxAmount.receivableDetailClearance)) {
pageReceivableDetailClearance.get(pageReceivableDetailClearance.indexOf(receivableBoxAmount.receivableDetailClearance)).addAmount(receivableBoxAmount.receivableDetailClearance.getAmount());
} else {
pageReceivableDetailClearance.add(receivableBoxAmount.receivableDetailClearance);
}
List<ReceivableCurrencyAmount> pageReceivableDetailOtherFee = resAmount.getReceivableDetailOtherFee();
if (pageReceivableDetailOtherFee.contains(receivableBoxAmount.receivableDetailOtherFee)) {
pageReceivableDetailOtherFee.get(pageReceivableDetailOtherFee.indexOf(receivableBoxAmount.receivableDetailOtherFee)).addAmount(receivableBoxAmount.receivableDetailOtherFee.getAmount());
} else {
pageReceivableDetailOtherFee.add(receivableBoxAmount.receivableDetailOtherFee);
}
List<ReceivableCurrencyAmount> pageReceivableDestCountryFreight = resAmount.getReceivableDestCountryFreight();
if (pageReceivableDestCountryFreight.contains(receivableBoxAmount.receivableDestCountryFreight)) {
pageReceivableDestCountryFreight.get(pageReceivableDestCountryFreight.indexOf(receivableBoxAmount.receivableDestCountryFreight)).addAmount(receivableBoxAmount.receivableDestCountryFreight.getAmount());
} else {
pageReceivableDestCountryFreight.add(receivableBoxAmount.receivableDestCountryFreight);
}
List<ReceivableCurrencyAmount> pageReceivableDestCountryClearance = resAmount.getReceivableDestCountryClearance();
if (pageReceivableDestCountryClearance.contains(receivableBoxAmount.receivableDestCountryClearance)) {
pageReceivableDestCountryClearance.get(pageReceivableDestCountryClearance.indexOf(receivableBoxAmount.receivableDestCountryClearance)).addAmount(receivableBoxAmount.receivableDestCountryClearance.getAmount());
} else {
pageReceivableDestCountryClearance.add(receivableBoxAmount.receivableDestCountryClearance);
}
List<ReceivableCurrencyAmount> pageReceivableDestCountryOtherFee = resAmount.getReceivableDestCountryOtherFee();
if (pageReceivableDestCountryOtherFee.contains(receivableBoxAmount.receivableDestCountryOtherFee)) {
pageReceivableDestCountryOtherFee.get(pageReceivableDestCountryOtherFee.indexOf(receivableBoxAmount.receivableDestCountryOtherFee)).addAmount(receivableBoxAmount.receivableDestCountryOtherFee.getAmount());
} else {
pageReceivableDestCountryOtherFee.add(receivableBoxAmount.receivableDestCountryOtherFee);
}
List<ReceivableCurrencyAmount> pageReceivableDestCountryOtherFeeSub = resAmount.getReceivableDestCountryOtherFeeSub();
if (pageReceivableDestCountryOtherFeeSub.contains(receivableBoxAmount.receivableDestCountryOtherFeeSub)) {
pageReceivableDestCountryOtherFeeSub.get(pageReceivableDestCountryOtherFeeSub.indexOf(receivableBoxAmount.receivableDestCountryOtherFeeSub)).addAmount(receivableBoxAmount.receivableDestCountryOtherFeeSub.getAmount());
} else {
pageReceivableDestCountryOtherFeeSub.add(receivableBoxAmount.receivableDestCountryOtherFeeSub);
}
List<ReceivableCurrencyAmount> pageReceivableStartCountryFreight = resAmount.getReceivableStartCountryFreight();
if (pageReceivableStartCountryFreight.contains(receivableBoxAmount.receivableStartCountryFreight)) {
pageReceivableStartCountryFreight.get(pageReceivableStartCountryFreight.indexOf(receivableBoxAmount.receivableStartCountryFreight)).addAmount(receivableBoxAmount.receivableStartCountryFreight.getAmount());
} else {
pageReceivableStartCountryFreight.add(receivableBoxAmount.receivableStartCountryFreight);
}
List<ReceivableCurrencyAmount> pageReceivableStartCountryClearance = resAmount.getReceivableStartCountryClearance();
if (pageReceivableStartCountryClearance.contains(receivableBoxAmount.receivableStartCountryClearance)) {
pageReceivableStartCountryClearance.get(pageReceivableStartCountryClearance.indexOf(receivableBoxAmount.receivableStartCountryClearance)).addAmount(receivableBoxAmount.receivableStartCountryClearance.getAmount());
} else {
pageReceivableStartCountryClearance.add(receivableBoxAmount.receivableStartCountryClearance);
}
List<ReceivableCurrencyAmount> pageReceivableStartCountryOtherFee = resAmount.getReceivableStartCountryOtherFee();
if (pageReceivableStartCountryOtherFee.contains(receivableBoxAmount.receivableStartCountryOtherFee)) {
pageReceivableStartCountryOtherFee.get(pageReceivableStartCountryOtherFee.indexOf(receivableBoxAmount.receivableStartCountryOtherFee)).addAmount(receivableBoxAmount.receivableStartCountryOtherFee.getAmount());
} else {
pageReceivableStartCountryOtherFee.add(receivableBoxAmount.receivableStartCountryOtherFee);
}
List<ReceivableCurrencyAmount> pageReceivableStartCountryOtherFeeSub = resAmount.getReceivableStartCountryOtherFeeSub();
if (pageReceivableStartCountryOtherFeeSub.contains(receivableBoxAmount.receivableStartCountryOtherFeeSub)) {
pageReceivableStartCountryOtherFeeSub.get(pageReceivableStartCountryOtherFeeSub.indexOf(receivableBoxAmount.receivableStartCountryOtherFeeSub)).addAmount(receivableBoxAmount.receivableStartCountryOtherFeeSub.getAmount());
} else {
pageReceivableStartCountryOtherFeeSub.add(receivableBoxAmount.receivableStartCountryOtherFeeSub);
}
List<ReceivableCurrencyAmount> pageReceivableDiscountFreight = resAmount.getReceivableDiscountFreight();
if (pageReceivableDiscountFreight.contains(receivableBoxAmount.receivableDiscountFreight)) {
pageReceivableDiscountFreight.get(pageReceivableDiscountFreight.indexOf(receivableBoxAmount.receivableDiscountFreight)).addAmount(receivableBoxAmount.receivableDiscountFreight.getAmount());
} else {
pageReceivableDiscountFreight.add(receivableBoxAmount.receivableDiscountFreight);
}
List<ReceivableCurrencyAmount> pageReceivableDiscountClearance = resAmount.getReceivableDiscountClearance();
if (pageReceivableDiscountClearance.contains(receivableBoxAmount.receivableDiscountClearance)) {
pageReceivableDiscountClearance.get(pageReceivableDiscountClearance.indexOf(receivableBoxAmount.receivableDiscountClearance)).addAmount(receivableBoxAmount.receivableDiscountClearance.getAmount());
} else {
pageReceivableDiscountClearance.add(receivableBoxAmount.receivableDiscountClearance);
}
List<ReceivableCurrencyAmount> pageReceivableDiscountOtherFee = resAmount.getReceivableDiscountOtherFee();
if (pageReceivableDiscountOtherFee.contains(receivableBoxAmount.receivableDiscountOtherFee)) {
pageReceivableDiscountOtherFee.get(pageReceivableDiscountOtherFee.indexOf(receivableBoxAmount.receivableDiscountOtherFee)).addAmount(receivableBoxAmount.receivableDiscountOtherFee.getAmount());
} else {
pageReceivableDiscountOtherFee.add(receivableBoxAmount.receivableDiscountOtherFee);
}
List<ReceivableCurrencyAmount> pageReceivableUnsettledFreight = resAmount.getReceivableUnsettledFreight();
if (pageReceivableUnsettledFreight.contains(receivableBoxAmount.receivableUnsettledFreight)) {
pageReceivableUnsettledFreight.get(pageReceivableUnsettledFreight.indexOf(receivableBoxAmount.receivableUnsettledFreight)).addAmount(receivableBoxAmount.receivableUnsettledFreight.getAmount());
} else {
pageReceivableUnsettledFreight.add(receivableBoxAmount.receivableUnsettledFreight);
}
List<ReceivableCurrencyAmount> pageReceivableUnsettledClearance = resAmount.getReceivableUnsettledClearance();
if (pageReceivableUnsettledClearance.contains(receivableBoxAmount.receivableUnsettledClearance)) {
pageReceivableUnsettledClearance.get(pageReceivableUnsettledClearance.indexOf(receivableBoxAmount.receivableUnsettledClearance)).addAmount(receivableBoxAmount.receivableUnsettledClearance.getAmount());
} else {
pageReceivableUnsettledClearance.add(receivableBoxAmount.receivableUnsettledClearance);
}
List<ReceivableCurrencyAmount> pageReceivableUnsettledOtherFee = resAmount.getReceivableUnsettledOtherFee();
if (pageReceivableUnsettledOtherFee.contains(receivableBoxAmount.receivableUnsettledOtherFee)) {
pageReceivableUnsettledOtherFee.get(pageReceivableUnsettledOtherFee.indexOf(receivableBoxAmount.receivableUnsettledOtherFee)).addAmount(receivableBoxAmount.receivableUnsettledOtherFee.getAmount());
} else {
pageReceivableUnsettledOtherFee.add(receivableBoxAmount.receivableUnsettledOtherFee);
}
}
/**
* 整合单个record的字符串结果,用于前端展示
*/
private void assembleRecord(ReceivableBoxAmount receivableBoxAmount, ReceivableBoxReportPageVO record, Map<Integer, CurrencyRespDTO> allCurrency) {
StringBuilder receivableCurrencyAmountBuilder = new StringBuilder();
for (ReceivableCurrencyAmount receivableCurrencyAmount : receivableBoxAmount.receivableTotalSummary) {
receivableCurrencyAmountBuilder.append(allCurrency.get(receivableCurrencyAmount.getCurrencyId().intValue()).getFuhao()).append(" ").append(receivableCurrencyAmount.getAmount()).append(", ");
}
record.setReceivableTotalSummary(receivableCurrencyAmountBuilder.substring(0, receivableCurrencyAmountBuilder.length() - 2));
record.setReceivableTotalSettle(allCurrency.get(receivableBoxAmount.receivableTotalSettle.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableTotalSettle.getAmount());
record.setReceivableDetailFreight(allCurrency.get(receivableBoxAmount.receivableDetailFreight.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableDetailFreight.getAmount());
record.setReceivableDetailClearance(allCurrency.get(receivableBoxAmount.receivableDetailClearance.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableDetailClearance.getAmount());
record.setReceivableDetailOtherFee(allCurrency.get(receivableBoxAmount.receivableDetailOtherFee.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableDetailOtherFee.getAmount());
record.setReceivableDestCountryFreight(allCurrency.get(receivableBoxAmount.receivableDestCountryFreight.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableDestCountryFreight.getAmount());
record.setReceivableDestCountryClearance(allCurrency.get(receivableBoxAmount.receivableDestCountryClearance.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableDestCountryClearance.getAmount());
record.setReceivableDestCountryOtherFee(allCurrency.get(receivableBoxAmount.receivableDestCountryOtherFee.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableDestCountryOtherFee.getAmount());
record.setReceivableDestCountryOtherFeeSub(allCurrency.get(receivableBoxAmount.receivableDestCountryOtherFeeSub.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableDestCountryOtherFeeSub.getAmount());
record.setReceivableStartCountryFreight(allCurrency.get(receivableBoxAmount.receivableStartCountryFreight.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableStartCountryFreight.getAmount());
record.setReceivableStartCountryClearance(allCurrency.get(receivableBoxAmount.receivableStartCountryClearance.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableStartCountryClearance.getAmount());
record.setReceivableStartCountryOtherFee(allCurrency.get(receivableBoxAmount.receivableStartCountryOtherFee.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableStartCountryOtherFee.getAmount());
record.setReceivableStartCountryOtherFeeSub(allCurrency.get(receivableBoxAmount.receivableStartCountryOtherFeeSub.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableStartCountryOtherFeeSub.getAmount());
record.setReceivableDiscountFreight(allCurrency.get(receivableBoxAmount.receivableDiscountFreight.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableDiscountFreight.getAmount());
record.setReceivableDiscountClearance(allCurrency.get(receivableBoxAmount.receivableDiscountClearance.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableDiscountClearance.getAmount());
record.setReceivableDiscountOtherFee(allCurrency.get(receivableBoxAmount.receivableDiscountOtherFee.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableDiscountOtherFee.getAmount());
record.setReceivableUnsettledFreight(allCurrency.get(receivableBoxAmount.receivableUnsettledFreight.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableUnsettledFreight.getAmount());
record.setReceivableUnsettledClearance(allCurrency.get(receivableBoxAmount.receivableUnsettledClearance.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableUnsettledClearance.getAmount());
record.setReceivableUnsettledOtherFee(allCurrency.get(receivableBoxAmount.receivableUnsettledOtherFee.getCurrencyId().intValue()).getFuhao() + " " + receivableBoxAmount.receivableUnsettledOtherFee.getAmount());
}
/**
* 获取汇率
*/
private BigDecimal getExchangeRate(List<ExchangeRateRespDTO> allCurrencyRate, Long sourceId, Long targetId) {
if (sourceId.equals(targetId)) {
return BigDecimal.ONE;
}
for (ExchangeRateRespDTO exchangeRateRespDTO : allCurrencyRate) {
if (exchangeRateRespDTO.getSourceCurrencyId().equals(sourceId) && exchangeRateRespDTO.getTargetCurrencyId().equals(targetId)) {
return exchangeRateRespDTO.getCurrencyRate();
}
}
return BigDecimal.ONE;
}
/**
* 应收报表中费用分类
*
* @param feeType
* @return
*/
private Integer getFeeType(Integer feeType) {
if (feeType == 1) {
return 0;
}
if (feeType == 2) {
return 1;
}
return 2;
}
/**
* 设置提单状态
*
* @param record
*/
private void setLadingBillStatus(ReceivableBoxReportPageVO record) {
record.setLadingBillStatus(0);
if (record.getOrderCount() != 0) {
if (record.getLadingCount() > 0) {
if (record.getOrderCount().equals(record.getLadingCount())) {
record.setLadingBillStatus(2);
} else if (record.getOrderCount() < record.getLadingCount()) {
// 添加的逻辑,提单有可能补单
record.setLadingBillStatus(2);
} else {
record.setLadingBillStatus(1);
}
}
}
}
@Data
@NoArgsConstructor
private static class ReceivableBoxAmount {
// 应收款
private ArrayList<ReceivableCurrencyAmount> receivableTotalSummary = new ArrayList<>();
private ReceivableCurrencyAmount receivableTotalSettle;
// 应收款明细
private ReceivableCurrencyAmount receivableDetailFreight;
private ReceivableCurrencyAmount receivableDetailClearance;
private ReceivableCurrencyAmount receivableDetailOtherFee;
// 折扣
private ReceivableCurrencyAmount receivableDiscountFreight;
private ReceivableCurrencyAmount receivableDiscountClearance;
private ReceivableCurrencyAmount receivableDiscountOtherFee;
// 未收款
private ReceivableCurrencyAmount receivableUnsettledFreight;
private ReceivableCurrencyAmount receivableUnsettledClearance;
private ReceivableCurrencyAmount receivableUnsettledOtherFee;
// 始发国实收
private ReceivableCurrencyAmount receivableStartCountryFreight;
private ReceivableCurrencyAmount receivableStartCountryClearance;
private ReceivableCurrencyAmount receivableStartCountryOtherFee;
private ReceivableCurrencyAmount receivableStartCountryOtherFeeSub;
// 目国实收
private ReceivableCurrencyAmount receivableDestCountryFreight;
private ReceivableCurrencyAmount receivableDestCountryClearance;
private ReceivableCurrencyAmount receivableDestCountryOtherFee;
private ReceivableCurrencyAmount receivableDestCountryOtherFeeSub;
public ReceivableBoxAmount(Long freightCurrency, Long clearanceCurrency, Long otherFeeCurrency, Long otherSubCurrency, Long receivableCurrency) {
this.receivableTotalSummary = new ArrayList<>();
this.receivableTotalSettle = new ReceivableCurrencyAmount(receivableCurrency, BigDecimal.ZERO);
this.receivableDetailFreight = new ReceivableCurrencyAmount(freightCurrency, BigDecimal.ZERO);
this.receivableDetailClearance = new ReceivableCurrencyAmount(clearanceCurrency, BigDecimal.ZERO);
this.receivableDetailOtherFee = new ReceivableCurrencyAmount(otherFeeCurrency, BigDecimal.ZERO);
this.receivableDiscountFreight = new ReceivableCurrencyAmount(freightCurrency, BigDecimal.ZERO);
this.receivableDiscountClearance = new ReceivableCurrencyAmount(clearanceCurrency, BigDecimal.ZERO);
this.receivableDiscountOtherFee = new ReceivableCurrencyAmount(otherFeeCurrency, BigDecimal.ZERO);
this.receivableUnsettledFreight = new ReceivableCurrencyAmount(freightCurrency, BigDecimal.ZERO);
this.receivableUnsettledClearance = new ReceivableCurrencyAmount(clearanceCurrency, BigDecimal.ZERO);
this.receivableUnsettledOtherFee = new ReceivableCurrencyAmount(otherFeeCurrency, BigDecimal.ZERO);
this.receivableStartCountryFreight = new ReceivableCurrencyAmount(freightCurrency, BigDecimal.ZERO);
this.receivableStartCountryClearance = new ReceivableCurrencyAmount(clearanceCurrency, BigDecimal.ZERO);
this.receivableStartCountryOtherFee = new ReceivableCurrencyAmount(otherFeeCurrency, BigDecimal.ZERO);
this.receivableStartCountryOtherFeeSub = new ReceivableCurrencyAmount(otherSubCurrency, BigDecimal.ZERO);
this.receivableDestCountryFreight = new ReceivableCurrencyAmount(freightCurrency, BigDecimal.ZERO);
this.receivableDestCountryClearance = new ReceivableCurrencyAmount(clearanceCurrency, BigDecimal.ZERO);
this.receivableDestCountryOtherFee = new ReceivableCurrencyAmount(otherFeeCurrency, BigDecimal.ZERO);
this.receivableDestCountryOtherFeeSub = new ReceivableCurrencyAmount(otherSubCurrency, BigDecimal.ZERO);
}
}
}
\ No newline at end of file
......@@ -29,6 +29,10 @@ public class ReceiptItemBatchCreateReqVO {
@ExcelProperty("收款日期")
private String payDate;
@ApiModelProperty(value = "收款账号id")
@ExcelIgnore
private Long accountId;
@ApiModelProperty(value = "收款账号")
@ExcelProperty("收款账号")
private String payAccount;
......
......@@ -23,6 +23,9 @@ public class ReceiptItemBaseVO {
@ApiModelProperty(value = "收款单id")
private Long receiptId;
@ApiModelProperty(value = "收款账号id")
private Long accountId;
@ApiModelProperty(value = "收款账号")
private String accountNo;
......
......@@ -40,6 +40,9 @@ public class BatchGenReceiptPageVO {
@ApiModelProperty(value = "付款人id")
private Long payerId;
@ApiModelProperty(value = "是否开票 0否1是")
private Integer openInvoice;
@ApiModelProperty(value = "客户编号")
private String customerNo;
......
package cn.iocoder.yudao.module.wealth.vo.receivable;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
@Data
@ApiModel("分页结果")
public class ReceivableBoxReportPageVO implements Serializable {
@ApiModelProperty(value = "自编号id")
private Long id;
@ApiModelProperty(value = "自编号")
private String selfNo;
@ApiModelProperty(value = "目的国id")
private Long destCountryId;
@ApiModelProperty(value = "订单数量")
private Integer orderCount;
@ApiModelProperty(value = "提单数量")
private Integer ladingCount;
@ApiModelProperty(value = "字典settlement_status,191-未结算,192-结算中,193-已结算")
private Integer slStatus;
@ApiModelProperty(value = "结算时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date slSettledTime;
@ApiModelProperty(value = "核销比例")
private String writeOffPercent;
@ApiModelProperty(value = "提单制作,未完成/部分完成/已完成")
private Integer ladingBillStatus;
@ApiModelProperty(value = "到港时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date dgDate;
@ApiModelProperty(value = "清关时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date qgDate;
@ApiModelProperty(value = "卸柜/到仓时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date ulWarehouseTime;
@ApiModelProperty(value = "应收款-汇总")
private String receivableTotalSummary;
@ApiModelProperty(value = "应收款-结算")
private String receivableTotalSettle;
@ApiModelProperty(value = "应收款明细-运费")
private String receivableDetailFreight;
@ApiModelProperty(value = "应收款明细-清关费")
private String receivableDetailClearance;
@ApiModelProperty(value = "应收款明细-额外费用")
private String receivableDetailOtherFee;
@ApiModelProperty(value = "目的国实收-运费")
private String receivableDestCountryFreight;
@ApiModelProperty(value = "目的国实收-清关费")
private String receivableDestCountryClearance;
@ApiModelProperty(value = "目的国实收-额外费用")
private String receivableDestCountryOtherFee;
@ApiModelProperty(value = "目的国实收-额外费用(副币种)")
private String receivableDestCountryOtherFeeSub;
@ApiModelProperty(value = "始发国实收-运费")
private String receivableStartCountryFreight;
@ApiModelProperty(value = "始发国实收-清关费")
private String receivableStartCountryClearance;
@ApiModelProperty(value = "始发国实收-额外费用")
private String receivableStartCountryOtherFee;
@ApiModelProperty(value = "始发国实收-额外费用(副币种)")
private String receivableStartCountryOtherFeeSub;
@ApiModelProperty(value = "折扣-运费")
private String receivableDiscountFreight;
@ApiModelProperty(value = "折扣-清关费")
private String receivableDiscountClearance;
@ApiModelProperty(value = "折扣-额外费用")
private String receivableDiscountOtherFee;
@ApiModelProperty(value = "未收款明细-运费")
private String receivableUnsettledFreight;
@ApiModelProperty(value = "未收款明细-清关费")
private String receivableUnsettledClearance;
@ApiModelProperty(value = "未收款明细-额外费用")
private String receivableUnsettledOtherFee;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ReceivableBoxReportPageVO that = (ReceivableBoxReportPageVO) o;
return Objects.equals(id, that.id);
}
@Override
public int hashCode() {
return Objects.hashCode(id);
}
}
package cn.iocoder.yudao.module.wealth.vo.receivable;
import cn.hutool.core.collection.CollectionUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
public class ReceivableBoxReportQueryVO {
@ApiModelProperty(value = "自编号")
private String selfNo;
@ApiModelProperty(value = "始发地id列表")
private List<Long> startWarehouseIdList;
@ApiModelProperty(value = "目的国家ID")
private List<Long> destCountryId;
@ApiModelProperty(value = "目的城市ID")
private List<Long> destCity;
@ApiModelProperty(value = "目的仓库id列表")
private List<Long> destWarehouseIdList;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始结算时间")
private Date beginJsDate;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束结算时间")
private Date endJsDate;
@ApiModelProperty(value = "191-未结算,192-结算中,193-已结算")
private Integer slStatus;
@ApiModelProperty(value = "出货状态")
private Integer boxStatus;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始到港时间")
private Date beginDaogangTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束到港时间")
private Date endDaogangTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始清关时间")
private Date beginQingguanTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束清关时间")
private Date endQingguanTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始卸柜/到仓时间")
private Date beginUlWarehouseTime ;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束卸柜/到仓时间")
private Date endUlWarehouseTime ;
@ApiModelProperty(value = "提单制作,0-未完成,1-部分完成,2-已完成")
private Integer ladingBillStatus;
@ApiModelProperty(value = "结算时间排序(默认倒序)")
private Boolean jsTimeDesc = true;
@ApiModelProperty(value = "卸柜/到仓时间排序(默认倒序)")
private Boolean ulWarehouseTimeDesc = true;
@ApiModelProperty(value = "清关时间排序(默认倒序)")
private Boolean qingguanTimeDesc = true;
@ApiModelProperty(value = "到港时间排序(默认倒序)")
private Boolean daogangTimeDesc = true;
private Boolean forceUpdateCache = false;
public Boolean isEmpty() {
return StringUtils.isBlank(selfNo)
&& (CollectionUtil.isEmpty(startWarehouseIdList))
&& (CollectionUtil.isEmpty(destCountryId))
&& (CollectionUtil.isEmpty(destCity))
&& (CollectionUtil.isEmpty(destWarehouseIdList))
&& (beginJsDate == null)
&& (endJsDate == null)
&& (slStatus == null)
&& (boxStatus == null)
&& (beginDaogangTime == null)
&& (endDaogangTime == null)
&& (beginQingguanTime == null)
&& (endQingguanTime == null)
&& (beginUlWarehouseTime == null)
&& (endUlWarehouseTime == null)
&& (ladingBillStatus == null);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ReceivableBoxReportQueryVO that = (ReceivableBoxReportQueryVO) o;
return Objects.equals(selfNo, that.selfNo) &&
// 比较两个list中的元素相同
CollectionUtil.isEqualList(startWarehouseIdList, that.startWarehouseIdList) &&
CollectionUtil.isEqualList(destCountryId, that.destCountryId) &&
CollectionUtil.isEqualList(destCity, that.destCity) &&
CollectionUtil.isEqualList(destWarehouseIdList, that.destWarehouseIdList) &&
Objects.equals(beginJsDate, that.beginJsDate) && Objects.equals(endJsDate, that.endJsDate) && Objects.equals(slStatus, that.slStatus) && Objects.equals(boxStatus, that.boxStatus) && Objects.equals(beginDaogangTime, that.beginDaogangTime) && Objects.equals(endDaogangTime, that.endDaogangTime) && Objects.equals(beginQingguanTime, that.beginQingguanTime) && Objects.equals(endQingguanTime, that.endQingguanTime) && Objects.equals(beginUlWarehouseTime, that.beginUlWarehouseTime) && Objects.equals(endUlWarehouseTime, that.endUlWarehouseTime) && Objects.equals(ladingBillStatus, that.ladingBillStatus) && Objects.equals(jsTimeDesc, that.jsTimeDesc) && Objects.equals(ulWarehouseTimeDesc, that.ulWarehouseTimeDesc) && Objects.equals(qingguanTimeDesc, that.qingguanTimeDesc) && Objects.equals(daogangTimeDesc, that.daogangTimeDesc);
}
@Override
public int hashCode() {
return Objects.hash(selfNo, startWarehouseIdList, destCountryId, destCity, destWarehouseIdList, beginJsDate, endJsDate, slStatus, boxStatus, beginDaogangTime, endDaogangTime, beginQingguanTime, endQingguanTime, beginUlWarehouseTime, endUlWarehouseTime, ladingBillStatus, jsTimeDesc, ulWarehouseTimeDesc, qingguanTimeDesc, daogangTimeDesc);
}
}
package cn.iocoder.yudao.module.wealth.vo.receivable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Data
@ApiModel("应收报表分页结果")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public final class ReceivableBoxReportVO implements Serializable {
@ApiModelProperty(value = "数据", required = true)
private List<ReceivableBoxReportPageVO> list;
@ApiModelProperty(value = "当页汇总", required = true)
private Amount pageAmount;
@ApiModelProperty(value = "查询条件汇总", required = true)
private Amount queryAmount;
@ApiModelProperty(value = "总量", required = true, example = "0")
private Long total = 0L;
@ApiModelProperty(value = "每页记录数", required = true, example = "10")
private Long rows = 10L;
@ApiModelProperty(value = "当前页数", required = true, example = "1")
private Long page = 1L;
@ApiModelProperty(value = "总页数", required = true, example = "0")
private Long pages = 0L;
@Data
public static class Amount {
@ApiModelProperty(value = "应收款-汇总")
private List<ReceivableCurrencyAmount> receivableTotalSummary = new ArrayList<>();
@ApiModelProperty(value = "应收款-结算")
private List<ReceivableCurrencyAmount> receivableTotalSettle = new ArrayList<>();
@ApiModelProperty(value = "应收款明细-运费")
private List<ReceivableCurrencyAmount> receivableDetailFreight = new ArrayList<>();
@ApiModelProperty(value = "应收款明细-清关费")
private List<ReceivableCurrencyAmount> receivableDetailClearance = new ArrayList<>();
@ApiModelProperty(value = "应收款明细-额外费用")
private List<ReceivableCurrencyAmount> receivableDetailOtherFee = new ArrayList<>();
@ApiModelProperty(value = "目的国实收-运费")
private List<ReceivableCurrencyAmount> receivableDestCountryFreight = new ArrayList<>();
@ApiModelProperty(value = "目的国实收-清关费")
private List<ReceivableCurrencyAmount> receivableDestCountryClearance = new ArrayList<>();
@ApiModelProperty(value = "目的国实收-额外费用")
private List<ReceivableCurrencyAmount> receivableDestCountryOtherFee = new ArrayList<>();
@ApiModelProperty(value = "目的国实收-额外费用(副币种)")
private List<ReceivableCurrencyAmount> receivableDestCountryOtherFeeSub = new ArrayList<>();
@ApiModelProperty(value = "始发国实收-运费")
private List<ReceivableCurrencyAmount> receivableStartCountryFreight = new ArrayList<>();
@ApiModelProperty(value = "始发国实收-清关费")
private List<ReceivableCurrencyAmount> receivableStartCountryClearance = new ArrayList<>();
@ApiModelProperty(value = "始发国实收-额外费用")
private List<ReceivableCurrencyAmount> receivableStartCountryOtherFee = new ArrayList<>();
@ApiModelProperty(value = "始发国实收-额外费用(副币种)")
private List<ReceivableCurrencyAmount> receivableStartCountryOtherFeeSub = new ArrayList<>();
@ApiModelProperty(value = "折扣-运费")
private List<ReceivableCurrencyAmount> receivableDiscountFreight = new ArrayList<>();
@ApiModelProperty(value = "折扣-清关费")
private List<ReceivableCurrencyAmount> receivableDiscountClearance = new ArrayList<>();
@ApiModelProperty(value = "折扣-额外费用")
private List<ReceivableCurrencyAmount> receivableDiscountOtherFee = new ArrayList<>();
@ApiModelProperty(value = "未收款明细-运费")
private List<ReceivableCurrencyAmount> receivableUnsettledFreight = new ArrayList<>();
@ApiModelProperty(value = "未收款明细-清关费")
private List<ReceivableCurrencyAmount> receivableUnsettledClearance = new ArrayList<>();
@ApiModelProperty(value = "未收款明细-额外费用")
private List<ReceivableCurrencyAmount> receivableUnsettledOtherFee = new ArrayList<>();
}
}
package cn.iocoder.yudao.module.wealth.vo.receivable;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Objects;
@Data
public class ReceivableCurrencyAmount {
@ApiModelProperty(value = "币种id")
private Long currencyId;
@ApiModelProperty(value = "金额")
private BigDecimal amount;
public ReceivableCurrencyAmount(Long currencyId, BigDecimal amount) {
this.currencyId = currencyId;
this.amount = amount;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ReceivableCurrencyAmount that = (ReceivableCurrencyAmount) o;
return Objects.equals(currencyId, that.currencyId);
}
@Override
public int hashCode() {
return Objects.hashCode(currencyId);
}
public void addAmount(BigDecimal amount) {
this.amount = this.amount.add(amount);
}
}
\ No newline at end of file
package cn.iocoder.yudao.module.wealth.vo.receivable;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class ReceivableIncomeBelong {
private Long receivableId;
/**
* 收款归属 0 目的国,1 始发国
*/
private Integer incomeBelong;
private BigDecimal writeOffAmount;
}
package cn.iocoder.yudao.module.wealth.vo.receivable;
import lombok.Data;
@Data
public class ReceivebleBoxRelationOrder {
private Long orderId;
private Long shipmentId;
private Long destCountryId;
}
package cn.iocoder.yudao.module.wealth.controller.admin.job;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.redis.helper.RedisHelper;
import cn.iocoder.yudao.module.wealth.dal.mysql.receivable.ReceivableMapper;
import cn.iocoder.yudao.module.wealth.service.receivable.ReceivableService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.module.wealth.enums.BoxReportConstant.BOX_AMOUNT_CACHE;
@Component
@Slf4j
@AllArgsConstructor
public class BoxReportCacheLoader implements ApplicationRunner {
private final ReceivableService receivableService;
private final ReceivableMapper receivableMapper;
private final RedisHelper redisHelper;
@Override
public void run(ApplicationArguments args) throws Exception {
log.info("初始化应收报表缓存");
List<Long> boxIds = receivableMapper.getAllBoxId();
Set<String> keys = redisHelper.keys(BOX_AMOUNT_CACHE + "*");
if (CollectionUtil.isNotEmpty(keys)) {
List<Long> cacheBoxIds = keys.stream().map(key -> Long.parseLong(key.replace(BOX_AMOUNT_CACHE, ""))).collect(Collectors.toList());
boxIds = boxIds.stream().filter(boxId -> !cacheBoxIds.contains(boxId)).collect(Collectors.toList());
}
receivableService.updateBoxAmountCache(boxIds, false);
log.info("初始化应收报表缓存完成");
}
}
......@@ -311,6 +311,7 @@ public class ReceiptController {
@PostMapping("/batch-gen-receipt")
@ApiOperation("批量生成收款单")
@Idempotent(timeout = 5)
public CommonResult<List<ReceiptBatchGenRespVO>> batchGenReceipt(@RequestBody List<ReceiptBatchCreateReqVO> createReqVOList) {
return success(receiptService.batchGenReceipt(createReqVOList));
}
......
......@@ -70,9 +70,6 @@ public class ReceiptItemController {
@Resource
private ReceiptApprovalMapper receiptApprovalMapper;
@Resource
private BankApi bankApi;
@PostMapping("/create")
@ApiOperation("创建收款明细")
//@PreAuthorize("@ss.hasPermission('ecw:receipt-item:create')")
......@@ -102,8 +99,6 @@ public class ReceiptItemController {
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
public CommonResult<ReceiptItemBackVO> getReceiptItemDetail(@RequestParam("id") Long id) {
ReceiptItemBackVO receiptItemVO = receiptItemService.getReceiptItemDetail(id);
BankAccountDTO account = bankApi.getBankAccountByAccountNo(receiptItemVO.getAccountNo());
receiptItemVO.setAccountId(account.getId());
getSY(receiptItemVO, receiptItemVO.getReceiptId());
SetData(receiptItemVO);
return success(receiptItemVO);
......@@ -214,12 +209,7 @@ public class ReceiptItemController {
LambdaQueryWrapper<ReceiptItemDO> lambdaQueryWrapper = new LambdaQueryWrapper();
lambdaQueryWrapper.eq(ReceiptItemDO::getReceiptId, id);
List<ReceiptItemDO> list = receiptItemService.list(lambdaQueryWrapper);
List<ReceiptItemBackVO> receiptItemBackVOS = ReceiptItemConvert.INSTANCE.convertList(list);
receiptItemBackVOS.forEach(vo -> {
BankAccountDTO account = bankApi.getBankAccountByAccountNo(vo.getAccountNo());
vo.setAccountId(account.getId());
});
return success(receiptItemBackVOS);
return success(ReceiptItemConvert.INSTANCE.convertList(list));
}
@PostMapping("/review/page")
......@@ -315,6 +305,7 @@ public class ReceiptItemController {
@PostMapping(value = "/import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ApiOperation("批量银行收款信息导入")
@Idempotent(timeout = 5)
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));
......
......@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.wealth.controller.admin.receivable;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.idempotent.core.annotation.Idempotent;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.wealth.convert.receivableDiscount.ReceivableDiscountConvert;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receivableDiscount.ReceivableDiscountDO;
......@@ -116,6 +117,7 @@ public class ReceivableController {
public CommonResult<ReceivablePageResult<BatchGenReceiptReceivablePageVO>> batchGenReceiptReceivablePage(@Valid @RequestBody BatchGenReceiptReceivablePageQueryVO query, PageVO page) {
return success(receivableService.batchGenReceiptReceivablePage(query, page));
}
@GetMapping("/getListForReceiptItem")
@ApiOperation("财务-创建收款明细获取应收明细")
public CommonResult<List<ReceivableInItemVO>> getListForCreateReceiptItem(Long receiptId) {
......@@ -127,51 +129,11 @@ public class ReceivableController {
public CommonResult<List<ReceivableInItemVO>> getReceivableByReceiptItem(Long receiptItemId) {
return success(receivableService.getReceivableByReceiptItem(receiptItemId));
}
/*
@GetMapping("/list")
@ApiOperation("根据id集合获得应收款列表")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
//@PreAuthorize("@ss.hasPermission('ecw:receivable:query')")
public CommonResult<List<ReceivableBackVO>> receivableList(@RequestParam("ids") List<Long> ids) {
List<ReceivableBackVO> list = receivableService.receivableList(ids);
return success(list);
}*/
/*
@GetMapping("/export-excel")
@ApiOperation("导出应收款 Excel")
//@PreAuthorize("@ss.hasPermission('ecw:receivable:export')")
@OperateLog(type = EXPORT)
public void exportReceivableExcel(@Valid ReceivableQueryVO query,
HttpServletResponse response) throws IOException {
List<ReceivableDO> list = receivableService.getReceivableList(query);
// 导出 Excel
List<ReceivableBackVO> datas = ReceivableConvert.INSTANCE.convertList(list);
ExcelUtils.write(response, "应收款.xls", "数据", ReceivableBackVO.class, datas);
}*/
// @PostMapping("/create")
// @ApiOperation("创建应收款")
// //@PreAuthorize("@ss.hasPermission('ecw:receivable:create')")
// public CommonResult<Long> createReceivable(@Valid @RequestBody ReceivableCreateReqVO createReqVO) {
// return success(receivableService.createReceivable(createReqVO));
// }
// @PutMapping("/update")
// @ApiOperation("更新应收款")
// //@PreAuthorize("@ss.hasPermission('ecw:receivable:update')")
// public CommonResult<Boolean> updateReceivable(@Valid @RequestBody ReceivableUpdateReqVO updateReqVO) {
// receivableService.updateReceivable(updateReqVO);
// return success(true);
// }
// @DeleteMapping("/delete")
// @ApiOperation("删除应收款")
// @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
// //@PreAuthorize("@ss.hasPermission('ecw:receivable:delete')")
// public CommonResult<Boolean> deleteReceivable(@RequestParam("id") Long id) {
// receivableService.deleteReceivable(id);
// return success(true);
// }
@PostMapping("/box/report")
@ApiOperation("财务-应收报表")
@Idempotent(timeout = 5)
public CommonResult<ReceivableBoxReportVO> getReceivableBoxReport(@Valid @RequestBody ReceivableBoxReportQueryVO query, PageVO page) {
return success(receivableService.getReceivableBoxReport(query, page));
}
}
......@@ -102,7 +102,7 @@
INNER JOIN (SELECT receipt_id, order_id FROM ecw_receivable GROUP BY receipt_id, order_id) rb
ON rb.receipt_id = er.id
LEFT JOIN ecw_order eo ON eo.order_id = rb.order_id
LEFT JOIN ecw_receipt_account era ON era.receipt_id = eri.receipt_id
LEFT JOIN ecw_bank_account eba ON eba.ba_account_num = eri.account_no
WHERE eri.status = 1
<include refid="incomePageCondition"/>
GROUP BY eri.id
......
......@@ -18,7 +18,6 @@
FROM ecw_receipt_item eri
LEFT JOIN ecw_receipt er ON eri.receipt_id = er.id
LEFT JOIN ecw_receipt_approval era ON era.bmp_id=eri.bmp_id
LEFT JOIN ecw_bank_account eba ON eba.ba_account_num = eri.account_no
INNER JOIN (SELECT receipt_id, order_id FROM ecw_receivable GROUP BY receipt_id, order_id) rb
ON rb.receipt_id = er.id
LEFT JOIN ecw_order o ON o.order_id = rb.order_id
......@@ -53,7 +52,7 @@
AND eri.amount_date BETWEEN #{query.beginAmountDate} and #{query.endAmountDate}
</if>
<if test="query.accountId != null and query.accountId.size > 0">
AND eba.id IN
AND eri.account_id IN
<foreach collection="query.accountId" item="account" open="(" separator="," close=")">
#{account}
</foreach>
......@@ -78,7 +77,6 @@
FROM ecw_receipt_item eri
LEFT JOIN ecw_receipt er ON eri.receipt_id = er.id
LEFT JOIN ecw_receipt_approval era ON era.bmp_id=eri.bmp_id
LEFT JOIN ecw_bank_account eba ON eba.ba_account_num = eri.account_no
INNER JOIN (SELECT receipt_id, order_id FROM ecw_receivable GROUP BY receipt_id, order_id) rb
ON rb.receipt_id = er.id
LEFT JOIN ecw_order o ON o.order_id = rb.order_id
......@@ -106,4 +104,19 @@
WHERE eri.deleted = 0 AND eri.bmp_status = 1
GROUP BY eri.write_off_currency_id
</select>
<select id="selectAllWriteOffItemByOrders" resultType="cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableIncomeBelong">
SELECT
erwor.receivable_id,
erwor.income_belong,
SUM(erwor.receivable_write_off_amount) AS write_off_amount
FROM ecw_receivable_write_off_record erwor
LEFT JOIN ecw_receipt_item eri ON erwor.receipt_item_id = eri.id
WHERE
erwor.order_id IN
<foreach collection="orderIds" item="orderId" open="(" separator="," close=")">
#{orderId}
</foreach>
AND eri.status = 1 AND eri.deleted = 0
GROUP BY erwor.receivable_id, erwor.income_belong
</select>
</mapper>
......@@ -37,10 +37,8 @@
</if>
WHERE er.deleted = 0
<include refid="pageCondition"/>
ORDER BY er.create_time DESC
<if test="query.numberNo != null and query.numberNo != ''">
GROUP BY er.receipt_no
</if>
ORDER BY MAX(er.create_time) DESC
LIMIT #{start}, #{size}
</select>
<select id="getOrderInfoByReceiptId"
......
......@@ -219,10 +219,14 @@
AND concat(r.`title_zh`, r.`title_en`) like concat("%",concat(#{query.title},"%"))
</if>
<if test="query.consignorNameOrPhone != null and query.consignorNameOrPhone != '' ">
AND (nor.`name` like concat("%",#{query.consignorNameOrPhone},"%") or nor.`phone` like concat("%",#{query.consignorNameOrPhone},"%") or nor.`company` like concat("%",#{query.consignorNameOrPhone},"%"))
AND (nor.`name` like concat("%",#{query.consignorNameOrPhone},"%") or nor.`phone` like
concat("%",#{query.consignorNameOrPhone},"%") or nor.`company` like
concat("%",#{query.consignorNameOrPhone},"%"))
</if>
<if test="query.consigneeNameOrPhone != null and query.consigneeNameOrPhone != '' ">
AND (nee.`name` like concat("%",#{query.consigneeNameOrPhone},"%") or nee.`phone` like concat("%",#{query.consigneeNameOrPhone},"%") or nee.`company` like concat("%",#{query.consigneeNameOrPhone},"%"))
AND (nee.`name` like concat("%",#{query.consigneeNameOrPhone},"%") or nee.`phone` like
concat("%",#{query.consigneeNameOrPhone},"%") or nee.`company` like
concat("%",#{query.consigneeNameOrPhone},"%"))
</if>
<if test="query.orderNo != null and query.orderNo != '' ">
AND r.`order_no` like concat("%",concat(#{query.orderNo},"%"))
......@@ -252,15 +256,13 @@
</select>
<select id="costDetailAmount" resultType="cn.iocoder.yudao.module.wealth.vo.receivable.WealthMoneyAmountVO">
SELECT
r.currency_id,
SELECT r.currency_id,
SUM(r.total_amount) AS total_amount,
SUM(r.tax_amount) AS tax_amount,
SUM(r.discount_total) AS discount_total,
SUM(r.write_off_amount) AS write_off_amount
FROM ecw_receivable r
WHERE
r.deleted = 0
WHERE r.deleted = 0
GROUP BY r.currency_id
</select>
<select id="batchGenReceiptPage" resultType="cn.iocoder.yudao.module.wealth.vo.receivable.BatchGenReceiptPageVO">
......@@ -269,6 +271,7 @@
r.order_no,
e.tidan_no,
e.transport_id,
e.shipment_state AS selfNoStatus,
de.departure_warehouse_id,
ob.objective_warehouse_id,
e.status AS order_status,
......@@ -308,18 +311,20 @@
</select>
<select id="calculateReceivableAmountByOrderId"
resultType="cn.iocoder.yudao.module.wealth.vo.receiptItem.CurrencyAmount">
SELECT
r.currency_id,
SELECT r.currency_id,
SUM(r.total_amount) AS amount
FROM ecw_receivable r
WHERE r.deleted = 0 AND r.order_id = #{orderId} AND r.receipt_id IS NULL
WHERE r.deleted = 0
AND r.order_id = #{orderId}
AND r.receipt_id IS NULL
GROUP BY r.currency_id
</select>
<select id="batchGenReceiptReceivablePage"
resultType="cn.iocoder.yudao.module.wealth.vo.receivable.BatchGenReceiptReceivablePageVO">
SELECT r.*
FROM ecw_receivable r
WHERE r.order_id = #{query.orderId} AND r.receipt_id IS NULL AND r.payment_user = #{query.paymentUser} AND r.deleted = 0
WHERE r.order_id = #{query.orderId} AND r.receipt_id IS NULL AND r.payment_user = #{query.paymentUser} AND
r.deleted = 0
<include refid="feeCondition"></include>
</select>
<select id="batchGenReceiptReceivablAmount"
......@@ -328,7 +333,8 @@
r.currency_id,
SUM(r.total_amount) AS amount
FROM ecw_receivable r
WHERE r.order_id = #{query.orderId} AND r.receipt_id IS NULL AND r.payment_user = #{query.paymentUser} AND r.deleted = 0
WHERE r.order_id = #{query.orderId} AND r.receipt_id IS NULL AND r.payment_user = #{query.paymentUser} AND
r.deleted = 0
<include refid="feeCondition"></include>
GROUP BY r.currency_id
</select>
......@@ -439,4 +445,128 @@
AND nor.name = #{query.consignor}
</if>
</sql>
<select id="getReceivableBoxPage"
resultType="cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableBoxReportPageVO">
SELECT
eb.id,
eb.self_no,
eb.dg_date,
eb.qg_date,
eb.orderCount,
eb.ladingCount,
eb.dest_country_id,
ebs.sl_settled_time,
ebcn.ul_warehouse_time
FROM (
SELECT
box.id id,
box.self_no self_no,
box.dg_date dg_date,
box.qg_date qg_date,
box.dest_country_id dest_country_id,
box.start_warehouse_id start_warehouse_id,
box.dest_warehouse_id dest_warehouse_id,
box.sl_status sl_status,
box.shipment_status shipment_status,
ifnull( preload.orderCount, 0 ) orderCount,
ifnull( lading.ladingCount, 0 ) ladingCount
FROM
ecw_box box
LEFT JOIN ( SELECT shipment_id, COUNT( DISTINCT order_id ) AS orderCount FROM ecw_box_preload_goods WHERE deleted = 0 AND is_remove = 0 GROUP BY shipment_id ) preload ON box.id = preload.shipment_id
LEFT JOIN ( SELECT shipment_id, COUNT(*) AS ladingCount FROM ecw_make_bill_of_lading WHERE deleted = 0 AND STATUS = 2 GROUP BY shipment_id ) lading ON box.id = lading.shipment_id
WHERE
box.deleted = 0 AND box.pr_status &gt; 21 AND box.dest_country_id > 0
<if test="query.beginDaogangTime != null and query.endDaogangTime != null">
AND box.dg_date BETWEEN #{query.beginDaogangTime} AND #{query.endDaogangTime}
</if>
<if test="query.beginQingguanTime != null and query.endQingguanTime != null">
AND box.qg_date BETWEEN #{query.beginQingguanTime} AND #{query.endQingguanTime}
</if>
<if test="query.selfNo != null and query.selfNo != '' ">
AND box.self_no LIKE concat('%',#{query.selfNo},'%')
</if>
<if test="query.startWarehouseIdList != null and query.startWarehouseIdList.size() > 0">
AND box.start_warehouse_id IN
<foreach collection="query.startWarehouseIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="query.destWarehouseIdList != null and query.destWarehouseIdList.size() > 0">
AND box.dest_warehouse_id IN
<foreach collection="query.destWarehouseIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="query.boxStatus != null">
AND box.shipment_status = #{query.boxStatus}
</if>
<if test="query.slStatus != null">
AND box.sl_status = #{query.slStatus}
</if>
) eb
LEFT JOIN ecw_box_cabinet_unload ebcn ON eb.id = ebcn.shipment_id
LEFT JOIN ecw_box_settlement ebs ON eb.id = ebs.shipment_id
<if test="query.beginUlWarehouseTime != null and query.endUlWarehouseTime != null">
LEFT JOIN ecw_box_clearance ebc ON eb.id = ebc.shipment_id
</if>
WHERE 1 = 1
<if test="query.beginJsDate != null and query.endJsDate != null">
AND ebs.sl_settled_time BETWEEN #{query.beginJsDate} AND #{query.endJsDate}
</if>
<if test="query.beginUlWarehouseTime != null and query.endUlWarehouseTime != null">
AND ebc.cl_clear_time BETWEEN #{query.beginUlWarehouseTime} AND #{query.endUlWarehouseTime}
</if>
<if test="query.ladingBillStatus != null">
<if test="query.ladingBillStatus == 0">
AND eb.ladingCount = 0
</if>
<if test="query.ladingBillStatus == 1">
AND eb.ladingCount &gt; 0 AND eb.ladingCount != eb.orderCount
</if>
<if test="query.ladingBillStatus == 2">
AND eb.ladingCount &gt; 0 AND eb.ladingCount = eb.orderCount
</if>
</if>
GROUP BY eb.id
</select>
<select id="getReceivableBoxRelationOrders"
resultType="cn.iocoder.yudao.module.wealth.vo.receivable.ReceivebleBoxRelationOrder">
SELECT
ebpg.shipment_id,
ebpg.order_id,
eb.dest_country_id
FROM ecw_box_preload_goods ebpg
LEFT JOIN ecw_box eb ON ebpg.shipment_id = eb.id
WHERE ebpg.is_remove = 0
AND eb.dest_country_id > 0
AND ebpg.shipment_id IN
<foreach collection="shipmentIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
GROUP BY ebpg.shipment_id,ebpg.order_id
</select>
<select id="selectBoxReceivablesByOrderIds"
resultType="cn.iocoder.yudao.module.wealth.dal.dataobject.receivable.ReceivableDO">
SELECT
id,
order_id,
currency_id,
tax_amount,
total_amount,
discount_total,
fee_type,
write_off_amount,
dest_country_currency_id,
dest_country_rate,
dest_country_sub_rate
FROM ecw_receivable
WHERE order_id IN
<foreach collection="orderIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getAllBoxId" resultType="java.lang.Long">
SELECT id FROM ecw_box WHERE deleted = 0 AND pr_status &gt; 21 AND dest_country_id > 0
</select>
</mapper>
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