package com.iformall.utils;

import com.iformall.common.ErrorCode;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxCUserBasicInfo;
import com.iformall.exception.MallinkException;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * 用户校验工具类
 */
public class UserUtil {


	/**
	 * 增加积分：校验用户信息
	 * 规则：有手机号增加积分，无手机号提示授权手机号
	 * @param wxCUser
	 * @param wxCUserBasicInfo
	 */
	public static void creditUserCheck(WxCUser wxCUser, WxCUserBasicInfo wxCUserBasicInfo) {
		if (Objects.isNull(wxCUser) && Objects.isNull(wxCUserBasicInfo)) {
			throw new MallinkException(ErrorCode.USER_NOT_AUTH_PHONE);
		}

		if (Objects.isNull(wxCUserBasicInfo)|| StringUtils.isBlank(wxCUserBasicInfo.getPhone())) {
			throw new MallinkException(ErrorCode.USER_NOT_AUTH_PHONE);
		}

		// 根据当前业务，wxCUserBasicInfo存在手机号，wxCUser肯定存在，除非人为删除手机号
		//if (Objects.isNull(wxCUser)|| StringUtils.isBlank(wxCUser.getPhone())) {
		//	throw new MallinkException(ErrorCode.USER_NOT_AUTH_PHONE);
		//}

	}
}
