package com.ghy.common.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;

/**
 * @author HH 2022/5/21
 */
@Slf4j
public class AdapayUtils {

    /**
     * 生成 Adapay member_id
     *
     * @param customerId 消费者ID
     * @param deptId     分平台id
     * @return Adapay member_id
     */
    public static String getCustomerMemberId(Long customerId, Long deptId) {
        Assert.isTrue(Math.min(customerId, deptId) > 0, "Invalid [customerId] or [deptId]");
        return String.format("C%dD%d", customerId, deptId);
    }

    /**
     * 生成 Adapay member_id
     *
     * @param workerId 师傅id
     * @param deptId   分平台id
     * @return 生成的唯一id
     */
    public static String getWorkerMemberId(Long workerId, Long deptId) {
        Assert.isTrue(Math.min(workerId, deptId) > 0, "Invalid [workerId] or [deptId]");
        return String.format("W%dD%d", workerId, deptId);
    }

}
