陶杰
2024-08-22 ee9032d9baf5f33e376d2d2699136e0a7b26bec7
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
package com.mzl.flower.web.init;
 
import com.mzl.flower.base.BaseController;
import com.mzl.flower.base.R;
import com.mzl.flower.base.ReturnDataDTO;
import com.mzl.flower.constant.Constants;
import com.mzl.flower.dto.request.payment.UserPaymentDTO;
import com.mzl.flower.service.payment.UserPaymentV3Service;
import com.mzl.flower.service.system.CodeService;
import com.mzl.flower.utils.UUIDGenerator;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
@RestController
@RequestMapping("/api/pub/init")
@Api(tags = "忽略-初始化接口管理")
@Validated
@Slf4j
public class InitResource extends BaseController {
 
    @Autowired
    private CodeService codeService;
 
    @Autowired
    private UserPaymentV3Service userPaymentV3Service;
 
    @GetMapping("/cache/{type}")
    public ResponseEntity<ReturnDataDTO> init(@PathVariable String type) {
        if("dict".equalsIgnoreCase(type)) {
            codeService.refreshCache();
        }
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/callback")
    public ResponseEntity<ReturnDataDTO> callback(String orderId) {
        String originalXml = "";
        UserPaymentDTO dto = new UserPaymentDTO();
        dto.setOrderId(orderId);
        dto.setTransactionId(UUIDGenerator.getUUID());
        dto.setOutTradeNo(orderId);
        dto.setOriginalXml(originalXml);
        dto.setPaymentAmountCallback("1");
        dto.setStatus(Constants.PAYMENT_STATUS.SUCCESS.name());
 
        userPaymentV3Service.saveCallbackInfo(dto, Constants.ORDER_STATUS_BACKEND.PAYMENT.name());
 
        return returnData(R.SUCCESS.getCode(), null);
    }
}