|
@@ -4,25 +4,29 @@
|
|
|
package credit
|
|
|
|
|
|
import (
|
|
|
+ "fmt"
|
|
|
"github.com/dchest/captcha"
|
|
|
"github.com/go-xweb/xweb"
|
|
|
. "gopkg.in/mgo.v2/bson"
|
|
|
+ cu "qfw/coreutil"
|
|
|
"qfw/util"
|
|
|
cd "qfw/util/credit"
|
|
|
"qfw/util/mongodb"
|
|
|
"qfw/util/redis"
|
|
|
+ "regexp"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
type credit struct {
|
|
|
*xweb.Action
|
|
|
- myCredit xweb.Mapper `xweb:"/member/credit/myCredit"` //我的积分
|
|
|
- creditRule xweb.Mapper `xweb:"/member/credit/creditRule"` //积分规则
|
|
|
- inCreditAjx xweb.Mapper `xweb:"/member/credit/inCreditAjx"` //ajx调用
|
|
|
- sessionQdAjx xweb.Mapper `xweb:"/member/credit/sessionQdAjx"` //查看签到
|
|
|
- bookInfo xweb.Mapper `xweb:"/member/credit/bookinfo"` //查看连续签到信息
|
|
|
- creditList xweb.Mapper `xweb:"/member/credit/creditList"` //查询积分明细
|
|
|
+ myCredit xweb.Mapper `xweb:"/member/credit/myCredit"` //我的积分
|
|
|
+ creditRule xweb.Mapper `xweb:"/member/credit/creditRule"` //积分规则
|
|
|
+ inCreditAjx xweb.Mapper `xweb:"/member/credit/inCreditAjx"` //ajx调用
|
|
|
+ sessionQdAjx xweb.Mapper `xweb:"/member/credit/sessionQdAjx"` //查看签到
|
|
|
+ bookInfo xweb.Mapper `xweb:"/member/credit/bookinfo"` //查看连续签到信息
|
|
|
+ creditList xweb.Mapper `xweb:"/member/credit/creditList"` //查询积分明细
|
|
|
+ yaoqingByEmail xweb.Mapper `xweb:"/member/credit/yaoqingByEmail"` //邮箱邀请用户
|
|
|
}
|
|
|
|
|
|
func (c *credit) MyCredit() error {
|
|
@@ -183,7 +187,8 @@ func (c *credit) CreditRule() error {
|
|
|
return c.Render("/member/credit/creditrule.html")
|
|
|
}
|
|
|
|
|
|
-func (c *credit) YqByemail() error {
|
|
|
+//邮箱邀请用户
|
|
|
+func (c *credit) YaoqingByEmail() error {
|
|
|
userId := util.ObjToString(c.GetSession("userId"))
|
|
|
result := make(M)
|
|
|
var msg string
|
|
@@ -192,7 +197,21 @@ func (c *credit) YqByemail() error {
|
|
|
if c.GetSession("CheckCodeId") == nil || !captcha.VerifyString(c.GetSession("CheckCodeId").(string), c.GetString("checkCodeId")) {
|
|
|
msg = "验证码错误!请重新输入验证码!"
|
|
|
} else {
|
|
|
-
|
|
|
+ s_email := c.GetString("s_email")
|
|
|
+ if isEmail(s_email) {
|
|
|
+ nickName := c.GetSession("nickName").(string)
|
|
|
+ //获取二维码随机数
|
|
|
+ wxnum := 0
|
|
|
+ cu.SendMail("invitebyemail", s_email, nickName+":邀请你加入企明星", nickName, fmt.Sprint(wxnum))
|
|
|
+ //邀请记录
|
|
|
+ yqmap := map[string]interface{}{}
|
|
|
+ yqmap["s_uid"] = userId
|
|
|
+ yqmap["s_toemail"] = s_email
|
|
|
+ yqmap["i_wxnum"] = wxnum
|
|
|
+ yqmap["l_date"] = time.Now().Unix()
|
|
|
+ mongodb.Save("invite_log", yqmap)
|
|
|
+ flag = true
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
msg = "请登录之后在操作"
|
|
@@ -202,3 +221,9 @@ func (c *credit) YqByemail() error {
|
|
|
c.ServeJson(result)
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+//邮箱格式验证
|
|
|
+func isEmail(value string) bool {
|
|
|
+ var emailPattern = regexp.MustCompile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$")
|
|
|
+ return emailPattern.MatchString(value)
|
|
|
+}
|