package cn.pluss.platform.wechat;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import cn.pluss.platform.api.Result;
import cn.pluss.platform.dto.WechatMerchantAuditDTO;
import cn.pluss.platform.entity.BankCard;
import cn.pluss.platform.entity.DeviceMerchantBuy;
import cn.pluss.platform.dto.DeviceMerchantBuyDTO;
import cn.pluss.platform.entity.MerchantBankCard;
import cn.pluss.platform.entity.UserApp;
import cn.pluss.platform.util.RSAEncryptUtil;
import cn.pluss.platform.util.StringUtil;
import cn.pluss.platform.util.WXPayHttpUtil;
import cn.pluss.platform.util.WXPayXmlUtil;

/**
 * @author yuchen
 * 
 * @Description 
 */
public interface WechatService {

	public final static String keyStoreUrl = "/home/syb/resources/wechatCert/apiclient_cert.p12";
	
	/**
	 * 
	 * AppPayParam:(APP统一下单MD5加密). <br/> 
	 * 
	 * @author Administrator 
	 * @param request
	 * @param map
	 * @return 
	 * @since JDK 1.8
	 */
	Result<Map<String, String>> appPayParam(HttpServletRequest request, Map<String, String> map, DeviceMerchantBuyDTO deviceMerchantBuyDTO);

	/**
	 *
	 * AppPayParam:(APP统一下单MD5加密). <br/>
	 * 
	 * @author Administrator
	 * @param request
	 * @param map
	 * @return
	 * @since JDK 1.8
	 */
	Result<Map<String, String>> appPayParamV2(HttpServletRequest request, Map<String, String> map, DeviceMerchantBuyDTO deviceMerchantBuyDTO);

	/**
	 * app统一支付下单，非商城
	 * AppPayParam:(APP统一下单MD5加密). <br/>
	 * 
	 * @author Administrator
	 * @param request
	 * @param map
	 * @return
	 * @since JDK 1.8
	 */
	Map<String, String> appPayParam(HttpServletRequest request, Map<String, String> map);

	/**
	 * 
	 * AppRefund:(APP退款). <br/> 
	 * 
	 * @author Administrator 
	 * @param deviceMerchantBuy
	 * @return 
	 * @since JDK 1.8
	 */
	Result<String> appRefund(DeviceMerchantBuy deviceMerchantBuy);
	
	/**
	 * 
	 * getRQcode:(获取关注公众号的图片). <br/> 
	 * 
	 * @author Administrator 
	 * @param sceneStr
	 * @return 
	 * @since JDK 1.8
	 */
	Result<String>  getRQcode(String sceneStr);

	/**
	 * 新版获取微信带参数的二维码
	 * @date: 2021/12/9 11:35
	 * @param sceneStr:
	 * @return cn.pluss.platform.api.Result<java.lang.String>
	 */
	Result<String>  getNewRQcode(String sceneStr);

	// 修改微信小微商户结算银行卡信息
	default Boolean updateWechatBankInfo(BankCard bankCard, UserApp userApp) throws Exception {
//		Map<String, String> loadDataMap = new HashMap<String, String>();
//		// 构造入住参数
//		Map<String, String> registData = new HashMap<String, String>(16);
//		loadDataMap.put("version", "1.0");
//		loadDataMap.put("cert_sn", "4F3FF2964275BA2D2D8320BC8187FB3E18D22DFE");
//		loadDataMap.put("mch_id", "1551169371");
//		loadDataMap.put("nonce_str", StringUtil.genRandomNum(8));
//		loadDataMap.put("sign_type", "HMAC-SHA256");
//		loadDataMap.put("sub_mch_id", userApp.getSubMchId());
//		loadDataMap.put("account_name", RSAEncryptUtil.rsaEncrypt(bankCard.getBankHolder()));
//		loadDataMap.put("account_number", RSAEncryptUtil.rsaEncrypt(bankCard.getBankCardNo()));
//		registData.put("account_bank", bankCard.getBankName());
//		registData.put("bank_address_code", bankCard.getBankAddressNo());
//		String result = WXPayHttpUtil.WXHttpPostXMLWithCert(
//				"https://api.mch.weixin.qq.com/applyment/micro/modifyarchives", registData, keyStoreUrl);
//		Map<String, String> resultMap = new HashMap<String, String>();
//		resultMap = WXPayXmlUtil.parseXMLToMap(result);
//		if ("SUCCESS".equalsIgnoreCase(resultMap.get("return_code"))
//				&& "SUCCESS".equalsIgnoreCase(resultMap.get("result_code"))) {
//			return true;
//		}
		return false;
	}

	/**
	 * 微信进件
	 * @deprecated 原生通道暂不使用
	 * @param wechatMerchantAuditDTO
	 */
	@Deprecated
	void wechatMerchantAudit(WechatMerchantAuditDTO wechatMerchantAuditDTO);
}

