local UnionLogic = require("union.UnionLogic")
local UnionEctypeLogic = require("union.UnionEctypeLogic")
local UnionTecLogic = require("union.UnionTecLogic")
local UnionWarLogic = require("union.UnionWarLogic")
local UnionLivenessLogic = require("union.UnionLivenessLogic")
local UnionDonateLogic = require("union.UnionDonateLogic")
local UnionRedBagLogic = require("union.UnionRedBagLogic")
local UnionDBLogic = require("union.UnionDBLogic")
function CG_UNION_CREATE(human, msg)
    UnionLogic.createUnion(human, msg.name,msg.bannerID,msg.notice, msg.needLv, msg.needAgree)
end

function CG_UNION_DISMISS(human)
    UnionLogic.dismissUnion(human)
end

function CG_UNION_APPLY_JOIN(human, msg)
    UnionLogic.applyJoinUnion(human, msg.unionUuid)
end

function CG_UNION_CANCEL_APPLY(human, msg)
    UnionLogic.cancelApply(human, msg.unionUuid)
end

function CG_UNION_AGREE_JOIN(human, msg)
    UnionLogic.agreeJoinUnion(human, msg.uuid, msg.flag)
end

function CG_UNION_LEAVE(human)
    UnionLogic.leaveUnion(human)
end

function CG_UNION_QUERY(human)
    UnionLogic.unionQuery(human)
end

function CG_UNION_FIND(human, msg)
    UnionLogic.findUnion(human,msg.val)
end

function CG_UNION_MEMBER_MAN(human, msg)
    UnionLogic.memberMam(human,msg.uuid,msg.type)
end

function CG_UNION_APPLY_MSG(human)
    UnionLogic.applyQuery(human)
end

function CG_UNION_CHANGE_NAME_QUERY(human)
    UnionLogic.sendChangeNameQuery(human)
end

function CG_UNION_CHANGE_NAME(human,msg)
    UnionLogic.changeUnionName(human, msg.name)
end

function CG_UNION_CHANGE_BANNERID(human,msg)
    UnionLogic.changeUnionBannerID(human, msg.bannerID)
end

function CG_UNION_GET_LOG(human,msg)
    UnionLogic.getLog(human,msg.type)
end

function CG_UNION_CHANGE_MSG(human,msg)
    UnionLogic.setNotice(human, msg.notice)
end

function CG_UNION_CHANGE_LIMIT_QUERY(human)
    UnionLogic.sendJoinLimitQuery(human)
end

function CG_UNION_CHANGE_LIMIT(human, msg)
	UnionLogic.setJoinLimit(human, msg.needLv, msg.needAgree)
end

function CG_UNION_MAIL(human,msg)
    UnionLogic.sendUnionMail(human,msg.content)
end

function CG_UNION_RECRUIT_QUERY(human)
    UnionLogic.sendRecruitQuery(human)
end

function CG_UNION_RECRUIT(human,msg)
    UnionLogic.unionRecruit(human,msg.str)
end

function CG_UNION_ECTYPE_QUERY(human,msg)
    UnionEctypeLogic.ectypeQuery(human)
end

-- 查询 指定关卡 副本
function CG_UNION_ONE_ECTYPE_QUERY(human,msg)
    UnionEctypeLogic.oneEctypeQuery(human,msg.level)
end

-- 升级或者激活 公会BUF
function CG_UNION_UP_ECTYPE_BUFF(human, msg)
    UnionEctypeLogic.upEctypeBuff(human, msg.level)
end

function CG_UNION_ONE_ECTYPE_SAODANG(human, msg)
    UnionEctypeLogic.saodang(human, msg.level, msg.touch)
end

-- 副本点赞
function CG_UNION_ECTYPE_RANK_DO_LIKE(human, msg)
    UnionEctypeLogic.giveLike(human, msg.level, msg.uuid)
end

-- 副本集结
function CG_UNION_ECTYPE_JIJIE(human, msg)
    UnionEctypeLogic.jiJie(human, msg.level,msg.str)
end

function CG_UNION_TECHNOLOGY_QUERY(human,msg)
    UnionTecLogic.techQuery(human,msg.occu)
end

function CG_UNION_TECHNOLOGY_LV_UP(human,msg)
    UnionTecLogic.techLvUp(human,msg.occu,msg.tier)
end

-- 科技类型重置查询
function CG_UNION_TECHNOLOGY_RESET_QUERY(human, msg)
    UnionTecLogic.techResetQuery(human, msg.occu)
end

-- 科技类型重置
function CG_UNION_TECHNOLOGY_RESET(human,msg)
    UnionTecLogic.techReset(human,msg.occu)
end

function CG_UNION_WAR_HALL_QUERY(human)
    UnionWarLogic.warHallQuery(human)
end


function CG_UNION_ONE_KEY_DISAGREE(human)
    UnionLogic.oneKeyDisagree(human)
end

function CG_UNION_LIVENESS_QUERY(human)
    UnionLivenessLogic.livenessQuery(human)
end

function CG_UNION_LIVENESS_REWARD_QUERY(human)
    UnionLivenessLogic.livenessRewardQuery(human)
end

function CG_UNION_LIVENESS_REWARD_GET(human,msg)
    UnionLivenessLogic.getReward(human,msg.lv)
end

function CG_UNION_DONATE_QUERY(human)
    UnionDonateLogic.unionDonateQuery(human)
end

function CG_UNION_DONATE_DO(human,msg)
    UnionDonateLogic.donateDo(human,msg.type)
end

function CG_UNION_DONATE_REWARD_GET(human,msg)
    UnionDonateLogic.getDonateReward(human,msg.id)
end

function CG_UNION_IMPEACH_PRESIDENT(human)
    UnionLogic.impeachPresident(human)
end

-- 红包列表
function CG_UNION_RED_BAG_QUERY(human)
    UnionRedBagLogic.unionRedBagQuery(human)
end

-- 单个红包查询
function CG_UNION_SINGLE_RED_BAG_QUERY(human,msg)
    UnionRedBagLogic.singleRedBag(human,msg.id)
end

-- 发红包查询
function CG_UNION_SEND_RED_BAG_QUERY(human)
    UnionRedBagLogic.sendRedBagQuery(human)
end

-- 抢红包
function CG_UNION_GET_RED_BAG(human,msg)
    UnionRedBagLogic.getRedBag(human,msg.id)
end

-- 红包榜查询
function CG_UNION_RED_BAG_BILLBOARD(human)
    UnionRedBagLogic.redBagBillboardQuery(human)
end

--------------------------------------------------
-- 公会战查找指定玩家
function CG_UNION_WAR_INFO(human, msg)
    UnionWarLogic.CGInfo(human,msg.unionUuid, msg.uuid)
end

-- 公会战匹配列表
function CG_UNION_WAR_MATCH(human, msg)
    UnionWarLogic.CGMatch(human)
end

-- 公会战大厅
function CG_UNION_WAR_QUERY(human, msg)
    UnionWarLogic.CGQuery(human)
end

function CG_UNION_WAR_BUFF(human)
    UnionWarLogic.CGBuffQuery(human)
end

function CG_UNION_WAR_TIME(human)
    UnionWarLogic.getWarTime(human)
end

-- 用于给 客户端  给予 停留在公会战界面  倒计时结束 公会战结果 查询更新
function CG_UNION_WAR_END_STATE_QUERY(human)
    UnionWarLogic.CGEndQuery(human)
end

function CG_UNION_WAR_ATKLOG(human,msg)
    UnionWarLogic.CGAtkLog(human, msg.type)
end

function CG_UNION_WAR_DEFLOG(human,msg)
    UnionWarLogic.CGDefLog(human,msg.uuid , msg.unionUuid)
end

function CG_UNION_WAR_VIDEO(human,msg)
    UnionWarLogic.CGVideo(human,msg.videoIndex)
end

function CG_UNION_WAR_BOX(human,msg)
    UnionWarLogic.CGBox(human)
end

function CG_UNION_WAR_BOX_GET(human,msg)
    UnionWarLogic.CGBoxGet(human, msg.ind)
end

function CG_UNION_WAR_CHENGJIU(human,msg)
    UnionWarLogic.CGChengjiu(human,msg.type)
end

function CG_UNION_WAR_CHENGJIU_GET(human,msg)
    UnionWarLogic.CGChengjiuGet(human,msg.type,msg.id)
end

function CG_UNION_WAR_SHOP_QUERY(human,msg)
    UnionWarLogic.CGShop(human,msg.type)
end

function CG_UNION_WAR_SHOP_BUY(human,msg)
    UnionWarLogic.CGBuy(human,msg.type,msg.id,msg.cnt)
end

function CG_UNION_WAR_RANK(human,msg)
    UnionWarLogic.CGRank(human)
end

function CG_UNION_WAR_RANK_REWARD(human)
    UnionWarLogic.CGRankReward(human)
end
-- 公会日志详情查询
function CG_UNION_LOG_DETAIL_QUERY(human,msg)
    UnionLogic.getUnionLogMemberDetail(human,msg.type)
end

function isDot(human)
    print("[UnionLogic_Handler_isDot] 进入红点判断")
    local union = UnionDBLogic.getUnion(human.db.unionUuid)
    if union == nil then
		-- 没加入公会 不显示红点
        print("[UnionLogic_Handler_isDot] 没加入公会 不显示红点")
        return
    end

    if UnionLogic.dot(human) then
        print("[UnionLogic_Handler] 111111")
        return true
    end

    if UnionEctypeLogic.isDot(human) then
        print("[UnionLogic_Handler] 222222")
        return true
    end

    -- if UnionLogic.hasLog(human, union) then
    --     return true
    -- end

    -- if UnionWarLogic.isDot(human) then
    --     print("[UnionLogic_Handler] 33333")
    --     return true
    -- end
    
    if UnionLivenessLogic.isDot(human) then
        print("[UnionLogic_Handler] 44444")
        return true
    end

    if UnionDonateLogic.isDot(human) then
        print("[UnionLogic_Handler] 55555")
        return true
    end

    print("[UnionLogic_Handler] 没有红点返回空")
    return nil
end