ManualHandlerApi.java
2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.diligrp.cashier.mall.api;
import com.diligrp.cashier.mall.context.MallInitializeContext;
import com.diligrp.cashier.mall.dao.MallBizRefundDao;
import com.diligrp.cashier.mall.model.MallBizPayment;
import com.diligrp.cashier.mall.model.MallBizRefund;
import com.diligrp.cashier.mall.service.biz.MallBizPaymentService;
import com.diligrp.cashier.mall.service.biz.PayNotifyService;
import com.diligrp.cashier.shared.domain.Message;
import com.diligrp.cashier.shared.spi.domain.PaymentResultBO;
import com.diligrp.cashier.shared.spi.domain.RefundResultBO;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @ClassName ManualHandlerApi.java
* @author dengwei
* @version 1.0.0
* @Description ManualHandlerApi
*/
@RestController
@RequestMapping(path = "/mall/manual")
@Validated
public class ManualHandlerApi {
@Resource
private PayNotifyService payNotifyServiceImpl;
@Resource
private MallBizPaymentService mallBizPaymentService;
@Resource
private MallBizRefundDao mallBizRefundDao;
@PostMapping("/payment/event")
public Message<?> handlePaymentEvent(@RequestBody PaymentResultBO payment) {
payNotifyServiceImpl.onEvent(payment);
return Message.success();
}
@PostMapping("/refund/event")
public Message<?> handlePaymentEvent(@RequestBody RefundResultBO refund) {
payNotifyServiceImpl.onEvent(refund);
return Message.success();
}
@PostMapping("/payment/callback/{source}")
public Message<?> paymentCallback(@RequestBody PaymentResultBO payment, @PathVariable("source") Integer source) {
String tradeId = payment.getTradeId();
MallBizPayment mallBizPayment = mallBizPaymentService.getByPayTradeId(tradeId);
MallInitializeContext.getBySource(source).payCallBack(payment, mallBizPayment);
return Message.success();
}
@PostMapping("/refund/callback/{source}")
public Message<?> refundCallback(@RequestBody RefundResultBO refund, @PathVariable("source") Integer source) {
MallBizRefund mallBizRefund = mallBizRefundDao.getByRefundTradeId(refund.getRefundId());
MallInitializeContext.getBySource(source).refundCallBack(refund, mallBizRefund);
return Message.success();
}
@GetMapping("/refund/event")
public Message<?> handlePaymentEvent(String tradeId) {
return Message.success(payNotifyServiceImpl.redirectUrl(tradeId));
}
}