package com.ym.mec.thirdparty.adapay;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import com.huifu.adapay.core.exception.BaseAdaPayException;

/**
 * @author
 */
public class CorpMember {

    /**
     * 查询 CorpMember
     *
     * @param member_id 待查询的member_id
     * @return 查询的 CorpMember 对象
     * @throws Exception 异常
     */
    public static Map<String, Object> executeQueryMember(String member_id) throws Exception {
        Map<String, Object> memberParams = new HashMap<String, Object>(2);
        memberParams.put("member_id", member_id);
        memberParams.put("app_id", ConfigInit.appId);
        return com.huifu.adapay.model.CorpMember.query(memberParams);
    }

    /**
     * 创建 CorpMember
     *
     * @return 创建的CorpMember 对象
     * @throws Exception 异常
     */
    public static Map<String, Object> executeCreateMember(Map<String, Object> info, File file) throws Exception {
        Map<String, Object> memberParams = new HashMap<String, Object>();
        memberParams.put("app_id", ConfigInit.appId);
        memberParams.putAll(info);

        Map<String, Object> member = com.huifu.adapay.model.CorpMember.create(memberParams, file);
        String error_code = (String) member.get("error_code");
        if (null != error_code) {
            String errorMsg = (String) member.get("error_msg");
            throw new BaseAdaPayException(errorMsg);
        }
        return member;
    }


}
