Compare commits
2 Commits
1c593d1dfb
...
34cf179254
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34cf179254 | ||
|
|
b355f0364c |
423
doc/sql/pending/202603123_increase.sql
Normal file
423
doc/sql/pending/202603123_increase.sql
Normal file
@@ -0,0 +1,423 @@
|
||||
-- =============================================
|
||||
-- 微信商户配置表 (blade_pay_wxpay_account_config)
|
||||
-- =============================================
|
||||
DROP TABLE IF EXISTS blade_pay_wxpay_account_config;
|
||||
CREATE TABLE blade_pay_wxpay_account_config
|
||||
(
|
||||
id int8 NOT NULL PRIMARY KEY, -- ID
|
||||
tenant_id varchar(12), -- 租户id
|
||||
mch_id varchar(255) NOT NULL, -- 商户号
|
||||
pay_key varchar(500) NOT NULL, -- 支付密钥
|
||||
pay_name varchar(255), -- 收款名称
|
||||
v3_key varchar(500), -- V3密钥
|
||||
api_type int4, -- API类型【0:普通】
|
||||
notify_url varchar(1000), -- 统一支付回调地址
|
||||
refund_notify_url varchar(1000), -- 统一退款回调
|
||||
cashier_url varchar(1000), -- 聚合收银台URL
|
||||
cert_pem text, -- 微信证书pem文件
|
||||
cert_pkcs text, -- 微信正式p12文件
|
||||
cert_pub_key text, -- 微信证书公钥
|
||||
cert_private_key text, -- 微信证书私钥
|
||||
cert_serial_no varchar(500), -- 商户 API 证书序列号
|
||||
cert_plat_serial_no varchar(500), -- 平台序列号
|
||||
wx_pub_key text, -- 微信支付公钥
|
||||
wx_pub_key_id varchar(255), -- 微信支付公钥ID
|
||||
status int4 NOT NULL DEFAULT 0, -- 状态【0:关闭、1:启用】
|
||||
create_user int8, -- 创建人
|
||||
create_dept int8, -- 创建部门
|
||||
create_time timestamp(6), -- 创建时间
|
||||
update_user int8, -- 修改人
|
||||
update_time timestamp(6), -- 修改时间
|
||||
is_deleted int4, -- 是否已删除
|
||||
remark varchar(500) DEFAULT '' -- 备注
|
||||
);
|
||||
|
||||
COMMENT ON TABLE blade_pay_wxpay_account_config IS '微信商户配置表';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.id IS 'ID';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.tenant_id IS '租户id';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.mch_id IS '商户号';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.pay_key IS '支付密钥';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.pay_name IS '收款名称';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.v3_key IS 'V3密钥';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.api_type IS 'API类型【0:普通】';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.notify_url IS '统一支付回调地址';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.refund_notify_url IS '统一退款回调';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.cashier_url IS '聚合收银台URL';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.cert_pem IS '微信证书pem文件';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.cert_pkcs IS '微信正式p12文件';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.cert_pub_key IS '微信证书公钥';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.cert_private_key IS '微信证书私钥';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.cert_serial_no IS '商户 API 证书序列号';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.cert_plat_serial_no IS '平台序列号';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.wx_pub_key IS '微信支付公钥';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.wx_pub_key_id IS '微信支付公钥ID';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.status IS '状态【0:关闭、1:启用】';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.create_user IS '创建人';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.create_dept IS '创建部门';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.create_time IS '创建时间';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.update_user IS '修改人';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.update_time IS '修改时间';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.is_deleted IS '是否已删除';
|
||||
COMMENT ON COLUMN blade_pay_wxpay_account_config.remark IS '备注';
|
||||
|
||||
|
||||
-- =============================================
|
||||
-- 支付订单表 (blade_pay_order)
|
||||
-- =============================================
|
||||
DROP TABLE IF EXISTS blade_pay_order;
|
||||
CREATE TABLE blade_pay_order
|
||||
(
|
||||
id int8 NOT NULL PRIMARY KEY, -- ID
|
||||
tenant_id varchar(12), -- 租户id
|
||||
order_no varchar(255) NOT NULL, -- 系统单号
|
||||
body varchar(255) NOT NULL, -- 商品名称
|
||||
money varchar(255) NOT NULL, -- 支付金额
|
||||
app_id varchar(255) NOT NULL, -- 应用ID
|
||||
mch_id varchar(255) NOT NULL, -- 商户号
|
||||
pay_name varchar(255) NOT NULL, -- 收款名称
|
||||
pay_type varchar(255) NOT NULL, -- 支付方式【code、native、jsapi、wxapp、h5、app】
|
||||
channel varchar(255) NOT NULL, -- 支付渠道【wxpay、alipay】
|
||||
buyer_id varchar(255), -- 买家ID
|
||||
status int4 NOT NULL DEFAULT 0, -- 0:未支付、1:已支付
|
||||
pay_no varchar(255), -- 第三方支付单号
|
||||
pay_time varchar(255), -- 支付时间
|
||||
is_refund int4 NOT NULL DEFAULT 0, -- 是否退款【0:否、1:是】
|
||||
refund_money varchar(255), -- 已退款金额
|
||||
notify_url varchar(255), -- 异步回调地址
|
||||
create_user int8, -- 创建人
|
||||
create_dept int8, -- 创建部门
|
||||
create_time timestamp(6), -- 创建时间
|
||||
update_user int8, -- 修改人
|
||||
update_time timestamp(6), -- 修改时间
|
||||
is_deleted int4, -- 是否已删除
|
||||
remark varchar(500) DEFAULT '' -- 备注
|
||||
);
|
||||
|
||||
COMMENT ON TABLE blade_pay_order IS '支付订单表';
|
||||
COMMENT ON COLUMN blade_pay_order.id IS 'ID';
|
||||
COMMENT ON COLUMN blade_pay_order.tenant_id IS '租户id';
|
||||
COMMENT ON COLUMN blade_pay_order.order_no IS '系统单号';
|
||||
COMMENT ON COLUMN blade_pay_order.body IS '商品名称';
|
||||
COMMENT ON COLUMN blade_pay_order.money IS '支付金额';
|
||||
COMMENT ON COLUMN blade_pay_order.app_id IS '应用ID';
|
||||
COMMENT ON COLUMN blade_pay_order.mch_id IS '商户号';
|
||||
COMMENT ON COLUMN blade_pay_order.pay_name IS '收款名称';
|
||||
COMMENT ON COLUMN blade_pay_order.pay_type IS '支付方式【code、native、jsapi、wxapp、h5、app】';
|
||||
COMMENT ON COLUMN blade_pay_order.channel IS '支付渠道【wxpay、alipay】';
|
||||
COMMENT ON COLUMN blade_pay_order.buyer_id IS '买家ID';
|
||||
COMMENT ON COLUMN blade_pay_order.status IS '0:未支付、1:已支付';
|
||||
COMMENT ON COLUMN blade_pay_order.pay_no IS '第三方支付单号';
|
||||
COMMENT ON COLUMN blade_pay_order.pay_time IS '支付时间';
|
||||
COMMENT ON COLUMN blade_pay_order.is_refund IS '是否退款【0:否、1:是】';
|
||||
COMMENT ON COLUMN blade_pay_order.refund_money IS '已退款金额';
|
||||
COMMENT ON COLUMN blade_pay_order.notify_url IS '异步回调地址';
|
||||
COMMENT ON COLUMN blade_pay_order.create_user IS '创建人';
|
||||
COMMENT ON COLUMN blade_pay_order.create_dept IS '创建部门';
|
||||
COMMENT ON COLUMN blade_pay_order.create_time IS '创建时间';
|
||||
COMMENT ON COLUMN blade_pay_order.update_user IS '修改人';
|
||||
COMMENT ON COLUMN blade_pay_order.update_time IS '修改时间';
|
||||
COMMENT ON COLUMN blade_pay_order.is_deleted IS '是否已删除';
|
||||
COMMENT ON COLUMN blade_pay_order.remark IS '备注';
|
||||
|
||||
|
||||
-- =============================================
|
||||
-- 订单退款表 (blade_pay_order_refund)
|
||||
-- =============================================
|
||||
DROP TABLE IF EXISTS blade_pay_order_refund;
|
||||
CREATE TABLE blade_pay_order_refund
|
||||
(
|
||||
id int8 NOT NULL PRIMARY KEY, -- ID
|
||||
tenant_id varchar(12), -- 租户id
|
||||
refund_no varchar(255) NOT NULL, -- 退款单号
|
||||
order_no varchar(255) NOT NULL, -- 业务订单
|
||||
pay_no varchar(255) NOT NULL, -- 支付单号
|
||||
refund_mch_id varchar(255) NOT NULL, -- 退款商户
|
||||
refund_money varchar(255) NOT NULL, -- 退款金额
|
||||
refund_desc varchar(255), -- 退款原因
|
||||
status int4 NOT NULL DEFAULT 0, -- 退款状态 -1:退款失败 0:已发起 1:退款成功
|
||||
notify_url varchar(1000), -- 退款回调地址
|
||||
create_user int8, -- 创建人
|
||||
create_dept int8, -- 创建部门
|
||||
create_time timestamp(6), -- 创建时间
|
||||
update_user int8, -- 修改人
|
||||
update_time timestamp(6), -- 修改时间
|
||||
is_deleted int4, -- 是否已删除
|
||||
remark varchar(500) DEFAULT '' -- 备注
|
||||
);
|
||||
|
||||
COMMENT ON TABLE blade_pay_order_refund IS '订单退款表';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.id IS 'ID';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.tenant_id IS '租户id';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.refund_no IS '退款单号';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.order_no IS '业务订单';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.pay_no IS '支付单号';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.refund_mch_id IS '退款商户';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.refund_money IS '退款金额';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.refund_desc IS '退款原因';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.status IS '退款状态 -1:退款失败 0:已发起 1:退款成功';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.notify_url IS '退款回调地址';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.create_user IS '创建人';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.create_dept IS '创建部门';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.create_time IS '创建时间';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.update_user IS '修改人';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.update_time IS '修改时间';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.is_deleted IS '是否已删除';
|
||||
COMMENT ON COLUMN blade_pay_order_refund.remark IS '备注';
|
||||
|
||||
|
||||
-- =============================================
|
||||
-- 支付宝商户配置表 (blade_pay_alipay_account_config)
|
||||
-- =============================================
|
||||
DROP TABLE IF EXISTS blade_pay_alipay_account_config;
|
||||
CREATE TABLE blade_pay_alipay_account_config
|
||||
(
|
||||
id int8 NOT NULL PRIMARY KEY, -- ID
|
||||
tenant_id varchar(12), -- 租户id
|
||||
mch_id varchar(255) NOT NULL, -- 商户号
|
||||
app_id varchar(255) NOT NULL, -- 支付宝应用ID
|
||||
account varchar(255) NOT NULL, -- 支付宝账户
|
||||
pay_key text, -- 支付密钥
|
||||
pub_key text, -- 支付宝公钥(开发者工具生成的txt文件)证书模式下通过程序提取该值
|
||||
private_key text, -- 支付宝私钥(开发者工具生成的txt文件,证书模式下CSR文件夹下的私钥)
|
||||
app_cert text, -- 应用证书,开发者网站下载
|
||||
alipay_pub_cert text, -- 支付宝公钥证书,开发者网站下载
|
||||
root_cert text, -- 支付宝根证书,开发者网站下载
|
||||
app_auth_token varchar(500), -- 三方模式授权token
|
||||
service_url varchar(500), -- 支付宝网关地址
|
||||
sign_type varchar(255) NOT NULL, -- 加密算法类型
|
||||
pay_name varchar(255), -- 收款名称
|
||||
company_name varchar(500), -- 公司名称
|
||||
api_type int4 NOT NULL DEFAULT 0, -- API类型【0:普通】
|
||||
notify_url varchar(1000), -- 统一支付回调地址
|
||||
refund_notify_url varchar(1000), -- 退款回调地址
|
||||
status int4 NOT NULL DEFAULT 0, -- 状态【0:关闭、1:启用】
|
||||
create_user int8, -- 创建人
|
||||
create_dept int8, -- 创建部门
|
||||
create_time timestamp(6), -- 创建时间
|
||||
update_user int8, -- 修改人
|
||||
update_time timestamp(6), -- 修改时间
|
||||
is_deleted int4, -- 是否已删除
|
||||
remark varchar(500) DEFAULT '' -- 备注
|
||||
);
|
||||
|
||||
COMMENT ON TABLE blade_pay_alipay_account_config IS '支付宝商户配置表';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.id IS 'ID';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.tenant_id IS '租户id';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.mch_id IS '商户号';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.app_id IS '支付宝应用ID';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.account IS '支付宝账户';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.pay_key IS '支付密钥';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.pub_key IS '支付宝公钥(开发者工具生成的txt文件)证书模式下通过程序提取该值';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.private_key IS '支付宝私钥(开发者工具生成的txt文件,证书模式下CSR文件夹下的私钥)';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.app_cert IS '应用证书,开发者网站下载';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.alipay_pub_cert IS '支付宝公钥证书,开发者网站下载';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.root_cert IS '支付宝根证书,开发者网站下载';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.app_auth_token IS '三方模式授权token';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.service_url IS '支付宝网关地址';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.sign_type IS '加密算法类型';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.pay_name IS '收款名称';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.company_name IS '公司名称';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.api_type IS 'API类型【0:普通】';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.notify_url IS '统一支付回调地址';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.refund_notify_url IS '退款回调地址';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.status IS '状态【0:关闭、1:启用】';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.create_user IS '创建人';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.create_dept IS '创建部门';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.create_time IS '创建时间';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.update_user IS '修改人';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.update_time IS '修改时间';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.is_deleted IS '是否已删除';
|
||||
COMMENT ON COLUMN blade_pay_alipay_account_config.remark IS '备注';
|
||||
|
||||
|
||||
-- =============================================
|
||||
-- 聚合支付配置表 (blade_pay_merge_pay_config)
|
||||
-- =============================================
|
||||
DROP TABLE IF EXISTS blade_pay_merge_pay_config;
|
||||
CREATE TABLE blade_pay_merge_pay_config
|
||||
(
|
||||
id int8 NOT NULL PRIMARY KEY, -- ID
|
||||
tenant_id varchar(12), -- 租户id
|
||||
mch_id varchar(255) NOT NULL, -- 商户号
|
||||
pay_key varchar(255) NOT NULL, -- 支付密钥
|
||||
notify_url varchar(1000), -- 统一支付回调地址
|
||||
refund_notify_url varchar(1000), -- 退款回调地址
|
||||
status int4 NOT NULL DEFAULT 0, -- 状态【0:关闭、1:启用】
|
||||
create_user int8, -- 创建人
|
||||
create_dept int8, -- 创建部门
|
||||
create_time timestamp(6), -- 创建时间
|
||||
update_user int8, -- 修改人
|
||||
update_time timestamp(6), -- 修改时间
|
||||
is_deleted int4, -- 是否已删除
|
||||
remark varchar(500) DEFAULT '' -- 备注
|
||||
);
|
||||
|
||||
COMMENT ON TABLE blade_pay_merge_pay_config IS '聚合支付配置表';
|
||||
COMMENT ON COLUMN blade_pay_merge_pay_config.id IS 'ID';
|
||||
COMMENT ON COLUMN blade_pay_merge_pay_config.tenant_id IS '租户id';
|
||||
COMMENT ON COLUMN blade_pay_merge_pay_config.mch_id IS '商户号';
|
||||
COMMENT ON COLUMN blade_pay_merge_pay_config.pay_key IS '支付密钥';
|
||||
COMMENT ON COLUMN blade_pay_merge_pay_config.notify_url IS '统一支付回调地址';
|
||||
COMMENT ON COLUMN blade_pay_merge_pay_config.refund_notify_url IS '退款回调地址';
|
||||
COMMENT ON COLUMN blade_pay_merge_pay_config.status IS '状态【0:关闭、1:启用】';
|
||||
COMMENT ON COLUMN blade_pay_merge_pay_config.create_user IS '创建人';
|
||||
COMMENT ON COLUMN blade_pay_merge_pay_config.create_dept IS '创建部门';
|
||||
COMMENT ON COLUMN blade_pay_merge_pay_config.create_time IS '创建时间';
|
||||
COMMENT ON COLUMN blade_pay_merge_pay_config.update_user IS '修改人';
|
||||
COMMENT ON COLUMN blade_pay_merge_pay_config.update_time IS '修改时间';
|
||||
COMMENT ON COLUMN blade_pay_merge_pay_config.is_deleted IS '是否已删除';
|
||||
COMMENT ON COLUMN blade_pay_merge_pay_config.remark IS '备注';
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS common_pay_order;
|
||||
create table common_pay_order
|
||||
(
|
||||
id int8 not null primary key, --支付插件支付记录id
|
||||
order_id int8, --系统内部订单id
|
||||
order_status int4 default 0 not null, --订单状态
|
||||
payment_status int4 default 0 not null, --支付状态
|
||||
order_no varchar(32), --支付插件orderNo
|
||||
payment_type int4, --支付类型
|
||||
status int4 NOT NULL DEFAULT 0,
|
||||
create_user int8,
|
||||
create_dept int8,
|
||||
create_time timestamp(6),
|
||||
update_user int8,
|
||||
update_time timestamp(6),
|
||||
is_deleted int4,
|
||||
remark varchar(500) default ''::character varying
|
||||
);
|
||||
|
||||
comment on table common_pay_order is '系统内部订单关联支付记录表';
|
||||
comment on column common_pay_order.id is '支付插件支付记录id';
|
||||
comment on column common_pay_order.order_id is '系统内部订单id';
|
||||
comment on column common_pay_order.order_no is '支付插件orderNo';
|
||||
comment on column common_pay_order.order_status is '订单状态';
|
||||
comment on column common_pay_order.payment_status is '支付状态';
|
||||
comment on column common_pay_order.payment_type is '支付类型';
|
||||
comment on column common_pay_order.status IS '状态';
|
||||
comment on column common_pay_order.create_user is '创建人';
|
||||
comment on column common_pay_order.create_dept is '创建部门';
|
||||
comment on column common_pay_order.create_time is '创建时间';
|
||||
comment on column common_pay_order.update_user is '修改人';
|
||||
comment on column common_pay_order.update_time is '修改时间';
|
||||
comment on column common_pay_order.is_deleted is '是否已删除';
|
||||
comment on column common_pay_order.remark is '备注';
|
||||
|
||||
create index idx_cpo_oid on common_pay_order (order_id); --订单id索引
|
||||
CREATE INDEX idx_cpo_ptime ON common_pay_order (payment_status, create_time);
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS common_order_confirm_log;
|
||||
|
||||
CREATE TABLE common_order_confirm_log
|
||||
(
|
||||
id int8 NOT NULL PRIMARY KEY, -- 主键ID
|
||||
user_id int8, -- 用户ID
|
||||
order_id int8, -- 订单ID
|
||||
item_name varchar(32), -- 商品名称
|
||||
delivery_address varchar(255), -- 收货地址ID
|
||||
actual_amount numeric(10, 2) default 0.00 not null, -- 实际支付金额
|
||||
order_type varchar(32), -- 订单类型
|
||||
payment_type int4, -- 支付类型
|
||||
is_agency_distributed int4 NOT NULL DEFAULT 0, -- 是否分发极差代理 (0:未分发, 1:已分发)
|
||||
agency_distribute_time timestamp(6), -- 极差代理发放时间
|
||||
is_service_distributed int4 NOT NULL DEFAULT 0, -- 是否发放服务商佣金 (0:未发放, 1:已发放)
|
||||
service_distribute_time timestamp(6), -- 服务商佣金发放时间
|
||||
status int4 NOT NULL DEFAULT 0, -- 状态
|
||||
create_user int8, -- 创建人
|
||||
create_dept int8, -- 创建部门
|
||||
create_time timestamp(6), -- 创建时间
|
||||
update_user int8, -- 修改人
|
||||
update_time timestamp(6), -- 修改时间
|
||||
is_deleted int4, -- 是否已删除 (0:未删除, 1:已删除)
|
||||
remark varchar(500) DEFAULT '' -- 备注
|
||||
|
||||
);
|
||||
|
||||
CREATE INDEX idx_cocl_aop ON common_order_confirm_log (is_agency_distributed, order_type, payment_type);
|
||||
CREATE INDEX idx_cocl_sop ON common_order_confirm_log (is_service_distributed, order_type, payment_type);
|
||||
CREATE INDEX idx_cocl_poc ON common_order_confirm_log (payment_type, order_type, create_time DESC);
|
||||
|
||||
COMMENT ON TABLE common_order_confirm_log IS '订单确认收货记录表';
|
||||
|
||||
COMMENT ON COLUMN common_order_confirm_log.id IS 'id';
|
||||
COMMENT ON COLUMN common_order_confirm_log.user_id IS '用户id';
|
||||
COMMENT ON COLUMN common_order_confirm_log.order_id IS '订单id';
|
||||
COMMENT ON COLUMN common_order_confirm_log.item_name IS '商品名称';
|
||||
COMMENT ON COLUMN common_order_confirm_log.delivery_address IS '收货地址';
|
||||
COMMENT ON COLUMN common_order_confirm_log.actual_amount IS '实际支付金额';
|
||||
COMMENT ON COLUMN common_order_confirm_log.order_type IS '订单类型';
|
||||
COMMENT ON COLUMN common_order_confirm_log.payment_type IS '支付类型';
|
||||
COMMENT ON COLUMN common_order_confirm_log.is_agency_distributed IS '是否分发极差代理 (0:未分发, 1:已分发)';
|
||||
COMMENT ON COLUMN common_order_confirm_log.agency_distribute_time IS '极差代理发放时间';
|
||||
COMMENT ON COLUMN common_order_confirm_log.is_service_distributed IS '是否发放服务商佣金 (0:未发放, 1:已发放)';
|
||||
COMMENT ON COLUMN common_order_confirm_log.service_distribute_time IS '服务商佣金发放时间';
|
||||
COMMENT ON COLUMN common_order_confirm_log.status IS '状态';
|
||||
COMMENT ON COLUMN common_order_confirm_log.create_user IS '创建人';
|
||||
COMMENT ON COLUMN common_order_confirm_log.create_dept IS '创建部门';
|
||||
COMMENT ON COLUMN common_order_confirm_log.create_time IS '创建时间';
|
||||
COMMENT ON COLUMN common_order_confirm_log.update_user IS '修改人';
|
||||
COMMENT ON COLUMN common_order_confirm_log.update_time IS '修改时间';
|
||||
COMMENT ON COLUMN common_order_confirm_log.is_deleted IS '是否已删除';
|
||||
COMMENT ON COLUMN common_order_confirm_log.remark IS '备注';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- =============================================
|
||||
-- 菜单数据初始化 (blade_menu)
|
||||
-- =============================================
|
||||
|
||||
-- 1. 支付管理 (根节点)
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, is_open, remark, is_deleted) VALUES (1477199103906373633, 0, '14', '支付管理', 'pay', '/pay', 'iconfont icon-weixin1', 100, 1, 1, '', 0);
|
||||
|
||||
-- 2. 微信支付配置模块
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted) VALUES (1476839243041804294, 1477199103906373633, 'wxconfig', '微信支付配置', 'menu', '/plugin/pay/wxconfig', NULL, 1, 1, 0, 1, NULL, 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1476839243041804295, 1476839243041804294, 'wxconfig_add', '新增', 'add', '/plugin/pay/wxconfig/add', 'plus', 1, 2, 1, 1, NULL, 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1476839243041804296, 1476839243041804294, 'wxconfig_edit', '修改', 'edit', '/plugin/pay/wxconfig/edit', 'form', 2, 2, 2, 1, NULL, 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted) VALUES (1476839243041804297, 1476839243041804294, 'wxconfig_delete', '删除', 'delete', '/api/blade-pay/wxconfig/remove', 'delete', 3, 2, 3, 1, NULL, 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1476839243041804298, 1476839243041804294, 'wxconfig_view', '查看', 'view', '/plugin/pay/wxconfig/view', 'file-text', 4, 2, 2, 1, NULL, 0);
|
||||
|
||||
-- 3. 订单管理模块
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1476767495650865158, 1477199103906373633, 'order', '订单管理', 'menu', '/plugin/pay/order', NULL, 1, 1, 0, 1, NULL, 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1476767495650865159, 1476767495650865158, 'order_add', '新增', 'add', '/plugin/pay/order/add', 'plus', 1, 2, 1, 1, NULL, 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1476767495650865160, 1476767495650865158, 'order_edit', '修改', 'edit', '/plugin/pay/order/edit', 'form', 2, 2, 2, 1, NULL, 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1476767495650865161, 1476767495650865158, 'order_delete', '删除', 'delete', '/api/blade-pay/order/remove', 'delete', 3, 2, 3, 1, NULL, 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1476767495650865162, 1476767495650865158, 'order_view', '查看', 'view', '/plugin/pay/order/view', 'file-text', 4, 2, 2, 1, NULL, 0);
|
||||
|
||||
-- 4. 支付体验 (根节点下的子菜单)
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, is_open, remark, is_deleted)VALUES (1477222211518210049, 1477199103906373633, '12', '支付体验', 'pay-demo', '/plugin/pay/demo', 'iconfont iconicon_wechat', 3, 1, 1, '', 0);
|
||||
|
||||
-- 5. 退款管理模块
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1478012327564226566, 1477199103906373633, 'refund', '退款管理', 'menu', '/plugin/pay/refund', NULL, 1, 1, 0, 1, NULL, 0);
|
||||
|
||||
-- 注意:原SQL中退款管理缺少“新增”按钮,此处保持原样。如果有需要可自行添加。
|
||||
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1478012327564226568, 1478012327564226566, 'refund_edit', '修改', 'edit', '/plugin/pay/refund/edit', 'form', 2, 2, 2, 1, NULL, 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1478012327564226569, 1478012327564226566, 'refund_delete', '删除', 'delete', '/api/blade-pay/refund/remove', 'delete', 3, 2, 3, 1, NULL, 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1478012327564226570, 1478012327564226566, 'refund_view', '查看', 'view', '/plugin/pay/refund/view', 'file-text', 4, 2, 2, 1, NULL, 0);
|
||||
|
||||
-- 6. 支付宝配置模块
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1519502474608390145, 1477199103906373633, 'aliconfig', '支付宝配置', 'menu', '/plugin/pay/aliconfig', NULL, 1, 1, 0, 1, NULL, 0);
|
||||
|
||||
-- 修正了原SQL中字段顺序不一致的问题,统一为 action 列
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1519502474608391478, 1477199103906373633, 'aliconfig_view', '查看', 'view', '/plugin/pay/aliconfig/view', 'file-text', 4, 2, 2, 1, '', 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1519502474608398520, 1477199103906373633, 'aliconfig_delete', '删除', 'delete', '/api/blade-pay/aliconfig/remove', 'delete', 3, 2, 3, 1, '', 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1519502474608399630, 1477199103906373633, 'aliconfig_edit', '修改', 'edit', '/plugin/pay/aliconfig/edit', 'form', 2, 2, 2, 1, '', 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1519502474608397841, 1477199103906373633, 'aliconfig_add', '新增', 'add', '/plugin/pay/aliconfig/add', 'plus', 1, 2, 1, 1, '', 0);
|
||||
|
||||
-- 7. 聚合支付配置模块
|
||||
-- 注意:原SQL使用 VALUES 位置匹配,这里显式指定字段以确保安全
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1541359525647163398, 1477199103906373633, 'mergepayconfig', '聚合支付', 'menu', '/plugin/pay/merge/config', NULL, 1, 1, 0, 1, NULL, 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1541359525647163399, 1541359525647163398, 'mergepayconfig_add', '新增', 'add', '/plugin/pay/merge/config/add', 'plus', 1, 2, 1, 1, NULL, 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1541359525647163400, 1541359525647163398, 'mergepayconfig_edit', '修改', 'edit', '/plugin/pay/merge/config/edit', 'form', 2, 2, 2, 1, NULL, 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1541359525647163401, 1541359525647163398, 'mergepayconfig_delete', '删除', 'delete', '/api/blade-pay/merge/config/remove', 'delete', 3, 2, 3, 1, NULL, 0);
|
||||
INSERT INTO blade_menu (id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)VALUES (1541359525647163402, 1541359525647163398, 'mergepayconfig_view', '查看', 'view', '/plugin/pay/merge/config/view', 'file-text', 4, 2, 2, 1, NULL, 0);
|
||||
|
||||
|
||||
|
||||
|
||||
39
pom.xml
39
pom.xml
@@ -296,6 +296,45 @@
|
||||
<version>1.19.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--blade-pay插件相关-->
|
||||
<dependency>
|
||||
<groupId>com.github.javen205</groupId>
|
||||
<artifactId>IJPay-WxPay</artifactId>
|
||||
<version>2.9.12</version>
|
||||
</dependency>
|
||||
<!--blade-pay插件相关 二维码生成-->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-extra</artifactId>
|
||||
<version>5.8.29</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.3.3</version>
|
||||
</dependency>
|
||||
|
||||
<!--支付宝SDK-->
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>4.39.134.ALL</version>
|
||||
</dependency>
|
||||
|
||||
<!--YunGouOS聚合支付相关-->
|
||||
<dependency>
|
||||
<groupId>com.yungouos.pay</groupId>
|
||||
<artifactId>yungouos-pay-sdk</artifactId>
|
||||
<version>2.0.38</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -25,4 +25,29 @@ public class AsyncConfiguration {
|
||||
return executor;
|
||||
}
|
||||
|
||||
@Bean("paymentAsyncExecutor")
|
||||
public ThreadPoolTaskExecutor paymentAsyncExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(6);
|
||||
executor.setMaxPoolSize(12);
|
||||
executor.setQueueCapacity(200);
|
||||
executor.setThreadNamePrefix("pay-");
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
|
||||
|
||||
@Bean("statsCommissionAsyncExecutor")
|
||||
public ThreadPoolTaskExecutor statsCommissionAsyncExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(6);
|
||||
executor.setMaxPoolSize(12);
|
||||
executor.setQueueCapacity(200);
|
||||
executor.setThreadNamePrefix("stats-commission-");
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
package org.springblade.job.processor;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.common.utils.date.DateUtil;
|
||||
import org.springblade.core.redis.cache.BladeRedis;
|
||||
import org.springblade.core.tool.sensitive.SensitiveUtil;
|
||||
import org.springblade.modules.common.eums.BusinessModule;
|
||||
import org.springblade.modules.common.pojo.entity.CommonOrderConfirmLogEntity;
|
||||
import org.springblade.modules.common.pojo.entity.CommonUserOrderEntity;
|
||||
import org.springblade.modules.common.service.ICommonOrderConfirmLogService;
|
||||
import org.springblade.modules.common.service.ICommonUserOrderService;
|
||||
import org.springblade.modules.market.eums.MarketBusinessModule;
|
||||
import org.springblade.modules.market.event.MarketUpgradeNoticeEvent;
|
||||
import org.springblade.modules.market.pojo.entity.MarketUpgradeCashLogEntity;
|
||||
import org.springblade.modules.market.pojo.entity.MarketUpgradeConfigEntity;
|
||||
import org.springblade.modules.market.pojo.entity.MarketUserCommissionEntity;
|
||||
import org.springblade.modules.market.pojo.entity.MarketUserCommissionLogEntity;
|
||||
import org.springblade.modules.market.pojo.entity.*;
|
||||
import org.springblade.modules.market.service.*;
|
||||
import org.springblade.modules.system.pojo.entity.User;
|
||||
import org.springblade.modules.system.service.IUserService;
|
||||
@@ -42,12 +43,15 @@ public class AccelUpgradeCashProcessor implements BasicProcessor {
|
||||
private final IMarketUpgradeConfigService upgradeConfigService;
|
||||
private final IMarketUpgradeCashLogService upgradeCashLogService;
|
||||
private final IMarketInfoService marketInfoService;
|
||||
private final ICommonUserOrderService userOrderService;
|
||||
private final ICommonOrderConfirmLogService orderConfirmLogService;
|
||||
private final IUserService userService;
|
||||
private final BladeRedis bladeRedis;
|
||||
private final IMarketUserCommissionService userCommissionService;
|
||||
private final IMarketUserCommissionLogService userCommissionLogService;
|
||||
private final ApplicationEventPublisher publisher;
|
||||
private final IMarketCommissionAccountService commissionAccountService;
|
||||
private final IMarketCommissionAgencyLogService agencyLogService;
|
||||
private static final Long AGENCY_ACCOUNT_ID = 2017486568441696258L;
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -85,24 +89,40 @@ public class AccelUpgradeCashProcessor implements BasicProcessor {
|
||||
|
||||
|
||||
|
||||
// 1. 分页查询订单 (修复内存溢出风险)
|
||||
List<CommonUserOrderEntity> orderPageList = userOrderService.list(
|
||||
Wrappers.lambdaQuery(CommonUserOrderEntity.class)
|
||||
.eq(CommonUserOrderEntity::getPaymentStatus, 1)
|
||||
.ge(CommonUserOrderEntity::getCreateTime, startDate)
|
||||
.lt(CommonUserOrderEntity::getCreateTime, endDate)
|
||||
.orderByAsc(CommonUserOrderEntity::getId) // 稳定排序
|
||||
|
||||
String orderType = BusinessModule.SELF_OPERATED_MALL.getCode().toUpperCase();
|
||||
List<CommonOrderConfirmLogEntity> orderPageList = orderConfirmLogService.list(
|
||||
Wrappers.lambdaQuery(CommonOrderConfirmLogEntity.class)
|
||||
.eq(CommonOrderConfirmLogEntity::getIsAgencyDistributed, 0)
|
||||
.func(queryWrapper -> queryWrapper.apply("UPPER(order_type) = {0}", orderType))
|
||||
.in(CommonOrderConfirmLogEntity::getPaymentType, List.of(1, 2))
|
||||
.ge(CommonOrderConfirmLogEntity::getCreateTime, startDate)
|
||||
.le(CommonOrderConfirmLogEntity::getCreateTime, endDate)
|
||||
.orderByAsc(CommonOrderConfirmLogEntity::getId)
|
||||
);
|
||||
|
||||
if (orderPageList.isEmpty()){
|
||||
log.info( "{} : 没有自营商城订单", DateUtil.convertFromDate(DateUtil.getYesterday() , "yyyy-MM-dd"));
|
||||
return new ProcessResult(true, "result is success") ;
|
||||
}
|
||||
|
||||
MarketCommissionAccountEntity agencyAccount = commissionAccountService.getById(AGENCY_ACCOUNT_ID);
|
||||
|
||||
if (agencyAccount == null || agencyAccount.getAmount().compareTo(BigDecimal.ZERO) < 0){
|
||||
log.info( "{} : 极差代理账户余额不足", DateUtil.convertFromDate(DateUtil.getYesterday() , "yyyy-MM-dd"));
|
||||
return new ProcessResult(true, "result is success") ;
|
||||
}
|
||||
List<MarketCommissionAgencyLogEntity> agencyLogList = new ArrayList<>();
|
||||
|
||||
|
||||
List<MarketUpgradeNoticeEvent.NoticeItem> noticeItems = new ArrayList<>();
|
||||
Map<Long, BigDecimal> userRewardRateMap = new HashMap<>();
|
||||
Map<Long, BigDecimal> userLastAmountMap = new HashMap<>();
|
||||
List<MarketUserCommissionLogEntity> userCommissionLogList = new ArrayList<>();
|
||||
|
||||
|
||||
BigDecimal agencyLastAmount = agencyAccount.getAmount();
|
||||
// 6. 处理订单
|
||||
for (CommonUserOrderEntity order : orderPageList) {
|
||||
for (CommonOrderConfirmLogEntity order : orderPageList) {
|
||||
Long userId = order.getUserId();
|
||||
|
||||
// 安全获取金额
|
||||
@@ -216,6 +236,24 @@ public class AccelUpgradeCashProcessor implements BasicProcessor {
|
||||
.setRemark(remarks + ",加速比例:" + rewardRate + ",加速金额:" + rewardRatePoint )
|
||||
.setStatisticalDate(DateUtil.getYesterday());
|
||||
userCommissionLogList.add(userCommissionLog);
|
||||
|
||||
MarketCommissionAgencyLogEntity agencyLog = new MarketCommissionAgencyLogEntity();
|
||||
agencyLog.setAccountId(agencyAccount.getId());
|
||||
agencyLog.setUserId(ancestorId);
|
||||
agencyLog.setAmount(rewardRatePoint);
|
||||
agencyLog.setLastAmount(agencyLastAmount);
|
||||
agencyLog.setSourceType(orderType);
|
||||
agencyLog.setSourceId(order.getId());
|
||||
agencyLog.setSourceDetail(JSONObject.toJSONString(order));
|
||||
agencyLog.setType(1);
|
||||
agencyLog.setStatisticalDate(DateUtil.getYesterday());
|
||||
agencyLog.setIsComplete(2);
|
||||
agencyLog.setRemark("极差代理奖励发放, 来源账号:" + account + ",来源订单id:" + order.getId());
|
||||
agencyLogList.add(agencyLog);
|
||||
agencyLastAmount = agencyLastAmount.subtract(rewardRatePoint);
|
||||
|
||||
agencyAccount.setAmount(agencyAccount.getAmount().subtract(rewardRatePoint));
|
||||
|
||||
if (userLastAmountMap.containsKey(ancestorId)){
|
||||
userLastAmountMap.merge(ancestorId, rewardRatePoint, BigDecimal::add);
|
||||
}else {
|
||||
@@ -224,9 +262,7 @@ public class AccelUpgradeCashProcessor implements BasicProcessor {
|
||||
|
||||
accelerationPoint = accelerationPoint.subtract(rewardRatePoint);
|
||||
|
||||
noticeItems.add(
|
||||
new MarketUpgradeNoticeEvent.NoticeItem(userCommissionLog.getUserId() ,userCommissionLog.getRemark())
|
||||
);
|
||||
noticeItems.add(new MarketUpgradeNoticeEvent.NoticeItem(userCommissionLog.getUserId() ,userCommissionLog.getRemark()));
|
||||
|
||||
}
|
||||
|
||||
@@ -246,6 +282,12 @@ public class AccelUpgradeCashProcessor implements BasicProcessor {
|
||||
userCommissionLogService.saveBatch(userCommissionLogList , 5000);
|
||||
publisher.publishEvent(event);
|
||||
|
||||
commissionAccountService.updateById(agencyAccount);
|
||||
agencyLogService.saveBatch(agencyLogList , 5000);
|
||||
|
||||
orderPageList.forEach(order -> order.setIsAgencyDistributed(1));
|
||||
orderConfirmLogService.updateBatchById(orderPageList , 5000);
|
||||
|
||||
return new ProcessResult(true, "result is success");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.springblade.job.processor;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -8,7 +9,12 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.common.utils.date.DateUtil;
|
||||
import org.springblade.core.redis.cache.BladeRedis;
|
||||
import org.springblade.core.tool.sensitive.SensitiveUtil;
|
||||
import org.springblade.modules.common.eums.BusinessModule;
|
||||
import org.springblade.modules.common.eums.OrderStatus;
|
||||
import org.springblade.modules.common.eums.PaymentStatus;
|
||||
import org.springblade.modules.common.pojo.entity.CommonOrderConfirmLogEntity;
|
||||
import org.springblade.modules.common.pojo.entity.CommonUserOrderEntity;
|
||||
import org.springblade.modules.common.service.ICommonOrderConfirmLogService;
|
||||
import org.springblade.modules.common.service.ICommonUserOrderService;
|
||||
import org.springblade.modules.market.pojo.entity.MarketCashPerformanceEntity;
|
||||
import org.springblade.modules.market.pojo.entity.MarketCashPerformanceLogEntity;
|
||||
@@ -36,7 +42,7 @@ import java.util.stream.Collectors;
|
||||
@AllArgsConstructor
|
||||
public class StatsCalculatorCashProcessor implements BasicProcessor {
|
||||
|
||||
private final ICommonUserOrderService userOrderService;
|
||||
private final ICommonOrderConfirmLogService orderConfirmLogService;
|
||||
private final IUserService userService;
|
||||
private final IMarketInfoService marketInfoService;
|
||||
private final IMarketCashPerformanceService cashPerformanceService;
|
||||
@@ -49,21 +55,22 @@ public class StatsCalculatorCashProcessor implements BasicProcessor {
|
||||
|
||||
Date startDate = DateUtil.getYesterday();
|
||||
Date endDate = DateUtil.getToday();
|
||||
String orderType = BusinessModule.SELF_OPERATED_MALL.getCode().toUpperCase();
|
||||
|
||||
// 1. 分页查询订单 (修复内存溢出风险)
|
||||
List<CommonUserOrderEntity> orderPageList = userOrderService.list(
|
||||
Wrappers.lambdaQuery(CommonUserOrderEntity.class)
|
||||
.eq(CommonUserOrderEntity::getPaymentStatus, 1)
|
||||
.eq(CommonUserOrderEntity::getPaymentType, List.of(1,2))
|
||||
.ge(CommonUserOrderEntity::getCreateTime, startDate)
|
||||
.le(CommonUserOrderEntity::getCreateTime, endDate)
|
||||
.orderByAsc(CommonUserOrderEntity::getId) // 稳定排序
|
||||
|
||||
List<CommonOrderConfirmLogEntity> orderPageList = orderConfirmLogService.list(
|
||||
Wrappers.lambdaQuery(CommonOrderConfirmLogEntity.class)
|
||||
.in(CommonOrderConfirmLogEntity::getPaymentType, List.of(1, 2))
|
||||
.func(queryWrapper -> queryWrapper.apply("UPPER(order_type) = {0}", orderType))
|
||||
.ge(CommonOrderConfirmLogEntity::getCreateTime, startDate)
|
||||
.le(CommonOrderConfirmLogEntity::getCreateTime, endDate)
|
||||
.orderByAsc(CommonOrderConfirmLogEntity::getId)
|
||||
);
|
||||
|
||||
|
||||
// 2. 提取所有用户ID,用于批量查询
|
||||
Set<Long> userIds = orderPageList.stream()
|
||||
.map(CommonUserOrderEntity::getUserId)
|
||||
.map(CommonOrderConfirmLogEntity::getUserId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 3. 批量查询用户信息 (修复 N+1)
|
||||
@@ -80,7 +87,7 @@ public class StatsCalculatorCashProcessor implements BasicProcessor {
|
||||
Map<Long, MarketCashPerformanceEntity> owenCashPerformanceMap = new HashMap<>(); // 自身业绩
|
||||
|
||||
// 6. 处理订单
|
||||
for (CommonUserOrderEntity order : orderPageList) {
|
||||
for (CommonOrderConfirmLogEntity order : orderPageList) {
|
||||
Long userId = order.getUserId();
|
||||
|
||||
// 安全获取金额
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
package org.springblade.job.processor;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.common.utils.date.DateUtil;
|
||||
import org.springblade.modules.common.eums.OrderStatus;
|
||||
import org.springblade.modules.common.eums.PaymentStatus;
|
||||
import org.springblade.modules.common.eums.PaymentType;
|
||||
import org.springblade.modules.common.pojo.entity.CommonPayOrderEntity;
|
||||
import org.springblade.modules.common.pojo.entity.CommonUserOrderEntity;
|
||||
import org.springblade.modules.common.service.ICommonPayOrderService;
|
||||
import org.springblade.modules.common.service.ICommonUserOrderService;
|
||||
import org.springblade.plugin.pay.api.PaymentFacade;
|
||||
import org.springblade.plugin.pay.dto.APPQueryDto;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import tech.powerjob.worker.core.processor.ProcessResult;
|
||||
import tech.powerjob.worker.core.processor.TaskContext;
|
||||
import tech.powerjob.worker.core.processor.sdk.BasicProcessor;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户未支付订单关闭
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class UserOrderCloseProcessor implements BasicProcessor {
|
||||
|
||||
|
||||
|
||||
private final PaymentFacade paymentFacade;
|
||||
private final ICommonPayOrderService commonPayOrderService;
|
||||
private final ICommonUserOrderService commonUserOrderService;
|
||||
|
||||
|
||||
@Override
|
||||
public ProcessResult process(TaskContext taskContext) throws Exception {
|
||||
|
||||
// 1. 计算截止时间 (30分钟前)
|
||||
Date expireTime = DateUtil.getMinutesLate(new Date(), 30);
|
||||
|
||||
int batchSize = 500; // 【优化点3】分批处理,防止内存溢出
|
||||
int currentCount = 0;
|
||||
|
||||
while (true) {
|
||||
// 2. 分批查询数据库
|
||||
// 【优化点1】增加 orderByAsc 保证按时间顺序处理,增加 last("LIMIT") 限制数量
|
||||
List<CommonPayOrderEntity> payOrderList = commonPayOrderService.list(
|
||||
Wrappers.lambdaQuery(CommonPayOrderEntity.class)
|
||||
.eq(CommonPayOrderEntity::getPaymentStatus, PaymentStatus.UNPAID.getCode()) // 确保传的是 code 值,如果是枚举对象需调整
|
||||
.eq(CommonPayOrderEntity::getOrderStatus, OrderStatus.PENDING_PAYMENT.getCode())
|
||||
.le(CommonPayOrderEntity::getCreateTime, expireTime)
|
||||
.orderByAsc(CommonPayOrderEntity::getCreateTime)
|
||||
.last("LIMIT " + batchSize)
|
||||
);
|
||||
|
||||
if (payOrderList == null || payOrderList.isEmpty()) {
|
||||
break; // 没有数据了,退出循环
|
||||
}
|
||||
|
||||
for (CommonPayOrderEntity payOrder : payOrderList) {
|
||||
try {
|
||||
processSingleOrder(payOrder);
|
||||
} catch (Exception e) {
|
||||
log.error("处理超时订单异常,订单号: {}", payOrder.getOrderNo(), e);
|
||||
// 单个失败不影响整体流程
|
||||
}
|
||||
}
|
||||
|
||||
// 如果本次查询数量小于批次大小,说明已经是最后一批,退出
|
||||
if (payOrderList.size() < batchSize) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new ProcessResult(true, "result is success");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理单个订单逻辑
|
||||
* 核心原则:先远程交互,成功后再开短事务更新本地
|
||||
*/
|
||||
private void processSingleOrder(CommonPayOrderEntity payOrder) {
|
||||
String orderNo = payOrder.getOrderNo();
|
||||
Long orderId = payOrder.getOrderId();
|
||||
|
||||
CommonPayOrderEntity currentPayOrder = commonPayOrderService.getById(payOrder.getId());
|
||||
if (currentPayOrder == null ||
|
||||
currentPayOrder.getPaymentStatus() != PaymentStatus.UNPAID.getCode()) {
|
||||
log.debug("订单 {} 状态已变更,跳过", orderNo);
|
||||
return;
|
||||
}
|
||||
|
||||
CommonUserOrderEntity userOrder = commonUserOrderService.getById(orderId);
|
||||
if (userOrder == null) {
|
||||
log.error("关联用户订单不存在,orderId: {}", orderId);
|
||||
return;
|
||||
}
|
||||
|
||||
Boolean isPaid = paymentFacade.query(
|
||||
new APPQueryDto()
|
||||
.setOrderNo(orderNo)
|
||||
.setPaymentType(PaymentType.fromCodeOrNull(payOrder.getPaymentType()))
|
||||
);
|
||||
|
||||
if (Boolean.TRUE.equals(isPaid)) {
|
||||
log.warn("【掉单补偿】订单 {} 在支付宝侧已支付,执行补单", orderNo);
|
||||
updateOrderToSuccess(payOrder, userOrder);
|
||||
return;
|
||||
}
|
||||
|
||||
// 6. 【远程调用】支付宝侧确认未支付,执行关闭
|
||||
// 即使 query 返回 false (不存在),close 接口通常也是幂等的,可以尝试关闭
|
||||
Boolean isClosed = paymentFacade.closeOrder(
|
||||
new APPQueryDto()
|
||||
.setOrderNo(orderNo)
|
||||
.setPaymentType(PaymentType.fromCodeOrNull(payOrder.getPaymentType()))
|
||||
);
|
||||
|
||||
if (!Boolean.TRUE.equals(isClosed)) {
|
||||
log.error("订单 {} 调用支付宝关闭失败,保留本地状态等待下次重试", orderNo);
|
||||
// 策略:不更新本地状态,下次定时任务再试。防止误关。
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
updateOrderToClosed(payOrder, userOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 事务方法:更新为成功状态
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateOrderToSuccess(CommonPayOrderEntity payOrder, CommonUserOrderEntity userOrder) {
|
||||
// 再次校验状态,防止并发
|
||||
LambdaQueryWrapper<CommonPayOrderEntity> checkWrapper = Wrappers.lambdaQuery(CommonPayOrderEntity.class)
|
||||
.eq(CommonPayOrderEntity::getId, payOrder.getId())
|
||||
.eq(CommonPayOrderEntity::getPaymentStatus, PaymentStatus.UNPAID.getCode());
|
||||
|
||||
long count = commonPayOrderService.count(checkWrapper);
|
||||
if (count == 0) {
|
||||
log.warn("更新成功状态时,订单 {} 状态已变,跳过", payOrder.getOrderNo());
|
||||
return;
|
||||
}
|
||||
|
||||
payOrder.setOrderStatus(OrderStatus.PAID.getCode());
|
||||
payOrder.setPaymentStatus(PaymentStatus.PAID.getCode());
|
||||
// payOrder.setUpdateTime(new Date()); // 如果有自动填充可省略
|
||||
|
||||
userOrder.setOrderStatus(OrderStatus.PAID.getCode());
|
||||
userOrder.setPaymentStatus(PaymentStatus.PAID.getCode());
|
||||
userOrder.setPaymentType(payOrder.getPaymentType());
|
||||
// userOrder.setUpdateTime(new Date());
|
||||
|
||||
commonPayOrderService.updateById(payOrder);
|
||||
commonUserOrderService.updateById(userOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 事务方法:更新为关闭状态
|
||||
* 使用 update(entity, wrapper) 方式实现乐观锁检查
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateOrderToClosed(CommonPayOrderEntity payOrder, CommonUserOrderEntity userOrder) {
|
||||
// 构造更新条件:必须当前还是未支付状态才能更新,否则说明被并发修改了
|
||||
LambdaQueryWrapper<CommonPayOrderEntity> updateWrapper = Wrappers.lambdaQuery(CommonPayOrderEntity.class)
|
||||
.eq(CommonPayOrderEntity::getId, payOrder.getId())
|
||||
.eq(CommonPayOrderEntity::getPaymentStatus, PaymentStatus.UNPAID.getCode());
|
||||
|
||||
// 准备更新的数据
|
||||
CommonPayOrderEntity updatePayOrder = new CommonPayOrderEntity();
|
||||
updatePayOrder.setOrderStatus(OrderStatus.CLOSED_TIMEOUT.getCode());
|
||||
updatePayOrder.setPaymentStatus(PaymentStatus.FAILED.getCode());
|
||||
// updatePayOrder.setUpdateTime(new Date());
|
||||
|
||||
boolean updated = commonPayOrderService.update(updatePayOrder, updateWrapper);
|
||||
|
||||
if (updated) {
|
||||
// 支付单更新成功,再更新用户订单
|
||||
userOrder.setOrderStatus(OrderStatus.CLOSED_TIMEOUT.getCode());
|
||||
userOrder.setPaymentStatus(PaymentStatus.FAILED.getCode());
|
||||
// userOrder.setUpdateTime(new Date());
|
||||
commonUserOrderService.updateById(userOrder);
|
||||
|
||||
log.info("订单 {} 已成功关闭", payOrder.getOrderNo());
|
||||
} else {
|
||||
// 更新失败,说明在此期间状态变了(比如用户刚支付成功回调到了)
|
||||
log.warn("订单 {} 关闭更新失败,状态可能已变更,放弃本次关闭本地状态", payOrder.getOrderNo());
|
||||
// 这里可以选择抛出异常回滚,或者仅仅记录日志。
|
||||
// 既然支付宝侧已经 close 成功了,本地不一致可以通过后续的“对账任务”来修复,或者抛异常让事务回滚(但支付宝侧已关无法回滚,所以最好记录日志告警)
|
||||
throw new RuntimeException("并发冲突:订单状态已变更,关闭失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,9 +4,11 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.modules.api.vo.MallProductApiVO;
|
||||
import org.springblade.modules.api.vo.MallProductDetailApiVO;
|
||||
import org.springblade.modules.mall.service.IMallProductService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -29,7 +31,15 @@ public class APPEcoController {
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "生态产品-商品列表")
|
||||
public R<List<MallProductApiVO>> ecosystemProductList() {
|
||||
return R.data(productService.apiVoListToCategory(2033413760969809921L));
|
||||
return R.data(productService.apiVoEcosListToCategory());
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "详情", description = "传入vo")
|
||||
public R<MallProductDetailApiVO> detail(@Valid MallProductDetailApiVO vo) {
|
||||
return R.data(productService.apiDetailVO(vo.getId()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,11 +44,7 @@ public class APPMallController {
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "列表")
|
||||
public R<List<MallCategoryApiVO>> categories() {
|
||||
List<MallCategoryEntity> list = categoryService.list(
|
||||
Wrappers.lambdaQuery(MallCategoryEntity.class)
|
||||
.notIn(MallCategoryEntity::getId, List.of(2033413707249164290L ,2033413760969809921L))
|
||||
);
|
||||
return R.data(AppMallConvert.INSTANCE.convertMallCategoryApiListVO(list));
|
||||
return R.data(AppMallConvert.INSTANCE.convertMallCategoryApiListVO(categoryService.categoryList()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,15 +67,6 @@ public class APPMallController {
|
||||
return R.data(productService.apiDetailVO(vo.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 自营商城-商品列表
|
||||
*/
|
||||
@GetMapping("/direct-mall-list")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "自营商城-商品列表")
|
||||
public R<List<MallProductApiVO>> directMallList() {
|
||||
return R.data(productService.apiVoListToCategory(2033413707249164290L));
|
||||
}
|
||||
|
||||
/**
|
||||
* 下单
|
||||
@@ -105,7 +92,7 @@ public class APPMallController {
|
||||
* 用户订单详情
|
||||
*/
|
||||
@GetMapping("/order-detail")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "用户订单详情")
|
||||
public R<CommonUserOrderDetailApiVO> orderDetail(Long id) {
|
||||
return R.data(orderService.orderDetail(id));
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.springblade.modules.api.app;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -29,8 +31,8 @@ public class APPStoreController {
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "商家店铺列表")
|
||||
public R<List<CommonMerchantStoreApiVO>> merchantStoreList(MerchantStoreRequest request) {
|
||||
return R.data(merchantFlagshipStoreService.merchantStoreList(request));
|
||||
public R<IPage<CommonMerchantStoreApiVO>> merchantStoreList(MerchantStoreRequest request , IPage<CommonMerchantStoreApiVO> page) {
|
||||
return R.data(merchantFlagshipStoreService.merchantStoreList(request , page));
|
||||
}
|
||||
|
||||
@GetMapping("/detail")
|
||||
|
||||
@@ -5,15 +5,14 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.modules.api.request.CommonRemoveTourRequest;
|
||||
import org.springblade.modules.api.request.CommonTourUserInfoRequest;
|
||||
import org.springblade.modules.api.request.TourProductRequest;
|
||||
import org.springblade.modules.api.vo.CommonTourInfoApiVO;
|
||||
import org.springblade.modules.api.vo.CommonTourProductApiVO;
|
||||
import org.springblade.modules.api.vo.CommonTourProductDetailApiVO;
|
||||
import org.springblade.modules.api.request.*;
|
||||
import org.springblade.modules.api.response.CreateOrderResponse;
|
||||
import org.springblade.modules.api.vo.*;
|
||||
import org.springblade.modules.common.service.ICommonTourInfoService;
|
||||
import org.springblade.modules.common.service.ICommonUserOrderService;
|
||||
import org.springblade.modules.common.service.ITourProductService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -27,6 +26,7 @@ import java.util.List;
|
||||
public class APPTourController {
|
||||
|
||||
private final ITourProductService tourProductService;
|
||||
private final ICommonUserOrderService orderService;
|
||||
|
||||
|
||||
@GetMapping("/product-list")
|
||||
@@ -51,5 +51,24 @@ public class APPTourController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 旅行团下单
|
||||
*/
|
||||
@PostMapping("/create-order")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "下单", description = "传入CreateTravelOrderRequest")
|
||||
public R<CreateOrderResponse> createOrder(@Valid @RequestBody CreateTravelOrderRequest request) {
|
||||
return R.data(orderService.createTravelOrder(request));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/order-detail")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "旅行团订单详情")
|
||||
public R<CommonTravelOrderDetailApiVO> orderDetail(Long id) {
|
||||
return R.data(orderService.travelOrderDetail(id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -12,11 +12,7 @@ import java.util.List;
|
||||
@Data
|
||||
public class CreateTravelOrderRequest implements Serializable {
|
||||
|
||||
// @NotEmpty(message = "请填写联系人")
|
||||
private String consignee;
|
||||
|
||||
// @NotEmpty(message = "请填写联系电话")
|
||||
private String consigneePhone;
|
||||
|
||||
@NotEmpty(message = "订单类型为空")
|
||||
private String orderType;
|
||||
@@ -24,12 +20,9 @@ public class CreateTravelOrderRequest implements Serializable {
|
||||
@NotEmpty(message = "商品编号为空")
|
||||
private String itemCode;
|
||||
|
||||
// @NotNull(message = "商品数量不能为空")
|
||||
@Min(value = 1, message = "无效商品数量")
|
||||
private Integer quantity;
|
||||
|
||||
// @NotEmpty(message = "请填写收货地址")
|
||||
private String address;
|
||||
|
||||
@NotNull(message = "无效支付方式")
|
||||
private Integer paymentType;
|
||||
|
||||
@@ -10,5 +10,5 @@ public class MerchantStoreRequest implements Serializable {
|
||||
|
||||
private BigDecimal longitude;
|
||||
private BigDecimal latitude;
|
||||
private BigDecimal distance = new BigDecimal("2000");
|
||||
// private BigDecimal distance = new BigDecimal("2000");
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package org.springblade.modules.api.response;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PaymentResponse implements Serializable {
|
||||
|
||||
private Integer paymentType;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.springblade.modules.api.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class CommonModulePayTypeApiVO {
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private Integer isEnable;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package org.springblade.modules.api.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springblade.modules.common.pojo.entity.TourOrderDetailEntity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CommonTravelOrderDetailApiVO implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String consigneePhone;
|
||||
|
||||
private String consignee;
|
||||
|
||||
private String orderType;
|
||||
|
||||
private String itemCode;
|
||||
|
||||
private String itemName;
|
||||
|
||||
private String imageUrl;
|
||||
|
||||
private Integer quantity;
|
||||
|
||||
|
||||
private Integer orderStatus;
|
||||
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
private BigDecimal actualAmount;
|
||||
|
||||
private Integer paymentType;
|
||||
|
||||
private Date paymentTime;
|
||||
|
||||
private Integer paymentStatus;
|
||||
|
||||
|
||||
private String contractUrl;
|
||||
/**
|
||||
* 合同签署状态:0=未签署,1=已签署,2=已过期
|
||||
*/
|
||||
|
||||
private Integer contractStatus;
|
||||
/**
|
||||
* 导游姓名
|
||||
*/
|
||||
private String guideName;
|
||||
/**
|
||||
* 导游联系电话
|
||||
*/
|
||||
private String guidePhone;
|
||||
|
||||
private Date tourStartDate;
|
||||
/**
|
||||
* 预计返回日期
|
||||
*/
|
||||
private Date tourEndDate;
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
private List<TourOrderDetailEntity.TravelerDetail> travelerDetail;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.springblade.modules.common.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "tianditumap")
|
||||
public class TianDiTuConfiguration {
|
||||
|
||||
private String key;
|
||||
|
||||
private String baseUrl;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.springblade.modules.common.constant;
|
||||
|
||||
public interface BladeCommonConstant {
|
||||
|
||||
// 业务模块支付类型
|
||||
String BUSINESS_MODULE_PAY_TYPE = "common.business.module.pay.type";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package org.springblade.modules.common.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import lombok.AllArgsConstructor;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.modules.common.pojo.entity.CommonOrderConfirmLogEntity;
|
||||
import org.springblade.modules.common.pojo.vo.CommonOrderConfirmLogVO;
|
||||
import org.springblade.modules.common.wrapper.CommonOrderConfirmLogWrapper;
|
||||
import org.springblade.modules.common.service.ICommonOrderConfirmLogService;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 订单确认收货记录 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-03-25
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("common/order-confirm-log")
|
||||
@Tag(name = "订单确认收货记录", description = "订单确认收货记录接口")
|
||||
public class CommonOrderConfirmLogController extends BladeController {
|
||||
|
||||
private final ICommonOrderConfirmLogService commonOrderConfirmLogService;
|
||||
|
||||
/**
|
||||
* 订单确认收货记录 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入commonOrderConfirmLog")
|
||||
public R<CommonOrderConfirmLogVO> detail(CommonOrderConfirmLogEntity commonOrderConfirmLog) {
|
||||
CommonOrderConfirmLogEntity detail = commonOrderConfirmLogService.getOne(Condition.getQueryWrapper(commonOrderConfirmLog));
|
||||
return R.data(CommonOrderConfirmLogWrapper.build().entityVO(detail));
|
||||
}
|
||||
/**
|
||||
* 订单确认收货记录 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入commonOrderConfirmLog")
|
||||
public R<IPage<CommonOrderConfirmLogVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> commonOrderConfirmLog, Query query) {
|
||||
IPage<CommonOrderConfirmLogEntity> pages = commonOrderConfirmLogService.page(Condition.getPage(query), Condition.getQueryWrapper(commonOrderConfirmLog, CommonOrderConfirmLogEntity.class));
|
||||
return R.data(CommonOrderConfirmLogWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单确认收货记录 自定义分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "分页", description = "传入commonOrderConfirmLog")
|
||||
public R<IPage<CommonOrderConfirmLogVO>> page(CommonOrderConfirmLogVO commonOrderConfirmLog, Query query) {
|
||||
IPage<CommonOrderConfirmLogVO> pages = commonOrderConfirmLogService.selectCommonOrderConfirmLogPage(Condition.getPage(query), commonOrderConfirmLog);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单确认收货记录 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入commonOrderConfirmLog")
|
||||
public R save(@Valid @RequestBody CommonOrderConfirmLogEntity commonOrderConfirmLog) {
|
||||
return R.status(commonOrderConfirmLogService.save(commonOrderConfirmLog));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单确认收货记录 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入commonOrderConfirmLog")
|
||||
public R update(@Valid @RequestBody CommonOrderConfirmLogEntity commonOrderConfirmLog) {
|
||||
return R.status(commonOrderConfirmLogService.updateById(commonOrderConfirmLog));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单确认收货记录 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入commonOrderConfirmLog")
|
||||
public R submit(@Valid @RequestBody CommonOrderConfirmLogEntity commonOrderConfirmLog) {
|
||||
return R.status(commonOrderConfirmLogService.saveOrUpdate(commonOrderConfirmLog));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单确认收货记录 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(commonOrderConfirmLogService.deleteLogic(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package org.springblade.modules.common.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import lombok.AllArgsConstructor;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.modules.common.pojo.entity.CommonPayOrderEntity;
|
||||
import org.springblade.modules.common.pojo.vo.CommonPayOrderVO;
|
||||
import org.springblade.modules.common.wrapper.CommonPayOrderWrapper;
|
||||
import org.springblade.modules.common.service.ICommonPayOrderService;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 系统内部订单关联支付记录 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-03-24
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("common/pay-order")
|
||||
@Tag(name = "系统内部订单关联支付记录", description = "系统内部订单关联支付记录接口")
|
||||
public class CommonPayOrderController extends BladeController {
|
||||
|
||||
private final ICommonPayOrderService commonPayOrderService;
|
||||
|
||||
/**
|
||||
* 系统内部订单关联支付记录 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入commonPayOrder")
|
||||
public R<CommonPayOrderVO> detail(CommonPayOrderEntity commonPayOrder) {
|
||||
CommonPayOrderEntity detail = commonPayOrderService.getOne(Condition.getQueryWrapper(commonPayOrder));
|
||||
return R.data(CommonPayOrderWrapper.build().entityVO(detail));
|
||||
}
|
||||
/**
|
||||
* 系统内部订单关联支付记录 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入commonPayOrder")
|
||||
public R<IPage<CommonPayOrderVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> commonPayOrder, Query query) {
|
||||
IPage<CommonPayOrderEntity> pages = commonPayOrderService.page(Condition.getPage(query), Condition.getQueryWrapper(commonPayOrder, CommonPayOrderEntity.class));
|
||||
return R.data(CommonPayOrderWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统内部订单关联支付记录 自定义分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "分页", description = "传入commonPayOrder")
|
||||
public R<IPage<CommonPayOrderVO>> page(CommonPayOrderVO commonPayOrder, Query query) {
|
||||
IPage<CommonPayOrderVO> pages = commonPayOrderService.selectCommonPayOrderPage(Condition.getPage(query), commonPayOrder);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统内部订单关联支付记录 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入commonPayOrder")
|
||||
public R save(@Valid @RequestBody CommonPayOrderEntity commonPayOrder) {
|
||||
return R.status(commonPayOrderService.save(commonPayOrder));
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统内部订单关联支付记录 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入commonPayOrder")
|
||||
public R update(@Valid @RequestBody CommonPayOrderEntity commonPayOrder) {
|
||||
return R.status(commonPayOrderService.updateById(commonPayOrder));
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统内部订单关联支付记录 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入commonPayOrder")
|
||||
public R submit(@Valid @RequestBody CommonPayOrderEntity commonPayOrder) {
|
||||
return R.status(commonPayOrderService.saveOrUpdate(commonPayOrder));
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统内部订单关联支付记录 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(commonPayOrderService.deleteLogic(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -5,7 +5,9 @@ import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import org.springblade.modules.api.request.AddressSubmitRequest;
|
||||
import org.springblade.modules.api.request.CreateMallOrderRequest;
|
||||
import org.springblade.modules.api.request.CreateTravelOrderRequest;
|
||||
import org.springblade.modules.api.vo.*;
|
||||
import org.springblade.modules.common.pojo.dto.BusinessModulePayTypeDTO;
|
||||
import org.springblade.modules.common.pojo.entity.*;
|
||||
import org.springblade.modules.common.pojo.vo.AppCommonRegionsInfoVO;
|
||||
import org.springblade.modules.common.pojo.vo.CommonUserOrderVO;
|
||||
@@ -49,14 +51,11 @@ public interface AppCommonConvert {
|
||||
@Mapping(target = "updateUser", ignore = true)
|
||||
@Mapping(target = "status", ignore = true)
|
||||
@Mapping(target = "isDeleted", ignore = true)
|
||||
@Mapping(target = "consigneePhone", source = "request.consigneePhone")
|
||||
@Mapping(target = "consignee", source = "request.consignee")
|
||||
@Mapping(target = "itemCode", source = "request.itemCode")
|
||||
@Mapping(target = "quantity", source = "request.quantity")
|
||||
@Mapping(target = "deliveryAddress", source = "request.address")
|
||||
@Mapping(target = "itemName", source = "product.productName")
|
||||
@Mapping(target = "imageUrl", source = "product.thumbnailUrl")
|
||||
CommonUserOrderEntity convertTourProductToOrder(CreateMallOrderRequest request, TourProductEntity product);
|
||||
CommonUserOrderEntity convertTourProductToOrder(CreateTravelOrderRequest request, TourProductEntity product);
|
||||
|
||||
CommonUserOrderApiVO convertUserOrderEntityToApi(CommonUserOrderEntity entity);
|
||||
|
||||
@@ -64,6 +63,8 @@ public interface AppCommonConvert {
|
||||
|
||||
CommonUserOrderDetailApiVO convertOrderDetailApiVO(CommonUserOrderEntity entity);
|
||||
|
||||
CommonTravelOrderDetailApiVO convertTravelOrderDetailApiVO(CommonUserOrderEntity entity);
|
||||
|
||||
CommonUserOrderApiVO convertOrderApiVO(CommonUserOrderVO vo);
|
||||
|
||||
List<CommonUserOrderApiVO> convertOrderApiListVO(List<CommonUserOrderVO> voList);
|
||||
@@ -87,4 +88,8 @@ public interface AppCommonConvert {
|
||||
TourOrderDetailEntity.ProductDetail convertTourProductToOrderDetail(TourProductEntity tourProduct);
|
||||
|
||||
List<TourOrderDetailEntity.ProductDetail> convertTourProductListToOrderDetail(List<TourProductEntity> tourProduct);
|
||||
|
||||
CommonModulePayTypeApiVO convertModulePayTypeToApiVO(BusinessModulePayTypeDTO.PayType dto);
|
||||
|
||||
List<CommonModulePayTypeApiVO> convertModulePayTypeListToApiVO(List<BusinessModulePayTypeDTO.PayType> list);
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ import lombok.RequiredArgsConstructor;
|
||||
@RequiredArgsConstructor
|
||||
public enum BusinessModule {
|
||||
|
||||
SELF_OPERATED_MALL("自营商城", "self_mall"),
|
||||
ECOSYSTEM_PRODUCT("生态商品", "eco_product"),
|
||||
TRAVEL_GROUP("旅游团", "travel_group"),
|
||||
LOTTERY("幸运抽奖", "lottery");
|
||||
SELF_OPERATED_MALL("自营商城", "self_mall" , "S"),
|
||||
ECOSYSTEM_PRODUCT("生态商品", "eco_product" , "E"),
|
||||
TRAVEL_GROUP("旅游团", "travel_group" , "T"),
|
||||
LOTTERY("幸运抽奖", "lottery" , "L");
|
||||
|
||||
@Getter
|
||||
private final String displayName;
|
||||
@@ -17,6 +17,9 @@ public enum BusinessModule {
|
||||
@Getter
|
||||
private final String code;
|
||||
|
||||
@Getter
|
||||
private final String abbr;
|
||||
|
||||
|
||||
// ========================
|
||||
// 根据 code 查找(忽略大小写)
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
package org.springblade.modules.common.eums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum PaymentType {
|
||||
|
||||
ALI(1, "支付宝"),
|
||||
WECHAT(2, "微信"),
|
||||
OFFLINE(99, "线下支付");
|
||||
ALI(1, "支付宝" , "A"),
|
||||
WECHAT(2, "微信" , "W"),
|
||||
OFFLINE(99, "线下支付" , "O");
|
||||
|
||||
@Getter
|
||||
private final int code;
|
||||
@Getter
|
||||
private final String name;
|
||||
@Getter
|
||||
private final String abbr;
|
||||
|
||||
|
||||
PaymentType(int code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
// ========== 静态映射:code -> enum ==========
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.springblade.modules.common.event;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PaymentCallbackEvent implements Serializable {
|
||||
|
||||
private Long id;
|
||||
private Date payTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.springblade.modules.common.event;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class StatsCommissionAccountEvent implements Serializable {
|
||||
|
||||
private Long id;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package org.springblade.modules.common.listener;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.modules.common.eums.BusinessModule;
|
||||
import org.springblade.modules.common.eums.OrderStatus;
|
||||
import org.springblade.modules.common.eums.PaymentStatus;
|
||||
import org.springblade.modules.common.event.PaymentCallbackEvent;
|
||||
import org.springblade.modules.common.event.PaymentSuccessEvent;
|
||||
import org.springblade.modules.common.event.StatsCommissionAccountEvent;
|
||||
import org.springblade.modules.common.pojo.entity.CommonPayOrderEntity;
|
||||
import org.springblade.modules.common.pojo.entity.CommonUserOrderEntity;
|
||||
import org.springblade.modules.common.service.ICommonPayOrderService;
|
||||
import org.springblade.modules.common.service.ICommonUserOrderService;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class PaymentListener {
|
||||
|
||||
private final ICommonPayOrderService commonPayOrderService;
|
||||
private final ICommonUserOrderService commonUserOrderService;
|
||||
private final ApplicationEventPublisher publisher;
|
||||
|
||||
@Async("paymentAsyncExecutor")
|
||||
@EventListener
|
||||
public void callbackSuccessPayment(PaymentCallbackEvent event) {
|
||||
log.info("支付回调监听 : {}" , event);
|
||||
|
||||
CommonPayOrderEntity payOrder = commonPayOrderService.getById(event.getId());
|
||||
if (payOrder == null){
|
||||
log.error("支付回调监听 : 订单不存在 , 订单id : {}" , event.getId());
|
||||
return;
|
||||
}
|
||||
if (payOrder.getOrderStatus() == 1){
|
||||
log.error("支付回调监听 : 订单已支付 , 订单id : {}" , event.getId());
|
||||
return;
|
||||
}
|
||||
if (payOrder.getPaymentStatus() == 1){
|
||||
log.error("支付回调监听 : 订单已支付 , 订单id : {}" , event.getId());
|
||||
return;
|
||||
}
|
||||
CommonUserOrderEntity userOrder = commonUserOrderService.getById(payOrder.getOrderId());
|
||||
if (userOrder == null){
|
||||
log.error("支付回调监听 : 订单不存在 , 订单id : {}" , payOrder.getOrderId());
|
||||
return;
|
||||
}
|
||||
if (userOrder.getOrderStatus() == 1){
|
||||
log.error("支付回调监听 : 订单已支付 , 订单id : {}" , payOrder.getOrderId());
|
||||
return;
|
||||
}
|
||||
|
||||
payOrder.setOrderStatus(OrderStatus.PAID.getCode());
|
||||
payOrder.setPaymentStatus(PaymentStatus.PAID.getCode());
|
||||
|
||||
userOrder.setOrderStatus(OrderStatus.PAID.getCode());
|
||||
userOrder.setPaymentStatus(PaymentStatus.PAID.getCode());
|
||||
userOrder.setPaymentType(payOrder.getPaymentType());
|
||||
userOrder.setPaymentTime(event.getPayTime());
|
||||
if (!commonPayOrderService.updateById(payOrder) || !commonUserOrderService.updateById(userOrder)){
|
||||
log.error("支付回调监听 : 订单支付失败 , 订单id : {}" , payOrder.getOrderId());
|
||||
return;
|
||||
}
|
||||
log.info("支付回调监听 : 订单支付成功 , 订单id : {}" , payOrder.getOrderId());
|
||||
publisher.publishEvent(new StatsCommissionAccountEvent().setId(userOrder.getId()));
|
||||
publisher.publishEvent(new PaymentSuccessEvent(payOrder.getOrderId(), userOrder.getUserId(), BusinessModule.fromCodeIgnoreCase(userOrder.getOrderType())));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
package org.springblade.modules.common.listener;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.common.utils.date.DateUtil;
|
||||
import org.springblade.modules.common.event.StatsCommissionAccountEvent;
|
||||
import org.springblade.modules.common.pojo.entity.CommonUserOrderEntity;
|
||||
import org.springblade.modules.common.service.ICommonUserOrderService;
|
||||
import org.springblade.modules.market.pojo.entity.*;
|
||||
import org.springblade.modules.market.service.*;
|
||||
import org.springframework.aop.framework.AopContext;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
@EnableAspectJAutoProxy(exposeProxy = true)
|
||||
public class StatsCommissionAccountListener {
|
||||
|
||||
private final ICommonUserOrderService userOrderService;
|
||||
private final IMarketCommissionAccountService commissionAccountService;
|
||||
private final IMarketCommissionAdvertisingLogService advertisingLogService;
|
||||
private final IMarketCommissionAgencyLogService agencyLogService;
|
||||
private final IMarketCommissionCoCreatorLogService creatorLogService;
|
||||
private final IMarketCommissionGoodsCostLogService goodsCostLogService;
|
||||
private final IMarketCommissionOperationLogService operationLogService;
|
||||
private final IMarketCommissionServiceProviderLogService serviceProviderLogService;
|
||||
|
||||
|
||||
|
||||
private static final Long GOODS_COST_ACCOUNT_ID = 2017485441885196290L;
|
||||
private static final Long OPERATION_ACCOUNT_ID = 2017486179294171138L;
|
||||
private static final Long ADVERTISING_ACCOUNT_ID = 2017486299502923778L;
|
||||
private static final Long SERVICE_PROVIDER_ACCOUNT_ID = 2017486437340336130L;
|
||||
private static final Long AGENCY_ACCOUNT_ID = 2017486568441696258L;
|
||||
private static final Long CREATOR_ACCOUNT_ID = 2017486664117964802L;
|
||||
|
||||
@Async("statsCommissionAsyncExecutor")
|
||||
@EventListener
|
||||
public void callbackSuccessPayment(StatsCommissionAccountEvent event) {
|
||||
try {
|
||||
// 【关键优化】使用 AopContext 获取当前代理对象,避免循环依赖
|
||||
// 必须确保启动类或配置类上有 @EnableAspectJAutoProxy(exposeProxy = true)
|
||||
StatsCommissionAccountListener proxy;
|
||||
try {
|
||||
proxy = (StatsCommissionAccountListener) AopContext.currentProxy();
|
||||
} catch (IllegalStateException e) {
|
||||
log.warn("AopContext 未开启 (exposeProxy=false),降级为直接调用,事务可能失效!请检查启动类配置。", e);
|
||||
proxy = this;
|
||||
}
|
||||
|
||||
proxy.processCommissionInternal(event);
|
||||
} catch (Exception e) {
|
||||
log.error("统计佣金入账处理异常,订单 ID: {}, 错误信息:{}", event.getId(), e.getMessage(), e);
|
||||
// 生产环境建议:此处可记录到死信表或发送告警
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void processCommissionInternal(StatsCommissionAccountEvent event) {
|
||||
log.info("开始处理统计佣金入账,订单 ID: {}", event.getId());
|
||||
|
||||
CommonUserOrderEntity userOrder = userOrderService.getById(event.getId());
|
||||
if (userOrder == null) {
|
||||
throw new RuntimeException("订单不存在,订单 ID: " + event.getId());
|
||||
}
|
||||
|
||||
BigDecimal totalActualAmount = userOrder.getActualAmount();
|
||||
if (totalActualAmount == null || totalActualAmount.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
log.warn("订单金额为 0 或空,跳过佣金计算,订单 ID: {}", event.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
String orderType = userOrder.getOrderType();
|
||||
Long orderId = userOrder.getId();
|
||||
String orderJson = JSONObject.toJSONString(userOrder);
|
||||
Date statisticalDate = DateUtil.getYesterday();
|
||||
|
||||
// --- 1. 广告补贴 (5%) ---
|
||||
BigDecimal advertisingAmount = totalActualAmount.multiply(BigDecimal.valueOf(0.05));
|
||||
if (advertisingAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
updateAccountAndSaveLog(ADVERTISING_ACCOUNT_ID, advertisingAmount, () -> {
|
||||
MarketCommissionAdvertisingLogEntity logEntity = new MarketCommissionAdvertisingLogEntity();
|
||||
logEntity.setAccountId(ADVERTISING_ACCOUNT_ID);
|
||||
logEntity.setAmount(advertisingAmount);
|
||||
logEntity.setLastAmount(BigDecimal.ZERO); // 并发下难以获取精确旧余额
|
||||
logEntity.setSourceType(orderType);
|
||||
logEntity.setSourceId(orderId);
|
||||
logEntity.setSourceDetail(orderJson);
|
||||
logEntity.setType(1);
|
||||
logEntity.setStatisticalDate(statisticalDate);
|
||||
logEntity.setIsComplete(1);
|
||||
logEntity.setRemark("自营商城订单入账 - 广告补贴");
|
||||
advertisingLogService.save(logEntity);
|
||||
});
|
||||
}
|
||||
|
||||
// --- 2. 极差代理 (15%) ---
|
||||
BigDecimal agencyAmount = totalActualAmount.multiply(BigDecimal.valueOf(0.15));
|
||||
if (agencyAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
updateAccountAndSaveLog(AGENCY_ACCOUNT_ID, agencyAmount, () -> {
|
||||
MarketCommissionAgencyLogEntity logEntity = new MarketCommissionAgencyLogEntity();
|
||||
logEntity.setAccountId(AGENCY_ACCOUNT_ID);
|
||||
logEntity.setAmount(agencyAmount);
|
||||
logEntity.setLastAmount(BigDecimal.ZERO);
|
||||
logEntity.setSourceType(orderType);
|
||||
logEntity.setSourceId(orderId);
|
||||
logEntity.setSourceDetail(orderJson);
|
||||
logEntity.setType(1);
|
||||
logEntity.setStatisticalDate(statisticalDate);
|
||||
logEntity.setIsComplete(1);
|
||||
logEntity.setRemark("自营商城订单入账 - 极差代理");
|
||||
agencyLogService.save(logEntity);
|
||||
});
|
||||
}
|
||||
|
||||
// --- 3. 联创 (5%) ---
|
||||
BigDecimal creatorAmount = totalActualAmount.multiply(BigDecimal.valueOf(0.05));
|
||||
if (creatorAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
updateAccountAndSaveLog(CREATOR_ACCOUNT_ID, creatorAmount, () -> {
|
||||
MarketCommissionCoCreatorLogEntity logEntity = new MarketCommissionCoCreatorLogEntity();
|
||||
logEntity.setAccountId(CREATOR_ACCOUNT_ID);
|
||||
logEntity.setAmount(creatorAmount);
|
||||
logEntity.setLastAmount(BigDecimal.ZERO);
|
||||
logEntity.setSourceType(orderType);
|
||||
logEntity.setSourceId(orderId);
|
||||
logEntity.setSourceDetail(orderJson);
|
||||
logEntity.setType(1);
|
||||
logEntity.setStatisticalDate(statisticalDate);
|
||||
logEntity.setIsComplete(1);
|
||||
logEntity.setRemark("自营商城订单入账 - 联创佣金");
|
||||
creatorLogService.save(logEntity);
|
||||
});
|
||||
}
|
||||
|
||||
// --- 4. 商品成本 (25%) ---
|
||||
BigDecimal goodsCostAmount = totalActualAmount.multiply(BigDecimal.valueOf(0.25));
|
||||
if (goodsCostAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
updateAccountAndSaveLog(GOODS_COST_ACCOUNT_ID, goodsCostAmount, () -> {
|
||||
MarketCommissionGoodsCostLogEntity logEntity = new MarketCommissionGoodsCostLogEntity();
|
||||
logEntity.setAccountId(GOODS_COST_ACCOUNT_ID);
|
||||
logEntity.setAmount(goodsCostAmount);
|
||||
logEntity.setLastAmount(BigDecimal.ZERO);
|
||||
logEntity.setSourceType(orderType);
|
||||
logEntity.setSourceId(orderId);
|
||||
logEntity.setSourceDetail(orderJson);
|
||||
logEntity.setType(1);
|
||||
logEntity.setStatisticalDate(statisticalDate);
|
||||
logEntity.setIsComplete(1);
|
||||
logEntity.setRemark("自营商城订单入账 - 商品成本");
|
||||
goodsCostLogService.save(logEntity);
|
||||
});
|
||||
}
|
||||
|
||||
// --- 5. 运营 (5%) ---
|
||||
BigDecimal operationAmount = totalActualAmount.multiply(BigDecimal.valueOf(0.05));
|
||||
if (operationAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
updateAccountAndSaveLog(OPERATION_ACCOUNT_ID, operationAmount, () -> {
|
||||
MarketCommissionOperationLogEntity logEntity = new MarketCommissionOperationLogEntity();
|
||||
logEntity.setAccountId(OPERATION_ACCOUNT_ID);
|
||||
logEntity.setAmount(operationAmount);
|
||||
logEntity.setLastAmount(BigDecimal.ZERO);
|
||||
logEntity.setSourceType(orderType);
|
||||
logEntity.setSourceId(orderId);
|
||||
logEntity.setSourceDetail(orderJson);
|
||||
logEntity.setType(1);
|
||||
logEntity.setStatisticalDate(statisticalDate);
|
||||
logEntity.setIsComplete(1);
|
||||
logEntity.setRemark("自营商城订单入账 - 运营佣金");
|
||||
operationLogService.save(logEntity);
|
||||
});
|
||||
}
|
||||
|
||||
// --- 6. 服务商 (5%) ---
|
||||
BigDecimal serviceProviderAmount = totalActualAmount.multiply(BigDecimal.valueOf(0.05));
|
||||
if (serviceProviderAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
updateAccountAndSaveLog(SERVICE_PROVIDER_ACCOUNT_ID, serviceProviderAmount, () -> {
|
||||
MarketCommissionServiceProviderLogEntity logEntity = new MarketCommissionServiceProviderLogEntity();
|
||||
logEntity.setAccountId(SERVICE_PROVIDER_ACCOUNT_ID);
|
||||
logEntity.setAmount(serviceProviderAmount);
|
||||
logEntity.setLastAmount(BigDecimal.ZERO);
|
||||
logEntity.setSourceType(orderType);
|
||||
logEntity.setSourceId(orderId);
|
||||
logEntity.setSourceDetail(orderJson);
|
||||
logEntity.setType(1);
|
||||
logEntity.setStatisticalDate(statisticalDate);
|
||||
logEntity.setIsComplete(1);
|
||||
logEntity.setIsSalaryPaid(1); // 特有字段
|
||||
logEntity.setRemark("自营商城订单入账 - 服务商佣金");
|
||||
serviceProviderLogService.save(logEntity);
|
||||
});
|
||||
}
|
||||
|
||||
log.info("佣金入账处理成功,订单 ID: {}", event.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 核心原子操作:更新账户余额 + 执行日志保存回调
|
||||
* 保证两者在同一个事务中,要么都成功,要么都回滚
|
||||
*/
|
||||
private void updateAccountAndSaveLog(Long accountId, BigDecimal amount, Runnable logSaveAction) {
|
||||
// 1. 数据库原子累加
|
||||
boolean updated = commissionAccountService.update(new LambdaUpdateWrapper<MarketCommissionAccountEntity>()
|
||||
.eq(MarketCommissionAccountEntity::getId, accountId)
|
||||
.setSql("amount = amount + " + amount.toPlainString())
|
||||
);
|
||||
|
||||
if (!updated) {
|
||||
log.error("佣金账户更新失败,账户 ID: {}, 金额:{}", accountId, amount);
|
||||
throw new RuntimeException("佣金账户更新失败,ID: " + accountId);
|
||||
}
|
||||
|
||||
// 2. 执行具体的日志保存逻辑
|
||||
logSaveAction.run();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.springblade.modules.common.manager;
|
||||
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.common.cache.ParamCache;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.modules.api.vo.CommonModulePayTypeApiVO;
|
||||
import org.springblade.modules.common.constant.BladeCommonConstant;
|
||||
import org.springblade.modules.common.convert.AppCommonConvert;
|
||||
import org.springblade.modules.common.eums.BusinessModule;
|
||||
import org.springblade.modules.common.pojo.dto.BusinessModulePayTypeDTO;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class AppCommonManager {
|
||||
|
||||
public List<CommonModulePayTypeApiVO> getModulePayTypeList(String moduleCode) {
|
||||
|
||||
BusinessModule businessModule = BusinessModule.fromCodeIgnoreCaseOrNull(moduleCode);
|
||||
if (businessModule == null) {
|
||||
log.error("无效业务模块");
|
||||
throw new ServiceException("无效业务模块");
|
||||
}
|
||||
|
||||
List<BusinessModulePayTypeDTO> payTypeDTOList = JSONArray.parseArray(ParamCache.getValue(BladeCommonConstant.BUSINESS_MODULE_PAY_TYPE), BusinessModulePayTypeDTO.class);
|
||||
BusinessModulePayTypeDTO result = payTypeDTOList.stream()
|
||||
.filter(dto -> moduleCode.equals(dto.getCode()))
|
||||
.findFirst()
|
||||
.orElse(null); // 如果找不到,返回 null
|
||||
|
||||
if (result == null) {
|
||||
log.error("无效业务模块");
|
||||
throw new ServiceException("无效业务模块");
|
||||
}
|
||||
|
||||
return AppCommonConvert.INSTANCE.convertModulePayTypeListToApiVO(result.getPayTypeList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.springblade.modules.common.mapper;
|
||||
|
||||
import org.springblade.modules.common.pojo.entity.CommonOrderConfirmLogEntity;
|
||||
import org.springblade.modules.common.pojo.vo.CommonOrderConfirmLogVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单确认收货记录 Mapper 接口
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-03-25
|
||||
*/
|
||||
public interface CommonOrderConfirmLogMapper extends BaseMapper<CommonOrderConfirmLogEntity> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param commonOrderConfirmLog 查询参数
|
||||
* @return List<CommonOrderConfirmLogVO>
|
||||
*/
|
||||
List<CommonOrderConfirmLogVO> selectCommonOrderConfirmLogPage(IPage page, CommonOrderConfirmLogVO commonOrderConfirmLog);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.springblade.modules.common.mapper.CommonOrderConfirmLogMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="commonOrderConfirmLogResultMap" type="org.springblade.modules.common.pojo.entity.CommonOrderConfirmLogEntity">
|
||||
<result column="id" property="id"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<result column="order_id" property="orderId"/>
|
||||
<result column="address_id" property="addressId"/>
|
||||
<result column="actual_amount" property="actualAmount"/>
|
||||
<result column="order_type" property="orderType"/>
|
||||
<result column="payment_type" property="paymentType"/>
|
||||
<result column="is_agency_distributed" property="isAgencyDistributed"/>
|
||||
<result column="agency_distribute_time" property="agencyDistributeTime"/>
|
||||
<result column="is_service_distributed" property="isServiceDistributed"/>
|
||||
<result column="service_distribute_time" property="serviceDistributeTime"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="create_user" property="createUser"/>
|
||||
<result column="create_dept" property="createDept"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_user" property="updateUser"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<result column="remark" property="remark"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="selectCommonOrderConfirmLogPage" resultMap="commonOrderConfirmLogResultMap">
|
||||
select * from common_order_confirm_log where is_deleted = 0
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.springblade.modules.common.mapper;
|
||||
|
||||
import org.springblade.modules.common.pojo.entity.CommonPayOrderEntity;
|
||||
import org.springblade.modules.common.pojo.vo.CommonPayOrderVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统内部订单关联支付记录 Mapper 接口
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-03-24
|
||||
*/
|
||||
public interface CommonPayOrderMapper extends BaseMapper<CommonPayOrderEntity> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param commonPayOrder 查询参数
|
||||
* @return List<CommonPayOrderVO>
|
||||
*/
|
||||
List<CommonPayOrderVO> selectCommonPayOrderPage(IPage page, CommonPayOrderVO commonPayOrder);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.springblade.modules.common.mapper.CommonPayOrderMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="commonPayOrderResultMap" type="org.springblade.modules.common.pojo.entity.CommonPayOrderEntity">
|
||||
<result column="id" property="id"/>
|
||||
<result column="order_id" property="orderId"/>
|
||||
<result column="order_status" property="orderStatus"/>
|
||||
<result column="payment_status" property="paymentStatus"/>
|
||||
<result column="create_user" property="createUser"/>
|
||||
<result column="create_dept" property="createDept"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_user" property="updateUser"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<result column="remark" property="remark"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="selectCommonPayOrderPage" resultMap="commonPayOrderResultMap">
|
||||
select * from common_pay_order where is_deleted = 0
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.springblade.modules.common.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springblade.modules.api.request.MerchantStoreRequest;
|
||||
import org.springblade.modules.api.vo.CommonMerchantStoreApiVO;
|
||||
import org.springblade.modules.api.vo.CommonMerchantStoreDetailApiVO;
|
||||
@@ -7,6 +8,7 @@ import org.springblade.modules.common.pojo.entity.MerchantFlagshipStoreEntity;
|
||||
import org.springblade.modules.common.pojo.vo.MerchantFlagshipStoreVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -27,7 +29,17 @@ public interface MerchantFlagshipStoreMapper extends BaseMapper<MerchantFlagship
|
||||
List<MerchantFlagshipStoreVO> selectMerchantFlagshipStorePage(IPage page, MerchantFlagshipStoreVO merchantFlagshipStore);
|
||||
|
||||
|
||||
List<CommonMerchantStoreApiVO> merchantStoreList(MerchantStoreRequest request);
|
||||
List<CommonMerchantStoreApiVO> merchantStoreList(
|
||||
@Param("request") MerchantStoreRequest request,
|
||||
@Param("offset") int offset,
|
||||
@Param("limit") int limit
|
||||
);
|
||||
|
||||
/**
|
||||
* 2. 只查总数 (复用你之前写好的逻辑,或者单独写一个简单的)
|
||||
* 这里的 ID 可以随意,只要 XML 对应即可
|
||||
*/
|
||||
Long merchantStoreListCount(@Param("request") MerchantStoreRequest request);
|
||||
|
||||
CommonMerchantStoreDetailApiVO merchantStoreDetail(Long id);
|
||||
}
|
||||
|
||||
@@ -40,8 +40,19 @@
|
||||
select * from merchant_flagship_store where is_deleted = 0 order by id desc
|
||||
</select>
|
||||
|
||||
<select id="merchantStoreList" resultType="org.springblade.modules.api.vo.CommonMerchantStoreApiVO">
|
||||
<!-- 1. 手动定义的 Count 查询 (解决分页插件解析 <-> 报错的问题) -->
|
||||
<select id="merchantStoreListCount" resultType="java.lang.Long">
|
||||
SELECT COUNT(*) FROM (
|
||||
SELECT 1
|
||||
FROM merchant_flagship_store
|
||||
WHERE
|
||||
ST_DWithin(location, ST_SetSRID(ST_Point(#{request.longitude}, #{request.latitude}), 4326), 5000000)
|
||||
AND is_deleted = 0
|
||||
) TOTAL
|
||||
</select>
|
||||
|
||||
<!-- 2. 原始数据查询 -->
|
||||
<select id="merchantStoreList" resultType="org.springblade.modules.api.vo.CommonMerchantStoreApiVO">
|
||||
SELECT
|
||||
id,
|
||||
store_name,
|
||||
@@ -49,18 +60,15 @@
|
||||
thumbnail_url,
|
||||
ST_X(location) AS lng,
|
||||
ST_Y(location) AS lat,
|
||||
ROUND(ST_DistanceSphere(location,ST_SetSRID(ST_Point(#{longitude}, #{latitude}), 4326))::numeric,2) AS distance
|
||||
ROUND(ST_DistanceSphere(location, ST_SetSRID(ST_Point(#{request.longitude}, #{request.latitude}), 4326))::numeric, 2) AS distance
|
||||
FROM
|
||||
merchant_flagship_store
|
||||
WHERE
|
||||
|
||||
ST_DWithin(location,ST_SetSRID(ST_Point(#{longitude}, #{latitude}), 4326),#{distance})
|
||||
|
||||
AND is_deleted = 0
|
||||
ST_DWithin(location, ST_SetSRID(ST_Point(#{request.longitude}, #{request.latitude}), 4326), 5000000)
|
||||
AND is_deleted = 0
|
||||
ORDER BY
|
||||
location <-> ST_SetSRID(ST_Point(#{longitude}, #{latitude}), 4326)
|
||||
|
||||
|
||||
location <-> ST_SetSRID(ST_Point(#{request.longitude}, #{request.latitude}), 4326)
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
</select>
|
||||
|
||||
<select id="merchantStoreDetail" resultMap="merchantStoreDetailApiMap">
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.springblade.modules.common.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BusinessModulePayTypeDTO {
|
||||
|
||||
private String code;
|
||||
|
||||
private List<PayType> payTypeList;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class PayType {
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private Integer isEnable;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.modules.common.pojo.dto;
|
||||
|
||||
import org.springblade.modules.common.pojo.entity.CommonOrderConfirmLogEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 订单确认收货记录 数据传输对象实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-03-25
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CommonOrderConfirmLogDTO extends CommonOrderConfirmLogEntity {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.modules.common.pojo.dto;
|
||||
|
||||
import org.springblade.modules.common.pojo.entity.CommonPayOrderEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 系统内部订单关联支付记录 数据传输对象实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-03-24
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CommonPayOrderDTO extends CommonPayOrderEntity {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package org.springblade.modules.common.pojo.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 订单确认收货记录 实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-03-25
|
||||
*/
|
||||
@Data
|
||||
@TableName("common_order_confirm_log")
|
||||
@Schema(description = "CommonOrderConfirmLog对象")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class CommonOrderConfirmLogEntity extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@Schema(description = "用户id")
|
||||
private Long userId;
|
||||
/**
|
||||
* 订单id
|
||||
*/
|
||||
@Schema(description = "订单id")
|
||||
private Long orderId;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Schema(description = "商品名称")
|
||||
private String itemName;
|
||||
|
||||
/**
|
||||
* 收货地址id
|
||||
*/
|
||||
@Schema(description = "收货地址")
|
||||
private String deliveryAddress;
|
||||
/**
|
||||
* 实际支付金额
|
||||
*/
|
||||
@Schema(description = "实际支付金额")
|
||||
private BigDecimal actualAmount;
|
||||
/**
|
||||
* 订单类型
|
||||
*/
|
||||
@Schema(description = "订单类型")
|
||||
private String orderType;
|
||||
/**
|
||||
* 支付类型
|
||||
*/
|
||||
@Schema(description = "支付类型")
|
||||
private Integer paymentType;
|
||||
/**
|
||||
* 是否分发极差代理 (0:未分发, 1:已分发)
|
||||
*/
|
||||
@Schema(description = "是否分发极差代理 (0:未分发, 1:已分发)")
|
||||
private Integer isAgencyDistributed;
|
||||
/**
|
||||
* 极差代理发放时间
|
||||
*/
|
||||
@Schema(description = "极差代理发放时间")
|
||||
private Date agencyDistributeTime;
|
||||
/**
|
||||
* 是否发放服务商佣金 (0:未发放, 1:已发放)
|
||||
*/
|
||||
@Schema(description = "是否发放服务商佣金 (0:未发放, 1:已发放)")
|
||||
private Integer isServiceDistributed;
|
||||
/**
|
||||
* 服务商佣金发放时间
|
||||
*/
|
||||
@Schema(description = "服务商佣金发放时间")
|
||||
private Date serviceDistributeTime;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.modules.common.pojo.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.util.Date;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
import org.springblade.core.tenant.mp.TenantEntity;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 系统内部订单关联支付记录 实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-03-24
|
||||
*/
|
||||
@Data
|
||||
@TableName("common_pay_order")
|
||||
@Schema(description = "CommonPayOrder对象")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class CommonPayOrderEntity extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 系统内部订单id
|
||||
*/
|
||||
@Schema(description = "系统内部订单id")
|
||||
private Long orderId;
|
||||
/**
|
||||
* 订单状态
|
||||
*/
|
||||
@Schema(description = "订单状态")
|
||||
private Integer orderStatus;
|
||||
/**
|
||||
* 支付状态
|
||||
*/
|
||||
@Schema(description = "支付状态")
|
||||
private Integer paymentStatus;
|
||||
|
||||
/**
|
||||
* 支付类型
|
||||
*/
|
||||
@Schema(description = "支付类型")
|
||||
private Integer paymentType;
|
||||
|
||||
/**
|
||||
* 支付插件orderNo
|
||||
*/
|
||||
@Schema(description = "支付插件orderNo")
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
* @since 2026-03-20
|
||||
*/
|
||||
@Data
|
||||
@TableName("tour_order_detail")
|
||||
@TableName(value = "tour_order_detail" , autoResultMap = true)
|
||||
@Schema(description = "TourOrderDetail对象")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TourOrderDetailEntity extends BaseEntity {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.modules.common.pojo.vo;
|
||||
|
||||
import org.springblade.modules.common.pojo.entity.CommonOrderConfirmLogEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 订单确认收货记录 视图实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-03-25
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CommonOrderConfirmLogVO extends CommonOrderConfirmLogEntity {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.modules.common.pojo.vo;
|
||||
|
||||
import org.springblade.modules.common.pojo.entity.CommonPayOrderEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 系统内部订单关联支付记录 视图实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-03-24
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CommonPayOrderVO extends CommonPayOrderEntity {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.springblade.modules.common.request;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class TianDiTuGeoInfoRequest implements Serializable {
|
||||
|
||||
private String ds;
|
||||
|
||||
private String tk;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package org.springblade.modules.common.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class TianDiTuGeoResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 响应消息,例如 "ok"
|
||||
*/
|
||||
@JsonProperty("msg")
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 详细位置信息对象
|
||||
*/
|
||||
@JsonProperty("location")
|
||||
private LocationInfo location;
|
||||
|
||||
/**
|
||||
* 搜索版本号,例如 "7.5.0V"
|
||||
*/
|
||||
@JsonProperty("searchVersion")
|
||||
private String searchVersion;
|
||||
|
||||
/**
|
||||
* 状态码,例如 "0" 表示成功
|
||||
*/
|
||||
@JsonProperty("status")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 内部静态类:位置详细信息
|
||||
*/
|
||||
@Data
|
||||
public static class LocationInfo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 匹配得分,例如 100
|
||||
*/
|
||||
@JsonProperty("score")
|
||||
private Integer score;
|
||||
|
||||
/**
|
||||
* 匹配级别,例如 "门址"
|
||||
*/
|
||||
@JsonProperty("level")
|
||||
private String level;
|
||||
|
||||
/**
|
||||
* 经度字符串
|
||||
*/
|
||||
@JsonProperty("lon")
|
||||
private String lon;
|
||||
|
||||
/**
|
||||
* 纬度字符串
|
||||
*/
|
||||
@JsonProperty("lat")
|
||||
private String lat;
|
||||
|
||||
/**
|
||||
* 原始关键词或地址描述
|
||||
*/
|
||||
@JsonProperty("keyWord")
|
||||
private String keyWord;
|
||||
|
||||
// 如果需要将经纬度转换为 Double 类型方便计算,可以添加辅助方法
|
||||
public Double getLonDouble() {
|
||||
try {
|
||||
return Double.parseDouble(this.lon);
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Double getLatDouble() {
|
||||
try {
|
||||
return Double.parseDouble(this.lat);
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.springblade.modules.common.service;
|
||||
|
||||
import org.springblade.modules.common.pojo.entity.CommonOrderConfirmLogEntity;
|
||||
import org.springblade.modules.common.pojo.vo.CommonOrderConfirmLogVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseService;
|
||||
|
||||
/**
|
||||
* 订单确认收货记录 服务类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-03-25
|
||||
*/
|
||||
public interface ICommonOrderConfirmLogService extends BaseService<CommonOrderConfirmLogEntity> {
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param commonOrderConfirmLog 查询参数
|
||||
* @return IPage<CommonOrderConfirmLogVO>
|
||||
*/
|
||||
IPage<CommonOrderConfirmLogVO> selectCommonOrderConfirmLogPage(IPage<CommonOrderConfirmLogVO> page, CommonOrderConfirmLogVO commonOrderConfirmLog);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.springblade.modules.common.service;
|
||||
|
||||
import org.springblade.modules.common.pojo.entity.CommonPayOrderEntity;
|
||||
import org.springblade.modules.common.pojo.vo.CommonPayOrderVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseService;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统内部订单关联支付记录 服务类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-03-24
|
||||
*/
|
||||
public interface ICommonPayOrderService extends BaseService<CommonPayOrderEntity> {
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param commonPayOrder 查询参数
|
||||
* @return IPage<CommonPayOrderVO>
|
||||
*/
|
||||
IPage<CommonPayOrderVO> selectCommonPayOrderPage(IPage<CommonPayOrderVO> page, CommonPayOrderVO commonPayOrder);
|
||||
|
||||
|
||||
}
|
||||
@@ -28,9 +28,11 @@ package org.springblade.modules.common.service;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import org.springblade.modules.api.request.ConfirmOrderRequest;
|
||||
import org.springblade.modules.api.request.CreateMallOrderRequest;
|
||||
import org.springblade.modules.api.request.CreateTravelOrderRequest;
|
||||
import org.springblade.modules.api.request.PaymentRequest;
|
||||
import org.springblade.modules.api.response.CreateOrderResponse;
|
||||
import org.springblade.modules.api.response.PaymentResponse;
|
||||
import org.springblade.modules.api.vo.CommonTravelOrderDetailApiVO;
|
||||
import org.springblade.modules.api.vo.CommonUserOrderApiVO;
|
||||
import org.springblade.modules.api.vo.CommonUserOrderDetailApiVO;
|
||||
import org.springblade.modules.common.pojo.entity.CommonUserOrderEntity;
|
||||
@@ -73,12 +75,16 @@ public interface ICommonUserOrderService extends IService<CommonUserOrderEntity>
|
||||
|
||||
CreateOrderResponse createMallOrder(CreateMallOrderRequest request);
|
||||
|
||||
CreateOrderResponse createTravelOrder(CreateTravelOrderRequest request);
|
||||
|
||||
PaymentResponse pay(PaymentRequest request);
|
||||
|
||||
IPage<CommonUserOrderApiVO> selectOrderApiPage(IPage<CommonUserOrderApiVO> page, CommonUserOrderApiVO userOrder);
|
||||
|
||||
CommonUserOrderDetailApiVO orderDetail(Long id);
|
||||
|
||||
CommonTravelOrderDetailApiVO travelOrderDetail(Long id);
|
||||
|
||||
boolean confirmPayment(Long id);
|
||||
|
||||
boolean fillExpress(Long id, String expressNo);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.springblade.modules.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springblade.modules.api.request.MerchantStoreRequest;
|
||||
@@ -33,7 +34,7 @@ public interface IMerchantFlagshipStoreService extends BaseService<MerchantFlags
|
||||
|
||||
boolean updateStore(@Valid MerchantFlagshipStoreVO merchantFlagshipStore);
|
||||
|
||||
List<CommonMerchantStoreApiVO> merchantStoreList(MerchantStoreRequest request);
|
||||
IPage<CommonMerchantStoreApiVO> merchantStoreList(MerchantStoreRequest request , IPage<CommonMerchantStoreApiVO> page);
|
||||
|
||||
CommonMerchantStoreDetailApiVO merchantStoreDetail(@NotNull(message = "无效店铺") Long id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.springblade.modules.common.service;
|
||||
|
||||
|
||||
import org.springblade.modules.common.pojo.dto.LocationDTO;
|
||||
|
||||
public interface TianDiTuMapService {
|
||||
|
||||
LocationDTO defaultLocation(String address);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.springblade.modules.common.service.impl;
|
||||
|
||||
import org.springblade.modules.common.pojo.entity.CommonOrderConfirmLogEntity;
|
||||
import org.springblade.modules.common.pojo.vo.CommonOrderConfirmLogVO;
|
||||
import org.springblade.modules.common.mapper.CommonOrderConfirmLogMapper;
|
||||
import org.springblade.modules.common.service.ICommonOrderConfirmLogService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
|
||||
/**
|
||||
* 订单确认收货记录 服务实现类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-03-25
|
||||
*/
|
||||
@Service
|
||||
public class CommonOrderConfirmLogServiceImpl extends BaseServiceImpl<CommonOrderConfirmLogMapper, CommonOrderConfirmLogEntity> implements ICommonOrderConfirmLogService {
|
||||
|
||||
@Override
|
||||
public IPage<CommonOrderConfirmLogVO> selectCommonOrderConfirmLogPage(IPage<CommonOrderConfirmLogVO> page, CommonOrderConfirmLogVO commonOrderConfirmLog) {
|
||||
return page.setRecords(baseMapper.selectCommonOrderConfirmLogPage(page, commonOrderConfirmLog));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.springblade.modules.common.service.impl;
|
||||
|
||||
import org.springblade.modules.common.pojo.entity.CommonPayOrderEntity;
|
||||
import org.springblade.modules.common.pojo.vo.CommonPayOrderVO;
|
||||
import org.springblade.modules.common.mapper.CommonPayOrderMapper;
|
||||
import org.springblade.modules.common.service.ICommonPayOrderService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
|
||||
|
||||
/**
|
||||
* 系统内部订单关联支付记录 服务实现类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-03-24
|
||||
*/
|
||||
@Service
|
||||
public class CommonPayOrderServiceImpl extends BaseServiceImpl<CommonPayOrderMapper, CommonPayOrderEntity> implements ICommonPayOrderService {
|
||||
|
||||
@Override
|
||||
public IPage<CommonPayOrderVO> selectCommonPayOrderPage(IPage<CommonPayOrderVO> page, CommonPayOrderVO commonPayOrder) {
|
||||
return page.setRecords(baseMapper.selectCommonPayOrderPage(page, commonPayOrder));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -36,9 +36,11 @@ import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.modules.api.request.ConfirmOrderRequest;
|
||||
import org.springblade.modules.api.request.CreateMallOrderRequest;
|
||||
import org.springblade.modules.api.request.CreateTravelOrderRequest;
|
||||
import org.springblade.modules.api.request.PaymentRequest;
|
||||
import org.springblade.modules.api.response.CreateOrderResponse;
|
||||
import org.springblade.modules.api.response.PaymentResponse;
|
||||
import org.springblade.modules.api.vo.CommonTravelOrderDetailApiVO;
|
||||
import org.springblade.modules.api.vo.CommonUserOrderApiVO;
|
||||
import org.springblade.modules.api.vo.CommonUserOrderDetailApiVO;
|
||||
import org.springblade.modules.common.convert.AppCommonConvert;
|
||||
@@ -48,10 +50,7 @@ import org.springblade.modules.common.eums.PaymentStatus;
|
||||
import org.springblade.modules.common.eums.PaymentType;
|
||||
import org.springblade.modules.common.event.FillExpressEvent;
|
||||
import org.springblade.modules.common.event.PaymentSuccessEvent;
|
||||
import org.springblade.modules.common.pojo.entity.CommonTourInfoEntity;
|
||||
import org.springblade.modules.common.pojo.entity.CommonUserOrderEntity;
|
||||
import org.springblade.modules.common.pojo.entity.TourOrderDetailEntity;
|
||||
import org.springblade.modules.common.pojo.entity.TourProductEntity;
|
||||
import org.springblade.modules.common.pojo.entity.*;
|
||||
import org.springblade.modules.common.pojo.vo.CommonUserOrderVO;
|
||||
import org.springblade.modules.common.excel.CommonUserOrderExcel;
|
||||
import org.springblade.modules.common.mapper.CommonUserOrderMapper;
|
||||
@@ -62,6 +61,9 @@ import org.springblade.modules.mall.service.IMallProductService;
|
||||
import org.springblade.modules.market.pojo.entity.MarketInfoEntity;
|
||||
import org.springblade.modules.market.service.IMarketInfoService;
|
||||
import org.springblade.modules.market.service.IMarketUserCommissionService;
|
||||
import org.springblade.plugin.pay.api.PaymentFacade;
|
||||
import org.springblade.plugin.pay.dto.APPPayDto;
|
||||
import org.springblade.plugin.pay.response.APPPayResult;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
@@ -95,6 +97,9 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
|
||||
private final IMarketInfoService marketInfoService;
|
||||
|
||||
private final PaymentFacade paymentFacade;
|
||||
private final ICommonOrderConfirmLogService orderConfirmLogService;
|
||||
|
||||
|
||||
@Override
|
||||
public IPage<CommonUserOrderVO> selectOrderPage(IPage<CommonUserOrderVO> page, CommonUserOrderVO order) {
|
||||
@@ -190,155 +195,137 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
order.setCreateTime(new Date());
|
||||
this.save(order);
|
||||
return new CreateOrderResponse(String.valueOf(order.getId()), actualAmount, totalAmount, discount);
|
||||
// return switch (BusinessModule.fromCodeIgnoreCaseOrNull(orderType)) {
|
||||
// case SELF_OPERATED_MALL -> {
|
||||
// if (request.getConsigneePhone() == null){
|
||||
// throw new ServiceException("请填写联系电话");
|
||||
// }
|
||||
//
|
||||
// if (request.getConsignee() == null){
|
||||
// throw new ServiceException("请填写联系人");
|
||||
// }
|
||||
//
|
||||
// MallProductEntity product = productService.getById(Long.valueOf(request.getItemCode()));
|
||||
// Assert.notNull(product, "无效商品");
|
||||
// CommonUserOrderEntity order = AppCommonConvert.INSTANCE.convertMallProductToOrder(request, product);
|
||||
// BigDecimal totalAmount = product.getRetailPrice().multiply(BigDecimal.valueOf(request.getQuantity())).setScale(2, RoundingMode.DOWN);
|
||||
// BigDecimal actualAmount = totalAmount.subtract(discount);
|
||||
// order.setOrderType(BusinessModule.SELF_OPERATED_MALL.getCode());
|
||||
// order.setUserId(AuthUtil.getUserId());
|
||||
// order.setTotalAmount(totalAmount);
|
||||
// order.setActualAmount(actualAmount);
|
||||
// order.setOrderType(orderType);
|
||||
// order.setPaymentType(request.getIsOfflinePayment() ? request.getPaymentType() : null);
|
||||
// order.setCreateTime(new Date());
|
||||
// this.save(order);
|
||||
// yield
|
||||
// }
|
||||
// case TRAVEL_GROUP -> {
|
||||
//
|
||||
// Long productId;
|
||||
// try {
|
||||
// productId = Long.valueOf(request.getItemCode());
|
||||
// } catch (NumberFormatException e) {
|
||||
// throw new ServiceException("商品ID格式非法");
|
||||
// }
|
||||
//
|
||||
// if (request.getPaymentType() != 1 && request.getPaymentType() != 2){
|
||||
// throw new ServiceException("请选择正确的支付方式");
|
||||
// }
|
||||
//
|
||||
// List<Long> travelerIds = request.getTourInfoIds();
|
||||
// if (CollectionUtils.isEmpty(travelerIds)) {
|
||||
// throw new ServiceException("请至少选择一名出行人");
|
||||
// }
|
||||
//
|
||||
// if (request.getTourStartDate() == null || request.getTourEndDate() == null){
|
||||
// throw new ServiceException("请选择出行时间");
|
||||
// }
|
||||
//
|
||||
// if (request.getTourStartDate().getTime() >= request.getTourEndDate().getTime()){
|
||||
// throw new ServiceException("开始时间不能大于结束时间");
|
||||
// }
|
||||
//
|
||||
// TourProductEntity tourProduct = tourProductService.getById(productId);
|
||||
// if (tourProduct == null || tourProduct.getStatus() != 1) { // 假设 1=上架
|
||||
// throw new ServiceException("该旅游产品已下架或不存在");
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// int selectedCount = travelerIds.size();
|
||||
// // 使用 Optional 处理数据库中可能为 NULL 的最大/最小人数限制
|
||||
// int minPeople = Optional.ofNullable(tourProduct.getMinPeople()).orElse(1);
|
||||
// int maxPeople = Optional.ofNullable(tourProduct.getMaxPeople()).orElse(9999);
|
||||
//
|
||||
// if (selectedCount < minPeople || selectedCount > maxPeople) {
|
||||
// throw new ServiceException(String.format("出行人数超出限制:最少 %d 人,最多 %d 人 (当前选择 %d 人)",
|
||||
// minPeople, maxPeople, selectedCount));
|
||||
// }
|
||||
//
|
||||
// // 3. 【核心安全】查询出行人信息 (增加 userId 校验,防止越权)
|
||||
// // 原代码未校验 userId,恶意用户可遍历 ID 盗用他人信息下单
|
||||
// List<CommonTourInfoEntity> travelerList = commonTourInfoService.list(
|
||||
// Wrappers.lambdaQuery(CommonTourInfoEntity.class)
|
||||
// .in(CommonTourInfoEntity::getId, travelerIds)
|
||||
// .eq(CommonTourInfoEntity::getUserId, AuthUtil.getUserId())
|
||||
// .orderByDesc(CommonTourInfoEntity::getId)
|
||||
// );
|
||||
//
|
||||
// // 校验是否所有请求的 ID 都成功查出(防止传入不存在的 ID 或他人的 ID)
|
||||
// if (travelerList.size() != selectedCount) {
|
||||
// throw new ServiceException("部分出行人信息无效或无权选择,请重新选择");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// // 4. 【金额计算】安全累加与证件校验
|
||||
// BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
// // 提前获取价格并兜底为 0,防止数据库脏数据导致 NPE
|
||||
// BigDecimal adultPrice = Optional.ofNullable(tourProduct.getAdultPrice()).orElse(BigDecimal.ZERO);
|
||||
// BigDecimal childPrice = Optional.ofNullable(tourProduct.getChildPrice()).orElse(BigDecimal.ZERO);
|
||||
// BigDecimal elderPrice = Optional.ofNullable(tourProduct.getBasePrice()).orElse(BigDecimal.ZERO);
|
||||
//
|
||||
// for (CommonTourInfoEntity traveler : travelerList) {
|
||||
// Integer type = Optional.ofNullable(traveler.getTravelerType()).orElse(1); // 默认成人
|
||||
//
|
||||
// // 累加金额
|
||||
// totalAmount = switch (type) {
|
||||
// case 1 -> totalAmount.add(adultPrice);
|
||||
// case 2 -> totalAmount.add(childPrice);
|
||||
// case 3 -> totalAmount.add(elderPrice);
|
||||
// default -> totalAmount.add(adultPrice); // 未知类型按成人算
|
||||
// };
|
||||
//
|
||||
// // 证件合规性校验 (提取为独立方法,保持主流程清晰)
|
||||
// validateCertificates(traveler, tourProduct);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// BigDecimal actualAmount = totalAmount.subtract(discount);
|
||||
// if (actualAmount.compareTo(BigDecimal.ZERO) < 0) {
|
||||
// actualAmount = BigDecimal.ZERO; // 防止实付金额为负
|
||||
// }
|
||||
//
|
||||
//
|
||||
// CommonUserOrderEntity order = AppCommonConvert.INSTANCE.convertTourProductToOrder(request, tourProduct);
|
||||
// order.setConsigneePhone(travelerList.get(0).getContactPhone());
|
||||
// order.setConsignee(travelerList.get(0).getUserName());
|
||||
// order.setUserId(AuthUtil.getUserId());
|
||||
// order.setOrderType(BusinessModule.TRAVEL_GROUP.getCode());
|
||||
// order.setTotalAmount(totalAmount);
|
||||
// order.setActualAmount(actualAmount);
|
||||
// order.setOrderType(orderType);
|
||||
// order.setPaymentType(request.getPaymentType());
|
||||
// order.setCreateTime(new Date());
|
||||
//
|
||||
// this.save(order);
|
||||
// if (order.getId() == null) {
|
||||
// throw new ServiceException("订单创建失败:无法生成订单号");
|
||||
// }
|
||||
//
|
||||
// // 7. 【构建订单】详情表 (快照)
|
||||
// TourOrderDetailEntity detail = new TourOrderDetailEntity();
|
||||
// detail.setOrderId(order.getId());
|
||||
// detail.setUserId(AuthUtil.getUserId());
|
||||
// detail.setStartDate(request.getTourStartDate());
|
||||
// detail.setEndDate(request.getTourEndDate());
|
||||
// detail.setRemark(request.getRemark());
|
||||
// detail.setContractStatus(0);
|
||||
//
|
||||
// // 转换快照数据
|
||||
// detail.setTravelerDetail(AppCommonConvert.INSTANCE.convertTourInfoListToOrderDetail(travelerList));
|
||||
// detail.setProductSnapshot(AppCommonConvert.INSTANCE.convertTourProductListToOrderDetail(List.of(tourProduct)));
|
||||
//
|
||||
// tourOrderDetailService.save(detail);
|
||||
//
|
||||
// yield new CreateOrderResponse(String.valueOf(order.getId()), actualAmount, totalAmount, discount);
|
||||
// }
|
||||
// default -> throw new IllegalArgumentException("不支持的订单类型: " + request.getOrderType());
|
||||
// };
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateOrderResponse createTravelOrder(CreateTravelOrderRequest request) {
|
||||
|
||||
BigDecimal discount = BigDecimal.ZERO;
|
||||
String orderType = request.getOrderType().toUpperCase();
|
||||
if (!request.getIsOfflinePayment()) {
|
||||
discount = BigDecimal.valueOf(new Random().nextInt(99) + 1, 2);
|
||||
}
|
||||
|
||||
Long productId;
|
||||
try {
|
||||
productId = Long.valueOf(request.getItemCode());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new ServiceException("商品ID格式非法");
|
||||
}
|
||||
|
||||
if (request.getPaymentType() != 1 && request.getPaymentType() != 2){
|
||||
throw new ServiceException("请选择正确的支付方式");
|
||||
}
|
||||
|
||||
List<Long> travelerIds = request.getTourInfoIds();
|
||||
if (CollectionUtils.isEmpty(travelerIds)) {
|
||||
throw new ServiceException("请至少选择一名出行人");
|
||||
}
|
||||
|
||||
if (request.getTourStartDate() == null || request.getTourEndDate() == null){
|
||||
throw new ServiceException("请选择出行时间");
|
||||
}
|
||||
|
||||
if (request.getTourStartDate().getTime() >= request.getTourEndDate().getTime()){
|
||||
throw new ServiceException("开始时间不能大于结束时间");
|
||||
}
|
||||
|
||||
TourProductEntity tourProduct = tourProductService.getById(productId);
|
||||
if (tourProduct == null || tourProduct.getStatus() != 1) { // 假设 1=上架
|
||||
throw new ServiceException("该旅游产品已下架或不存在");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int selectedCount = travelerIds.size();
|
||||
// 使用 Optional 处理数据库中可能为 NULL 的最大/最小人数限制
|
||||
int minPeople = Optional.ofNullable(tourProduct.getMinPeople()).orElse(1);
|
||||
int maxPeople = Optional.ofNullable(tourProduct.getMaxPeople()).orElse(9999);
|
||||
|
||||
if (selectedCount < minPeople || selectedCount > maxPeople) {
|
||||
throw new ServiceException(String.format("出行人数超出限制:最少 %d 人,最多 %d 人 (当前选择 %d 人)",
|
||||
minPeople, maxPeople, selectedCount));
|
||||
}
|
||||
|
||||
// 3. 【核心安全】查询出行人信息 (增加 userId 校验,防止越权)
|
||||
// 原代码未校验 userId,恶意用户可遍历 ID 盗用他人信息下单
|
||||
List<CommonTourInfoEntity> travelerList = commonTourInfoService.list(
|
||||
Wrappers.lambdaQuery(CommonTourInfoEntity.class)
|
||||
.in(CommonTourInfoEntity::getId, travelerIds)
|
||||
.eq(CommonTourInfoEntity::getUserId, AuthUtil.getUserId())
|
||||
.orderByDesc(CommonTourInfoEntity::getId)
|
||||
);
|
||||
|
||||
// 校验是否所有请求的 ID 都成功查出(防止传入不存在的 ID 或他人的 ID)
|
||||
if (travelerList.size() != selectedCount) {
|
||||
throw new ServiceException("部分出行人信息无效或无权选择,请重新选择");
|
||||
}
|
||||
|
||||
|
||||
// 4. 【金额计算】安全累加与证件校验
|
||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||
// 提前获取价格并兜底为 0,防止数据库脏数据导致 NPE
|
||||
BigDecimal adultPrice = Optional.ofNullable(tourProduct.getAdultPrice()).orElse(BigDecimal.ZERO);
|
||||
BigDecimal childPrice = Optional.ofNullable(tourProduct.getChildPrice()).orElse(BigDecimal.ZERO);
|
||||
BigDecimal elderPrice = Optional.ofNullable(tourProduct.getBasePrice()).orElse(BigDecimal.ZERO);
|
||||
|
||||
for (CommonTourInfoEntity traveler : travelerList) {
|
||||
Integer type = Optional.ofNullable(traveler.getTravelerType()).orElse(1); // 默认成人
|
||||
|
||||
// 累加金额
|
||||
totalAmount = switch (type) {
|
||||
case 1 -> totalAmount.add(adultPrice);
|
||||
case 2 -> totalAmount.add(childPrice);
|
||||
case 3 -> totalAmount.add(elderPrice);
|
||||
default -> totalAmount.add(adultPrice); // 未知类型按成人算
|
||||
};
|
||||
|
||||
// 证件合规性校验 (提取为独立方法,保持主流程清晰)
|
||||
validateCertificates(traveler, tourProduct);
|
||||
}
|
||||
|
||||
|
||||
|
||||
BigDecimal actualAmount = totalAmount.subtract(discount);
|
||||
if (actualAmount.compareTo(BigDecimal.ZERO) < 0) {
|
||||
actualAmount = BigDecimal.ZERO; // 防止实付金额为负
|
||||
}
|
||||
|
||||
|
||||
CommonUserOrderEntity order = AppCommonConvert.INSTANCE.convertTourProductToOrder(request, tourProduct);
|
||||
order.setConsigneePhone(travelerList.get(0).getContactPhone());
|
||||
order.setConsignee(travelerList.get(0).getUserName());
|
||||
order.setUserId(AuthUtil.getUserId());
|
||||
order.setOrderType(BusinessModule.TRAVEL_GROUP.getCode());
|
||||
order.setTotalAmount(totalAmount);
|
||||
order.setActualAmount(actualAmount);
|
||||
order.setOrderType(orderType);
|
||||
order.setPaymentType(request.getPaymentType());
|
||||
order.setCreateTime(new Date());
|
||||
|
||||
this.save(order);
|
||||
if (order.getId() == null) {
|
||||
throw new ServiceException("订单创建失败:无法生成订单号");
|
||||
}
|
||||
|
||||
// 7. 【构建订单】详情表 (快照)
|
||||
TourOrderDetailEntity detail = new TourOrderDetailEntity();
|
||||
detail.setOrderId(order.getId());
|
||||
detail.setUserId(AuthUtil.getUserId());
|
||||
detail.setStartDate(request.getTourStartDate());
|
||||
detail.setEndDate(request.getTourEndDate());
|
||||
detail.setRemark(request.getRemark());
|
||||
detail.setContractStatus(0);
|
||||
|
||||
// 转换快照数据
|
||||
detail.setTravelerDetail(AppCommonConvert.INSTANCE.convertTourInfoListToOrderDetail(travelerList));
|
||||
detail.setProductSnapshot(AppCommonConvert.INSTANCE.convertTourProductListToOrderDetail(List.of(tourProduct)));
|
||||
|
||||
tourOrderDetailService.save(detail);
|
||||
|
||||
return new CreateOrderResponse(String.valueOf(order.getId()), actualAmount, totalAmount, discount);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -350,8 +337,26 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
if (order.getPaymentType().equals(PaymentType.OFFLINE.getCode())) {
|
||||
throw new ServiceException("无效订单");
|
||||
}
|
||||
//todo: 继续支付逻辑
|
||||
return null;
|
||||
try {
|
||||
APPPayResult appPayResult = paymentFacade.appPay(
|
||||
new APPPayDto()
|
||||
.setOrderId(Long.valueOf(request.getOrderId()))
|
||||
.setPaymentType(PaymentType.fromCode(request.getPaymentType()))
|
||||
.setBusinessModule(BusinessModule.fromCodeIgnoreCaseOrNull(order.getOrderType()))
|
||||
.setAmount(order.getActualAmount())
|
||||
.setBody(order.getItemName())
|
||||
.setRemark(order.getItemName())
|
||||
);
|
||||
return new PaymentResponse()
|
||||
.setPaymentType(appPayResult.getPaymentTypeEnum().getCode())
|
||||
.setParams(appPayResult.getContent())
|
||||
.setPayChannel(appPayResult.getPaymentTypeEnum().getName())
|
||||
;
|
||||
}catch (Exception e){
|
||||
log.error("支付异常 : {}" , e.getMessage());
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -370,6 +375,30 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
return AppCommonConvert.INSTANCE.convertOrderDetailApiVO(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonTravelOrderDetailApiVO travelOrderDetail(Long id) {
|
||||
CommonUserOrderEntity order = getById(id);
|
||||
Assert.notNull(order, "无效订单");
|
||||
CommonTravelOrderDetailApiVO travelOrderDetailApiVO = AppCommonConvert.INSTANCE.convertTravelOrderDetailApiVO(order);
|
||||
|
||||
TourOrderDetailEntity tourOrderDetail = tourOrderDetailService.getOne(
|
||||
Wrappers.lambdaQuery(TourOrderDetailEntity.class)
|
||||
.eq(TourOrderDetailEntity::getOrderId, id)
|
||||
);
|
||||
|
||||
travelOrderDetailApiVO.setContractUrl(tourOrderDetail.getContractUrl());
|
||||
travelOrderDetailApiVO.setContractStatus(tourOrderDetail.getContractStatus());
|
||||
travelOrderDetailApiVO.setGuideName(tourOrderDetail.getGuideName());
|
||||
travelOrderDetailApiVO.setGuidePhone(tourOrderDetail.getGuidePhone());
|
||||
travelOrderDetailApiVO.setTourStartDate(tourOrderDetail.getStartDate());
|
||||
travelOrderDetailApiVO.setTourEndDate(tourOrderDetail.getEndDate());
|
||||
travelOrderDetailApiVO.setRemark(tourOrderDetail.getRemark());
|
||||
|
||||
travelOrderDetailApiVO.setTravelerDetail(tourOrderDetail.getTravelerDetail());
|
||||
|
||||
return travelOrderDetailApiVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean confirmPayment(Long id) {
|
||||
@@ -442,6 +471,7 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
if (order.getPaymentType().equals(PaymentType.OFFLINE.getCode())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (order.getOrderType().equalsIgnoreCase(BusinessModule.SELF_OPERATED_MALL.getCode())) {
|
||||
userPointService.grantPointsByUserOrder(order);
|
||||
MarketInfoEntity marketInfo = marketInfoService.getById(AuthUtil.getUserId());
|
||||
@@ -449,6 +479,19 @@ public class CommonUserOrderServiceImpl extends ServiceImpl<CommonUserOrderMappe
|
||||
if (marketInfo.getPid() != null) {
|
||||
commissionService.earnedCommissionByUserOrder(order, marketInfo.getPid());
|
||||
}
|
||||
|
||||
orderConfirmLogService.save(
|
||||
new CommonOrderConfirmLogEntity()
|
||||
.setOrderId(order.getId())
|
||||
.setUserId(order.getUserId())
|
||||
.setItemName(order.getItemName())
|
||||
.setOrderType(order.getOrderType())
|
||||
.setDeliveryAddress(order.getDeliveryAddress())
|
||||
.setActualAmount(order.getActualAmount())
|
||||
.setPaymentType(order.getPaymentType())
|
||||
.setIsServiceDistributed(0)
|
||||
.setIsAgencyDistributed(0)
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.springblade.modules.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
@@ -14,6 +15,7 @@ import org.springblade.modules.common.mapper.MerchantFlagshipStoreMapper;
|
||||
import org.springblade.modules.common.service.AMapService;
|
||||
import org.springblade.modules.common.service.ICommonRegionsInfoService;
|
||||
import org.springblade.modules.common.service.IMerchantFlagshipStoreService;
|
||||
import org.springblade.modules.common.service.TianDiTuMapService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
@@ -33,6 +35,7 @@ public class MerchantFlagshipStoreServiceImpl extends BaseServiceImpl<MerchantFl
|
||||
|
||||
private final AMapService mapService;
|
||||
private final ICommonRegionsInfoService commonRegionsInfoService;
|
||||
private final TianDiTuMapService tianDiTuMapService;
|
||||
|
||||
@Override
|
||||
public IPage<MerchantFlagshipStoreVO> selectMerchantFlagshipStorePage(IPage<MerchantFlagshipStoreVO> page, MerchantFlagshipStoreVO merchantFlagshipStore) {
|
||||
@@ -49,8 +52,8 @@ public class MerchantFlagshipStoreServiceImpl extends BaseServiceImpl<MerchantFl
|
||||
if (regionsInfo == null){
|
||||
throw new ServiceException("请选择正确的地址");
|
||||
}
|
||||
LocationDTO locationDTO = mapService.defaultLocation(regionsInfo.getFullName() + storeVO.getAddressDetail());
|
||||
|
||||
// LocationDTO locationDTO = mapService.defaultLocation(regionsInfo.getFullName() + storeVO.getAddressDetail());
|
||||
LocationDTO locationDTO = tianDiTuMapService.defaultLocation(regionsInfo.getFullName() + storeVO.getAddressDetail());
|
||||
|
||||
|
||||
MerchantFlagshipStoreEntity store = new MerchantFlagshipStoreEntity();
|
||||
@@ -83,7 +86,8 @@ public class MerchantFlagshipStoreServiceImpl extends BaseServiceImpl<MerchantFl
|
||||
throw new ServiceException("请选择正确的地址");
|
||||
}
|
||||
|
||||
LocationDTO locationDTO = mapService.defaultLocation(regionsInfo.getFullName() + storeVO.getAddressDetail());
|
||||
// LocationDTO locationDTO = mapService.defaultLocation(regionsInfo.getFullName() + storeVO.getAddressDetail());
|
||||
LocationDTO locationDTO = tianDiTuMapService.defaultLocation(regionsInfo.getFullName() + storeVO.getAddressDetail());
|
||||
|
||||
MerchantFlagshipStoreEntity store = new MerchantFlagshipStoreEntity();
|
||||
|
||||
@@ -103,8 +107,25 @@ public class MerchantFlagshipStoreServiceImpl extends BaseServiceImpl<MerchantFl
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommonMerchantStoreApiVO> merchantStoreList(MerchantStoreRequest request) {
|
||||
return this.baseMapper.merchantStoreList(request);
|
||||
public IPage<CommonMerchantStoreApiVO> merchantStoreList(MerchantStoreRequest request , IPage<CommonMerchantStoreApiVO> page) {
|
||||
long current = page.getCurrent();
|
||||
long size = page.getSize();
|
||||
int offset = (int) ((current - 1) * size);
|
||||
int limit = (int) size;
|
||||
|
||||
// 2. 手动查询总数
|
||||
// 注意:如果数据量极大且不需要精确总数,这里可以优化为查固定值或省略
|
||||
long total = baseMapper.merchantStoreListCount(request);
|
||||
|
||||
// 3. 手动查询列表数据
|
||||
List<CommonMerchantStoreApiVO> records = baseMapper.merchantStoreList(request, offset, limit);
|
||||
|
||||
// 4. 手动组装 IPage 对象
|
||||
Page<CommonMerchantStoreApiVO> resultPage = new Page<>(current, size, total);
|
||||
resultPage.setRecords(records);
|
||||
|
||||
|
||||
return resultPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.springblade.modules.common.service.impl;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.modules.common.config.TianDiTuConfiguration;
|
||||
import org.springblade.modules.common.pojo.dto.LocationDTO;
|
||||
import org.springblade.modules.common.response.TianDiTuGeoResponse;
|
||||
import org.springblade.modules.common.service.TianDiTuMapService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class TianDiTuMapServiceImpl implements TianDiTuMapService {
|
||||
|
||||
|
||||
private final TianDiTuConfiguration configuration;
|
||||
|
||||
private static String ADDRESS_TEMPLATE = """
|
||||
{"keyWord":"%s"}
|
||||
""";
|
||||
|
||||
@Override
|
||||
public LocationDTO defaultLocation(String address) {
|
||||
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("ds", ADDRESS_TEMPLATE.formatted(address));
|
||||
paramMap.put("tk", configuration.getKey());
|
||||
|
||||
String result = HttpUtil.get(configuration.getBaseUrl() + "/geocoder", paramMap);
|
||||
TianDiTuGeoResponse response = JSONObject.parseObject(result, TianDiTuGeoResponse.class);
|
||||
if (response.getStatus().equals("0")) {
|
||||
TianDiTuGeoResponse.LocationInfo locationInfo = response.getLocation();
|
||||
return new LocationDTO().setLongitude(locationInfo.getLonDouble()).setLatitude(locationInfo.getLatDouble());
|
||||
}
|
||||
|
||||
throw new ServiceException(String.valueOf(response));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.modules.common.wrapper;
|
||||
|
||||
import org.springblade.core.mp.support.BaseEntityWrapper;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.modules.common.pojo.entity.CommonOrderConfirmLogEntity;
|
||||
import org.springblade.modules.common.pojo.vo.CommonOrderConfirmLogVO;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 订单确认收货记录 包装类,返回视图层所需的字段
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-03-25
|
||||
*/
|
||||
public class CommonOrderConfirmLogWrapper extends BaseEntityWrapper<CommonOrderConfirmLogEntity, CommonOrderConfirmLogVO> {
|
||||
|
||||
public static CommonOrderConfirmLogWrapper build() {
|
||||
return new CommonOrderConfirmLogWrapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonOrderConfirmLogVO entityVO(CommonOrderConfirmLogEntity commonOrderConfirmLog) {
|
||||
CommonOrderConfirmLogVO commonOrderConfirmLogVO = Objects.requireNonNull(BeanUtil.copyProperties(commonOrderConfirmLog, CommonOrderConfirmLogVO.class));
|
||||
|
||||
//User createUser = UserCache.getUser(commonOrderConfirmLog.getCreateUser());
|
||||
//User updateUser = UserCache.getUser(commonOrderConfirmLog.getUpdateUser());
|
||||
//commonOrderConfirmLogVO.setCreateUserName(createUser.getName());
|
||||
//commonOrderConfirmLogVO.setUpdateUserName(updateUser.getName());
|
||||
|
||||
return commonOrderConfirmLogVO;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.modules.common.wrapper;
|
||||
|
||||
import org.springblade.core.mp.support.BaseEntityWrapper;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.modules.common.pojo.entity.CommonPayOrderEntity;
|
||||
import org.springblade.modules.common.pojo.vo.CommonPayOrderVO;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 系统内部订单关联支付记录 包装类,返回视图层所需的字段
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2026-03-24
|
||||
*/
|
||||
public class CommonPayOrderWrapper extends BaseEntityWrapper<CommonPayOrderEntity, CommonPayOrderVO> {
|
||||
|
||||
public static CommonPayOrderWrapper build() {
|
||||
return new CommonPayOrderWrapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonPayOrderVO entityVO(CommonPayOrderEntity commonPayOrder) {
|
||||
CommonPayOrderVO commonPayOrderVO = Objects.requireNonNull(BeanUtil.copyProperties(commonPayOrder, CommonPayOrderVO.class));
|
||||
|
||||
//User createUser = UserCache.getUser(commonPayOrder.getCreateUser());
|
||||
//User updateUser = UserCache.getUser(commonPayOrder.getUpdateUser());
|
||||
//commonPayOrderVO.setCreateUserName(createUser.getName());
|
||||
//commonPayOrderVO.setUpdateUserName(updateUser.getName());
|
||||
|
||||
return commonPayOrderVO;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -30,6 +30,8 @@ import org.springblade.modules.mall.pojo.vo.MallCategoryVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品分类 服务类
|
||||
*
|
||||
@@ -46,4 +48,5 @@ public interface IMallCategoryService extends BaseService<MallCategoryEntity> {
|
||||
*/
|
||||
IPage<MallCategoryVO> selectMallCategoryPage(IPage<MallCategoryVO> page, MallCategoryVO mallCategory);
|
||||
|
||||
List<MallCategoryEntity> categoryList();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public interface IMallProductService extends BaseService<MallProductEntity> {
|
||||
|
||||
List<MallProductApiVO> apiVoList(Long categoryId);
|
||||
|
||||
List<MallProductApiVO> apiVoListToCategory(Long categoryId);
|
||||
List<MallProductApiVO> apiVoEcosListToCategory();
|
||||
|
||||
|
||||
MallProductDetailApiVO apiDetailVO(@NotNull(message = "无效商品") Long id);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
package org.springblade.modules.mall.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springblade.modules.mall.pojo.entity.MallCategoryEntity;
|
||||
import org.springblade.modules.mall.pojo.vo.MallCategoryVO;
|
||||
import org.springblade.modules.mall.mapper.MallCategoryMapper;
|
||||
@@ -9,6 +10,8 @@ import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品分类 服务实现类
|
||||
*
|
||||
@@ -23,6 +26,14 @@ public class MallCategoryServiceImpl extends BaseServiceImpl<MallCategoryMapper,
|
||||
return page.setRecords(baseMapper.selectMallCategoryPage(page, mallCategory));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MallCategoryEntity> categoryList() {
|
||||
return list(
|
||||
Wrappers.lambdaQuery(MallCategoryEntity.class)
|
||||
.notIn(MallCategoryEntity::getId, List.of(2033413707249164290L ,2033413760969809921L))
|
||||
);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public List<MallCategoryEntity> selectParent() {
|
||||
//
|
||||
|
||||
@@ -67,19 +67,19 @@ public class MallProductServiceImpl extends BaseServiceImpl<MallProductMapper, M
|
||||
@Override
|
||||
public List<MallProductApiVO> apiVoList(Long categoryId) {
|
||||
LambdaQueryWrapper<MallProductEntity> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.eq( MallProductEntity::getCategoryId, 2033413707249164290L);
|
||||
queryWrapper.eq(categoryId != null, MallProductEntity::getCategoryId, categoryId);
|
||||
queryWrapper.eq(MallProductEntity::getStatus, 1); // 上架中
|
||||
queryWrapper.eq(MallProductEntity::getIsDeleted, 0);
|
||||
queryWrapper.notIn(MallProductEntity::getCategoryId, List.of(2033413707249164290L ,2033413760969809921L));
|
||||
queryWrapper.orderByAsc(MallProductEntity::getRetailPrice);
|
||||
List<MallProductEntity> list = list(queryWrapper);
|
||||
return AppMallConvert.INSTANCE.convertMallProductApiListVO(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MallProductApiVO> apiVoListToCategory(Long categoryId) {
|
||||
public List<MallProductApiVO> apiVoEcosListToCategory() {
|
||||
LambdaQueryWrapper<MallProductEntity> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.eq(categoryId != null, MallProductEntity::getCategoryId, categoryId);
|
||||
queryWrapper.eq( MallProductEntity::getCategoryId, 2033413760969809921L);
|
||||
queryWrapper.eq(MallProductEntity::getStatus, 1); // 上架中
|
||||
queryWrapper.eq(MallProductEntity::getIsDeleted, 0);
|
||||
queryWrapper.orderByAsc(MallProductEntity::getRetailPrice);
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
import java.io.Serial;
|
||||
|
||||
@@ -19,6 +20,7 @@ import java.io.Serial;
|
||||
@TableName("market_commission_advertising_log")
|
||||
@Schema(description = "MarketCommissionAdvertisingLog对象")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class MarketCommissionAdvertisingLogEntity extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
import java.io.Serial;
|
||||
|
||||
@@ -19,6 +20,7 @@ import java.io.Serial;
|
||||
@TableName("market_commission_agency_log")
|
||||
@Schema(description = "MarketCommissionAgencyLog对象")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class MarketCommissionAgencyLogEntity extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
import java.io.Serial;
|
||||
|
||||
@@ -19,6 +20,7 @@ import java.io.Serial;
|
||||
@TableName("market_commission_co_creator_log")
|
||||
@Schema(description = "MarketCommissionCoCreatorLog对象")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class MarketCommissionCoCreatorLogEntity extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
import java.io.Serial;
|
||||
|
||||
@@ -19,6 +20,7 @@ import java.io.Serial;
|
||||
@TableName("market_commission_goods_cost_log")
|
||||
@Schema(description = "MarketCommissionGoodsCostLog对象")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class MarketCommissionGoodsCostLogEntity extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
import java.io.Serial;
|
||||
|
||||
@@ -19,6 +20,7 @@ import java.io.Serial;
|
||||
@TableName("market_commission_operation_log")
|
||||
@Schema(description = "MarketCommissionOperationLog对象")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class MarketCommissionOperationLogEntity extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
import java.io.Serial;
|
||||
|
||||
@@ -19,6 +20,7 @@ import java.io.Serial;
|
||||
@TableName("market_commission_service_provider_log")
|
||||
@Schema(description = "MarketCommissionServiceProviderLog对象")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class MarketCommissionServiceProviderLogEntity extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
@@ -70,9 +72,9 @@ public class MarketCommissionServiceProviderLogEntity extends BaseEntity {
|
||||
@Schema(description = "0-未完成 1-已完成")
|
||||
private Integer isComplete;
|
||||
/**
|
||||
* 金额是否发放到用户 0-否 1-是
|
||||
* 金额是否到账 0-否 1-是
|
||||
*/
|
||||
@Schema(description = "金额是否发放到用户 0-否 1-是")
|
||||
@Schema(description = "金额是否到账 0-否 1-是")
|
||||
private Integer isSalaryPaid;
|
||||
/**
|
||||
* 统计时间
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.springblade.plugin.pay.api;
|
||||
|
||||
import org.springblade.plugin.pay.dto.APPPayDto;
|
||||
import org.springblade.plugin.pay.dto.APPQueryDto;
|
||||
import org.springblade.plugin.pay.response.APPPayResult;
|
||||
|
||||
public interface PaymentFacade {
|
||||
|
||||
APPPayResult appPay(APPPayDto dto) throws Exception;
|
||||
|
||||
Boolean query(APPQueryDto dto);
|
||||
|
||||
Boolean closeOrder(APPQueryDto dto);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package org.springblade.plugin.pay.api.alipay;
|
||||
|
||||
import com.alipay.api.response.AlipayTradeCloseResponse;
|
||||
import com.alipay.api.response.AlipayTradeQueryResponse;
|
||||
import com.alipay.api.response.AlipayTradeRefundResponse;
|
||||
import org.springblade.plugin.pay.entity.AliPayAccountConfig;
|
||||
import org.springblade.plugin.pay.entity.Order;
|
||||
import org.springblade.plugin.pay.entity.Refund;
|
||||
import org.springblade.plugin.pay.entityBiz.AliPayBiz;
|
||||
|
||||
/**
|
||||
* 支付宝API接口
|
||||
*
|
||||
* @author YunGouOS技术部-029
|
||||
* @time 2022/4/28 14:56
|
||||
*/
|
||||
public interface IAliPayApiService {
|
||||
|
||||
|
||||
/**
|
||||
* 付款码支付(当面付产品)返回支付结果
|
||||
*
|
||||
* @param order
|
||||
* @param aliPayAccountConfig
|
||||
* @param authCode
|
||||
* @param attach
|
||||
* @return
|
||||
*/
|
||||
public AliPayBiz codePay(Order order, AliPayAccountConfig aliPayAccountConfig, String authCode, String attach);
|
||||
|
||||
/**
|
||||
* 支付宝扫码支付(当面付产品)返回二维码地址
|
||||
*
|
||||
* @param order
|
||||
* @param aliPayAccountConfig
|
||||
* @param attach
|
||||
* @return
|
||||
*/
|
||||
public String nativePay(Order order, AliPayAccountConfig aliPayAccountConfig, String attach);
|
||||
|
||||
|
||||
/**
|
||||
* 支付宝js支付,适合支付宝小程序使用 返回支付宝付款对象,前端按照支付宝JSAPI进行调用
|
||||
*
|
||||
* @param order
|
||||
* @param aliPayAccountConfig
|
||||
* @param attach
|
||||
* @return
|
||||
*/
|
||||
public AliPayBiz jsPay(Order order, AliPayAccountConfig aliPayAccountConfig, String attach);
|
||||
|
||||
|
||||
/**
|
||||
* 电脑网站支付 返回form表单字符串,输出跳转
|
||||
*
|
||||
* @param order
|
||||
* @param aliPayAccountConfig
|
||||
* @param attach
|
||||
*/
|
||||
public String webPay(Order order, AliPayAccountConfig aliPayAccountConfig, String attach, String returnUrl);
|
||||
|
||||
|
||||
/**
|
||||
* 手机网站支付
|
||||
*
|
||||
* @param order
|
||||
* @param aliPayAccountConfig
|
||||
* @param attach
|
||||
* @param returnUrl
|
||||
* @return
|
||||
*/
|
||||
public String mobilePay(Order order, AliPayAccountConfig aliPayAccountConfig, String attach, String returnUrl);
|
||||
|
||||
|
||||
/**
|
||||
* APP支付
|
||||
*
|
||||
* @param order
|
||||
* @param aliPayAccountConfig
|
||||
* @param attach
|
||||
*/
|
||||
public String appPay(Order order, AliPayAccountConfig aliPayAccountConfig, String attach);
|
||||
|
||||
|
||||
/**
|
||||
* 发起退款
|
||||
*
|
||||
* @param refund
|
||||
* @param aliPayAccountConfig
|
||||
* @return
|
||||
*/
|
||||
public AlipayTradeRefundResponse refund(Refund refund, AliPayAccountConfig aliPayAccountConfig);
|
||||
|
||||
|
||||
public AlipayTradeQueryResponse query(String orderNo, AliPayAccountConfig aliPayAccountConfig) throws Exception;
|
||||
|
||||
public AlipayTradeCloseResponse closeOrder(String orderNo, AliPayAccountConfig aliPayAccountConfig) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
package org.springblade.plugin.pay.api.alipay.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayResponse;
|
||||
import com.alipay.api.domain.*;
|
||||
import com.alipay.api.request.*;
|
||||
import com.alipay.api.response.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.plugin.pay.api.alipay.IAliPayApiService;
|
||||
import org.springblade.plugin.pay.constant.PayConstant;
|
||||
import org.springblade.plugin.pay.entity.AliPayAccountConfig;
|
||||
import org.springblade.plugin.pay.entity.Order;
|
||||
import org.springblade.plugin.pay.entity.Refund;
|
||||
import org.springblade.plugin.pay.entityBiz.AliPayBiz;
|
||||
import org.springblade.plugin.pay.service.IOrderService;
|
||||
import org.springblade.plugin.pay.util.AliPayHttpUtil;
|
||||
import org.springblade.plugin.pay.util.AliPayParamsUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 支付宝API接口实现类
|
||||
*
|
||||
* @author YunGouOS技术部-029
|
||||
* @time 2022/4/28 14:56
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class AliPayApiServiceImpl implements IAliPayApiService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AliPayApiServiceImpl.class);
|
||||
private final AliPayParamsUtil aliPayParamsUtil;
|
||||
|
||||
private final AliPayHttpUtil aliPayHttpUtil;
|
||||
|
||||
private final IOrderService orderService;
|
||||
|
||||
|
||||
@Override
|
||||
public AliPayBiz codePay(Order order, AliPayAccountConfig aliPayAccountConfig, String authCode, String attach) {
|
||||
AliPayBiz aliPayBiz = null;
|
||||
try {
|
||||
String body = order.getBody();
|
||||
String money = order.getMoney();
|
||||
String orderNo = order.getOrderNo();
|
||||
AlipayTradePayModel alipayTradePayModel = aliPayParamsUtil.getAliPayTradePayParams(aliPayAccountConfig, PayConstant.CODEPAY, body, money, orderNo, authCode);
|
||||
AlipayTradePayRequest request = new AlipayTradePayRequest();
|
||||
request.setBizModel(alipayTradePayModel);
|
||||
AlipayTradePayResponse response = (AlipayTradePayResponse) aliPayHttpUtil.doPost(aliPayAccountConfig, request, aliPayAccountConfig.getAppAuthToken(), true);
|
||||
aliPayBiz = new AliPayBiz();
|
||||
aliPayBiz.setOrderNo(orderNo);
|
||||
aliPayBiz.setPayNo(response.getTradeNo());
|
||||
aliPayBiz.setMoney(response.getReceiptAmount());
|
||||
aliPayBiz.setPayTime(DateUtil.formatDateTime(response.getGmtPayment()));
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
return aliPayBiz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String nativePay(Order order, AliPayAccountConfig aliPayAccountConfig, String attach) {
|
||||
String codeUrl = null;
|
||||
try {
|
||||
String body = order.getBody();
|
||||
String money = order.getMoney();
|
||||
String orderNo = order.getOrderNo();
|
||||
AlipayTradePrecreateModel model = aliPayParamsUtil.getAliPayServicePushOrderParam(aliPayAccountConfig, body, money, orderNo);
|
||||
AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();
|
||||
request.setBizModel(model);
|
||||
AlipayTradePrecreateResponse response = (AlipayTradePrecreateResponse) aliPayHttpUtil.doPost(aliPayAccountConfig, request, aliPayAccountConfig.getAppAuthToken(), true);
|
||||
codeUrl = response.getQrCode();
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
return codeUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AliPayBiz jsPay(Order order, AliPayAccountConfig aliPayAccountConfig, String attach) {
|
||||
AliPayBiz aliPayBiz = null;
|
||||
try {
|
||||
String body = order.getBody();
|
||||
String money = order.getMoney();
|
||||
String orderNo = order.getOrderNo();
|
||||
String buyerId = order.getBuyerId();
|
||||
if (StringUtils.isBlank(buyerId)) {
|
||||
throw new ServiceException("buyerId不能为空");
|
||||
}
|
||||
AlipayTradeCreateModel alipayTradeCreateModel = aliPayParamsUtil.getAliPayServicePushOrderCreateParam(aliPayAccountConfig, buyerId, body, money, orderNo);
|
||||
AlipayTradeCreateRequest request = new AlipayTradeCreateRequest();
|
||||
request.setBizModel(alipayTradeCreateModel);
|
||||
AlipayTradeCreateResponse response = (AlipayTradeCreateResponse) aliPayHttpUtil.doPost(aliPayAccountConfig, request, aliPayAccountConfig.getAppAuthToken(), true);
|
||||
aliPayBiz = new AliPayBiz();
|
||||
aliPayBiz.setPayNo(response.getTradeNo());
|
||||
aliPayBiz.setOrderNo(orderNo);
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
return aliPayBiz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String webPay(Order order, AliPayAccountConfig aliPayAccountConfig, String attach, String returnUrl) {
|
||||
String form = null;
|
||||
try {
|
||||
String body = order.getBody();
|
||||
String money = order.getMoney();
|
||||
String orderNo = order.getOrderNo();
|
||||
AlipayTradePagePayModel alipayTradeCreateModel = aliPayParamsUtil.getAliPayServiceWebParam(orderNo, money, body);
|
||||
AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
|
||||
request.setBizModel(alipayTradeCreateModel);
|
||||
if (!StringUtils.isBlank(returnUrl)) {
|
||||
request.setReturnUrl(returnUrl);
|
||||
}
|
||||
AlipayResponse response = aliPayHttpUtil.doPostPage(aliPayAccountConfig, request, true);
|
||||
form = response.getBody();
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
return form;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mobilePay(Order order, AliPayAccountConfig aliPayAccountConfig, String attach, String returnUrl) {
|
||||
String wapPayStr = null;
|
||||
try {
|
||||
String body = order.getBody();
|
||||
String money = order.getMoney();
|
||||
String orderNo = order.getOrderNo();
|
||||
AlipayTradeWapPayModel alipayTradeWapPayModel = aliPayParamsUtil.getAliPayServiceH5Param(aliPayAccountConfig, body, money, orderNo, returnUrl);
|
||||
AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
|
||||
request.setBizModel(alipayTradeWapPayModel);
|
||||
if (!StringUtils.isBlank(returnUrl)) {
|
||||
request.setReturnUrl(returnUrl);
|
||||
}
|
||||
AlipayResponse response = aliPayHttpUtil.doPostPage(aliPayAccountConfig, request, true);
|
||||
wapPayStr = response.getBody();
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
return wapPayStr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String appPay(Order order, AliPayAccountConfig aliPayAccountConfig, String attach) {
|
||||
String appStr = null;
|
||||
try {
|
||||
String body = order.getBody();
|
||||
String money = order.getMoney();
|
||||
String orderNo = order.getOrderNo();
|
||||
AlipayTradeAppPayModel alipayTradeAppPayModel = aliPayParamsUtil.getAliPayServiceAppParam(orderNo, money, body);
|
||||
AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
|
||||
request.setBizModel(alipayTradeAppPayModel);
|
||||
AlipayResponse response = aliPayHttpUtil.doPostSdk(aliPayAccountConfig, request, aliPayAccountConfig.getAppAuthToken(), true);
|
||||
appStr = response.getBody();
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
return appStr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlipayTradeRefundResponse refund(Refund refund, AliPayAccountConfig aliPayAccountConfig) {
|
||||
AlipayTradeRefundResponse refundResult = null;
|
||||
try {
|
||||
String refundNo = refund.getRefundNo();
|
||||
String orderNo = refund.getOrderNo();
|
||||
String payNo = refund.getPayNo();
|
||||
String refundMoney = refund.getRefundMoney();
|
||||
String refundDesc = refund.getRefundDesc();
|
||||
AlipayTradeRefundModel alipayTradeRefundModel = aliPayParamsUtil.getAliPayRefundParam(refundNo, orderNo, payNo, refundMoney, refundDesc);
|
||||
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
|
||||
request.setBizModel(alipayTradeRefundModel);
|
||||
refundResult = (AlipayTradeRefundResponse) aliPayHttpUtil.doPost(aliPayAccountConfig, request, aliPayAccountConfig.getAppAuthToken(), true);
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
return refundResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlipayTradeQueryResponse query(String orderNo, AliPayAccountConfig aliPayAccountConfig) throws Exception{
|
||||
|
||||
AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
|
||||
AlipayTradeQueryModel model = new AlipayTradeQueryModel();
|
||||
model.setOutTradeNo(orderNo);
|
||||
model.setOrgPid(aliPayAccountConfig.getAppId());
|
||||
request.setBizModel(model);
|
||||
return (AlipayTradeQueryResponse) aliPayHttpUtil.doPost(aliPayAccountConfig, request, aliPayAccountConfig.getAppAuthToken(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlipayTradeCloseResponse closeOrder(String orderNo, AliPayAccountConfig aliPayAccountConfig) throws Exception {
|
||||
AlipayTradeCloseRequest request = new AlipayTradeCloseRequest();
|
||||
AlipayTradeCloseModel model = new AlipayTradeCloseModel();
|
||||
model.setOutTradeNo(orderNo);
|
||||
request.setBizModel(model);
|
||||
return (AlipayTradeCloseResponse) aliPayHttpUtil.doPost(aliPayAccountConfig, request, aliPayAccountConfig.getAppAuthToken(), true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package org.springblade.plugin.pay.api.impl;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.modules.common.eums.BusinessModule;
|
||||
import org.springblade.modules.common.eums.PaymentType;
|
||||
import org.springblade.plugin.pay.api.PaymentFacade;
|
||||
import org.springblade.plugin.pay.config.AliPayConfiguration;
|
||||
import org.springblade.plugin.pay.config.WxPayConfiguration;
|
||||
import org.springblade.plugin.pay.dto.APPPayDto;
|
||||
import org.springblade.plugin.pay.dto.APPQueryDto;
|
||||
import org.springblade.plugin.pay.response.APPPayResult;
|
||||
import org.springblade.plugin.pay.service.IAliPayService;
|
||||
import org.springblade.plugin.pay.service.IWxPayService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class PaymentFacadeImpl implements PaymentFacade {
|
||||
|
||||
private final IAliPayService aliPayService;
|
||||
private final AliPayConfiguration aliPayConfig;
|
||||
|
||||
private final IWxPayService wxPayService;
|
||||
private final WxPayConfiguration wxPayConfig;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public APPPayResult appPay(APPPayDto dto) {
|
||||
|
||||
PaymentType paymentType = dto.getPaymentType();
|
||||
BusinessModule businessModule = dto.getBusinessModule();
|
||||
|
||||
APPPayResult result = new APPPayResult();
|
||||
String content = "success";
|
||||
|
||||
switch (paymentType) {
|
||||
case ALI:
|
||||
content = aliPayService.appPay(
|
||||
aliPayConfig.getAppId(),
|
||||
aliPayConfig.getMachId(),
|
||||
dto.getBody(),
|
||||
String.valueOf(dto.getAmount()),
|
||||
aliPayConfig.getNotifyUrl(),
|
||||
dto.getRemark(),
|
||||
paymentType.getAbbr() + businessModule.getAbbr(),
|
||||
dto.getOrderId()
|
||||
);
|
||||
break;
|
||||
case WECHAT:
|
||||
Map<String, String> stringStringMap = wxPayService.appPay(
|
||||
wxPayConfig.getAppId(),
|
||||
wxPayConfig.getMachId(),
|
||||
dto.getBody(),
|
||||
String.valueOf(dto.getAmount()),
|
||||
wxPayConfig.getNotifyUrl(),
|
||||
dto.getRemark(),
|
||||
paymentType.getAbbr() + businessModule.getAbbr(),
|
||||
dto.getOrderId()
|
||||
);
|
||||
log.info("微信APP支付结果:{}", stringStringMap);
|
||||
//todo 微信app支付结果处理
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new RuntimeException("支付类型错误");
|
||||
}
|
||||
|
||||
return result
|
||||
.setSuccess(Boolean.TRUE)
|
||||
.setContent(content)
|
||||
.setPaymentTypeEnum(paymentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean query(APPQueryDto dto){
|
||||
PaymentType paymentType = dto.getPaymentType();
|
||||
Boolean result = false;
|
||||
switch (paymentType) {
|
||||
case ALI:
|
||||
result = aliPayService.query(dto.getOrderNo(),aliPayConfig.getAppId(), aliPayConfig.getMachId());
|
||||
break;
|
||||
case WECHAT:
|
||||
|
||||
//todo 微信app查询支付结果
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new RuntimeException("支付类型错误");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean closeOrder(APPQueryDto dto) {
|
||||
PaymentType paymentType = dto.getPaymentType();
|
||||
Boolean result = false;
|
||||
switch (paymentType) {
|
||||
case ALI:
|
||||
result = aliPayService.closeOrder(dto.getOrderNo(),aliPayConfig.getAppId(), aliPayConfig.getMachId());
|
||||
break;
|
||||
case WECHAT:
|
||||
|
||||
//todo 微信app查询支付结果
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new RuntimeException("支付类型错误");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package org.springblade.plugin.pay.api.wxpay;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springblade.plugin.pay.entity.Order;
|
||||
import org.springblade.plugin.pay.entity.Refund;
|
||||
import org.springblade.plugin.pay.entity.WxPayAccountConfig;
|
||||
import org.springblade.plugin.pay.entityBiz.WxPayRefundBiz;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 微信支付API接口
|
||||
*
|
||||
* @author YunGouOS技术部-029
|
||||
* @time 2021/12/28 22:47
|
||||
*/
|
||||
public interface IWxPayApiService {
|
||||
|
||||
/**
|
||||
* 获取证书公钥
|
||||
*
|
||||
* @author YunGouOS
|
||||
* @date 2020年12月2日 下午6:39:26
|
||||
*/
|
||||
public String getPublicKey(String path, String mchId, String v3Key, String certficatesNo);
|
||||
|
||||
|
||||
/**
|
||||
* 微信回调通知解密
|
||||
* @param wxPayAccountConfig
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public JSONObject decryptCallback(WxPayAccountConfig wxPayAccountConfig,JSONObject data);
|
||||
|
||||
|
||||
/**
|
||||
* 微信付款码支付
|
||||
* @param authCode
|
||||
* @param order
|
||||
* @param wxPayAccountConfig
|
||||
* @param attach
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> codePay(String authCode, Order order, WxPayAccountConfig wxPayAccountConfig, String attach);
|
||||
|
||||
|
||||
/**
|
||||
* 微信扫码支付
|
||||
*
|
||||
* @param order
|
||||
* @param wxPayAccountConfig
|
||||
* @return
|
||||
*/
|
||||
public String nativePay(Order order, WxPayAccountConfig wxPayAccountConfig, String attach);
|
||||
|
||||
|
||||
/**
|
||||
* 微信jsapi支付
|
||||
*
|
||||
* @param openId
|
||||
* @param order
|
||||
* @param wxPayAccountConfig
|
||||
* @param attach
|
||||
* @return
|
||||
*/
|
||||
public String jsPay(String openId, Order order, WxPayAccountConfig wxPayAccountConfig, String attach);
|
||||
|
||||
|
||||
/**
|
||||
* 微信H5支付
|
||||
*
|
||||
* @param order
|
||||
* @param wxPayAccountConfig
|
||||
* @param returnUrl
|
||||
* @param attach
|
||||
* @return
|
||||
*/
|
||||
public String h5Pay(Order order, WxPayAccountConfig wxPayAccountConfig, String returnUrl, String attach);
|
||||
|
||||
|
||||
/**
|
||||
* 微信APP支付
|
||||
*
|
||||
* @param appId
|
||||
* @param order
|
||||
* @param wxPayAccountConfig
|
||||
* @param attach
|
||||
* @return
|
||||
*/
|
||||
public String appPay(String appId, Order order, WxPayAccountConfig wxPayAccountConfig, String attach);
|
||||
|
||||
|
||||
/**
|
||||
* 发起退款
|
||||
* @param refund
|
||||
* @param wxPayAccountConfig
|
||||
* @return
|
||||
*/
|
||||
public WxPayRefundBiz refund(Refund refund, WxPayAccountConfig wxPayAccountConfig,String orderMoney);
|
||||
|
||||
|
||||
/**
|
||||
* 查询微信订单详情
|
||||
* @param orderNo
|
||||
* @param payNo
|
||||
* @param wxPayAccountConfig
|
||||
*/
|
||||
public JSONObject getOrderInfo(String orderNo, String payNo, WxPayAccountConfig wxPayAccountConfig);
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
package org.springblade.plugin.pay.api.wxpay.impl;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ijpay.core.enums.RequestMethodEnum;
|
||||
import com.ijpay.core.kit.AesUtil;
|
||||
import com.ijpay.wxpay.WxPayApi;
|
||||
import com.ijpay.wxpay.enums.WxApiType;
|
||||
import com.ijpay.wxpay.enums.WxDomainEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.core.tool.utils.WebUtil;
|
||||
import org.springblade.plugin.pay.api.wxpay.IWxPayApiService;
|
||||
import org.springblade.plugin.pay.common.Common;
|
||||
import org.springblade.plugin.pay.common.WxPayException;
|
||||
import org.springblade.plugin.pay.entity.Order;
|
||||
import org.springblade.plugin.pay.entity.Refund;
|
||||
import org.springblade.plugin.pay.entity.WxPayAccountConfig;
|
||||
import org.springblade.plugin.pay.entityBiz.WxPayRefundBiz;
|
||||
import org.springblade.plugin.pay.service.IOrderService;
|
||||
import org.springblade.plugin.pay.util.WxPayInitUtil;
|
||||
import org.springblade.plugin.pay.util.WxPayV2ParamsUtil;
|
||||
import org.springblade.plugin.pay.util.WxPayV3ApiHttpUtil;
|
||||
import org.springblade.plugin.pay.util.WxPayV3ParamsUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 微信支付API接口对接
|
||||
*
|
||||
* @author YunGouOS技术部-029
|
||||
* @time 2021/12/28 22:48
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class WxPayApiServiceImpl implements IWxPayApiService {
|
||||
|
||||
private final WxPayV3ParamsUtil wxPayV3ParamsUtil;
|
||||
|
||||
private final WxPayV2ParamsUtil wxPayV2ParamsUtil;
|
||||
|
||||
private final WxPayV3ApiHttpUtil wxPayV3ApiHttpUtil;
|
||||
|
||||
private final IOrderService orderService;
|
||||
|
||||
@Override
|
||||
public String getPublicKey(String path, String mchId, String v3Key, String certficatesNo) {
|
||||
String wxPayPublicKey = null;
|
||||
try {
|
||||
// 获取证书url
|
||||
String url = WxApiType.GET_CERTIFICATES.toString();
|
||||
// 证书公钥
|
||||
Map<String, Object> result = WxPayApi.v3Execution(RequestMethodEnum.GET, WxDomainEnum.CHINA.toString(), url, mchId, certficatesNo, path, "");
|
||||
|
||||
Integer status = (Integer) result.get("status");
|
||||
if (status != null && 404 == status.intValue()) {
|
||||
//无平台证书,可能是新版的 微信支付公钥方式
|
||||
return null;
|
||||
}
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("mchId", mchId);
|
||||
params.put("certficatesNo", certficatesNo);
|
||||
JSONObject body = Common.doWxPayApiV3Result(result);
|
||||
if (body == null) {
|
||||
throw new ServiceException("初始化失败。请先生成微信V3证书");
|
||||
}
|
||||
JSONArray certList = body.getJSONArray("data");
|
||||
if (certList == null || certList.size() <= 0) {
|
||||
throw new ServiceException("初始化失败。请先生成微信V3证书");
|
||||
}
|
||||
JSONObject certJson = certList.getJSONObject(0);
|
||||
if (certJson == null) {
|
||||
throw new ServiceException("初始化失败。请先生成微信V3证书");
|
||||
}
|
||||
JSONObject certInfoJson = certJson.getJSONObject("encrypt_certificate");
|
||||
if (certInfoJson == null) {
|
||||
throw new ServiceException("初始化失败。请先生成微信V3证书");
|
||||
}
|
||||
String associatedData = certInfoJson.getString("associated_data");
|
||||
String cipherText = certInfoJson.getString("ciphertext");
|
||||
String nonce = certInfoJson.getString("nonce");
|
||||
wxPayPublicKey = WxPayInitUtil.getWxPayPublicKey(associatedData, nonce, cipherText, v3Key);
|
||||
} catch (WxPayException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
return wxPayPublicKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject decryptCallback(WxPayAccountConfig wxPayAccountConfig, JSONObject data) {
|
||||
try {
|
||||
if (data == null) {
|
||||
throw new ServiceException("通知数据为空");
|
||||
}
|
||||
JSONObject resourceJson = data.getJSONObject("resource");
|
||||
if (resourceJson == null) {
|
||||
throw new ServiceException("通知数据转json对象失败");
|
||||
}
|
||||
AesUtil aesUtil = new AesUtil(wxPayAccountConfig.getV3Key().getBytes(StandardCharsets.UTF_8));
|
||||
String associatedData = resourceJson.getString("associated_data");
|
||||
String nonce = resourceJson.getString("nonce");
|
||||
String cipherText = resourceJson.getString("ciphertext");
|
||||
if (StringUtils.isBlank(associatedData) || StringUtils.isBlank(nonce) || StringUtils.isBlank(cipherText)) {
|
||||
throw new ServiceException("通知参数解密失败");
|
||||
}
|
||||
String resource = aesUtil.decryptToString(associatedData.getBytes(StandardCharsets.UTF_8), nonce.getBytes(StandardCharsets.UTF_8), cipherText);
|
||||
if (StringUtil.isBlank(resource)) {
|
||||
throw new ServiceException("通知参数解密失败");
|
||||
}
|
||||
JSONObject notifyJson = JSONObject.parseObject(resource);
|
||||
return notifyJson;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> codePay(String authCode, Order order, WxPayAccountConfig wxPayAccountConfig, String attach) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
Map<String, String> codePayParam = wxPayV2ParamsUtil.getCodePayParam(authCode, order, wxPayAccountConfig, attach);
|
||||
String xmlResult = WxPayApi.doPost(WxApiType.MICRO_PAY.toString(), codePayParam);
|
||||
Map<String, String> resultMap = Common.doWxPayApiResult(xmlResult);
|
||||
map.put("status", "NONE");
|
||||
map.put("orderNo", order.getOrderNo());
|
||||
if ("USERPAYING".equals(resultMap.get("err_code"))) {
|
||||
map.put("status", "PAYING");
|
||||
} else {
|
||||
map.put("status", "SUCCESS");
|
||||
String payNo = resultMap.get("transaction_id");
|
||||
String payTime = resultMap.get("time_end");
|
||||
if (!StringUtils.isBlank(payTime)) {
|
||||
payTime = DateUtil.formatDateTime(DateUtil.parse(payTime, DatePattern.NORM_DATETIME_FORMAT));
|
||||
}
|
||||
String openId = resultMap.get("openid");
|
||||
orderService.paySuccess(order.getOrderNo(), order.getMchId(), payNo, payTime, openId);
|
||||
}
|
||||
} catch (WxPayException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String nativePay(Order order, WxPayAccountConfig wxPayAccountConfig, String attach) {
|
||||
String codeUrl = null;
|
||||
try {
|
||||
Map<String, Object> nativePayParams = wxPayV3ParamsUtil.getNativePayParams(order.getOrderNo(), order.getAppId(), order.getMchId(), order.getBody(), order.getMoney(), attach, order.getNotifyUrl());
|
||||
String url = WxApiType.NATIVE_PAY.toString();
|
||||
JSONObject body = wxPayV3ApiHttpUtil.doPost(url, nativePayParams, wxPayAccountConfig);
|
||||
codeUrl = body.getString("code_url");
|
||||
} catch (WxPayException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
return codeUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String jsPay(String openId, Order order, WxPayAccountConfig wxPayAccountConfig, String attach) {
|
||||
String prepayId = null;
|
||||
try {
|
||||
Map<String, Object> jsApiParams = wxPayV3ParamsUtil.getJsApiParams(order.getOrderNo(), order.getAppId(), order.getMchId(), openId, order.getBody(), order.getMoney(), attach, order.getNotifyUrl());
|
||||
String url = WxApiType.JS_API_PAY.toString();
|
||||
JSONObject body = wxPayV3ApiHttpUtil.doPost(url,jsApiParams, wxPayAccountConfig);
|
||||
prepayId = body.getString("prepay_id");
|
||||
} catch (WxPayException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
return prepayId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String h5Pay(Order order, WxPayAccountConfig wxPayAccountConfig, String returnUrl, String attach) {
|
||||
String h5Url = null;
|
||||
try {
|
||||
Map<String, Object> h5PayParams = wxPayV3ParamsUtil.getH5PayParams(order.getOrderNo(), order.getAppId(), order.getMchId(), order.getBody(), order.getMoney(), attach, order.getNotifyUrl(), returnUrl, WebUtil.getIP());
|
||||
String url = WxApiType.H5_PAY.toString();
|
||||
JSONObject body = wxPayV3ApiHttpUtil.doPost(url, h5PayParams, wxPayAccountConfig);
|
||||
h5Url = body.getString("h5_url");
|
||||
} catch (WxPayException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
return h5Url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String appPay(String appId, Order order, WxPayAccountConfig wxPayAccountConfig, String attach) {
|
||||
String prepayId = null;
|
||||
try {
|
||||
Map<String, Object> appPayParams = wxPayV3ParamsUtil.getAppPayParams(order.getOrderNo(), order.getAppId(), order.getMchId(), order.getBody(), order.getMoney(), attach, order.getNotifyUrl());
|
||||
String url = WxApiType.APP_PAY.toString();
|
||||
JSONObject body = wxPayV3ApiHttpUtil.doPost(url, appPayParams, wxPayAccountConfig);
|
||||
prepayId = body.getString("prepay_id");
|
||||
} catch (WxPayException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
return prepayId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxPayRefundBiz refund(Refund refund, WxPayAccountConfig wxPayAccountConfig, String orderMoney) {
|
||||
WxPayRefundBiz wxPayRefundBiz = null;
|
||||
try {
|
||||
Map<String, Object> refundParams = wxPayV3ParamsUtil.getRefundParams(refund.getOrderNo(), refund.getPayNo(), refund.getRefundNo(), orderMoney, refund.getRefundMoney(), refund.getRefundDesc(), refund.getNotifyUrl());
|
||||
String url = WxApiType.DOMESTIC_REFUNDS.toString();
|
||||
JSONObject body = wxPayV3ApiHttpUtil.doPost(url, refundParams, wxPayAccountConfig);
|
||||
wxPayRefundBiz = JSON.toJavaObject(body, WxPayRefundBiz.class);
|
||||
} catch (WxPayException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
return wxPayRefundBiz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getOrderInfo(String orderNo, String payNo, WxPayAccountConfig wxPayAccountConfig) {
|
||||
try {
|
||||
Map<String, String> params = wxPayV3ParamsUtil.getOrderInfoParams(wxPayAccountConfig.getMchId());
|
||||
String url = String.format(WxApiType.ORDER_QUERY_BY_NO.toString(), orderNo);
|
||||
if (!StringUtil.isBlank(payNo)) {
|
||||
url = String.format(WxApiType.ORDER_QUERY_BY_ID.toString(), payNo);
|
||||
}
|
||||
JSONObject body = wxPayV3ApiHttpUtil.doGet(url, params, wxPayAccountConfig);
|
||||
return body;
|
||||
} catch (WxPayException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.springblade.plugin.pay.api.yungouos;
|
||||
|
||||
import org.springblade.plugin.pay.entity.MergePayConfig;
|
||||
import org.springblade.plugin.pay.entity.Order;
|
||||
|
||||
/**
|
||||
* YunGouOS聚合支付接口
|
||||
*
|
||||
* @author YunGouOS技术部-029
|
||||
* @time 2022/6/28 15:05
|
||||
*/
|
||||
public interface IMergePayApiService {
|
||||
|
||||
/**
|
||||
* 微信扫码支付
|
||||
*
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
public String nativePay(Order order, MergePayConfig mergePayConfig, String type, String attach, String returnUrl, String configNo, String auto, String autoNode);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.springblade.plugin.pay.api.yungouos.impl;
|
||||
|
||||
import com.yungouos.pay.common.PayException;
|
||||
import com.yungouos.pay.merge.MergePay;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.plugin.pay.api.yungouos.IMergePayApiService;
|
||||
import org.springblade.plugin.pay.entity.MergePayConfig;
|
||||
import org.springblade.plugin.pay.entity.Order;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author YunGouOS技术部-029
|
||||
* @time 2022/6/28 15:05
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class MergePayApiServiceImpl implements IMergePayApiService {
|
||||
@Override
|
||||
public String nativePay(Order order, MergePayConfig mergePayConfig, String type, String attach, String returnUrl, String configNo, String auto, String autoNode) {
|
||||
String url = null;
|
||||
try {
|
||||
url = MergePay.nativePay(order.getOrderNo(), order.getMoney(), order.getMchId(), order.getBody(), type, attach, order.getNotifyUrl(), returnUrl, configNo, auto, autoNode,null,null, mergePayConfig.getPayKey());
|
||||
} catch (PayException e) {
|
||||
e.printStackTrace();
|
||||
throw new PayException(e.getMessage());
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package org.springblade.plugin.pay.common;
|
||||
|
||||
/**
|
||||
* 自定义支付宝处理异常
|
||||
*
|
||||
* @description
|
||||
*
|
||||
* @author YunGouOS技术部-029
|
||||
*
|
||||
* @time 2018年12月14日 下午8:16:15
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class AliPayException extends RuntimeException {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 7973713189507995958L;
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
*/
|
||||
private String errorCode;
|
||||
|
||||
/**
|
||||
* 消息是否为属性文件中的Key
|
||||
*/
|
||||
private boolean propertiesKey = true;
|
||||
|
||||
/**
|
||||
* 构造一个基本异常.
|
||||
*
|
||||
* @param message
|
||||
* 信息描述
|
||||
*/
|
||||
public AliPayException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造一个基本异常.
|
||||
*
|
||||
* @param errorCode
|
||||
* 错误编码
|
||||
* @param message
|
||||
* 信息描述
|
||||
*/
|
||||
public AliPayException(String errorCode, String message) {
|
||||
this(errorCode, message, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造一个基本异常.
|
||||
*
|
||||
* @param errorCode
|
||||
* 错误编码
|
||||
* @param message
|
||||
* 信息描述
|
||||
*/
|
||||
public AliPayException(String errorCode, String message, Throwable cause) {
|
||||
this(errorCode, message, cause, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造一个基本异常.
|
||||
*
|
||||
* @param errorCode
|
||||
* 错误编码
|
||||
* @param message
|
||||
* 信息描述
|
||||
* @param propertiesKey
|
||||
* 消息是否为属性文件中的Key
|
||||
*/
|
||||
public AliPayException(String errorCode, String message, boolean propertiesKey) {
|
||||
super(message);
|
||||
this.setErrorCode(errorCode);
|
||||
this.setPropertiesKey(propertiesKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造一个基本异常.
|
||||
*
|
||||
* @param errorCode
|
||||
* 错误编码
|
||||
* @param message
|
||||
* 信息描述
|
||||
*/
|
||||
public AliPayException(String errorCode, String message, Throwable cause, boolean propertiesKey) {
|
||||
super(message, cause);
|
||||
this.setErrorCode(errorCode);
|
||||
this.setPropertiesKey(propertiesKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造一个基本异常.
|
||||
*
|
||||
* @param message
|
||||
* 信息描述
|
||||
* @param cause
|
||||
* 根异常类(可以存入任何异常)
|
||||
*/
|
||||
public AliPayException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setErrorCode(String errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public boolean isPropertiesKey() {
|
||||
return propertiesKey;
|
||||
}
|
||||
|
||||
public void setPropertiesKey(boolean propertiesKey) {
|
||||
this.propertiesKey = propertiesKey;
|
||||
}
|
||||
|
||||
}
|
||||
101
src/main/java/org/springblade/plugin/pay/common/Common.java
Normal file
101
src/main/java/org/springblade/plugin/pay/common/Common.java
Normal file
@@ -0,0 +1,101 @@
|
||||
package org.springblade.plugin.pay.common;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ijpay.core.kit.PayKit;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author YunGouOS技术部-029
|
||||
* @time 2021/12/31 11:28
|
||||
*/
|
||||
public class Common {
|
||||
|
||||
/**
|
||||
* 解析微信支付V3api返回结果
|
||||
*
|
||||
* @author YunGouOS
|
||||
* @date 2020年3月9日 上午10:07:57
|
||||
*/
|
||||
public static JSONObject doWxPayApiV3Result(Map<String, Object> resultMap) {
|
||||
if (resultMap == null || resultMap.size() <= 0) {
|
||||
throw new WxPayException("请求微信API无响应,请稍候再试!");
|
||||
}
|
||||
Integer status = MapUtil.getInt(resultMap, "status");
|
||||
String body = MapUtil.getStr(resultMap, "body");
|
||||
JSONObject data = null;
|
||||
if (!StringUtils.isBlank(body)) {
|
||||
data = JSONObject.parseObject(body);
|
||||
}
|
||||
List<Integer> list = getWxV3ApiSuccessStatusList();
|
||||
if (!list.contains(status)) {
|
||||
if (data == null) {
|
||||
throw new WxPayException("请求微信API无响应数据,请稍后再试!");
|
||||
}
|
||||
String code = data.getString("code");
|
||||
if (!StringUtils.isBlank(code)) {
|
||||
throw new WxPayException(data.getString("message"));
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public static List<Integer> getWxV3ApiSuccessStatusList() {
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
list.add(200);// 处理成功有消息体
|
||||
list.add(204);// 处理成功 无消息体
|
||||
list.add(202);// 处理中
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析支付宝API返回结果
|
||||
*
|
||||
* @title
|
||||
* @author YunGouOS
|
||||
* @date 2019年12月29日 下午1:53:47
|
||||
*/
|
||||
public static JSONObject doAliPayApiResult(String jsonResult) {
|
||||
if (StringUtils.isBlank(jsonResult)) {
|
||||
throw new AliPayException("请求支付宝API无响应,请稍候再试!");
|
||||
}
|
||||
JSONObject resultJsonObj = (JSONObject) JSONObject.parse(jsonResult);
|
||||
if (resultJsonObj == null) {
|
||||
throw new AliPayException("支付宝API返回结果转换失败,请稍候再试!");
|
||||
}
|
||||
|
||||
return resultJsonObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析微信支付API返回结果
|
||||
*
|
||||
* @author YunGouOS
|
||||
* @date 2019年3月4日 下午4:03:55
|
||||
*/
|
||||
public static Map<String, String> doWxPayApiResult(String xmlResult) {
|
||||
if (StringUtils.isBlank(xmlResult)) {
|
||||
throw new WxPayException("请求微信API无响应,请稍候再试!");
|
||||
}
|
||||
Map<String, String> resultMap = PayKit.xmlToMap(xmlResult);
|
||||
String return_code = resultMap.get("return_code");
|
||||
String return_msg = resultMap.get("return_msg");
|
||||
if (StringUtil.isBlank(return_code) || !"SUCCESS".equals(return_code)) {
|
||||
throw new WxPayException(return_msg);
|
||||
}
|
||||
String result_code = resultMap.get("result_code");
|
||||
if (StringUtil.isBlank(result_code) || !"SUCCESS".equals(result_code)) {
|
||||
// 付款码支付,等待用户输入密码
|
||||
if ("USERPAYING".equals(resultMap.get("err_code"))) {
|
||||
return resultMap;
|
||||
}
|
||||
throw new WxPayException(resultMap.get("err_code_des"));
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package org.springblade.plugin.pay.common;
|
||||
|
||||
/**
|
||||
* 自定义微信支付处理异常
|
||||
*
|
||||
* @description
|
||||
*
|
||||
* @author YunGouOS技术部-029
|
||||
*
|
||||
* @time 2018年12月14日 下午8:16:15
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class WxPayException extends RuntimeException {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 7973713189507995958L;
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
*/
|
||||
private String errorCode;
|
||||
|
||||
/**
|
||||
* 消息是否为属性文件中的Key
|
||||
*/
|
||||
private boolean propertiesKey = true;
|
||||
|
||||
/**
|
||||
* 构造一个基本异常.
|
||||
*
|
||||
* @param message
|
||||
* 信息描述
|
||||
*/
|
||||
public WxPayException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造一个基本异常.
|
||||
*
|
||||
* @param errorCode
|
||||
* 错误编码
|
||||
* @param message
|
||||
* 信息描述
|
||||
*/
|
||||
public WxPayException(String errorCode, String message) {
|
||||
this(errorCode, message, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造一个基本异常.
|
||||
*
|
||||
* @param errorCode
|
||||
* 错误编码
|
||||
* @param message
|
||||
* 信息描述
|
||||
*/
|
||||
public WxPayException(String errorCode, String message, Throwable cause) {
|
||||
this(errorCode, message, cause, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造一个基本异常.
|
||||
*
|
||||
* @param errorCode
|
||||
* 错误编码
|
||||
* @param message
|
||||
* 信息描述
|
||||
* @param propertiesKey
|
||||
* 消息是否为属性文件中的Key
|
||||
*/
|
||||
public WxPayException(String errorCode, String message, boolean propertiesKey) {
|
||||
super(message);
|
||||
this.setErrorCode(errorCode);
|
||||
this.setPropertiesKey(propertiesKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造一个基本异常.
|
||||
*
|
||||
* @param errorCode
|
||||
* 错误编码
|
||||
* @param message
|
||||
* 信息描述
|
||||
*/
|
||||
public WxPayException(String errorCode, String message, Throwable cause, boolean propertiesKey) {
|
||||
super(message, cause);
|
||||
this.setErrorCode(errorCode);
|
||||
this.setPropertiesKey(propertiesKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造一个基本异常.
|
||||
*
|
||||
* @param message
|
||||
* 信息描述
|
||||
* @param cause
|
||||
* 根异常类(可以存入任何异常)
|
||||
*/
|
||||
public WxPayException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setErrorCode(String errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public boolean isPropertiesKey() {
|
||||
return propertiesKey;
|
||||
}
|
||||
|
||||
public void setPropertiesKey(boolean propertiesKey) {
|
||||
this.propertiesKey = propertiesKey;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.springblade.plugin.pay.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "alipay")
|
||||
public class AliPayConfiguration {
|
||||
|
||||
|
||||
private String appId;
|
||||
private String machId;
|
||||
private String notifyUrl;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.springblade.plugin.pay.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "wechatpay")
|
||||
public class WxPayConfiguration {
|
||||
|
||||
private String appId;
|
||||
private String machId;
|
||||
private String notifyUrl;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.springblade.plugin.pay.constant;
|
||||
|
||||
/**
|
||||
* 支付通用常量
|
||||
*
|
||||
* @author YunGouOS技术部-029
|
||||
* @time 2022/1/2 22:45
|
||||
*/
|
||||
public interface PayConstant {
|
||||
|
||||
//服务名
|
||||
String SERVICE_NAME = "blade-pay";
|
||||
|
||||
//微信支付
|
||||
String WXPAY = "wxpay";
|
||||
|
||||
//支付宝
|
||||
String ALIPAY = "alipay";
|
||||
|
||||
//聚合支付
|
||||
String MERGE = "merge";
|
||||
|
||||
//扫码支付
|
||||
String NATIVEPAY = "native";
|
||||
|
||||
//公众号支付
|
||||
String JSPAY = "jsapi";
|
||||
|
||||
//微信小程序支付
|
||||
String WXMAPPPAY = "wxapp";
|
||||
|
||||
//H5支付
|
||||
String H5PAY = "h5";
|
||||
|
||||
//APP支付
|
||||
String APPPAY = "app";
|
||||
|
||||
// 条码支付
|
||||
String CODEPAY = "code";
|
||||
|
||||
// 人脸支付
|
||||
String FACEPAY = "face";
|
||||
|
||||
// 电脑支付
|
||||
String PCPAY = "pc";
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,145 @@
|
||||
package org.springblade.plugin.pay.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.plugin.pay.constant.PayConstant;
|
||||
import org.springblade.plugin.pay.entity.AliPayAccountConfig;
|
||||
import org.springblade.plugin.pay.service.IAliPayAccountConfigService;
|
||||
import org.springblade.plugin.pay.vo.AliPayAccountConfigVO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 支付宝商户配置控制器
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping(PayConstant.SERVICE_NAME + "/" + PayConstant.ALIPAY + "/config")
|
||||
@Tag(name = "", description = "接口")
|
||||
public class AliPayAccountConfigController extends BladeController {
|
||||
|
||||
private final IAliPayAccountConfigService aliPayAccountConfigService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入aliPayAccountConfig")
|
||||
public R<AliPayAccountConfig> detail(AliPayAccountConfig aliPayAccountConfig) {
|
||||
AliPayAccountConfig detail = aliPayAccountConfigService.getOne(Condition.getQueryWrapper(aliPayAccountConfig));
|
||||
return R.data(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入aliPayAccountConfig")
|
||||
public R<IPage<AliPayAccountConfig>> list(AliPayAccountConfig aliPayAccountConfig, Query query) {
|
||||
IPage<AliPayAccountConfig> pages = aliPayAccountConfigService.page(Condition.getPage(query.setDescs("create_time")), Condition.getQueryWrapper(aliPayAccountConfig));
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "分页", description = "传入aliPayAccountConfig")
|
||||
public R<IPage<AliPayAccountConfigVO>> page(AliPayAccountConfigVO aliPayAccountConfig, Query query) {
|
||||
IPage<AliPayAccountConfigVO> pages = aliPayAccountConfigService.selectAliPayAccountConfigPage(Condition.getPage(query.setDescs("create_time")), aliPayAccountConfig);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入aliPayAccountConfig")
|
||||
public R save(@Valid @RequestBody AliPayAccountConfig aliPayAccountConfig) {
|
||||
if (!StringUtil.isBlank(aliPayAccountConfig.getAlipayPubCert())) {
|
||||
aliPayAccountConfig.setAlipayPubCert(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(aliPayAccountConfig.getPrivateKey())) {
|
||||
aliPayAccountConfig.setPrivateKey(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(aliPayAccountConfig.getRootCert())) {
|
||||
aliPayAccountConfig.setRootCert(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(aliPayAccountConfig.getAppCert())) {
|
||||
aliPayAccountConfig.setAppCert(null);
|
||||
}
|
||||
return R.status(aliPayAccountConfigService.save(aliPayAccountConfig));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入aliPayAccountConfig")
|
||||
public R update(@Valid @RequestBody AliPayAccountConfig aliPayAccountConfig) {
|
||||
if (!StringUtil.isBlank(aliPayAccountConfig.getAlipayPubCert())) {
|
||||
aliPayAccountConfig.setAlipayPubCert(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(aliPayAccountConfig.getPrivateKey())) {
|
||||
aliPayAccountConfig.setPrivateKey(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(aliPayAccountConfig.getRootCert())) {
|
||||
aliPayAccountConfig.setRootCert(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(aliPayAccountConfig.getAppCert())) {
|
||||
aliPayAccountConfig.setAppCert(null);
|
||||
}
|
||||
return R.status(aliPayAccountConfigService.updateById(aliPayAccountConfig));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入aliPayAccountConfig")
|
||||
public R submit(@Valid @RequestBody AliPayAccountConfig aliPayAccountConfig) {
|
||||
if (!StringUtil.isBlank(aliPayAccountConfig.getAlipayPubCert())) {
|
||||
aliPayAccountConfig.setAlipayPubCert(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(aliPayAccountConfig.getPrivateKey())) {
|
||||
aliPayAccountConfig.setPrivateKey(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(aliPayAccountConfig.getRootCert())) {
|
||||
aliPayAccountConfig.setRootCert(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(aliPayAccountConfig.getAppCert())) {
|
||||
aliPayAccountConfig.setAppCert(null);
|
||||
}
|
||||
return R.status(aliPayAccountConfigService.saveOrUpdate(aliPayAccountConfig));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "删除", description = "传入ids")
|
||||
public R remove(@Parameter(name = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(aliPayAccountConfigService.removeByIds(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package org.springblade.plugin.pay.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.plugin.pay.constant.PayConstant;
|
||||
import org.springblade.plugin.pay.entityBiz.AliPayBiz;
|
||||
import org.springblade.plugin.pay.entityBiz.AliPayPageApiBiz;
|
||||
import org.springblade.plugin.pay.service.IAliPayService;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付宝支付接口控制器
|
||||
*
|
||||
* @author YunGouOS技术部-029
|
||||
* @time 2022/1/1 17:57
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping(PayConstant.SERVICE_NAME + "/alipay")
|
||||
public class AliPayController extends BladeController {
|
||||
|
||||
private final IAliPayService aliPayService;
|
||||
|
||||
|
||||
/**
|
||||
* 付款码支付
|
||||
*
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/codePay")
|
||||
public R<Boolean> codePay(@RequestBody JSONObject json) {
|
||||
String appId = json.getString("appId");
|
||||
String mchId = json.getString("mchId");
|
||||
String body = json.getString("body");
|
||||
String authCode = json.getString("authCode");
|
||||
String money = json.getString("money");
|
||||
String notify = json.getString("notifyUrl");
|
||||
String attach = json.getString("attach");
|
||||
String orderPrefix = "S";
|
||||
boolean result = aliPayService.codePay(appId, mchId, body, money, notify, authCode, attach ,orderPrefix);
|
||||
return R.data(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付宝扫码支付
|
||||
*
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/nativePay")
|
||||
public R<Map<String, Object>> nativePay(@RequestBody JSONObject json) {
|
||||
String appId = json.getString("appId");
|
||||
String mchId = json.getString("mchId");
|
||||
String body = json.getString("body");
|
||||
String money = json.getString("money");
|
||||
String notify = json.getString("notifyUrl");
|
||||
String attach = json.getString("attach");
|
||||
String orderPrefix = "S";
|
||||
Map<String, Object> map = aliPayService.nativePay(appId, mchId, body, money, notify, attach ,orderPrefix);
|
||||
return R.data(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付宝jsapi支付
|
||||
*
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/jsPay")
|
||||
public R<AliPayBiz> jsPay(@RequestBody JSONObject json) {
|
||||
String appId = json.getString("appId");
|
||||
String mchId = json.getString("mchId");
|
||||
String buyerId = json.getString("buyerId");
|
||||
String body = json.getString("body");
|
||||
String money = json.getString("money");
|
||||
String notify = json.getString("notifyUrl");
|
||||
String attach = json.getString("attach");
|
||||
String orderPrefix = "S";
|
||||
AliPayBiz aliPayBiz = aliPayService.jsPay(appId, mchId, buyerId, body, money, notify, attach ,orderPrefix);
|
||||
return R.data(aliPayBiz);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 电脑网站支付
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/pcPay")
|
||||
public R<AliPayPageApiBiz> pcPay(@RequestBody JSONObject json) {
|
||||
String appId = json.getString("appId");
|
||||
String mchId = json.getString("mchId");
|
||||
String body = json.getString("body");
|
||||
String money = json.getString("money");
|
||||
String notify = json.getString("notifyUrl");
|
||||
String returnUrl = json.getString("returnUrl");
|
||||
String attach = json.getString("attach");
|
||||
String orderPrefix = "S";
|
||||
AliPayPageApiBiz aliPayPageApiBiz = aliPayService.pcPay(appId, mchId, body, money, notify, returnUrl, attach ,orderPrefix);
|
||||
return R.data(aliPayPageApiBiz);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 支付宝H5支付
|
||||
*
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/h5Pay")
|
||||
public R<AliPayPageApiBiz> h5Pay(@RequestBody JSONObject json) {
|
||||
String appId = json.getString("appId");
|
||||
String mchId = json.getString("mchId");
|
||||
String body = json.getString("body");
|
||||
String money = json.getString("money");
|
||||
String notify = json.getString("notifyUrl");
|
||||
String returnUrl = json.getString("returnUrl");
|
||||
String attach = json.getString("attach");
|
||||
String orderPrefix = "S";
|
||||
AliPayPageApiBiz aliPayPageApiBiz = aliPayService.h5Pay(appId, mchId, body, money, notify, returnUrl, attach , orderPrefix);
|
||||
return R.data(aliPayPageApiBiz);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 支付宝APP支付
|
||||
*
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/appPay")
|
||||
public R<String> appPay(@RequestBody JSONObject json) {
|
||||
String appId = json.getString("appId");
|
||||
String mchId = json.getString("mchId");
|
||||
String body = json.getString("body");
|
||||
String money = json.getString("money");
|
||||
String notify = json.getString("notifyUrl");
|
||||
String attach = json.getString("attach");
|
||||
String orderPrefix = "S";
|
||||
Long orderId = 12736612836182L;
|
||||
String appPayStr = aliPayService.appPay(appId, mchId , body, money, notify, attach, orderPrefix ,orderId);
|
||||
return R.data(appPayStr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,382 @@
|
||||
package org.springblade.plugin.pay.controller;
|
||||
|
||||
import cn.hutool.http.ContentType;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.internal.util.AlipaySignature;
|
||||
import com.ijpay.core.utils.DateTimeZoneUtil;
|
||||
import com.yungouos.pay.util.PaySignUtil;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.plugin.pay.api.wxpay.IWxPayApiService;
|
||||
import org.springblade.plugin.pay.common.WxPayException;
|
||||
import org.springblade.plugin.pay.constant.PayConstant;
|
||||
import org.springblade.plugin.pay.entity.AliPayAccountConfig;
|
||||
import org.springblade.plugin.pay.entity.MergePayConfig;
|
||||
import org.springblade.plugin.pay.entity.WxPayAccountConfig;
|
||||
import org.springblade.plugin.pay.service.*;
|
||||
import org.springblade.plugin.pay.util.AliPayApiUtil;
|
||||
import org.springblade.plugin.pay.util.WxPayUtil;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付回调
|
||||
*
|
||||
* @author YunGouOS技术部-029
|
||||
* @time 2021/12/31 22:18
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping(PayConstant.SERVICE_NAME + "/callback")
|
||||
public class CallbackController {
|
||||
private final IWxPayApiService wxPayApiService;
|
||||
private final IWxPayAccountConfigService wxPayAccountConfigService;
|
||||
private final IOrderService orderService;
|
||||
private final IRefundService refundService;
|
||||
private final IAliPayAccountConfigService aliPayAccountConfigService;
|
||||
private final IMergePayConfigService mergePayConfigService;
|
||||
|
||||
/**
|
||||
* 微信支付回调
|
||||
*
|
||||
* @param mchId
|
||||
* @param jsonParam
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/wxpay/{mchId}")
|
||||
public ResponseEntity wxCallback(@PathVariable String mchId, @RequestBody JSONObject jsonParam, HttpServletRequest request) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code", "fail");
|
||||
result.put("message", "支付失败");
|
||||
try {
|
||||
|
||||
WxPayAccountConfig wxPayAccountConfig = wxPayAccountConfigService.getInfoByMchId(mchId);
|
||||
if (wxPayAccountConfig == null) {
|
||||
throw new WxPayException("商户号尚未接入");
|
||||
}
|
||||
|
||||
//签名验证
|
||||
WxPayUtil.checkNotifySign(request, wxPayAccountConfig);
|
||||
|
||||
JSONObject notifyJson = wxPayApiService.decryptCallback(wxPayAccountConfig, jsonParam);
|
||||
String orderNo = notifyJson.getString("out_trade_no");
|
||||
String payNo = notifyJson.getString("transaction_id");
|
||||
String payTime = notifyJson.getString("success_time");
|
||||
if (!StringUtil.isBlank(payTime)) {
|
||||
payTime = DateTimeZoneUtil.timeZoneDateToStr(payTime);
|
||||
}
|
||||
String openId = notifyJson.getJSONObject("payer").getString("openid");
|
||||
boolean success = orderService.paySuccess(orderNo, mchId, payNo, payTime, openId);
|
||||
if (success) {
|
||||
//返回给微信告诉处理完成,不需要再回调。
|
||||
return new ResponseEntity(null, HttpStatus.OK);
|
||||
}
|
||||
} catch (WxPayException e) {
|
||||
e.printStackTrace();
|
||||
result.put("message", e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.put("message", e.getMessage());
|
||||
}
|
||||
return new ResponseEntity<JSONObject>(result, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付退款回调
|
||||
*
|
||||
* @param mchId
|
||||
* @param jsonParam
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/wxpay/refund/{mchId}")
|
||||
public ResponseEntity wxPayRefundCallback(@PathVariable String mchId, @RequestBody JSONObject jsonParam, HttpServletRequest request) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code", "fail");
|
||||
result.put("message", "退款失败");
|
||||
try {
|
||||
WxPayAccountConfig wxPayAccountConfig = wxPayAccountConfigService.getInfoByMchId(mchId);
|
||||
if (wxPayAccountConfig == null) {
|
||||
throw new ServiceException("商户号尚未接入");
|
||||
}
|
||||
//签名验证
|
||||
WxPayUtil.checkNotifySign(request, wxPayAccountConfig);
|
||||
|
||||
JSONObject notifyJson = wxPayApiService.decryptCallback(wxPayAccountConfig, jsonParam);
|
||||
String orderNo = notifyJson.getString("out_trade_no");
|
||||
String payNo = notifyJson.getString("transaction_id");
|
||||
String refundNo = notifyJson.getString("out_refund_no");
|
||||
String refundId = notifyJson.getString("refund_id");
|
||||
String refundStatus = notifyJson.getString("refund_status");
|
||||
String refundTime = notifyJson.getString("success_time");
|
||||
JSONObject amount = notifyJson.getJSONObject("amount");
|
||||
Integer refund = amount.getInteger("refund");
|
||||
if (!StringUtil.isBlank(refundTime)) {
|
||||
refundTime = DateTimeZoneUtil.timeZoneDateToStr(refundTime);
|
||||
}
|
||||
boolean success = refundService.refundSuccess(refundNo, mchId);
|
||||
if (success) {
|
||||
//返回给微信告诉处理完成,不需要再回调。
|
||||
return new ResponseEntity(null, HttpStatus.OK);
|
||||
}
|
||||
} catch (WxPayException e) {
|
||||
e.printStackTrace();
|
||||
result.put("message", e.getMessage());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.put("message", e.getMessage());
|
||||
}
|
||||
return new ResponseEntity<JSONObject>(result, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 支付宝支付回调
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
@RequestMapping(value = "/alipay")
|
||||
public void alipay(HttpServletRequest request, HttpServletResponse response) {
|
||||
String result = "支付失败";
|
||||
try {
|
||||
// 获取支付宝POST过来反馈信息
|
||||
Map<String, String> params = AliPayApiUtil.toMap(request);
|
||||
System.out.println("支付宝回调参数:" + params.toString());
|
||||
String mchId = params.get("seller_id");
|
||||
String appId = params.get("app_id");
|
||||
if (StringUtils.isBlank(mchId)) {
|
||||
result = "seller_id is not null";
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
||||
return;
|
||||
}
|
||||
AliPayAccountConfig aliPayAccountConfig = aliPayAccountConfigService.getInfoByMchIdAndAppId(mchId, appId);
|
||||
if (aliPayAccountConfig == null) {
|
||||
result = "该商户号尚未接入";
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
||||
return;
|
||||
}
|
||||
String signType = aliPayAccountConfig.getSignType();
|
||||
String pubKey = aliPayAccountConfig.getPubKey();
|
||||
boolean verify_result = AlipaySignature.rsaCheckV1(params, pubKey, "UTF-8", signType);
|
||||
if (!verify_result) {
|
||||
result = "签名验证失败";
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
||||
return;
|
||||
}
|
||||
//支付状态
|
||||
String trade_status = params.get("trade_status");
|
||||
// 总金额
|
||||
String money = params.get("total_amount");
|
||||
// 支付宝订单号
|
||||
String payNo = params.get("trade_no");
|
||||
// 商户订单号
|
||||
String orderNo = params.get("out_trade_no");
|
||||
//买家ID
|
||||
String openId = params.get("buyer_id");
|
||||
//支付时间
|
||||
String payTime = params.get("gmt_payment");
|
||||
//退款金额
|
||||
String refund_fee = params.get("refund_fee");
|
||||
//退款时间
|
||||
String gmt_refund = params.get("gmt_refund");
|
||||
//退款单号
|
||||
String refundNo = params.get("out_biz_no");
|
||||
switch (trade_status) {
|
||||
case "WAIT_BUYER_PAY":
|
||||
result = "wait buyer pay";
|
||||
break;
|
||||
case "TRADE_CLOSED":
|
||||
//全额退款成功回调
|
||||
if (refundService.refundSuccess(refundNo, mchId)) {
|
||||
result = "success";
|
||||
}
|
||||
break;
|
||||
case "TRADE_SUCCESS":
|
||||
if (StringUtils.isBlank(refund_fee) && StringUtils.isBlank(gmt_refund)) {
|
||||
//支付成功回调
|
||||
if (orderService.paySuccess(orderNo, mchId, payNo, payTime, openId)) {
|
||||
result = "success";
|
||||
}
|
||||
} else {
|
||||
//部分退款回调
|
||||
if (refundService.refundSuccess(refundNo, mchId)) {
|
||||
result = "success";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "TRADE_FINISHED":
|
||||
//交易结束,不可退款
|
||||
result = "success";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), e.getMessage(), new String[]{"encoding:UTF-8"});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), e.getMessage(), new String[]{"encoding:UTF-8"});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* YunGouOS服务商支付回调
|
||||
* 回调文档:https://open.pay.yungouos.com/#/callback/notify
|
||||
*
|
||||
* @param data
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/yungouos")
|
||||
public void yungouos(@RequestParam Map<String, String> data, HttpServletResponse response, String appId) {
|
||||
String result = "faild";
|
||||
try {
|
||||
String channel = data.get("payChannel");
|
||||
String mchId = data.get("mchId");
|
||||
if (StringUtils.isBlank(channel) || StringUtils.isBlank(mchId)) {
|
||||
result = "参数错误";
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
||||
return;
|
||||
}
|
||||
String payKey = null;
|
||||
switch (channel) {
|
||||
case "wxpay":
|
||||
//微信交易回调
|
||||
WxPayAccountConfig wxPayAccountConfig = wxPayAccountConfigService.getInfoByMchId(mchId);
|
||||
if (wxPayAccountConfig == null) {
|
||||
result = "商户号尚未接入";
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
||||
return;
|
||||
}
|
||||
payKey = wxPayAccountConfig.getPayKey();
|
||||
break;
|
||||
case "alipay":
|
||||
//支付宝交易回调
|
||||
AliPayAccountConfig aliPayAccountConfig = aliPayAccountConfigService.getInfoByMchIdAndAppId(mchId, null);
|
||||
if (aliPayAccountConfig == null) {
|
||||
result = "商户号尚未接入";
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
||||
return;
|
||||
}
|
||||
payKey = aliPayAccountConfig.getPayKey();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
boolean check = PaySignUtil.checkRefundNotifySign(data, payKey);
|
||||
if (!check) {
|
||||
result = "验签失败,签名错误";
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
||||
return;
|
||||
}
|
||||
//TODO 处理你自己的业务
|
||||
String orderNo = data.get("outTradeNo");
|
||||
String payNo = data.get("payNo");
|
||||
String payTime = data.get("time");
|
||||
String openId = data.get("openId");
|
||||
boolean success = false;
|
||||
if (!StringUtil.isBlank(appId)) {
|
||||
//聚合支付
|
||||
success = orderService.paySuccessMerge(orderNo, appId, mchId, payNo, payTime, openId);
|
||||
} else {
|
||||
success = orderService.paySuccess(orderNo, mchId, payNo, payTime, openId);
|
||||
}
|
||||
if (success) {
|
||||
result = "SUCCESS";
|
||||
}
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), e.getMessage(), new String[]{"encoding:UTF-8"});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* YunGouOS服务商退款回调
|
||||
* 文档地址:https://open.pay.yungouos.com/#/callback/refund
|
||||
*
|
||||
* @param data
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/yungouos/refund")
|
||||
public void yungouosRefund(@RequestParam Map<String, String> data, HttpServletResponse response) {
|
||||
String result = "faild";
|
||||
try {
|
||||
String channel = data.get("channel");
|
||||
String mchId = data.get("mchId");
|
||||
String refundNo = data.get("outTradeRefundNo");
|
||||
if (StringUtils.isBlank(channel) || StringUtils.isBlank(mchId)) {
|
||||
result = "参数错误";
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
||||
return;
|
||||
}
|
||||
String payKey = null;
|
||||
switch (channel) {
|
||||
case "wxpay":
|
||||
//微信交易回调
|
||||
WxPayAccountConfig wxPayAccountConfig = wxPayAccountConfigService.getInfoByMchId(mchId);
|
||||
if (wxPayAccountConfig == null) {
|
||||
result = "商户号尚未接入";
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
||||
return;
|
||||
}
|
||||
payKey = wxPayAccountConfig.getPayKey();
|
||||
break;
|
||||
case "alipay":
|
||||
//支付宝交易回调
|
||||
AliPayAccountConfig aliPayAccountConfig = aliPayAccountConfigService.getInfoByMchIdAndAppId(mchId, null);
|
||||
if (aliPayAccountConfig == null) {
|
||||
result = "商户号尚未接入";
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
||||
return;
|
||||
}
|
||||
payKey = aliPayAccountConfig.getPayKey();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
boolean check = PaySignUtil.checkRefundNotifySign(data, payKey);
|
||||
if (!check) {
|
||||
result = "验签失败,签名错误";
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
||||
return;
|
||||
}
|
||||
//TODO 处理你自己的业务
|
||||
boolean success = refundService.refundSuccess(refundNo, mchId);
|
||||
if (success) {
|
||||
result = "SUCCESS";
|
||||
}
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), result, new String[]{"encoding:UTF-8"});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), e.getMessage(), new String[]{"encoding:UTF-8"});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* YunGouOS服务商聚合支付回调
|
||||
*
|
||||
* @param mchId
|
||||
* @param data
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/yungouos/merge/{mchId}")
|
||||
public void yungouosMerge(@PathVariable String mchId, @RequestParam Map<String, String> data, HttpServletResponse response) {
|
||||
MergePayConfig payConfig = mergePayConfigService.getInfoByMchId(mchId);
|
||||
if (payConfig == null) {
|
||||
AliPayApiUtil.render(response, ContentType.TEXT_PLAIN.getValue(), "商户号尚未接入", new String[]{"encoding:UTF-8"});
|
||||
return;
|
||||
}
|
||||
yungouos(data, response, mchId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the dreamlu.net developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: Chill 庄骞 (smallchill@163.com)
|
||||
*/
|
||||
package org.springblade.plugin.pay.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.plugin.pay.constant.PayConstant;
|
||||
import org.springblade.plugin.pay.entity.MergePayConfig;
|
||||
import org.springblade.plugin.pay.service.IMergePayConfigService;
|
||||
import org.springblade.plugin.pay.vo.MergePayConfigVO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2022-06-27
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping(PayConstant.SERVICE_NAME + "/merge/config")
|
||||
@Tag(name = "", description = "接口")
|
||||
public class MergePayConfigController extends BladeController {
|
||||
|
||||
private final IMergePayConfigService mergePayConfigService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入mergePayConfig")
|
||||
public R<MergePayConfig> detail(MergePayConfig mergePayConfig) {
|
||||
MergePayConfig detail = mergePayConfigService.getOne(Condition.getQueryWrapper(mergePayConfig));
|
||||
return R.data(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入mergePayConfig")
|
||||
public R<IPage<MergePayConfig>> list(MergePayConfig mergePayConfig, Query query) {
|
||||
IPage<MergePayConfig> pages = mergePayConfigService.page(Condition.getPage(query), Condition.getQueryWrapper(mergePayConfig));
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "分页", description = "传入mergePayConfig")
|
||||
public R<IPage<MergePayConfigVO>> page(MergePayConfigVO mergePayConfig, Query query) {
|
||||
IPage<MergePayConfigVO> pages = mergePayConfigService.selectMergePayConfigPage(Condition.getPage(query), mergePayConfig);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入mergePayConfig")
|
||||
public R save(@Valid @RequestBody MergePayConfig mergePayConfig) {
|
||||
if (mergePayConfig != null) {
|
||||
mergePayConfig.setIsDeleted(0);
|
||||
}
|
||||
return R.status(mergePayConfigService.save(mergePayConfig));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入mergePayConfig")
|
||||
public R update(@Valid @RequestBody MergePayConfig mergePayConfig) {
|
||||
return R.status(mergePayConfigService.updateById(mergePayConfig));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入mergePayConfig")
|
||||
public R submit(@Valid @RequestBody MergePayConfig mergePayConfig) {
|
||||
if (mergePayConfig != null) {
|
||||
mergePayConfig.setIsDeleted(0);
|
||||
}
|
||||
return R.status(mergePayConfigService.saveOrUpdate(mergePayConfig));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "删除", description = "传入ids")
|
||||
public R remove(@Parameter(name = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(mergePayConfigService.removeByIds(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package org.springblade.plugin.pay.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.plugin.pay.constant.PayConstant;
|
||||
import org.springblade.plugin.pay.service.IMergePayService;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 聚合支付控制类
|
||||
*
|
||||
* @author YunGouOS技术部-029
|
||||
* @time 2022/6/28 11:10
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping(PayConstant.SERVICE_NAME + "/merge")
|
||||
@Tag(name = "", description = "接口")
|
||||
public class MergePayController extends BladeController {
|
||||
|
||||
private final IMergePayService mergePayService;
|
||||
|
||||
/**
|
||||
* 聚合支付一码付,适合展示二维码 用户扫码支付
|
||||
*
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/nativePay")
|
||||
public R<Map<String, Object>> nativePay(@RequestBody JSONObject json) {
|
||||
String appId = json.getString("appId");
|
||||
String mchId = json.getString("mchId");
|
||||
String body = json.getString("body");
|
||||
String money = json.getString("money");
|
||||
String notifyUrl = json.getString("notifyUrl");
|
||||
String returnUrl = json.getString("returnUrl");
|
||||
String attach = json.getString("attach");
|
||||
String configNo = json.getString("configNo");
|
||||
String auto = json.getString("auto");
|
||||
String autoNode = json.getString("autoNode");
|
||||
String orderPrefix = "S";
|
||||
Map<String, Object> map = mergePayService.nativePay(mchId, body, money, notifyUrl, returnUrl, attach, configNo, auto, autoNode, orderPrefix);
|
||||
return R.data(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 聚合支付手机端,返回URL,在手机端重定向即可
|
||||
*
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/mobilePay")
|
||||
public R<Map<String, Object>> mobilePay(@RequestBody JSONObject json) {
|
||||
String appId = json.getString("appId");
|
||||
String mchId = json.getString("mchId");
|
||||
String body = json.getString("body");
|
||||
String money = json.getString("money");
|
||||
String notifyUrl = json.getString("notifyUrl");
|
||||
String returnUrl = json.getString("returnUrl");
|
||||
String attach = json.getString("attach");
|
||||
String configNo = json.getString("configNo");
|
||||
String auto = json.getString("auto");
|
||||
String autoNode = json.getString("autoNode");
|
||||
String orderPrefix = "S";
|
||||
Map<String, Object> map = mergePayService.mobilePay(mchId, body, money, notifyUrl, returnUrl, attach, configNo, auto, autoNode, orderPrefix);
|
||||
return R.data(map);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the dreamlu.net developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: Chill 庄骞 (smallchill@163.com)
|
||||
*/
|
||||
package org.springblade.plugin.pay.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.plugin.pay.constant.PayConstant;
|
||||
import org.springblade.plugin.pay.entity.Order;
|
||||
import org.springblade.plugin.pay.service.IOrderService;
|
||||
import org.springblade.plugin.pay.vo.OrderVO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2021-12-31
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping(PayConstant.SERVICE_NAME + "/order")
|
||||
@Tag(name = "", description = "接口")
|
||||
public class OrderController extends BladeController {
|
||||
|
||||
private final IOrderService orderService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description ="传入order")
|
||||
public R<Order> detail(Order order) {
|
||||
Order detail = orderService.getOne(Condition.getQueryWrapper(order));
|
||||
return R.data(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description ="传入order")
|
||||
public R<IPage<Order>> list(Order order, Query query) {
|
||||
IPage<Order> pages = orderService.page(Condition.getPage(query.setDescs("create_time")), Condition.getQueryWrapper(order));
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "分页", description ="传入order")
|
||||
public R<IPage<OrderVO>> page(OrderVO order, Query query) {
|
||||
IPage<OrderVO> pages = orderService.selectOrderPage(Condition.getPage(query.setDescs("create_time")), order);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description ="传入order")
|
||||
public R save(@Valid @RequestBody Order order) {
|
||||
return R.status(orderService.save(order));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description ="传入order")
|
||||
public R update(@Valid @RequestBody Order order) {
|
||||
return R.status(orderService.updateById(order));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description ="传入order")
|
||||
public R submit(@Valid @RequestBody Order order) {
|
||||
return R.status(orderService.saveOrUpdate(order));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "删除", description ="传入ids")
|
||||
public R remove(@Parameter(name = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(orderService.removeByIds(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查订单状态
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/checkOrderStatus")
|
||||
public R checkOrderStatus(@RequestParam String orderNo) {
|
||||
try {
|
||||
Order order = orderService.getOrderInfoByOrderNoAndMchId(orderNo,null);
|
||||
if (order == null) {
|
||||
return R.data(false);
|
||||
}
|
||||
Integer status = order.getStatus();
|
||||
if (1 != status.intValue()) {
|
||||
return R.data(false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return R.data(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the dreamlu.net developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: Chill 庄骞 (smallchill@163.com)
|
||||
*/
|
||||
package org.springblade.plugin.pay.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.plugin.pay.constant.PayConstant;
|
||||
import org.springblade.plugin.pay.entity.Refund;
|
||||
import org.springblade.plugin.pay.service.IRefundService;
|
||||
import org.springblade.plugin.pay.vo.RefundVO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 订单退款表 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2022-01-03
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping(PayConstant.SERVICE_NAME + "/refund")
|
||||
@Tag(name = "订单退款表", description = "订单退款表接口")
|
||||
public class RefundController extends BladeController {
|
||||
|
||||
private final IRefundService refundService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description ="传入refund")
|
||||
public R<Refund> detail(Refund refund) {
|
||||
Refund detail = refundService.getOne(Condition.getQueryWrapper(refund));
|
||||
return R.data(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页 订单退款表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description ="传入refund")
|
||||
public R<IPage<Refund>> list(Refund refund, Query query) {
|
||||
IPage<Refund> pages = refundService.page(Condition.getPage(query.setDescs("create_time")), Condition.getQueryWrapper(refund));
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义分页 订单退款表
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "分页", description ="传入refund")
|
||||
public R<IPage<RefundVO>> page(RefundVO refund, Query query) {
|
||||
IPage<RefundVO> pages = refundService.selectRefundPage(Condition.getPage(query), refund);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 订单退款表
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description ="传入refund")
|
||||
public R save(@Valid @RequestBody Refund refund) {
|
||||
return R.status(refundService.save(refund));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 订单退款表
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description ="传入refund")
|
||||
public R update(@Valid @RequestBody Refund refund) {
|
||||
return R.status(refundService.updateById(refund));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改 订单退款表
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description ="传入refund")
|
||||
public R submit(@Valid @RequestBody Refund refund) {
|
||||
return R.status(refundService.saveOrUpdate(refund));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除 订单退款表
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "删除", description ="传入ids")
|
||||
public R remove(@Parameter(name = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(refundService.removeByIds(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
package org.springblade.plugin.pay.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.plugin.pay.constant.PayConstant;
|
||||
import org.springblade.plugin.pay.entity.WxPayAccountConfig;
|
||||
import org.springblade.plugin.pay.service.IWxPayAccountConfigService;
|
||||
import org.springblade.plugin.pay.vo.WxPayAccountConfigVO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2021-12-31
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping(PayConstant.SERVICE_NAME +"/wxconfig")
|
||||
@Tag(name = "", description = "接口")
|
||||
public class WxPayAccountConfigController extends BladeController {
|
||||
|
||||
private final IWxPayAccountConfigService wxpayAccountConfigService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary ="详情", description ="传入wxpayAccountConfig")
|
||||
public R<WxPayAccountConfig> detail(WxPayAccountConfig wxpayAccountConfig) {
|
||||
WxPayAccountConfig detail = wxpayAccountConfigService.getOne(Condition.getQueryWrapper(wxpayAccountConfig));
|
||||
return R.data(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary ="分页", description ="传入wxpayAccountConfig")
|
||||
public R<IPage<WxPayAccountConfig>> list(WxPayAccountConfig wxpayAccountConfig, Query query) {
|
||||
IPage<WxPayAccountConfig> pages = wxpayAccountConfigService.page(Condition.getPage(query.setDescs("create_time")), Condition.getQueryWrapper(wxpayAccountConfig));
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary ="分页", description ="传入wxpayAccountConfig")
|
||||
public R<IPage<WxPayAccountConfigVO>> page(WxPayAccountConfigVO wxpayAccountConfig, Query query) {
|
||||
IPage<WxPayAccountConfigVO> pages = wxpayAccountConfigService.selectWxpayAccountConfigPage(Condition.getPage(query.setDescs("create_time")), wxpayAccountConfig);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary ="新增", description ="传入wxpayAccountConfig")
|
||||
public R save(@Valid @RequestBody WxPayAccountConfig wxpayAccountConfig) {
|
||||
if (wxpayAccountConfig.getPrivateKey() != null) {
|
||||
wxpayAccountConfig.setPrivateKey(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertPem())) {
|
||||
wxpayAccountConfig.setCertPem(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertPkcs())) {
|
||||
wxpayAccountConfig.setCertPkcs(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertPubKey())) {
|
||||
wxpayAccountConfig.setCertPubKey(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertPrivateKey())) {
|
||||
wxpayAccountConfig.setCertPrivateKey(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertSerialNo())) {
|
||||
wxpayAccountConfig.setCertSerialNo(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertPlatSerialNo())) {
|
||||
wxpayAccountConfig.setCertPlatSerialNo(null);
|
||||
}
|
||||
if (wxpayAccountConfig.getPrivateKey() != null) {
|
||||
wxpayAccountConfig.setPrivateKey(null);
|
||||
}
|
||||
if (wxpayAccountConfig.getCertPkcsStream() != null) {
|
||||
wxpayAccountConfig.setCertPkcsStream(null);
|
||||
}
|
||||
if (wxpayAccountConfig.getCertPubKeyStream() != null) {
|
||||
wxpayAccountConfig.setCertPubKeyStream(null);
|
||||
}
|
||||
return R.status(wxpayAccountConfigService.save(wxpayAccountConfig));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary ="修改", description ="传入wxpayAccountConfig")
|
||||
public R update(@Valid @RequestBody WxPayAccountConfig wxpayAccountConfig) {
|
||||
if (wxpayAccountConfig.getPrivateKey() != null) {
|
||||
wxpayAccountConfig.setPrivateKey(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertPem())) {
|
||||
wxpayAccountConfig.setCertPem(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertPkcs())) {
|
||||
wxpayAccountConfig.setCertPkcs(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertPubKey())) {
|
||||
wxpayAccountConfig.setCertPubKey(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertPrivateKey())) {
|
||||
wxpayAccountConfig.setCertPrivateKey(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertSerialNo())) {
|
||||
wxpayAccountConfig.setCertSerialNo(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertPlatSerialNo())) {
|
||||
wxpayAccountConfig.setCertPlatSerialNo(null);
|
||||
}
|
||||
if (wxpayAccountConfig.getPrivateKey() != null) {
|
||||
wxpayAccountConfig.setPrivateKey(null);
|
||||
}
|
||||
if (wxpayAccountConfig.getCertPkcsStream() != null) {
|
||||
wxpayAccountConfig.setCertPkcsStream(null);
|
||||
}
|
||||
if (wxpayAccountConfig.getCertPubKeyStream() != null) {
|
||||
wxpayAccountConfig.setCertPubKeyStream(null);
|
||||
}
|
||||
return R.status(wxpayAccountConfigService.updateById(wxpayAccountConfig));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary ="新增或修改", description ="传入wxpayAccountConfig")
|
||||
public R submit(@Valid @RequestBody WxPayAccountConfig wxpayAccountConfig) {
|
||||
if (wxpayAccountConfig.getPrivateKey() != null) {
|
||||
wxpayAccountConfig.setPrivateKey(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertPem())) {
|
||||
wxpayAccountConfig.setCertPem(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertPkcs())) {
|
||||
wxpayAccountConfig.setCertPkcs(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertPubKey())) {
|
||||
wxpayAccountConfig.setCertPubKey(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertPrivateKey())) {
|
||||
wxpayAccountConfig.setCertPrivateKey(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertSerialNo())) {
|
||||
wxpayAccountConfig.setCertSerialNo(null);
|
||||
}
|
||||
if (!StringUtil.isBlank(wxpayAccountConfig.getCertPlatSerialNo())) {
|
||||
wxpayAccountConfig.setCertPlatSerialNo(null);
|
||||
}
|
||||
if (wxpayAccountConfig.getPrivateKey() != null) {
|
||||
wxpayAccountConfig.setPrivateKey(null);
|
||||
}
|
||||
if (wxpayAccountConfig.getCertPkcsStream() != null) {
|
||||
wxpayAccountConfig.setCertPkcsStream(null);
|
||||
}
|
||||
if (wxpayAccountConfig.getCertPubKeyStream() != null) {
|
||||
wxpayAccountConfig.setCertPubKeyStream(null);
|
||||
}
|
||||
return R.status(wxpayAccountConfigService.saveOrUpdate(wxpayAccountConfig));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary ="删除", description ="传入ids")
|
||||
public R remove(@Parameter(name ="主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(wxpayAccountConfigService.removeByIds(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package org.springblade.plugin.pay.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.plugin.pay.constant.PayConstant;
|
||||
import org.springblade.plugin.pay.service.IWxPayService;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author YunGouOS技术部-029
|
||||
* @time 2022/1/1 17:57
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping(PayConstant.SERVICE_NAME + "/wxpay")
|
||||
public class WxPayController {
|
||||
|
||||
private final IWxPayService wxPayService;
|
||||
|
||||
/**
|
||||
* 微信扫码支付
|
||||
*
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/nativePay")
|
||||
public R<Map<String, Object>> nativePay(@RequestBody JSONObject json) {
|
||||
String appId = json.getString("appId");
|
||||
String mchId = json.getString("mchId");
|
||||
String body = json.getString("body");
|
||||
String money = json.getString("money");
|
||||
String notify = json.getString("notifyUrl");
|
||||
String attach = json.getString("attach");
|
||||
String orderPrefix = "S";
|
||||
Map<String, Object> map = wxPayService.nativePay(appId, mchId, body, money, notify, attach, orderPrefix);
|
||||
return R.data(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信jsapi支付
|
||||
*
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/jsPay")
|
||||
public R<Map<String, String>> jsPay(@RequestBody JSONObject json) {
|
||||
String appId = json.getString("appId");
|
||||
String mchId = json.getString("mchId");
|
||||
String openId = json.getString("openId");
|
||||
String body = json.getString("body");
|
||||
String money = json.getString("money");
|
||||
String notify = json.getString("notifyUrl");
|
||||
String attach = json.getString("attach");
|
||||
String orderPrefix = "S";
|
||||
Map<String, String> jsPay = wxPayService.jsPay(appId, mchId, openId, body, money, notify, attach , orderPrefix);
|
||||
return R.data(jsPay);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信小程序支付
|
||||
*
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/wxAppPay")
|
||||
public R<Map<String, String>> wxAppPay(@RequestBody JSONObject json) {
|
||||
String appId = json.getString("appId");
|
||||
String mchId = json.getString("mchId");
|
||||
String openId = json.getString("openId");
|
||||
String body = json.getString("body");
|
||||
String money = json.getString("money");
|
||||
String notify = json.getString("notifyUrl");
|
||||
String attach = json.getString("attach");
|
||||
String orderPrefix = "S";
|
||||
Map<String, String> wxAppPay = wxPayService.wxApp(appId, mchId, openId, body, money, notify, attach , orderPrefix);
|
||||
return R.data(wxAppPay);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信H5支付
|
||||
*
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/h5Pay")
|
||||
public R<String> h5Pay(@RequestBody JSONObject json) {
|
||||
String appId = json.getString("appId");
|
||||
String mchId = json.getString("mchId");
|
||||
String body = json.getString("body");
|
||||
String money = json.getString("money");
|
||||
String notify = json.getString("notifyUrl");
|
||||
String returnUrl = json.getString("returnUrl");
|
||||
String attach = json.getString("attach");
|
||||
String orderPrefix = "S";
|
||||
String url = wxPayService.h5Pay(appId, mchId, body, money, notify, returnUrl, attach , orderPrefix);
|
||||
return R.data(url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 微信APP支付
|
||||
*
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/appPay")
|
||||
public R<Map<String, String>> appPay(@RequestBody JSONObject json) {
|
||||
String appId = json.getString("appId");
|
||||
String mchId = json.getString("mchId");
|
||||
String body = json.getString("body");
|
||||
String money = json.getString("money");
|
||||
String notify = json.getString("notifyUrl");
|
||||
String attach = json.getString("attach");
|
||||
String orderPrefix = "S";
|
||||
Long orderNo = System.currentTimeMillis();
|
||||
Map<String, String> appPay = wxPayService.appPay(appId, mchId, body, money, notify, attach , orderPrefix , orderNo);
|
||||
return R.data(appPay);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
36
src/main/java/org/springblade/plugin/pay/dto/APPPayDto.java
Normal file
36
src/main/java/org/springblade/plugin/pay/dto/APPPayDto.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package org.springblade.plugin.pay.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springblade.modules.common.eums.BusinessModule;
|
||||
import org.springblade.modules.common.eums.PaymentType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class APPPayDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private PaymentType paymentType;
|
||||
|
||||
private BusinessModule businessModule;
|
||||
|
||||
|
||||
private Long orderId;
|
||||
|
||||
private String body;
|
||||
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 现金金额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.springblade.plugin.pay.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springblade.modules.common.eums.BusinessModule;
|
||||
import org.springblade.modules.common.eums.PaymentType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class APPQueryDto implements Serializable {
|
||||
|
||||
private String orderNo;
|
||||
private PaymentType paymentType;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the dreamlu.net developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: Chill 庄骞 (smallchill@163.com)
|
||||
*/
|
||||
package org.springblade.plugin.pay.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.plugin.pay.entity.AliPayAccountConfig;
|
||||
|
||||
/**
|
||||
* 数据传输对象实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2021-12-31
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class AliPayAccountConfigDTO extends AliPayAccountConfig {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the dreamlu.net developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: Chill 庄骞 (smallchill@163.com)
|
||||
*/
|
||||
package org.springblade.plugin.pay.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.plugin.pay.entity.MergePayConfig;
|
||||
|
||||
/**
|
||||
* 数据传输对象实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2022-06-27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class MergePayConfigDTO extends MergePayConfig {
|
||||
|
||||
}
|
||||
34
src/main/java/org/springblade/plugin/pay/dto/OrderDTO.java
Normal file
34
src/main/java/org/springblade/plugin/pay/dto/OrderDTO.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the dreamlu.net developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: Chill 庄骞 (smallchill@163.com)
|
||||
*/
|
||||
package org.springblade.plugin.pay.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.plugin.pay.entity.Order;
|
||||
|
||||
/**
|
||||
* 数据传输对象实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2021-12-31
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class OrderDTO extends Order {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
34
src/main/java/org/springblade/plugin/pay/dto/RefundDTO.java
Normal file
34
src/main/java/org/springblade/plugin/pay/dto/RefundDTO.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the dreamlu.net developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: Chill 庄骞 (smallchill@163.com)
|
||||
*/
|
||||
package org.springblade.plugin.pay.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.plugin.pay.entity.Refund;
|
||||
|
||||
/**
|
||||
* 订单退款表数据传输对象实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2022-01-03
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class RefundDTO extends Refund {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the dreamlu.net developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: Chill 庄骞 (smallchill@163.com)
|
||||
*/
|
||||
package org.springblade.plugin.pay.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.plugin.pay.entity.WxPayAccountConfig;
|
||||
|
||||
/**
|
||||
* 数据传输对象实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2021-12-31
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WxPayAccountConfigDTO extends WxPayAccountConfig {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package org.springblade.plugin.pay.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
|
||||
/**
|
||||
* 支付宝商户配置对象
|
||||
*/
|
||||
@Data
|
||||
@TableName("blade_pay_alipay_account_config")
|
||||
@Schema(description = "AlipayAccountConfig对象")
|
||||
public class AliPayAccountConfig extends BaseEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 商户号
|
||||
*/
|
||||
@Schema(description = "mch_id")
|
||||
private String mchId;
|
||||
|
||||
/**
|
||||
* 支付密钥
|
||||
*/
|
||||
@Schema(description = "pay_key")
|
||||
private String payKey;
|
||||
|
||||
/**
|
||||
* 支付宝应用id
|
||||
*/
|
||||
@Schema(description = "app_id")
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* 支付宝账户
|
||||
*/
|
||||
@Schema(description = "account")
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 支付宝公钥
|
||||
*/
|
||||
@Schema(description = "pub_key")
|
||||
private String pubKey;
|
||||
|
||||
/**
|
||||
* 支付宝私钥
|
||||
*/
|
||||
@Schema(description = "private_key")
|
||||
private String privateKey;
|
||||
|
||||
|
||||
/**
|
||||
* 支付宝证书
|
||||
*/
|
||||
@Schema(description = "app_cert")
|
||||
private String appCert;
|
||||
|
||||
/**
|
||||
* 支付宝公钥证书
|
||||
*/
|
||||
@Schema(description = "alipay_pub_cert")
|
||||
private String alipayPubCert;
|
||||
|
||||
/**
|
||||
* 支付宝根证书
|
||||
*/
|
||||
@Schema(description = "root_cert")
|
||||
private String rootCert;
|
||||
|
||||
/**
|
||||
* 支付宝网关地址
|
||||
*/
|
||||
@Schema(description = "service_url")
|
||||
private String serviceUrl;
|
||||
|
||||
/**
|
||||
* 加密算法类型
|
||||
*/
|
||||
@Schema(description = "sign_type")
|
||||
private String signType;
|
||||
|
||||
/**
|
||||
* 收款名称
|
||||
*/
|
||||
@Schema(description = "pay_name")
|
||||
private String payName;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
@Schema(description = "company_name")
|
||||
private String companyName;
|
||||
|
||||
/**
|
||||
* API类型【0:普通】
|
||||
*/
|
||||
@Schema(description = "API类型【0:普通】")
|
||||
private Integer apiType;
|
||||
|
||||
/**
|
||||
* 统一支付回调地址
|
||||
*/
|
||||
@Schema(description = "notify_url")
|
||||
private String notifyUrl;
|
||||
|
||||
/**
|
||||
* 统一退款回调地址
|
||||
*/
|
||||
@Schema(description = "refund_notify_url")
|
||||
private String refundNotifyUrl;
|
||||
|
||||
/**
|
||||
* 三方模式授权token
|
||||
*/
|
||||
@Schema(description = "app_auth_token")
|
||||
private String appAuthToken;
|
||||
|
||||
|
||||
/**
|
||||
* 状态【0:关闭、1:启用】
|
||||
*/
|
||||
@Schema(description = "status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 接口交互证书临时路径(privateKeyUrl)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String privateKeyUrl;
|
||||
|
||||
|
||||
/**
|
||||
* 接口交互证书临时路径(支付宝根证书)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String aliPayRootCertUrl;
|
||||
|
||||
/**
|
||||
* 接口交互证书临时路径(应用公钥证书)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String appCertUrl;
|
||||
|
||||
/**
|
||||
* 接口交互证书临时路径(支付宝公钥证书)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String aliPayPubCertUrl;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the dreamlu.net developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: Chill 庄骞 (smallchill@163.com)
|
||||
*/
|
||||
package org.springblade.plugin.pay.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
|
||||
/**
|
||||
* 实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2022-06-27
|
||||
*/
|
||||
@Data
|
||||
@TableName("blade_pay_merge_pay_config")
|
||||
@Schema(description = "MergePayConfig对象")
|
||||
public class MergePayConfig extends BaseEntity {
|
||||
|
||||
private Long id;
|
||||
/**
|
||||
* 商户号
|
||||
*/
|
||||
@Schema(description = "商户号")
|
||||
private String mchId;
|
||||
/**
|
||||
* 支付密钥
|
||||
*/
|
||||
@Schema(description = "支付密钥")
|
||||
private String payKey;
|
||||
|
||||
/**
|
||||
* 统一支付回调地址
|
||||
*/
|
||||
@Schema(description = "统一支付回调地址")
|
||||
private String notifyUrl;
|
||||
|
||||
/**
|
||||
* 退款回调地址
|
||||
*/
|
||||
@Schema(description = "退款回调地址")
|
||||
private String refundNotifyUrl;
|
||||
|
||||
/**
|
||||
* 状态【0:关闭、1:启用】
|
||||
*/
|
||||
@Schema(description = "状态【0:关闭、1:启用】")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
123
src/main/java/org/springblade/plugin/pay/entity/Order.java
Normal file
123
src/main/java/org/springblade/plugin/pay/entity/Order.java
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the dreamlu.net developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: Chill 庄骞 (smallchill@163.com)
|
||||
*/
|
||||
package org.springblade.plugin.pay.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
|
||||
/**
|
||||
* 实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2021-12-31
|
||||
*/
|
||||
@Data
|
||||
@TableName("blade_pay_order")
|
||||
@Schema(description = "Order对象")
|
||||
public class Order extends BaseEntity{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
/**
|
||||
* 系统单号
|
||||
*/
|
||||
@Schema(description = "系统单号")
|
||||
private String orderNo;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Schema(description = "商品名称")
|
||||
private String body;
|
||||
/**
|
||||
* 支付金额
|
||||
*/
|
||||
@Schema(description = "支付金额")
|
||||
private String money;
|
||||
|
||||
/**
|
||||
* 应用ID
|
||||
*/
|
||||
@Schema(description = "应用ID")
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* 商户号
|
||||
*/
|
||||
@Schema(description = "商户号")
|
||||
private String mchId;
|
||||
/**
|
||||
* 收款名称
|
||||
*/
|
||||
@Schema(description = "收款名称")
|
||||
private String payName;
|
||||
/**
|
||||
* 支付方式【code、native、jsapi、wxapp、h5、app】
|
||||
*/
|
||||
@Schema(description = "支付方式【code、native、jsapi、wxapp、h5、app】")
|
||||
private String payType;
|
||||
/**
|
||||
* 支付渠道【wxpay、alipay】
|
||||
*/
|
||||
@Schema(description = "支付渠道【wxpay、alipay】")
|
||||
private String channel;
|
||||
/**
|
||||
* 买家ID
|
||||
*/
|
||||
@Schema(description = "买家ID")
|
||||
private String buyerId;
|
||||
/**
|
||||
* 0:未支付、1:已支付
|
||||
*/
|
||||
@Schema(description = "0:未支付、1:已支付")
|
||||
private Integer status;
|
||||
/**
|
||||
* 第三方支付单号
|
||||
*/
|
||||
@Schema(description = "第三方支付单号")
|
||||
private String payNo;
|
||||
/**
|
||||
* 支付时间
|
||||
*/
|
||||
@Schema(description = "支付时间")
|
||||
private String payTime;
|
||||
/**
|
||||
* 是否退款【0:否、1:是】
|
||||
*/
|
||||
@Schema(description = "是否退款【0:否、1:是】")
|
||||
private Integer isRefund;
|
||||
/**
|
||||
* 已退款金额
|
||||
*/
|
||||
@Schema(description = "已退款金额")
|
||||
private String refundMoney;
|
||||
/**
|
||||
* 异步回调地址
|
||||
*/
|
||||
@Schema(description = "异步回调地址")
|
||||
private String notifyUrl;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
83
src/main/java/org/springblade/plugin/pay/entity/Refund.java
Normal file
83
src/main/java/org/springblade/plugin/pay/entity/Refund.java
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the dreamlu.net developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: Chill 庄骞 (smallchill@163.com)
|
||||
*/
|
||||
package org.springblade.plugin.pay.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
|
||||
/**
|
||||
* 订单退款表实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2022-01-03
|
||||
*/
|
||||
@Data
|
||||
@TableName("blade_pay_order_refund")
|
||||
@Schema(description = "订单退款表")
|
||||
public class Refund extends BaseEntity {
|
||||
|
||||
private Long id;
|
||||
/**
|
||||
* 退款单号
|
||||
*/
|
||||
@Schema(description = "退款单号")
|
||||
private String refundNo;
|
||||
/**
|
||||
* 业务订单
|
||||
*/
|
||||
@Schema(description = "业务订单")
|
||||
private String orderNo;
|
||||
/**
|
||||
* 支付单号
|
||||
*/
|
||||
@Schema(description = "支付单号")
|
||||
private String payNo;
|
||||
/**
|
||||
* 退款商户
|
||||
*/
|
||||
@Schema(description = "退款商户")
|
||||
private String refundMchId;
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
@Schema(description = "退款金额")
|
||||
private String refundMoney;
|
||||
/**
|
||||
* 退款原因
|
||||
*/
|
||||
@Schema(description = "退款原因")
|
||||
private String refundDesc;
|
||||
/**
|
||||
* 退款状态 -1:退款失败 0:已发起 1:退款成功
|
||||
*/
|
||||
@Schema(description = "退款状态 -1:退款失败 0:已发起 1:退款成功")
|
||||
private Integer status;
|
||||
/**
|
||||
* 退款回调地址
|
||||
*/
|
||||
@Schema(description = "退款回调地址 ")
|
||||
private String notifyUrl;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the dreamlu.net developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: Chill 庄骞 (smallchill@163.com)
|
||||
*/
|
||||
package org.springblade.plugin.pay.entity;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.ijpay.core.kit.RsaKit;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springblade.core.mp.base.BaseEntity;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.security.PrivateKey;
|
||||
|
||||
/**
|
||||
* 实体类
|
||||
*
|
||||
* @author BladeX
|
||||
* @since 2021-12-31
|
||||
*/
|
||||
@Data
|
||||
@TableName("blade_pay_wxpay_account_config")
|
||||
@Schema(description = "WxPayAccountConfig对象")
|
||||
public class WxPayAccountConfig extends BaseEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 商户号
|
||||
*/
|
||||
@Schema(description = "商户号")
|
||||
private String mchId;
|
||||
|
||||
/**
|
||||
* 支付密钥
|
||||
*/
|
||||
@Schema(description = "支付密钥")
|
||||
private String payKey;
|
||||
/**
|
||||
* 收款名称
|
||||
*/
|
||||
@Schema(description = "收款名称")
|
||||
private String payName;
|
||||
|
||||
/**
|
||||
* V3密钥
|
||||
*/
|
||||
@Schema(description = "V3密钥")
|
||||
private String v3Key;
|
||||
|
||||
/**
|
||||
* API类型【0:普通】
|
||||
*/
|
||||
@Schema(description = "API类型【0:普通】")
|
||||
private Integer apiType;
|
||||
/**
|
||||
* 统一支付回调地址
|
||||
*/
|
||||
@Schema(description = "统一支付回调地址")
|
||||
private String notifyUrl;
|
||||
/**
|
||||
* 统一退款回调
|
||||
*/
|
||||
@Schema(description = "统一退款回调")
|
||||
private String refundNotifyUrl;
|
||||
/**
|
||||
* 聚合收银台URL
|
||||
*/
|
||||
@Schema(description = "聚合收银台URL")
|
||||
private String cashierUrl;
|
||||
/**
|
||||
* 微信证书pem文件
|
||||
*/
|
||||
@Schema(description = "微信证书pem文件")
|
||||
private String certPem;
|
||||
/**
|
||||
* 微信正式p12文件
|
||||
*/
|
||||
@Schema(description = "微信正式p12文件")
|
||||
private String certPkcs;
|
||||
/**
|
||||
* 微信证书公钥
|
||||
*/
|
||||
@Schema(description = "微信证书公钥")
|
||||
private String certPubKey;
|
||||
/**
|
||||
* 微信证书私钥
|
||||
*/
|
||||
@Schema(description = "微信证书私钥")
|
||||
private String certPrivateKey;
|
||||
/**
|
||||
* 商户 API 证书序列号
|
||||
*/
|
||||
@Schema(description = "商户 API 证书序列号")
|
||||
private String certSerialNo;
|
||||
/**
|
||||
* 平台序列号
|
||||
*/
|
||||
@Schema(description = "平台序列号")
|
||||
private String certPlatSerialNo;
|
||||
|
||||
/**
|
||||
* 微信支付公钥
|
||||
*/
|
||||
@Schema(description = "微信支付公钥")
|
||||
private String wxPubKey;
|
||||
|
||||
/**
|
||||
* 微信支付公钥ID
|
||||
*/
|
||||
@Schema(description = "微信支付公钥ID")
|
||||
private String wxPubKeyId;
|
||||
|
||||
|
||||
/**
|
||||
* 状态【0:关闭、1:启用】
|
||||
*/
|
||||
@Schema(description = "状态【0:关闭、1:启用】")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 微信私钥
|
||||
*/
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private PrivateKey privateKey;
|
||||
|
||||
/**
|
||||
* P12 流
|
||||
*/
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private ByteArrayInputStream certPkcsStream;
|
||||
|
||||
/**
|
||||
* 公钥流
|
||||
*/
|
||||
@JsonIgnore
|
||||
@TableField(exist = false)
|
||||
private ByteArrayInputStream certPubKeyStream;
|
||||
|
||||
/**
|
||||
* 接口交互证书临时路径
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String wxPayCertFile;
|
||||
|
||||
/**
|
||||
* 接口交互证书临时路径
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String wxPayPkCsFile;
|
||||
|
||||
/**
|
||||
* 接口交互证书临时路径
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String wxPayPrivateKeyFile;
|
||||
|
||||
/**
|
||||
* 接口交互微信公钥证书临时路径
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String wxPubKeyFile;
|
||||
|
||||
|
||||
public PrivateKey getPrivateKey() {
|
||||
if (!StringUtils.isBlank(certPrivateKey)) {
|
||||
try {
|
||||
String privateKeyStr = certPrivateKey.replace("-----BEGIN PRIVATE KEY-----", "").replace("-----END PRIVATE KEY-----", "").replaceAll("\\s+", "");
|
||||
privateKey = RsaKit.loadPrivateKey(privateKeyStr);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("微信私钥证书格式错误");
|
||||
}
|
||||
}
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
public ByteArrayInputStream getCertPkcsStream() {
|
||||
if (!StringUtils.isBlank(certPkcs)) {
|
||||
try {
|
||||
byte[] decode = Base64.decode(certPkcs);
|
||||
ByteArrayInputStream stream = new ByteArrayInputStream(decode);
|
||||
certPkcsStream = stream;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("微信p12证书格式错误");
|
||||
}
|
||||
}
|
||||
return certPkcsStream;
|
||||
}
|
||||
|
||||
public ByteArrayInputStream getCertPubKeyStream() {
|
||||
if (!StringUtils.isBlank(certPubKey)) {
|
||||
try {
|
||||
ByteArrayInputStream stream = new ByteArrayInputStream(certPubKey.getBytes());
|
||||
certPubKeyStream = stream;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("微信公钥证书格式错误");
|
||||
}
|
||||
}
|
||||
return certPubKeyStream;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user