package com.trade.client;

import com.trade.client.credit.controller.BizCreditApplyController;
import com.trade.client.credit.controller.BizEntityCreditAuthController;
import com.trade.service.TransStruct;
import com.trade.service.credit.domain.vo.BizCreditApplyVO;
import com.trade.service.trade.salesorder.domain.SalesOrderGoods;
import com.trade.service.trade.salesorder.dto.GoodsInfo4TL;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@SpringBootTest
public class CreditApplyTest {

    @Resource
    private BizCreditApplyController creditApplyController;
    @Autowired
    private TransStruct transStruct;
    @Resource
    private BizEntityCreditAuthController bizEntityCreditAuthController;

    @Test
    public void structTest() {
//        BizCreditApplyVO bizCreditApplyVO = new BizCreditApplyVO();
//        bizCreditApplyVO.setBizProd("example_prod");
//        bizCreditApplyVO.setCurrency("CNY");
//        BizCreditApply creditApply =  transStruct.vO2BizCreditApply(bizCreditApplyVO);
//        System.out.println(creditApply.getBizProd());


        List<SalesOrderGoods> salesOrderGoodsList = new ArrayList<>();
        SalesOrderGoods goods1 = new SalesOrderGoods();
        goods1.setHsCode("123");
        goods1.setCount(new BigDecimal("6"));
        goods1.setPriceTotal(new BigDecimal(800));
        salesOrderGoodsList.add(goods1);
        SalesOrderGoods goods2 = new SalesOrderGoods();
        goods2.setHsCode("123");
        goods2.setCount(new BigDecimal("6"));
        goods2.setPriceTotal(new BigDecimal(900));
        salesOrderGoodsList.add(goods2);
        List<GoodsInfo4TL> goodsList = transStruct.transOrder2GoodsInfo4TLList(salesOrderGoodsList);
        goodsList.forEach(e-> System.out.println(e.getAmount()));

    }



    @Test
    public void tempSaveTest() {
        BizCreditApplyVO bizCreditApplyVO = new BizCreditApplyVO();
        bizCreditApplyVO.setBizProd("example_prod");
        bizCreditApplyVO.setCurrency("CNY");
        creditApplyController.tempSave(bizCreditApplyVO);
    }
    
    
    @Test
    public void authTest() {
        bizEntityCreditAuthController.doAuth(123L);
    }



}
