From 38b9bc343b81b43fe8ca219b9dce7192cb5980f5 Mon Sep 17 00:00:00 2001 From: zhengfangyuan Date: Sun, 4 Sep 2022 15:19:45 +0800 Subject: [PATCH] fix pay v3 share --- .../db/migration/V2022090300001_seller.sql | 213 +++++++++++++++++- .../schedule/SharingOrderRedoSchedule.java | 2 +- .../domain/dto/WxSharingOrderDto.java | 8 +- .../com/iformall/domain/po/WxPayAccount.java | 3 +- .../com/iformall/domain/po/WxPayOrder.java | 14 +- .../service/WxProfitSharingOrderService.java | 2 +- .../impl/WxCouponOrderServiceImpl.java | 24 +- .../service/impl/WxOrderServiceImpl.java | 6 +- .../service/impl/WxPayOrderServiceImpl.java | 99 ++++---- .../impl/WxProfitSharingOrderServiceImpl.java | 43 ++-- .../entity/WxComposeChildOrderShare.java | 18 +- .../service/order/util/OrderHelper.java | 24 +- .../service/share/PayShareAdapterService.java | 2 +- .../share/douyin/TtPayShareService.java | 5 +- .../share/entity/PayShareCalculateAmount.java | 17 +- .../share/wx/sft/WxPayShareSFTService.java | 4 +- .../share/wx/v2/WxPayShareService.java | 4 +- .../share/wx/v3/WxPayShareV3Service.java | 5 +- .../resources/mapper/WxPayAccountMapper.xml | 3 +- .../resources/mapper/WxPayOrderMapper.xml | 8 +- 20 files changed, 368 insertions(+), 136 deletions(-) diff --git a/mallinkAdmin/src/main/resources/db/migration/V2022090300001_seller.sql b/mallinkAdmin/src/main/resources/db/migration/V2022090300001_seller.sql index c6a04c566..a70c6b79a 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V2022090300001_seller.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V2022090300001_seller.sql @@ -18,4 +18,215 @@ CREATE TABLE `seller_agent_account` ( `update_time` datetime DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `UNIQUE_A_M_P` (`seller_agent_id`,`merchant_u_id`,`plat`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +ALTER TABLE `mallink`.`wx_pay_account` +ADD COLUMN `system_rate` int(6) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `real_rate`; + +alter table wx_pay_order_0 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_1 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_2 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_3 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_4 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_5 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_6 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_7 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_8 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_9 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_10 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_11 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_12 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_13 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_14 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_15 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_16 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_17 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_18 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_19 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_20 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_21 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_22 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_23 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_24 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_25 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_26 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_27 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_28 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_29 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_30 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_31 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_32 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_33 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_34 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_35 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_36 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_37 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_38 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_39 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_40 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_41 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_42 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_43 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_44 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_45 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_46 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_47 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_48 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_49 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_50 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_51 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_52 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_53 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_54 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_55 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_56 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_57 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_58 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_59 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_60 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_61 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_62 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_63 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_64 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_65 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_66 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_67 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_68 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_69 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_70 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_71 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_72 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_73 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_74 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_75 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_76 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_77 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_78 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_79 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_80 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_81 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_82 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_83 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_84 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_85 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_86 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_87 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_88 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_89 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_90 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_91 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_92 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_93 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_94 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_95 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_96 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_97 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_98 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; +alter table wx_pay_order_99 add column `system_amount` int(11) NOT NULL DEFAULT 0 COMMENT '系统扣点' AFTER `share_amount`; + + +ALTER TABLE wx_pay_order_0 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_1 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_2 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_3 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_4 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_5 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_6 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_7 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_8 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_9 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_10 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_11 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_12 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_13 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_14 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_15 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_16 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_17 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_18 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_19 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_20 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_21 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_22 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_23 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_24 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_25 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_26 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_27 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_28 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_29 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_30 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_31 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_32 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_33 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_34 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_35 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_36 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_37 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_38 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_39 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_40 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_41 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_42 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_43 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_44 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_45 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_46 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_47 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_48 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_49 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_50 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_51 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_52 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_53 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_54 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_55 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_56 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_57 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_58 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_59 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_60 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_61 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_62 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_63 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_64 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_65 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_66 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_67 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_68 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_69 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_70 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_71 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_72 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_73 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_74 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_75 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_76 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_77 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_78 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_79 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_80 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_81 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_82 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_83 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_84 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_85 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_86 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_87 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_88 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_89 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_90 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_91 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_92 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_93 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_94 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_95 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_96 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_97 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_98 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; +ALTER TABLE wx_pay_order_99 ADD COLUMN `commission_amount` INT(11) NOT NULL DEFAULT 0 COMMENT '平台(微信,抖音)扣点' AFTER `system_amount`; + + + + + diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoSchedule.java index e9a982e61..6340ae985 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoSchedule.java @@ -71,7 +71,7 @@ public class SharingOrderRedoSchedule { + " ID:" +sharingOrder.getId() + " RES: wxPayOrder is null." ); } - ResultData result = wxProfitSharingOrderService.redoSharingOrder(sharingOrder,wxPayOrder,wxPayOrder.getShareAmount()); + ResultData result = wxProfitSharingOrderService.redoSharingOrder(sharingOrder,wxPayOrder); if (result.code != ResultData.SUCCESS) { logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getMessage() + " ID:" +sharingOrder.getId() diff --git a/mallinkService/src/main/java/com/iformall/domain/dto/WxSharingOrderDto.java b/mallinkService/src/main/java/com/iformall/domain/dto/WxSharingOrderDto.java index c719670d2..573cd638d 100644 --- a/mallinkService/src/main/java/com/iformall/domain/dto/WxSharingOrderDto.java +++ b/mallinkService/src/main/java/com/iformall/domain/dto/WxSharingOrderDto.java @@ -24,13 +24,15 @@ public class WxSharingOrderDto extends TenantEntity { private Long payMerchantId; @io.swagger.annotations.ApiModelProperty(value="支付时收款商户号",name="payMerchantMchId") private String payMerchantMchId; - @io.swagger.annotations.ApiModelProperty(value="分账金额(总金额扣除手续费后的金额)",name="shareAmount") + @io.swagger.annotations.ApiModelProperty(value="分账金额(总金额扣除手续费后的金额,系统扣点)",name="shareAmount") private Integer shareAmount; @io.swagger.annotations.ApiModelProperty(value="分账通道费差()",name="rateAmount") private Integer rateAmount; - private Integer realRateAmount;//平台手续费 - private Integer commissionAmount;//平台佣金 + private Integer realRateAmount;//平台手续费(微信,抖音) + private Integer commissionAmount;//平台佣金(微信,抖音) + + private Integer systemAmount;//系统扣点费 @io.swagger.annotations.ApiModelProperty(value="支付发起时间",name="payTimeStart") private Date payTimeStart; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java b/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java index 8f7b1e1ea..6ed91247c 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxPayAccount.java @@ -56,7 +56,8 @@ public class WxPayAccount extends TenantEntity { private Integer rate; @io.swagger.annotations.ApiModelProperty(value="实际手续费(万分之几,默认60)",name="realRate") private Integer realRate; - + @io.swagger.annotations.ApiModelProperty(value="系统提点,包含在rate之内",name="systemRate") + private Integer systemRate; public String getPayNotifyV3Url() { return notifyUrl + "/pay/v3/"+this.getTenantId(); diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxPayOrder.java b/mallinkService/src/main/java/com/iformall/domain/po/WxPayOrder.java index 6549a9077..f76c748c8 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxPayOrder.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxPayOrder.java @@ -67,10 +67,14 @@ public class WxPayOrder extends TenantEntity { private Integer mchType; @io.swagger.annotations.ApiModelProperty(value="分账状态: 0-未分账;1-分账",name="payOrderStatus") private Integer share; - @io.swagger.annotations.ApiModelProperty(value="分账金额(总金额扣除手续费后的金额)",name="shareAmount") + @io.swagger.annotations.ApiModelProperty(value="商户实际分账金额",name="shareAmount") private Integer shareAmount; - @io.swagger.annotations.ApiModelProperty(value="通道费差(购买时刻的通道费差,分账完结时使用)",name="rateAmount") + @io.swagger.annotations.ApiModelProperty(value="商场实际通道费(扣除了支付通道费)",name="rateAmount") private Integer rateAmount; + @io.swagger.annotations.ApiModelProperty(value="系统抽点费",name="systemAmount") + private Integer systemAmount; + @io.swagger.annotations.ApiModelProperty(value="平台(微信,抖音)抽点",name="commissionAmount") + private Integer commissionAmount; // @io.swagger.annotations.ApiModelProperty(value="收款账户 (抖音分账用)",name="storeId") // private String storeId; @io.swagger.annotations.ApiModelProperty(value="子订单分账金额json",name="childOrderShare") @@ -101,13 +105,13 @@ public class WxPayOrder extends TenantEntity { public WxComposeChildOrderShare getChildOrderShare(Long wxOrderId) { if (StringUtils.isBlank(this.childOrderShare)) { - return new WxComposeChildOrderShare(this.payAmount, this.shareAmount, this.rateAmount,null,null,null,null,null); + return new WxComposeChildOrderShare(this.payAmount, this.shareAmount, this.rateAmount,0,this.commissionAmount,this.systemAmount,null,null,wxOrderId); } Map childs = JSON.parseObject(this.childOrderShare, Map.class); JSONObject childOrderShare = (JSONObject) childs.get(String.valueOf(wxOrderId)); if (null != childOrderShare) { return new WxComposeChildOrderShare(childOrderShare.getInteger("realPayMent"), childOrderShare.getInteger("shareAmount"), childOrderShare.getInteger("rateAmount"), - childOrderShare.getInteger("realRateAmount"), childOrderShare.getInteger("commissionAmount"), + childOrderShare.getInteger("realRateAmount"), childOrderShare.getInteger("commissionAmount"),childOrderShare.getInteger("systemAmount"), childOrderShare.getLong("merchantId"),childOrderShare.getString("merchantUid"),childOrderShare.getLong("orderId")); } return null; @@ -123,7 +127,7 @@ public class WxPayOrder extends TenantEntity { for (Iterator it = childs.keySet().iterator();it.hasNext();) { JSONObject childOrderShare = (JSONObject) childs.get(it.next()); WxComposeChildOrderShare child = new WxComposeChildOrderShare(childOrderShare.getInteger("realPayMent"), childOrderShare.getInteger("shareAmount"), childOrderShare.getInteger("rateAmount"), - childOrderShare.getInteger("realRateAmount"), childOrderShare.getInteger("commissionAmount"), + childOrderShare.getInteger("realRateAmount"), childOrderShare.getInteger("commissionAmount"),childOrderShare.getInteger("systemAmount"), childOrderShare.getLong("merchantId"),childOrderShare.getString("merchantUid"),childOrderShare.getLong("orderId")); childList.add(child); if (null != index && index.intValue() == _index) { diff --git a/mallinkService/src/main/java/com/iformall/service/WxProfitSharingOrderService.java b/mallinkService/src/main/java/com/iformall/service/WxProfitSharingOrderService.java index 6e448afa9..57acf2a0d 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxProfitSharingOrderService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxProfitSharingOrderService.java @@ -26,7 +26,7 @@ public interface WxProfitSharingOrderService { /** * 分账重试 */ - ResultData redoSharingOrder(WxProfitSharingOrder sharingOrder,WxPayOrder payOrder,Integer merchantShareAmount); + ResultData redoSharingOrder(WxProfitSharingOrder sharingOrder,WxPayOrder payOrder); /** * 分账完结重试 diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java index 44fa8a8e7..c11307ef8 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java @@ -34,6 +34,8 @@ import com.iformall.service.order.entity.WxComposeOrder; import com.iformall.service.order.util.OrderHelper; import com.iformall.service.pay.PayServiceFactory; import com.iformall.service.pay.service.pay.douyin.v1.miniApp.EnumTtPayChannel; +import com.iformall.service.pay.service.share.PayShareAdapterService; +import com.iformall.service.pay.service.share.entity.PayShareCalculateAmount; import com.iformall.utils.Constant; import com.iformall.utils.DateUtils; import com.iformall.utils.PayUtils; @@ -1757,6 +1759,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { wxSharingOrderDto.setRateAmount(childShare.getRateAmount()); wxSharingOrderDto.setRealRateAmount(childShare.getRealRateAmount()); wxSharingOrderDto.setCommissionAmount(childShare.getCommissionAmount()); + wxSharingOrderDto.setSystemAmount(childShare.getSystemAmount()); wxSharingOrderDto.setOrderId(wxPayOrder.getId()); wxSharingOrderDto.setPayTimeStart(wxPayOrder.getPayTimeStart()); wxSharingOrderDto.setPayTimeEnd(wxPayOrder.getPayTimeEnd()); @@ -2718,29 +2721,26 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { payOrder.setAuthCode(authCode); Integer payAmount = composeOrder.getSingleOrder().getPayment() - wxCoupon.getPrice(); payOrder.setPayAmount(payAmount); -// if (microOrder.getPayment() > wxCoupon.getPrice()) { -// payOrder.setPayAmount(wxCoupon.getPrice()); -// } else { -// payOrder.setPayAmount(microOrder.getPayment()); -// } payOrder.setPayVendor(payWay.getCode()); payOrder.setPayVersion(payVersion.getCode()); payOrder.setPayOrderStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); payOrder.setShare(shareCode); + int systemAmount = OrderHelper.getAmount(payAmount, payAccount.getSystemRate()); + PayShareAdapterService payShareServie = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion()); + int rate = payShareServie.getOfficialCommission(composeOrder.getSingleOrder(),payAccount);//抖音分佣率 + PayShareCalculateAmount oShareAmount = payShareServie.calculateAmount(payAmount,rate,systemAmount, payAccount); if (shareCode.intValue() == EnumPayShare.YES.getCode().intValue()) { // 分账金额 - int iChargeFee = OrderHelper.getMallCharge(payAmount, payAccount); - Integer share_amount = payAmount - iChargeFee; - payOrder.setShareAmount(share_amount); + payOrder.setShareAmount(oShareAmount.getMerchantShareAmount()); if(payAccount.getRealRate() != null) { - int iRealChargeFee = PayUtils.getPayRate(payAmount, payAccount.getRealRate(), true); - payOrder.setRateAmount(iRealChargeFee); + payOrder.setRateAmount(oShareAmount.getMallRealRateAmount()); } - if (share_amount <= 0) { + if (oShareAmount.getMerchantShareAmount() <= 0) { payOrder.setShare(EnumPayShare.NO.getCode()); } - } + payOrder.setCommissionAmount(oShareAmount.getCommissionAmount()); + payOrder.setSystemAmount(oShareAmount.getSystemAmount()); payOrder.setPayFrom(EnumPayFrom.INSIDE_B.getCode()); payOrder.setPosPayOrderId(couponOrder.getId()); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java index e026396c4..f39f07210 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java @@ -1456,12 +1456,14 @@ public class WxOrderServiceImpl implements WxOrderService { cardInfo.setRateAmount(share.getRateAmount()); } else { // 未开启分账 - Integer orderRealPayMent = payOrder.getChildOrderShare(order.getId()).getRealPayMent(); + WxComposeChildOrderShare share = payOrder.getChildOrderShare(order.getId()); + Integer orderRealPayMent = share.getRealPayMent(); fee = OrderHelper.getMallCharge(orderRealPayMent, payAccount); Integer shareAmount = orderRealPayMent - fee; cardInfo.setShareFeeAmount(shareAmount); cardInfo.setRemainingShareFeeAmount(shareAmount); - cardInfo.setRateAmount(OrderHelper.getRateAmount(orderRealPayMent, fee, payAccount)); + int systemAmount = OrderHelper.getAmount(orderRealPayMent, payAccount.getSystemRate());//系统扣点 + cardInfo.setRateAmount(OrderHelper.getMallRateAmount(orderRealPayMent, fee,systemAmount, payAccount)); } } } else { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java index 5bea653dc..7b9750d3f 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java @@ -408,13 +408,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { } }else { // 3.1 创建支付订单 -// Long id = idworker.nextId(); -// if (null == id || id.longValue() <=0) { -// throw new MallinkException(ErrorCode.PAY_ORDER_PAYING.getCode(),"订单支付流水号生成失败!new payorder:"+record.getOrderId()+",id:"+id); -// } - Long id = record.getOrderId();//支付订单号=订单号 - record.setId(id); record.updateTenantInfo(composeOrder); record.setCUserId(user.getId()); @@ -432,48 +426,46 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { record.setMchType(payMchType.getCode()); record.setShare(isShare.getCode()); record.setComposeOrder(composeOrder.getComposeOrderType()); -// if (isShare == EnumPayShare.YES) { -// PayShareCalculateAmount recordShareAmount = payShareServie.calculateAmount(record.getPayAmount(), payAccount); -// // 分账金额 -// Integer share_amount = recordShareAmount.getShareAmount(); -// record.setShareAmount(share_amount); -// record.setRateAmount(recordShareAmount.getRateAmount()); - //设置子订单分账金额 - Map childShares = new HashMap(); - OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(composeOrder.getComposeOrderType()); - List orderList = orderAdapterService.getChildOrders(composeOrder, appInfo.getTenantId()); - if(orderList == null || orderList.isEmpty()){ - logger.error("getChildOrders null" + record.toString()); - throw new MallinkException(ErrorCode.PAY_ORDER_ERROR); - } - int share_amount = 0; - int rate_amount = 0; - //todo 注意购物车模式(需测试)每笔子订单算法可能与总订单算法有差 - for (WxOrder o : orderList) { - Long merchant_id = null; - String merchant_uid = ""; - if(EnumPayMchType.DIRECT.equals(payMchType)){//直连模式记录收款商户 - //11111111111加缓存 - merchant_id = wxCouponChannelService.getCouponOneMerchantId(o.getCouponChannelId(),o.getTenantId()); - WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, payMchTypeEnum.getCode()); - if(receiver == null){ - throw new MallinkException(ErrorCode.PAY_ORDER_MERCHANT_UID_ERROR); - } - merchant_uid = receiver.getReceiverAccount(); + //设置子订单分账金额 + Map childShares = new HashMap(); + OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(composeOrder.getComposeOrderType()); + List orderList = orderAdapterService.getChildOrders(composeOrder, appInfo.getTenantId()); + if(orderList == null || orderList.isEmpty()){ + logger.error("getChildOrders null" + record.toString()); + throw new MallinkException(ErrorCode.PAY_ORDER_ERROR); + } + int merchantShare_amount = 0; + int mall_real_rate_amount = 0; + int sys_share_amount = 0;//系统的提点 + int commission_amount = 0;//平台(微信,抖音)扣点 + //TODO 注意购物车模式(需测试)每笔子订单算法可能与总订单算法有差 + for (WxOrder o : orderList) { + Long merchant_id = null; + String merchant_uid = ""; + if(EnumPayMchType.DIRECT.equals(payMchType)){//直连模式记录收款商户 + //TODO 11111111111加缓存 + merchant_id = wxCouponChannelService.getCouponOneMerchantId(o.getCouponChannelId(),o.getTenantId()); + WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, payMchTypeEnum.getCode()); + if(receiver == null){ + throw new MallinkException(ErrorCode.PAY_ORDER_MERCHANT_UID_ERROR); } - //1111111111111加缓存 - int rate = payShareServie.getOfficialCommission(o,payAccount);//抖音分佣率 - logger.info("抖音分佣率"+rate); - PayShareCalculateAmount oShareAmount = payShareServie.calculateAmount(o.getPayment(),rate, payAccount); - logger.info("佣金明细"+ JSON.toJSONString(oShareAmount)); - share_amount += oShareAmount.getShareAmount(); - rate_amount += oShareAmount.getRateAmount(); - childShares.put(String.valueOf(o.getId()), new WxComposeChildOrderShare(oShareAmount,merchant_id,merchant_uid,o.getId())); + merchant_uid = receiver.getReceiverAccount(); } - record.setShareAmount(share_amount); - record.setRateAmount(rate_amount); - record.setChildOrderShare(JSON.toJSONString(childShares)); -// } + //TODO 1111111111111加缓存 + int rate = payShareServie.getOfficialCommission(o,payAccount);//平台(微信,抖音)分佣率 + int systemAmount = OrderHelper.getAmount(o.getPayment(), payAccount.getSystemRate());//系统扣点 + PayShareCalculateAmount oShareAmount = payShareServie.calculateAmount(o.getPayment(),rate,systemAmount, payAccount); + merchantShare_amount += oShareAmount.getMerchantShareAmount(); + mall_real_rate_amount += oShareAmount.getMallRealRateAmount(); + sys_share_amount += oShareAmount.getSystemAmount(); + commission_amount += oShareAmount.getCommissionAmount(); + childShares.put(String.valueOf(o.getId()), new WxComposeChildOrderShare(oShareAmount,merchant_id,merchant_uid,o.getId())); + } + record.setShareAmount(merchantShare_amount); + record.setRateAmount(mall_real_rate_amount); + record.setSystemAmount(sys_share_amount); + record.setCommissionAmount(commission_amount); + record.setChildOrderShare(JSON.toJSONString(childShares)); int sqlRow = wxPayOrderMapper.insert(record); record.setCreatPay(true); @@ -586,22 +578,19 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { if(EnumPayMchType.DIRECT.getCode().equals(record.getMchType())){//直连模式记录收款商户 merchant_id = user.getMerchantId(); WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, merchant_id, null, record.getMchType()); -// merchant_uid = wxCouponChannelService.getCouponOneMerchantUid(payWay,merchant_id,o.getTenantId()); -// if(null == merchant_id || StringUtils.isBlank(merchant_uid)){ if(receiver == null){ throw new MallinkException(ErrorCode.PAY_ORDER_MERCHANT_UID_ERROR); } merchant_uid = receiver.getReceiverAccount(); } int rate = payShareServie.getOfficialCommission(order,payAccount);//抖音分佣率 - logger.info("抖音分佣率"+rate); - PayShareCalculateAmount oShareAmount = payShareServie.calculateAmount(order.getPayment(),rate, payAccount); - logger.info("佣金明细"+ JSON.toJSONString(oShareAmount)); - int share_amount = oShareAmount.getShareAmount(); - int rate_amount = oShareAmount.getRateAmount(); + int systemAmount = OrderHelper.getAmount(order.getPayment(), payAccount.getSystemRate());//系统扣点 + PayShareCalculateAmount oShareAmount = payShareServie.calculateAmount(order.getPayment(),rate,systemAmount, payAccount); childShares.put(String.valueOf(order.getId()), new WxComposeChildOrderShare(oShareAmount,merchant_id,merchant_uid,order.getId())); - record.setShareAmount(share_amount); - record.setRateAmount(rate_amount); + record.setShareAmount(oShareAmount.getMerchantShareAmount()); + record.setRateAmount(oShareAmount.getMallRealRateAmount()); + record.setSystemAmount(oShareAmount.getSystemAmount()); + record.setCommissionAmount(oShareAmount.getCommissionAmount()); record.setChildOrderShare(JSON.toJSONString(childShares)); int sqlRow = wxPayOrderMapper.insert(record); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java index baf622b75..5f26cbf6a 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java @@ -139,7 +139,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ @Override @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) - public ResultData redoSharingOrder(WxProfitSharingOrder sharingOrder,WxPayOrder payOrder,Integer merchantShareAmount) { + public ResultData redoSharingOrder(WxProfitSharingOrder sharingOrder,WxPayOrder payOrder) { if(!EnumProfitSharingOrderStatus.shareStatus().contains(sharingOrder.getSharingStatus())){ return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"分账状态不允许"); @@ -167,25 +167,28 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ recordJsonArray = JSONArray.parseArray(sharingOrder.getReceivers()); } - //TODO 要根据商户配置的提成点数来计算分账金额,wxPayOrder里面的金额是按照商场的统一比例算的,不对 - int rate = payShareAdapterService.getOfficialCommission(o,payAccount);//抖音分佣率 - PayShareCalculateAmount oShareAmount = payShareAdapterService.calculateAmount(o.getPayment(),rate, payAccount); - - //直连模式 - if (EnumPayMchType.DIRECT.getCode() == payOrder.getMchType()) { - //当前商户的收款账号,为了加上收款记录 - WxProfitSharingReceiver receiver = payShareAdapterService.getReceiver(sharingOrder, sharingOrder.getMerchantId(), payOrder.getTtPayWay(), payOrder.getMchType()); - if (null == receiver) { - return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"当前商户未配置收款账号"); - } - StringBuffer sb = new StringBuffer("{").append("\"description\":").append(receiver.getId()).append(",\"amount\":").append(merchantShareAmount).append("}"); - if (null == recordJsonArray) { - recordJsonArray = JSONArray.parseArray("["+sb.toString()+"]"); - }else { - recordJsonArray.add(JSON.parseObject(sb.toString())); - } - } + //TODO 我们的提成,绑定的销售提点,商场的提成要根据商户配置的提成点数来计算分账金额,wxPayOrder里面的金额是按照商场的统一比例算的,不对 +// int rate = payShareAdapterService.getOfficialCommission(o,payAccount);//抖音分佣率 +// PayShareCalculateAmount oShareAmount = payShareAdapterService.calculateAmount(o.getPayment(),rate, payAccount); +// +// +// +// +// //直连模式 +// if (EnumPayMchType.DIRECT.getCode() == payOrder.getMchType()) { +// //当前商户的收款账号,为了加上收款记录 +// WxProfitSharingReceiver receiver = payShareAdapterService.getReceiver(sharingOrder, sharingOrder.getMerchantId(), payOrder.getTtPayWay(), payOrder.getMchType()); +// if (null == receiver) { +// return new ResultData(ErrorCode.PROFIT_SHARING_REQUEST_FAILED.getCode(),"当前商户未配置收款账号"); +// } +// StringBuffer sb = new StringBuffer("{").append("\"description\":").append(receiver.getId()).append(",\"amount\":").append(0).append("}"); +// if (null == recordJsonArray) { +// recordJsonArray = JSONArray.parseArray("["+sb.toString()+"]"); +// }else { +// recordJsonArray.add(JSON.parseObject(sb.toString())); +// } +// } List resultList = new ArrayList(); if(jsonArray == null || jsonArray.isEmpty()){ @@ -258,7 +261,7 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ return new ResultData(); } - ResultData resultData = redoSharingOrder(record,payOrder,sharingOrderDto.getShareAmount()); + ResultData resultData = redoSharingOrder(record,payOrder); return resultData; } diff --git a/mallinkService/src/main/java/com/iformall/service/order/entity/WxComposeChildOrderShare.java b/mallinkService/src/main/java/com/iformall/service/order/entity/WxComposeChildOrderShare.java index eee36cb6e..f02f2d842 100644 --- a/mallinkService/src/main/java/com/iformall/service/order/entity/WxComposeChildOrderShare.java +++ b/mallinkService/src/main/java/com/iformall/service/order/entity/WxComposeChildOrderShare.java @@ -11,13 +11,14 @@ import lombok.Data; @Data public class WxComposeChildOrderShare { - public WxComposeChildOrderShare(Integer realPayMent,Integer shareAmount,Integer rateAmount,Integer realRateAmount,Integer commissionAmount, + public WxComposeChildOrderShare(Integer realPayMent,Integer shareAmount,Integer rateAmount,Integer realRateAmount,Integer commissionAmount,Integer systemAmount, Long merchantId,String merchantUid,Long orderId) { this.realPayMent = realPayMent; this.shareAmount = shareAmount; this.rateAmount = rateAmount; this.realRateAmount = realRateAmount; this.commissionAmount = commissionAmount; + this.systemAmount = systemAmount; this.merchantId = merchantId; this.merchantUid = merchantUid; this.orderId = orderId; @@ -25,10 +26,11 @@ public class WxComposeChildOrderShare { public WxComposeChildOrderShare(PayShareCalculateAmount shareCalculateAmount,Long merchantId,String merchantUid,Long orderId) { this.realPayMent = shareCalculateAmount.getPayAmount(); - this.shareAmount = shareCalculateAmount.getShareAmount(); - this.rateAmount = shareCalculateAmount.getRateAmount(); + this.shareAmount = shareCalculateAmount.getMerchantShareAmount(); + this.rateAmount = shareCalculateAmount.getMallRealRateAmount(); this.realRateAmount = shareCalculateAmount.getRealRateAmount(); this.commissionAmount = shareCalculateAmount.getCommissionAmount(); + this.systemAmount = shareCalculateAmount.getSystemAmount(); this.merchantId = merchantId; this.merchantUid = merchantUid; this.orderId = orderId; @@ -37,12 +39,14 @@ public class WxComposeChildOrderShare { private Long orderId;//订单编号,v3要用 private Integer realPayMent;//付款金额 - private Integer shareAmount;//分账的钱(分给商户的) + private Integer shareAmount;//商户实际分账的钱 - private Integer rateAmount;//通道费(广场收的) + private Integer rateAmount;//商场实际通道费(扣除了支付通道费的) - private Integer realRateAmount;//平台手续费 - private Integer commissionAmount;//平台佣金 + private Integer realRateAmount;//平台手续费(微信,抖音) + private Integer commissionAmount;//平台佣金(微信,抖音) + + private Integer systemAmount;//系统扣点费 private Long merchantId;//收款商户 private String merchantUid;//收款商户 diff --git a/mallinkService/src/main/java/com/iformall/service/order/util/OrderHelper.java b/mallinkService/src/main/java/com/iformall/service/order/util/OrderHelper.java index 8639a4c3f..613900adc 100644 --- a/mallinkService/src/main/java/com/iformall/service/order/util/OrderHelper.java +++ b/mallinkService/src/main/java/com/iformall/service/order/util/OrderHelper.java @@ -1,10 +1,12 @@ package com.iformall.service.order.util; +import com.iformall.common.ErrorCode; import com.iformall.domain.po.WxCoupon; import com.iformall.domain.po.WxCouponChannel; import com.iformall.domain.po.WxPayAccount; import com.iformall.enums.EnumCouponType; import com.iformall.enums.EnumOrderStatus; +import com.iformall.exception.MallinkException; import com.iformall.utils.PayUtils; public class OrderHelper { @@ -50,12 +52,16 @@ public class OrderHelper { return orderStatus; } - //分账金额,扣掉商场设置的手续费率,默认取最小整数,不四舍五入 + public static int getAmount(Integer payment,Integer rate) { + return PayUtils.getPayRate(payment, rate, false); + } + + //商场总包费用,扣掉商场设置的手续费率,默认取最小整数,不四舍五入 public static int getMallCharge(Integer payment,WxPayAccount payAccount) { int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRate(), false); return iChargeFee; } - //分账金额,扣掉商场设置的手续费率,是否四舍五入 + //商场总包费用,扣掉商场设置的手续费率,是否四舍五入 public static int getMallCharge(Integer payment,WxPayAccount payAccount,boolean round) { int iChargeFee = PayUtils.getPayRate(payment, payAccount.getRate(), round); return iChargeFee; @@ -71,18 +77,18 @@ public class OrderHelper { int iRealChargeFee = PayUtils.getPayRate(payment, payAccount.getRealRate(), true); return iRealChargeFee; } - return -1; + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"支付通道费率未设置."); } - //费率差. iChargeFee:商场扣掉的手续费 - public static Integer getRateAmount(Integer payment,int mallCharge, WxPayAccount payAccount) { + public static Integer getMallRateAmount(Integer payment,int mallCharge,int systemAmount, WxPayAccount payAccount) { int iRealChargeFee = getRealRateAmount(payment, payAccount); if (iRealChargeFee < 0) { - return null; + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"支付通道费率设置非法."); } - if(mallCharge > iRealChargeFee) { - return mallCharge - iRealChargeFee; + if(mallCharge > (iRealChargeFee + systemAmount)) { + return mallCharge - iRealChargeFee - systemAmount; + }else { + throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"支付费率设置非法:商场总扣点小于支付通道和系统扣点之和."); } - return null; } } diff --git a/mallinkService/src/main/java/com/iformall/service/pay/service/share/PayShareAdapterService.java b/mallinkService/src/main/java/com/iformall/service/pay/service/share/PayShareAdapterService.java index 4ad2f7e13..15a0256fa 100644 --- a/mallinkService/src/main/java/com/iformall/service/pay/service/share/PayShareAdapterService.java +++ b/mallinkService/src/main/java/com/iformall/service/pay/service/share/PayShareAdapterService.java @@ -41,7 +41,7 @@ public interface PayShareAdapterService { /** * 计算商场分账金额和实际费率金额 */ - public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,WxPayAccount payAccount); + public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,Integer systemAmount,WxPayAccount payAccount); /** * 查询商户的收款账号信息 diff --git a/mallinkService/src/main/java/com/iformall/service/pay/service/share/douyin/TtPayShareService.java b/mallinkService/src/main/java/com/iformall/service/pay/service/share/douyin/TtPayShareService.java index 19a97959d..c4c301261 100644 --- a/mallinkService/src/main/java/com/iformall/service/pay/service/share/douyin/TtPayShareService.java +++ b/mallinkService/src/main/java/com/iformall/service/pay/service/share/douyin/TtPayShareService.java @@ -93,11 +93,11 @@ public class TtPayShareService extends PayShareBaseAdapterService{ } @Override - public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate, WxPayAccount payAccount) { + public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,Integer systemAmount, WxPayAccount payAccount) { int mallCharge = OrderHelper.getMallCharge(payAmount, payAccount,true); Integer realRateAmount = OrderHelper.getRealRateAmount(payAmount, payAccount); int officialCommission = PayUtils.getPayRate(payAmount, officialCommissionRate, true); - return new PayShareCalculateAmount(payAmount,mallCharge,realRateAmount,officialCommission); + return new PayShareCalculateAmount(payAmount,mallCharge,realRateAmount,officialCommission,systemAmount); } @Override @@ -334,7 +334,6 @@ public class TtPayShareService extends PayShareBaseAdapterService{ JSONObject jo = new JSONObject(); jo.put("type",this.getShareAccount(receiver.getReceiverType()).getMessage()); jo.put("account",receiver.getReceiverAccount()); - jo.put("amount", childOrderShare.getShareAmount() - darenTakeAmount); jo.put("rateAmount", childOrderShare.getRateAmount()); jo.put("realRateAmount", childOrderShare.getRealRateAmount()); diff --git a/mallinkService/src/main/java/com/iformall/service/pay/service/share/entity/PayShareCalculateAmount.java b/mallinkService/src/main/java/com/iformall/service/pay/service/share/entity/PayShareCalculateAmount.java index cdcc18752..1af10f36c 100644 --- a/mallinkService/src/main/java/com/iformall/service/pay/service/share/entity/PayShareCalculateAmount.java +++ b/mallinkService/src/main/java/com/iformall/service/pay/service/share/entity/PayShareCalculateAmount.java @@ -12,17 +12,22 @@ public class PayShareCalculateAmount implements Serializable{ private static final long serialVersionUID = -3701322871877301001L; private Integer payAmount; - private Integer mallCharge;//商场拿走的钱+realRateAmount + + private Integer mallCharge;//商场总包费用,包括:商场拿走的钱+支付通道手续费(realRateAmount)+平台扣点(systemAmount) private Integer realRateAmount;//平台手续费(微信,抖音的支付通道费) + private Integer systemAmount;//系统扣点费,是包含在商场的扣点内的 + + //单独计算 private Integer commissionAmount;//平台佣金(微信,抖音平台抽点) + - //分账的钱 sellerAgentAmount:销售代理的抽成 - public Integer getShareAmount() { + //商户分账的钱 + public Integer getMerchantShareAmount() { return payAmount - mallCharge - commissionAmount; } - //商场拿走的钱 - public Integer getRateAmount() { - return mallCharge - realRateAmount; + //商场实际拿走的钱 + public Integer getMallRealRateAmount() { + return mallCharge - realRateAmount - systemAmount; } } diff --git a/mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/sft/WxPayShareSFTService.java b/mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/sft/WxPayShareSFTService.java index da6f781f1..76e5dfb2b 100644 --- a/mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/sft/WxPayShareSFTService.java +++ b/mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/sft/WxPayShareSFTService.java @@ -77,10 +77,10 @@ public class WxPayShareSFTService extends PayShareBaseAdapterService{ } @Override - public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate, WxPayAccount payAccount) { + public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,Integer systemAmount, WxPayAccount payAccount) { int mallCharge = OrderHelper.getMallCharge(payAmount, payAccount); Integer realRateAmount = OrderHelper.getRealRateAmount(payAmount, payAccount); - return new PayShareCalculateAmount(payAmount,mallCharge,realRateAmount,0); + return new PayShareCalculateAmount(payAmount,mallCharge,realRateAmount,0,systemAmount); } @Override diff --git a/mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v2/WxPayShareService.java b/mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v2/WxPayShareService.java index 2b58deef0..5f1613a68 100644 --- a/mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v2/WxPayShareService.java +++ b/mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v2/WxPayShareService.java @@ -70,10 +70,10 @@ public class WxPayShareService extends PayShareBaseAdapterService{ } @Override - public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate, WxPayAccount payAccount) { + public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,Integer systemAmount, WxPayAccount payAccount) { int mallCharge = OrderHelper.getMallCharge(payAmount, payAccount); Integer realRateAmount = OrderHelper.getRealRateAmount(payAmount, payAccount); - return new PayShareCalculateAmount(payAmount,mallCharge,realRateAmount,0); + return new PayShareCalculateAmount(payAmount,mallCharge,realRateAmount,0,systemAmount); } @Override diff --git a/mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v3/WxPayShareV3Service.java b/mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v3/WxPayShareV3Service.java index 3ef8a55d6..50395042e 100644 --- a/mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v3/WxPayShareV3Service.java +++ b/mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v3/WxPayShareV3Service.java @@ -70,10 +70,10 @@ public class WxPayShareV3Service extends PayShareBaseAdapterService{ } @Override - public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate, WxPayAccount payAccount) { + public PayShareCalculateAmount calculateAmount(Integer payAmount,Integer officialCommissionRate,Integer systemAmount, WxPayAccount payAccount) { int mallCharge = OrderHelper.getMallCharge(payAmount, payAccount); Integer realRateAmount = OrderHelper.getRealRateAmount(payAmount, payAccount); - return new PayShareCalculateAmount(payAmount,mallCharge,realRateAmount,0); + return new PayShareCalculateAmount(payAmount,mallCharge,realRateAmount,0,systemAmount); } @Override @@ -116,6 +116,7 @@ public class WxPayShareV3Service extends PayShareBaseAdapterService{ record.setType(sharingOrderDto.getType()); wxProfitSharingOrderMapper.insert(record); } + //分账需要加上 我们的提成,绑定的销售提点,商场的提成要根据商户配置的提成点数来计算分账金额,wxPayOrder里面的金额是按照商场的统一比例算的,不对 //如果是总分模式,则需要加上收款账户 if (mchType == EnumPayMchType.TOTAL.getCode()) { WxProfitSharingReceiver psReceiver = getReceiver(sharingOrderDto, sharingOrderDto.getMerchantId(), null,mchType); diff --git a/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml b/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml index f8f932619..77ceeddcd 100644 --- a/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxPayAccountMapper.xml @@ -24,6 +24,7 @@ + @@ -35,7 +36,7 @@ `id`,`tenant_id`,`parent_tenant_id`,`mch_id`,`sub_mch_id`,`sub_app_id`,`api_key`,`merchant_api_key`,`notify_url`,`notify_token`,`cert_path`, - `merchant_cert_path`,`type`,`mch_type`,`open_pay`,`share`,`rate`,`real_rate`, + `merchant_cert_path`,`type`,`mch_type`,`open_pay`,`share`,`rate`,`real_rate`,`system_rate`, `service_id`,`pay_score_notify_url`,`api_v3_key`,`cert_serial_no`,`private_key_path`,`private_cert_pem_path`, `merchant_key_path`,`merchant_apiv3_key`,`merchant_cert_pem_path` diff --git a/mallinkService/src/main/resources/mapper/WxPayOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxPayOrderMapper.xml index 0dc33931e..241eb01be 100644 --- a/mallinkService/src/main/resources/mapper/WxPayOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxPayOrderMapper.xml @@ -27,6 +27,8 @@ + + @@ -42,7 +44,7 @@ `id`,`tenant_id`,`parent_tenant_id`,`create_time`,`update_time`,`order_id`,`c_user_id`,`open_id`,`b_user_id`, `auth_code`,`ip`,`pay_amount`,`pay_time_start`,`pay_time_end`, `prepay_id`,`transaction_id`,`pay_vendor`,`pay_version`,`tt_pay_way`,`pay_order_no`, - `pay_order_status`,`pay_param`,`mch_type`,`share`,`share_amount`,`rate_amount`,`fail_reason`, + `pay_order_status`,`pay_param`,`mch_type`,`share`,`share_amount`,`system_amount`,`commission_amount`,`rate_amount`,`fail_reason`, `pos_pay_order_id`,`pos_pay_order_time`,`pos_payment_type`,`pos_pay_order_no`,`pos_pay_des`,`compose_order`, `child_order_share` @@ -240,6 +242,8 @@ + + @@ -251,7 +255,7 @@ p.`id`,p.`tenant_id`,p.`parent_tenant_id`,p.`create_time`,p.`update_time`,p.`order_id`,p.`c_user_id`,p.`open_id`,p.`b_user_id`, p.`auth_code`,p.`ip`,p.`pay_amount`,p.`pay_time_start`,p.`pay_time_end`, p.`prepay_id`,p.`transaction_id`,p.`pay_vendor`,p.`pay_version`,p.`pay_order_no`, - p.`pay_order_status`,p.`share`,p.`share_amount`,p.`rate_amount`,p.`fail_reason`, + p.`pay_order_status`,p.`share`,p.`share_amount`,p.`system_amount`,p.`commission_amount`,p.`rate_amount`,p.`fail_reason`, a.`app_id`, a.`pay_id`