public StoreConfigModel GetStoreConfig(int aid) { Store store = GetModelByAId(aid); StoreConfigModel config = null; if (!string.IsNullOrWhiteSpace(store.configJson)) { try { config = JsonConvert.DeserializeObject <StoreConfigModel>(store.configJson); } catch { } } return(config ?? new StoreConfigModel()); }
public bool UpdateConfig(Store model, Dictionary <string, object> updateSet) { if (model == null || updateSet == null || updateSet.Count == 0) { return(false); } StoreConfigModel config = string.IsNullOrWhiteSpace(model.configJson) ? new StoreConfigModel() : JsonConvert.DeserializeObject <StoreConfigModel>(model.configJson); try { config = SetConfigValue(updateSet, config); } catch (Exception ex) { log4net.LogHelper.WriteError(this.GetType(), ex); return(false); } model.configJson = JsonConvert.SerializeObject(config); return(Update(model, "configJson")); }
/// <summary> /// /// </summary> /// <param name="config"></param> /// <param name="cartIds"></param> /// <returns>"运费|优惠信息|是否在配送范围"</returns> public FreightInfo GetFreightFee(StoreConfigModel config, string cartIds, string province, string city) { FreightInfo info = null; //返回统一运费 if (config.FreightPriceSwitch) { info = new FreightInfo { Fee = config.FreightPrice, Msg = "无优惠", IsVaild = true }; return(info); } //获取模板(未启用模板时,返回默认官方模板) EntFreightTemplate template = config.FreightTemplateId <= 0 ? GetDefaultTemplate() : GetModel(config.FreightTemplateId); //送货地址是否在商家配送范围(默认模板:全国配送) bool isInDeliveryArea = CheckDeliveryArea(template: template, province: province, city: city); if (!isInDeliveryArea) { info = new FreightInfo { Fee = 0, Msg = "送货地址超出配送范围", IsVaild = false }; return(info); } //获取购物车商品 var shopingItem = EntGoodsCartBLL.SingleModel.GetMyCartById(cartIds.Trim(',')); if (shopingItem?.Count <= 0) { info = new FreightInfo { Fee = 0, Msg = "无效商品", IsVaild = false }; return(info); } //获取运费 return(GetFreightFeeByTemplate(template, shopingItem)); }
public StoreConfigModel SetConfigValue(Dictionary <string, object> updateList, StoreConfigModel config) { Type configType = typeof(StoreConfigModel); 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 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 ? "修改成功" : "修改失败" })); }