package org.springblade.payment.callback.inivtation;

import org.springblade.common.enums.AppConstant;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.flow.shop.entity.InvitationCallbackData;
import org.springblade.flow.shop.service.IAuditShopService;
import org.springblade.yeePay.service.YeePayService;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author: lianghanqiang
 * @description: 商户入网通知回调
 * @since: 9/15/21 -- 5:25 PM
 */
public class ShopInvitationCallback implements InvitationCallbackHandle {
	private YeePayService yeePayService;
	private IAuditShopService auditShopService;

	/** 初始化各状态回调处理 */
	{
		this.yeePayService =  SpringUtil.getBean(YeePayService.class);
		this.auditShopService = SpringUtil.getBean(IAuditShopService.class);
	}


	/**
	 * 	调用商户审核服务处理回调
	 * */
	@Override
	public void handle(HttpServletRequest httpRequest, AppConstant.InvitationType invitationType) {
		Map<String, String[]> parameterMap = httpRequest.getParameterMap();
		InvitationCallbackData invitationCallbackData = yeePayService.deCodeNotifyData(parameterMap.get("cipherText")[0], InvitationCallbackData.class);
		auditShopService.invitationCallback(invitationCallbackData);
	}
}
