/// <summary> /// 聊天计费倍率查询 /// </summary> /// <param name="client"></param> /// <param name="buffer"></param> private void ProChatFeeRateQuery(CommuTcpClient client, byte[] buffer) { ChatFeeRateQuery chatFeeRateQuery = new ChatFeeRateQuery(buffer); OnRaiseMsgRecvEvent(client, chatFeeRateQuery.ToString()); var tchatReceiverRate = pXinDb.GetTchatRate(chatFeeRateQuery.Body.Sender, chatFeeRateQuery.Body.Receiver, chatFeeRateQuery.Body.Type); var tchatSenderRate = new TchatRate(); if (chatFeeRateQuery.Body.Type == 1) { if (tchatReceiverRate.Id == 0)//没有设置私聊倍率 { tchatReceiverRate = pXinDb.GetTchatRate(0, chatFeeRateQuery.Body.Receiver, 3); } tchatSenderRate = pXinDb.GetTchatRate(chatFeeRateQuery.Body.Receiver, chatFeeRateQuery.Body.Sender, chatFeeRateQuery.Body.Type); if (tchatSenderRate.Id == 0)//没有设置私聊倍率 { tchatSenderRate = pXinDb.GetTchatRate(0, chatFeeRateQuery.Body.Sender, 3); } var pxinUser = pXinDb.GetReginfoByNodeid(chatFeeRateQuery.Body.Receiver); tchatSenderRate.Rate = pxinUser.Isenterprise == 3 ? 1 : tchatSenderRate.Rate; //当用户是达人时 pxinUser = pXinDb.GetReginfoByNodeid(chatFeeRateQuery.Body.Sender); tchatReceiverRate.Rate = pxinUser.Isenterprise == 3 ? 1 : tchatReceiverRate.Rate; //当对方用户是达人时 } else { tchatSenderRate.Rate = tchatReceiverRate.Rate; tchatSenderRate.Id = tchatReceiverRate.Id; } ChatFeeRateQueryResp chatFeeRateQueryResp = new ChatFeeRateQueryResp(chatFeeRateQuery.Header.Sequence_Id); chatFeeRateQueryResp.Body.Type = chatFeeRateQuery.Body.Type; chatFeeRateQueryResp.Body.Sender = chatFeeRateQuery.Body.Type == 1 ? chatFeeRateQuery.Body.Sender : chatFeeRateQuery.Body.Receiver; chatFeeRateQueryResp.Body.ReceiverRate = tchatReceiverRate.Id == 0 ? 1 : tchatReceiverRate.Rate; chatFeeRateQueryResp.Body.SenderRate = tchatSenderRate.Id == 0 ? 1 : tchatSenderRate.Rate; var userInfo = pXinDb.GetUserInfoByNodeId(client.Nodeid); chatFeeRateQueryResp.Body.VDianBalance = userInfo.V; chatFeeRateQueryResp.Body.PDianBalance = userInfo.P; client.SendData(chatFeeRateQueryResp.ToBytes()); }
private void ProChatFeeRateQueryResp() { ChatFeeRateQueryResp chatFeeRateQueryResp = new ChatFeeRateQueryResp(_buffer); OnRaiseMsgRecvEvent(chatFeeRateQueryResp.Header.Command_Id, chatFeeRateQueryResp, "接收消息:" + chatFeeRateQueryResp.ToString()); }
private void OnRaiseMsgSendEvent(byte[] buffer) { if (MsgSendEventHandler != null) { string msg = string.Empty; MessageHeader header = new MessageHeader(buffer); switch (header.Command_Id) { case PXin_COMMAND_TYPE.Login: msg = new Login(buffer).ToString(); break; case PXin_COMMAND_TYPE.LoginResp: msg = new LoginResp(buffer).ToString(); break; case PXin_COMMAND_TYPE.Logout: msg = new Wt_Logout(buffer).ToString(); break; case PXin_COMMAND_TYPE.LogoutResp: msg = new LogoutResp(buffer).ToString(); break; case PXin_COMMAND_TYPE.Active: msg = new Active(buffer).ToString(); break; case PXin_COMMAND_TYPE.ActiveResp: msg = new ActiveResp(buffer).ToString(); break; case PXin_COMMAND_TYPE.ChatFee: msg = new ChatFee(buffer).ToString(); break; case PXin_COMMAND_TYPE.ChatFeeResp: msg = new ChatFeeResp(buffer).ToString(); break; case PXin_COMMAND_TYPE.ChatFeePush: msg = new ChatFeePush(buffer).ToString(); break; case PXin_COMMAND_TYPE.ChatFeeRateSet: msg = new ChatFeeRateSet(buffer).ToString(); break; case PXin_COMMAND_TYPE.ChatFeeRateSetResp: msg = new ChatFeeRateSetResp(buffer).ToString(); break; case PXin_COMMAND_TYPE.ChatFeeRateQuery: msg = new ChatFeeRateQuery(buffer).ToString(); break; case PXin_COMMAND_TYPE.ChatFeeRateQueryResp: msg = new ChatFeeRateQueryResp(buffer).ToString(); break; default: break; } //发布"消息发送"事件 if (header.Command_Id != PXin_COMMAND_TYPE.Active && header.Command_Id != PXin_COMMAND_TYPE.ActiveResp) { MsgSendEventHandler?.Invoke(this, new MessageEventArgs(string.Empty, Identity, msg)); } } }