import cn.hutool.crypto.digest.MD5;
import com.gic.haoban.manage.api.enums.content.MaterialInteractRecordEventType;
import com.gic.haoban.manage.api.enums.content.TriggerCustomerChannelType;
import com.gic.haoban.manage.service.pojo.bo.content.message.InteractRecordMessageBO;
import com.gic.haoban.manage.service.pojo.qo.content.InteractRecordQO;
import com.gic.haoban.manage.service.service.content.InteractRecordService;
import com.gic.haoban.manage.service.service.content.message.InteractRecordMessageService;
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;
import java.util.UUID;

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

    @Autowired
    private InteractRecordService interactRecordService;
    @Autowired
    private InteractRecordMessageService interactRecordMessageService;


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

    @Test
    public void queryInteractPageTest(){
        InteractRecordQO interactRecordQO = new InteractRecordQO();
        interactRecordQO.setClerkId(staffId);
        interactRecordService.queryInteractRecordPage(interactRecordQO);
    }

    @Test
    public void dealRecordTest(){
        String businessId = "UUID.randomUUID().toString()";
        InteractRecordMessageBO message = new InteractRecordMessageBO();
        message.setClerkId(clerkId);
        message.setEnterpriseId(eid);
        message.setMemberId(memberId);
        message.setUnionId(memberId);
        message.setStoreId("ff8080818499a54801849ce85f9f003f");
        message.setMaterialId("1232139123912");
        message.setChannelSource(TriggerCustomerChannelType.PYQ.getCode());
        message.setEventType(MaterialInteractRecordEventType.VISIT_PRODUCT.getCode());
        message.setGoodsIds(Collections.singletonList("fbc508e395f846ef9005852c420e1c23"));
        message.setDurationTime(2000);
        message.setBusinessUUId(businessId);
        message.setLastAccessTime(new Date().getTime());
        interactRecordMessageService.dealRecord(message);
    }

    @Test
    public void test(){
        for (int i = 0; i < 10; i++) {
            System.out.println(MD5.create().digestHex("song"));
        }
    }
}
