Beispiel #1
0
        private bool CheckIconOutputLock(ApiMethodAttribute apiMethodAttribute, Dictionary <string, object> dicParas, out string errMsg)
        {
            TokenType tokenType = TokenType.Mobile;
            string    mobile    = string.Empty;

            errMsg = string.Empty;

            if (apiMethodAttribute.IconOutputLock == false)
            {
                return(true);
            }

            if (apiMethodAttribute.SignKeyEnum == SignKeyEnum.XCGameMemberToken || apiMethodAttribute.SignKeyEnum == SignKeyEnum.MobileToken || apiMethodAttribute.SignKeyEnum == SignKeyEnum.XCGameMemberOrMobileToken)
            {
                if (!MeberAndMobileTokenBusiness.GetTokenData(dicParas, out tokenType, out mobile, out errMsg))
                {
                    return(false);
                }

                if (IconOutLockBusiness.Exist(mobile))
                {
                    errMsg = "正在出币中,请稍后再进行操作。";
                    return(false);
                }

                return(true);
            }
            else
            {
                return(true);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 出币
 /// </summary>
 /// <returns></returns>
 public static bool DeviceOutputCoin(XCGameManaDeviceStoreType deviceStoreType, DevieControlTypeEnum deviceControlType, string storeId, string mobile, int icCardId, string orderId, string segment, string mcuId, string storePassword, int foodId, int coins, string ruleId, out string errMsg)
 {
     errMsg = string.Empty;
     if (deviceStoreType == XCGameManaDeviceStoreType.Store || deviceStoreType == XCGameManaDeviceStoreType.Merch)
     {
         string action = ((int)(deviceControlType)).ToString();
         string sn     = UDPSocketAnswerBusiness.GetSN();
         if (string.IsNullOrEmpty(orderId))
         {
             orderId = System.Guid.NewGuid().ToString("N");
         }
         DeviceControlRequestDataModel deviceControlModel = new DeviceControlRequestDataModel(storeId, mobile, icCardId.ToString(), segment, mcuId, action, coins, sn, orderId, storePassword, foodId, ruleId);
         MPOrderBusiness.AddTCPAnswerOrder(orderId, mobile, coins, action, "", storeId);
         IconOutLockBusiness.Add(mobile, coins);
         if (!DataFactory.SendDataToRadar(deviceControlModel, out errMsg))
         {
             return(false);
         }
         else
         {
             return(true);
         }
     }
     else
     {
         errMsg = "门店类型不正确";
         return(false);
     }
 }
        public object coinPut()
        {
            string orderId  = System.DateTime.Now.ToString("yyyyMMddHHmmss");
            string storeId  = "100027";
            string mobile   = "15618920033";
            int    icCardId = 10000002;
            string action   = "6";
            int    coins    = 5;
            string segment  = "0001";
            string mcuId    = "20170518000023";
            string sn       = UDPSocketAnswerBusiness.GetSN();
            string errMsg   = string.Empty;

            DeviceControlRequestDataModel deviceControlModel =
                new DeviceControlRequestDataModel(storeId, mobile, icCardId.ToString(), segment, mcuId, action, coins, sn, orderId, "778852013146", 0, "");

            MPOrderBusiness.AddTCPAnswerOrder(orderId, mobile, coins, action, "", storeId);
            IconOutLockBusiness.Add(mobile, coins);
            if (!DataFactory.SendDataToRadar(deviceControlModel, out errMsg))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Beispiel #4
0
        public object saveCoins(Dictionary <string, object> dicParas)
        {
            try
            {
                string state         = string.Empty;
                string stateName     = string.Empty;
                string xcGameDBName  = string.Empty;
                string errMsg        = string.Empty;
                string storePassword = string.Empty;
                string terminalNo    = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;

                XCGameMemberTokenModel memberTokenModel = (XCGameMemberTokenModel)(dicParas[Constant.XCGameMemberTokenModel]);
                MobileTokenModel       mobileTokenModel = (MobileTokenModel)(dicParas[Constant.MobileTokenModel]);

                //根据终端号查询终端号是否存在
                XCCloudService.BLL.IBLL.XCGameManager.IDeviceService deviceService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGameManager.IDeviceService>();
                var deviceModel = deviceService.GetModels(p => p.TerminalNo.Equals(terminalNo, StringComparison.OrdinalIgnoreCase)).FirstOrDefault <XCCloudService.Model.XCGameManager.t_device>();
                if (deviceModel == null)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "终端号不存在"));
                }
                StoreBusiness store = new StoreBusiness();
                if (!store.IsEffectiveStore(deviceModel.StoreId, out xcGameDBName, out storePassword, out errMsg))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                }

                if (!deviceModel.StoreId.Equals(memberTokenModel.StoreId))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "会员令牌对应门店和设备不一致"));
                }

                //判断设备状态是否为启用状态
                XCCloudService.BLL.IBLL.XCGame.IDeviceService ids = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IDeviceService>(xcGameDBName);
                var menlist = ids.GetModels(p => p.MCUID.Equals(deviceModel.DeviceId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault <XCCloudService.Model.XCGame.t_device>();
                if (menlist == null)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备不存在"));
                }

                if (menlist.state != "启用")
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备未启用"));
                }

                //验证缓存设备状态
                if (DeviceStateBusiness.ExistDeviceState(deviceModel.StoreId, deviceModel.DeviceId))
                {
                    state = DeviceStateBusiness.GetDeviceState(deviceModel.StoreId, deviceModel.DeviceId);
                }
                if (state != "1")
                {
                    stateName = DeviceStateBusiness.GetStateName(state);
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, stateName));
                }

                //请求雷达处理存币
                string action  = ((int)(DevieControlTypeEnum.存币)).ToString();
                string sn      = UDPSocketAnswerBusiness.GetSN();
                string orderId = System.Guid.NewGuid().ToString("N");
                DeviceControlRequestDataModel deviceControlModel = new DeviceControlRequestDataModel(deviceModel.StoreId, mobileTokenModel.Mobile, memberTokenModel.ICCardId, menlist.segment, menlist.MCUID, action, 0, sn, orderId, storePassword, 0, "");
                MPOrderBusiness.AddTCPAnswerOrder(orderId, mobileTokenModel.Mobile, 0, action, memberTokenModel.ICCardId, deviceModel.StoreId);
                IconOutLockBusiness.AddByNoTimeLimit(mobileTokenModel.Mobile);
                if (!DataFactory.SendDataToRadar(deviceControlModel, out errMsg))
                {
                    ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.F, "", Result_Code.T, errMsg);
                }

                //设置推送消息的缓存结构
                string form_id = dicParas.ContainsKey("form_id") ? dicParas["form_id"].ToString() : string.Empty;
                SAppMessageMana.SetMemberCoinsMsgCacheData(SAppMessageType.MemberCoinsOperationNotify, orderId, form_id, mobileTokenModel.Mobile, null, out errMsg);

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #5
0
        public static void RadarNotify(string requestDataJson, UDPClientItemBusiness.ClientItem item)
        {
            object outModel     = null;
            object requestModel = null;

            DataFactory.CreateResponseProtocolData(TransmiteEnum.雷达通知指令, requestDataJson, ref requestModel, ref outModel);
            RadarNotifyRequestModel     rnrModel         = Utils.DataContractJsonDeserializer <RadarNotifyRequestModel>(requestDataJson);
            RadarNotifyOutParamsModel   responseOutModel = (RadarNotifyOutParamsModel)outModel;
            XCGameRadarDeviceTokenModel radarTokenModel  = XCGameRadarDeviceTokenBusiness.GetRadarDeviceTokenModel(rnrModel.Token);

            Send(((IPEndPoint)item.remotePoint).Address.ToString(), ((IPEndPoint)item.remotePoint).Port, ((RadarNotifyOutParamsModel)outModel).ResponsePackages);
            RadarNotifyRequestModel requestDataModel = (RadarNotifyRequestModel)requestModel;

            //验证相应模式
            bool bCoinSuccess = false;

            if (responseOutModel.ResponseModel.GetType().Name.Equals("ComonErrorResponseModel"))
            {
                ComonErrorResponseModel model = (ComonErrorResponseModel)(responseOutModel.ResponseModel);
                bCoinSuccess = model.Result_Code == "1" ? true : false;
            }
            else if (responseOutModel.ResponseModel.GetType().Name.Equals("ComonSuccessResponseModel"))
            {
                ComonSuccessResponseModel model = (ComonSuccessResponseModel)(responseOutModel.ResponseModel);
                bCoinSuccess = model.Result_Code == "1" ? true : false;
            }

            //记录日志
            string logTxt = "[接收:" + requestDataJson + "]" + "[响应:" + responseOutModel.ResponseJson + "]" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");

            UDPLogHelper.SaveUDPRadarNotifyLog(requestDataModel.StoreId, requestDataModel.OrderId, requestDataModel.Token, requestDataModel.SN, int.Parse(requestDataModel.Coins), int.Parse(requestDataModel.Action), requestDataModel.Result, ((IPEndPoint)item.remotePoint).Address.ToString(), ((IPEndPoint)item.remotePoint).Port, requestDataJson, responseOutModel.ResponseJson, bCoinSuccess, logTxt);
            string message = "[接收:" + requestDataJson + "]" + "[响应:" + responseOutModel.ResponseJson + "]";

            SignalrServerToClient.BroadcastMessage(Convert.ToInt32(TransmiteEnum.雷达通知指令), "雷达通知指令", requestDataModel.Token, message, System.DateTime.Now);
            if (rnrModel.Result == "成功" && bCoinSuccess)
            {
                //出币后向客户端发送成功信息
                try
                {
                    TCPAnswerOrderModel taoModel = null;
                    //如果订单缓存信息存在
                    if (MPOrderBusiness.ExistTCPAnswerOrder(rnrModel.OrderId, ref taoModel))
                    {
                        string coinType      = CoinBusiess.GetCoinOpetionName(taoModel.Action);
                        string notifyMsg     = string.Empty;
                        string answerMsgType = string.Empty;
                        string errMsg        = string.Empty;
                        SAppPushMessageCacheModel msgModel = null;

                        if (taoModel.Action == "1")
                        {
                            notifyMsg     = "成功出币" + taoModel.Coins.ToString() + "个";
                            answerMsgType = ((int)(TCPAnswerMessageType.出币)).ToString();
                            if (SAppPushMessageBusiness.GetModel(rnrModel.OrderId, ref msgModel))
                            {
                                if (msgModel.SAppMessageType == SAppMessageType.MemberCoinsOperationNotify)
                                {
                                    MemberCoinsOperationNotifyDataModel dataModel = (MemberCoinsOperationNotifyDataModel)(msgModel.DataObj);
                                    SAppMessageMana.PushMemberCoinsMsg(msgModel.OpenId, msgModel.SAppAccessToken, "提币", dataModel.StoreName, dataModel.Mobile, dataModel.ICCardId, int.Parse(requestDataModel.Coins), dataModel.LastBalance, msgModel.FormId, "", out errMsg);
                                }
                                else if (msgModel.SAppMessageType == SAppMessageType.MemberFoodSaleNotify)
                                {
                                    MemberFoodSaleNotifyDataModel dataModel = (MemberFoodSaleNotifyDataModel)(msgModel.DataObj);
                                    SAppMessageMana.PushMemberFoodSaleMsg(msgModel.OpenId, msgModel.SAppAccessToken, "购币", dataModel.StoreName, msgModel.Mobile, msgModel.OrderId, dataModel.FoodName, dataModel.FoodNum, dataModel.ICCardId, dataModel.Money, dataModel.Coins, msgModel.FormId, out errMsg);
                                }
                            }
                        }
                        else if (taoModel.Action == "2")
                        {
                            notifyMsg     = "成功存币" + requestDataModel.Coins.ToString() + "个";
                            answerMsgType = ((int)(TCPAnswerMessageType.存币)).ToString();
                            IconOutLockBusiness.RemoveByNoTimeList(taoModel.Mobile);
                            if (int.Parse(requestDataModel.Coins) > 0)
                            {
                                try
                                {
                                    int    lastBalance = 0;
                                    string storeName   = string.Empty;
                                    string mobile      = string.Empty;
                                    if (MemberPreservationBusiness.PreservationBusiness(int.Parse(taoModel.ICCardId), int.Parse(taoModel.StoreId), int.Parse(requestDataModel.Coins), out lastBalance, out storeName, out mobile))
                                    {
                                        if (SAppPushMessageBusiness.GetModel(rnrModel.OrderId, ref msgModel))
                                        {
                                            MemberCoinsOperationNotifyDataModel dataModel = (MemberCoinsOperationNotifyDataModel)(msgModel.DataObj);
                                            SAppMessageMana.PushMemberCoinsMsg(msgModel.OpenId, msgModel.SAppAccessToken, "存币", dataModel.StoreName, dataModel.Mobile, dataModel.ICCardId, int.Parse(requestDataModel.Coins), dataModel.LastBalance, msgModel.FormId, "", out errMsg);
                                        }
                                    }
                                }
                                catch (Exception e)
                                {
                                    LogHelper.SaveLog(TxtLogType.Api, TxtLogContentType.Debug, TxtLogFileType.Day, "MemberPreservationBusiness.PreservationBusiness:" + e.Message);
                                }
                            }
                        }
                        else if (taoModel.Action == "6")//投币
                        {
                            MemberCoinsOperationNotifyDataModel dataModel = (MemberCoinsOperationNotifyDataModel)(msgModel.DataObj);
                            SAppMessageMana.PushMemberCoinsMsg(msgModel.OpenId, msgModel.SAppAccessToken, "投币", dataModel.StoreName, dataModel.Mobile, dataModel.ICCardId, int.Parse(requestDataModel.Coins), dataModel.LastBalance, msgModel.FormId, "", out errMsg);
                        }
                        else if (taoModel.Action == "7")//退币
                        {
                            MemberCoinsOperationNotifyDataModel dataModel = (MemberCoinsOperationNotifyDataModel)(msgModel.DataObj);
                            SAppMessageMana.PushMemberCoinsMsg(msgModel.OpenId, msgModel.SAppAccessToken, "退币", dataModel.StoreName, dataModel.Mobile, dataModel.ICCardId, int.Parse(requestDataModel.Coins), dataModel.LastBalance, msgModel.FormId, "", out errMsg);
                        }

                        var dataObj = new {
                            result_code   = "1",
                            answerMsg     = notifyMsg,
                            answerMsgType = answerMsgType
                        };
                        MPOrderBusiness.RemoveTCPAnswerOrder(rnrModel.OrderId);
                        TCPServiceBusiness.Send(taoModel.Mobile, dataObj);
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.SaveLog(TxtLogType.UPDService, TxtLogContentType.Exception, TxtLogFileType.Day, "Exception:" + rnrModel.OrderId + Utils.GetException(ex) + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                }
            }
        }