RtMallOrderRefundApi.java 2.44 KB
package com.diligrp.cashier.mall.api;

import com.diligrp.cashier.mall.domain.rtmall.RtMarkMessage;
import com.diligrp.cashier.mall.domain.rtmall.co.OrderCO;
import com.diligrp.cashier.mall.domain.rtmall.vo.OrderSuccessVO;
import com.diligrp.cashier.mall.service.biz.MallBizOrderService;
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 jakarta.validation.Valid;
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", "/rt/mall"})
@Validated
public class RtMallOrderRefundApi {
    @Resource
    private MallBizOrderService mallBizOrderService;

    /**
     * createOrder
     * @see https://shopex.yuque.com/hl0rrx/vlp0m4/nkwt5yrhdfzoy78s?singleDoc#oJ2JC
     * 创建订单接口
     */
    @PostMapping("/refund/v1")
    @ParamLogPrint(outPrint = true)
    @Sign(sign = RtMallSign.class)
    @RepeatSubmit(prefix = "order_sync:", value = "#req['order_id']", duplicationSubmit = SpelDuplicationSubmit.class)
    public RtMarkMessage<OrderSuccessVO> refund(@Valid @RequestBody Object req) {
        OrderCO orderCo = JsonUtils.convertValue(req, OrderCO.class);
        RtMallValidateUtils.valid(orderCo);
        return RtMarkMessage.success(mallBizOrderService.createOrder(orderCo));
    }

    /**
     * info
     * @see https://shopex.yuque.com/hl0rrx/vlp0m4/nkwt5yrhdfzoy78s?singleDoc#oJ2JC
     * 查询订单状态
     */
    @PostMapping("/refund/v1/info")
    @ParamLogPrint(outPrint = true)
    @Sign(sign = RtMallSign.class)
    public RtMarkMessage<?> info(@Valid @RequestBody Object req) {
        OrderCO orderCo = JsonUtils.convertValue(req, OrderCO.class);
        RtMallValidateUtils.valid(orderCo);
        return RtMarkMessage.success();
    }
}