package services

import (
	"hongze/hongze_cygx/models"
	"hongze/hongze_cygx/utils"
)

func CheckActivityUserPermission(user *models.WxUserItem) (sellerMobile, sellerRealName string, err error) {
	companyPermission, e := models.GetCompanyPermission(user.CompanyId)
	if e != nil {
		err = e
		return
	}
	if companyPermission == "" {
		companyPermissionNoStatus, e := models.GetCompanyPermissionByUserNoStatus(user.CompanyId)
		if e != nil {
			err = e
			return
		}
		if companyPermissionNoStatus != "" {
			sellerItemQy, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
			if e != nil && e.Error() != utils.ErrNoRow() {
				err = e
				return
			}
			if sellerItemQy != nil {
				sellerMobile = sellerItemQy.Mobile
				sellerRealName = sellerItemQy.RealName
			}
		}
	}
	return
}
