|
@@ -8,6 +8,7 @@ import (
|
|
|
"qfw/creditlog"
|
|
|
"qfw/util"
|
|
|
"qfw/util/mongodb"
|
|
|
+ "qfw/util/msg"
|
|
|
"qfw/util/redis"
|
|
|
qrpc "qfw/util/rpc"
|
|
|
"runtime"
|
|
@@ -21,6 +22,7 @@ type CreditRpc struct{}
|
|
|
var Message map[string]string
|
|
|
var Score map[string]int
|
|
|
var Rpcserver string
|
|
|
+var Hour int
|
|
|
|
|
|
//用户访问redis加锁
|
|
|
var SN = 100
|
|
@@ -254,15 +256,15 @@ func (c *CreditRpc) OutCreadit(param *qrpc.CreditData, replay *int) error {
|
|
|
"s_operation": Message["txt_"+param.Code],
|
|
|
"i_type": 0,
|
|
|
"l_date": now.Unix(),
|
|
|
- "i_score": param.Num,
|
|
|
- "i_scorenow": i_scorenow,
|
|
|
}
|
|
|
if param.OtherParam != nil && param.OtherParam["i_way"] != nil {
|
|
|
creditDoc["i_way"] = param.OtherParam["i_way"]
|
|
|
}
|
|
|
+ var newDate time.Time
|
|
|
switch first {
|
|
|
case "A":
|
|
|
- creditDoc["l_enddate"] = now.AddDate(0, 1, 0).Unix()
|
|
|
+ newDate = GetTimeByNow(now, Hour).AddDate(0, 1, 1)
|
|
|
+ creditDoc["l_enddate"] = newDate.Unix()
|
|
|
creditDoc["i_valid"] = 1
|
|
|
if param.OtherParam != nil {
|
|
|
str := []string{}
|
|
@@ -270,22 +272,36 @@ func (c *CreditRpc) OutCreadit(param *qrpc.CreditData, replay *int) error {
|
|
|
str = append(str, k)
|
|
|
}
|
|
|
creditDoc["s_type"] = strings.Join(str, ",")
|
|
|
+ creditDoc["i_score"] = Score[param.Code] * len(str)
|
|
|
+ creditDoc["i_scorenow"] = i_scorenow + Score[param.Code]*len(str)
|
|
|
}
|
|
|
case "B":
|
|
|
+ creditDoc["i_score"] = param.Num
|
|
|
+ creditDoc["i_scorenow"] = i_scorenow + param.Num
|
|
|
creditDoc["i_givestatus"] = 0
|
|
|
}
|
|
|
if creditlog.Save(creditDoc) {
|
|
|
*replay = 1
|
|
|
//发送微信通知扣积分成功
|
|
|
- go SendWeixin(param.Num, param.Umid, "")
|
|
|
+ if first == "A" {
|
|
|
+ go SendMsgWebAndWx(Message["swordfish_payTitle"], fmt.Sprintf(Message["swordfish_pay"], creditDoc["i_score"], creditDoc["i_scorenow"], util.FormatDate(&newDate, util.Date_Full_Layout)), param.Uid, param.Umid)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
lock.Unlock()
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-//发送微信积分变动通知
|
|
|
-func SendWeixin(num int, uid, info string) {
|
|
|
+//发送微信和站内信通知
|
|
|
+func SendMsgWebAndWx(title, content, userId, umid string) {
|
|
|
+ m := &msg.Msg{
|
|
|
+ Msgtype: 1,
|
|
|
+ Title: title,
|
|
|
+ Content: content,
|
|
|
+ ReceiveId: userId,
|
|
|
+ }
|
|
|
+ go m.SaveMsg()
|
|
|
+ go SendManagerNotifyMsg(&qrpc.NotifyMsg{Openid: umid, Title: title, Detail: "管理员", Remark: content})
|
|
|
|
|
|
}
|
|
|
|
|
@@ -320,3 +336,8 @@ func GetSubSecond(n int) int {
|
|
|
tom := time.Date(now.Year(), now.Month(), now.Day()+n, 0, 0, 0, 0, time.Local)
|
|
|
return int(tom.Unix() - now.Unix())
|
|
|
}
|
|
|
+
|
|
|
+func GetTimeByNow(now time.Time, nhour int) time.Time {
|
|
|
+ tom := time.Date(now.Year(), now.Month(), now.Day(), nhour, 0, 0, 0, time.Local)
|
|
|
+ return tom
|
|
|
+}
|