package com.sckw.transport.dubbo;

import com.sckw.transport.api.dubbo.ParkingWalletFeeRemoteService;
import com.sckw.transport.api.model.param.ParkingWalletFeeFreezeParam;
import com.sckw.transport.api.model.vo.ParkingWalletFeeFreezeResult;
import com.sckw.transport.service.ParkingWalletFeeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * 服务费远程服务实现
 */
@Slf4j
@Service
@DubboService(group = "design", version = "1.0.0", timeout = 60000)
@RequiredArgsConstructor
public class ParkingWalletFeeRemoteServiceImpl implements ParkingWalletFeeRemoteService {

    private final ParkingWalletFeeService parkingWalletFeeService;

    @Override
    public ParkingWalletFeeFreezeResult applyChargeStrategyFreeze(ParkingWalletFeeFreezeParam param) {
        return parkingWalletFeeService.applyChargeStrategyFreeze(param);
    }

    @Override
    public ParkingWalletFeeFreezeResult unfreezeChargeStrategy(ParkingWalletFeeFreezeParam param) {
        return parkingWalletFeeService.unfreezeChargeStrategy(param);
    }

    @Override
    public ParkingWalletFeeFreezeResult settleChargeStrategy(ParkingWalletFeeFreezeParam param) {
        log.info("远程调用服务费完结结算，订单号:{}, 采购方企业ID:{}, 供应商企业ID:{}",
                param == null ? null : param.getOrderNo(),
                param == null ? null : param.getProEntId(),
                param == null ? null : param.getSupEntId());
        return parkingWalletFeeService.settleChargeStrategy(param);
    }

    @Override
    public BigDecimal queryServiceFeeBalance(Long proEntId, Long supEntId) {
        return parkingWalletFeeService.queryPurchaserServiceFeeBalance(proEntId, supEntId);
    }
}
