package com.api.test;

import com.alibaba.fastjson.JSON;
import com.heyu.api.data.kuaidi100.VvTradeOrderLineDO;
import com.heyu.api.data.entity.vv.VvTradeOrderLineEntity;
import com.heyu.api.data.utils.MD5Utils;
import com.heyu.api.data.utils.SanUtils;
import org.junit.Test;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class Test4 {
    public static void main(String[] args) {
        String code = MD5Utils.encode("quyixiaohukaiming");

        System.out.println(code);

        String code2 = MD5Utils.encode("quzhixing");

        System.out.println(code2);

    }


    @Test
    public void test1() {

        VvTradeOrderLineEntity vvTradeOrderLineEntity1 = new VvTradeOrderLineEntity();
        VvTradeOrderLineEntity vvTradeOrderLineEntity2 = new VvTradeOrderLineEntity();
        VvTradeOrderLineEntity vvTradeOrderLineEntity3 = new VvTradeOrderLineEntity();

        vvTradeOrderLineEntity1.setId(1L);
        vvTradeOrderLineEntity2.setId(2L);
        vvTradeOrderLineEntity3.setId(3L);


        vvTradeOrderLineEntity1.setSkuId(1L);
        vvTradeOrderLineEntity2.setSkuId(2L);
        vvTradeOrderLineEntity3.setSkuId(2L);


        vvTradeOrderLineEntity1.setSalePrice(new BigDecimal(10));
        vvTradeOrderLineEntity2.setSalePrice(new BigDecimal(15));
        vvTradeOrderLineEntity3.setSalePrice(new BigDecimal(18));


        vvTradeOrderLineEntity1.setPromotionPrice(new BigDecimal(3));
        vvTradeOrderLineEntity2.setPromotionPrice(new BigDecimal(2));
        vvTradeOrderLineEntity3.setPromotionPrice(new BigDecimal(19));


        List<VvTradeOrderLineEntity> vvTradeOrderLineEntityList = new ArrayList<>();
       vvTradeOrderLineEntityList.add(vvTradeOrderLineEntity1);
        vvTradeOrderLineEntityList.add(vvTradeOrderLineEntity2);
        vvTradeOrderLineEntityList.add(vvTradeOrderLineEntity3);


        // VvTradeOrderLineEntity vvTradeOrderLine = merge(vvTradeOrderLineEntityList, VvTradeOrderLineEntity::getSalePrice,
        //       VvTradeOrderLineEntity::getPromotionPrice,
        //     VvTradeOrderLineEntity::getRefundCount
        // );

        //System.out.println(JSON.toJSONString(vvTradeOrderLine));


        List<VvTradeOrderLineDO> vvTradeOrderLineDOList = SanUtils.copy2List(vvTradeOrderLineEntityList, VvTradeOrderLineDO.class);


        Map<Long, VvTradeOrderLineDO> vvTradeOrderLineMap = SanUtils.groupMerge2Map(VvTradeOrderLineEntity::getSkuId,
                vvTradeOrderLineDOList,
                VvTradeOrderLineEntity::getSalePrice,
                VvTradeOrderLineEntity::getPromotionPrice,
                VvTradeOrderLineEntity::getRefundCount,
                VvTradeOrderLineEntity::getId
        );

        System.out.println(JSON.toJSONString(vvTradeOrderLineMap));

    }
}