package com.fs.company.controller;

import com.fs.FSAdminApplication;
import com.fs.common.config.FSSysConfig;
import com.fs.common.core.domain.R;
import com.fs.erp.domain.ErpOrder;
import com.fs.erp.domain.ErpOrderItem;
import com.fs.erp.service.IErpOrderService;
import com.fs.erp.service.impl.ErpOrderServiceImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@RunWith(org.springframework.test.context.junit4.SpringRunner.class)
@SpringBootTest(classes = FSAdminApplication.class)
public class CompanyControllerTest {

    @Autowired
    private FSSysConfig fsSysConfig;

    @Autowired
    private IErpOrderService erpOrderService;


    @Test
    public void addOrder() {
        ErpOrder order=new ErpOrder();
        order.setShop_code(fsSysConfig.getErpShopCode());
        order.setVip_code("10000");
        order.setPlatform_code("202211111110");
        order.setWarehouse_code("CQDS001");
        order.setExpress_code("YZJD");
        order.setPost_fee(1.00);
        order.setSeller_memo("备注");
        // order.setCurrency_code("JCZD");
        // order.setCod_fee(2.00);//到 付服务费
        order.setBuyer_memo("备注");
        order.setOrder_type_code("order");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        order.setDeal_datetime(sdf.format(new Date()));
        List<ErpOrderItem> details=new ArrayList<>();
        ErpOrderItem item=new ErpOrderItem();
        item.setItem_code("105015");
        // item.setSku_code("1122");
        item.setOrigin_price("1.00");
        item.setPrice("12.00");
        item.setQty(1);
        item.setRefund(0);
        details.add(item);
        order.setDetails(details);
        order.setReceiver_name("张三");
        order.setReceiver_mobile("15193139333");
        order.setReceiver_province("重庆市");
        order.setReceiver_city("重庆市");
        order.setReceiver_district("江北区");
        order.setReceiver_address("观音桥街道中翰名苑");
        erpOrderService.addOrder(order);
    }
}
