BACKOFFICE SALESSERVICE

mail@pastecode.io avatar
unknown
java
2 years ago
4.5 kB
1
Indexable
Never
package com.oto11.service;

import com.oto11.dto.PageData;
import com.oto11.dto.sales.SalesDTO;
import com.oto11.dto.settlement.SettlementPaymentDTO;
import com.oto11.dto.settlement.SettlementSalesDTO;
import com.oto11.dto.settlement.ws.*;
import com.oto11.feign_client.GarajimClient;
import com.oto11.feign_client.SettlementWsClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

@Service
@RequiredArgsConstructor
@Log4j2
public class SalesService {

    @Value("${backoffice.garajimapi.key}")
    private String apiKey;

    @Value("${backoffice.garajimapi.secret}")
    private String apiSecret;

    private final GarajimClient garajimClient;

    private final SettlementWsClient settlementWsClient;

    public PageData<List<SalesDTO>> findSalesList(Long orderId, String buyerId, String buyerName, String buyerSurname, String sellerId, String sellerName, String plate, String garageId, String vehicleTitle, String beginDate, String endDate, String salesType, Integer pageNo, Integer pageSize, String sortBy, String sortType,String campaign) {
        return garajimClient.findSalesList(apiKey, apiSecret, orderId, buyerId, buyerName, buyerSurname, sellerId, sellerName, plate, garageId, vehicleTitle, beginDate, endDate, salesType, pageNo, pageSize, sortBy, sortType,campaign).getBody();
    }

    public SalesDTO getSales(String carId, Long orderId) {
        return garajimClient.getSales(apiKey, apiSecret, carId, orderId).getBody();
    }

    public String updateSales(SalesDTO sales) {
        garajimClient.updateSales(apiKey, apiSecret, sales).getBody();
        return "";
    }

    public SettlementSalesDTO findSales(Long salesId) {
        return garajimClient.findSales(apiKey, apiSecret, salesId).getBody();
    }

    public ResponseEntity<List<SalesDTO>> findAllSalesList(Long orderId, String buyerId, String buyerName, String buyerSurname, String sellerId, String sellerName, String plate, String garageId, String vehicleTitle, Timestamp beginDate, Timestamp endDate, String salesType) {
        return garajimClient.findAllSalesList(apiKey, apiSecret, orderId, buyerId, buyerName, buyerSurname, sellerId, sellerName, plate, garageId, vehicleTitle, beginDate, endDate, salesType);
    }

    public SettlementPaymentDTO findPaymentByOrderId(Long orderId) {
        return garajimClient.findPaymentByOrderId(apiKey, apiSecret, orderId).getBody();
    }

    public List<SettlementPaymentDTO> findPaymentsByOrderId(Long orderId) {
        return garajimClient.findPaymentsByOrderId(apiKey, apiSecret, orderId).getBody();
    }

    public Boolean setDeliveredDate(String carId, Timestamp deliveredDate) {
        return garajimClient.setDeliveredDate(apiKey, apiSecret, carId, deliveredDate).getBody();
    }

    public Boolean setSettlementStatus(Long orderId, Integer settlementStatus) {
        return garajimClient.setSettlementStatus(apiKey, apiSecret, orderId, settlementStatus).getBody();
    }

    public BAPIRET2 sendReceiptOfPayment(ZFI_GRJ11_S_001 zfi_grj11_s_001, ZFI_GRJ11_S_002 zfi_grj11_s_002) {
        ZFI_GRJ11_S_001_002 zfi_grj11_s_001_002 = new ZFI_GRJ11_S_001_002();
        zfi_grj11_s_001_002.setZfi_grj11_s_001(zfi_grj11_s_001);
        zfi_grj11_s_001_002.setZfi_grj11_s_002(zfi_grj11_s_002);
        return settlementWsClient.pushReceiptOfPayment(apiKey, apiSecret, zfi_grj11_s_001_002).getBody();
    }

    public BAPIRET2 sendPayment(ZFI_GRJ11_S_004 zfi_grj11_s_004) {
        return settlementWsClient.pushPayment(apiKey, apiSecret, zfi_grj11_s_004).getBody();
    }

    public BAPIRET2 sendCommission(ZFI_GRJ11_S_003 zfi_grj11_s_003) {
        return settlementWsClient.pushCommission(apiKey, apiSecret, zfi_grj11_s_003).getBody();
    }

    public BAPIRET2 sendReceiptOfPayments(List<ZFI_GRJ11_S_001_002> items) {
        return settlementWsClient.pushReceiptOfPayments(apiKey, apiSecret, items).getBody();
    }

    public BAPIRET2 sendPayments(List<ZFI_GRJ11_S_004> items) {
        return settlementWsClient.pushPayments(apiKey, apiSecret, items).getBody();
    }

    public BAPIRET2 sendCommissions(List<ZFI_GRJ11_S_003> items) {
        return settlementWsClient.pushCommissions(apiKey, apiSecret, items).getBody();
    }

}