package com.cyksj.service.wechat;


import com.cyksj.model.dto.*;
import com.cyksj.model.request.TargetAppletSchemeReq;
import com.cyksj.model.response.WxGzhQrCodeTicketRep;
import com.cyksj.model.wechat.MiniURLLink;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;

public interface WeChatService {

    String createUrl(String state, String redirectUrl);

    String createUrl(String state, String redirectUrl, String appId, String scope);

    AuthToken getAuthToken(String code) throws Exception;

    AuthToken getAuthToken(String code, String appId) throws Exception;

    String getJsTicket() throws Exception;

    String getJsTicket(String appId) throws Exception;

    GzhOAuth2UserInfo getUserInfo(String accessToken, String openid) throws Exception;

    /**
     * 通过公众号的access_token 获取用户基本信息
     */
    GzhUnionidUserinfo getUserInfo2(String accessToken, String openid) throws Exception;

    String getAccessToken() throws Exception;

    String getAccessToken(String appId) throws Exception;

    /**
     * 统一订单
     *
     * @param appid      微信应用唯一id
     * @param openid     微信的用户标识
     * @param totalFee   订单总金额 单位为分
     * @param outTradeNo 订单批次号 一次支付对应一条订单批次号 可以包含多条购物记录(订单)
     * @param notifyUrl  通知地址
     * /@param attach     传入订单id 在查询API和支付通知中原样返回 用于处理订单
     * @return h5调用微信js-sdk必要的参数
     */
    H5JsPayParams getJsPayParams(String appid, String shopId,String openid, Integer totalFee, String outTradeNo, String notifyUrl, String attach, String body, String tradeType, Date ExpiryTime) throws Exception;


    /* 微信签名算法 */

    boolean checkSignWithMd5(Map<String, String> map) throws Exception;

    boolean checkSignWithMd5(Map<String, String> map, String shopKey) throws Exception;


    H5PayParams getH5PayParams(String appid, Integer totalFee, String outTradeNo, String notifyUrl, String attach, String ip, String body) throws Exception;

    /**
     * 发送模板消息 单对象
     *
     * @param accessToken WechatCache.getAccessToken()
     * @param json        消息json
     */
    void sendTemplateMessage(String accessToken, String json) throws Exception;

    /**
     * @param appId 应用id
     * @param transactionId 微信支付订单号
     * @param outRefundNo 商户退款单号
     * @param totalFee  订单金额 单位为分，只能为整数
     * @param refundMoney  退款金额
     */
    void refundWxOrder(String appId, String shopId, String transactionId, String outRefundNo, BigDecimal totalFee, BigDecimal refundMoney, String notifyUrl) throws Exception;

    /**
     * 获取公众号带参数的临时二维码
     * @return
     */
    WxGzhQrCodeTicketRep getWxGzhQrCode(GzhBodyDto gzhBodyDto) throws Exception;

    /**
     * 获取公众号带参数的永久二维码
     */
    String getNotExpiredWxGzhQrCode(String sceneKey) throws Exception;

    /**
     * 获取微信订单信息 校验订单是否已支付
     */
    Map<String, String> getWxOrderDetail(String shopId, String orderNo) throws Exception;

    /**
     * 获取微信网页授权url
     */
    String createWxAuthLoginUrl(String state, String appId, String redirectUri);

    /**
     * 获取跳转微信小程序链接
     */
    String getMiniURLLink(String accessToken, MiniURLLink miniURLLink) throws Exception;

    MiniProgramSession code2Session(String appId, String code) throws Exception;

    void getMiniStudentIdentity(String openId, String code) throws Exception;

	String generateSchema(String accessToken, TargetAppletSchemeReq targetAppletSchemeReq) throws Exception;

    byte[] generateCode(String accessToken, String path) throws Exception;
}
