Пример #1
0
        public ActionResult MiniAppSaveMoneySetManager(int appId, int?projectType = null, int?pageType = null)
        {
            if (dzaccount == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙auth_null!" }, JsonRequestBehavior.AllowGet));
            }
            XcxAppAccountRelation app = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

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

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

            int saveMoneySwtich = 0;//储值开关
            int versionId       = 0;

            if (_tempLate.Type == (int)TmpType.小程序专业模板)
            {
                FunctionList functionList = new FunctionList();
                versionId    = app.VersionId;
                functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={_tempLate.Type} and VersionId={versionId}");
                if (functionList == null)
                {
                    return(View("PageError", new Return_Msg()
                    {
                        Msg = "功能权限未设置!", code = "500"
                    }));
                }
                if (!string.IsNullOrEmpty(functionList.ProductMgr))
                {
                    OperationMgr operationMgr = JsonConvert.DeserializeObject <OperationMgr>(functionList.OperationMgr);
                    saveMoneySwtich = operationMgr.SaveMoney;
                }
            }
            string souceFrom = Context.GetRequest("SouceFrom", string.Empty);

            ViewBag.SouceFrom       = souceFrom;
            ViewBag.saveMoneySwtich = saveMoneySwtich;
            ViewBag.versionId       = versionId;

            bool canSaveMoneyFunction = 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));
                }
                try
                {
                    store.funJoinModel = JsonConvert.DeserializeObject <StoreConfigModel>(store.configJson);
                }
                catch (Exception)
                {
                    store.funJoinModel = new StoreConfigModel();
                }
                canSaveMoneyFunction = store.funJoinModel.canSaveMoneyFunction;
                break;

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

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

                canSaveMoneyFunction = ent.funJoinModel.canSaveMoneyFunction;
                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);
                canSaveMoneyFunction = footbath.switchModel.canSaveMoneyFunction;
                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();
                canSaveMoneyFunction   = multiStore.switchModel.canSaveMoneyFunction;
                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 = Newtonsoft.Json.JsonConvert.DeserializeObject <PlatStoreSwitchModel>(platStore.SwitchConfig);
                }
                canSaveMoneyFunction = switchModel.SaveMoneyPay;
                break;
            }

            ViewBag.canSaveMoneyFuntion = canSaveMoneyFunction;
            ViewBag.appId = appId;
            if (projectType.HasValue)
            {
                ViewBag.typeId = projectType.Value;
            }
            if (pageType.HasValue)
            {
                ViewBag.typeId = pageType.Value;
            }

            return(View());
        }
Пример #2
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 ? "修改成功" : "修改失败" }));
        }
Пример #3
0
        public ActionResult AddMiniAppSaveMoneySet(int appId, SaveMoneySet model)
        {
            XcxAppAccountRelation app = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (app == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙null!" }, JsonRequestBehavior.AllowGet));
            }

            XcxTemplate _tempLate = XcxTemplateBLL.SingleModel.GetModel(app.TId);

            if (_tempLate == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙tempLate_null!" }));
            }
            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 = "请升级更高版本才能使用此功能!" }));
                }
            }
            if (dzaccount == null)
            {
                return(Json(new { isok = false, msg = "系统繁忙auth_null!" }, JsonRequestBehavior.AllowGet));
            }

            if (model.JoinMoney <= 0 || model.JoinMoney > 9999999)
            {
                return(Json(new { isok = false, msg = "充值金额请设定0.01 ~ 99999.99!" }, JsonRequestBehavior.AllowGet));
            }

            if (model.GiveMoney < 0 || model.GiveMoney > 9999999)
            {
                return(Json(new { isok = false, msg = "赠送金额请设定0.00 ~ 99999.99!" }, JsonRequestBehavior.AllowGet));
            }
            //int resultInt = 0;//
            List <SaveMoneySet> List = SaveMoneySetBLL.SingleModel.getListByAppId(app.AppId);

            if (model.Id == 0)//添加
            {
                if (List.Count >= 20)
                {
                    return(Json(new { isok = false, msg = "目前最多能添加20个储值项目" }));
                }
                if (List.Any(m => m.JoinMoney == model.JoinMoney && m.GiveMoney == model.GiveMoney))
                {
                    return(Json(new { isok = false, msg = "已存在相同储值项目 , 请重新添加" }));
                }
                model.AppId       = app.AppId;
                model.SetName     = $"充{model.JoinMoneyStr}送{model.GiveMoneyStr}";
                model.AmountMoney = model.JoinMoney + model.GiveMoney;
                model.CreateDate  = DateTime.Now;
                model.State       = 1;
                object result = SaveMoneySetBLL.SingleModel.Add(model);
                if (int.Parse(result.ToString()) > 0)
                {
                    return(Json(new { isok = true, msg = "添加成功!", newid = result }, JsonRequestBehavior.AllowGet));
                }
            }


            return(Json(new { isok = false, msg = "系统错误!" }));
        }
Пример #4
0
        public ActionResult SaveExchangePlayCardConfig(ExchangePlayCardConfig model)
        {
            result = new Return_Msg();
            int appId = Context.GetRequestInt("appId", 0);

            if (dzaccount == null)
            {
                result.Msg = "登录信息超时";
                return(Json(result));
            }

            XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (xcx == null)
            {
                result.Msg = "小程序未授权";
                return(Json(result));
            }


            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel($"id={xcx.TId}");

            if (xcxTemplate == null)
            {
                result.Msg = "找不到小程序模板";
                return(Json(result));
            }

            if (xcxTemplate.Type == (int)TmpType.小程序专业模板)
            {
                FunctionList functionList = new FunctionList();
                int          industr      = xcx.VersionId;
                functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={xcxTemplate.Type} and VersionId={industr}");
                if (functionList == null)
                {
                    result.Msg = "功能权限未设置";
                    return(Json(result));
                }

                OperationMgr operationMgr = new OperationMgr();
                if (!string.IsNullOrEmpty(functionList.OperationMgr))
                {
                    operationMgr = JsonConvert.DeserializeObject <OperationMgr>(functionList.OperationMgr);
                }

                if (operationMgr.Integral == 1)
                {
                    result.Msg = "请先升级到更高版本才能开启此功能";
                    return(Json(result));
                }
            }

            Store store = StoreBLL.SingleModel.GetModelByRid(appId);

            if (store == null)
            {
                result.Msg = $"店铺配置不存在";
                return(Json(result));
            }
            ExchangePlayCardConfig exchangePlayCardConfig = new ExchangePlayCardConfig();

            store.funJoinModel = JsonConvert.DeserializeObject <StoreConfigModel>(store.configJson) ?? new StoreConfigModel();//若为 null 则new一个新的配置
            if (store.funJoinModel != null)
            {
                store.funJoinModel.ExchangePlayCardConfig = JsonConvert.SerializeObject(model);
                store.configJson = JsonConvert.SerializeObject(store.funJoinModel);
            }

            if (StoreBLL.SingleModel.Update(store, "configJson"))
            {
                result.Msg = $"保存成功";
                return(Json(result));
            }
            else
            {
                result.Msg = $"保存失败";
                return(Json(result));
            }
        }
Пример #5
0
        public ActionResult SaveExchangeRule(ExchangeRule exchangeRule)
        {
            if (exchangeRule.appId <= 0)
            {
                return(Json(new { isok = false, msg = "appId非法" }, JsonRequestBehavior.AllowGet));
            }
            if (dzaccount == null)
            {
                return(Json(new { isok = false, msg = "登录信息超时" }, JsonRequestBehavior.AllowGet));
            }
            XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(exchangeRule.appId, dzaccount.Id.ToString());

            if (xcx == null)
            {
                return(Json(new { isok = false, msg = "小程序未授权" }, JsonRequestBehavior.AllowGet));
            }

            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel($"id={xcx.TId}");

            if (xcxTemplate == null)
            {
                return(Json(new { isok = false, msg = "找不到小程序模板" }, JsonRequestBehavior.AllowGet));
            }



            int ruleTotalCount = ExchangeRuleBLL.SingleModel.GetCount($"appId={exchangeRule.appId} and state=0");

            if (ruleTotalCount >= 10)
            {
                return(Json(new { isok = false, msg = "最多设置10条规则" }, JsonRequestBehavior.AllowGet));
            }

            if (!Regex.IsMatch(exchangeRule.integral.ToString(), @"^\+?[1-9][0-9]*$"))
            {
                return(Json(new { isok = false, msg = "积分必须为大于零的整数" }, JsonRequestBehavior.AllowGet));
            }

            if (!Regex.IsMatch(exchangeRule.price.ToString(), @"^\+?[0-9][0-9]*$"))
            {
                return(Json(new { isok = false, msg = "金额不合法!" }, JsonRequestBehavior.AllowGet));
            }

            if (exchangeRule.ruleType == 1)
            {
                //表示选择部分商品消费赠送积分
                if (!StringHelper.IsNumByStrs(',', exchangeRule.goodids))
                {
                    return(Json(new { isok = false, msg = "请选择消费赠送金额的商品!" }, JsonRequestBehavior.AllowGet));
                }
            }

            if (exchangeRule.Id > 0)
            {
                ExchangeRule model = ExchangeRuleBLL.SingleModel.GetModel(exchangeRule.Id);
                if (model == null)
                {
                    return(Json(new { isok = false, msg = "数据不存在!" }, JsonRequestBehavior.AllowGet));
                }
                //表示更新
                exchangeRule.UpdateDate = DateTime.Now;
                if (ExchangeRuleBLL.SingleModel.Update(exchangeRule))
                {
                    return(Json(new { isok = true, msg = "更新成功!" }, JsonRequestBehavior.AllowGet));
                }
                return(Json(new { isok = false, msg = "更新失败!" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                if (xcxTemplate.Type == (int)TmpType.小程序专业模板)
                {
                    FunctionList functionList = new FunctionList();
                    int          industr      = xcx.VersionId;
                    functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={xcxTemplate.Type} and VersionId={industr}");
                    if (functionList == null)
                    {
                        return(Json(new { isok = false, msg = $"功能权限未设置" }, JsonRequestBehavior.AllowGet));
                    }
                    OperationMgr operationMgr = new OperationMgr();
                    if (!string.IsNullOrEmpty(functionList.OperationMgr))
                    {
                        operationMgr = JsonConvert.DeserializeObject <OperationMgr>(functionList.OperationMgr);
                    }

                    if (operationMgr.Integral == 1)
                    {
                        return(Json(new { isok = false, msg = $"请先升级到更高版本才能开启此功能" }, JsonRequestBehavior.AllowGet));
                    }
                }


                //表示新增
                exchangeRule.AddTime    = DateTime.Now;
                exchangeRule.UpdateDate = DateTime.Now;
                int ruleId = Convert.ToInt32(ExchangeRuleBLL.SingleModel.Add(exchangeRule));
                if (ruleId > 0)
                {
                    return(Json(new { isok = true, msg = "新增成功!", obj = ruleId }, JsonRequestBehavior.AllowGet));
                }
                return(Json(new { isok = false, msg = "新增失败!" }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #6
0
        public ActionResult ExchangeRuleList(int appId = 0)
        {
            if (appId <= 0)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "参数错误!", code = "500"
                }));
            }
            if (dzaccount == null)
            {
                return(Redirect("/dzhome/login"));
            }
            XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (xcx == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "小程序未授权!", code = "403"
                }));
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel($"id={xcx.TId}");

            if (xcxTemplate == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "小程序模板不存在!", code = "500"
                }));
            }

            Store storeModel = StoreBLL.SingleModel.GetModelByAId(appId);

            if (storeModel == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "店铺信息错误!", code = "403"
                }));
            }

            int integralSwtich = 0;//积分开关
            int versionId      = 0;

            if (xcxTemplate.Type == (int)TmpType.小程序专业模板)
            {
                FunctionList functionList = new FunctionList();
                versionId    = xcx.VersionId;
                functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={xcxTemplate.Type} and VersionId={versionId}");
                if (functionList == null)
                {
                    return(View("PageError", new Return_Msg()
                    {
                        Msg = "功能权限未设置!", code = "500"
                    }));
                }
                if (!string.IsNullOrEmpty(functionList.OperationMgr))
                {
                    OperationMgr operationMgr = JsonConvert.DeserializeObject <OperationMgr>(functionList.OperationMgr);
                    integralSwtich = operationMgr.Integral;
                }
            }

            ViewBag.integralSwtich = integralSwtich;
            ViewBag.versionId      = versionId;

            ViewBag.PageType = xcxTemplate.Type;
            ViewBag.appId    = appId;

            List <ExchangeRule> listRule = ExchangeRuleBLL.SingleModel.GetList($"appId={appId} and state=0");

            listRule.ForEach(x =>
            {
                if (x.ruleType == 1 && !string.IsNullOrEmpty(x.goodids))
                {
                    List <EntGoods> listgoods = EntGoodsBLL.SingleModel.GetList($" id in({x.goodids})");
                    listgoods.ForEach(y =>
                    {
                        x.goodslist.Add(new PickGood {
                            Id = y.id, GoodsName = y.name, ImgUrl = y.img, sel = true, showtime = y.showUpdateTime
                        });
                    });
                }
            });
            ExchangePlayCardConfig exchangePlayCardConfig = new ExchangePlayCardConfig();

            if (string.IsNullOrEmpty(storeModel.configJson))
            {
                storeModel.funJoinModel = new StoreConfigModel();
            }
            else
            {
                storeModel.funJoinModel = JsonConvert.DeserializeObject <StoreConfigModel>(storeModel.configJson);
            }
            if (!string.IsNullOrEmpty(storeModel.funJoinModel.ExchangePlayCardConfig))
            {
                exchangePlayCardConfig = JsonConvert.DeserializeObject <ExchangePlayCardConfig>(storeModel.funJoinModel.ExchangePlayCardConfig);
            }

            ViewBag.ExchangePlayCardConfig = exchangePlayCardConfig;

            return(View(listRule));
        }
Пример #7
0
        public ActionResult ExchangeActivityList(int appId = 0)
        {
            if (appId <= 0)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "参数错误!", code = "500"
                }));
            }
            if (dzaccount == null)
            {
                return(Redirect("/dzhome/login"));
            }
            XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (xcx == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "小程序未授权!", code = "403"
                }));
            }
            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel($"id={xcx.TId}");

            if (xcxTemplate == null)
            {
                return(View("PageError", new Return_Msg()
                {
                    Msg = "小程序模板不存在!", code = "500"
                }));
            }

            int integralSwtich = 0;//积分开关
            int versionId      = 0;

            if (xcxTemplate.Type == (int)TmpType.小程序专业模板)
            {
                FunctionList functionList = new FunctionList();
                versionId    = xcx.VersionId;
                functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={xcxTemplate.Type} and VersionId={versionId}");
                if (functionList == null)
                {
                    return(View("PageError", new Return_Msg()
                    {
                        Msg = "功能权限未设置!", code = "500"
                    }));
                }
                if (!string.IsNullOrEmpty(functionList.OperationMgr))
                {
                    OperationMgr operationMgr = JsonConvert.DeserializeObject <OperationMgr>(functionList.OperationMgr);
                    integralSwtich = operationMgr.Integral;
                }
            }

            ViewBag.integralSwtich = integralSwtich;
            ViewBag.versionId      = versionId;
            ViewBag.PageType       = xcxTemplate.Type;
            ViewBag.appId          = appId;

            return(View());
        }
Пример #8
0
        public ActionResult ExchangeActivitySaveSet(ExchangeActivity exChangeModel)
        {
            int appId = Context.GetRequestInt("appId", 0);

            if (appId <= 0)
            {
                return(Json(new { isok = false, msg = "appId非法" }, JsonRequestBehavior.AllowGet));
            }
            if (dzaccount == null)
            {
                return(Json(new { isok = false, msg = "登录信息超时" }, JsonRequestBehavior.AllowGet));
            }
            XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString());

            if (xcx == null)
            {
                return(Json(new { isok = false, msg = "小程序未授权" }, JsonRequestBehavior.AllowGet));
            }

            XcxTemplate xcxTemplate = XcxTemplateBLL.SingleModel.GetModel($"id={xcx.TId}");

            if (xcxTemplate == null)
            {
                return(Json(new { isok = false, msg = "找不到该小程序模板" }, JsonRequestBehavior.AllowGet));
            }



            if (exChangeModel.activityname.Length <= 0 || exChangeModel.activityname.Length > 100)
            {
                return(Json(new { isok = false, msg = "活动名称不能为空并且小于100字符" }, JsonRequestBehavior.AllowGet));
            }

            if (!Regex.IsMatch(exChangeModel.integral.ToString(), @"^\+?[0-9]*$"))
            {
                return(Json(new { isok = false, msg = "所需积分必须为整数" }, JsonRequestBehavior.AllowGet));
            }
            if (!Regex.IsMatch(exChangeModel.stock.ToString(), @"^\+?[0-9]*$"))
            {
                return(Json(new { isok = false, msg = "库存必须为正整数" }, JsonRequestBehavior.AllowGet));
            }
            if (!Regex.IsMatch(exChangeModel.perexgcount.ToString(), @"^\+?[1-9][0-9]*$"))
            {
                return(Json(new { isok = false, msg = "每人可兑换数量必须为正整数且大于0" }, JsonRequestBehavior.AllowGet));
            }

            if (!Regex.IsMatch(exChangeModel.freight.ToString(), @"^\+?[0-9]*$"))
            {
                return(Json(new { isok = false, msg = "运费不合法!" }, JsonRequestBehavior.AllowGet));
            }

            if (exChangeModel.exchangeway == 1)
            {
                //表示积分+金额兑换需要验证金额
                if (!Regex.IsMatch(exChangeModel.price.ToString(), @"^\+?[1-9][0-9]*$") || exChangeModel.price <= 0)
                {
                    return(Json(new { isok = false, msg = "金额不合法!" }, JsonRequestBehavior.AllowGet));
                }
            }

            //图片
            string activityimg = Context.GetRequest("activityimg", string.Empty);
            string imgs        = Context.GetRequest("imgs", string.Empty);

            bool result = false;

            string[] Imgs = imgs.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            if (exChangeModel.id > 0)
            {
                //表示更新
                ExchangeActivity model = ExchangeActivityBLL.SingleModel.GetModel(exChangeModel.id);
                if (model == null)
                {
                    return(Json(new { isok = false, msg = "数据不存在!" }, JsonRequestBehavior.AllowGet));
                }
                exChangeModel.UpdateDate = DateTime.Now;

                result = ExchangeActivityBLL.SingleModel.Update(exChangeModel);
            }
            else
            {
                if (xcxTemplate.Type == (int)TmpType.小程序专业模板)
                {
                    FunctionList functionList = new FunctionList();
                    int          industr      = xcx.VersionId;
                    functionList = FunctionListBLL.SingleModel.GetModel($"TemplateType={xcxTemplate.Type} and VersionId={industr}");
                    if (functionList == null)
                    {
                        return(Json(new { isok = false, msg = $"功能权限未设置" }, JsonRequestBehavior.AllowGet));
                    }
                    OperationMgr operationMgr = new OperationMgr();
                    if (!string.IsNullOrEmpty(functionList.OperationMgr))
                    {
                        operationMgr = JsonConvert.DeserializeObject <OperationMgr>(functionList.OperationMgr);
                    }

                    if (operationMgr.Integral == 1)
                    {
                        return(Json(new { isok = false, msg = $"请先升级到更高版本才能开启此功能" }, JsonRequestBehavior.AllowGet));
                    }
                }


                //表示新增
                if (activityimg.Length <= 0)
                {
                    return(Json(new { isok = false, msg = "请上传活动图片!" }, JsonRequestBehavior.AllowGet));
                }

                if (Imgs.Length <= 0 || Imgs.Length > 5)
                {
                    return(Json(new { isok = false, msg = "轮播图至少一张最多5张!" }, JsonRequestBehavior.AllowGet));
                }
                exChangeModel.appId      = appId;
                exChangeModel.apptype    = xcxTemplate.Type;
                exChangeModel.AddTime    = DateTime.Now;
                exChangeModel.UpdateDate = DateTime.Now;
                int id = Convert.ToInt32(ExchangeActivityBLL.SingleModel.Add(exChangeModel));
                result           = id > 0;
                exChangeModel.id = id;
            }

            if (result)
            {
                if (!string.IsNullOrEmpty(activityimg))
                {
                    //添加店铺Logo
                    C_AttachmentBLL.SingleModel.Add(new C_Attachment
                    {
                        itemId     = exChangeModel.id,
                        createDate = DateTime.Now,
                        filepath   = activityimg,
                        itemType   = (int)AttachmentItemType.小程序积分活动图片,
                        thumbnail  = Utility.AliOss.AliOSSHelper.GetAliImgThumbKey(activityimg, 300, 300),
                        status     = 0
                    });
                }


                if (Imgs.Length > 0)
                {
                    foreach (string img in Imgs)
                    {
                        //判断上传图片是否以http开头,不然为破图-蔡华兴
                        if (!string.IsNullOrWhiteSpace(img) && img.IndexOf("http") == 0)
                        {
                            C_AttachmentBLL.SingleModel.Add(new C_Attachment
                            {
                                itemId     = exChangeModel.id,
                                createDate = DateTime.Now,
                                filepath   = img,
                                itemType   = (int)AttachmentItemType.小程序积分活动轮播图,
                                thumbnail  = img,
                                status     = 0
                            });
                        }
                    }
                }

                return(Json(new { isok = true, msg = "操作成功!", obj = exChangeModel.id }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new { isok = true, msg = "操作失败!" }, JsonRequestBehavior.AllowGet));
        }