Пример #1
0
        /// <summary>
        /// 接收者计费操作
        /// </summary>
        /// <param name="nodeId"></param>
        /// <param name="pXinDb"></param>
        /// <param name="amount">金额</param>
        /// <param name="isGorup">是否为群发送</param>
        private (bool, string) ReceiverFeeOperation(int receiverId, decimal amount, OracleTransaction transaction, List <PushPDian> pushPList, string transferId)
        {
            var userInfo      = pXinDb.GetUserInfoByNodeId(receiverId);
            var pushPDianResp = new PushPDian {
                NodeId = receiverId, PDianPush = 1, PDianBalance = userInfo.P + Math.Abs(amount)
            };

            if (userInfo != null && userInfo.Nodeid > 0)
            {
                var amountBeforeP = userInfo.P;
                userInfo.P = Math.Abs(amount);
                userInfo.V = 0;
                if (userInfo.P == 0)
                {
                    Log.MessageInfo($"ReceiverFeeOperation v点获取失败,nodeId:{receiverId},p点:{userInfo.P},amount:{amount}");
                    return(false, "聊天计费失败,请联系管理员!");
                }
                pushPDianResp.PDianPush = Math.Abs(amount);
                var pChangeHis = CreateAmountChangeHis(receiverId, 2, userInfo.P, 6, transferId, "聊天增加", amountBeforeP, amountBeforeP + userInfo.P);
                var falg       = pXinDb.AddTpxinAmountChangeHis(pChangeHis, transaction);
                if (!pXinDb.UpdateTpxinUserinfo(userInfo, transaction) ||
                    !falg)
                {
                    Log.MessageInfo("聊天计费UpdateTpxinUserinfo失败,receiverId" + receiverId);
                    return(false, "聊天计费失败,请联系管理员!");
                }
                pushPList.Add(pushPDianResp);
                return(true, null);
            }
            else
            {
                Log.MessageInfo("聊天计费接收者:" + receiverId + "不存在");
                return(false, "找不到您当前信息,请重新登录再尝试!");
            }
        }
Пример #2
0
        /// <summary>
        /// 接收者计费操作
        /// </summary>
        /// <param name="receiverId"></param>
        /// <param name="amount"></param>
        /// <param name="pushPList"></param>
        /// <param name="transferId"></param>
        /// <returns></returns>
        private (bool, string) ReceiverFeeOperation(int receiverId, decimal amount, List <PushPDian> pushPList, string transferId)
        {
            var userInfo      = db.TpxinUserinfoSet.FirstOrDefault(p => p.Nodeid == receiverId);
            var pushPDianResp = new PushPDian {
                NodeId = receiverId, PDianPush = 1, PDianBalance = userInfo.P + Math.Abs(amount)
            };

            if (userInfo != null && userInfo.Nodeid > 0)
            {
                var p = Math.Abs(amount);
                userInfo.P += p;
                pushPDianResp.PDianPush = Math.Abs(amount);
                var pChangeHis = CreateAmountChangeHis(receiverId, 2, p, 6, transferId, "聊天增加");
                db.TpxinAmountChangeHisSet.Add(pChangeHis);
                if (db.SaveChanges() <= 0)
                {
                    logger.Info("聊天计费UpdateTpxinUserinfo失败,receiverId" + receiverId);
                    return(false, "聊天计费失败,请联系管理员!");
                }
                pushPList.Add(pushPDianResp);
                return(true, null);
            }
            else
            {
                logger.Info("聊天计费接收者:" + receiverId + "不存在");
                return(false, "找不到您当前信息,请重新登录再尝试!");
            }
        }
Пример #3
0
 /// <summary>
 /// 给接收者推送
 /// </summary>
 /// <param name="nodeId"></param>
 /// <param name="pushPDian"></param>
 private void PushReceive(PushPDian pushPDian)
 {
     if (pushPDian != null)
     {
         CommuTcpClient receiveClient = CommuClient.Values.FirstOrDefault(c => c.Nodeid == pushPDian.NodeId);
         if (receiveClient != null)
         {
             //给接收用户推送P点余额
             ChatFeePush chatFeePush = new ChatFeePush();
             chatFeePush.Body.PDianPush    = pushPDian.PDianPush;
             chatFeePush.Body.PDianBalance = pushPDian.PDianBalance;
             receiveClient.SendData(chatFeePush.ToBytes());
         }
     }
 }