protected override XResp Execute() { if (limit > count) { throw new XExcep("0x0032"); } var ent = DB.x_goods.SingleOrDefault(o => o.goods_id == id); if (ent == null) { throw new XExcep("0x0020"); } if (ent.status != 2) { throw new XExcep("0x0033"); } if (ent.stock < count) { throw new XExcep("0x0034"); } if (ctime.CompareTo(etime) > 0) { throw new XExcep("0x0035"); } x_sale saleItem = DB.x_sale.SingleOrDefault(o => o.goods_id == id); if (saleItem == null) { saleItem = new x_sale(); } saleItem.goods_id = ent.goods_id; saleItem.city_id = mg.city; saleItem.limit = limit; saleItem.count = count; saleItem.price = price; saleItem.ctime = ctime; saleItem.etime = etime; if (saleItem.sale_id == 0) { DB.x_sale.InsertOnSubmit(saleItem); } SubmitDBChanges(); return(new XResp()); }
protected override void InitDict() { base.InitDict(); var gc = 0; sl = DB.x_sale.FirstOrDefault(o => o.sale_id == id); if (cu != null) { var g = cu.x_cart.FirstOrDefault(o => o.goods_id == sl.goods_id); if (g != null) { gc = g.count.Value; } dict.Add("tc", cu.x_cart.Sum(o => o.count.Value)); } else { dict.Add("tc", 0); } if (sl == null || sl.x_goods == null || sl.etime <= DateTime.Now || sl.count <= 0) { dict.Add("img", "/img/wx/uig.png"); if (sl == null) { dict.Add("msg", "秒杀记录不存在"); dict.Add("bt_txt", "返回首页"); dict.Add("bt_url", "/wx/index.html"); } else { dict.Add("msg", "秒杀活动已经结束"); dict.Add("bt_txt", "浏览此商品"); dict.Add("bt_url", "/wx/goods/detail-" + sl.goods_id + ".html"); } dict.Add("show_foot", 0); } else { dict.Add("g", sl.x_goods); dict.Add("sl", sl); dict.Add("pics", sl.x_goods.imgs.Split(',').ToList()); dict.Add("desc", Context.Server.HtmlDecode(sl.x_goods.desc)); dict.Add("gc", gc); } }
protected override XResp Execute() { if (limit > count) { throw new XExcep("T限购量超出促销量"); } x_goods ent = null; if (id > 0) { ent = DB.x_goods.SingleOrDefault(o => o.goods_id == id); if (ent == null) { throw new XExcep("0x0005"); } } if (ent == null) { throw new XExcep("T商品不存在,无法加入促销列表"); } if (ent.stock < count) { throw new XExcep("T内容错误,促销量超出库存"); } x_sale saleItem = null; saleItem = DB.x_sale.SingleOrDefault(o => o.goods_id == id); if (saleItem != null) { throw new XExcep("T此商品已存在,无法重复加入,请先删除再操作"); } if (ctime.CompareTo(etime) > 0) { throw new XExcep("T内容错误,开始时间晚于结束时间"); } //复制属性 saleItem = new x_sale(); saleItem.goods_id = ent.goods_id; saleItem.city_id = (int)ent.city;//????会不会有问题 saleItem.limit = limit; saleItem.count = count; saleItem.price = price; saleItem.ctime = ctime; saleItem.etime = etime; //if (ent.goods_id == 0) ent.status = 2; if (saleItem.sale_id == 0) //????? { DB.x_sale.InsertOnSubmit(saleItem); SubmitDBChanges(); } SubmitDBChanges(); return(new XResp()); }