EntmicroFollowServiceTest.java 4.43 KB
package cn.com.glsx.entmicro.service;

import cn.com.glsx.entmicro.Main;
import cn.com.glsx.entmicro.entity.EntmicroCustomerFollow;
import cn.com.glsx.entmicro.mapper.EntmicroCustomerFollowMapper;
import cn.com.glsx.entmicro.model.request.GetStaffFollowCustomerRequest;
import cn.com.glsx.entmicro.service.cache.RedisCacheService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
 * @author Lichongyuan
 * @Description:
 * @date 2021/11/5 11:44
 */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Main.class)
public class EntmicroFollowServiceTest {

    @Autowired
    private EntmicroFollowService entmicroFollowService;

    @Resource
    private EntmicroCustomerFollowMapper entmicroCustomerFollowMapper;

    @Resource
    private SyncCustomerService syncCustomerService;

    @Resource
    private RedisCacheService redisCacheService;

    @Test
    public void insert() {
        List<EntmicroCustomerFollow> customerFollowRelations = new ArrayList<>();
        EntmicroCustomerFollow entmicroCustomerFollow = new EntmicroCustomerFollow();
        entmicroCustomerFollow.setAddWay(2);
        entmicroCustomerFollow.setStaffId(19);
        entmicroCustomerFollow.setCustomerId(829);
        entmicroCustomerFollow.setDelFlag((byte)0);
        customerFollowRelations.add(entmicroCustomerFollow);
        EntmicroCustomerFollow entmicroCustomerFollow1 = new EntmicroCustomerFollow();
        entmicroCustomerFollow1.setAddWay(3);
        entmicroCustomerFollow1.setStaffId(18);
        entmicroCustomerFollow1.setDelFlag((byte)0);
        entmicroCustomerFollow1.setCustomerId(855);
        customerFollowRelations.add(entmicroCustomerFollow1);
        entmicroFollowService.insert(customerFollowRelations);
    }

    @Test
    public void getStaffFollowCustomerTest(){
        GetStaffFollowCustomerRequest request = new GetStaffFollowCustomerRequest();
        request.setMerchantId(44211425);
        request.setCustomerPhone("17750020170");
        request.setStaffUserIdList(Arrays.asList("wo-ZewEAAAdWCWU-E6ti-_EDYp4yq5Ow","wo-ZewEAAAZTCCHRHzUWt2SjOJNFnm7w"));
        System.out.println(entmicroFollowService.getStaffFollowCustomer(request));
    }

    @Test
    public void selectCustomerFollowRemarkTest(){
        List<Integer> merchantIdList = null;
        List<Map<String, Object>> maps = entmicroCustomerFollowMapper.selectCustomerFollowRemark(new Date(), merchantIdList);
        System.out.println("===============" + maps);
    }

    @Test
    public void syncCustomerRemarkToCdpTest() throws ParseException {
//        redisCacheService.deleteCache("sync_customer_remark_to_cdp_cache");
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date parse = format.parse("2024-01-31 01:00:01");
        redisCacheService.setCache("sync_customer_remark_to_cdp_cache", parse, 60 * 60 * 24 * 7L);
        syncCustomerService.syncCustomerRemarkToCdp();
    }

    @Test
    public void cacheTest(){
        Date date = new Date();
        System.out.println("1===========" + date);
        redisCacheService.setCache("sync_customer_remark_to_cdp_cache",date);
        Object cache = redisCacheService.getCache("sync_customer_remark_to_cdp_cache");
        date = (Date)cache;
        System.out.println("2===========" + date);
        redisCacheService.deleteCache("sync_customer_remark_to_cdp_cache");
    }

    public static void main(String[] args) {
        String regular = ".*?-.*?-.*";
        String filter = "^(.*?-[^-]*-[^-])-.*$";
        Pattern compile = Pattern.compile(regular);
        List<String> list = Arrays.asList("3-23B甘女士(租户)","3-23B甘女士(租户)","2-1-21E(业主父亲)","12-7A 郑圆(业主)","16-2-7A 郑圆(业主)","业主父亲");
        for (String data : list) {
//            System.out.println(string);
            Matcher matcher = compile.matcher(data);
            boolean x = matcher.find();
            String string = data.replaceAll("^(.*?)(?:-[^-]*)$", "$1");
//            string = string.replaceAll(".*-(.*)", "$1");
            System.out.println(data + x + ": " + string);
        }
    }
}