import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.PropertyNamingStrategy;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerBO;
import com.gic.haoban.manage.service.pojo.bo.content.TriggerCustomerDetailBO;
import com.gic.haoban.manage.service.pojo.qo.content.PotentialCustomerQO;
import com.gic.haoban.manage.service.service.MemberQueryService;
import com.gic.haoban.manage.service.service.content.PotentialCustomerService;
import com.gic.haoban.manage.service.service.content.TriggerCustomerDetailService;
import com.gic.member.api.dto.MemberDTO;
import com.gic.member.api.service.MemberService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.Collections;
import java.util.Date;

/**
 * @Author MUSI
 * @Date 2023/3/30 10:15 PM
 * @Description
 * @Version
 **/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class PotentialCustomerServiceTest {

    @Autowired
    PotentialCustomerService potentialCustomerService;
    @Autowired
    private MemberService memberService;
    @Autowired
    MemberQueryService memberQueryService;
    @Autowired
    private TriggerCustomerDetailService triggerCustomerDetailService;

    String eid = "ff8080815dacd3a2015dacd3ef5c0000";
    String wxEid = "ca66a01b79474c40b3e7c7f93daf1a3b";
    String staffId = "e608b51b267e4943b87e222a343b4f25";
    String clerkId = "bcbfff6c8e2e40aaac795a99d0dde2aa";
    String memberId = "ff8080818147efc8018148d1759903c8";

    @Test
    public void queryPotentialCustomerTest(){
        PotentialCustomerQO potentialCustomerQO = new PotentialCustomerQO();
        potentialCustomerQO.setEnterpriseId(eid);
        potentialCustomerQO.setWxEnterpriseId(wxEid);
        potentialCustomerQO.setClerkId(clerkId);
        potentialCustomerQO.setHasMemberRelation(1);
        potentialCustomerQO.setSearchType(2);
        potentialCustomerQO.setSearch("红");
        Page<PotentialCustomerBO> customerBOPage =
                potentialCustomerService.queryPotentialCustomerPage(potentialCustomerQO);
        System.out.println(JSON.toJSONString(customerBOPage));
    }

    @Test
    public void queryMemberinfo(){
        MemberDTO memberDTO = memberService.queryMember("ff8080818215878101821949a845003c");
        System.out.println(JSON.toJSONString(memberDTO));

        JSONObject jsonObject = memberQueryService.queryDataSingle(eid, "ff8080818215878101821949a845003c", null);
        System.out.println(jsonObject.toJSONString());
    }

    @Test
    public void triggerTest(){
        TriggerCustomerDetailBO triggerCustomerDetailBO = new TriggerCustomerDetailBO();
        triggerCustomerDetailBO.setId(UniqueIdUtils.uniqueLong());
        triggerCustomerDetailBO.setCustomerId("dadadada");
        triggerCustomerDetailBO.setEnterpriseId(eid);
        triggerCustomerDetailBO.setWxEnterpriseId(wxEid);
        triggerCustomerDetailBO.setBizId("musidanxieru091210");
        triggerCustomerDetailBO.setBizType(1);
        triggerCustomerDetailBO.setClerkId(clerkId);
        triggerCustomerDetailBO.setStaffId(staffId);
        triggerCustomerDetailBO.setStoreId(staffId);
        triggerCustomerDetailBO.setChannelType(1);
        triggerCustomerDetailBO.setCustomerId(staffId);
        triggerCustomerDetailBO.setCreateTime(new Date());
        triggerCustomerDetailBO.setUpdateTime(new Date());
        triggerCustomerDetailBO.setDeleteFlag(1);
        triggerCustomerDetailBO.setId(UniqueIdUtils.uniqueLong());
        triggerCustomerDetailService.batchSave(Collections.singletonList(triggerCustomerDetailBO));
        triggerCustomerDetailBO.setId(UniqueIdUtils.uniqueLong());
        triggerCustomerDetailBO.setBizId("musidanxieru091211");
        triggerCustomerDetailService.batchSave(Collections.singletonList(triggerCustomerDetailBO));

        long time = new Date().getTime();
        System.out.println((int)time);

    }
}
