CashierDeskController.java
2.42 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
package com.diligrp.cashier.boss.controller;
import com.diligrp.cashier.boss.domain.CashierOrderDTO;
import com.diligrp.cashier.boss.domain.CashierPaymentUrl;
import com.diligrp.cashier.boss.service.ICashierDeskService;
import com.diligrp.cashier.boss.service.IMerchantService;
import com.diligrp.cashier.boss.util.CashierOrderConverter;
import com.diligrp.cashier.pipeline.domain.OnlinePaymentStatus;
import com.diligrp.cashier.shared.domain.Message;
import com.diligrp.cashier.shared.util.AssertUtils;
import com.diligrp.cashier.trade.domain.CashierOrder;
import com.diligrp.cashier.trade.domain.CashierPayment;
import com.diligrp.cashier.trade.domain.Merchant;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/payment/cashier")
public class CashierDeskController {
@Resource
private IMerchantService merchantService;
@Resource
private ICashierDeskService cashierDeskService;
@RequestMapping("/submitOrder")
public Message<?> submitOrder(@RequestBody CashierOrderDTO request) {
// 基本参数校验
AssertUtils.notNull(request.getMchId(), "mchId missed");
AssertUtils.notEmpty(request.getUserId(), "userId missed");
AssertUtils.notNull(request.getCashierType(), "cashierType missed");
AssertUtils.notEmpty(request.getGoods(), "goods missed");
AssertUtils.notNull(request.getAmount(), "amount missed");
AssertUtils.isTrue(request.getAmount() > 0, "Invalid amount");
AssertUtils.notEmpty(request.getOutTradeNo(), "outTradeNo missed");
CashierOrder cashierOrder = CashierOrderConverter.INSTANCE.convert(request);
Merchant merchant = merchantService.loadCashierMerchant(request.getMchId());
CashierPaymentUrl paymentUrl = cashierDeskService.doSubmit(merchant, cashierOrder);
return Message.success(paymentUrl);
}
@RequestMapping("/orderPayment")
public Message<?> orderPayment(@RequestBody CashierPayment request) {
// 基本参数校验
AssertUtils.notEmpty(request.getTradeId(), "paymentId missed");
AssertUtils.notNull(request.getPipelineId(), "pipelineId missed");
OnlinePaymentStatus paymentStatus = cashierDeskService.doPayment(request);
return Message.success(paymentStatus);
}
}