package com.hzs.sale.pub.provider;

import com.hzs.common.core.domain.R;
import com.hzs.common.core.enums.EApprovalBusiness;
import com.hzs.sale.pub.ISaleApprovalServiceApi;
import com.hzs.sale.pub.service.ISaleApprovalBusiness;
import com.hzs.system.sys.dto.ApprovalBusinessResultDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Description:
 * @Author: sui q
 * @Time: 2022/10/25 13:47
 * @Classname: SaleApprovalBusiness
 * @PackageName: com.hzs.sale.pub.provider
 */
@Slf4j
@DubboService
public class SaleApprovalBusinessProvider implements ISaleApprovalServiceApi {

    private ISaleApprovalBusiness saleApprovalBusiness;

    @Autowired
    public void setSaleApprovalBusiness(ISaleApprovalBusiness saleApprovalBusiness) {
        this.saleApprovalBusiness = saleApprovalBusiness;
    }

    @Override
    public R<Boolean> approvalCallback(ApprovalBusinessResultDTO approvalBusinessResultDTO) {
        try {
            saleApprovalBusiness.approvalCallback(approvalBusinessResultDTO);
            return R.ok();
        } catch (Exception e) {
            log.error("订单业务处理回调异常", e);
            return R.fail(e.getMessage());
        }
    }

    @Override
    public R queryApprovalData(EApprovalBusiness eApprovalBusiness, String businessCode, String toLanguageTag) {
        try {
            return R.ok(saleApprovalBusiness.approvalData(eApprovalBusiness, businessCode, toLanguageTag));
        } catch (Exception e) {
            log.error("订单业务数据查询异常", e);
            return R.fail(e.getMessage());
        }
    }

}
