刷新退款结果
This commit is contained in:
parent
d61b9e9391
commit
65754161b6
|
@ -82,4 +82,14 @@ public interface RefundService
|
||||||
* 创建退款并发起退款
|
* 创建退款并发起退款
|
||||||
*/
|
*/
|
||||||
int createRefund(Refund refund);
|
int createRefund(Refund refund);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新退款结果
|
||||||
|
*/
|
||||||
|
int refreshResult(Long refundId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新退款结果
|
||||||
|
*/
|
||||||
|
int refreshResult(RefundVO refund);
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,4 +218,34 @@ public class RefundServiceImpl implements RefundService
|
||||||
|
|
||||||
return result == null ? 0 : result;
|
return result == null ? 0 : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int refreshResult(Long refundId) {
|
||||||
|
RefundVO refund = selectRefundByRefundId(refundId);
|
||||||
|
return this.refreshResult(refund);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int refreshResult(RefundVO refund) {
|
||||||
|
if (refund == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!RefundStatus.REFUNDING.getStatus().equals(refund.getStatus())) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通联微信
|
||||||
|
if (TransactionBillPayType.TL_WX.getType().equals(refund.getChannelId())) {
|
||||||
|
Map<String, String> params = sybPayService.queryOrderByOutTradeNo(refund.getRefundNo());
|
||||||
|
String trxStatus = params.get("trxstatus");
|
||||||
|
if (SybTrxStatus.isSuccess(trxStatus)) {
|
||||||
|
// 退款成功
|
||||||
|
scheduledExecutorService.schedule(() -> {
|
||||||
|
this.handleRefundSuccess(refund.getRefundNo());
|
||||||
|
}, 0, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.ruoyi.task.refund;
|
||||||
|
|
||||||
|
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||||
|
import com.ruoyi.ss.refund.domain.RefundQuery;
|
||||||
|
import com.ruoyi.ss.refund.domain.RefundVO;
|
||||||
|
import com.ruoyi.ss.refund.domain.enums.RefundStatus;
|
||||||
|
import com.ruoyi.ss.refund.service.RefundService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wjh
|
||||||
|
* 2024/9/11
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class RefundTask {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RefundService refundService;
|
||||||
|
|
||||||
|
// 刷新退款结果
|
||||||
|
public void refreshRefundResult() {
|
||||||
|
// 查询退款中的退款订单
|
||||||
|
RefundQuery query = new RefundQuery();
|
||||||
|
query.setStatus(RefundStatus.REFUNDING.getStatus());
|
||||||
|
List<RefundVO> list = refundService.selectRefundList(query);
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmptyElement(list)) {
|
||||||
|
log.info("没有正在退款中的退款订单");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理退款订单
|
||||||
|
for (RefundVO refund : list) {
|
||||||
|
try {
|
||||||
|
log.info("退款订单处理:{}", refund.getRefundNo());
|
||||||
|
int i = refundService.refreshResult(refund);
|
||||||
|
log.info("处理结果:{}", i);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("退款订单{}处理失败:{}", refund.getRefundNo(), e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -72,36 +72,10 @@ public class RefundController extends BaseController
|
||||||
return success(refundService.selectRefundByRefundId(refundId));
|
return success(refundService.selectRefundByRefundId(refundId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@PreAuthorize("@ss.hasPermi('ss:refund:refresh')")
|
||||||
* 新增退款订单
|
@PutMapping(value = "/refresh/{refundId}")
|
||||||
*/
|
public AjaxResult refreshResult(@PathVariable("refundId") Long refundId)
|
||||||
@PreAuthorize("@ss.hasPermi('ss:refund:add')")
|
|
||||||
@Log(title = "退款订单", businessType = BusinessType.INSERT)
|
|
||||||
@PostMapping
|
|
||||||
public AjaxResult add(@RequestBody Refund refund)
|
|
||||||
{
|
{
|
||||||
return toAjax(refundService.insertRefund(refund));
|
return success(refundService.refreshResult(refundId));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改退款订单
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('ss:refund:edit')")
|
|
||||||
@Log(title = "退款订单", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult edit(@RequestBody Refund refund)
|
|
||||||
{
|
|
||||||
return toAjax(refundService.updateRefund(refund));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除退款订单
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('ss:refund:remove')")
|
|
||||||
@Log(title = "退款订单", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{refundIds}")
|
|
||||||
public AjaxResult remove(@PathVariable Long[] refundIds)
|
|
||||||
{
|
|
||||||
return toAjax(refundService.deleteRefundByRefundIds(refundIds));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user