Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fzm-joying
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lei
fzm-joying
Commits
5cf5f779
Commit
5cf5f779
authored
Feb 09, 2022
by
tangtuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增退款 订单详情接口
parent
bde11b59
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
253 additions
and
26 deletions
+253
-26
PaymentController.java
...main/java/com/fzm/admin/controller/PaymentController.java
+2
-0
RefundController.java
.../main/java/com/fzm/admin/controller/RefundController.java
+55
-0
CopyrightTask.java
...n/src/main/java/com/fzm/admin/schedule/CopyrightTask.java
+2
-2
PaymentVo.java
...mon/src/main/java/com/fzm/common/entity/vo/PaymentVo.java
+3
-0
RefundLaunchChannel.java
...c/main/java/com/fzm/common/enums/RefundLaunchChannel.java
+25
-0
RefundMapper.java
...mon/src/main/java/com/fzm/common/mapper/RefundMapper.java
+8
-0
RefundService.java
...n/src/main/java/com/fzm/common/service/RefundService.java
+29
-0
WxPayService.java
...on/src/main/java/com/fzm/common/service/WxPayService.java
+3
-2
CopyrightApplyServiceImpl.java
...om/fzm/common/service/impl/CopyrightApplyServiceImpl.java
+3
-2
RefundServiceImpl.java
...n/java/com/fzm/common/service/impl/RefundServiceImpl.java
+39
-0
WxPayServiceImpl.java
...in/java/com/fzm/common/service/impl/WxPayServiceImpl.java
+11
-3
RefundMapper.xml
joying-common/src/main/resources/mapper/RefundMapper.xml
+44
-0
JoyingPortalApplication.java
...src/main/java/com/fzm/portal/JoyingPortalApplication.java
+2
-0
NftController.java
...rc/main/java/com/fzm/portal/controller/NftController.java
+10
-4
WxPayController.java
.../main/java/com/fzm/portal/controller/WxPayController.java
+2
-1
NftListener.java
...al/src/main/java/com/fzm/portal/listener/NftListener.java
+2
-5
OrderListener.java
.../src/main/java/com/fzm/portal/listener/OrderListener.java
+2
-1
PayTask.java
...portal/src/main/java/com/fzm/portal/schedule/PayTask.java
+11
-6
logback.2022-02-08.0.log
logs/logback.2022-02-08.0.log
+0
-0
logback.2022-02-09.0.log
logs/logback.2022-02-09.0.log
+0
-0
No files found.
joying-admin/src/main/java/com/fzm/admin/controller/PaymentController.java
View file @
5cf5f779
...
@@ -42,4 +42,6 @@ public class PaymentController {
...
@@ -42,4 +42,6 @@ public class PaymentController {
PageInfo
<
PaymentVo
>
pageInfo
=
paymentService
.
pages
(
pageNum
,
pageSize
,
name
,
telephone
,
orderName
,
type
,
payScene
,
start
,
end
);
PageInfo
<
PaymentVo
>
pageInfo
=
paymentService
.
pages
(
pageNum
,
pageSize
,
name
,
telephone
,
orderName
,
type
,
payScene
,
start
,
end
);
return
ResponseModel
.
success
(
pageInfo
);
return
ResponseModel
.
success
(
pageInfo
);
}
}
}
}
joying-admin/src/main/java/com/fzm/admin/controller/RefundController.java
0 → 100644
View file @
5cf5f779
package
com
.
fzm
.
admin
.
controller
;
import
com.fzm.common.annotation.Authentication
;
import
com.fzm.common.entity.vo.PaymentVo
;
import
com.fzm.common.enums.RefundLaunchChannel
;
import
com.fzm.common.model.ResponseModel
;
import
com.fzm.common.service.RefundService
;
import
com.fzm.common.service.WxPayService
;
import
com.github.pagehelper.PageInfo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
/**
* @author tangtuo
* @date 2022/2/9 10:16
*/
@Authentication
@RestController
@RequestMapping
(
"/refund"
)
@Api
(
tags
=
"退款管理"
)
public
class
RefundController
{
@Resource
private
RefundService
refundService
;
@GetMapping
(
"/pages"
)
@ApiOperation
(
value
=
"退款分页列表"
)
public
ResponseModel
<
PageInfo
<
PaymentVo
>>
pages
(
@ApiParam
(
value
=
"页码"
,
required
=
true
)
@RequestParam
Integer
pageNum
,
@ApiParam
(
value
=
"每页记录数"
,
required
=
true
)
@RequestParam
Integer
pageSize
,
@ApiParam
(
value
=
"姓名"
)
@RequestParam
(
required
=
false
)
String
name
,
@ApiParam
(
value
=
"注册手机号"
)
@RequestParam
(
required
=
false
)
String
telephone
,
@ApiParam
(
value
=
"订单名"
)
@RequestParam
(
required
=
false
)
String
orderName
,
@ApiParam
(
value
=
"交易类型"
)
@RequestParam
(
required
=
false
)
String
type
,
@ApiParam
(
value
=
"支付场景 1-nft发行 2-版权申请"
)
@RequestParam
(
required
=
false
)
Integer
payScene
,
@ApiParam
(
value
=
"创建开始日期,yyyy-MM-dd格式"
)
@RequestParam
(
required
=
false
)
String
start
,
@ApiParam
(
value
=
"创建截止日期,yyyy-MM-dd格式"
)
@RequestParam
(
required
=
false
)
String
end
)
{
PageInfo
<
PaymentVo
>
pages
=
refundService
.
pages
(
pageNum
,
pageSize
,
name
,
telephone
,
orderName
,
type
,
payScene
,
start
,
end
);
return
ResponseModel
.
success
(
pages
);
}
@GetMapping
(
"/submit"
)
@ApiOperation
(
value
=
"提交退款申请"
)
public
ResponseModel
<
Boolean
>
submit
(
@ApiParam
(
required
=
true
,
value
=
"订单id"
)
@RequestParam
Long
orderId
)
throws
IOException
,
InterruptedException
{
Boolean
result
=
refundService
.
submit
(
orderId
);
return
ResponseModel
.
success
(
result
);
}
}
joying-admin/src/main/java/com/fzm/admin/schedule/CopyrightTask.java
View file @
5cf5f779
...
@@ -2,7 +2,6 @@ package com.fzm.admin.schedule;
...
@@ -2,7 +2,6 @@ package com.fzm.admin.schedule;
import
cn.fzm.chain.simplesdk.client.ParaChainClient
;
import
cn.fzm.chain.simplesdk.client.ParaChainClient
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.lang.TypeReference
;
import
cn.hutool.core.lang.TypeReference
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
...
@@ -16,6 +15,7 @@ import com.fzm.common.entity.dto.EvidenceHashMessage;
...
@@ -16,6 +15,7 @@ import com.fzm.common.entity.dto.EvidenceHashMessage;
import
com.fzm.common.entity.vo.NftVo
;
import
com.fzm.common.entity.vo.NftVo
;
import
com.fzm.common.enums.CopyrightApplyState
;
import
com.fzm.common.enums.CopyrightApplyState
;
import
com.fzm.common.enums.PayScene
;
import
com.fzm.common.enums.PayScene
;
import
com.fzm.common.enums.RefundLaunchChannel
;
import
com.fzm.common.properties.CopyrightProperties
;
import
com.fzm.common.properties.CopyrightProperties
;
import
com.fzm.common.service.CopyrightApplyService
;
import
com.fzm.common.service.CopyrightApplyService
;
import
com.fzm.common.service.NftService
;
import
com.fzm.common.service.NftService
;
...
@@ -151,7 +151,7 @@ public class CopyrightTask {
...
@@ -151,7 +151,7 @@ public class CopyrightTask {
copyrightApply
.
setRejectReason
(
copyrightResponse
.
getRemark
());
copyrightApply
.
setRejectReason
(
copyrightResponse
.
getRemark
());
Order
order
=
orderService
.
getByPaySceneAndProductId
(
PayScene
.
COPYRIGHT
.
getCode
(),
copyrightApply
.
getId
());
Order
order
=
orderService
.
getByPaySceneAndProductId
(
PayScene
.
COPYRIGHT
.
getCode
(),
copyrightApply
.
getId
());
if
(
order
!=
null
)
{
if
(
order
!=
null
)
{
wxPayService
.
refund
(
order
.
getId
());
wxPayService
.
refund
(
order
.
getId
()
,
RefundLaunchChannel
.
USER
.
getCode
()
);
}
}
}
}
copyrightApplyService
.
updateById
(
copyrightApply
);
copyrightApplyService
.
updateById
(
copyrightApply
);
...
...
joying-common/src/main/java/com/fzm/common/entity/vo/PaymentVo.java
View file @
5cf5f779
...
@@ -26,4 +26,7 @@ public class PaymentVo extends Order {
...
@@ -26,4 +26,7 @@ public class PaymentVo extends Order {
@ApiModelProperty
(
"手机号"
)
@ApiModelProperty
(
"手机号"
)
private
String
telephone
;
private
String
telephone
;
@ApiModelProperty
(
"退款状态 1- 退款中 2-退款成功 3-退款失败"
)
private
Integer
refundStatus
;
}
}
joying-common/src/main/java/com/fzm/common/enums/RefundLaunchChannel.java
0 → 100644
View file @
5cf5f779
package
com
.
fzm
.
common
.
enums
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* @author tangtuo
* @date 2021/6/28 11:49
* <p>退款发起渠道</p>
*/
@AllArgsConstructor
@Getter
public
enum
RefundLaunchChannel
{
// 用户
USER
(
1
),
// 后台管理员
ADMIN
(
2
);
private
Integer
code
;
}
joying-common/src/main/java/com/fzm/common/mapper/RefundMapper.java
View file @
5cf5f779
package
com
.
fzm
.
common
.
mapper
;
package
com
.
fzm
.
common
.
mapper
;
import
cn.hutool.core.date.DateTime
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.fzm.common.entity.Refund
;
import
com.fzm.common.entity.Refund
;
import
com.fzm.common.entity.vo.PaymentVo
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
/**
* @author tangtuo
* @author tangtuo
...
@@ -10,4 +15,7 @@ import org.apache.ibatis.annotations.Mapper;
...
@@ -10,4 +15,7 @@ import org.apache.ibatis.annotations.Mapper;
*/
*/
@Mapper
@Mapper
public
interface
RefundMapper
extends
BaseMapper
<
Refund
>
{
public
interface
RefundMapper
extends
BaseMapper
<
Refund
>
{
List
<
PaymentVo
>
list
(
@Param
(
"name"
)
String
name
,
@Param
(
"telephone"
)
String
telephone
,
@Param
(
"orderName"
)
String
orderName
,
@Param
(
"type"
)
String
type
,
@Param
(
"payScene"
)
Integer
payScene
,
@Param
(
"startDate"
)
DateTime
startDate
,
@Param
(
"endDate"
)
DateTime
endDate
);
}
}
joying-common/src/main/java/com/fzm/common/service/RefundService.java
View file @
5cf5f779
...
@@ -2,6 +2,10 @@ package com.fzm.common.service;
...
@@ -2,6 +2,10 @@ package com.fzm.common.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.fzm.common.entity.Refund
;
import
com.fzm.common.entity.Refund
;
import
com.fzm.common.entity.vo.PaymentVo
;
import
com.github.pagehelper.PageInfo
;
import
java.io.IOException
;
/**
/**
* @author tangtuo
* @author tangtuo
...
@@ -16,4 +20,29 @@ public interface RefundService extends IService<Refund> {
...
@@ -16,4 +20,29 @@ public interface RefundService extends IService<Refund> {
* @return
* @return
*/
*/
Refund
getByOrderId
(
Long
orderId
);
Refund
getByOrderId
(
Long
orderId
);
/**
* 提交退款申请
*
* @param orderId
* @return
*/
Boolean
submit
(
Long
orderId
)
throws
IOException
,
InterruptedException
;
/**
* 分页查询待处理的退款订单
*
* @param pageNum
* @param pageSize
* @param name
* @param telephone
* @param orderName
* @param type
* @param payScene
* @param start
* @param end
* @return
*/
PageInfo
<
PaymentVo
>
pages
(
Integer
pageNum
,
Integer
pageSize
,
String
name
,
String
telephone
,
String
orderName
,
String
type
,
Integer
payScene
,
String
start
,
String
end
);
}
}
joying-common/src/main/java/com/fzm/common/service/WxPayService.java
View file @
5cf5f779
...
@@ -40,9 +40,10 @@ public interface WxPayService {
...
@@ -40,9 +40,10 @@ public interface WxPayService {
/**
/**
* 退款
* 退款
*
*
* @param orderId
* @param orderId 订单id
* @param channel 退款发起渠道
*/
*/
void
refund
(
Long
orderId
)
throws
IOException
,
InterruptedException
;
Boolean
refund
(
Long
orderId
,
Integer
channel
)
throws
IOException
,
InterruptedException
;
/**
/**
* 退款回调
* 退款回调
...
...
joying-common/src/main/java/com/fzm/common/service/impl/CopyrightApplyServiceImpl.java
View file @
5cf5f779
...
@@ -19,6 +19,7 @@ import com.fzm.common.entity.vo.CopyrightCertificateVo;
...
@@ -19,6 +19,7 @@ import com.fzm.common.entity.vo.CopyrightCertificateVo;
import
com.fzm.common.entity.vo.CopyrightVo
;
import
com.fzm.common.entity.vo.CopyrightVo
;
import
com.fzm.common.enums.CopyrightApplyState
;
import
com.fzm.common.enums.CopyrightApplyState
;
import
com.fzm.common.enums.PayScene
;
import
com.fzm.common.enums.PayScene
;
import
com.fzm.common.enums.RefundLaunchChannel
;
import
com.fzm.common.enums.ResultCode
;
import
com.fzm.common.enums.ResultCode
;
import
com.fzm.common.exception.GlobalException
;
import
com.fzm.common.exception.GlobalException
;
import
com.fzm.common.mapper.CopyrightApplyMapper
;
import
com.fzm.common.mapper.CopyrightApplyMapper
;
...
@@ -189,7 +190,7 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
...
@@ -189,7 +190,7 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
// 用户撤回后,需要主动退款
// 用户撤回后,需要主动退款
Order
order
=
orderService
.
getByPaySceneAndProductId
(
PayScene
.
COPYRIGHT
.
getCode
(),
id
);
Order
order
=
orderService
.
getByPaySceneAndProductId
(
PayScene
.
COPYRIGHT
.
getCode
(),
id
);
if
(
order
!=
null
)
{
if
(
order
!=
null
)
{
wxPayService
.
refund
(
order
.
getId
());
wxPayService
.
refund
(
order
.
getId
()
,
RefundLaunchChannel
.
USER
.
getCode
()
);
}
}
return
true
;
return
true
;
}
}
...
@@ -354,7 +355,7 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
...
@@ -354,7 +355,7 @@ public class CopyrightApplyServiceImpl extends ServiceImpl<CopyrightApplyMapper,
// 管理员驳回后,需要自动发起退款
// 管理员驳回后,需要自动发起退款
Order
order
=
orderService
.
getByPaySceneAndProductId
(
PayScene
.
COPYRIGHT
.
getCode
(),
id
);
Order
order
=
orderService
.
getByPaySceneAndProductId
(
PayScene
.
COPYRIGHT
.
getCode
(),
id
);
if
(
order
!=
null
)
{
if
(
order
!=
null
)
{
wxPayService
.
refund
(
order
.
getId
());
wxPayService
.
refund
(
order
.
getId
()
,
RefundLaunchChannel
.
USER
.
getCode
()
);
}
}
return
true
;
return
true
;
}
}
...
...
joying-common/src/main/java/com/fzm/common/service/impl/RefundServiceImpl.java
View file @
5cf5f779
package
com
.
fzm
.
common
.
service
.
impl
;
package
com
.
fzm
.
common
.
service
.
impl
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.fzm.common.entity.Refund
;
import
com.fzm.common.entity.Refund
;
import
com.fzm.common.entity.vo.PaymentVo
;
import
com.fzm.common.enums.RefundLaunchChannel
;
import
com.fzm.common.mapper.RefundMapper
;
import
com.fzm.common.mapper.RefundMapper
;
import
com.fzm.common.service.OrderService
;
import
com.fzm.common.service.RefundService
;
import
com.fzm.common.service.RefundService
;
import
com.fzm.common.service.WxPayService
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.util.List
;
/**
/**
* @author tangtuo
* @author tangtuo
* @date 2022/1/24 14:27
* @date 2022/1/24 14:27
...
@@ -16,10 +29,36 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -16,10 +29,36 @@ import org.springframework.transaction.annotation.Transactional;
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
@Transactional
(
rollbackFor
=
RuntimeException
.
class
)
public
class
RefundServiceImpl
extends
ServiceImpl
<
RefundMapper
,
Refund
>
implements
RefundService
{
public
class
RefundServiceImpl
extends
ServiceImpl
<
RefundMapper
,
Refund
>
implements
RefundService
{
@Resource
private
WxPayService
wxPayService
;
@Resource
private
RefundMapper
refundMapper
;
@Override
@Override
public
Refund
getByOrderId
(
Long
orderId
)
{
public
Refund
getByOrderId
(
Long
orderId
)
{
QueryWrapper
<
Refund
>
queryWrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
Refund
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
eq
(
"order_id"
,
orderId
);
queryWrapper
.
eq
(
"order_id"
,
orderId
);
return
getOne
(
queryWrapper
);
return
getOne
(
queryWrapper
);
}
}
@Override
public
Boolean
submit
(
Long
orderId
)
throws
IOException
,
InterruptedException
{
return
wxPayService
.
refund
(
orderId
,
RefundLaunchChannel
.
ADMIN
.
getCode
());
}
@Override
public
PageInfo
<
PaymentVo
>
pages
(
Integer
pageNum
,
Integer
pageSize
,
String
name
,
String
telephone
,
String
orderName
,
String
type
,
Integer
payScene
,
String
start
,
String
end
)
{
PageHelper
.
startPage
(
pageNum
,
pageSize
);
DateTime
startDate
=
null
;
DateTime
endDate
=
null
;
if
(
StringUtils
.
isNotBlank
(
start
))
{
startDate
=
DateUtil
.
parse
(
start
+
" 00:00:00"
,
"yyyy-MM-dd HH:mm:ss"
);
}
if
(
StringUtils
.
isNotBlank
(
end
))
{
endDate
=
DateUtil
.
parse
(
end
+
" 23:59:59"
,
"yyyy-MM-dd HH:mm:ss"
);
}
List
<
PaymentVo
>
list
=
refundMapper
.
list
(
name
,
telephone
,
orderName
,
type
,
payScene
,
startDate
,
endDate
);
return
new
PageInfo
<>(
list
);
}
}
}
joying-common/src/main/java/com/fzm/common/service/impl/WxPayServiceImpl.java
View file @
5cf5f779
...
@@ -243,7 +243,8 @@ public class WxPayServiceImpl implements WxPayService {
...
@@ -243,7 +243,8 @@ public class WxPayServiceImpl implements WxPayService {
}
}
@Override
@Override
public
void
refund
(
Long
orderId
)
throws
IOException
,
InterruptedException
{
public
Boolean
refund
(
Long
orderId
,
Integer
channel
)
throws
IOException
,
InterruptedException
{
Boolean
result
;
RLock
lock
=
redisson
.
getLock
(
"refund-"
+
orderId
);
RLock
lock
=
redisson
.
getLock
(
"refund-"
+
orderId
);
if
(!
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
))
{
if
(!
lock
.
tryLock
(
10
,
TimeUnit
.
SECONDS
))
{
throw
GlobalException
.
newException
(
ResultCode
.
REFUND_FAILED
,
"当前订单正在退款中,请勿重复点击"
);
throw
GlobalException
.
newException
(
ResultCode
.
REFUND_FAILED
,
"当前订单正在退款中,请勿重复点击"
);
...
@@ -283,26 +284,33 @@ public class WxPayServiceImpl implements WxPayService {
...
@@ -283,26 +284,33 @@ public class WxPayServiceImpl implements WxPayService {
String
bodyAsString
=
EntityUtils
.
toString
(
response
.
getEntity
());
String
bodyAsString
=
EntityUtils
.
toString
(
response
.
getEntity
());
log
.
info
(
"退款接口返回参数: {}"
,
bodyAsString
);
log
.
info
(
"退款接口返回参数: {}"
,
bodyAsString
);
int
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
int
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
if
(
statusCode
==
200
||
statusCode
==
204
)
{
// 发起退款成功
// 发起退款成功
if
(
statusCode
==
200
||
statusCode
==
204
)
{
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
bodyAsString
);
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
bodyAsString
);
refund
.
setRefundId
(
jsonObject
.
getStr
(
"refund_id"
));
refund
.
setRefundId
(
jsonObject
.
getStr
(
"refund_id"
));
refund
.
setTransactionId
(
jsonObject
.
getStr
(
"transaction_id"
));
refund
.
setTransactionId
(
jsonObject
.
getStr
(
"transaction_id"
));
refund
.
setUserReceivedAccount
(
jsonObject
.
getStr
(
"user_received_account"
));
refund
.
setUserReceivedAccount
(
jsonObject
.
getStr
(
"user_received_account"
));
refund
.
setRefundStatus
(
RefundStatus
.
REFUNDING
.
getStatus
()
);
refund
.
setRefundStatus
(
channel
);
// 修改订单状态为退款中
// 修改订单状态为退款中
orderService
.
updateOrderStatus
(
orderId
,
OrderStatus
.
REFUNDING
);
orderService
.
updateOrderStatus
(
orderId
,
OrderStatus
.
REFUNDING
);
result
=
true
;
}
else
{
}
else
{
// 发起退款失败
// 发起退款失败
refund
.
setRefundStatus
(
RefundStatus
.
FAINED
.
getStatus
());
refund
.
setRefundStatus
(
RefundStatus
.
FAINED
.
getStatus
());
result
=
false
;
}
}
// 插入退款信息
// 插入退款信息
refund
.
setId
(
out_refund_no
);
refund
.
setId
(
out_refund_no
);
refund
.
setFee
(
order
.
getFee
());
refund
.
setFee
(
order
.
getFee
());
refund
.
setOrderId
(
orderId
);
refund
.
setOrderId
(
orderId
);
refund
.
setChannel
(
RefundLaunchChannel
.
USER
.
getCode
());
refundService
.
saveOrUpdate
(
refund
);
refundService
.
saveOrUpdate
(
refund
);
// 如果是用户端发起的退款, 失败时则需抛出异常,告知系统管理员退款失败
if
(
RefundLaunchChannel
.
USER
.
getCode
().
equals
(
channel
))
{
// 异步发送退款短信通知
// 异步发送退款短信通知
smsService
.
sendRefundSms
(
orderId
);
smsService
.
sendRefundSms
(
orderId
);
}
return
result
;
}
finally
{
}
finally
{
lock
.
unlock
();
lock
.
unlock
();
}
}
...
...
joying-common/src/main/resources/mapper/RefundMapper.xml
0 → 100644
View file @
5cf5f779
<?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=
"com.fzm.common.mapper.RefundMapper"
>
<select
id=
"list"
resultType=
"com.fzm.common.entity.vo.PaymentVo"
>
SELECT
t.order_id,
t.refund_status,
t.update_date as trade_time,
o.*,
u.telephone,
p.`name`
FROM
tb_refund t
LEFT JOIN tb_order o ON t.order_id = o.id
LEFT JOIN tb_user u ON o.user_id = u.id
LEFT JOIN tb_auth_person p ON u.id = p.user_id
<where>
(t.refund_status = 3 or (t.channel = 2 and t.refund_status = 2))
<if
test=
"payScene != null"
>
and o.pay_scene = #{payScene}
</if>
<if
test=
"orderName != null and orderName != ''"
>
and o.order_name like concat('%',#{orderName},'%')
</if>
<if
test=
"telephone != null and telephone != ''"
>
and u.telephone = #{telephone}
</if>
<if
test=
"name != null and name != ''"
>
and p.name = #{name}
</if>
<if
test=
"startDate != null"
>
and t.update_date >= #{startDate}
</if>
<if
test=
"endDate != null"
>
and t.update_date
<
= #{endDate}
</if>
</where>
ORDER BY
t.update_date DESC
</select>
</mapper>
\ No newline at end of file
joying-portal/src/main/java/com/fzm/portal/JoyingPortalApplication.java
View file @
5cf5f779
...
@@ -6,7 +6,9 @@ import org.springframework.boot.SpringApplication;
...
@@ -6,7 +6,9 @@ import org.springframework.boot.SpringApplication;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
@EnableScheduling
@EnableAsync
@EnableAsync
@EnableSwagger2Doc
@EnableSwagger2Doc
@EnableCaching
@EnableCaching
...
...
joying-portal/src/main/java/com/fzm/portal/controller/NftController.java
View file @
5cf5f779
...
@@ -183,10 +183,16 @@ public class NftController {
...
@@ -183,10 +183,16 @@ public class NftController {
return
ResponseModel
.
success
(
list
);
return
ResponseModel
.
success
(
list
);
}
}
@GetMapping
(
"/republish"
)
// @GetMapping("/republish")
public
ResponseModel
<
String
>
republish
(){
// public ResponseModel<String> republish() {
nftService
.
republish
();
// nftService.republish();
return
ResponseModel
.
success
();
// return ResponseModel.success();
// }
@GetMapping
(
"/detail/{id}"
)
@ApiOperation
(
value
=
"nft订单详情页"
)
public
ResponseModel
<
Nft
>
getDetail
(
@PathVariable
Integer
id
)
{
return
ResponseModel
.
success
(
nftService
.
getById
(
id
));
}
}
}
}
joying-portal/src/main/java/com/fzm/portal/controller/WxPayController.java
View file @
5cf5f779
...
@@ -4,6 +4,7 @@ import cn.hutool.http.HttpStatus;
...
@@ -4,6 +4,7 @@ import cn.hutool.http.HttpStatus;
import
com.fzm.common.annotation.Authentication
;
import
com.fzm.common.annotation.Authentication
;
import
com.fzm.common.entity.dto.JsapiPayDto
;
import
com.fzm.common.entity.dto.JsapiPayDto
;
import
com.fzm.common.entity.dto.OrderDto
;
import
com.fzm.common.entity.dto.OrderDto
;
import
com.fzm.common.enums.RefundLaunchChannel
;
import
com.fzm.common.model.ResponseModel
;
import
com.fzm.common.model.ResponseModel
;
import
com.fzm.common.service.WxPayService
;
import
com.fzm.common.service.WxPayService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
...
@@ -73,7 +74,7 @@ public class WxPayController {
...
@@ -73,7 +74,7 @@ public class WxPayController {
@GetMapping
(
"/refund/{orderId}"
)
@GetMapping
(
"/refund/{orderId}"
)
public
ResponseModel
<
String
>
refund
(
@PathVariable
Long
orderId
)
throws
IOException
,
InterruptedException
{
public
ResponseModel
<
String
>
refund
(
@PathVariable
Long
orderId
)
throws
IOException
,
InterruptedException
{
wxPayService
.
refund
(
orderId
);
wxPayService
.
refund
(
orderId
,
RefundLaunchChannel
.
USER
.
getCode
()
);
return
ResponseModel
.
success
(
"退款成功"
);
return
ResponseModel
.
success
(
"退款成功"
);
}
}
...
...
joying-portal/src/main/java/com/fzm/portal/listener/NftListener.java
View file @
5cf5f779
...
@@ -8,10 +8,7 @@ import com.fzm.common.entity.Nft;
...
@@ -8,10 +8,7 @@ import com.fzm.common.entity.Nft;
import
com.fzm.common.entity.Order
;
import
com.fzm.common.entity.Order
;
import
com.fzm.common.entity.User
;
import
com.fzm.common.entity.User
;
import
com.fzm.common.entity.dto.NftPublishMsg
;
import
com.fzm.common.entity.dto.NftPublishMsg
;
import
com.fzm.common.enums.OrderStatus
;
import
com.fzm.common.enums.*
;
import
com.fzm.common.enums.PayScene
;
import
com.fzm.common.enums.PublishStatus
;
import
com.fzm.common.enums.ResultCode
;
import
com.fzm.common.exception.GlobalException
;
import
com.fzm.common.exception.GlobalException
;
import
com.fzm.common.service.NftService
;
import
com.fzm.common.service.NftService
;
import
com.fzm.common.service.OrderService
;
import
com.fzm.common.service.OrderService
;
...
@@ -92,7 +89,7 @@ public class NftListener {
...
@@ -92,7 +89,7 @@ public class NftListener {
nftService
.
updateById
(
nft
);
nftService
.
updateById
(
nft
);
Order
order
=
orderService
.
getByPaySceneAndProductId
(
PayScene
.
NFT
.
getCode
(),
nft
.
getId
());
Order
order
=
orderService
.
getByPaySceneAndProductId
(
PayScene
.
NFT
.
getCode
(),
nft
.
getId
());
if
(
order
!=
null
)
{
if
(
order
!=
null
)
{
wxPayService
.
refund
(
order
.
getId
());
wxPayService
.
refund
(
order
.
getId
()
,
RefundLaunchChannel
.
USER
.
getCode
()
);
}
}
}
}
}
}
...
...
joying-portal/src/main/java/com/fzm/portal/listener/OrderListener.java
View file @
5cf5f779
...
@@ -3,6 +3,7 @@ package com.fzm.portal.listener;
...
@@ -3,6 +3,7 @@ package com.fzm.portal.listener;
import
com.fzm.common.entity.dto.OrderProcessMsg
;
import
com.fzm.common.entity.dto.OrderProcessMsg
;
import
com.fzm.common.enums.CopyrightApplyState
;
import
com.fzm.common.enums.CopyrightApplyState
;
import
com.fzm.common.enums.PayScene
;
import
com.fzm.common.enums.PayScene
;
import
com.fzm.common.enums.RefundLaunchChannel
;
import
com.fzm.common.service.CopyrightApplyService
;
import
com.fzm.common.service.CopyrightApplyService
;
import
com.fzm.common.service.NftService
;
import
com.fzm.common.service.NftService
;
import
com.fzm.common.service.WxPayService
;
import
com.fzm.common.service.WxPayService
;
...
@@ -43,7 +44,7 @@ public class OrderListener {
...
@@ -43,7 +44,7 @@ public class OrderListener {
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
// 处理失败,需要主动发起退款
// 处理失败,需要主动发起退款
wxPayService
.
refund
(
msg
.
getOrderId
());
wxPayService
.
refund
(
msg
.
getOrderId
()
,
RefundLaunchChannel
.
USER
.
getCode
()
);
}
}
}
}
...
...
joying-portal/src/main/java/com/fzm/portal/schedule/PayTask.java
View file @
5cf5f779
...
@@ -8,13 +8,13 @@ import com.fzm.common.service.OrderService;
...
@@ -8,13 +8,13 @@ import com.fzm.common.service.OrderService;
import
com.fzm.common.service.RefundService
;
import
com.fzm.common.service.RefundService
;
import
com.fzm.common.service.WxPayService
;
import
com.fzm.common.service.WxPayService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.redisson.Redisson
;
import
org.redisson.Redisson
;
import
org.redisson.api.RLock
;
import
org.redisson.api.RLock
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -41,8 +41,8 @@ public class PayTask {
...
@@ -41,8 +41,8 @@ public class PayTask {
/**
/**
* 定时关单的任务
* 定时关单的任务
*/
*/
@Scheduled
(
cron
=
"0 */
5
* * * ?"
)
@Scheduled
(
cron
=
"0 */
1
* * * ?"
)
public
void
closeOrder
()
throws
InterruptedException
,
IOException
{
public
void
closeOrder
()
throws
InterruptedException
{
RLock
lock
=
redisson
.
getLock
(
"close-order"
);
RLock
lock
=
redisson
.
getLock
(
"close-order"
);
// 加锁,避免集群环境下多个节点同事运行此定时任务
// 加锁,避免集群环境下多个节点同事运行此定时任务
if
(!
lock
.
tryLock
(
30
,
TimeUnit
.
SECONDS
))
{
if
(!
lock
.
tryLock
(
30
,
TimeUnit
.
SECONDS
))
{
...
@@ -55,11 +55,16 @@ public class PayTask {
...
@@ -55,11 +55,16 @@ public class PayTask {
return
;
return
;
}
}
for
(
Order
order
:
orderList
)
{
for
(
Order
order
:
orderList
)
{
Long
orderId
=
order
.
getId
();
try
{
// 确认订单状态
// 确认订单状态
String
orderStatus
=
wxPayService
.
queryOrder
(
order
.
getId
()
);
String
orderStatus
=
wxPayService
.
queryOrder
(
orderId
);
if
(
WxPayStatus
.
NOTPAY
.
getStatus
().
equals
(
orderStatus
))
{
if
(
StringUtils
.
isBlank
(
orderStatus
)
||
WxPayStatus
.
NOTPAY
.
getStatus
().
equals
(
orderStatus
))
{
// 订单未支付,则关闭订单
// 订单未支付,则关闭订单
orderService
.
cancel
(
order
.
getId
(),
OrderStatus
.
CLOSED
);
orderService
.
cancel
(
orderId
,
OrderStatus
.
CLOSED
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
String
.
format
(
"订单状态更新失败,当前订单号: %s"
,
orderId
),
e
);
}
}
}
}
}
}
...
...
logs/logback.2022-02-08.0.log
View file @
5cf5f779
This diff is collapsed.
Click to expand it.
logs/logback.2022-02-09.0.log
0 → 100644
View file @
5cf5f779
This source diff could not be displayed because it is too large. You can
view the blob
instead.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment