|
@@ -319,18 +319,22 @@ func MultSave(this message.MultipleSaveMsgReq) (int64, string) {
|
|
|
//m := entity.Mysql.SelectBySql("select count(id) from conversation where receive_id=? and send_id=?", v, this.SendUserId)
|
|
|
sql3 := `INSERT INTO message(appid,receive_userid,receive_name,send_userid,send_name,title,content,msg_type,link,cite_id,createtime,isRead,isdel,msg_log_id) values ("%s",'%s','%s','%s','%s','%s','%s',%d,'%s',0,'%s',0,1,%d);`
|
|
|
sql3 = fmt.Sprintf(sql3, this.Appid, v, userName, this.SendUserId, this.SendName, this.Title, this.Content, this.MsgType, this.Link, time.Now().Format("2006-01-02 15:04:05"), this.MsgLogId)
|
|
|
+ log.Println("插入消息表sql3:", sql3)
|
|
|
if c <= 0 {
|
|
|
sql1 := `INSERT INTO conversation(appid,secret_key,user_id,receive_id,receive_name,send_id,send_name,sort,createtime) values ('%s','','%s','%s','%s','%s','%s',0,'%s');`
|
|
|
sql1 = fmt.Sprintf(sql1, this.Appid, this.SendUserId, v, userName, this.SendUserId, this.SendName, time.Now().Format("2006-01-02 15:04:05"))
|
|
|
+ log.Println("插入会话表sql1:", sql1)
|
|
|
ok := entity.Mysql.ExecTx("发送消息事务", func(tx *sql.Tx) bool {
|
|
|
//插入会话表
|
|
|
//开始时间
|
|
|
in1 := entity.Mysql.InsertBySqlByTx(tx, sql1)
|
|
|
sql2 := `INSERT INTO conversation(appid,secret_key,user_id,receive_id,receive_name,send_id,send_name,sort,createtime) values ('%s','','%s','%s','%s','%s','%s',0,'%s');`
|
|
|
sql2 = fmt.Sprintf(sql2, this.Appid, v, this.SendUserId, this.SendName, v, userName, time.Now().Format("2006-01-02 15:04:05"))
|
|
|
+ log.Println("插入会话表sql2:", sql2)
|
|
|
in2 := entity.Mysql.InsertBySqlByTx(tx, sql2)
|
|
|
//插入消息表
|
|
|
in3 := entity.Mysql.InsertBySqlByTx(tx, sql3)
|
|
|
+ log.Println("插入消息返回 in3 id:", in3)
|
|
|
log.Println("存储耗时:", time.Since(bT))
|
|
|
log.Println(in1, in2, in3)
|
|
|
|
|
@@ -345,6 +349,7 @@ func MultSave(this message.MultipleSaveMsgReq) (int64, string) {
|
|
|
|
|
|
} else {
|
|
|
in := entity.Mysql.InsertBySql(sql3)
|
|
|
+ log.Println("插入消息返回 in1 id:", in)
|
|
|
if in > -1 {
|
|
|
EtcdCountAdd(v, strconv.Itoa(int(this.MsgType)))
|
|
|
} else {
|