Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
04f53da6
提交
04f53da6
authored
11月 29, 2020
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
将支付成功、退款成功的 MQ 消费逻辑进行迁移
上级
63b4c27c
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
139 行增加
和
409 行删除
+139
-409
PayRefundMapper.java
...ain/java/cn/iocoder/mall/pay/biz/dao/PayRefundMapper.java
+0
-38
PayTransactionMapper.java
...ava/cn/iocoder/mall/pay/biz/dao/PayTransactionMapper.java
+0
-38
PayRefundMapper.xml
...application/src/main/resources/mapper/PayRefundMapper.xml
+0
-122
PayTransactionExtensionMapper.xml
...c/main/resources/mapper/PayTransactionExtensionMapper.xml
+0
-25
PayTransactionMapper.xml
...cation/src/main/resources/mapper/PayTransactionMapper.xml
+0
-128
PayRefundStatus.java
...iocoder/mall/payservice/enums/refund/PayRefundStatus.java
+6
-21
DubboReferencePool.java
...oder/mall/payservice/common/dubbo/DubboReferencePool.java
+3
-3
package-info.java
.../java/cn/iocoder/mall/payservice/common/package-info.java
+1
-0
PayRefundDO.java
...l/payservice/dal/mysql/dataobject/refund/PayRefundDO.java
+2
-1
PayRefundMapper.java
...l/payservice/dal/mysql/mapper/refund/PayRefundMapper.java
+57
-0
PayTransactionMapper.java
...ce/dal/mysql/mapper/transaction/PayTransactionMapper.java
+36
-0
AbstractPayNotifySuccessMQConsumer.java
...rvice/mq/consumer/AbstractPayNotifySuccessMQConsumer.java
+20
-18
PayRefundSuccessMQConsumer.java
...ll/payservice/mq/consumer/PayRefundSuccessMQConsumer.java
+7
-8
PayTransactionSuccessMQConsumer.java
...yservice/mq/consumer/PayTransactionSuccessMQConsumer.java
+7
-7
没有找到文件。
moved/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/dao/PayRefundMapper.java
deleted
100644 → 0
浏览文件 @
63b4c27c
package
cn
.
iocoder
.
mall
.
pay
.
biz
.
dao
;
import
cn.iocoder.mall.pay.biz.dataobject.PayRefundDO
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.Date
;
import
java.util.List
;
@Repository
public
interface
PayRefundMapper
{
void
insert
(
PayRefundDO
entity
);
int
update
(
@Param
(
"entity"
)
PayRefundDO
entity
,
@Param
(
"whereStatus"
)
Integer
whereStatus
);
PayRefundDO
selectById
(
@Param
(
"id"
)
Integer
id
);
PayRefundDO
selectByRefundCode
(
@Param
(
"refundCode"
)
String
refundCode
);
List
<
PayRefundDO
>
selectListByPage
(
@Param
(
"createBeginTime"
)
Date
createBeginTime
,
@Param
(
"createEndTime"
)
Date
createEndTime
,
@Param
(
"finishBeginTime"
)
Date
finishBeginTime
,
@Param
(
"finishEndTime"
)
Date
finishEndTime
,
@Param
(
"status"
)
Integer
status
,
@Param
(
"payChannel"
)
Integer
payChannel
,
@Param
(
"offset"
)
Integer
offset
,
@Param
(
"limit"
)
Integer
limit
);
Integer
selectCountByPage
(
@Param
(
"createBeginTime"
)
Date
createBeginTime
,
@Param
(
"createEndTime"
)
Date
createEndTime
,
@Param
(
"finishBeginTime"
)
Date
finishBeginTime
,
@Param
(
"finishEndTime"
)
Date
finishEndTime
,
@Param
(
"status"
)
Integer
status
,
@Param
(
"payChannel"
)
Integer
payChannel
);
}
moved/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/dao/PayTransactionMapper.java
deleted
100644 → 0
浏览文件 @
63b4c27c
package
cn
.
iocoder
.
mall
.
pay
.
biz
.
dao
;
import
cn.iocoder.mall.pay.biz.dataobject.PayTransactionDO
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.stereotype.Repository
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.List
;
@Repository
public
interface
PayTransactionMapper
{
int
updateForRefundTotal
(
@Param
(
"id"
)
Integer
id
,
@Param
(
"refundTotalIncr"
)
Integer
refundTotalIncr
);
List
<
PayTransactionDO
>
selectListByPage
(
@Param
(
"createBeginTime"
)
Date
createBeginTime
,
@Param
(
"createEndTime"
)
Date
createEndTime
,
@Param
(
"paymentBeginTime"
)
Date
paymentBeginTime
,
@Param
(
"paymentEndTime"
)
Date
paymentEndTime
,
@Param
(
"status"
)
Integer
status
,
@Param
(
"hasRefund"
)
Boolean
hasRefund
,
@Param
(
"payChannel"
)
Integer
payChannel
,
@Param
(
"orderSubject"
)
String
orderSubject
,
@Param
(
"offset"
)
Integer
offset
,
@Param
(
"limit"
)
Integer
limit
);
Integer
selectCountByPage
(
@Param
(
"createBeginTime"
)
Date
createBeginTime
,
@Param
(
"createEndTime"
)
Date
createEndTime
,
@Param
(
"paymentBeginTime"
)
Date
paymentBeginTime
,
@Param
(
"paymentEndTime"
)
Date
paymentEndTime
,
@Param
(
"status"
)
Integer
status
,
@Param
(
"hasRefund"
)
Boolean
hasRefund
,
@Param
(
"payChannel"
)
Integer
payChannel
,
@Param
(
"orderSubject"
)
String
orderSubject
);
}
moved/pay/pay-application/src/main/resources/mapper/PayRefundMapper.xml
deleted
100644 → 0
浏览文件 @
63b4c27c
<?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=
"cn.iocoder.mall.pay.biz.dao.PayRefundMapper"
>
<sql
id=
"FIELDS"
>
id, transaction_id, refund_code, app_id, create_ip, order_id,
order_description, price, status,
finish_time, notify_url, extension_data, refund_channel, refund_time, notify_time,
trade_no, create_time
</sql>
<insert
id=
"insert"
parameterType=
"PayRefundDO"
useGeneratedKeys=
"true"
keyColumn=
"id"
keyProperty=
"id"
>
INSERT INTO refund (
transaction_id, refund_code, app_id, create_ip, order_id,
order_description, price, status,
finish_time, notify_url, extension_data, refund_channel, refund_time, notify_time,
trade_no, create_time
) VALUES (
#{transactionId}, #{refundCode}, #{appId}, #{createIp}, #{orderId},
#{orderDescription}, #{price}, #{status},
#{finishTime}, #{notifyUrl}, #{extensionData}, #{refundChannel}, #{refundTime}, #{notifyTime},
#{tradeNo}, #{createTime}
)
</insert>
<update
id=
"update"
>
UPDATE refund
<set>
<if
test=
"entity.status != null"
>
, status = #{entity.status}
</if>
<if
test=
"entity.finishTime != null"
>
, finish_time = #{entity.finishTime}
</if>
<if
test=
"entity.extensionData != null"
>
, extension_data = #{entity.extensionData}
</if>
<if
test=
"entity.refundTime != null"
>
, refund_time = #{entity.refundTime}
</if>
<if
test=
"entity.notifyTime != null"
>
, notify_time = #{entity.notifyTime}
</if>
<if
test=
"entity.tradeNo != null"
>
, trade_no = #{entity.tradeNo}
</if>
</set>
WHERE id = #{entity.id}
<if
test=
"whereStatus != null"
>
AND status = #{whereStatus}
</if>
</update>
<select
id=
"selectByRefundCode"
parameterType=
"String"
resultType=
"PayRefundDO"
>
SELECT
<include
refid=
"FIELDS"
/>
FROM refund
WHERE refund_code = #{refundCode}
LIMIT 1
</select>
<select
id=
"selectById"
parameterType=
"Integer"
resultType=
"PayRefundDO"
>
SELECT
<include
refid=
"FIELDS"
/>
FROM refund
WHERE id = #{id}
</select>
<select
id=
"selectListByPage"
resultType=
"PayRefundDO"
>
SELECT
<include
refid=
"FIELDS"
/>
FROM refund
<where>
<if
test=
"createBeginTime != null"
>
AND create_time >= #{createBeginTime}
</if>
<if
test=
"createEndTime != null"
>
AND #{createEndTime} >= create_time
</if>
<if
test=
"finishBeginTime != null"
>
AND finish_time >= #{finishBeginTime}
</if>
<if
test=
"finishEndTime != null"
>
AND #{finishEndTime} >= finish_time
</if>
<if
test=
"status != null"
>
AND status = #{status}
</if>
<if
test=
"payChannel != null"
>
AND pay_channel = #{payChannel}
</if>
</where>
LIMIT #{offset}, #{limit}
</select>
<select
id=
"selectCountByPage"
resultType=
"Integer"
>
SELECT
COUNT(1)
FROM refund
<where>
<if
test=
"createBeginTime != null"
>
AND create_time >= #{createBeginTime}
</if>
<if
test=
"createEndTime != null"
>
AND #{createEndTime} >= create_time
</if>
<if
test=
"finishBeginTime != null"
>
AND finish_time >= #{finishBeginTime}
</if>
<if
test=
"finishEndTime != null"
>
AND #{finishEndTime} >= finish_time
</if>
<if
test=
"status != null"
>
AND status = #{status}
</if>
<if
test=
"payChannel != null"
>
AND pay_channel = #{payChannel}
</if>
</where>
</select>
</mapper>
moved/pay/pay-application/src/main/resources/mapper/PayTransactionExtensionMapper.xml
deleted
100644 → 0
浏览文件 @
63b4c27c
<?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=
"cn.iocoder.mall.pay.biz.dao.PayTransactionExtensionMapper"
>
<sql
id=
"FIELDS"
>
id, transaction_id, pay_channel, transaction_code, extension_data,
create_ip, status, create_time
</sql>
<select
id=
"selectByTransactionCode"
parameterType=
"String"
resultType=
"PayTransactionExtensionDO"
>
SELECT
<include
refid=
"FIELDS"
/>
FROM transaction_extension
WHERE transaction_code = #{transactionCode}
LIMIT 1
</select>
<select
id=
"selectById"
parameterType=
"Integer"
resultType=
"PayTransactionExtensionDO"
>
SELECT
<include
refid=
"FIELDS"
/>
FROM transaction_extension
WHERE id = #{id}
</select>
</mapper>
moved/pay/pay-application/src/main/resources/mapper/PayTransactionMapper.xml
deleted
100644 → 0
浏览文件 @
63b4c27c
<?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=
"cn.iocoder.mall.pay.biz.dao.PayTransactionMapper"
>
<sql
id=
"FIELDS"
>
id, app_id, create_ip, order_id, order_subject,
order_description, order_memo, price, status, expire_time,
finish_time, notify_url, extension_id, pay_channel, payment_time,
notify_time, trade_no, refund_total, create_time
</sql>
<update
id=
"update"
>
UPDATE transaction
<set>
<if
test=
"entity.status != null"
>
, status = #{entity.status}
</if>
<if
test=
"entity.extensionId != null"
>
, extension_id = #{entity.extensionId}
</if>
<if
test=
"entity.payChannel != null"
>
, pay_channel = #{entity.payChannel}
</if>
<if
test=
"entity.paymentTime != null"
>
, payment_time = #{entity.paymentTime}
</if>
<if
test=
"entity.finishTime != null"
>
, finish_time = #{entity.finishTime}
</if>
<if
test=
"entity.notifyTime != null"
>
, notify_time = #{entity.notifyTime}
</if>
<if
test=
"entity.tradeNo != null"
>
, trade_no = #{entity.tradeNo}
</if>
</set>
WHERE id = #{entity.id}
<if
test=
"whereStatus != null"
>
AND status = #{whereStatus}
</if>
</update>
<update
id=
"updateForRefundTotal"
>
UPDATE `transaction`
SET refund_total = refund_total + ${refundTotalIncr}
WHERE price >= refund_total + ${refundTotalIncr}
</update>
<select
id=
"selectByAppIdAndOrderId"
resultType=
"PayTransactionDO"
>
SELECT
<include
refid=
"FIELDS"
/>
FROM transaction
WHERE app_id = #{appId}
AND order_id = #{orderId}
</select>
<select
id=
"selectListByPage"
resultType=
"PayTransactionDO"
>
SELECT
<include
refid=
"FIELDS"
/>
FROM transaction
<where>
<if
test=
"createBeginTime != null"
>
AND create_time >= #{createBeginTime}
</if>
<if
test=
"createEndTime != null"
>
AND #{createEndTime} >= create_time
</if>
<if
test=
"paymentBeginTime != null"
>
AND payment_time >= #{paymentBeginTime}
</if>
<if
test=
"paymentEndTime != null"
>
AND #{paymentEndTime} >= payment_time
</if>
<if
test=
"status != null"
>
AND status = #{status}
</if>
<if
test=
"hasRefund == true"
>
AND refund_total > 0
</if>
<if
test=
"hasRefund == false"
>
AND refund_total = 0
</if>
<if
test=
"payChannel != null"
>
AND pay_channel = #{payChannel}
</if>
<if
test=
"orderSubject != null"
>
order_subject LIKE "%"#{orderSubject}"%"
</if>
</where>
LIMIT #{offset}, #{limit}
</select>
<select
id=
"selectCountByPage"
resultType=
"Integer"
>
SELECT
COUNT(1)
FROM transaction
<where>
<if
test=
"createBeginTime != null"
>
AND create_time >= #{createBeginTime}
</if>
<if
test=
"createEndTime != null"
>
AND #{createEndTime} >= create_time
</if>
<if
test=
"paymentBeginTime != null"
>
AND payment_time >= #{paymentBeginTime}
</if>
<if
test=
"paymentEndTime != null"
>
AND #{paymentEndTime} >= payment_time
</if>
<if
test=
"status != null"
>
AND status = #{status}
</if>
<if
test=
"hasRefund == true"
>
AND refund_total > 0
</if>
<if
test=
"hasRefund == false"
>
AND refund_total = 0
</if>
<if
test=
"payChannel != null"
>
AND pay_channel = #{payChannel}
</if>
<if
test=
"orderSubject != null"
>
order_subject LIKE "%"#{orderSubject}"%"
</if>
</where>
</select>
</mapper>
moved/pay/pay-application/src/main/java/cn/iocoder/mall/pay/api/constant
/PayRefundStatus.java
→
pay-service-project/pay-service-api/src/main/java/cn/iocoder/mall/payservice/enums/refund
/PayRefundStatus.java
浏览文件 @
04f53da6
package
cn
.
iocoder
.
mall
.
pay
.
api
.
constant
;
package
cn
.
iocoder
.
mall
.
payservice
.
enums
.
refund
;
import
lombok.Getter
;
/**
* 支付退款状态枚举
*/
@Getter
public
enum
PayRefundStatus
{
WAITING
(
1
,
"处理中"
),
...
...
@@ -13,33 +16,15 @@ public enum PayRefundStatus {
/**
* 状态
*/
private
Integer
value
;
private
final
Integer
value
;
/**
* 名字
*/
private
String
name
;
private
final
String
name
;
PayRefundStatus
(
Integer
value
,
String
name
)
{
this
.
value
=
value
;
this
.
name
=
name
;
}
public
Integer
getValue
()
{
return
value
;
}
public
PayRefundStatus
setValue
(
Integer
value
)
{
this
.
value
=
value
;
return
this
;
}
public
String
getName
()
{
return
name
;
}
public
PayRefundStatus
setName
(
String
name
)
{
this
.
name
=
name
;
return
this
;
}
}
moved/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/component
/DubboReferencePool.java
→
pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/common/dubbo
/DubboReferencePool.java
浏览文件 @
04f53da6
package
cn
.
iocoder
.
mall
.
pay
.
biz
.
component
;
package
cn
.
iocoder
.
mall
.
pay
service
.
common
.
dubbo
;
import
cn.iocoder.common.framework.util.StringUtil
;
import
cn.iocoder.common.framework.util.StringUtil
s
;
import
com.google.common.cache.CacheBuilder
;
import
com.google.common.cache.CacheLoader
;
import
com.google.common.cache.LoadingCache
;
...
...
@@ -48,7 +48,7 @@ public class DubboReferencePool {
private
ReferenceMeta
createGenericService
(
String
notifyUrl
)
{
// 使用 # 号分隔,格式为 服务名#方法名#版本号
List
<
String
>
notifyUrlParts
=
StringUtil
.
split
(
notifyUrl
,
"#"
);
List
<
String
>
notifyUrlParts
=
StringUtil
s
.
split
(
notifyUrl
,
"#"
);
// 创建 ApplicationConfig 对象
ApplicationConfig
application
=
new
ApplicationConfig
();
application
.
setName
(
dubboApplicationName
);
...
...
pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/common/package-info.java
0 → 100644
浏览文件 @
04f53da6
package
cn
.
iocoder
.
mall
.
payservice
.
common
;
pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/dataobject/refund/PayRefundDO.java
浏览文件 @
04f53da6
package
cn
.
iocoder
.
mall
.
payservice
.
dal
.
mysql
.
dataobject
.
refund
;
import
cn.iocoder.mall.mybatis.core.dataobject.DeletableDO
;
import
cn.iocoder.mall.payservice.enums.refund.PayRefundStatus
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
...
...
@@ -68,7 +69,7 @@ public class PayRefundDO extends DeletableDO {
/**
* 退款状态
*
*
@see cn.iocoder.mall.pay.api.constant.PayRefundStatus
*
外键 {@link PayRefundStatus}
*/
private
Integer
status
;
/**
...
...
pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/mapper/refund/PayRefundMapper.java
0 → 100644
浏览文件 @
04f53da6
package
cn
.
iocoder
.
mall
.
payservice
.
dal
.
mysql
.
mapper
.
refund
;
import
cn.iocoder.mall.payservice.dal.mysql.dataobject.refund.PayRefundDO
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.springframework.stereotype.Repository
;
@Repository
public
interface
PayRefundMapper
extends
BaseMapper
<
PayRefundDO
>
{
default
int
update
(
PayRefundDO
entity
,
Integer
whereStatus
)
{
return
update
(
entity
,
new
QueryWrapper
<
PayRefundDO
>()
.
eq
(
"id"
,
entity
.
getId
()).
eq
(
"status"
,
whereStatus
));
}
default
PayRefundDO
selectByRefundCode
(
String
refundCode
)
{
return
selectOne
(
new
QueryWrapper
<
PayRefundDO
>()
.
eq
(
"refund_code"
,
refundCode
));
}
// <if test="createBeginTime != null">
// AND create_time >= #{createBeginTime}
// </if>
// <if test="createEndTime != null">
// AND #{createEndTime} >= create_time
// </if>
// <if test="finishBeginTime != null">
// AND finish_time >= #{finishBeginTime}
// </if>
// <if test="finishEndTime != null">
// AND #{finishEndTime} >= finish_time
// </if>
// <if test="status != null">
// AND status = #{status}
// </if>
// <if test="payChannel != null">
// AND pay_channel = #{payChannel}
// </if>
// List<PayRefundDO> selectListByPage(@Param("createBeginTime") Date createBeginTime,
// @Param("createEndTime") Date createEndTime,
// @Param("finishBeginTime") Date finishBeginTime,
// @Param("finishEndTime") Date finishEndTime,
// @Param("status") Integer status,
// @Param("payChannel") Integer payChannel,
// @Param("offset") Integer offset,
// @Param("limit") Integer limit);
//
// Integer selectCountByPage(@Param("createBeginTime") Date createBeginTime,
// @Param("createEndTime") Date createEndTime,
// @Param("finishBeginTime") Date finishBeginTime,
// @Param("finishEndTime") Date finishEndTime,
// @Param("status") Integer status,
// @Param("payChannel") Integer payChannel);
}
pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/dal/mysql/mapper/transaction/PayTransactionMapper.java
浏览文件 @
04f53da6
...
...
@@ -7,6 +7,42 @@ import org.springframework.stereotype.Repository;
@Repository
public
interface
PayTransactionMapper
extends
BaseMapper
<
PayTransactionDO
>
{
//
// UPDATE `transaction`
// SET refund_total = refund_total + ${refundTotalIncr}
// WHERE price >= refund_total + ${refundTotalIncr}
//
// int updateForRefundTotal(@Param("id") Integer id,
// @Param("refundTotalIncr") Integer refundTotalIncr);
// <if test="createBeginTime != null">
// AND create_time >= #{createBeginTime}
// </if>
// <if test="createEndTime != null">
// AND #{createEndTime} >= create_time
// </if>
// <if test="paymentBeginTime != null">
// AND payment_time >= #{paymentBeginTime}
// </if>
// <if test="paymentEndTime != null">
// AND #{paymentEndTime} >= payment_time
// </if>
// <if test="status != null">
// AND status = #{status}
// </if>
// <if test="hasRefund == true">
// AND refund_total > 0
// </if>
// <if test="hasRefund == false">
// AND refund_total = 0
// </if>
// <if test="payChannel != null">
// AND pay_channel = #{payChannel}
// </if>
// <if test="orderSubject != null">
// order_subject LIKE "%"#{orderSubject}"%"
// </if>
// default IPage<PayTransactionDO> selectPage(TransactionPageBO pageBO) {
// return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
...
...
moved/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/mq/AbstractPayNotifySuccess
Consumer.java
→
pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/mq/consumer/AbstractPayNotifySuccessMQ
Consumer.java
浏览文件 @
04f53da6
package
cn
.
iocoder
.
mall
.
pay
.
biz
.
mq
;
package
cn
.
iocoder
.
mall
.
pay
service
.
mq
.
consumer
;
import
cn.iocoder.common.framework.util.DateUtil
;
import
cn.iocoder.common.framework.util.ExceptionUtil
;
import
cn.iocoder.mall.pay
.api.constant.PayTransactionNotifyStatusEnum
;
import
cn.iocoder.mall.pay
.api.message.AbstractPayNotifySuccessMessage
;
import
cn.iocoder.mall.pay
.biz.component.DubboReferencePool
;
import
cn.iocoder.mall.pay
.biz.dao
.PayNotifyLogMapper
;
import
cn.iocoder.mall.pay
.biz.dao
.PayNotifyTaskMapper
;
import
cn.iocoder.mall.pay
.biz.dataobject.PayNotifyLogDO
;
import
cn.iocoder.mall.pay
.biz.dataobject.PayNotifyTaskDO
;
import
cn.iocoder.mall.pay
service.common.dubbo.DubboReferencePool
;
import
cn.iocoder.mall.pay
service.dal.mysql.dataobject.notify.PayNotifyLogDO
;
import
cn.iocoder.mall.pay
service.dal.mysql.dataobject.notify.PayNotifyTaskDO
;
import
cn.iocoder.mall.pay
service.dal.mysql.mapper.notify
.PayNotifyLogMapper
;
import
cn.iocoder.mall.pay
service.dal.mysql.mapper.notify
.PayNotifyTaskMapper
;
import
cn.iocoder.mall.pay
service.enums.notify.PayNotifyStatusEnum
;
import
cn.iocoder.mall.pay
service.mq.producer.message.AbstractPayNotifySuccessMessage
;
import
com.alibaba.fastjson.JSON
;
import
org.apache.rocketmq.spring.core.RocketMQListener
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -17,13 +17,13 @@ import org.springframework.transaction.annotation.Transactional;
import
java.util.Calendar
;
import
java.util.Date
;
public
abstract
class
AbstractPayNotifySuccessConsumer
<
T
extends
AbstractPayNotifySuccessMessage
>
implements
RocketMQListener
<
T
>
{
public
abstract
class
AbstractPayNotifySuccess
MQ
Consumer
<
T
extends
AbstractPayNotifySuccessMessage
>
implements
RocketMQListener
<
T
>
{
@Autowired
private
DubboReferencePool
dubboReferencePool
;
@Autowired
private
PayNotifyTaskMapper
pay
Transaction
NotifyTaskMapper
;
private
PayNotifyTaskMapper
payNotifyTaskMapper
;
@Autowired
private
PayNotifyLogMapper
payTransactionNotifyLogMapper
;
...
...
@@ -39,25 +39,27 @@ public abstract class AbstractPayNotifySuccessConsumer<T extends AbstractPayNoti
.
setLastExecuteTime
(
new
Date
())
.
setNotifyTimes
(
message
.
getNotifyTimes
()
+
1
);
try
{
// TODO 芋艿,这里要优化下,不要在事务里,进行 RPC 调用
response
=
invoke
(
message
,
referenceMeta
);
if
(
"success"
.
equals
(
response
))
{
// 情况一,请求成功且返回成功
// 更新通知成功
updateTask
.
setStatus
(
Pay
TransactionNotifyStatusEnum
.
SUCCESS
.
getValue
());
pay
TransactionNotifyTaskMapper
.
update
(
updateTask
);
updateTask
.
setStatus
(
Pay
NotifyStatusEnum
.
SUCCESS
.
getStatus
());
pay
NotifyTaskMapper
.
updateById
(
updateTask
);
// 需要更新支付交易单通知应用成功
afterInvokeSuccess
(
message
);
}
else
{
// 情况二,请求成功且返回失败
// 更新通知请求成功,但是结果失败
handleFailure
(
updateTask
,
Pay
TransactionNotifyStatusEnum
.
REQUEST_SUCCESS
.
getValue
());
pay
TransactionNotifyTaskMapper
.
update
(
updateTask
);
handleFailure
(
updateTask
,
Pay
NotifyStatusEnum
.
REQUEST_SUCCESS
.
getStatus
());
pay
NotifyTaskMapper
.
updateById
(
updateTask
);
}
}
catch
(
Throwable
e
)
{
// 请求失败
// 更新通知请求失败
response
=
ExceptionUtil
.
getRootCauseMessage
(
e
);
handleFailure
(
updateTask
,
Pay
TransactionNotifyStatusEnum
.
REQUEST_FAILURE
.
getValue
());
pay
TransactionNotifyTaskMapper
.
update
(
updateTask
);
handleFailure
(
updateTask
,
Pay
NotifyStatusEnum
.
REQUEST_FAILURE
.
getStatus
());
pay
NotifyTaskMapper
.
updateById
(
updateTask
);
// 抛出异常,回滚事务
throw
e
;
// TODO 芋艿,此处不能抛出异常。因为,会导致 MQ + 定时任务多重试。此处的目标是,事务回滚 + 吃掉事务。另外,最后的 finally 的日志,要插入成功。
// TODO 芋艿,此处不能抛出异常。因为,会导致 MQ + 定时任务多重试。此处的目标是,事务回滚 + 吃掉事务。另外,最后的 finally 的日志,要插入成功。
// throw e;
}
finally
{
// 插入 PayTransactionNotifyLogDO 日志
PayNotifyLogDO
notifyLog
=
new
PayNotifyLogDO
().
setNotifyId
(
message
.
getId
())
...
...
@@ -68,7 +70,7 @@ public abstract class AbstractPayNotifySuccessConsumer<T extends AbstractPayNoti
private
void
handleFailure
(
PayNotifyTaskDO
updateTask
,
Integer
defaultStatus
)
{
if
(
updateTask
.
getNotifyTimes
()
>=
PayNotifyTaskDO
.
NOTIFY_FREQUENCY
.
length
)
{
updateTask
.
setStatus
(
Pay
TransactionNotifyStatusEnum
.
FAILURE
.
getValue
());
updateTask
.
setStatus
(
Pay
NotifyStatusEnum
.
FAILURE
.
getStatus
());
}
else
{
updateTask
.
setNextNotifyTime
(
DateUtil
.
addDate
(
Calendar
.
SECOND
,
PayNotifyTaskDO
.
NOTIFY_FREQUENCY
[
updateTask
.
getNotifyTimes
()]));
updateTask
.
setStatus
(
defaultStatus
);
...
...
moved/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/mq/PayRefundSuccess
Consumer.java
→
pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/mq/consumer/PayRefundSuccessMQ
Consumer.java
浏览文件 @
04f53da6
package
cn
.
iocoder
.
mall
.
pay
.
biz
.
mq
;
package
cn
.
iocoder
.
mall
.
pay
service
.
mq
.
consumer
;
import
cn.iocoder.mall.pay
.api.message.PayRefundSuccessMessage
;
import
cn.iocoder.mall.pay
.biz.component.DubboReferencePool
;
import
cn.iocoder.mall.pay
.biz.dao
.PayRefundMapper
;
import
cn.iocoder.mall.pay
.biz.dataobject.PayRefundDO
;
import
cn.iocoder.mall.pay
service.common.dubbo.DubboReferencePool
;
import
cn.iocoder.mall.pay
service.dal.mysql.dataobject.refund.PayRefundDO
;
import
cn.iocoder.mall.pay
service.dal.mysql.mapper.refund
.PayRefundMapper
;
import
cn.iocoder.mall.pay
service.mq.producer.message.PayRefundSuccessMessage
;
import
org.apache.dubbo.rpc.service.GenericService
;
import
org.apache.rocketmq.spring.annotation.RocketMQMessageListener
;
import
org.apache.rocketmq.spring.core.RocketMQListener
;
...
...
@@ -18,8 +18,7 @@ import java.util.Date;
topic
=
PayRefundSuccessMessage
.
TOPIC
,
consumerGroup
=
"pay-consumer-group-"
+
PayRefundSuccessMessage
.
TOPIC
)
@Deprecated
// 艿艿:突然发现,业务方实际无需回调。参考了 https://help.youzan.com/displaylist/detail_4_998 的文章。业务方,只要记录下退款单号,进行关联即可。
public
class
PayRefundSuccessConsumer
extends
AbstractPayNotifySuccessConsumer
<
PayRefundSuccessMessage
>
public
class
PayRefundSuccessMQConsumer
extends
AbstractPayNotifySuccessMQConsumer
<
PayRefundSuccessMessage
>
implements
RocketMQListener
<
PayRefundSuccessMessage
>
{
@Autowired
...
...
@@ -40,7 +39,7 @@ public class PayRefundSuccessConsumer extends AbstractPayNotifySuccessConsumer<P
@Override
protected
void
afterInvokeSuccess
(
PayRefundSuccessMessage
message
)
{
PayRefundDO
updateRefund
=
new
PayRefundDO
().
setId
(
message
.
getRefundId
()).
setFinishTime
(
new
Date
());
payRefundMapper
.
update
(
updateRefund
,
null
);
payRefundMapper
.
update
ById
(
updateRefund
);
}
}
moved/pay/pay-application/src/main/java/cn/iocoder/mall/pay/biz/mq/PayTransactionSuccess
Consumer.java
→
pay-service-project/pay-service-app/src/main/java/cn/iocoder/mall/payservice/mq/consumer/PayTransactionSuccessMQ
Consumer.java
浏览文件 @
04f53da6
package
cn
.
iocoder
.
mall
.
pay
.
biz
.
mq
;
package
cn
.
iocoder
.
mall
.
pay
service
.
mq
.
consumer
;
import
cn.iocoder.mall.pay
.api.message.PayTransactionSuccessMessage
;
import
cn.iocoder.mall.pay
.biz.component.DubboReferencePool
;
import
cn.iocoder.mall.pay
.biz.dao
.PayTransactionMapper
;
import
cn.iocoder.mall.pay
.biz.dataobject.PayTransactionDO
;
import
cn.iocoder.mall.pay
service.common.dubbo.DubboReferencePool
;
import
cn.iocoder.mall.pay
service.dal.mysql.dataobject.transaction.PayTransactionDO
;
import
cn.iocoder.mall.pay
service.dal.mysql.mapper.transaction
.PayTransactionMapper
;
import
cn.iocoder.mall.pay
service.mq.producer.message.PayTransactionSuccessMessage
;
import
org.apache.dubbo.rpc.service.GenericService
;
import
org.apache.rocketmq.spring.annotation.RocketMQMessageListener
;
import
org.apache.rocketmq.spring.core.RocketMQListener
;
...
...
@@ -18,7 +18,7 @@ import java.util.Date;
topic
=
PayTransactionSuccessMessage
.
TOPIC
,
consumerGroup
=
"pay-consumer-group-"
+
PayTransactionSuccessMessage
.
TOPIC
)
public
class
PayTransactionSuccess
Consumer
extends
AbstractPayNotifySuccess
Consumer
<
PayTransactionSuccessMessage
>
public
class
PayTransactionSuccess
MQConsumer
extends
AbstractPayNotifySuccessMQ
Consumer
<
PayTransactionSuccessMessage
>
implements
RocketMQListener
<
PayTransactionSuccessMessage
>
{
@Autowired
...
...
@@ -39,7 +39,7 @@ public class PayTransactionSuccessConsumer extends AbstractPayNotifySuccessConsu
@Override
protected
void
afterInvokeSuccess
(
PayTransactionSuccessMessage
message
)
{
PayTransactionDO
updateTransaction
=
new
PayTransactionDO
().
setId
(
message
.
getTransactionId
()).
setFinishTime
(
new
Date
());
payTransactionMapper
.
update
(
updateTransaction
,
null
);
payTransactionMapper
.
update
ById
(
updateTransaction
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论