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.JSON;
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 2020/12/19.
 */
public class LocalTestByBulkStore {
    private static final String bizType = "store";
    private static final String itemIds = "002";
    private static final String contractId = "38d0362f69824db8b9c9853e72dec930";

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring/dubbo-provider.xml");
        FeeController fee = context.getBean(FeeController.class);
        ReqSource reqSource = new ReqSource();
        LocalTestByBulkStore.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<>();
        String bizId01 = "8f548bf59afa4440b86636c10ba31";
        SourceProperty store01 = new SourceProperty();
        sources.add(store01);
        store01.setBizId(bizId01);
        store01.setBizTime(TimeUtil.getDateTime());
        store01.setBizType(bizType);
        JSONObject storeMap01 = new JSONObject();
        storeMap01.put(ICondition.TIME_ON, "2019-08-01 00:00:00");
        storeMap01.put(ICondition.TIME_END, "2019-08-13 00:00:00");
        storeMap01.put(ICondition.weight, 800);
        storeMap01.put("CARGO_CODE", "HB");
        storeMap01.put("TRADE_ID", "1");
        storeMap01.put("STORAGE_FLAG", "0");
        storeMap01.put("COV_ID", "1");
        store01.setProperty(storeMap01);

        String bizId02 = "8f548bf59afa33";
        SourceProperty store02 = new SourceProperty();
        sources.add(store02);
        store02.setBizId(bizId02);
        store02.setBizTime(TimeUtil.getDateTime());
        store02.setBizType(bizType);
        JSONObject storeMap02 = new JSONObject();
        storeMap02.put(ICondition.TIME_ON, "2019-08-02 00:00:00");
        storeMap02.put(ICondition.TIME_END, "2019-08-14 00:00:00");
        storeMap02.put(ICondition.weight, 600);
        storeMap02.put("CARGO_CODE", "HB");
        storeMap02.put("TRADE_ID", "1");
        storeMap02.put("STORAGE_FLAG", "0");
        storeMap02.put("COV_ID", "0");
        store02.setProperty(storeMap02);

        reqSource.setSourceProperties(sources);
        //reqSource.setTenancyId("QHD");
        reqSource.setOperMan("admin");
        reqSource.setContractId(contractId);
        reqSource.setItemId(itemIds);
    }
}
