package main

import "time"

func onClick(ss *openIDSessionData, in *InWechatMsg) {
	e := in.body.(EventMsg)
	openid := in.header.FromUserName
	switch e.EventKey {
	case "MEMBER_MYPROFILE":
		//kfSendTxtAs(openid, "profile", "孙鹏")
		startProc(AllProc["用户信息"], ss, in)
	case "MEMBER_CREDITS":
		onMembeCredits(ss, in)
	case "MEMBER_SEARCH":
		startProc(AllProc["搜索校友"], ss, in)
	case "MEMBER_FEEDBACK":
		startProc(AllProc["投诉反馈"], ss, in)
	case "EVENT_STARTONE":
		kfSendTxtAs(openid, "开启活动", "孙鹏")
	case "EVENT_LIVE":
		kfSendTxtAs(openid, "当前暂无直播，如果你报名了直播活动，会自动收到直播", "孙鹏")
	case "EVENT_CHECKIN":
		kfSendTxtAs(openid, "签到", "孙鹏")
	case "EVENT_LUCKYDRAW":
		kfSendTxtAs(openid, "抽奖", "孙鹏")
	case "EVENTS_UPCOMING":
		kfSendTxtAs(openid, "活动s", "孙鹏")
	case "CAREERDEV_JOBS":
		kfSendTxtAs(openid, "工作", "孙鹏")
	case "CAREERDEV_INDUSTRY":
		kfSendTxtAs(openid, "业界", "孙鹏")
	case "CAREERDEV_OUTREACH":
		kfSendTxtAs(openid, "out", "孙鹏")
	case "CAREERDEV_HIT":
		kfSendTxtAs(openid, "母校", "孙鹏")
	case "CAREERDEV_HELP":
		kfSendTxtAs(openid, "互助", "孙鹏")
	default:
		kfSendTxt(openid, e.EventKey)
	}
	in.replyText("")
}

func onMembeCredits(ss *openIDSessionData, in *InWechatMsg) {
	msg := `
积分是您对校友会的贡献记录，积分越高对校友会的贡献越大，也是对所有对校友会无私奉献的一种公开认可。

积分可以通过校友会兑换成奖金或纪念品。

余额是您在校友会活动中的奖金余额，根据活动内容，以现金，卡，或者礼物的形式兑现。
`
	kfSendTxtAs(ss.OpenID, msg, "孙鹏")

	info, found, err := crmFindLeadByOpenID(ss.OpenID)

	if found && err == nil {
		url := ""
		first := "截至" + time.Now().Format("2006-01-02 15:04:06 Mon MST -07") + " 您的积分，奖品，余额，如下\n\n" +
			"积分：无"
		name := info.LastName
		addr := info.EmailAddress
		card := info.ID
		balance := "澳币 $0 "
		remark := "奖品：无\n\n余额可联络财务兑现，奖品余额30过期" + "\n请确保您的姓名，地址信息正确"
		templateSendAccountBalance(ss.OpenID, url, first, remark, name, addr, card, balance)
	}

}
