package cn.quantgroup.xyqb.service.wechat;

import cn.quantgroup.xyqb.entity.WechatUserInfo;
import cn.quantgroup.xyqb.model.webchat.AccessTokenResponse;

import java.util.List;

/**
 * Created by Miraculous on 2017/1/19.
 */
public interface IWechatService {
    AccessTokenResponse getToken(String code);

    WechatUserInfo getWechatUserInfoFromWechatServer(String token, String openId);

    WechatUserInfo findWechatUserInfoFromDb(String openId);

    WechatUserInfo findWechatUserInfoByPhoneNo(String phoneNo);

    WechatUserInfo saveWechatUserInfo(WechatUserInfo userInfo);

    /**
     * 关联用户和微信
     *
     * @param userId  - 用户标识
     * @param phoneNo
     * @param openId  - 微信标识
     * @return
     */
    int relateUser(Long userId, String phoneNo, String openId);

    /**
     * 按userId查微信信息
     * 此接口实现处不应加缓存，否则解绑时（在关联用户的事务中）不好清除
     *
     * @param userId - 用户标识
     * @return
     */
    WechatUserInfo queryByUserId(Long userId);

    WechatUserInfo queryByUserId(Long userId, String appName);

    int forbiddenUserWeChat(Long userId);

    /**
     * 通过userId解除商城用户与小程序和公众号关联关系
     *
     * @param userId  用户id
     * @return 禁用结果
     */
    int forbiddenXyqbAndWuxiUserByUserId(Long userId);

    List<WechatUserInfo> queryListByUserId(Long userId);

    List<WechatUserInfo> queryListByUnionId(String unionId);

    List<WechatUserInfo> queryListByUnionIds(List<String> unionIds);
}
