|
@@ -8,7 +8,6 @@ import (
|
|
"qfw/coreconfig"
|
|
"qfw/coreconfig"
|
|
"qfw/coreutil"
|
|
"qfw/coreutil"
|
|
"qfw/util"
|
|
"qfw/util"
|
|
- "qfw/util/consts"
|
|
|
|
"qfw/util/mongodb"
|
|
"qfw/util/mongodb"
|
|
"qfw/util/redis"
|
|
"qfw/util/redis"
|
|
"runtime"
|
|
"runtime"
|
|
@@ -30,6 +29,7 @@ func (m *Mobile) Share() error {
|
|
return m.Render("/swordfish/wxshare.html", &m.T)
|
|
return m.Render("/swordfish/wxshare.html", &m.T)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//进入订阅页面
|
|
func (m *Mobile) Wxrssset() error {
|
|
func (m *Mobile) Wxrssset() error {
|
|
defer func() {
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
if r := recover(); r != nil {
|
|
@@ -44,7 +44,6 @@ func (m *Mobile) Wxrssset() error {
|
|
}
|
|
}
|
|
}()
|
|
}()
|
|
userId := m.Session().Get("userId")
|
|
userId := m.Session().Get("userId")
|
|
- //userId = "55a39942af53740186000004"
|
|
|
|
if userId != nil {
|
|
if userId != nil {
|
|
m.T["signature"] = getSignature(m.Url())
|
|
m.T["signature"] = getSignature(m.Url())
|
|
userInfo := mongodb.FindById("user", userId.(string), nil)
|
|
userInfo := mongodb.FindById("user", userId.(string), nil)
|
|
@@ -57,136 +56,103 @@ func (m *Mobile) Wxrssset() error {
|
|
return m.Redirect("/swordfish/guide")
|
|
return m.Redirect("/swordfish/guide")
|
|
}
|
|
}
|
|
m.T["msgset"] = (*userInfo)["o_msgset"]
|
|
m.T["msgset"] = (*userInfo)["o_msgset"]
|
|
- entid := util.ObjToString((*userInfo)["s_enterpriseid"])
|
|
|
|
- if entid != "" {
|
|
|
|
- local := mongodb.FindById("enterprise", entid, `{"_id":0,"OpLocDistrict":1,"i_area":1}`)
|
|
|
|
- localids := (*local)["OpLocDistrict"]
|
|
|
|
- i_area := (*local)["i_area"]
|
|
|
|
- if localids != nil && len(localids.(string)) > 2 {
|
|
|
|
- localid := localids.(string)
|
|
|
|
- localid = localid[:2]
|
|
|
|
- m.T["scode"] = localid
|
|
|
|
- m.T["sname"] = consts.SRcode[localid]
|
|
|
|
- } else if i_area != nil && len(fmt.Sprintf("%d", i_area)) > 2 {
|
|
|
|
- area := fmt.Sprintf("%d", i_area)
|
|
|
|
- area = area[:2]
|
|
|
|
- m.T["scode"] = area
|
|
|
|
- m.T["sname"] = consts.SRcode[area]
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- //m.T["mid"] = openid
|
|
|
|
return m.Render("/swordfish/wxrssset.html", &m.T)
|
|
return m.Render("/swordfish/wxrssset.html", &m.T)
|
|
} else {
|
|
} else {
|
|
return m.Render("_err.html")
|
|
return m.Render("_err.html")
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
- enstr := strings.Split(se.DecodeString(str), ",")
|
|
|
|
- if len(enstr) >= 3 {
|
|
|
|
- openid := enstr[0]
|
|
|
|
- if len(openid) == 0 {
|
|
|
|
- return nil
|
|
|
|
- }
|
|
|
|
- userInfo := mongodb.FindOneByField("user", `{"s_m_openid":"`+openid+`"}`, `{"_id":1,"o_msgset":1,"s_enterpriseid":1}`)
|
|
|
|
- if userInfo == nil || len(*userInfo) == 0 {
|
|
|
|
- return nil
|
|
|
|
- } else {
|
|
|
|
- m.T["msgset"] = (*userInfo)["o_msgset"]
|
|
|
|
- entid := util.ObjToString((*userInfo)["s_enterpriseid"])
|
|
|
|
- if entid != "" {
|
|
|
|
- local := mongodb.FindById("enterprise", entid, `{"_id":0,"OpLocDistrict":1,"i_area":1}`)
|
|
|
|
- localids := (*local)["OpLocDistrict"]
|
|
|
|
- i_area := (*local)["i_area"]
|
|
|
|
- if localids != nil && len(localids.(string)) > 2 {
|
|
|
|
- localid := localids.(string)
|
|
|
|
- localid = localid[:2]
|
|
|
|
- m.T["scode"] = localid
|
|
|
|
- m.T["sname"] = consts.SRcode[localid]
|
|
|
|
- } else if i_area != nil && len(fmt.Sprintf("%d", i_area)) > 2 {
|
|
|
|
- area := fmt.Sprintf("%d", i_area)
|
|
|
|
- area = area[:2]
|
|
|
|
- m.T["scode"] = area
|
|
|
|
- m.T["sname"] = consts.SRcode[area]
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- m.T["mid"] = openid
|
|
|
|
- return m.Render("/member/message/wxrssset.html", &m.T)
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- return m.Render("_err.html")
|
|
|
|
- }
|
|
|
|
- **/
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//获取积分
|
|
//获取积分
|
|
-func (m *Mobile) GetCredit() error {
|
|
|
|
|
|
+func (m *Mobile) GetMyCredit() error {
|
|
userId := m.GetSession("userId")
|
|
userId := m.GetSession("userId")
|
|
res := map[string]interface{}{}
|
|
res := map[string]interface{}{}
|
|
if userId != nil {
|
|
if userId != nil {
|
|
res["flag"] = true
|
|
res["flag"] = true
|
|
- user := mongodb.FindById("user", userId.(string), `{"_id":0,"i_credit":1}`)
|
|
|
|
- if *user != nil {
|
|
|
|
- res["val"] = util.IntAll((*user)["i_credit"])
|
|
|
|
- }
|
|
|
|
|
|
+ res["val"] = getCreditById(userId.(string))
|
|
} else {
|
|
} else {
|
|
res["flag"] = false
|
|
res["flag"] = false
|
|
}
|
|
}
|
|
|
|
+ m.ServeJson(&res)
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
-//订阅消息设置
|
|
|
|
-func (m *Mobile) MsgSet() error {
|
|
|
|
- data := m.GetString("data")
|
|
|
|
- /**
|
|
|
|
- mid := m.GetString("mid")
|
|
|
|
- if mid == "" {
|
|
|
|
- return nil
|
|
|
|
|
|
+func getCreditById(userId string) int {
|
|
|
|
+ user := mongodb.FindById("user", userId, `{"_id":0,"i_credit":1}`)
|
|
|
|
+ if *user != nil {
|
|
|
|
+ return util.IntAll((*user)["i_credit"])
|
|
}
|
|
}
|
|
- **/
|
|
|
|
- bcon := true
|
|
|
|
- doc := map[string]interface{}{}
|
|
|
|
- if data != "" {
|
|
|
|
- mson := map[string]interface{}{}
|
|
|
|
- err := json.Unmarshal([]byte(data), &mson)
|
|
|
|
- if err != nil || mson == nil || len(mson) == 0 {
|
|
|
|
- log.Println("保存订阅设置出错", err)
|
|
|
|
- } else {
|
|
|
|
- for _, v := range mson {
|
|
|
|
- util.Try(func() {
|
|
|
|
- item := v.(map[string]interface{})
|
|
|
|
- a_key := util.ObjArrToStringArr(item["a_key"].([]interface{}))
|
|
|
|
- if a_key == nil || len(a_key) == 0 || len(a_key) > 5 {
|
|
|
|
- bcon = false
|
|
|
|
- } else {
|
|
|
|
- for _, v := range a_key {
|
|
|
|
- if len(v) > 300 {
|
|
|
|
- bcon = false
|
|
|
|
- break
|
|
|
|
|
|
+ return 0
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//直接查询开启状态和截止日期
|
|
|
|
+func getMsgSetById(userId string) map[string]interface{} {
|
|
|
|
+ user := mongodb.FindById("user", userId, `{"_id":0,"i_credit":1,"o_msgset.tender.i_status":1,"o_msgset.tender.l_enddate":1,"o_msgset.bid.i_status":1,"o_msgset.bid.l_enddate":1}`)
|
|
|
|
+ if *user != nil {
|
|
|
|
+ return *user
|
|
|
|
+ }
|
|
|
|
+ return nil
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//扣分操作
|
|
|
|
+func (m *Mobile) SwordfishPay() {
|
|
|
|
+ userId := m.GetSession("userId")
|
|
|
|
+ res := map[string]interface{}{}
|
|
|
|
+ if userId != nil {
|
|
|
|
+ types := m.GetSlice("types")
|
|
|
|
+ res["flag"] = true
|
|
|
|
+ if len(types) > 0 {
|
|
|
|
+ //获取积分
|
|
|
|
+ user := getMsgSetById(userId.(string))
|
|
|
|
+ if user == nil {
|
|
|
|
+ res["flag"] = false
|
|
|
|
+ } else {
|
|
|
|
+ i_credit := util.IntAll(user["i_credit"])
|
|
|
|
+ if i_credit > 0 {
|
|
|
|
+ isPay := map[string]bool{}
|
|
|
|
+ for _, v := range types {
|
|
|
|
+ util.Try(func() {
|
|
|
|
+ obj_typei := user["o_msgset"].(map[string]interface{})[v]
|
|
|
|
+ b_newopen := false
|
|
|
|
+ if obj_typei == nil {
|
|
|
|
+ b_newopen = true
|
|
|
|
+ } else {
|
|
|
|
+ obj_type := obj_typei.(map[string]interface{})
|
|
|
|
+ st := obj_type["i_status"]
|
|
|
|
+ objt := obj_type["l_enddate"]
|
|
|
|
+ if st == nil || objt == nil {
|
|
|
|
+ b_newopen = true
|
|
|
|
+ } else {
|
|
|
|
+ //判断是否开启
|
|
|
|
+ i_st := st.(int)
|
|
|
|
+ l_objt := objt.(int64)
|
|
|
|
+ if !(i_st == 1 && l_objt > util.GetDayStartSecond(0)) {
|
|
|
|
+ b_newopen = true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ if b_newopen { //进行扣费操作
|
|
|
|
+ isPay[v] = true
|
|
|
|
+ }
|
|
|
|
+ }, func(e interface{}) {
|
|
|
|
+ log.Println(e)
|
|
|
|
+ })
|
|
}
|
|
}
|
|
- }, func(e interface{}) {
|
|
|
|
- log.Println("验证关键词出错", e)
|
|
|
|
- bcon = false
|
|
|
|
- })
|
|
|
|
|
|
+ for k, _ := range isPay {
|
|
|
|
+ //先扣分,然后更新,然后返回结果
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ res["credit"] = i_credit
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- mson["l_modifydate"] = time.Now().Unix()
|
|
|
|
- doc["o_msgset"] = mson
|
|
|
|
} else {
|
|
} else {
|
|
- bcon = false
|
|
|
|
- }
|
|
|
|
- da := map[string]interface{}{
|
|
|
|
- "msg": util.If(bcon, "保存成功", "保存失败"),
|
|
|
|
- }
|
|
|
|
- if bcon {
|
|
|
|
- mongodb.Update("user", `{"_id":"`+util.ObjToString(m.GetSession("userId"))+`"}`, &map[string]interface{}{
|
|
|
|
- "$set": doc,
|
|
|
|
- }, false, false)
|
|
|
|
|
|
+ res["flag"] = false
|
|
}
|
|
}
|
|
- m.ServeJson(da)
|
|
|
|
- return nil
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+//剑鱼保存
|
|
func (m *Mobile) AjaxReq() error {
|
|
func (m *Mobile) AjaxReq() error {
|
|
reqType := m.GetString("reqType")
|
|
reqType := m.GetString("reqType")
|
|
var flag = "n"
|
|
var flag = "n"
|
|
@@ -229,12 +195,12 @@ func (m *Mobile) AjaxReq() error {
|
|
set := make(map[string]interface{})
|
|
set := make(map[string]interface{})
|
|
for _, v := range []string{"tender", "bid"} {
|
|
for _, v := range []string{"tender", "bid"} {
|
|
if len(m.GetString(v+"_scope")) > 0 {
|
|
if len(m.GetString(v+"_scope")) > 0 {
|
|
- tmp := make(map[string]interface{})
|
|
|
|
- tmp["a_key"] = m.GetSlice(v + "_keys")
|
|
|
|
- tmp["s_scope"] = m.GetString(v + "_scope")
|
|
|
|
- tmp["i_status"], _ = m.GetInteger(v + "_status")
|
|
|
|
- tmp["l_modifydate"] = time.Now().Unix()
|
|
|
|
- set["o_msgset."+v] = tmp
|
|
|
|
|
|
+ //还有一个截止时间字段和一个剑鱼服务状态
|
|
|
|
+ status, _ := m.GetInteger(v + "_status")
|
|
|
|
+ set["o_msgset."+v+".i_switchstatus"] = status
|
|
|
|
+ set["o_msgset."+v+".a_key"] = m.GetSlice(v + "_keys")
|
|
|
|
+ set["o_msgset."+v+".s_scope"] = m.GetString(v + "_scope")
|
|
|
|
+ set["o_msgset."+v+".l_modifydate"] = time.Now().Unix()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//更新数据库
|
|
//更新数据库
|