第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

根據(jù)asp.net mvc5中多供應(yīng)商電子商務(wù)商店中的商店訂單限制計(jì)算購物車的商店折扣

根據(jù)asp.net mvc5中多供應(yīng)商電子商務(wù)商店中的商店訂單限制計(jì)算購物車的商店折扣

C#
九州編程 2023-09-24 16:16:34
我有一個多供應(yīng)商電子商務(wù)商店,每個商店經(jīng)理都可以管理商店訂單和商品的折扣。購物車模型如下:    namespace myapp.Models     public class Cart     {        [Key]        public int RecordId { get; set; }        public string CartId { get; set; }        public Guid ItemId { get; set; }        public Guid StoreId { get; set; }        public Decimal? ShopDiscount { get; set; }        public long ShopId { get; set; }        [Display(Name = "Discount Time")]        public string Duration { get; set; }        [StringLength(100, ErrorMessage = "Must be less than 100 characters")]        public string StoreName { get; set; }        public decimal? Giftback { get; set; }        [Display(Name = "Min order For Disc")]        public Decimal? OrderLimit { get; set; }        public int Count { get; set; }        public decimal? Discount { get; set; }        public System.DateTime DateCreated { get; set; }        public virtual Item Item { get; set; }      }    }我使用了帶有代碼優(yōu)先腳手架的實(shí)體框架。此外,在我的購物車模型類中,我使用了 shopdeal() 方法來計(jì)算商店級別折扣,但它始終返回 0 并且確實(shí)如此。我認(rèn)為這個方法有問題。    // shopdeal method to calculate shopdiscount for all items in cart      //             public decimal? ShopDeal()        {            decimal? shopdeal = 0;           //get record with different shops so that calculate shop total      //separatly            var results = db.Carts.Select(m => new { m.CartId, m.StoreId,     m.OrderLimit, m.ShopDiscount, m.Duration }).Distinct().ToList();              // calculate total price of all items for a particular shop              foreach (var item in results)            {                decimal? shoptotal = (from cartItems in db.Carts                                      where cartItems.CartId == ShoppingCartId                                      && cartItems.Item.StoreId ==     item.StoreId在上面的方法中,我們嘗試計(jì)算特定商店的所有商品的總價(jià),然后將 shoptotal 與該商店的 shopdiscount (orderlimit) 進(jìn)行比較,并檢查其時間段(是否開始),如果兩個條件都為 true,則為該商店應(yīng)用 shopdiscount。如果用戶從多個商店購買,則對所有商店應(yīng)用相同的條件(使用 foreach 循環(huán))。如果有解決方法可以獲取每個商店的總價(jià)格并應(yīng)用商店折扣并獲取總商店交易(總商店折扣),請幫忙。
查看完整描述

1 回答

?
慕斯王

TA貢獻(xiàn)1864條經(jīng)驗(yàn) 獲得超2個贊

謝謝大家,經(jīng)過大量努力,以下工作按預(yù)期為我工作

? ? public decimal? ShopDeal()

? ? ? ? {

? ? ? ? ? ? decimal? shopdeal = 0;


? ? ? ? ? ? var results = (from cartItems in db.Carts

? ? ? ? ? ? ? ? ? ? ? ? ? ?where cartItems.CartId == ShoppingCartId

? ? ? ? ? ? ? ? ? ? ? ? ? ?select new { cartItems.StoreId,cartItems.OrderLimit,cartItems.Duration,cartItems.ShopDiscount }).Distinct().ToList();

? ? ? ? ? ? ? ? //db.Carts.Select(m => new { m.StoreId, m.OrderLimit, m.ShopDiscount, m.Giftback, m.Duration }.where()).Distinct().ToList();



? ? ? ? ? ? foreach (var item in results)

? ? ? ? ? ? {

? ? ? ? ? ? ? ? decimal? shoptotal = (from cartItems in db.Carts

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? where cartItems.CartId == ShoppingCartId

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? && cartItems.Item.StoreId == item.StoreId

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? select (decimal?)cartItems.Item.Price).Sum();

? ? ? ? ? ? ? ? if (shoptotal >= item.OrderLimit && item.Duration == "Started")

? ? ? ? ? ? ? ? {

? ? ? ? ? ? ? ? ? ? shopdeal = shopdeal + shoptotal * item.ShopDiscount / 100;

? ? ? ? ? ? ? ? }


? ? ? ? ? ? }


? ? ? ? ? ? return shopdeal;

? ? ? ? }


regards?

fiaz ahmed ranjha


查看完整回答
反對 回復(fù) 2023-09-24
  • 1 回答
  • 0 關(guān)注
  • 116 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號