package com.ag.test;

import com.ag.account.service.FeeController;
import com.ag.entity.fee.face.ICondition;
import com.ag.entity.fee.face.ReqSource;
import com.ag.entity.fee.face.SourceProperty;
import com.ag.util.TimeUtil;
import com.alibaba.fastjson.JSONObject;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by yangxh on 2019/8/27.
 */
public class LocalTestByCntrStore {

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("classpath:META-INF/spring/dubbo-provider.xml");
        FeeController fee = context.getBean(FeeController.class);
        ReqSource reqSource = new ReqSource();
        LocalTestByCntrStore.generateData(reqSource);
        //LocalTestData.generateDataByStore(reqSource);

        String req = "{\"accountPointCode\":\"08\",\"contractId\":\"67e28d2715684d6e8db0eb77f86cc567\",\"operMan\":\"admin\",\"sourceProperties\":[{\"bizId\":\"A8165E60D2BF462D942DE97E3BA58911\",\"bizTime\":\"2019-10-17 15:49:49\",\"bizType\":\"08\",\"property\":{\"V_C_TYPE_DATA_FEE\":\"HC\",\"LIN_ID\":\"IRNL\",\"timeOn\":\"2019-09-19 00:00:00\",\"timeEnd\":\"2019-10-16 00:00:00\",\"derateType\":\"1\",\"I_E_ID\":\"1\",\"V_C_SIZE_DATA_FEE\":\"40\",\"derateDay\":\"10\",\"V_C_CLIENT_DATA_YYR_FEE\":\"IRNL\"},\"spare\":{}}],\"tenancyId\":\"010102\"}\n";
        String str = fee.callback(req);
        //String str = fee.callback(JSON.toJSONString(reqSource));
        //System.out.println(str);
    }

    /**
     * 箱*天 阶梯费率计算(重箱堆存费)
     * @param reqSource
     */
    public static void generateData(ReqSource reqSource) {
        List<SourceProperty> sources = new ArrayList<>();
        //箱1
        String bizId = "789456rt";
        SourceProperty cntr = new SourceProperty();
        sources.add(cntr);
        cntr.setBizId(bizId);
        cntr.setBizTime(TimeUtil.getDateTime());
        cntr.setBizType("08");
        JSONObject cntrMap = new JSONObject();
        cntrMap.put("V_C_TYPE_DATA_FEE", "HD");
        cntrMap.put("V_C_SIZE_DATA_FEE", "40");
        cntrMap.put("I_E_ID", "1");
        cntrMap.put("V_C_CLIENT_DATA_YYR_FEE", "IRNL");
        cntrMap.put(ICondition.TIME_ON, "2019-08-01 00:00:00");
        cntrMap.put(ICondition.TIME_END, "2019-08-13 00:00:00");
        cntrMap.put(ICondition.LIN_ID, "IRNL");
        cntrMap.put(ICondition.CAR_AGE, "货代code");
        cntr.setProperty(cntrMap);
        //箱2
        String bizId2 = "9654321gg";
        SourceProperty cntr2 = new SourceProperty();
        sources.add(cntr2);
        cntr2.setBizId(bizId2);
        cntr2.setBizTime(TimeUtil.getDateTime());
        cntr2.setBizType("08");
        JSONObject cntrMap2 = new JSONObject();
        cntrMap2.put("V_C_TYPE_DATA_FEE", "HD");
        cntrMap2.put("V_C_SIZE_DATA_FEE", "40");
        cntrMap2.put("I_E_ID", "0");
        cntrMap2.put("V_C_CLIENT_DATA_YYR_FEE", "IRNL");
        //cntrMap2.put("EIR_APPLY_TYPE", "03");
        cntrMap2.put(ICondition.TIME_ON, "2019-08-01 00:00:00");
        cntrMap2.put(ICondition.TIME_END, "2019-08-20 00:00:00");
        cntrMap2.put(ICondition.LIN_ID, "IRNL");
        cntrMap2.put(ICondition.CAR_AGE, "货代code");
        cntrMap2.put(ICondition.DERATE_TYPE, "2");
        cntrMap2.put(ICondition.DERATE_DAY, "10");
        cntrMap2.put(ICondition.DERATE_MONEY, "200");
        cntr2.setProperty(cntrMap2);

        reqSource.setSourceProperties(sources);
        reqSource.setTenancyId("01");
        reqSource.setOperMan("admin");
        reqSource.setContractId("67e28d2715684d6e8db0eb77f86cc567");
        //reqSource.setItemId("8f548bf59afa4440b86636c10ba31547");
        reqSource.setAccountPointCode("08");
    }
}
