package com.hzs.sale.refund.provider;

import com.hzs.common.core.domain.R;
import com.hzs.sale.refund.ISaRefundServiceApi;
import com.hzs.sale.refund.service.IRefundBusinessService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Description: 订单退款对外服务api
 * @Author: jiang chao
 * @Time: 2023/8/26 14:45
 * @Classname: SaRefundServiceProvider
 * @PackageName: com.hzs.sale.order.provider
 */
@Slf4j
@DubboService
public class SaRefundServiceProvider implements ISaRefundServiceApi {

    @Autowired
    private IRefundBusinessService iRefundBusinessService;

    @Override
    public R<String> onlinePayRefundCallback(String orderCode, String refundCode, Integer refundStatus, String refundMsg) {
        try {
            String str = iRefundBusinessService.refundOnlineCallback(orderCode, refundCode, refundStatus, refundMsg);
            if (null == str) {
                return R.ok();
            }
            return R.fail("直销订单在线支付退款失败: {}", str);
        } catch (Exception e) {
            log.error("直销订单在线支付退款异常: ", e);
            return R.fail("直销订单在线支付退款异常： {}", e.getMessage());
        }
    }

}
