Commit 2d562c8f authored by chenweijian's avatar chenweijian

cp翻译

parent 20afbb54
...@@ -7,7 +7,7 @@ type CpCancelStatus mysql.Type ...@@ -7,7 +7,7 @@ type CpCancelStatus mysql.Type
const ( const (
//新用户 //新用户
CpRelationInviteDiamond = 18888 CpRelationInviteDiamond = 18888 // cwj----
//1.未接受2.已接受3.拒接导致退费4.过期导致退费 //1.未接受2.已接受3.拒接导致退费4.过期导致退费
CpInvite CpInviteStatus = 1 CpInvite CpInviteStatus = 1
......
...@@ -30,8 +30,7 @@ func CpInviteCancelInit() { ...@@ -30,8 +30,7 @@ func CpInviteCancelInit() {
defer utils.CheckGoPanic() defer utils.CheckGoPanic()
model := domain.CreateModelNil() model := domain.CreateModelNil()
// 获取超过24小时没被处理的cp邀请 // 获取超过24小时没被处理的cp邀请
//inviteList, err := cp_m.GetCpInviteByTime(model, time.Now().AddDate(0, 0, -1)) cwj---- inviteList, err := cp_m.GetCpInviteByTime(model, time.Now().AddDate(0, 0, -1))
inviteList, err := cp_m.GetCpInviteByTime(model, time.Now().Add(-time.Minute*10)) // cwj----
if err != nil { if err != nil {
model.Log.Errorf("CpInviteCancelInit err:%v", err) model.Log.Errorf("CpInviteCancelInit err:%v", err)
return return
...@@ -61,8 +60,7 @@ func CpInviteCancelInit() { ...@@ -61,8 +60,7 @@ func CpInviteCancelInit() {
} }
// 获取超过24小时没被处理的cp解除申请 // 获取超过24小时没被处理的cp解除申请
//cancelList, err := cp_m.GetCpCancelByTime(model, time.Now().AddDate(0, 0, -1)) cwj---- cancelList, err := cp_m.GetCpCancelByTime(model, time.Now().AddDate(0, 0, -1))
cancelList, err := cp_m.GetCpCancelByTime(model, time.Now().Add(-time.Minute*10)) // cwj----
if err != nil { if err != nil {
model.Log.Errorf("CpInviteCancelInit err:%v", err) model.Log.Errorf("CpInviteCancelInit err:%v", err)
return return
......
...@@ -2,6 +2,7 @@ package cp_s ...@@ -2,6 +2,7 @@ package cp_s
import ( import (
"encoding/json" "encoding/json"
"git.hilo.cn/hilo-common/_const/common"
"git.hilo.cn/hilo-common/_const/enum/diamond_e" "git.hilo.cn/hilo-common/_const/enum/diamond_e"
"git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext" "git.hilo.cn/hilo-common/mycontext"
...@@ -13,6 +14,7 @@ import ( ...@@ -13,6 +14,7 @@ import (
"hilo-user/domain/model/cp_m" "hilo-user/domain/model/cp_m"
"hilo-user/domain/model/diamond_m" "hilo-user/domain/model/diamond_m"
"hilo-user/domain/model/user_m" "hilo-user/domain/model/user_m"
"hilo-user/myerr"
"hilo-user/myerr/bizerr" "hilo-user/myerr/bizerr"
) )
...@@ -37,7 +39,7 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l ...@@ -37,7 +39,7 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
return err return err
} }
if myCp.Id > 0 { if myCp.Id > 0 {
return msg.GetErrByLanguage(model, 0, lang, comerr.InvalidParameter) return msg.GetErrByLanguage(model, common.MSG_ID_ALREADY_HAS_CP, lang, comerr.AlreadyHasCp)
} }
// 对方是否已经有cp了 // 对方是否已经有cp了
inviCp, err := cp_m.GetCp(model, userInvite.ID) inviCp, err := cp_m.GetCp(model, userInvite.ID)
...@@ -45,7 +47,7 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l ...@@ -45,7 +47,7 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
return err return err
} }
if inviCp.Id > 0 { if inviCp.Id > 0 {
return msg.GetErrByLanguage(model, 0, lang, comerr.InvalidParameter) return msg.GetErrByLanguage(model, common.MSG_ID_ALREADY_HAS_CP, lang, comerr.AlreadyHasCp)
} }
// 我是否发起过cp邀请,且还未被处理 // 我是否发起过cp邀请,且还未被处理
...@@ -58,6 +60,14 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l ...@@ -58,6 +60,14 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
return bizerr.CpAlreadyInvite return bizerr.CpAlreadyInvite
} }
content, err := msg.GetResMultiTextBy(model, common.MSG_ID_WANT_BE_YOUR_CP, lang)
if err != nil {
return err
}
tip, err := msg.GetResMultiTextBy(model, common.MSG_ID_EXPIRES_AFTER_24_H, lang)
if err != nil {
return err
}
err = model.Transaction(func(model *domain.Model) error { err = model.Transaction(func(model *domain.Model) error {
// 创建邀请记录 // 创建邀请记录
cpInvId, err := cp_m.CreateCpInvite(model, myUserId, userInvite.ID, cp_e.CpRelationInviteDiamond) cpInvId, err := cp_m.CreateCpInvite(model, myUserId, userInvite.ID, cp_e.CpRelationInviteDiamond)
...@@ -74,8 +84,8 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l ...@@ -74,8 +84,8 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
// 发送私信-邀请 // 发送私信-邀请
data, _ := json.Marshal(cp_m.CpInviteMessage{ data, _ := json.Marshal(cp_m.CpInviteMessage{
Identifier: "CpInviteMessage", Identifier: "CpInviteMessage",
Msg: "Do you want to be CP with me?", Msg: content,
Tip: "24 hours automatic expiration", Tip: tip,
Sender: user_m.ToUserTiny(user), Sender: user_m.ToUserTiny(user),
}) })
if err := tencentyun.BatchSendCustomMsg(model, 1, user.ExternalId, []string{userInvite.ExternalId}, string(data), "cp邀请"); err != nil { if err := tencentyun.BatchSendCustomMsg(model, 1, user.ExternalId, []string{userInvite.ExternalId}, string(data), "cp邀请"); err != nil {
...@@ -89,7 +99,7 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l ...@@ -89,7 +99,7 @@ func InviteCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
return err return err
} }
// socket 推送弹窗 // socket 推送弹窗
go rpc.SendCpInviteNotice(userInvite.ID, user.Code, user.Nick, user.Avatar, "Do you want to be CP with me?", user.ExternalId) go rpc.SendCpInviteNotice(userInvite.ID, user.Code, user.Nick, user.Avatar, content, user.ExternalId)
return nil return nil
} }
...@@ -109,13 +119,22 @@ func CancelCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l ...@@ -109,13 +119,22 @@ func CancelCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
return bizerr.InvalidParameter return bizerr.InvalidParameter
} }
tip, err := msg.GetResMultiTextBy(model, common.MSG_ID_EXPIRES_AFTER_24_H, lang)
if err != nil {
return err
}
content, err := msg.GetResMultiTextBy(model, common.MSG_ID_WANT_UNBIND_CP, lang)
if err != nil {
return err
}
// 自己没有cp了 // 自己没有cp了
myCp, err := cp_m.GetCp(model, myUserId) myCp, err := cp_m.GetCp(model, myUserId)
if err != nil { if err != nil {
return err return err
} }
if myCp.Id == 0 { if myCp.Id == 0 {
return msg.GetErrByLanguage(model, 0, lang, comerr.InvalidParameter) return myerr.WrapErr(bizerr.InvalidParameter)
} }
// 对方没有cp了 // 对方没有cp了
inviCp, err := cp_m.GetCp(model, userRec.ID) inviCp, err := cp_m.GetCp(model, userRec.ID)
...@@ -123,7 +142,7 @@ func CancelCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l ...@@ -123,7 +142,7 @@ func CancelCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
return err return err
} }
if inviCp.Id == 0 { if inviCp.Id == 0 {
return msg.GetErrByLanguage(model, 0, lang, comerr.InvalidParameter) return myerr.WrapErr(bizerr.InvalidParameter)
} }
// 是否有关于我的cp解除申请,且还未被处理 // 是否有关于我的cp解除申请,且还未被处理
...@@ -146,8 +165,8 @@ func CancelCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l ...@@ -146,8 +165,8 @@ func CancelCpRelation(myCtx *mycontext.MyContext, myUserId uint64, externalId, l
// 发送私信-发起解除 // 发送私信-发起解除
data, _ := json.Marshal(cp_m.CpCancelMessage{ data, _ := json.Marshal(cp_m.CpCancelMessage{
Identifier: "CpCancelMessage", Identifier: "CpCancelMessage",
Msg: "I want to unbind the CP relationship", Msg: content,
Tip: "24 hours automatic expiration", Tip: tip,
Sender: user_m.ToUserTiny(user), Sender: user_m.ToUserTiny(user),
}) })
if err := tencentyun.BatchSendCustomMsg(model, 1, user.ExternalId, []string{userRec.ExternalId}, string(data), "cp解除"); err != nil { if err := tencentyun.BatchSendCustomMsg(model, 1, user.ExternalId, []string{userRec.ExternalId}, string(data), "cp解除"); err != nil {
......
This diff is collapsed.
...@@ -3,6 +3,7 @@ package cp_r ...@@ -3,6 +3,7 @@ package cp_r
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"git.hilo.cn/hilo-common/_const/common"
"git.hilo.cn/hilo-common/_const/enum/diamond_e" "git.hilo.cn/hilo-common/_const/enum/diamond_e"
"git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext" "git.hilo.cn/hilo-common/mycontext"
...@@ -61,10 +62,14 @@ func CheckUserCpRelation(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -61,10 +62,14 @@ func CheckUserCpRelation(c *gin.Context) (*mycontext.MyContext, error) {
return myCtx, err return myCtx, err
} }
if cp.Id > 0 { if cp.Id > 0 {
return myCtx, msg.GetErrByLanguage(model, 0, lang, comerr.InvalidParameter) // cwj---- return myCtx, msg.GetErrByLanguage(model, common.MSG_ID_ALREADY_HAS_CP, lang, comerr.AlreadyHasCp)
}
msg, err := msg.GetResMultiTextBy(model, common.MSG_ID_INVITE_CP, lang)
if err != nil {
return myCtx, err
} }
resp.ResponseOk(c, cp_cv.CheckCpRelationRes{Diamond: cp_e.CpRelationInviteDiamond, Msg: "Do you want to be CP with me?"}) resp.ResponseOk(c, cp_cv.CheckCpRelationRes{Diamond: cp_e.CpRelationInviteDiamond, Msg: msg})
return myCtx, nil return myCtx, nil
} }
...@@ -161,7 +166,7 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -161,7 +166,7 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) {
return myCtx, err return myCtx, err
} }
if myCp.Id > 0 { if myCp.Id > 0 {
return myCtx, msg.GetErrByLanguage(model, 0, lang, comerr.InvalidParameter) return myCtx, msg.GetErrByLanguage(model, common.MSG_ID_ALREADY_HAS_CP, lang, comerr.AlreadyHasCp)
} }
// 对方是否已经有cp了 // 对方是否已经有cp了
senderCp, err := cp_m.GetCp(model, userSender.ID) senderCp, err := cp_m.GetCp(model, userSender.ID)
...@@ -169,7 +174,7 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -169,7 +174,7 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) {
return myCtx, err return myCtx, err
} }
if senderCp.Id > 0 { if senderCp.Id > 0 {
return myCtx, msg.GetErrByLanguage(model, 0, lang, comerr.InvalidParameter) return myCtx, msg.GetErrByLanguage(model, common.MSG_ID_ALREADY_HAS_CP, lang, comerr.AlreadyHasCp)
} }
} }
err = model.Transaction(func(model *domain.Model) error { err = model.Transaction(func(model *domain.Model) error {
...@@ -206,7 +211,7 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -206,7 +211,7 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) {
model.Log.Errorf("ReplyCpInvite InitCpAnniversary fail:%v-%v-%v", userSender.ID, user.ID, err) model.Log.Errorf("ReplyCpInvite InitCpAnniversary fail:%v-%v-%v", userSender.ID, user.ID, err)
return err return err
} }
// 发放告白礼物 cwj---- // 发放告白礼物
if _, err = bag_tx.SendUserBag(model, userSender.ID, 1, cp_e.CpConfessionGiftId, 1, 3, "告白礼物"); err != nil { if _, err = bag_tx.SendUserBag(model, userSender.ID, 1, cp_e.CpConfessionGiftId, 1, 3, "告白礼物"); err != nil {
model.Log.Errorf("ReplyCpInvite userSender:%d, user:%d, status:%d, err:%v", userSender.ID, user.ID, updateStatus, err) model.Log.Errorf("ReplyCpInvite userSender:%d, user:%d, status:%d, err:%v", userSender.ID, user.ID, updateStatus, err)
return err return err
...@@ -221,10 +226,18 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -221,10 +226,18 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) {
// return err // return err
//} //}
// 私信-接受 // 私信-接受
content, err := msg.GetResMultiTextBy(model, common.MSG_ID_BIND_CP_SUCCEED, lang)
if err != nil {
return err
}
tip, err := msg.GetResMultiTextBy(model, common.MSG_ID_SEND_CP_GIFT, lang)
if err != nil {
return err
}
msgData, _ = json.Marshal(cp_m.CpAcceptInviteMessage{ msgData, _ = json.Marshal(cp_m.CpAcceptInviteMessage{
Identifier: "CpAcceptInviteMessage", Identifier: "CpAcceptInviteMessage",
Msg: "We are already CP!", Msg: content,
Tip: fmt.Sprintf("Celebration gifts have been sent to %s's backpack", userSender.Code), Tip: fmt.Sprintf(tip, userSender.Code),
Sender: user_m.ToUserTiny(userSender), Sender: user_m.ToUserTiny(userSender),
Receiver: user_m.ToUserTiny(user), Receiver: user_m.ToUserTiny(user),
}) })
...@@ -236,9 +249,13 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -236,9 +249,13 @@ func ReplyCpInvite(c *gin.Context) (*mycontext.MyContext, error) {
return err return err
} }
// 私信-拒绝 // 私信-拒绝
content, err := msg.GetResMultiTextBy(model, common.MSG_ID_REJECTED_CP_INVITE, lang)
if err != nil {
return err
}
msgData, _ = json.Marshal(cp_m.CpDenyInviteMessage{ msgData, _ = json.Marshal(cp_m.CpDenyInviteMessage{
Identifier: "CpDenyInviteMessage", Identifier: "CpDenyInviteMessage",
Msg: fmt.Sprintf("%s have declined the CP invitation", user.Nick), Msg: fmt.Sprintf(content, user.Nick),
Sender: user_m.ToUserTiny(user), Sender: user_m.ToUserTiny(user),
}) })
} }
...@@ -274,7 +291,7 @@ func ReplyCpCancel(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -274,7 +291,7 @@ func ReplyCpCancel(c *gin.Context) (*mycontext.MyContext, error) {
return myCtx, bizerr.InvalidParameter return myCtx, bizerr.InvalidParameter
} }
myUserId, _, err := req.GetUserIdLang(c, myCtx) myUserId, lang, err := req.GetUserIdLang(c, myCtx)
if err != nil { if err != nil {
return myCtx, err return myCtx, err
} }
...@@ -327,9 +344,13 @@ func ReplyCpCancel(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -327,9 +344,13 @@ func ReplyCpCancel(c *gin.Context) (*mycontext.MyContext, error) {
var msgData []byte var msgData []byte
if optType == 1 { // 撤销解除 if optType == 1 { // 撤销解除
// 私信 // 私信
//content, err := msg.GetResMultiTextBy(model, common.MSG_ID_UNBIND_CP_SUCCEED, lang)
//if err != nil {
// return err
//}
msgData, _ = json.Marshal(cp_m.CpDealCancelMessage{ msgData, _ = json.Marshal(cp_m.CpDealCancelMessage{
Identifier: "CpDealCancelMessage", Identifier: "CpDealCancelMessage",
Msg: fmt.Sprintf("%s withdrew my application to lift CP", myUser.Nick), Msg: fmt.Sprintf("%s withdrew my application to lift CP", myUser.Nick), // cwj----
Status: 1, Status: 1,
}) })
} else { // 接受解除 } else { // 接受解除
...@@ -340,9 +361,13 @@ func ReplyCpCancel(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -340,9 +361,13 @@ func ReplyCpCancel(c *gin.Context) (*mycontext.MyContext, error) {
return err return err
} }
// 私信-接受解除 // 私信-接受解除
content, err := msg.GetResMultiTextBy(model, common.MSG_ID_UNBIND_CP_SUCCEED, lang)
if err != nil {
return err
}
msgData, _ = json.Marshal(cp_m.CpDealCancelMessage{ msgData, _ = json.Marshal(cp_m.CpDealCancelMessage{
Identifier: "CpDealCancelMessage", Identifier: "CpDealCancelMessage",
Msg: "The CP relationship has been unbound, the CP value has been cleared, and the CP privilege has disappeared", Msg: content,
Status: 2, Status: 2,
}) })
} }
......
...@@ -57,7 +57,7 @@ func UserBag(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -57,7 +57,7 @@ func UserBag(c *gin.Context) (*mycontext.MyContext, error) {
Count: bagGift.Count, Count: bagGift.Count,
RemainDays: int(bagGift.EndTime.Sub(time.Now()).Hours() / 24), RemainDays: int(bagGift.EndTime.Sub(time.Now()).Hours() / 24),
} }
if gift.ID == cp_e.CpConfessionGiftId { // cwj---- 如果是cp告白礼物 if gift.ID == cp_e.CpConfessionGiftId { // 如果是cp告白礼物
info.TextStyleList = make([]*user_cv.TextStyle, 0, 2) info.TextStyleList = make([]*user_cv.TextStyle, 0, 2)
info.TextStyleList = append(info.TextStyleList, info.TextStyleList = append(info.TextStyleList,
&user_cv.TextStyle{TextColor: "#ce0083", TextSize: 20, TextKey: "sender_name"}, &user_cv.TextStyle{TextColor: "#ce0083", TextSize: 20, TextKey: "sender_name"},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment