//ADD:Vip public async Task <JsonResult> AddVip(string levelname, double?discount, string discountname) { if (levelname != null && discount != null && discountname != null) { var vip = new VipLevel { Name = levelname, }; db.VipLevels.Add(vip); await db.SaveChangesAsync(); db.VipDiscounts.Add(new VipDiscount { Id = vip.Id, Discount = discount.Value / 100, Name = discountname }); await db.SaveChangesAsync(); return(Json(new { succeeded = true })); } else { return(Json(new { succeeded = false })); } }
/// <summary> /// 绘制会员修改 /// </summary> void DrawVIP() { GUILayout.BeginHorizontal(); VipLevelActive = DrawToggle(VipLevelActive, "VIP"); string vipstr = GUILayout.TextField(VipLevel.ToString(), 2); try { VipLevel = int.Parse(vipstr); } catch { } VipLevel = Mathf.Clamp(VipLevel, 0, 12); if (VipLevelActive) { if (MainGameController.RunningGame != null) { if (MainGameController.RunningGame.playerInfo != null) { MainGameController.RunningGame.playerInfo.progressionLevel = VipLevel + 1; } } } GUILayout.EndHorizontal(); }
public override int GetHashCode() { int hash = 1; if (Uid != 0UL) { hash ^= Uid.GetHashCode(); } if (Recharge != 0) { hash ^= Recharge.GetHashCode(); } if (Diamonds != 0) { hash ^= Diamonds.GetHashCode(); } if (VipLevel != 0) { hash ^= VipLevel.GetHashCode(); } if (Username.Length != 0) { hash ^= Username.GetHashCode(); } return(hash); }
public PayContentPayment GetVipDiscountByUserId(PayContent content, int userId) { //会员等级信息 VipRelation vipInfo = VipRelationBLL.SingleModel.GetModel($"uid={userId} and state>=0"); VipLevel levelInfo = levelInfo = vipInfo != null?VipLevelBLL.SingleModel.GetModel($"id={vipInfo.levelid} and state>=0") : null; return(GetVipDiscount(content, levelInfo)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(VipLevel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Shop_VipLevel set "); strSql.Append("VipLevel=@VipLevel,"); strSql.Append("Score=@Score,"); strSql.Append("LevelRemark=@LevelRemark,"); strSql.Append("Discount=@Discount,"); strSql.Append("Status=@Status,"); strSql.Append("CreateBy=@CreateBy,"); strSql.Append("CreateDate=@CreateDate,"); strSql.Append("UpdateBy=@UpdateBy,"); strSql.Append("UpdateDate=@UpdateDate"); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@VipLevel", SqlDbType.Int, 4), new SqlParameter("@Score", SqlDbType.Int, 4), new SqlParameter("@LevelRemark", SqlDbType.Text), new SqlParameter("@Discount", SqlDbType.Float, 8), new SqlParameter("@Status", SqlDbType.VarChar, 20), new SqlParameter("@CreateBy", SqlDbType.UniqueIdentifier, 16), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@UpdateBy", SqlDbType.UniqueIdentifier, 16), new SqlParameter("@UpdateDate", SqlDbType.DateTime), new SqlParameter("@Id", SqlDbType.UniqueIdentifier, 16) }; parameters[0].Value = model.LevelNumber; parameters[1].Value = model.Score; parameters[2].Value = model.LevelRemark; parameters[3].Value = model.Discount; parameters[4].Value = model.Status; parameters[5].Value = model.CreateBy; parameters[6].Value = model.CreateDate; parameters[7].Value = model.UpdateBy; parameters[8].Value = model.UpdateDate; parameters[9].Value = model.Id; int rows = _db.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public void Cannot_change_vip_level_with_invalid_brand() { // Arrange var player = CreateNewPlayer(); var vipLevel = new VipLevel() { BrandId = player.BrandId }; LogWithNewAdmin(Modules.PlayerManager, Permissions.AssignVipLevel); // Act Assert.Throws <InsufficientPermissionsException>(() => _playerCommands.ChangeVipLevel(player.Id, vipLevel.Id, "Some remark")); }
/// <summary> /// 得到一个对象实体 /// </summary> public VipLevel DataRowToModel(DataRow row) { VipLevel model = new VipLevel(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = new Guid(row["Id"].ToString()); } if (row["LevelNumber"] != null && row["LevelNumber"].ToString() != "") { model.LevelNumber = int.Parse(row["LevelNumber"].ToString()); } if (row["Score"] != null && row["Score"].ToString() != "") { model.Score = int.Parse(row["Score"].ToString()); } if (row["LevelRemark"] != null) { model.LevelRemark = row["LevelRemark"].ToString(); } if (row["Discount"] != null && row["Discount"].ToString() != "") { model.Discount = decimal.Parse(row["Discount"].ToString()); } if (row["Status"] != null) { model.Status = row["Status"].ToString(); } if (row["CreateBy"] != null && row["CreateBy"].ToString() != "") { model.CreateBy = new Guid(row["CreateBy"].ToString()); } if (row["CreateDate"] != null && row["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(row["CreateDate"].ToString()); } if (row["UpdateBy"] != null && row["UpdateBy"].ToString() != "") { model.UpdateBy = new Guid(row["UpdateBy"].ToString()); } if (row["UpdateDate"] != null && row["UpdateDate"].ToString() != "") { model.UpdateDate = DateTime.Parse(row["UpdateDate"].ToString()); } } return(model); }
//} //DEL:Vip public async Task <JsonResult> DelVip(int id) { VipLevel viplevels = await db.VipLevels.FirstOrDefaultAsync(p => p.Id == id); if (viplevels == null) { return(Json(new { succeeded = false })); } else { db.VipLevels.Remove(viplevels); await db.SaveChangesAsync(); return(Json(new { succeeded = true })); } }
//ALT:Vip public async Task <JsonResult> AltVip(int id, string levelname, double discount, string discountname) { VipLevel viplevels = await db.VipLevels.Include(p => p.VipDiscount).FirstOrDefaultAsync(p => p.Id == id); if (viplevels == null) { return(Json(new { succeeded = false })); } else { viplevels.Name = levelname; viplevels.VipDiscount.Discount = discount / 100; viplevels.VipDiscount.Name = discountname; await db.SaveChangesAsync(); return(Json(new { succeeded = true })); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(VipLevel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Shop_VipLevel("); strSql.Append("Id,VipLevel,Score,LevelRemark,Discount,Status,CreateBy,CreateDate,UpdateBy,UpdateDate)"); strSql.Append(" values ("); strSql.Append("@Id,@VipLevel,@Score,@LevelRemark,@Discount,@Status,@CreateBy,@CreateDate,@UpdateBy,@UpdateDate)"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.UniqueIdentifier, 16), new SqlParameter("@VipLevel", SqlDbType.Int, 4), new SqlParameter("@Score", SqlDbType.Int, 4), new SqlParameter("@LevelRemark", SqlDbType.Text), new SqlParameter("@Discount", SqlDbType.Float, 8), new SqlParameter("@Status", SqlDbType.VarChar, 20), new SqlParameter("@CreateBy", SqlDbType.UniqueIdentifier, 16), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@UpdateBy", SqlDbType.UniqueIdentifier, 16), new SqlParameter("@UpdateDate", SqlDbType.DateTime) }; parameters[0].Value = Guid.NewGuid(); parameters[1].Value = model.LevelNumber; parameters[2].Value = model.Score; parameters[3].Value = model.LevelRemark; parameters[4].Value = model.Discount; parameters[5].Value = model.Status; parameters[6].Value = Guid.NewGuid(); parameters[7].Value = model.CreateDate; parameters[8].Value = Guid.NewGuid(); parameters[9].Value = model.UpdateDate; int rows = _db.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public override void BeforeAll() { base.BeforeAll(); //create a not default VIP Level for Brand _vipLevel = _container.Resolve <BrandTestHelper>().CreateNotDefaultVipLevel(DefaultBrandId); //generate risk profile check configuration form data _riskProfileCheckData = TestDataGenerator.CreateRiskProfileCheckConfigurationData( DefaultLicensee, DefaultBrand, DefaultCurrency, _vipLevel.Name ); _dashboardPage = _driver.LoginToAdminWebsiteAsSuperAdmin(); _riskProfileCheckConfigurationPage = _dashboardPage.Menu.ClickRiskProfileCheckConfiguration(); _newRPCForm = _riskProfileCheckConfigurationPage.OpenNewRiskProfileCheckConfigurationForm(); _newRPCForm.SetRiskProfileCheckConfigurationFields(_riskProfileCheckData); _newRPCForm.SubmitRiskProfileCheckConfiguration().CloseTab("View Risk Profile Check Configuration"); }
public PayContentPayment GetVipDiscount(PayContent content, VipLevel userLevel) { List <int> vipFreeList = content.Exclusive.ConvertToIntList(','); PayContentPayment payInfo = new PayContentPayment { OrgAmount = content.Amount }; if (userLevel != null && vipFreeList != null && vipFreeList.Contains(userLevel.Id)) { int free = 0; payInfo.PayAmount = free; payInfo.DiscountAmount = content.Amount; payInfo.Info = $"用户为[{userLevel.name}]免费购买付费内容"; } else { payInfo.PayAmount = content.Amount; payInfo.Info = "无优惠"; } return(payInfo); }
public void Consume(VipLevelRegistered @event) { using (var scope = CustomTransactionScope.GetTransactionScope()) { var vipLevel = new VipLevel { Id = @event.Id, BrandId = @event.BrandId, Code = @event.Code, Name = @event.Name, Rank = @event.Rank, Description = @event.Description, ColorCode = @event.ColorCode, Status = @event.Status }; _playerRepository.VipLevels.Add(vipLevel); _playerRepository.SaveChanges(); scope.Complete(); } }
/// <summary> /// 得到一个对象实体 /// </summary> public VipLevel GetModel(Guid Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,VipLevel,Score,LevelRemark,Discount,Status,CreateBy,CreateDate,UpdateBy,UpdateDate from Shop_VipLevel "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.UniqueIdentifier, 16) }; parameters[0].Value = Id; VipLevel model = new VipLevel(); DataSet ds = _db.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 优惠金额处理 /// </summary> /// <param name="couponLogId">用户领取优惠券id</param> /// <param name="cartList">购物车</param> /// <param name="userId">用户ID</param> /// <param name="beforeDiscountPrice">优惠前商品总价</param> /// <param name="afterDiscountPrice">优惠后商品总价</param> /// <param name="vipDiscountPrice">会员优惠价</param> /// <param name="couponPrice">优惠券优惠价格</param> public void DiscountPrice(int couponLogId, ref List <QiyeGoodsCart> cartList, int userId, ref int beforeDiscountPrice, ref int afterDiscountPrice, ref int vipDiscountPrice, ref int couponPrice, ref string msg) { beforeDiscountPrice = cartList.Sum(x => x.Price * x.Count); #region 会员打折 cartList.ForEach(g => g.OriginalPrice = g.Price); //获取会员信息 VipRelation vipInfo = VipRelationBLL.SingleModel.GetModelByUserid(userId); VipLevel levelInfo = vipInfo != null?VipLevelBLL.SingleModel.GetModel(vipInfo.levelid) : null; VipLevelBLL.SingleModel.GetVipDiscount(ref cartList, vipInfo, levelInfo, userId, "Discount", "Price"); #endregion 会员打折 //折后总价 afterDiscountPrice = cartList.Sum(x => x.Price * x.Count); //会员优惠金额 vipDiscountPrice = beforeDiscountPrice - afterDiscountPrice; //优惠金额 couponPrice = CouponLogBLL.SingleModel.GetCouponPrice <QiyeGoodsCart>(couponLogId, cartList, "GoodsId", "Price", "Count", ref msg); afterDiscountPrice = afterDiscountPrice - couponPrice; afterDiscountPrice = afterDiscountPrice < 0 ? 0 : afterDiscountPrice; }
/// <summary> /// 获取单个会员的详细信息 /// </summary> /// <param name="uid"></param> /// <param name="appid"></param> /// <param name="PageType">模板对应例如PageType=22 表示专业版 PageType=6表示电商版</param> /// <returns></returns> public VipRelation GetVipModel(int uid, string appid, int PageType = 6, int aid = 0) { VipRelation vipRelation = GetModel($"uid={uid} and appid='{appid}' and state>=0"); if (vipRelation == null) { VipLevel def_level = null; int pricesum = 0; switch (PageType) { case (int)TmpType.小程序多门店模板: case (int)TmpType.小程序足浴模板: case (int)TmpType.小程序专业模板: pricesum = GetEntGoodsVipPriceSum(uid); break; case (int)TmpType.小程序电商模板: pricesum = GetVipConsumptionrecord(uid); break; case (int)TmpType.小程序餐饮模板: pricesum = GetFoodVipPriceSum(uid); break; case (int)TmpType.小未平台子模版: pricesum = GetPlatChildGoodsVipPriceSum(uid); break; } if (pricesum <= 0) { def_level = VipLevelBLL.SingleModel.GetDefModel(appid, PageType); } else { VipRule rule = VipRuleBLL.SingleModel.GetModel($"minMoney<={pricesum} and maxMoney>{pricesum} and state>=0 and RuleType=0"); if (rule == null) { rule = VipRuleBLL.SingleModel.GetList($"appid='{appid}' and state>=0 and RuleType=0", 11, 1, "*", "minMoney desc")?.FirstOrDefault();//取最高级别规则 } def_level = VipLevelBLL.SingleModel.GetModel(rule.levelid); } vipRelation = new VipRelation(); vipRelation.appId = appid; vipRelation.addtime = vipRelation.updatetime = DateTime.Now; vipRelation.uid = uid; vipRelation.levelid = def_level.Id; vipRelation.PriceSum = pricesum; vipRelation.Id = Convert.ToInt32(Add(vipRelation)); if (vipRelation.Id <= 0) { log4net.LogHelper.WriteInfo(this.GetType(), $"用户注册会员失败 uid" + uid); } vipRelation.levelInfo = def_level; } else { vipRelation.levelInfo = VipLevelBLL.SingleModel.GetModel($"id={vipRelation.levelid} and state>=0"); if (vipRelation.levelInfo != null) { if (vipRelation.levelInfo.type == 2 && !string.IsNullOrEmpty(vipRelation.levelInfo.gids)) { switch (PageType) { case (int)TmpType.小程序多门店模板: case (int)TmpType.小程序足浴模板: case (int)TmpType.小程序专业模板: vipRelation.levelInfo.entGoodsList = EntGoodsBLL.SingleModel.GetList($"id in ({vipRelation.levelInfo.gids}) and state=1 and tag = 1 "); break; case (int)TmpType.小程序电商模板: vipRelation.levelInfo.goodslist = StoreGoodsBLL.SingleModel.GetList($"id in ({vipRelation.levelInfo.gids}) and state>=0"); break; case (int)TmpType.小程序餐饮模板: vipRelation.levelInfo.foodgoodslist = FoodGoodsBLL.SingleModel.GetList($"id in ({vipRelation.levelInfo.gids}) and IsSell=1 and state=1"); break; case (int)TmpType.小未平台子模版: vipRelation.levelInfo.PlatChildGoodsList = PlatChildGoodsBLL.SingleModel.GetListByIds(vipRelation.levelInfo.gids); break; } } } //专业版对接预约功能 if (PageType == (int)TmpType.小程序专业模板) { vipRelation.reservation = FoodReservationBLL.SingleModel.GetOnGoingReservation(aid, uid)?.Id.ToString(); } } return(vipRelation); }
public ActionResult GetGoodInfo() { int pid = Context.GetRequestInt("pid", 0); int userId = Context.GetRequestInt("userId", 0); returnObj = new Return_Msg_APP(); returnObj.code = "200"; if (pid == 0) { returnObj.Msg = "请选择产品"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } PlatChildGoods goodModel = PlatChildGoodsBLL.SingleModel.GetModel(pid); if (goodModel == null || goodModel.State == 0) { returnObj.Msg = "产品不存在或已删除"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } PlatStore platStore = PlatStoreBLL.SingleModel.GetModelByAId(goodModel.AId); if (platStore == null) { returnObj.Msg = "店铺不存在"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); } if (!string.IsNullOrEmpty(goodModel.Plabels)) { //goodModel.plabelstr = DAL.Base.SqlMySql.ExecuteScalar(Utility.dbEnum.MINIAPP.ToString(), CommandType.Text, $"SELECT group_concat(name order by sort desc) from entgoodlabel where id in ({goodModel.plabels})").ToString(); goodModel.PlabelStr = PlatChildGoodsLabelBLL.SingleModel.GetEntGoodsLabelStr(goodModel.Plabels); goodModel.PlabelStr_Arry = goodModel.PlabelStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } #region 会员折扣显示 //获取会员信息 VipRelation vipInfo = VipRelationBLL.SingleModel.GetModelByUserid(userId); VipLevel levelinfo = vipInfo != null?VipLevelBLL.SingleModel.GetModel(vipInfo.levelid) : null; List <PlatChildGoods> list = new List <PlatChildGoods>(); list.Add(goodModel); // _miniappVipLevelBll.GetVipDiscount(ref list, vipInfo, levelinfo, userId, "Discount", "Price"); goodModel = list.FirstOrDefault(); #endregion 会员折扣显示 //#region 会员打折 List <PlatChildGoodsCart> carlist = new List <PlatChildGoodsCart>() { new PlatChildGoodsCart() { GoodsId = goodModel.Id } }; carlist.ForEach(g => g.OriginalPrice = g.Price); VipLevelBLL.SingleModel.GetVipDiscount(ref carlist, vipInfo, levelinfo, userId, "Discount", "Price"); goodModel.Discount = carlist[0].Discount; //#endregion 会员打折 if (!string.IsNullOrEmpty(goodModel.Img)) { goodModel.Img = goodModel.Img.Replace("http://vzan-img.oss-cn-hangzhou.aliyuncs.com", "https://i.vzan.cc/"); } List <GoodsSpecDetail> listGoodsSpecDetail = Newtonsoft.Json.JsonConvert.DeserializeObject <List <GoodsSpecDetail> >(goodModel.SpecDetail); listGoodsSpecDetail.ForEach(x => { if (x.Discount == 100) { x.DiscountPrice = x.Price; } }); goodModel.SpecDetail = JsonConvert.SerializeObject(listGoodsSpecDetail); goodModel.storeModel = new StoreModel() { StoreId = platStore.Id, Name = platStore.Name, Img = platStore.StoreHeaderImg, Loction = platStore.Location, Lng = platStore.Lng, Lat = platStore.Lat }; PlatMyCard platMyCard = PlatMyCardBLL.SingleModel.GetModel(platStore.MyCardId); if (platMyCard != null) { goodModel.storeOwner = new StoreOwner() { UserId = platMyCard.UserId, Name = platMyCard.Name, Avatar = platMyCard.ImgUrl }; PlatUserCash userCash = PlatUserCashBLL.SingleModel.GetModelByUserId(platMyCard.AId, platMyCard.UserId); if (userCash != null) { goodModel.storeOwner.IsOpenDistribution = userCash.IsOpenDistribution; } } returnObj.isok = true; returnObj.dataObj = goodModel; returnObj.Msg = "获取成功"; return(Json(returnObj, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 产品列表 /// </summary> /// <param name="appid"></param> /// <param name="typeid"></param> /// <param name="pageindex"></param> /// <param name="pagesize"></param> /// <returns></returns> public ActionResult GetGoodsList(int aid, string typeid = "", int pageindex = 1, int pagesize = 10, int userId = 0, int isFirstType = -1) { returnObj = new Return_Msg_APP(); returnObj.code = "200"; string goodsName = Context.GetRequest("goodsName", ""); string priceSort = Context.GetRequest("pricesort", ""); string entGoodTypeIds = string.Empty; if (!string.IsNullOrEmpty(typeid)) { typeid = EncodeHelper.ReplaceSqlKey(typeid); typeid = Server.UrlDecode(typeid); } List <PlatChildGoods> goodslist = PlatChildGoodsBLL.SingleModel.GetListGoods(aid, goodsName, typeid, priceSort, pagesize, pageindex, isFirstType); //log4net.LogHelper.WriteInfo(this.GetType(), JsonConvert.SerializeObject(goodslist)); if (goodslist != null) { goodslist.ForEach((Action <PlatChildGoods>)(goodModel => { if (!string.IsNullOrEmpty(goodModel.Categorys)) { goodModel.CategorysStr = PlatChildGoodsCategoryBLL.SingleModel.GetPlatChildGoodsCategoryName(goodModel.Categorys); } if (!string.IsNullOrEmpty(goodModel.Plabels)) { goodModel.PlabelStr = PlatChildGoodsLabelBLL.SingleModel.GetGoodsLabel(goodModel.Plabels); goodModel.PlabelStr_Arry = goodModel.PlabelStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } List <GoodsSpecDetail> listGoodsSpecDetail = Newtonsoft.Json.JsonConvert.DeserializeObject <List <GoodsSpecDetail> >(goodModel.SpecDetail); if (listGoodsSpecDetail != null) { listGoodsSpecDetail.ForEach(x => { if (x.Discount == 100) { x.DiscountPrice = x.Price; } }); goodModel.SpecDetail = JsonConvert.SerializeObject(listGoodsSpecDetail); } })); //获取会员信息 VipRelation vipInfo = VipRelationBLL.SingleModel.GetModelByUserid(userId); VipLevel levelinfo = vipInfo != null?VipLevelBLL.SingleModel.GetModel(vipInfo.levelid) : null; //#region 会员打折 VipLevelBLL.SingleModel.GetVipDiscount(ref goodslist, vipInfo, levelinfo, userId, "Discount", "Price"); } var postdata = new { goodslist = goodslist.Select(g => new { Id = g.Id, Img = g.Img, Name = g.Name, Plabelstr_array = g.PlabelStr_Arry, PriceFen = g.PriceFen, DiscountPricestr = g.DiscountPricestr, Discount = g.Discount, Unit = g.Unit, VirtualSalesCount = g.VirtualSalesCount, SalesCount = g.SalesCount, Price = g.Price }), }; returnObj.isok = true; returnObj.dataObj = postdata; return(Json(returnObj, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 查询购物车 /// </summary> /// <param name="appid"></param> /// <param name="openid"></param> /// <param name="pageindex"></param> /// <param name="pagesize"></param> /// <returns></returns> public ActionResult GetGoodsCarList() { returnObj = new Return_Msg_APP(); int pageSize = Context.GetRequestInt("pageSize", 6); int pageIndex = Context.GetRequestInt("pageIndex", 1); int userId = Context.GetRequestInt("userid", 0); try { C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(userId); if (userInfo == null) { returnObj.Msg = "用户不存在"; return(Json(returnObj)); } XcxAppAccountRelation xcxrelation = _xcxAppAccountRelationBLL.GetModelByAppid(userInfo.appId); if (xcxrelation == null) { returnObj.Msg = "未绑定小程序或模板已过期"; return(Json(returnObj)); } List <PlatChildGoodsCart> carList = PlatChildGoodsCartBLL.SingleModel.GetListByUserId(xcxrelation.Id, userInfo.Id, pageSize, pageIndex); if (carList == null || carList.Count <= 0) { returnObj.Msg = "购物车为空"; return(Json(returnObj)); } //获取会员信息 VipRelation vipInfo = VipRelationBLL.SingleModel.GetModelByUserid(userInfo.Id); VipLevel levelInfo = vipInfo != null?VipLevelBLL.SingleModel.GetModel(vipInfo.levelid) : null; //#region 会员打折 carList.ForEach(g => g.OriginalPrice = g.Price); VipLevelBLL.SingleModel.GetVipDiscount(ref carList, vipInfo, levelInfo, userInfo.Id, "Discount", "Price"); //#endregion 会员打折 //获取商品详细资料 List <PlatChildGoods> goods = new List <PlatChildGoods>(); goods = PlatChildGoodsBLL.SingleModel.GetList($" Id in ({string.Join(",", carList.Select(x => x.GoodsId))}) "); if (goods == null || goods.Count <= 0) { returnObj.Msg = "商品已过期"; returnObj.dataObj = carList; return(Json(returnObj)); } PlatChildGoods curGood = new PlatChildGoods(); carList.ForEach(c => { curGood = goods.FirstOrDefault(g => g.Id == c.GoodsId); if (curGood != null && curGood.Id > 0) { //多规格处理 if (curGood.GASDetailList != null && curGood.GASDetailList.Count > 0) { List <GoodsSpecDetail> detaillist = curGood.GASDetailList.ToList(); detaillist?.ForEach(g => { g.OriginalPrice = g.Price; g.Discount = c.Discount; float discountPrice = g.Price * (c.Discount * 0.01F); g.DiscountPrice = discountPrice < 0.01 ? 0.01F : discountPrice; }); curGood.SpecDetail = JsonConvert.SerializeObject(detaillist); } curGood.Description = string.Empty; c.GoodsInfo = curGood; } }); returnObj.dataObj = new { carlist = carList, count = carList.Sum(s => s.Count) }; returnObj.isok = true; return(Json(returnObj)); } catch (Exception ex) { returnObj.dataObj = ex; return(Json(returnObj)); } }
public ActionResult GetCoupon() { string appId = Context.GetRequest("appId", string.Empty); int couponId = Context.GetRequestInt("couponId", 0); int userId = Context.GetRequestInt("userId", 0); if (couponId <= 0) { return(Json(new { isok = false, msg = "优惠券ID不能小于0" }, JsonRequestBehavior.AllowGet)); } if (userId <= 0) { return(Json(new { isok = false, msg = "用户ID不能小于0" }, JsonRequestBehavior.AllowGet)); } C_UserInfo usermodel = C_UserInfoBLL.SingleModel.GetModel(userId); if (usermodel == null) { return(Json(new { isok = false, msg = "找不到用户" }, JsonRequestBehavior.AllowGet)); } XcxAppAccountRelation xcxrelation = _xcxAppAccountRelationBLL.GetModelByAppid(appId); if (xcxrelation == null) { return(Json(new { isok = false, msg = "未找到小程序授权资料" }, JsonRequestBehavior.AllowGet)); } string userids = ""; string aids = ""; string errMsg = string.Empty; //店铺ID int storeId = _xcxAppAccountRelationBLL.ReturnStoreIdByAId(xcxrelation.Id, ref errMsg, ref aids, ref userids); if (!string.IsNullOrWhiteSpace(errMsg)) { return(Json(new { isok = false, errMsg }, JsonRequestBehavior.AllowGet)); } lock (lockgetcoupon) { string nowtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); Coupons couponmodel = CouponsBLL.SingleModel.GetValidModel(couponId, nowtime); if (couponmodel == null) { return(Json(new { isok = false, msg = "找不到优惠券!" }, JsonRequestBehavior.AllowGet)); } int couponlogcount = CouponLogBLL.SingleModel.GetCountByCouponId(couponId); if (couponlogcount >= couponmodel.CreateNum) { return(Json(new { isok = false, msg = "您下手太慢了,优惠券被抢光了!" }, JsonRequestBehavior.AllowGet)); } //判断用户领取是否超过限制 if (couponmodel.LimitReceive > 0) { int usercouponlogcount = CouponLogBLL.SingleModel.GetCountByCouponIdAndUserId(couponId, userId); if (usercouponlogcount >= couponmodel.LimitReceive) { return(Json(new { isok = false, msg = "您已领取过了,快去使用!" }, JsonRequestBehavior.AllowGet)); } } //判断有会员等级限制 if (couponmodel.VipLevel > 0) { VipRelation viprelationmodel = VipRelationBLL.SingleModel.GetModelByRidAndUid(xcxrelation.AppId, userId); if (viprelationmodel != null) { VipLevel viplevel = VipLevelBLL.SingleModel.GetModel(viprelationmodel.levelid); if (viplevel == null || viplevel.level < couponmodel.VipLevel) { return(Json(new { isok = false, msg = "您的会员等级不够,无法领取优惠券!" }, JsonRequestBehavior.AllowGet)); } } } CouponLog couponlog = new CouponLog(); couponlog.AddTime = DateTime.Now; couponlog.CouponId = couponmodel.Id; if (couponmodel.ValType == 0) { //指定优惠券固定时间 couponlog.StartUseTime = couponmodel.StartUseTime; couponlog.EndUseTime = couponmodel.EndUseTime; } else { //领券时间 string getcouptime = DateTime.Now.ToShortDateString(); //1:领到券次日开始N天内有效,2:领到券当日开始N天内有效 couponlog.StartUseTime = DateTime.Parse(getcouptime + " 00:00:00").AddDays(couponmodel.ValType == 1 ? 1 : 0); couponlog.EndUseTime = DateTime.Parse(getcouptime + " 23:59:59").AddDays(couponmodel.ValDay + (couponmodel.ValType == 1 ? 0 : -1)); } couponlog.CouponName = couponmodel.CouponName; couponlog.UserId = userId; couponlog.Id = Convert.ToInt32(CouponLogBLL.SingleModel.Add(couponlog)); return(Json(new { isok = couponlog.Id > 0, msg = couponlog.Id > 0 ? "领取成功" : "领取失败" }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(VipLevel model) { return(VipLevelDAL.instance.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(VipLevel model) { return(VipLevelDAL.instance.Add(model)); }