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 2019/8/24.
 */
public class LocalTestByProxy {

    private static final String bizType = "MACH";
    private static final String contractId = "ccb1deff1086449d87106a6478f34ca4";

    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();
        LocalTestByProxy.generateData(reqSource);

        //String req = "{\"accountPointCode\":\"02\",\"contractId\":\"67e28d2715684d6e8db0eb77f86cc567\",\"operMan\":\"王楠\",\"sourceProperties\":[{\"bizId\":\"72372405-69ff-47a3-af0e-541e4d062427\",\"bizTime\":\"2019-08-29 10:19:44\",\"bizType\":\"02\",\"property\":{\"BILL_CALC\":\"1\",\"I_E_ID\":\"0\"},\"spare\":{}},{\"bizId\":\"72372405-69ff-47a3-af0e-541e4d062427\",\"bizTime\":\"2019-08-29 10:19:44\",\"bizType\":\"02\",\"property\":{\"MAIN_CNTR\":\"1\",\"quantity\":\"2\",\"I_E_ID\":\"0\",\"V_V_C_SIZE_DATA_FEE_FEE\":\"20\"},\"spare\":{}}],\"tenancyId\":\"01\"}";
        //String str = fee.callback(req);
        String str = fee.callback(JSON.toJSONString(reqSource));
        //fee.call(JSON.toJSONString(reqSource));
    }

    /**
     * 箱,票,拼箱比例费用计算(代理费)
     * @param reqSource
     */
    public static void generateData(ReqSource reqSource){

        List<SourceProperty> sources = new ArrayList<>();
        //包干航次
        String mainId  = "8f548bf59afa4440b86636c10ba";
        SourceProperty bill = new SourceProperty();
        sources.add(bill);
        bill.setBizId(mainId);
        bill.setBizTime(TimeUtil.getDateTime());
        bill.setBizType(bizType);
        JSONObject billMap = new JSONObject();
        //billMap.put("TAKEOVER_PROXY_FEE", "包干代理费");
        //billMap.put(ICondition.LIN_ID, "营运人code");
        //billMap.put(ICondition.CAR_AGE, "货代code");
        billMap.put(ICondition.weight, "1000.435");
        billMap.put("TRADE_ID", "1");
        bill.setProperty(billMap);

        //箱1
        /*String bizId = "8f548bf59afa4440b86636c10ba31547";
        SourceProperty cntr = new SourceProperty();
        sources.add(cntr);
        cntr.setBizId(bizId);
        cntr.setBizTime(TimeUtil.getDateTime());
        cntr.setBizType(bizType);
        JSONObject cntrMap = new JSONObject();
        cntrMap.put("V_C_SIZE_DATA_FEE", "20");
        cntrMap.put("E_F_IDCODE", "E");
        cntrMap.put(ICondition.QUANTITY, "8");
        cntrMap.put(ICondition.LIN_ID, "营运人CODE");
        cntrMap.put(ICondition.CAR_AGE, "货代code");
        cntr.setProperty(cntrMap);
        //箱2
        String bizId2 = "8f548bf59afa4440b86636c10ba31";
        SourceProperty cntr2 = new SourceProperty();
        sources.add(cntr2);
        cntr2.setBizId(bizId2);
        cntr2.setBizTime(TimeUtil.getDateTime());
        cntr2.setBizType(bizType);
        JSONObject cntrMap2 = new JSONObject();

        cntrMap2.put("V_C_SIZE_DATA_FEE", "20");
        cntrMap2.put("E_F_IDCODE", "F");
        cntrMap2.put("TRANS_FLAG_FEE", "中转");
        cntrMap2.put(ICondition.QUANTITY, "50");
        cntrMap2.put(ICondition.LIN_ID, "营运人code");
        cntrMap2.put(ICondition.CAR_AGE, "货代code");
        cntr2.setProperty(cntrMap2);*/

        reqSource.setSourceProperties(sources);
        reqSource.setTenancyId("QHD");
        reqSource.setOperMan("admin");
        reqSource.setContractId(contractId);
        //reqSource.setItemId("8f548bf59afa4440b86636c10ba31547");
        reqSource.setAccountPointCode(bizType);
    }


}
