示例#1
0
文件: FoodBLL.cs 项目: soon14/vzan
        public bool UpdateConfigJson(Food store, string option, string value)
        {
            FoodConfigModel newConfig = null;

            switch (option.ToLower())
            {
            case "reservation":
                newConfig = store.funJoinModel;
                newConfig.reservationSwitch = value == "true";
                break;

            case "reservationprint":
                newConfig = store.funJoinModel;
                newConfig.reservationPrint = value == "true";
                break;
            }
            if (newConfig != null)
            {
                store.configJson = JsonConvert.SerializeObject(newConfig);
                return(Update(store, "configJson,UpdateDate"));
            }
            return(false);
        }
示例#2
0
        public ActionResult ModifyFirstOrderDiscountMoneySetting(int appId, int storeId = 0, float newUserFirstOrderDiscountMoney = 0.00f, float userFirstOrderDiscountMoney = 0.00f)
        {
            Return_Msg handingResult = new Return_Msg();

            handingResult.isok = true;
            handingResult.code = "0";
            handingResult.Msg  = "保存成功";

            if (newUserFirstOrderDiscountMoney < 0 || newUserFirstOrderDiscountMoney > 99999.99)
            {
                handingResult.code = "201";
                handingResult.Msg  = "新用户首单立减金额请设定 0.00 ~ 99999.99 区间的值";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }
            if (userFirstOrderDiscountMoney < 0 || userFirstOrderDiscountMoney > 99999.99)
            {
                handingResult.code = "202";
                handingResult.Msg  = "用户首单立减金额请设定 0.00 ~ 99999.99 区间的值";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(appId);

            if (xcxrelation == null)
            {
                handingResult.code = "1";
                handingResult.Msg  = "未找到小程序授权资料";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                handingResult.code = "2";
                handingResult.Msg  = "未找到小程序的模板";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }

            bool isUpdateSuccess = false;

            switch (xcxTemplate.Type)
            {
            case (int)TmpType.小程序餐饮模板:
                Food store_Food = FoodBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store_Food == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(Json(handingResult, JsonRequestBehavior.AllowGet));
                }

                //修改设定
                FoodConfigModel foodConfig = store_Food.funJoinModel;
                foodConfig.newUserFirstOrderDiscountMoney = newUserFirstOrderDiscountMoney;
                foodConfig.userFirstOrderDiscountMoney    = userFirstOrderDiscountMoney;

                store_Food.configJson = JsonConvert.SerializeObject(foodConfig);
                store_Food.UpdateDate = DateTime.Now;

                isUpdateSuccess = FoodBLL.SingleModel.Update(store_Food, "configJson,UpdateDate");
                break;

            case (int)TmpType.小程序多门店模板:
                FootBath store_MultiStore = FootBathBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : " and HomeId = 0 ")}");
                if (store_MultiStore == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(Json(handingResult, JsonRequestBehavior.AllowGet));
                }

                //读取配置
                SwitchModel switchModel = null;
                try
                {
                    switchModel = JsonConvert.DeserializeObject <SwitchModel>(store_MultiStore.SwitchConfig);
                }
                catch (Exception)
                {
                    switchModel = new SwitchModel();
                }
                //修改设定
                switchModel.newUserFirstOrderDiscountMoney = newUserFirstOrderDiscountMoney;
                switchModel.userFirstOrderDiscountMoney    = userFirstOrderDiscountMoney;

                store_MultiStore.SwitchConfig = JsonConvert.SerializeObject(switchModel);
                store_MultiStore.UpdateDate   = DateTime.Now;

                isUpdateSuccess = FootBathBLL.SingleModel.Update(store_MultiStore, "SwitchConfig,UpdateDate");
                break;

            default:
                handingResult.code = "3";
                handingResult.Msg  = "还未开通店铺";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }

            if (!isUpdateSuccess)
            {
                handingResult.isok = false;
                handingResult.code = "-1";
                handingResult.Msg  = "修改失败,请重试!";
            }
            return(Json(handingResult, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public ActionResult ModifyMeetMoneySwitchState(int appId, int storeId = 0, bool discountRuleSwitch = false)
        {
            Return_Msg handingResult = new Return_Msg();

            handingResult.isok = true;
            handingResult.code = "0";
            handingResult.Msg  = discountRuleSwitch ? "已开启" : "已关闭";

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(appId);

            if (xcxrelation == null)
            {
                handingResult.code = "1";
                handingResult.Msg  = "未找到小程序授权资料";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                handingResult.code = "2";
                handingResult.Msg  = "未找到小程序的模板";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }

            bool isUpdateSuccess = false;

            switch (xcxTemplate.Type)
            {
            case (int)TmpType.小程序餐饮模板:
                Food store_Food = FoodBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store_Food == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(Json(handingResult, JsonRequestBehavior.AllowGet));
                }

                //修改设定
                FoodConfigModel foodConfig = store_Food.funJoinModel;
                foodConfig.discountRuleSwitch = discountRuleSwitch;

                store_Food.configJson = JsonConvert.SerializeObject(foodConfig);
                store_Food.UpdateDate = DateTime.Now;

                isUpdateSuccess = FoodBLL.SingleModel.Update(store_Food, "configJson,UpdateDate");
                break;

            case (int)TmpType.小程序多门店模板:
                FootBath store_MultiStore = FootBathBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : " and HomeId = 0 ")}");
                if (store_MultiStore == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(Json(handingResult, JsonRequestBehavior.AllowGet));
                }

                //读取配置
                SwitchModel switchModel = null;
                try
                {
                    switchModel = JsonConvert.DeserializeObject <SwitchModel>(store_MultiStore.SwitchConfig);
                }
                catch (Exception)
                {
                    switchModel = new SwitchModel();
                }
                switchModel.discountRuleSwitch = discountRuleSwitch;

                //修改设定
                store_MultiStore.SwitchConfig = JsonConvert.SerializeObject(switchModel);
                store_MultiStore.UpdateDate   = DateTime.Now;
                isUpdateSuccess = FootBathBLL.SingleModel.Update(store_MultiStore, "SwitchConfig,UpdateDate");
                break;

            default:
                handingResult.code = "3";
                handingResult.Msg  = "还未开通店铺";
                return(Json(handingResult, JsonRequestBehavior.AllowGet));
            }

            if (!isUpdateSuccess)
            {
                handingResult.isok = false;
                handingResult.code = "-1";
                handingResult.Msg  = "修改失败,请重试!";
            }
            return(Json(handingResult, JsonRequestBehavior.AllowGet));
        }
示例#4
0
        public ActionResult changeCanSaveMoenySetting(int appId, bool canSaveMoneyFunction)
        {
            if (dzaccount == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙auth_null!" }));
            }
            XcxAppAccountRelation app = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (app == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙null!" }));
            }
            XcxTemplate _tempLate = XcxTemplateBLL.SingleModel.GetModel(app.TId);

            if (_tempLate == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙tempLate_null!" }));
            }

            #region 专业版 版本控制
            if (_tempLate.Type == (int)TmpType.小程序专业模板)
            {
                FunctionList functionList = new FunctionList();
                int          industr      = app.VersionId;
                functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={_tempLate.Type} and VersionId={industr}");
                if (functionList == null)
                {
                    return(Json(new { isok = false, msg = "此功能未开启" }));
                }

                OperationMgr operationMgr = new OperationMgr();
                if (!string.IsNullOrEmpty(functionList.OperationMgr))
                {
                    operationMgr = JsonConvert.DeserializeObject <OperationMgr>(functionList.OperationMgr);
                }
                if (operationMgr.SaveMoney == 1)//表示关闭了储值使用功能
                {
                    return(Json(new { isok = false, msg = "请升级更高版本才能使用此功能!" }));
                }
            }
            #endregion

            bool isSuccess = true;

            switch (_tempLate.Type)
            {
            case (int)TmpType.小程序电商模板:
                Store store = StoreBLL.SingleModel.GetModel($"appId={appId}");
                if (store == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙store_null!" }, JsonRequestBehavior.AllowGet));
                }
                StoreConfigModel newConfig = null;
                try
                {
                    newConfig = JsonConvert.DeserializeObject <StoreConfigModel>(store.configJson);
                }
                catch (Exception)
                {
                    newConfig = new StoreConfigModel();
                }

                newConfig.canSaveMoneyFunction = canSaveMoneyFunction;
                store.configJson = JsonConvert.SerializeObject(newConfig);

                isSuccess = StoreBLL.SingleModel.Update(store, "configJson");
                break;

            case (int)TmpType.小程序餐饮模板:
                Food food = FoodBLL.SingleModel.GetModel($"appId={appId}");
                if (food == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙store_null!" }, JsonRequestBehavior.AllowGet));
                }
                FoodConfigModel foodConfig = food.funJoinModel;
                foodConfig.canSaveMoneyFunction = canSaveMoneyFunction;
                food.configJson = JsonConvert.SerializeObject(foodConfig);

                isSuccess = FoodBLL.SingleModel.Update(food, "configJson");
                break;

            case (int)TmpType.小程序专业模板:
                EntSetting ent = EntSettingBLL.SingleModel.GetModel($"aid={appId}");
                if (ent == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙store_null!" }, JsonRequestBehavior.AllowGet));
                }


                EntConfigModel entConfig = ent.funJoinModel;
                entConfig.canSaveMoneyFunction = canSaveMoneyFunction;
                ent.configJson = JsonConvert.SerializeObject(entConfig);

                isSuccess = EntSettingBLL.SingleModel.Update(ent, "configJson");
                break;

            case (int)TmpType.小程序足浴模板:
                FootBath footbath = FootBathBLL.SingleModel.GetModel($"appId={appId}");
                if (footbath == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙store_null!" }, JsonRequestBehavior.AllowGet));
                }
                footbath.switchModel = JsonConvert.DeserializeObject <SwitchModel>(footbath.SwitchConfig);
                footbath.switchModel.canSaveMoneyFunction = canSaveMoneyFunction;
                footbath.SwitchConfig = JsonConvert.SerializeObject(footbath.switchModel);
                isSuccess             = FootBathBLL.SingleModel.Update(footbath, "SwitchConfig");
                break;

            case (int)TmpType.小程序多门店模板:
                FootBath multiStore = FootBathBLL.SingleModel.GetModel($"appId={appId} and HomeId = 0 ");
                if (multiStore == null)
                {
                    return(Json(new { isok = false, msg = "系统繁忙store_null!" }, JsonRequestBehavior.AllowGet));
                }
                multiStore.switchModel = JsonConvert.DeserializeObject <SwitchModel>(multiStore.SwitchConfig) ?? new SwitchModel();
                multiStore.switchModel.canSaveMoneyFunction = canSaveMoneyFunction;
                multiStore.SwitchConfig = JsonConvert.SerializeObject(multiStore.switchModel);
                isSuccess = FootBathBLL.SingleModel.Update(multiStore, "SwitchConfig");
                break;

            case (int)TmpType.小未平台子模版:
                PlatStore platStore = PlatStoreBLL.SingleModel.GetPlatStore(app.Id, 2);

                if (platStore == null)
                {
                    return(Json(new { isok = false, msg = "店铺不存在!" }, JsonRequestBehavior.AllowGet));
                }
                PlatStoreSwitchModel switchModel = new PlatStoreSwitchModel();

                if (!string.IsNullOrEmpty(platStore.SwitchConfig))
                {
                    switchModel = JsonConvert.DeserializeObject <PlatStoreSwitchModel>(platStore.SwitchConfig);
                }
                switchModel.SaveMoneyPay = canSaveMoneyFunction;
                platStore.SwitchConfig   = JsonConvert.SerializeObject(switchModel);
                platStore.UpdateTime     = DateTime.Now;
                isSuccess = PlatStoreBLL.SingleModel.Update(platStore, "UpdateTime,SwitchConfig");
                break;
            }
            return(Json(new { isok = isSuccess, msg = isSuccess ? "修改成功" : "修改失败" }));
        }
示例#5
0
        /// <summary>
        /// 将 CommonSetting 逆推更入数据库
        /// </summary>
        /// <param name="commonSetting"></param>
        /// <param name="aId"></param>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public static Return_Msg UpdateCommonSetting(CommonSetting commonSetting, int aId, int storeId = 0)
        {
            Return_Msg handingResult = new Return_Msg();

            handingResult.isok = false;

            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModel(aId);

            if (xcxrelation == null)
            {
                handingResult.code = "1";
                handingResult.Msg  = "未找到小程序授权资料";
                return(handingResult);
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel(xcxrelation.TId);

            if (xcxTemplate == null)
            {
                handingResult.code = "2";
                handingResult.Msg  = "未找到小程序的模板";
                return(handingResult);
            }

            switch (xcxTemplate.Type)
            {
            case (int)TmpType.小程序餐饮模板:
                Food store_Food = FoodBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store_Food == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(handingResult);
                }

                //修改设定
                FoodConfigModel foodConfig = store_Food.funJoinModel;
                foodConfig.discountRuleSwitch             = commonSetting.discountRuleSwitch;
                foodConfig.newUserFirstOrderDiscountMoney = commonSetting.newUserFirstOrderDiscountMoney;
                foodConfig.userFirstOrderDiscountMoney    = commonSetting.userFirstOrderDiscountMoney;
                foodConfig.sortQueueSwitch = commonSetting.sortQueueSwitch;
                foodConfig.sortNo_next     = commonSetting.sortNo_next;

                store_Food.configJson = JsonConvert.SerializeObject(foodConfig);
                store_Food.UpdateDate = DateTime.Now;

                handingResult.isok = FoodBLL.SingleModel.Update(store_Food, "configJson,UpdateDate");
                handingResult.Msg  = handingResult.isok ? "配置变更成功" : "配置变更失败";
                return(handingResult);

            case (int)TmpType.小程序多门店模板:
                FootBath store_MultiStore = FootBathBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : " and HomeId = 0 ")}");
                if (store_MultiStore == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(handingResult);
                }

                //读取配置
                SwitchModel switchModel = null;
                try
                {
                    switchModel = JsonConvert.DeserializeObject <SwitchModel>(store_MultiStore.SwitchConfig);
                }
                catch (Exception)
                {
                    switchModel = new SwitchModel();
                }
                switchModel.discountRuleSwitch             = commonSetting.discountRuleSwitch;
                switchModel.newUserFirstOrderDiscountMoney = commonSetting.newUserFirstOrderDiscountMoney;
                switchModel.userFirstOrderDiscountMoney    = commonSetting.userFirstOrderDiscountMoney;

                //修改设定
                store_MultiStore.SwitchConfig = JsonConvert.SerializeObject(switchModel);
                store_MultiStore.UpdateDate   = DateTime.Now;
                handingResult.isok            = FootBathBLL.SingleModel.Update(store_MultiStore, "SwitchConfig,UpdateDate");
                handingResult.Msg             = handingResult.isok ? "配置变更成功" : "配置变更失败";
                return(handingResult);

            case (int)TmpType.小程序电商模板:
            case (int)TmpType.小程序专业模板:
                Store store = StoreBLL.SingleModel.GetModel($" appId = {xcxrelation.Id} {(storeId > 0 ? $" and Id = {storeId}" : "")} ");
                if (store == null)
                {
                    handingResult.code = "3";
                    handingResult.Msg  = "还未开通店铺";
                    return(handingResult);
                }
                try
                {
                    store.funJoinModel = JsonConvert.DeserializeObject <StoreConfigModel>(store.configJson);
                }
                catch (Exception)
                {
                    store.funJoinModel = new StoreConfigModel();
                }

                storeId = store.Id;
                store.funJoinModel.sortQueueSwitch = commonSetting.sortQueueSwitch;
                store.funJoinModel.sortNo_next     = commonSetting.sortNo_next;
                store.configJson = JsonConvert.SerializeObject(store.funJoinModel);

                store.UpdateDate   = DateTime.Now;
                handingResult.isok = StoreBLL.SingleModel.Update(store, "configJson,UpdateDate");
                handingResult.Msg  = handingResult.isok ? "配置变更成功" : "配置变更失败";
                return(handingResult);

            default:
                handingResult.code = "3";
                handingResult.Msg  = "还未开通店铺";
                return(handingResult);
            }
        }