Commit 5cf5f779 authored by tangtuo's avatar tangtuo

新增退款 订单详情接口

parent bde11b59
...@@ -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);
} }
} }
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);
}
}
...@@ -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);
......
...@@ -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;
} }
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;
}
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);
} }
...@@ -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);
} }
...@@ -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;
/** /**
* 退款回调 * 退款回调
......
...@@ -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;
} }
......
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);
}
} }
...@@ -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();
} }
......
<?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 &lt;= #{endDate}
</if>
</where>
ORDER BY
t.update_date DESC
</select>
</mapper>
\ No newline at end of file
...@@ -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
......
...@@ -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));
} }
} }
...@@ -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("退款成功");
} }
......
...@@ -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());
} }
} }
} }
......
...@@ -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());
} }
} }
......
...@@ -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);
} }
} }
} }
......
...@@ -1900,3 +1900,46 @@ Caused by: java.sql.SQLSyntaxErrorException: Unknown column 'o.type' in 'where c ...@@ -1900,3 +1900,46 @@ Caused by: java.sql.SQLSyntaxErrorException: Unknown column 'o.type' in 'where c
2022-02-08 18:55:15.518 [http-nio-8002-exec-3] DEBUG com.fzm.common.mapper.PaymentMapper.list_COUNT-==> Preparing: SELECT count(0) FROM (SELECT order_id, update_date AS trade_time, '支付' AS type FROM tb_payment UNION ALL SELECT order_id, update_date AS trade_time, '退款' AS type FROM tb_refund WHERE refund_status = 2) 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 o.pay_scene = ? AND o.order_name LIKE concat('%', ?, '%') AND u.telephone = ? AND p.name = ? AND t.type = ? AND t.trade_time >= ? AND t.trade_time <= ? 2022-02-08 18:55:15.518 [http-nio-8002-exec-3] DEBUG com.fzm.common.mapper.PaymentMapper.list_COUNT-==> Preparing: SELECT count(0) FROM (SELECT order_id, update_date AS trade_time, '支付' AS type FROM tb_payment UNION ALL SELECT order_id, update_date AS trade_time, '退款' AS type FROM tb_refund WHERE refund_status = 2) 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 o.pay_scene = ? AND o.order_name LIKE concat('%', ?, '%') AND u.telephone = ? AND p.name = ? AND t.type = ? AND t.trade_time >= ? AND t.trade_time <= ?
2022-02-08 18:55:15.519 [http-nio-8002-exec-3] DEBUG com.fzm.common.mapper.PaymentMapper.list_COUNT-==> Parameters: 1(Integer), 哈哈(String), 17620078872(String), 唐(String), 退款(String), 2022-02-08 14:36:04.0(Timestamp), 2022-02-08 14:36:04.0(Timestamp) 2022-02-08 18:55:15.519 [http-nio-8002-exec-3] DEBUG com.fzm.common.mapper.PaymentMapper.list_COUNT-==> Parameters: 1(Integer), 哈哈(String), 17620078872(String), 唐(String), 退款(String), 2022-02-08 14:36:04.0(Timestamp), 2022-02-08 14:36:04.0(Timestamp)
2022-02-08 18:55:15.538 [http-nio-8002-exec-3] DEBUG com.fzm.common.mapper.PaymentMapper.list_COUNT-<== Total: 1 2022-02-08 18:55:15.538 [http-nio-8002-exec-3] DEBUG com.fzm.common.mapper.PaymentMapper.list_COUNT-<== Total: 1
2022-02-08 18:56:00.044 [scheduling-1] DEBUG c.f.c.mapper.CopyrightApplyMapper.getSerialCodes-==> Preparing: SELECT serial_num FROM tb_copyright_apply WHERE register_state IN (2, 6, 7)
2022-02-08 18:56:00.044 [scheduling-1] DEBUG c.f.c.mapper.CopyrightApplyMapper.getSerialCodes-==> Parameters:
2022-02-08 18:56:00.060 [scheduling-1] DEBUG c.f.c.mapper.CopyrightApplyMapper.getSerialCodes-<== Total: 3
2022-02-08 18:56:00.105 [scheduling-1] INFO com.fzm.admin.schedule.CopyrightTask-更新状态: 当前流水号为: 22011243543
2022-02-08 18:56:00.106 [scheduling-1] INFO com.fzm.common.utils.CopyrightSignUtil-signStr: app_id=289391457858&app_secret=xExjKUCYH1nrze6Hpxf8s1dYWdxEggo2FiwKlZKygCItOV7E8bFhkyr4C192uhK&biz_content={"serial_code":"22011243543"}&charset=utf-8&sign_type=md5&timestamp=2022-02-08 18:56:00&version=1.0
2022-02-08 18:56:00.106 [scheduling-1] INFO com.fzm.admin.schedule.CopyrightTask-查询审核结果, 当前流水号为:22011243543 , 请求参数为 : {"charset":"utf-8","biz_content":"{\"serial_code\":\"22011243543\"}","sign":"e2e8a9c1184bc7e25c6f72a960f9ecea","version":"1.0","app_id":"289391457858","sign_type":"md5","timestamp":"2022-02-08 18:56:00"}
2022-02-08 18:56:00.204 [scheduling-1] INFO com.fzm.admin.schedule.CopyrightTask-查询审核结果接口响应内容: {"success":true,"message":"查询成功","code":200,"timestamp":"2022-02-08 18:56:00","remark":null,"certificate":null,"sign":"5d25fa6aae8012f0222b2753c88daed6","copyright_detail":{"serial_code":null,"nature_code":4,"nature_desc":"","nature_name":null,"end_time":"2022-01-27","end_address":"北京市北京市","works_desc":"fbf","works_create_desc":"bfgbf","publish_status":1,"publish_time":null,"publish_address":null,"agency_photo":null,"works_name":"fdvf","works_type_code":3,"works_type_name":null,"works_type_desc":"","rights_affilia_code":4,"rights_affilia_name":null,"affilia_photo":"https://p.yareiot.com/wk/uploads/20220112161323/df41e363a47c4e61b2d2f5473eb848fc.jpg","gain_code":null,"gain_name":null,"gain_desc":null,"geren_uname":null,"geren_uxname":null,"geren_uxname_type":null,"geren_uxname_type_name":null,"gain_photo":"https://p.yareiot.com/wknull","author_photo":"https://p.yareiot.com/wknull","entrust_photo":"https://p.yareiot.com/wknull","rights_desc":"1、2、3、4、5、6、7、8、9、10、11、12、13、14、15、16、17","other_photo":"https://p.yareiot.com/wknull","rights_guarantee_photo":"https://p.yareiot.com/wk/uploads/20220112161323/594e0e36becd4d489b3513d78d82c066.jpg","is_grade":0,"cooperator":null,"works_files":[{"file_name":"作品.jpg","file":"/uploads/20220112161323/73320cf5d49a4806a0fd4b3d22f74031.jpg","file_format":"jpg","file_size":"133.9KB","file_token":"80758630e76e5990b4de0e913ba42c5e","keywords":null}],"owner_list":[{"owner_name":"asdas","owner_type_code":1,"document_type_code":1,"document_code":"dasdas","other_document_code":null,"document_image":null,"other_start_date":null,"other_end_date":"2022-01-21","is_forever":1,"valid_start_date":null,"valid_end_date":null,"handheld_photo":"/uploads/20220112161323/8e9fa0f1e640421cbe35cc501430d555.png","front_photo":"/uploads/20220112161323/8de585668b644a8482bb2cf6a87c96d3.png","back_photo":"/uploads/20220112161323/39a4fec704714eee81d7424935bea09e.png","company_photo":null,"prove_photo":null,"province":"北京市","province_id":"110000","city":"北京市","city_id":"110100","address":"北京市北京市","owner_sign_name":"","owner_type_name":null,"document_type_name":null}]},"audit_status":1,"apply_time":"2022-01-12"}
2022-02-08 18:56:00.228 [scheduling-1] DEBUG c.fzm.common.mapper.CopyrightApplyMapper.selectOne-==> Preparing: SELECT id,serial_num,user_id,nft_hash,nft_name,register_entrust,opus_name,opus_category_id,opus_property,content_synopsis,create_process,opus_complete_date,opus_complete_province,opus_complete_city,publish_state,first_publish_date,first_publish_province,first_publish_city,authority_acquire_mode,authority_acquire_prove,authority_ascription_mode,authority_ascription_prove,opus_power_guarantee,apply_time,pass_time,register_state,evidence_hash,evidence_date,reject_reason,content,register_code,create_date,update_date FROM tb_copyright_apply WHERE (serial_num = ?)
2022-02-08 18:56:00.228 [scheduling-1] DEBUG c.fzm.common.mapper.CopyrightApplyMapper.selectOne-==> Parameters: 22011243543(String)
2022-02-08 18:56:00.247 [scheduling-1] DEBUG c.fzm.common.mapper.CopyrightApplyMapper.selectOne-<== Total: 1
2022-02-08 18:56:00.278 [scheduling-1] INFO com.fzm.admin.schedule.CopyrightTask-当前版权状态无更新, 流水号为: 22011243543
2022-02-08 18:56:00.278 [scheduling-1] INFO com.fzm.admin.schedule.CopyrightTask-更新状态: 当前流水号为: 22011206781
2022-02-08 18:56:00.279 [scheduling-1] INFO com.fzm.common.utils.CopyrightSignUtil-signStr: app_id=289391457858&app_secret=xExjKUCYH1nrze6Hpxf8s1dYWdxEggo2FiwKlZKygCItOV7E8bFhkyr4C192uhK&biz_content={"serial_code":"22011206781"}&charset=utf-8&sign_type=md5&timestamp=2022-02-08 18:56:00&version=1.0
2022-02-08 18:56:00.279 [scheduling-1] INFO com.fzm.admin.schedule.CopyrightTask-查询审核结果, 当前流水号为:22011206781 , 请求参数为 : {"charset":"utf-8","biz_content":"{\"serial_code\":\"22011206781\"}","sign":"3bb3cfc59e2a7366d1d4bbbffdfddc1a","version":"1.0","app_id":"289391457858","sign_type":"md5","timestamp":"2022-02-08 18:56:00"}
2022-02-08 18:56:00.311 [scheduling-1] INFO com.fzm.admin.schedule.CopyrightTask-查询审核结果接口响应内容: {"success":true,"message":"查询成功","code":200,"timestamp":"2022-02-08 18:56:00","remark":null,"certificate":null,"sign":"07ddabbd12c0d5181abe3ae04015edce","copyright_detail":{"serial_code":null,"nature_code":1,"nature_desc":"","nature_name":null,"end_time":"2022-01-07","end_address":"湖北省武汉市","works_desc":"厚厚的云","works_create_desc":"武汉随拍","publish_status":1,"publish_time":null,"publish_address":null,"agency_photo":null,"works_name":"厚厚的云","works_type_code":10,"works_type_name":null,"works_type_desc":"","rights_affilia_code":1,"rights_affilia_name":null,"affilia_photo":"https://p.yareiot.com/wknull","gain_code":null,"gain_name":null,"gain_desc":null,"geren_uname":null,"geren_uxname":null,"geren_uxname_type":null,"geren_uxname_type_name":null,"gain_photo":"https://p.yareiot.com/wknull","author_photo":"https://p.yareiot.com/wknull","entrust_photo":"https://p.yareiot.com/wknull","rights_desc":"1、2、3、4、5、6、7、8、9、10、11、12、13、14、15、16、17","other_photo":"https://p.yareiot.com/wknull","rights_guarantee_photo":"https://p.yareiot.com/wk/uploads/20220112161322/99478d0e12f143b1b06c8a6f4aa897da.png","is_grade":0,"cooperator":null,"works_files":[{"file_name":"16D8CD93-824E-440D-9D8F-5B2BA97F81E4.png","file":"/uploads/20220112161322/9d781d5a441241b98b8d89e5e198c091.png","file_format":"png","file_size":"1.28MB","file_token":"c4831a0d6edbf2436d89a78c2ec0a6bc","keywords":null}],"owner_list":[{"owner_name":"我是著作权人","owner_type_code":1,"document_type_code":1,"document_code":"420194199437284679","other_document_code":null,"document_image":null,"other_start_date":null,"other_end_date":"2022-01-01","is_forever":1,"valid_start_date":null,"valid_end_date":null,"handheld_photo":"/uploads/20220112161322/03ae66edeaac47a1a9b53d43cf3ec0ff.png","front_photo":"/uploads/20220112161322/96851b2ce1ae4e1b9fc202718f009b49.jpeg","back_photo":"/uploads/20220112161322/16b41dfde410488d8948f1c39e19e62e.jpeg","company_photo":null,"prove_photo":null,"province":"湖北省","province_id":"420000","city":"武汉市","city_id":"420100","address":"湖北省武汉市","owner_sign_name":"","owner_type_name":null,"document_type_name":null}]},"audit_status":1,"apply_time":"2022-01-12"}
2022-02-08 18:56:00.333 [scheduling-1] DEBUG c.fzm.common.mapper.CopyrightApplyMapper.selectOne-==> Preparing: SELECT id,serial_num,user_id,nft_hash,nft_name,register_entrust,opus_name,opus_category_id,opus_property,content_synopsis,create_process,opus_complete_date,opus_complete_province,opus_complete_city,publish_state,first_publish_date,first_publish_province,first_publish_city,authority_acquire_mode,authority_acquire_prove,authority_ascription_mode,authority_ascription_prove,opus_power_guarantee,apply_time,pass_time,register_state,evidence_hash,evidence_date,reject_reason,content,register_code,create_date,update_date FROM tb_copyright_apply WHERE (serial_num = ?)
2022-02-08 18:56:00.334 [scheduling-1] DEBUG c.fzm.common.mapper.CopyrightApplyMapper.selectOne-==> Parameters: 22011206781(String)
2022-02-08 18:56:00.359 [scheduling-1] DEBUG c.fzm.common.mapper.CopyrightApplyMapper.selectOne-<== Total: 1
2022-02-08 18:56:00.397 [scheduling-1] INFO com.fzm.admin.schedule.CopyrightTask-当前版权状态无更新, 流水号为: 22011206781
2022-02-08 18:56:00.397 [scheduling-1] INFO com.fzm.admin.schedule.CopyrightTask-更新状态: 当前流水号为: 22011391333
2022-02-08 18:56:00.398 [scheduling-1] INFO com.fzm.common.utils.CopyrightSignUtil-signStr: app_id=289391457858&app_secret=xExjKUCYH1nrze6Hpxf8s1dYWdxEggo2FiwKlZKygCItOV7E8bFhkyr4C192uhK&biz_content={"serial_code":"22011391333"}&charset=utf-8&sign_type=md5&timestamp=2022-02-08 18:56:00&version=1.0
2022-02-08 18:56:00.398 [scheduling-1] INFO com.fzm.admin.schedule.CopyrightTask-查询审核结果, 当前流水号为:22011391333 , 请求参数为 : {"charset":"utf-8","biz_content":"{\"serial_code\":\"22011391333\"}","sign":"7480e836c9e4644024db7f725550a819","version":"1.0","app_id":"289391457858","sign_type":"md5","timestamp":"2022-02-08 18:56:00"}
2022-02-08 18:56:00.436 [scheduling-1] INFO com.fzm.admin.schedule.CopyrightTask-查询审核结果接口响应内容: {"success":true,"message":"查询成功","code":200,"timestamp":"2022-02-08 18:56:00","remark":null,"certificate":null,"sign":"52e5e8d219de6aeee4c6ba995c9554f7","copyright_detail":{"serial_code":null,"nature_code":1,"nature_desc":"","nature_name":null,"end_time":"2022-01-05","end_address":"北京市北京市","works_desc":"1","works_create_desc":"2","publish_status":1,"publish_time":null,"publish_address":null,"agency_photo":null,"works_name":"先看书看书","works_type_code":1,"works_type_name":null,"works_type_desc":"","rights_affilia_code":2,"rights_affilia_name":null,"affilia_photo":"https://p.yareiot.com/wk/uploads/20220113152334/1f99abf3dbcf4da38094574c8d982c07.png","gain_code":null,"gain_name":null,"gain_desc":null,"geren_uname":null,"geren_uxname":null,"geren_uxname_type":null,"geren_uxname_type_name":null,"gain_photo":"https://p.yareiot.com/wknull","author_photo":"https://p.yareiot.com/wknull","entrust_photo":"https://p.yareiot.com/wknull","rights_desc":"1、2、3、4、5、6、7、8、9、10、11、12、13、14、15、16、17","other_photo":"https://p.yareiot.com/wknull","rights_guarantee_photo":"https://p.yareiot.com/wk/uploads/20220113152334/8c48350338194799b1a0082778c9cd84.png","is_grade":0,"cooperator":null,"works_files":[{"file_name":"张震岳-爱我别走(1)(1).mp3","file":"/uploads/20220113152335/cdbe0e6a9f684e9a865380ae6d4570f9.mp3","file_format":"mp3","file_size":"4.39MB","file_token":"ff9b3ac328885fbadbdbc7cc90acd4ad","keywords":null},{"file_name":"微信图片_20211109150850.wav","file":"/uploads/20220113152335/485ccac180e54d87acae53169478b33f.wav","file_format":"wav","file_size":"33.24KB","file_token":"69691f6370f1e590662293d56e3d8d87","keywords":null}],"owner_list":[{"owner_name":"阿达","owner_type_code":1,"document_type_code":1,"document_code":"1313123123123","other_document_code":null,"document_image":null,"other_start_date":null,"other_end_date":"2022-01-03","is_forever":1,"valid_start_date":null,"valid_end_date":null,"handheld_photo":"/uploads/20220111102004/012a22dadb0f47ac83028f7e3f845589.png","front_photo":"/uploads/20220111102004/43930f4d41c0403eaa54f0da84b85aba.png","back_photo":"/uploads/20220111102004/02b752334631470f97f30ee333a1321c.png","company_photo":null,"prove_photo":null,"province":"河北省","province_id":"130000","city":"石家庄市","city_id":"130100","address":"河北省石家庄市","owner_sign_name":"","owner_type_name":null,"document_type_name":null}]},"audit_status":4,"apply_time":"2022-01-13"}
2022-02-08 18:56:00.458 [scheduling-1] DEBUG c.fzm.common.mapper.CopyrightApplyMapper.selectOne-==> Preparing: SELECT id,serial_num,user_id,nft_hash,nft_name,register_entrust,opus_name,opus_category_id,opus_property,content_synopsis,create_process,opus_complete_date,opus_complete_province,opus_complete_city,publish_state,first_publish_date,first_publish_province,first_publish_city,authority_acquire_mode,authority_acquire_prove,authority_ascription_mode,authority_ascription_prove,opus_power_guarantee,apply_time,pass_time,register_state,evidence_hash,evidence_date,reject_reason,content,register_code,create_date,update_date FROM tb_copyright_apply WHERE (serial_num = ?)
2022-02-08 18:56:00.458 [scheduling-1] DEBUG c.fzm.common.mapper.CopyrightApplyMapper.selectOne-==> Parameters: 22011391333(String)
2022-02-08 18:56:00.476 [scheduling-1] DEBUG c.fzm.common.mapper.CopyrightApplyMapper.selectOne-<== Total: 1
2022-02-08 18:56:00.512 [scheduling-1] INFO com.fzm.admin.schedule.CopyrightTask-当前版权状态无更新, 流水号为: 22011391333
2022-02-08 18:56:38.907 [SpringContextShutdownHook] INFO o.s.a.r.listener.SimpleMessageListenerContainer-Waiting for workers to finish.
2022-02-08 18:56:39.234 [SpringContextShutdownHook] INFO o.s.a.r.listener.SimpleMessageListenerContainer-Successfully waited for workers to finish.
2022-02-08 18:56:39.252 [SpringContextShutdownHook] INFO o.s.a.r.listener.SimpleMessageListenerContainer-Waiting for workers to finish.
2022-02-08 18:56:39.364 [SpringContextShutdownHook] INFO o.s.a.r.listener.SimpleMessageListenerContainer-Successfully waited for workers to finish.
2022-02-08 18:56:39.583 [SpringContextShutdownHook] INFO o.s.a.r.listener.SimpleMessageListenerContainer-Shutdown ignored - container is not active already
2022-02-08 18:56:39.583 [SpringContextShutdownHook] INFO o.s.a.r.listener.SimpleMessageListenerContainer-Shutdown ignored - container is not active already
2022-02-08 18:56:39.612 [SpringContextShutdownHook] INFO o.s.scheduling.concurrent.ThreadPoolTaskExecutor-Shutting down ExecutorService 'threadPoolTaskExecutor'
2022-02-08 18:56:39.634 [SpringContextShutdownHook] INFO com.alibaba.druid.pool.DruidDataSource-{dataSource-4} closing ...
2022-02-08 18:56:39.635 [SpringContextShutdownHook] INFO com.alibaba.druid.pool.DruidDataSource-{dataSource-4} closed
2022-02-08 18:56:40.288 [SpringContextShutdownHook] INFO o.s.a.r.listener.SimpleMessageListenerContainer-Waiting for workers to finish.
2022-02-08 18:56:40.561 [SpringContextShutdownHook] INFO o.s.a.r.listener.SimpleMessageListenerContainer-Successfully waited for workers to finish.
2022-02-08 18:56:40.769 [SpringContextShutdownHook] INFO o.s.scheduling.concurrent.ThreadPoolTaskScheduler-Shutting down ExecutorService 'taskScheduler'
2022-02-08 18:56:40.769 [SpringContextShutdownHook] INFO o.s.a.r.listener.SimpleMessageListenerContainer-Shutdown ignored - container is not active already
2022-02-08 18:56:40.808 [SpringContextShutdownHook] INFO o.s.scheduling.concurrent.ThreadPoolTaskExecutor-Shutting down ExecutorService 'threadPoolTaskExecutor'
2022-02-08 18:56:41.064 [SpringContextShutdownHook] INFO com.alibaba.druid.pool.DruidDataSource-{dataSource-1} closing ...
2022-02-08 18:56:41.070 [SpringContextShutdownHook] INFO com.alibaba.druid.pool.DruidDataSource-{dataSource-1} closed
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment