Exemplo n.º 1
0
        public object DelChainStore(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg = string.Empty;
                string id     = dicParas.ContainsKey("id") ? (dicParas["id"] + "") : string.Empty;

                if (string.IsNullOrEmpty(id))
                {
                    errMsg = "门店连锁规则ID不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                int iId = Convert.ToInt32(id);
                IBase_ChainRule_StoreService base_ChainRule_StoreService = BLLContainer.Resolve <IBase_ChainRule_StoreService>();
                if (!base_ChainRule_StoreService.Any(a => a.ID == iId))
                {
                    errMsg = "该门店连锁规则不存在";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                var base_ChainRule_StoreModel = base_ChainRule_StoreService.GetModels(p => p.ID == iId).FirstOrDefault();
                if (!base_ChainRule_StoreService.Delete(base_ChainRule_StoreModel))
                {
                    errMsg = "删除接收余额的门店失败";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }
Exemplo n.º 2
0
        public object SaveChainStore(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg     = string.Empty;
                string revStoreId = dicParas.ContainsKey("revStoreId") ? (dicParas["revStoreId"] + "") : string.Empty;
                string ruleType   = dicParas.ContainsKey("ruleType") ? (dicParas["ruleType"] + "") : string.Empty;
                XCCloudUserTokenModel userTokenKeyModel = (XCCloudUserTokenModel)dicParas[Constant.XCCloudUserTokenModel];
                string merchId = userTokenKeyModel.DataModel.MerchID;

                if (string.IsNullOrEmpty(revStoreId))
                {
                    errMsg = "接收门店ID不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (string.IsNullOrEmpty(ruleType))
                {
                    errMsg = "规则类别不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (!Utils.isNumber(ruleType))
                {
                    errMsg = "规则类别格式不正确";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                int iRuleType = Convert.ToInt32(ruleType);
                IBase_ChainRuleService       base_ChainRuleService       = BLLContainer.Resolve <IBase_ChainRuleService>();
                IBase_ChainRule_StoreService base_ChainRule_StoreService = BLLContainer.Resolve <IBase_ChainRule_StoreService>();

                if (!base_ChainRuleService.Any(a => a.MerchID.Equals(merchId, StringComparison.OrdinalIgnoreCase) && a.RuleType == iRuleType))
                {
                    errMsg = "该商户分组规则不存在";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                int ruleGroupId = base_ChainRuleService.GetModels(p => p.MerchID.Equals(merchId, StringComparison.OrdinalIgnoreCase) && p.RuleType == iRuleType).FirstOrDefault().RuleGroupID;
                var base_ChainRule_StoreModel = new Base_ChainRule_Store();
                base_ChainRule_StoreModel.RuleGroupID = ruleGroupId;
                base_ChainRule_StoreModel.StoreID     = revStoreId;
                if (base_ChainRule_StoreService.Any(a => a.StoreID.Equals(revStoreId, StringComparison.OrdinalIgnoreCase) && a.RuleGroupID == ruleGroupId))
                {
                    errMsg = "该门店连锁规则已存在";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                if (!base_ChainRule_StoreService.Add(base_ChainRule_StoreModel))
                {
                    errMsg = "保存接收余额的门店失败";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

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