public BusinessResultDto ExchangeOrder(ExchangeOrderDto orderdto) { try { using (var db = base.NewDB()) { var order = new OrderInfo { Consignee = orderdto.consignee, AddressDetail = orderdto.addressdetail, AddressRegion = orderdto.addressregion, Telephone = orderdto.telephone, UserNote = orderdto.usernote, TotalPoints = orderdto.quantity * orderdto.points, OrderCommoditys = new List <OrderCommodity> { new OrderCommodity { Commodity = db.Commoditys.FirstOrDefault(t => t.CommodityUID == orderdto.commodityuid), Quantity = orderdto.quantity, Points = orderdto.points, TotalPoints = orderdto.quantity * orderdto.points, CommodityAttrsStr = orderdto.GetCommodityAttrsStr() } }, //UserIntegral = db.UserIntegrals.First(t => t.IntegralID == orderdto.integralid), UserIntegral = db.Users.FirstOrDefault(t => t.AuthID == orderdto.authid).UserIntegral }; var bus = new StoreBus(db); var res = bus.SaveExchangeOrder(order); if (res.issave) { db.SaveChanges(); } return(res); } } catch (Exception) { throw; } }
public CommodityDetailDto GetCommodity(Guid uid, Guid authid) { using (var db = base.NewDB()) { var dbitem = db.Commoditys.FirstOrDefault(t => t.IsValid == true && t.CommodityUID == uid); if (dbitem == null) { return(null); } var res = new CommodityDetailDto { id = dbitem.ID, commodityuid = dbitem.CommodityUID, name = dbitem.Name, pic = Function.GetStaticPicUrl(dbitem.Pic), points = dbitem.Points, description = dbitem.Description, //details = dbitem.Details, code = dbitem.Code, memo = dbitem.Memo, price = dbitem.Price, isvalid = dbitem.IsValid, stock = dbitem.Stock, isreal = dbitem.IsReal ?? true, detailAttrs = GetAttrs(dbitem.Details), articleid = dbitem.ArticleID }; string msglimit = string.Empty; var bus = new StoreBus(db); res.stock = bus.CheckStock(res.stock, dbitem, authid, out msglimit); res.msglimit = msglimit; return(res); } }