public object deviceControl(Dictionary <string, object> dicParas)
        {
            string errMsg   = string.Empty;
            string token    = dicParas.ContainsKey("token") ? dicParas["token"].ToString() : string.Empty;
            string mcuid    = dicParas.ContainsKey("mcuid") ? dicParas["mcuid"].ToString() : string.Empty;
            string icCardId = dicParas.ContainsKey("icCardId") ? dicParas["icCardId"].ToString() : string.Empty;
            string action   = dicParas.ContainsKey("controlAction") ? dicParas["controlAction"].ToString() : string.Empty;
            string coins    = dicParas.ContainsKey("coins") ? dicParas["coins"].ToString() : string.Empty;

            UDPClientItemBusiness.ClientItem item = XCCloudService.SocketService.UDP.ClientList.ClientListObj.Where <UDPClientItemBusiness.ClientItem>(p => p.gID.Equals(token)).FirstOrDefault <UDPClientItemBusiness.ClientItem>();
            if (item == null)
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "雷达token不存在"));
            }

            StoreBusiness   storeBusiness   = new StoreBusiness();
            StoreCacheModel storeCacheModel = null;

            if (!storeBusiness.IsEffectiveStore(item.StoreID, ref storeCacheModel, out errMsg))
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "门店不存在"));
            }

            IMemberService memberService = BLLContainer.Resolve <IMemberService>(storeCacheModel.StoreDBName);
            var            memberlist    = memberService.GetModels(x => x.ICCardID.ToString() == icCardId).FirstOrDefault <t_member>();

            if (memberlist == null)
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "手机号码无效"));
            }

            //判断设备状态是否为启用状态
            XCCloudService.BLL.IBLL.XCGame.IDeviceService ids = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IDeviceService>(storeCacheModel.StoreDBName);
            var menlist = ids.GetModels(p => p.MCUID.Equals(mcuid, 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, "设备未启用"));
            }

            string sn      = UDPSocketAnswerBusiness.GetSN();
            string orderId = System.Guid.NewGuid().ToString("N");
            DeviceControlRequestDataModel deviceControlModel = new DeviceControlRequestDataModel(item.StoreID, memberlist.Mobile, icCardId, item.Segment, mcuid, action, int.Parse(coins), sn, orderId, storeCacheModel.StorePassword, 0, "");

            MPOrderBusiness.AddTCPAnswerOrder(orderId, memberlist.Mobile, int.Parse(coins), action, icCardId, item.StoreID);

            if (!DataFactory.SendDataToRadar(deviceControlModel, out errMsg))
            {
                ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.F, "", Result_Code.T, errMsg);
            }

            var obj = new { orderId = orderId, sn = sn };

            return(ResponseModelFactory.CreateAnonymousSuccessModel(isSignKeyReturn, obj));
        }
Exemple #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);
            }
        }
Exemple #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;
            }
        }