예제 #1
0
        public object getDeviceInfo(Dictionary <string, object> dicParas)
        {
            try
            {
//                string MobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;//获取手机令牌
//                if (MobileToken == "")
//                {
//                    return ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "手机令牌不能为空");
//                }
//                string mobile = string.Empty;
//                if (!MobileTokenBusiness.ExistToken(MobileToken, out mobile))
//                {
//                    return ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "手机token无效");
//                }
//                mobile = mobile.Replace("RS232", "");
//                string sql = "";
//                sql = @"select b.SN,b.Token,b.DeviceName,b.Status from Base_DeviceInfo as b
// left join Base_MerchInfo as a on a.ID=b.MerchID  where a.State='1'  and DeviceType='0' and a.Mobile='" + mobile + "'";
//                DataSet ds = XCCloudRS232BLL.ExecuteQuerySentence(sql, null);
//                DataTable dt = ds.Tables[0];
//                if (dt.Rows.Count > 0)
//                {
//                    var basedeviceinfolist = Utils.GetModelList<BaseDeviceInfoModel>(dt).ToList();
//                    BaseDeviceInfoModelList baseDeviceInfoModelList = new BaseDeviceInfoModelList();
//                    baseDeviceInfoModelList.Lists = basedeviceinfolist;
//                    return ResponseModelFactory<BaseDeviceInfoModelList>.CreateModel(isSignKeyReturn, baseDeviceInfoModelList);
//                }
                string         mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                Base_MerchInfo merch       = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                var list = DeviceBusiness.GetDeviceList().Where(t => t.MerchID == merch.ID && (DeviceTypeEnum)(int)t.DeviceType == DeviceTypeEnum.Router && t.Status == 1).ToList();
                if (list.IsNull() || list.Count == 0)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "无数据"));
                }

                BaseDeviceInfoModelList baseDeviceInfoModelList = new BaseDeviceInfoModelList();
                baseDeviceInfoModelList.Lists = new List <BaseDeviceInfoModel>();
                foreach (var item in list)
                {
                    BaseDeviceInfoModel model = new BaseDeviceInfoModel();
                    model.DeviceName = item.DeviceName ?? item.SN;
                    model.SN         = item.SN;
                    model.Token      = item.Token;
                    model.Status     = DeviceStatusBusiness.GetDeviceState(item.Token);

                    baseDeviceInfoModelList.Lists.Add(model);
                }

                return(ResponseModelFactory <BaseDeviceInfoModelList> .CreateModel(isSignKeyReturn, baseDeviceInfoModelList));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #2
0
        public object DelMerch(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg  = string.Empty;
                string merchId = dicParas.ContainsKey("merchId") ? dicParas["merchId"].ToString() : string.Empty;
                XCCloudUserTokenModel userTokenKeyModel = (XCCloudUserTokenModel)dicParas[Constant.XCCloudUserTokenModel];
                string createUserId = userTokenKeyModel.LogId;

                #region 验证参数

                if (string.IsNullOrWhiteSpace(merchId))
                {
                    errMsg = "商户编号不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (!string.IsNullOrEmpty(merchId) && merchId.Length > 11)
                {
                    errMsg = "商户编号不能超过11个字符";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                #endregion

                IBase_MerchantInfoService base_MerchantInfoService = BLLContainer.Resolve <IBase_MerchantInfoService>();
                if (base_MerchantInfoService.Any(p => p.MerchID.Equals(merchId, StringComparison.OrdinalIgnoreCase)))
                {
                    var base_MerchantInfoModel = base_MerchantInfoService.GetModels(p => p.MerchID.Equals(merchId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                    if (base_MerchantInfoModel.CreateType == (int)CreateType.Agent && !base_MerchantInfoModel.CreateUserID.Equals(createUserId, StringComparison.OrdinalIgnoreCase)) //代理商创建
                    {
                        errMsg = "该商户只有所属代理商能删除";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }

                    base_MerchantInfoModel.MerchStatus = (int)MerchState.Stop;
                    if (!base_MerchantInfoService.Update(base_MerchantInfoModel))
                    {
                        errMsg = "删除商户信息失败";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }
                }
                else
                {
                    errMsg = "该商户信息不存在";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                //更新缓存
                MerchBusiness.Init();

                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }
예제 #3
0
        public object getSegmentList(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string routerToken = dicParas.ContainsKey("routerToken") ? dicParas["routerToken"].ToString() : string.Empty;
                string groupId     = dicParas.ContainsKey("groupId") ? dicParas["groupId"].ToString() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo router = DeviceBusiness.GetDeviceModel(routerToken);
                if (router.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "控制器令牌无效"));
                }

                Data_GameInfo group = GameBusiness.GetGameInfoModel(Convert.ToInt32(groupId));
                if (group.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "分组参数无效"));
                }

                //分组集合
                var groupList = MerchSegmentBusiness.GetMerchSegmentList().Where(t => t.ParentID == router.ID && t.GroupID == group.GroupID).ToList();

                GroupInfoModel model = new GroupInfoModel();
                model.groupId   = group.GroupID;
                model.groupName = group.GroupName;

                List <Terminal> Terminals = new List <Terminal>();
                foreach (var item in groupList)
                {
                    Terminal        t       = new Terminal();
                    Base_DeviceInfo cDevice = DeviceBusiness.GetDeviceModelById((int)item.DeviceID);
                    t.terminalName  = cDevice.DeviceName ?? cDevice.SN;
                    t.terminalToken = cDevice.Token;
                    t.headAddress   = item.HeadAddress;
                    t.sn            = cDevice.SN;
                    t.deviceType    = ((DeviceTypeEnum)cDevice.DeviceType).ToDescription();
                    t.status        = DeviceStatusBusiness.GetDeviceState(cDevice.Token);

                    Terminals.Add(t);
                }
                model.Terminals = Terminals;

                return(ResponseModelFactory <GroupInfoModel> .CreateModel(isSignKeyReturn, model));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #4
0
        public object getMemberExpenseDetail(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg       = string.Empty;
                string mobileToken  = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string icCardId     = dicParas.ContainsKey("icCardId") ? dicParas["icCardId"].ToString() : string.Empty;
                string flowType     = dicParas.ContainsKey("flowType") ? dicParas["flowType"].ToString() : string.Empty;
                string sDate        = dicParas.ContainsKey("sDate") ? dicParas["sDate"].ToString() : string.Empty;
                string eDate        = dicParas.ContainsKey("eDate") ? dicParas["eDate"].ToString() : string.Empty;
                string strPageIndex = dicParas.ContainsKey("pageIndex") ? dicParas["pageIndex"].ToString() : string.Empty;
                string strpageSize  = dicParas.ContainsKey("pageSize") ? dicParas["pageSize"].ToString() : string.Empty;

                int pageIndex = 1, pageSize = 10;

                if (!string.IsNullOrWhiteSpace(strPageIndex) && strPageIndex.IsInt())
                {
                    pageIndex = Convert.ToInt32(strPageIndex);
                }

                if (!string.IsNullOrWhiteSpace(strpageSize) && strpageSize.IsInt())
                {
                    pageSize = Convert.ToInt32(strpageSize);
                }

                if (mobileToken == "")
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "手机令牌不能为空"));
                }
                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户token无效"));
                }

                t_member member = MemberBusiness.GetMerchModel(icCardId);
                if (member.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "会员卡号错误"));
                }

                DataTable table = AccountBusiness.GetMemberExpenseDetail(merch.ID, icCardId, flowType, sDate, eDate, pageIndex, pageSize);

                if (table.Rows.Count == 0)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "无数据"));
                }

                var list = Utils.GetModelList <MemberExpenseDetailModel>(table).ToList();
                return(ResponseModelFactory <List <MemberExpenseDetailModel> > .CreateModel(isSignKeyReturn, list));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #5
0
        public object editDeviceName(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string deviceToken = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;
                string deviceName  = dicParas.ContainsKey("deviceName") ? dicParas["deviceName"].ToString() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo device = DeviceBusiness.GetDeviceModel(deviceToken);
                if (device.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备令牌无效"));
                }

                //设备未绑定
                if (device.MerchID.IsNull() || device.MerchID == 0)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备尚未绑定"));
                }

                //设备所属商户不是当前商户
                if (device.MerchID.IsNull() || device.MerchID == 0 || device.MerchID != merch.ID)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备属于其他商户,您没有权限查看该设备"));
                }

                device.DeviceName = deviceName;
                DeviceBusiness.UpdateDevice(device);

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #6
0
        public object updateDeviceState(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string deviceToken = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;
                string status      = dicParas.ContainsKey("status") ? dicParas["status"].ToString() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo device = DeviceBusiness.GetDeviceModel(deviceToken);
                if (device.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备令牌无效"));
                }

                //设备所属商户不是当前商户
                if (device.MerchID != merch.ID)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备属于其他商户,您没有权限查看该设备"));
                }

                if (string.IsNullOrWhiteSpace(status))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "参数错误"));
                }

                int    routerId       = 0;
                string strHeadAddress = string.Empty;

                //当前设备类型
                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)device.DeviceType;
                switch (currDeviceType)
                {
                case DeviceTypeEnum.SlotMachines:
                case DeviceTypeEnum.DepositMachine:
                {
                    //获取外设绑定关系实体
                    Data_MerchDevice md = MerchDeviceBusiness.GetMerchDeviceModel(device.ID);
                    if (md.IsNull())
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备未绑定"));
                    }

                    //获取控制器ID
                    routerId       = (int)md.ParentID;
                    strHeadAddress = md.HeadAddress;
                }
                break;

                case DeviceTypeEnum.Clerk:
                case DeviceTypeEnum.Terminal:
                {
                    //获取终端绑定关系实体
                    Data_MerchSegment ms = MerchSegmentBusiness.GetMerchSegmentModel(device.ID);
                    if (ms.IsNull())
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备未绑定"));
                    }

                    //获取控制器ID
                    routerId       = (int)ms.ParentID;
                    strHeadAddress = ms.HeadAddress;
                }
                break;
                }

                Base_DeviceInfo router = null;

                if (routerId != 0)
                {
                    //获取当前设备所属的控制器实体
                    router = DeviceBusiness.GetDeviceModelById(routerId);
                }

                if (router == null)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "获取控制器信息失败"));
                }

                if (string.IsNullOrWhiteSpace(strHeadAddress))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "获取设备地址失败"));
                }

                //雷达处理指令
                switch (status.Trim())
                {
                //启用
                case "1":
                    device.DeviceType = (int)DeviceStatusEnum.启用;
                    DeviceBusiness.UpdateDevice(device);
                    DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.离线.ToDescription());
                    break;

                //停用
                case "2":
                    device.DeviceType = (int)DeviceStatusEnum.停用;
                    DeviceBusiness.UpdateDevice(device);
                    DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.停用.ToDescription());
                    break;

                //锁定
                case "3":
                    UDPServer.server.机头锁定解锁指令(router.Token, strHeadAddress, true);
                    DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.锁定.ToDescription());
                    break;

                //解除锁定
                case "4":
                    UDPServer.server.机头锁定解锁指令(router.Token, strHeadAddress, false);
                    DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.在线.ToDescription());
                    break;

                //解除报警
                case "5": break;
                    ////投币
                    //case "6":
                    //    UDPServer.server.远程投币上分(router.Token, strHeadAddress, "10000010", 5);
                    //    break;
                    ////退币
                    //case "7":
                    //    UDPServer.server.远程退币(router.Token, strHeadAddress);
                    //    break;
                }

                //if (state == DeviceStatusEnum.停用 || state == DeviceStatusEnum.启用)
                //{
                //    device.Status = (int)state;
                //    DeviceBusiness.UpdateDevice(device);
                //}

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #7
0
        public object getMerchDeviceInfo(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string deviceToken = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo device = DeviceBusiness.GetDeviceModel(deviceToken);
                if (device.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备令牌无效"));
                }

                //设备所属商户不是当前商户
                if (device.MerchID != merch.ID)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备属于其他商户,您没有权限查看该设备"));
                }

                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)device.DeviceType;

                DeviceInfoModel model = new DeviceInfoModel();
                model.Router      = new Router();
                model.Group       = new Group();
                model.deviceName  = device.DeviceName ?? device.SN;
                model.deviceToken = device.Token;
                model.deviceType  = currDeviceType.ToDescription();
                model.deviceSN    = device.SN;
                model.status      = DeviceStatusBusiness.GetDeviceState(device.Token);

                switch (currDeviceType)
                {
                case DeviceTypeEnum.SlotMachines:
                case DeviceTypeEnum.DepositMachine:
                {
                    //获取外设绑定关系实体
                    Data_MerchDevice md = MerchDeviceBusiness.GetMerchDeviceModel(device.ID);
                    model.headAddress = md.HeadAddress;

                    //获取控制器实体
                    Base_DeviceInfo router = DeviceBusiness.GetDeviceModelById((int)md.ParentID);
                    model.Router.routerName  = router.DeviceName ?? router.SN;
                    model.Router.routerToken = router.Token;
                    model.Router.sn          = router.SN;
                }
                break;

                case DeviceTypeEnum.Clerk:
                case DeviceTypeEnum.Terminal:
                {
                    //获取终端绑定关系实体
                    Data_MerchSegment ms = MerchSegmentBusiness.GetMerchSegmentModel(device.ID);
                    model.headAddress = ms.HeadAddress;

                    //获取分组实体
                    Data_GameInfo group = GameBusiness.GetGameInfoModel(Convert.ToInt32(ms.GroupID));
                    model.Group.groupId   = group.GroupID;
                    model.Group.groupName = group.GroupName;
                    model.Group.groupType = ((GroupTypeEnum)(int)group.GroupType).ToDescription();
                }
                break;
                }
                return(ResponseModelFactory <DeviceInfoModel> .CreateModel(isSignKeyReturn, model));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #8
0
        public object removeDevice(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string deviceToken = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo device = DeviceBusiness.GetDeviceModel(deviceToken);
                if (device.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备令牌无效"));
                }

                //设备所属商户不是当前商户
                if (device.MerchID != merch.ID)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备已被其他商户绑定,没有权限操作该设备"));
                }

                //开始解除绑定
                device.MerchID = 0;
                device.Status  = (int)DeviceStatusEnum.未激活;

                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)device.DeviceType;
                bool           ret            = false;

                switch (currDeviceType)
                {
                case DeviceTypeEnum.Router:
                {
                    string sql = string.Format("exec RemoveMerchRouter {0}", device.ID);
                    XCCloudRS232BLL.ExecuteSql(sql);

                    //ret = DeviceBusiness.UpdateDevice(device);
                }
                break;

                case DeviceTypeEnum.SlotMachines:
                case DeviceTypeEnum.DepositMachine:
                {
                    //获取外设绑定关系实体
                    Data_MerchDevice md = MerchDeviceBusiness.GetMerchDeviceModel(device.ID);

                    using (var transactionScope = new System.Transactions.TransactionScope(TransactionScopeOption.RequiresNew))
                    {
                        DeviceBusiness.UpdateDevice(device);
                        ret = MerchDeviceBusiness.DeleteMerchDevice(md);

                        transactionScope.Complete();
                    }
                }
                break;

                case DeviceTypeEnum.Clerk:
                case DeviceTypeEnum.Terminal:
                {
                    //获取终端绑定关系实体
                    Data_MerchSegment ms = MerchSegmentBusiness.GetMerchSegmentModel(device.ID);

                    using (var transactionScope = new System.Transactions.TransactionScope(TransactionScopeOption.RequiresNew))
                    {
                        DeviceBusiness.UpdateDevice(device);
                        ret = MerchSegmentBusiness.DeleteMerchSegment(ms);

                        transactionScope.Complete();
                    }
                }
                break;
                }

                if (ret)
                {
                    DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.未激活.ToDescription());
                }

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #9
0
        public object getDeviceInfo(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string deviceToken = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;
                string routerToken = dicParas.ContainsKey("routerToken") ? dicParas["routerToken"].ToString().Trim().ToLower() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo device = DeviceBusiness.GetDeviceModel(deviceToken);
                if (device.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备令牌无效"));
                }

                string status = DeviceStatusBusiness.GetDeviceState(device.Token);

                //当前设备类型
                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)device.DeviceType;

                DeviceInfoModel model = new DeviceInfoModel();
                model.Router      = new Router();
                model.Group       = new Group();
                model.deviceName  = device.DeviceName ?? device.SN;
                model.deviceToken = device.Token;
                model.deviceType  = currDeviceType.ToDescription();
                model.deviceSN    = device.SN;
                model.status      = DeviceStatusBusiness.GetDeviceState(device.Token);


                //设备未绑定
                if (device.MerchID == 0 || device.MerchID.IsNull())
                {
                    model.BindState = (int)DeviceBoundStateEnum.NotBound;
                    return(ResponseModelFactory <DeviceInfoModel> .CreateModel(isSignKeyReturn, model));
                }

                //判断设备绑定的商户是否与当前商户一致
                if (device.MerchID != merch.ID)
                {
                    //与当前商户不一致
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "没有权限查看该设备信息"));
                }

                //Base_DeviceInfo currRouter = null;
                //if (!string.IsNullOrWhiteSpace(routerToken))
                //{
                //    currRouter = DeviceBusiness.GetDeviceModel(routerToken);
                //}

                //1.如果设备绑定的商户与当前商户一致
                //2.判断设备是否已与当前商户建立绑定关系
                switch (currDeviceType)
                {
                case DeviceTypeEnum.Router:
                    model.BindState = (int)DeviceBoundStateEnum.Bound;
                    break;

                case DeviceTypeEnum.SlotMachines:
                case DeviceTypeEnum.DepositMachine:
                {
                    //获取外设绑定关系实体
                    Data_MerchDevice md = MerchDeviceBusiness.GetMerchDeviceModel(device.ID);
                    if (md.IsNull())
                    {
                        model.BindState = (int)DeviceBoundStateEnum.NotBound;
                    }
                    else
                    {
                        //获取控制器实体
                        Base_DeviceInfo router = DeviceBusiness.GetDeviceModelById((int)md.ParentID);

                        if (router.Token.Trim().ToLower() != routerToken)
                        {
                            //设备所属控制器与当前控制器不一致
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备不属于当前控制器"));
                        }

                        model.BindState   = (int)DeviceBoundStateEnum.Bound;
                        model.headAddress = md.HeadAddress;
                        //控制器信息
                        model.Router.routerName  = router.DeviceName ?? router.SN;
                        model.Router.routerToken = router.Token;
                        model.Router.sn          = router.SN;
                    }
                }
                break;

                case DeviceTypeEnum.Clerk:
                case DeviceTypeEnum.Terminal:
                {
                    //获取终端绑定关系实体
                    Data_MerchSegment ms = MerchSegmentBusiness.GetMerchSegmentModel(device.ID);
                    if (ms.IsNull())
                    {
                        model.BindState = (int)DeviceBoundStateEnum.NotBound;
                    }
                    else
                    {
                        //获取控制器实体
                        Base_DeviceInfo router = DeviceBusiness.GetDeviceModelById((int)ms.ParentID);

                        if (router.Token.Trim().ToLower() != routerToken)
                        {
                            //设备所属控制器与当前控制器不一致
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备不属于当前控制器"));
                        }

                        model.BindState   = (int)DeviceBoundStateEnum.Bound;
                        model.headAddress = ms.HeadAddress;

                        //控制器信息
                        model.Router.routerName  = router.DeviceName ?? router.SN;
                        model.Router.routerToken = router.Token;
                        model.Router.sn          = router.SN;

                        //获取分组实体
                        Data_GameInfo group = GameBusiness.GetGameInfoModel(Convert.ToInt32(ms.GroupID));
                        model.Group.groupId   = group.GroupID;
                        model.Group.groupName = group.GroupName;
                        model.Group.groupType = ((GroupTypeEnum)(int)group.GroupType).ToDescription();
                    }
                }
                break;
                }

                //返回设备信息
                return(ResponseModelFactory <DeviceInfoModel> .CreateModel(isSignKeyReturn, model));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #10
0
        public object bindDevice(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string deviceToken = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;
                string deviceName  = dicParas.ContainsKey("deviceName") ? dicParas["deviceName"].ToString() : string.Empty;
                string level       = dicParas.ContainsKey("level") ? dicParas["level"].ToString() : string.Empty;
                string routerToken = dicParas.ContainsKey("routerToken") ? dicParas["routerToken"].ToString() : string.Empty;
                string groupId     = dicParas.ContainsKey("groupId") ? dicParas["groupId"].ToString() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                if (merch.State == 0)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "当前用户已被禁用"));
                }

                Base_DeviceInfo device = DeviceBusiness.GetDeviceModel(deviceToken);
                if (device.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备令牌无效"));
                }

                //设备已被绑定
                if (!device.MerchID.IsNull() && device.MerchID != 0 && device.MerchID != merch.ID)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备已被其他商户绑定"));
                }

                //设备未绑定,开始绑定
                device.MerchID    = merch.ID;
                device.DeviceName = deviceName;
                device.Status     = (int)DeviceStatusEnum.启用;

                if (string.IsNullOrWhiteSpace(level))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "参数错误"));
                }

                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)device.DeviceType;

                switch (level)
                {
                case "1":
                {
                    if (currDeviceType == DeviceTypeEnum.Router)
                    {
                        DeviceBusiness.UpdateDevice(device);
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
                    }
                    else if (currDeviceType == DeviceTypeEnum.SlotMachines || currDeviceType == DeviceTypeEnum.DepositMachine)
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "请选定控制器后绑定该设备"));
                    }
                    else
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "请在分组中绑定该设备"));
                    }
                }

                case "2":
                {
                    if (currDeviceType == DeviceTypeEnum.Router)
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "请在返回上级绑定"));
                    }
                    else if (currDeviceType == DeviceTypeEnum.SlotMachines || currDeviceType == DeviceTypeEnum.DepositMachine)
                    {
                        if (string.IsNullOrWhiteSpace(routerToken))
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "获取控制器参数错误"));
                        }
                        //获取控制器实体
                        Base_DeviceInfo router = DeviceBusiness.GetDeviceModel(routerToken);
                        if (router.IsNull())
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "获取控制器参数错误"));
                        }

                        //获取当前控制器中的外设列表
                        var list = MerchDeviceBusiness.GetListByParentId(router.ID).OrderBy(m => m.HeadAddress).ToList();

                        if (list.Count >= 11)
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "超出最大绑定数量"));
                        }

                        Data_MerchDevice md = list.FirstOrDefault(m => m.DeviceID == device.ID);
                        if (md.IsNull())
                        {
                            md          = new Data_MerchDevice();
                            md.ParentID = router.ID;
                            md.DeviceID = device.ID;

                            int index = 0;
                            foreach (var item in list)
                            {
                                string currAddress = string.Format("A{0}", index);
                                //int currIndex = int.Parse(item.HeadAddress, System.Globalization.NumberStyles.AllowHexSpecifier);
                                if (currAddress != item.HeadAddress)
                                {
                                    break;
                                }
                                index++;
                                continue;
                            }
                            //md.HeadAddress = Convert.ToString(index, 16).PadLeft(2, '0').ToUpper();
                            md.HeadAddress = string.Format("A{0}", index);
                        }

                        using (var transactionScope = new System.Transactions.TransactionScope(
                                   TransactionScopeOption.RequiresNew))
                        {
                            DeviceBusiness.UpdateDevice(device);
                            MerchDeviceBusiness.AddMerchDevice(md);

                            transactionScope.Complete();
                        }

                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
                    }
                    else
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "请在分组中绑定该设备"));
                    }
                }

                case "3":
                {
                    if (currDeviceType != DeviceTypeEnum.Clerk && currDeviceType != DeviceTypeEnum.Terminal)
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "请在分组中绑定该设备"));
                    }
                    else
                    {
                        if (string.IsNullOrWhiteSpace(groupId))
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "获取分组参数错误"));
                        }

                        //获取分组实体
                        Data_GameInfo group = GameBusiness.GetGameInfoModel(Convert.ToInt32(groupId));
                        if (group.IsNull())
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "获取分组参数错误"));
                        }

                        //根据分组获取当前分组的控制器
                        Base_DeviceInfo router = DeviceBusiness.GetDeviceModelById((int)group.DeviceID);
                        if (router.IsNull())
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "获取控制器参数错误"));
                        }

                        //判断当前分组是否属于当前商户
                        if (router.MerchID != merch.ID)
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "分组信息与当前商户不匹配"));
                        }

                        //获取当前分组中的终端列表
                        var list = MerchSegmentBusiness.GetListByGroupId(group.GroupID).OrderBy(m => m.HeadAddress).ToList();

                        if (list.Count >= 99)
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "超出最大绑定数量"));
                        }

                        Data_MerchSegment ms = list.FirstOrDefault(m => m.ParentID == group.DeviceID && m.DeviceID == device.ID);
                        if (ms.IsNull())
                        {
                            ms          = new Data_MerchSegment();
                            ms.ParentID = group.DeviceID;
                            ms.GroupID  = group.GroupID;
                            ms.DeviceID = device.ID;

                            int index = 1;
                            foreach (var item in list)
                            {
                                int currIndex = int.Parse(item.HeadAddress, System.Globalization.NumberStyles.AllowHexSpecifier);
                                if (currIndex != index)
                                {
                                    break;
                                }
                                index++;
                                continue;
                            }
                            ms.HeadAddress = Convert.ToString(index, 16).PadLeft(2, '0').ToUpper();
                        }

                        using (var transactionScope = new System.Transactions.TransactionScope(
                                   TransactionScopeOption.RequiresNew))
                        {
                            DeviceBusiness.UpdateDevice(device);
                            MerchSegmentBusiness.AddMerchSegment(ms);

                            transactionScope.Complete();
                        }

                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
                    }
                }
                }

                DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.离线.ToDescription());

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #11
0
        public object getRouterChildList(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string routerToken = dicParas.ContainsKey("routerToken") ? dicParas["routerToken"].ToString() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户token无效"));
                }

                Base_DeviceInfo router = DeviceBusiness.GetDeviceModel(routerToken);
                if (router.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "控制器token无效"));
                }

                //分组集合
                var groupList = GameBusiness.GetGameList().Where(t => t.DeviceID == router.ID).ToList();

                //外设集合
                var peripheralList = MerchDeviceBusiness.GetListByParentId(router.ID).ToList();

                RouterModel model = new RouterModel();
                model.routerName   = string.IsNullOrWhiteSpace(router.DeviceName) ? router.SN : router.DeviceName;
                model.routerToken  = router.Token;
                model.routerStatus = DeviceStatusBusiness.GetDeviceState(router.Token);
                model.routerSN     = router.SN;
                model.Groups       = groupList.Select(t => new Group
                {
                    groupId   = t.GroupID,
                    groupName = t.GroupName,
                    groupType = ((GroupTypeEnum)t.GroupType).ToDescription()
                }).ToList();

                List <Peripheral> Peripherals = new List <Peripheral>();
                foreach (var item in peripheralList)
                {
                    Peripheral      p       = new Peripheral();
                    Base_DeviceInfo cDevice = DeviceBusiness.GetDeviceModelById((int)item.DeviceID);
                    p.peripheralId    = (int)item.DeviceID;
                    p.peripheralName  = cDevice.DeviceName;
                    p.peripheralToken = cDevice.Token;
                    p.sn          = cDevice.SN;
                    p.deviceType  = ((DeviceTypeEnum)cDevice.DeviceType).ToDescription();
                    p.state       = DeviceStatusBusiness.GetDeviceState(cDevice.Token);
                    p.headAddress = item.HeadAddress;

                    Peripherals.Add(p);
                }
                model.Peripherals = Peripherals;

                return(ResponseModelFactory <RouterModel> .CreateModel(isSignKeyReturn, model));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #12
0
        public object ResetPassword(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg = string.Empty;
                //string mobil = dicParas.ContainsKey("mobil") ? dicParas["mobil"].ToString() : string.Empty;

                //if (string.IsNullOrEmpty(mobil))
                //{
                //    errMsg = "手机号不能为空";
                //    return ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg);
                //}

                //if (!Utils.CheckMobile(mobil))
                //{
                //    errMsg = "手机号不正确";
                //    return ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg);
                //}

                //bool isSMSTest = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["isSMSTest"].ToString());
                //string pwd = "123456";
                //if (!isSMSTest)
                //{
                //    //生成6位随机字母数字混合
                //    pwd = Utils.GetCheckCode(6);
                //    ResetPasswordCache.Add(mobil, pwd, CacheExpires.SMSCodeExpires);
                //    if (!SMSBusiness.SendSMSCode("3", mobil, pwd, out errMsg))
                //    {
                //        return ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg);
                //    }
                //}
                //else
                //{
                //    ResetPasswordCache.Add(mobil, pwd, CacheExpires.SMSCodeExpires);
                //}

                string openId = dicParas.ContainsKey("openId") ? dicParas["openId"].ToString() : string.Empty;

                if (string.IsNullOrEmpty(openId))
                {
                    errMsg = "openId不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                MerchInfoCacheModel merchInfoCacheModel = null;
                if (!MerchBusiness.IsEffectiveMerch(openId, out merchInfoCacheModel))
                {
                    errMsg = "该商户不存在";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                string merchId = merchInfoCacheModel.MerchID;
                string pwd     = Utils.GetCheckCode(6);
                IBase_MerchantInfoService base_MerchantInfoService = BLLContainer.Resolve <IBase_MerchantInfoService>();
                var base_MerchantInfoModel = base_MerchantInfoService.GetModels(p => p.MerchID.Equals(merchId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                base_MerchantInfoModel.MerchPassword = Utils.MD5(pwd);
                if (!base_MerchantInfoService.Update(base_MerchantInfoModel))
                {
                    errMsg = "更新数据库失败";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                //推送微信消息
                ResetPasswordMessagePush(openId, base_MerchantInfoModel.MerchAccount, pwd);

                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }
예제 #13
0
        public object getRoutersRevenue(Dictionary <string, object> dicParas)
        {
            try
            {
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string routerToken = dicParas.ContainsKey("routerToken") ? dicParas["routerToken"].ToString() : string.Empty;
                string sDate       = dicParas.ContainsKey("sDate") ? dicParas["sDate"].ToString() : string.Empty;
                string eDate       = dicParas.ContainsKey("eDate") ? dicParas["eDate"].ToString() : string.Empty;

                if (mobileToken == "")
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "手机令牌不能为空"));
                }
                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo router = DeviceBusiness.GetDeviceModel(routerToken);
                if (router.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "控制器令牌无效"));
                }

                DataSet ds = AccountBusiness.GetRoutersAmount(merch.ID, router.ID, sDate, eDate);

                MerchRoutersRevenueModel model = new MerchRoutersRevenueModel();
                model.RouterName = router.DeviceName;
                model.Token      = router.Token;

                if (ds.Tables.Count == 0)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, "无数据"));
                }

                model.SaveCoins = new CoinRevenueModel()
                {
                    Coins = new List <RevenueDataModel>()
                };
                if (ds.Tables[0].Rows.Count > 0)
                {
                    Int64 coinTotal = 0;
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        string currCoin = row["SaveCoins"].IsNull() ? "0" : row["SaveCoins"].ToString();
                        model.SaveCoins.Coins.Add(new RevenueDataModel()
                        {
                            Title = row["DeviceName"].ToString(), Value = currCoin
                        });

                        coinTotal += Convert.ToInt64(currCoin);
                    }
                    model.SaveCoins.CoinsTotal = coinTotal.ToString();
                }

                model.SaleCoins = new CoinRevenueModel()
                {
                    Coins = new List <RevenueDataModel>()
                };
                if (ds.Tables[1].Rows.Count > 0)
                {
                    Int64 coinTotal = 0;
                    foreach (DataRow row in ds.Tables[1].Rows)
                    {
                        string currCoin = row["SaleCoins"].IsNull() ? "0" : row["SaleCoins"].ToString();
                        model.SaleCoins.Coins.Add(new RevenueDataModel()
                        {
                            Title = row["DeviceName"].ToString(), Value = currCoin
                        });

                        coinTotal += Convert.ToInt64(currCoin);
                    }

                    model.SaleCoins.CoinsTotal = coinTotal.ToString();
                }

                return(ResponseModelFactory <MerchRoutersRevenueModel> .CreateModel(isSignKeyReturn, model));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #14
0
        public object getMemberDetail(Dictionary <string, object> dicParas)
        {
            try
            {
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string memberId    = dicParas.ContainsKey("memberId") ? dicParas["memberId"].ToString() : string.Empty;

                if (mobileToken == "")
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "手机令牌不能为空"));
                }
                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                if (string.IsNullOrWhiteSpace(memberId))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "参数错误"));
                }

                MemberDetailModel model = new MemberDetailModel();

                DataTable table = AccountBusiness.GetMemberDetail(memberId);

                if (table.Rows.Count == 0)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, "无数据"));
                }

                DataRow row = table.Rows[0];
                model.ICCardID     = row["ICCardID"].ToString();
                model.MemberName   = row["MemberName"].ToString();
                model.Mobile       = row["Mobile"].ToString();
                model.Birthday     = row["Birthday"].ToString();
                model.CertificalID = row["CertificalID"].ToString();
                model.Balance      = string.IsNullOrWhiteSpace(row["Balance"].ToString()) ? "0" : row["Balance"].ToString();
                model.Lottery      = string.IsNullOrWhiteSpace(row["Lottery"].ToString()) ? "0" : row["Lottery"].ToString();
                model.Point        = string.IsNullOrWhiteSpace(row["Point"].ToString()) ? "0" : row["Point"].ToString();
                switch (row["Type"].ToString())
                {
                case "0": model.Type = "会员卡"; break;

                case "1": model.Type = "数字币"; break;

                case "2": model.Type = "临时卡"; break;

                case "3": model.Type = "返分卡"; break;

                default: model.Type = "会员卡"; break;
                }
                model.JoinTime       = row["JoinTime"].IsNull() ? "" : Convert.ToDateTime(row["JoinTime"]).ToString("yyyy-MM-dd HH:mm:ss");
                model.EndDate        = string.IsNullOrWhiteSpace(row["EndDate"].ToString()) ? "" : Convert.ToDateTime(row["EndDate"]).ToString("yyyy-MM-dd");
                model.MemberPassword = row["MemberPassword"].ToString();
                model.Note           = row["Note"].ToString();
                model.Lock           = string.IsNullOrWhiteSpace(row["EndDate"].ToString()) || row["EndDate"].ToString() == "0" ? "未锁定" : "已锁定";
                model.LockDate       = "";
                if (model.Lock == "已锁定")
                {
                    model.LockDate = string.IsNullOrWhiteSpace(row["LockDate"].ToString()) ? "" : Convert.ToDateTime(row["EndDate"]).ToString("yyyy-MM-dd");
                }

                return(ResponseModelFactory <MemberDetailModel> .CreateModel(isSignKeyReturn, model));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #15
0
        public object getMemberSummary(Dictionary <string, object> dicParas)
        {
            try
            {
                string mobileToken  = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string icCardId     = dicParas.ContainsKey("icCardId") ? dicParas["icCardId"].ToString() : string.Empty;
                string sDate        = dicParas.ContainsKey("sDate") ? dicParas["sDate"].ToString() : string.Empty;
                string eDate        = dicParas.ContainsKey("eDate") ? dicParas["eDate"].ToString() : string.Empty;
                string strPageIndex = dicParas.ContainsKey("pageIndex") ? dicParas["pageIndex"].ToString() : string.Empty;
                string strpageSize  = dicParas.ContainsKey("pageSize") ? dicParas["pageSize"].ToString() : string.Empty;

                int pageIndex = 1, pageSize = 10;

                if (!string.IsNullOrWhiteSpace(strPageIndex) && strPageIndex.IsInt())
                {
                    pageIndex = Convert.ToInt32(strPageIndex);
                }

                if (!string.IsNullOrWhiteSpace(strpageSize) && strpageSize.IsInt())
                {
                    pageSize = Convert.ToInt32(strpageSize);
                }

                if (mobileToken == "")
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "手机令牌不能为空"));
                }
                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                DataSet ds = AccountBusiness.GetMemberSummary(merch.ID, icCardId, sDate, eDate, pageIndex, pageSize);

                MemberViewModel model = new MemberViewModel();

                if (ds.Tables.Count == 0)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, "无数据"));
                }

                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow row = ds.Tables[0].Rows[0];
                    model.MemberTotal      = Convert.ToInt32(row["MemberTotal"]);
                    model.BalanceTotal     = Convert.ToInt32(row["BalanceTotal"]);
                    model.TodayJoinMembers = Convert.ToInt32(row["TodayJoinMembers"]);
                    model.TodayGameMembers = Convert.ToInt32(row["TodayGameMembers"]);
                }

                model.MemberList = new List <MemberListModel>();
                if (ds.Tables[1].Rows.Count > 0)
                {
                    model.MemberList = Utils.GetModelList <MemberListModel>(ds.Tables[1]).ToList();
                }

                return(ResponseModelFactory <MemberViewModel> .CreateModel(isSignKeyReturn, model));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #16
0
        public object getFoodSaleRevenue(Dictionary <string, object> dicParas)
        {
            try
            {
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string routerToken = dicParas.ContainsKey("routerToken") ? dicParas["routerToken"].ToString() : string.Empty;
                string sDate       = dicParas.ContainsKey("sDate") ? dicParas["sDate"].ToString() : string.Empty;
                string eDate       = dicParas.ContainsKey("eDate") ? dicParas["eDate"].ToString() : string.Empty;

                if (mobileToken == "")
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "手机令牌不能为空"));
                }
                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户token无效"));
                }

                int?            routerId = null;
                Base_DeviceInfo router   = DeviceBusiness.GetDeviceModel(routerToken);
                if (!router.IsNull())
                {
                    routerId = router.ID;
                }

                DataSet ds = AccountBusiness.GetMerchRevenue(merch.ID, routerId, sDate, eDate);

                MerchRevenueModel model = new MerchRevenueModel();
                model.MerchName = merch.MerchName;

                if (ds.Tables.Count == 0)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, "无数据"));
                }

                model.Revenues = new List <RevenueDataModel>();
                model.Payment  = new List <RevenueDataModel>();
                if (ds.Tables[0].Rows.Count > 0)
                {
                    model.Amount = ds.Tables[0].Rows[0]["Amount"].ToString();

                    model.Revenues.Add(new RevenueDataModel()
                    {
                        Title = "充值总额", Value = ds.Tables[0].Rows[0]["RechargeAmount"].ToString()
                    });
                    model.Revenues.Add(new RevenueDataModel()
                    {
                        Title = "售币总额", Value = ds.Tables[0].Rows[0]["SaleAmount"].ToString()
                    });

                    model.Payment.Add(new RevenueDataModel()
                    {
                        Title = "现金", Value = ds.Tables[0].Rows[0]["CashPayAmount"].ToString()
                    });
                    model.Payment.Add(new RevenueDataModel()
                    {
                        Title = "微信", Value = ds.Tables[0].Rows[0]["WechatPayAmount"].ToString()
                    });
                    model.Payment.Add(new RevenueDataModel()
                    {
                        Title = "支付宝", Value = ds.Tables[0].Rows[0]["AliPayAmount"].ToString()
                    });
                    model.Payment.Add(new RevenueDataModel()
                    {
                        Title = "银联", Value = ds.Tables[0].Rows[0]["UnionPayAmount"].ToString()
                    });
                }
                else
                {
                    model.Revenues.Add(new RevenueDataModel()
                    {
                        Title = "充值总额", Value = "0.00"
                    });
                    model.Revenues.Add(new RevenueDataModel()
                    {
                        Title = "售币总额", Value = "0.00"
                    });

                    model.Payment.Add(new RevenueDataModel()
                    {
                        Title = "现金", Value = "0.00"
                    });
                    model.Payment.Add(new RevenueDataModel()
                    {
                        Title = "微信", Value = "0.00"
                    });
                    model.Payment.Add(new RevenueDataModel()
                    {
                        Title = "支付宝", Value = "0.00"
                    });
                    model.Payment.Add(new RevenueDataModel()
                    {
                        Title = "银联", Value = "0.00"
                    });
                }

                model.Coins = new List <RevenueDataModel>();
                if (ds.Tables[1].Rows.Count > 0)
                {
                    model.Coins.Add(new RevenueDataModel()
                    {
                        Title = "存币数", Value = ds.Tables[1].Rows[0]["SaveCoins"].ToString()
                    });
                }

                if (ds.Tables[2].Rows.Count > 0)
                {
                    model.Coins.Add(new RevenueDataModel()
                    {
                        Title = "售币数", Value = ds.Tables[2].Rows[0]["SaleCoins"].ToString()
                    });
                }

                return(ResponseModelFactory <MerchRevenueModel> .CreateModel(isSignKeyReturn, model));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #17
0
        public object getPeripheralRevenue(Dictionary <string, object> dicParas)
        {
            try
            {
                string mobileToken  = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string deviceToken  = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;
                string sDate        = dicParas.ContainsKey("sDate") ? dicParas["sDate"].ToString() : string.Empty;
                string eDate        = dicParas.ContainsKey("eDate") ? dicParas["eDate"].ToString() : string.Empty;
                string strPageIndex = dicParas.ContainsKey("pageIndex") ? dicParas["pageIndex"].ToString() : string.Empty;
                string strpageSize  = dicParas.ContainsKey("pageSize") ? dicParas["pageSize"].ToString() : string.Empty;

                int pageIndex = 1, pageSize = 10;

                if (!string.IsNullOrWhiteSpace(strPageIndex) && strPageIndex.IsInt())
                {
                    pageIndex = Convert.ToInt32(strPageIndex);
                }

                if (!string.IsNullOrWhiteSpace(strpageSize) && strpageSize.IsInt())
                {
                    pageSize = Convert.ToInt32(strpageSize);
                }

                if (mobileToken == "")
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "手机令牌不能为空"));
                }
                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo device = DeviceBusiness.GetDeviceModel(deviceToken);
                if (device.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备令牌无效"));
                }

                PeripheralRevenueModel model = new PeripheralRevenueModel();
                model.DeviceName = device.DeviceName;
                model.SN         = device.SN;

                //当前设备类型
                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)device.DeviceType;
                if (currDeviceType == DeviceTypeEnum.DepositMachine)
                {
                    DataSet ds = AccountBusiness.GetSaveCoinMachineRevenue(merch.ID, device.ID, sDate, eDate, pageIndex, pageSize);
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            RevenueDataModel m = new RevenueDataModel();
                            m.Title = "存币数";
                            m.Value = ds.Tables[0].Rows[0]["SaveCoins"].ToString();
                            model.Coins.Add(m);
                        }
                        if (ds.Tables[1].Rows.Count > 0)
                        {
                            model.CoinSerials = Utils.GetModelList <CoinSerialModel>(ds.Tables[1]).ToList();
                        }
                    }
                }
                else if (currDeviceType == DeviceTypeEnum.SlotMachines)
                {
                    DataSet ds = AccountBusiness.GetSaleCoinMachineRevenue(merch.ID, device.ID, sDate, eDate, pageIndex, pageSize);
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            RevenueDataModel m = new RevenueDataModel();
                            m.Title = "提币数";
                            m.Value = ds.Tables[0].Rows[0]["PullCoins"].ToString();
                            model.Coins.Add(m);

                            m       = new RevenueDataModel();
                            m.Title = "售币数";
                            m.Value = ds.Tables[0].Rows[0]["SaleCoins"].ToString();
                            model.Coins.Add(m);

                            m       = new RevenueDataModel();
                            m.Title = "售币金额";
                            m.Value = ds.Tables[0].Rows[0]["SaleCoinAmount"].ToString();
                            model.Coins.Add(m);
                        }
                        if (ds.Tables[1].Rows.Count > 0)
                        {
                            model.CoinSerials = Utils.GetModelList <CoinSerialModel>(ds.Tables[1]).ToList();
                        }
                    }
                }
                else
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, "无数据"));
                }

                return(ResponseModelFactory <PeripheralRevenueModel> .CreateModel(isSignKeyReturn, model));
            }
            catch (Exception e)
            {
                throw e.InnerException;
            }
        }
예제 #18
0
        public object replaceDevice(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg         = string.Empty;
                string mobileToken    = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string oldDeviceToken = dicParas.ContainsKey("oldDeviceToken") ? dicParas["oldDeviceToken"].ToString() : string.Empty;
                string newDeviceToken = dicParas.ContainsKey("newDeviceToken") ? dicParas["newDeviceToken"].ToString() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo oldDevice = DeviceBusiness.GetDeviceModel(oldDeviceToken);
                if (oldDevice.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "您要替换的设备令牌无效"));
                }

                //设备所属商户不是当前商户
                if (oldDevice.MerchID != merch.ID)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备不属于当前商户,没有权限操作该设备"));
                }

                //新设备实体
                Base_DeviceInfo newDevice = DeviceBusiness.GetDeviceModel(newDeviceToken);
                if (newDevice.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "当前扫面的设备令牌无效"));
                }

                //判断设备类别是否相同
                if (oldDevice.DeviceType != newDevice.DeviceType)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备类型不同,不能替换"));
                }

                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)oldDevice.DeviceType;
                int            category       = 0;

                switch (currDeviceType)
                {
                case DeviceTypeEnum.Router:
                    category = 1;
                    break;

                case DeviceTypeEnum.SlotMachines:
                case DeviceTypeEnum.DepositMachine:
                    category = 2;
                    break;

                case DeviceTypeEnum.Clerk:
                case DeviceTypeEnum.Terminal:
                    category = 3;
                    break;
                }

                if (category != 0)
                {
                    string         sql        = "exec ReplaceDevice @oldDeviceId,@newDeviceId,@merchId,@category";
                    SqlParameter[] parameters = new SqlParameter[4];
                    parameters[0] = new SqlParameter("@oldDeviceId", oldDevice.ID);
                    parameters[1] = new SqlParameter("@newDeviceId", newDevice.ID);
                    parameters[2] = new SqlParameter("@merchId", merch.ID);
                    parameters[3] = new SqlParameter("@category", category);
                    int ret = XCCloudRS232BLL.ExecuteSql(sql, parameters);
                    if (ret == 0)
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备替换失败"));
                    }
                }

                //修改设备缓存状态
                DeviceStatusBusiness.SetDeviceState(oldDevice.Token, DeviceStatusEnum.未激活.ToDescription());
                DeviceStatusBusiness.SetDeviceState(newDevice.Token, DeviceStatusEnum.离线.ToDescription());

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #19
0
        public object EditMerch(Dictionary <string, object> dicParas)
        {
            try
            {
                string   errMsg           = string.Empty;
                string   merchId          = dicParas.ContainsKey("merchId") ? dicParas["merchId"].ToString() : string.Empty;
                string   merchType        = dicParas.ContainsKey("merchType") ? dicParas["merchType"].ToString() : string.Empty;
                string   merchTag         = dicParas.ContainsKey("merchTag") ? dicParas["merchTag"].ToString() : string.Empty;
                string   merchStatus      = dicParas.ContainsKey("merchStatus") ? dicParas["merchStatus"].ToString() : string.Empty;
                string   merchAccount     = dicParas.ContainsKey("merchAccount") ? dicParas["merchAccount"].ToString() : string.Empty;
                string   merchName        = dicParas.ContainsKey("merchName") ? dicParas["merchName"].ToString() : string.Empty;
                string   openId           = dicParas.ContainsKey("openId") ? dicParas["openId"].ToString() : string.Empty;
                string   mobil            = dicParas.ContainsKey("mobil") ? dicParas["mobil"].ToString() : string.Empty;
                string   allowCreateSub   = dicParas.ContainsKey("allowCreateSub") ? dicParas["allowCreateSub"].ToString() : string.Empty;
                string   allowCreateCount = dicParas.ContainsKey("allowCreateCount") ? dicParas["allowCreateCount"].ToString() : string.Empty;
                string   comment          = dicParas.ContainsKey("comment") ? dicParas["comment"].ToString() : string.Empty;
                object[] merchFunction    = dicParas.ContainsKey("merchFunction") ? (object[])dicParas["merchFunction"] : null;
                XCCloudUserTokenModel userTokenKeyModel = (XCCloudUserTokenModel)dicParas[Constant.XCCloudUserTokenModel];
                string createUserId = userTokenKeyModel.LogId;
                int    logType      = userTokenKeyModel.LogType;

                #region 验证参数

                if (string.IsNullOrEmpty(merchId))
                {
                    errMsg = "商户编号不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (string.IsNullOrWhiteSpace(merchType))
                {
                    errMsg = "商户类型不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (!Utils.isNumber(merchType))
                {
                    errMsg = "商户类别不是Int类型";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (string.IsNullOrWhiteSpace(merchStatus))
                {
                    errMsg = "商户状态不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (!Utils.isNumber(merchStatus))
                {
                    errMsg = "商户状态不是Int类型";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (string.IsNullOrEmpty(merchTag))
                {
                    errMsg = "商户标签不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (!Utils.isNumber(merchTag))
                {
                    errMsg = "商户标签不是Int类型";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (string.IsNullOrWhiteSpace(merchAccount))
                {
                    errMsg = "商户账号不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (merchAccount.Length > 100)
                {
                    errMsg = "商户账号不能超过100个字符";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (string.IsNullOrWhiteSpace(merchName))
                {
                    errMsg = "负责人不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (merchName.Length > 50)
                {
                    errMsg = "负责人名称不能超过50个字符";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (string.IsNullOrWhiteSpace(openId))
                {
                    errMsg = "请选择微信昵称";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (string.IsNullOrWhiteSpace(mobil))
                {
                    errMsg = "手机号不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (!Utils.CheckMobile(mobil))
                {
                    errMsg = "手机号不正确";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (!string.IsNullOrEmpty(allowCreateSub) && !Utils.isNumber(allowCreateSub))
                {
                    errMsg = "是否允许创建子账号不是Int类型";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (!string.IsNullOrEmpty(allowCreateCount) && !Utils.isNumber(allowCreateCount))
                {
                    errMsg = "账号数量不是Int类型";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (!string.IsNullOrEmpty(comment) && comment.Length > 500)
                {
                    errMsg = "备注不能超过500个字符";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                //获取用户基本信息
                string unionId = string.Empty;
                if (!TokenMana.GetUnionId(openId, out unionId, out errMsg))
                {
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                #endregion

                //开启EF事务
                using (TransactionScope ts = new TransactionScope())
                {
                    try
                    {
                        IBase_MerchantInfoService base_MerchantInfoService = BLLContainer.Resolve <IBase_MerchantInfoService>();
                        if (base_MerchantInfoService.GetCount(p => !p.MerchID.Equals(merchId) && p.MerchAccount.Equals(merchAccount, StringComparison.OrdinalIgnoreCase)) > 0)
                        {
                            errMsg = "该商户账号名称已存在";
                            return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                        }

                        var base_MerchantInfo = base_MerchantInfoService.GetModels(p => p.MerchID.Equals(merchId)).FirstOrDefault();
                        base_MerchantInfo.MerchType        = Convert.ToInt32(merchType);
                        base_MerchantInfo.MerchStatus      = Convert.ToInt32(merchStatus);
                        base_MerchantInfo.MerchAccount     = merchAccount;
                        base_MerchantInfo.MerchName        = merchName;
                        base_MerchantInfo.Mobil            = mobil;
                        base_MerchantInfo.WxOpenID         = openId;
                        base_MerchantInfo.WxUnionID        = unionId;
                        base_MerchantInfo.AllowCreateSub   = !string.IsNullOrEmpty(allowCreateSub) ? Convert.ToInt32(allowCreateSub) : default(int?);
                        base_MerchantInfo.AllowCreateCount = !string.IsNullOrEmpty(allowCreateCount) ? Convert.ToInt32(allowCreateCount) : default(int?);
                        base_MerchantInfo.CreateUserID     = createUserId;
                        base_MerchantInfo.CreateType       = (logType == (int)RoleType.XcUser || logType == (int)RoleType.XcAdmin) ? (int)CreateType.Xc : (logType == (int)RoleType.MerchUser ? (int)CreateType.Agent : 0);
                        base_MerchantInfo.Comment          = comment;
                        base_MerchantInfo.MerchTag         = Convert.ToInt32(merchTag);

                        if (!base_MerchantInfoService.Update(base_MerchantInfo))
                        {
                            errMsg = "修改商户信息失败";
                            return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                        }

                        IBase_UserInfoService base_UserInfoService = BLLContainer.Resolve <IBase_UserInfoService>();
                        var base_UserInfo = base_UserInfoService.GetModels(p => p.OpenID.Equals(openId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                        if (base_UserInfo == null)
                        {
                            base_UserInfo          = new Base_UserInfo();
                            base_UserInfo.OpenID   = openId;
                            base_UserInfo.UserType = Convert.ToInt32(merchType);
                            if (!base_UserInfoService.Add(base_UserInfo))
                            {
                                errMsg = "添加商户负责人信息失败";
                                return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                            }
                        }

                        if (merchFunction != null && merchFunction.Count() >= 0)
                        {
                            //先删除已有数据,后添加
                            var dbContext = DbContextFactory.CreateByModelNamespace(typeof(Base_MerchFunction).Namespace);
                            var base_MerchFunctionList = dbContext.Set <Base_MerchFunction>().Where(p => p.MerchID.Equals(merchId, StringComparison.OrdinalIgnoreCase)).ToList();
                            foreach (var base_MerchFunction in base_MerchFunctionList)
                            {
                                dbContext.Entry(base_MerchFunction).State = EntityState.Deleted;
                            }


                            foreach (IDictionary <string, object> el in merchFunction)
                            {
                                if (el != null)
                                {
                                    var    dicPara    = new Dictionary <string, object>(el, StringComparer.OrdinalIgnoreCase);
                                    string functionId = dicPara.ContainsKey("functionId") ? dicPara["functionId"].ToString() : string.Empty;
                                    string functionEn = dicPara.ContainsKey("functionEn") ? dicPara["functionEn"].ToString() : string.Empty;
                                    if (string.IsNullOrEmpty(functionId))
                                    {
                                        errMsg = "功能编号不能为空";
                                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                                    }
                                    if (!Utils.isNumber(functionId))
                                    {
                                        errMsg = "功能编号不是Int类型";
                                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                                    }
                                    if (!string.IsNullOrEmpty(functionEn) && !Utils.isNumber(functionEn))
                                    {
                                        errMsg = "功能启停不是Int类型";
                                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                                    }
                                    var base_MerchFunction = new Base_MerchFunction();
                                    base_MerchFunction.MerchID                = merchId;
                                    base_MerchFunction.FunctionID             = Convert.ToInt32(functionId);
                                    base_MerchFunction.FunctionEN             = !string.IsNullOrEmpty(functionEn) ? Convert.ToInt32(functionEn) : default(int?);
                                    dbContext.Entry(base_MerchFunction).State = EntityState.Added;
                                }
                                else
                                {
                                    errMsg = "提交数据包含空对象";
                                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                                }
                            }

                            if (dbContext.SaveChanges() < 0)
                            {
                                errMsg = "保存商户功能菜单信息失败";
                                return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                            }
                        }

                        ts.Complete();
                    }
                    catch (Exception ex)
                    {
                        errMsg = ex.Message;
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }
                }

                //更新缓存
                MerchBusiness.Init();

                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }