RtMallScanOrderRefundApi.java 3.24 KB
package com.diligrp.cashier.mall.api;

import com.diligrp.cashier.mall.domain.rtmall.RtMarkMessage;
import com.diligrp.cashier.mall.domain.rtmall.co.RefundCO;
import com.diligrp.cashier.mall.domain.rtmall.co.RefundStatusCO;
import com.diligrp.cashier.mall.domain.rtmall.vo.RefundSuccessVO;
import com.diligrp.cashier.mall.domain.rtmall.vo.RefundVO;
import com.diligrp.cashier.mall.service.biz.MallBizRefundService;
import com.diligrp.cashier.mall.sign.RtMallSign;
import com.diligrp.cashier.mall.util.RtMallValidateUtils;
import com.diligrp.cashier.shared.annotation.ParamLogPrint;
import com.diligrp.cashier.shared.annotation.RepeatSubmit;
import com.diligrp.cashier.shared.annotation.Sign;
import com.diligrp.cashier.shared.handler.duplication.SpelDuplicationSubmit;
import com.diligrp.cashier.shared.util.JsonUtils;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName RtMallOrderRefundApi.java
 * @author dengwei
 * @version 1.0.0
 * @Description RtMallOrderRefundApi
 */
@RestController
@RequestMapping(path = {"/api/rt/mall/scan", "/rt/mall/scan"})
@Validated
public class RtMallScanOrderRefundApi {
    @Resource
    private MallBizRefundService mallBizRefundService;

    /**
     * refund
     * @see https://shopex.yuque.com/hl0rrx/vlp0m4/kmcazgnimg28d8ih?singleDoc#jRAS2
     * 申请退款接口
     */
    @PostMapping("/refund/v1")
    @ParamLogPrint(outPrint = true)
    @Sign(sign = RtMallSign.class)
    @RepeatSubmit(
            prefix = "refund:",
            waitTime = 5,
            leaseTime = 10,
            value = {"#req['order_id']", "#req['trade_id']"},
            duplicationSubmit = SpelDuplicationSubmit.class)
    public RtMarkMessage<RefundSuccessVO> refund(@RequestBody Object req) {
        RefundCO refundCo = JsonUtils.convertValue(req, RefundCO.class);
        RtMallValidateUtils.valid(refundCo);
        return RtMarkMessage.success(mallBizRefundService.refund(refundCo));
    }

    /**
     * info
     * @see https://shopex.yuque.com/hl0rrx/vlp0m4/kmcazgnimg28d8ih?singleDoc#iYTdn
     * 查询退款状态
     */
    @PostMapping("/refund/v1/status")
    @ParamLogPrint(outPrint = true)
    @Sign(sign = RtMallSign.class)
    public RtMarkMessage<RefundVO> status(@RequestBody Object req) {
        RefundStatusCO refundStatusCo = JsonUtils.convertValue(req, RefundStatusCO.class);
        RtMallValidateUtils.valid(refundStatusCo);
        return RtMarkMessage.success(mallBizRefundService.info(refundStatusCo));
    }

    /**
     * info
     * @see https://shopex.yuque.com/hl0rrx/vlp0m4/kmcazgnimg28d8ih?singleDoc#iYTdn
     * 查询退款详情
     */
    @PostMapping("/refund/v1/info")
    @ParamLogPrint(outPrint = true)
    @Sign(sign = RtMallSign.class)
    public RtMarkMessage<RefundVO> info(@RequestBody Object req) {
        RefundStatusCO refundStatusCo = JsonUtils.convertValue(req, RefundStatusCO.class);
        RtMallValidateUtils.valid(refundStatusCo);
        return RtMarkMessage.success(mallBizRefundService.info(refundStatusCo));
    }
}