/// <summary> /// 获取店铺产品类别配置 来进行样式的显示 /// </summary> /// <returns></returns> public ActionResult GetGoodsCategoryLevel() { returnObj = new Return_Msg_APP(); returnObj.code = "200"; string appId = Context.GetRequest("appId", string.Empty); if (string.IsNullOrEmpty(appId)) { returnObj.Msg = "参数错误"; return(Json(returnObj)); } XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId); if (r == null) { returnObj.Msg = "小程序未授权"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } PlatStore platStore = PlatStoreBLL.SingleModel.GetPlatStore(r.Id, 2); if (platStore == null) { returnObj.Msg = "店铺不存在"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } PlatStoreSwitchModel switchModel = new PlatStoreSwitchModel(); int productCategoryLevel = 1; if (!string.IsNullOrEmpty(platStore.SwitchConfig)) { switchModel = Newtonsoft.Json.JsonConvert.DeserializeObject <PlatStoreSwitchModel>(platStore.SwitchConfig); productCategoryLevel = switchModel.ProductCategoryLevel; } returnObj.dataObj = new { Level = productCategoryLevel }; returnObj.isok = true; returnObj.Msg = "获取成功"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 运费模板设置 /// </summary> /// <param name="model"></param> /// <param name="updateSet"></param> /// <returns></returns> public bool UpdateConfig(PlatStore model, Dictionary <string, object> updateSet) { if (model == null || updateSet == null || updateSet.Count == 0) { return(false); } PlatStoreSwitchModel config = string.IsNullOrWhiteSpace(model.SwitchConfig) ? new PlatStoreSwitchModel() : JsonConvert.DeserializeObject <PlatStoreSwitchModel>(model.SwitchConfig); try { config = SetConfigValue(updateSet, config); } catch (Exception ex) { log4net.LogHelper.WriteError(this.GetType(), ex); return(false); } model.SwitchConfig = JsonConvert.SerializeObject(config); return(Update(model, "SwitchConfig")); }
/// <summary> /// 企业智推版运费 /// </summary> /// <param name="goodcartids"></param> /// <param name="aid"></param> /// <param name="province"></param> /// <param name="city"></param> /// <param name="msg"></param> /// <returns></returns> public DeliveryFeeResult GetQiyeFee(string goodcartids, int aid, string province, string city, ref string msg) { DeliveryFeeResult deliueryResult = new DeliveryFeeResult(); //购物车 List <QiyeGoodsCart> cartList = QiyeGoodsCartBLL.SingleModel.GetListByIds(goodcartids); if (cartList == null || cartList.Count <= 0) { msg = "运费:购物车数据为空"; return(deliueryResult); } //商品 string goodsIds = string.Join(",", cartList.Select(s => s.GoodsId)); List <QiyeGoods> goodsList = QiyeGoodsBLL.SingleModel.GetListByIds(goodsIds); if (goodsList == null || goodsList.Count <= 0) { msg = "运费:找不到商品数据"; return(deliueryResult); } QiyeStore store = QiyeStoreBLL.SingleModel.GetModelByAId(aid); if (store == null) { msg = "运费:无效店铺"; return(deliueryResult); } DeliveryFeeSumMethond sumMethod; PlatStoreSwitchModel config = string.IsNullOrWhiteSpace(store.SwitchConfig) ? new PlatStoreSwitchModel() : JsonConvert.DeserializeObject <PlatStoreSwitchModel>(store.SwitchConfig); if (config.enableDeliveryTemplate) { if (!Enum.TryParse(config.deliveryFeeSumMethond.ToString(), out sumMethod)) { msg = "运费:无效运费模板"; return(deliueryResult); } List <DeliveryProduct> productInfo = new List <DeliveryProduct>(); foreach (QiyeGoods goodItem in goodsList) { List <QiyeGoodsCart> tempCartList = cartList.Where(w => w.GoodsId == goodItem.Id).ToList(); if (tempCartList == null || tempCartList.Count <= 0) { msg = "运费:无效购物车数据"; return(deliueryResult); } productInfo.Add(new DeliveryProduct { TemplateId = goodItem.TemplateId, Name = goodItem.Name, Count = tempCartList.Sum(s => s.Count), }); } deliueryResult = GetDeliveryFeeCommon(productInfo, province, city, sumMethod); if (deliueryResult == null) { msg = "运费:无效运费模板"; } else if (!deliueryResult.InRange) { msg = deliueryResult.Message; } } return(deliueryResult); }
public PlatStoreSwitchModel SetConfigValue(Dictionary <string, object> updateList, PlatStoreSwitchModel config) { Type configType = typeof(PlatStoreSwitchModel); foreach (var set in updateList) { object newValue = Convert.ChangeType(set.Value, configType.GetProperty(set.Key).PropertyType); configType.GetProperty(set.Key).SetValue(config, newValue, null); } return(config); }
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()); }
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 ? "修改成功" : "修改失败" })); }