Example #1
0
        static void Main(string[] args)
        {
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                try
                {
                    PurchaseClient PurchaseClientObject = new PurchaseClient();
                    decimal        dTotalBillAmt        = PurchaseClientObject.PurchaseToys(11);
                    CardTransactionServiceClient CardTransClientObject = new CardTransactionServiceClient();
                    TransactionInformation       info = Transaction.Current.TransactionInformation;
                    Console.WriteLine("Local Identifier" + info.LocalIdentifier);
                    CardTransClientObject.IsEligibletoBuy(dTotalBillAmt);


                    //if (!CardTransClientObject.IsEligibletoBuy(dTotalBillAmt))
                    //{
                    //    throw new Exception("Sorry!! Bill value exceeded your Account Balance");
                    //}
                    //   CardTransClientObject.DebitTheAmountFromAccount(0608, 1000);
                    //PurchaseClientObject.UpdateStock(2);
                    ts.Complete();
                    Console.ReadLine();
                }
                catch (Exception ex)
                {
                    ts.Dispose();
                    Console.ReadLine();
                    //PurchaseClientObject.UpdateStock(2);
                }
            }
        }
Example #2
0
        public static IEnumerable <CarPriceManagementResponse> SelectPurchaseInfoByPID(List <string> pids)
        {
            IEnumerable <CarPriceManagementResponse> result = new List <CarPriceManagementResponse>();

            try
            {
                if (pids != null && pids.Any())
                {
                    List <CarPriceManagementRequest> pidList = new List <CarPriceManagementRequest>();
                    pids.ForEach(x => pidList.Add(new CarPriceManagementRequest()
                    {
                        PID = x
                    }));
                    using (var client = new PurchaseClient())
                    {
                        var getResult = client.SelectPurchaseInfoByPID(pidList);
                        getResult.ThrowIfException(true);
                        result = getResult.Result;
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
            return(result);
        }
Example #3
0
        public ActionResult Purchase()
        {
            if (AuthorizeUser())
            {
                int            idUser = Convert.ToInt32(Session["UserId"]);
                PurchaseClient PC     = new PurchaseClient();
                ViewBag.purchase = PC.GetPurchase(idUser);

                return(View());
            }
            return(Redirect("/Account/Login"));
        }
Example #4
0
        /// <summary>
        /// 查询商品相关信息(库存,活动价格,商品基本信息)
        /// </summary>
        /// <param name="pids"></param>
        /// <param name="conn"></param>
        /// <returns></returns>
        static async Task <List <CarProductPriceModel> > FullStockData(List <string> pids, SqlConnection conn, IDBScopeManager mana)
        {
            var list = await DalCarProductPrice.GetProductBaseInfoByCatalog(conn, pids);

            if (list == null || list.Count < 1)
            {
                return(list);
            }

            //活动价格 activityType:1.天天秒杀 4.限时抢购
            var activityPrices = await DalCarProductPrice.GetActivityPricesByPids(conn, pids, DateTime.Now);

            //拼团价格
            var pintuanPirces = await DalCarProductPrice.GetPintuanPricesByPids(conn, pids, DateTime.Now);

            //采购相关价格信息
            //var carigouPrices = await DalCarProductPrice.GetCaigouPriceByPids(conn, pids);
            List <CarPriceManagementResponse> carigouPrices = new List <CarPriceManagementResponse>();

            using (PurchaseClient _OperationResult = new PurchaseClient())
            {
                List <CarPriceManagementRequest> req = pids.Select(p => new CarPriceManagementRequest()
                {
                    PID = p
                }).ToList();
                var result = _OperationResult.SelectPurchaseInfoByPID(req);
                if (result.Success && result.Result.Any())
                {
                    carigouPrices = result.Result.ToList();
                }
            }


            //11410.广州保养仓库、 8598.上海保养仓库 、7295.武汉保养仓库、8634.北京保养仓库、缺少一个义乌(还未上线此仓库)
            var wareHouseIds = new List <string> {
                "8598", "7295", "11410", "8634"
            };
            var stockInfos = await DalCarProductPrice.GetStockQuantityByPids(conn, pids, wareHouseIds);

            foreach (var item in list)
            {
                #region 字段赋值

                var tempPintuanPrices   = pintuanPirces.Where(x => x.PID == item.PID);
                var temp0ActivityPrices = activityPrices?.Where(x => x.PID == item.PID && x.ActiveType == 0);
                var temp1ActivityPrices = activityPrices?.Where(x => x.PID == item.PID && x.ActiveType == 1);
                var temp4ActivityPrices = activityPrices?.Where(x => x.PID == item.PID && x.ActiveType == 4);
                //最小价格
                item.FullNetActivityPrice = (temp0ActivityPrices.OrderBy(x => x.Price).FirstOrDefault()?.Price) ?? 0;
                item.DaydaySeckillPrice   = (temp1ActivityPrices.OrderBy(x => x.Price).FirstOrDefault()?.Price) ?? 0;
                item.FlashSalePrice       = (temp4ActivityPrices.OrderBy(x => x.Price).FirstOrDefault()?.Price) ?? 0;
                item.PintuanPrice         = (tempPintuanPrices.OrderBy(x => x.Price).FirstOrDefault()?.Price) ?? 0;

                var tempCarigouPrices = carigouPrices?.Where(x => x.PID == item.PID);
                //采购相关价格信息
                item.PurchasePrice      = tempCarigouPrices.OrderBy(p => p.PurchasePrice).FirstOrDefault()?.PurchasePrice ?? 0;
                item.ContractPrice      = tempCarigouPrices.OrderBy(p => p.ContractPrice).FirstOrDefault()?.ContractPrice ?? 0;
                item.OfferPurchasePrice = tempCarigouPrices.OrderBy(p => p.OfferPurchasePrice).FirstOrDefault()?.OfferPurchasePrice ?? 0;
                item.OfferContractPrice = tempCarigouPrices.OrderBy(p => p.OfferContractPrice).FirstOrDefault()?.OfferContractPrice ?? 0;

                //历史价格
                item.FullNetActivityPriceList = temp0ActivityPrices.ToList();
                item.DaydaySeckillPriceList   = temp1ActivityPrices.ToList();
                item.FlashSalePriceList       = temp4ActivityPrices.ToList();
                item.PintuanPriceList         = tempPintuanPrices.ToList();

                //库存
                var tempStockInfos8598 = stockInfos?.FirstOrDefault(x => x.PID == item.PID && x.WAREHOUSEID == 8598);
                item.SH_AvailableStockQuantity = tempStockInfos8598?.TotalAvailableStockQuantity ?? 0;
                item.SH_ZaituStockQuantity     = tempStockInfos8598?.CaigouZaitu ?? 0;

                var tempStockInfos7295 = stockInfos?.FirstOrDefault(x => x.PID == item.PID && x.WAREHOUSEID == 7295);
                item.WH_AvailableStockQuantity = tempStockInfos7295?.TotalAvailableStockQuantity ?? 0;
                item.WH_ZaituStockQuantity     = tempStockInfos7295?.CaigouZaitu ?? 0;

                var tempStockInfos11410 = stockInfos?.FirstOrDefault(x => x.PID == item.PID && x.WAREHOUSEID == 11410);
                item.GZ_AvailableStockQuantity = tempStockInfos11410?.TotalAvailableStockQuantity ?? 0;
                item.GZ_ZaituStockQuantity     = tempStockInfos11410?.CaigouZaitu ?? 0;

                var tempStockInfos111 = stockInfos?.FirstOrDefault(x => x.PID == item.PID && x.WAREHOUSEID == 111);
                item.YW_AvailableStockQuantity = tempStockInfos111?.TotalAvailableStockQuantity ?? 0;
                item.YW_ZaituStockQuantity     = tempStockInfos111?.CaigouZaitu ?? 0;

                item.TotalAvailableStockQuantity = stockInfos?.Sum(x => x.TotalAvailableStockQuantity) ?? 0;
                item.TotalZaituStockQuantity     = stockInfos?.Sum(x => x.CaigouZaitu) ?? 0;

                #endregion
            }

            return(list);
        }
Example #5
0
        /// <summary>
        /// 查询商品相关信息(库存,活动价格,商品基本信息)
        /// </summary>
        /// <param name="pids"></param>
        /// <param name="conn"></param>
        /// <returns></returns>
        private static async Task <List <CarProductPriceModel> > FullPriceData(List <string> pids, SqlConnection conn)
        {
            //logger.Info($"FullPriceData 调用接口 start");
            //try
            //{
            var list = await DalCarProductPrice.GetProductBaseInfoByPids(conn, pids);

            if (list == null || list.Count < 1)
            {
                return(list);
            }

            //活动价格 activityType:1.天天秒杀 4.限时抢购,0.全网活动价
            var activityPrices = await DalCarProductPrice.GetActivityPricesByPids(conn, pids, DateTime.Now);

            //拼团价格
            var pintuanPirces = await DalCarProductPrice.GetPintuanPricesByPids(conn, pids, DateTime.Now);

            //采购相关价格信息
            //var carigouPrices = await DalCarProductPrice.GetCaigouPriceByPids(conn, pids);
            List <CarPriceManagementResponse> carigouPrices = new List <CarPriceManagementResponse>();

            using (PurchaseClient _OperationResult = new PurchaseClient())
            {
                List <CarPriceManagementRequest> req = pids.Select(p => new CarPriceManagementRequest()
                {
                    PID = p
                }).ToList();
                var result = _OperationResult.SelectPurchaseInfoByPID(req);
                if (result.Success && result.Result.Any())
                {
                    carigouPrices = result.Result.ToList();
                }
            }

            //11410.广州保养仓库、 8598.上海保养仓库 、7295.武汉保养仓库、8634.北京保养仓库、缺少一个义乌(还未上线此仓库)
            var wareHouseIds = new List <string> {
                "8598", "7295", "11410", "8634"
            };

            //获取相关的库存
            var stockInfos = dbScopeManagerBI.Execute(mana =>
                                                      DalCarProductPrice.GetStockQuantityByPids_new(mana, pids, wareHouseIds));

            //var stockInfos = await DalCarProductPrice.GetStockQuantityByPids(conn, pids, wareHouseIds);

            foreach (var item in list)
            {
                #region 字段赋值

                var tempPintuanPrices   = pintuanPirces.Where(x => x.PID == item.PID);
                var temp0ActivityPrices = activityPrices?.Where(x => x.PID == item.PID && x.ActiveType == 0);
                var temp1ActivityPrices = activityPrices?.Where(x => x.PID == item.PID && x.ActiveType == 1);
                var temp4ActivityPrices = activityPrices?.Where(x => x.PID == item.PID && x.ActiveType == 4);
                //最小价格
                item.FullNetActivityPrice = (temp0ActivityPrices.OrderBy(x => x.Price).FirstOrDefault()?.Price) ?? 0;
                item.DaydaySeckillPrice   = (temp1ActivityPrices.OrderBy(x => x.Price).FirstOrDefault()?.Price) ?? 0;
                item.FlashSalePrice       = (temp4ActivityPrices.OrderBy(x => x.Price).FirstOrDefault()?.Price) ?? 0;
                item.PintuanPrice         = (tempPintuanPrices.OrderBy(x => x.Price).FirstOrDefault()?.Price) ?? 0;
                item.IsFullNetUsePCode    =
                    temp0ActivityPrices.OrderBy(x => x.Price).FirstOrDefault()?.IsUsePCode ?? false;
                var tempCarigouPrices = carigouPrices?.Where(x => x.PID == item.PID);
                //采购相关价格信息
                item.PurchasePrice      = tempCarigouPrices.OrderBy(p => p.PurchasePrice).FirstOrDefault()?.PurchasePrice ?? 0;
                item.ContractPrice      = tempCarigouPrices.OrderBy(p => p.ContractPrice).FirstOrDefault()?.ContractPrice ?? 0;
                item.OfferPurchasePrice = tempCarigouPrices.OrderBy(p => p.OfferPurchasePrice).FirstOrDefault()?.OfferPurchasePrice ?? 0;
                item.OfferContractPrice = tempCarigouPrices.OrderBy(p => p.OfferContractPrice).FirstOrDefault()?.OfferContractPrice ?? 0;

                //历史价格
                item.FullNetActivityPriceList = temp0ActivityPrices.ToList();
                item.DaydaySeckillPriceList   = temp1ActivityPrices.ToList();
                item.FlashSalePriceList       = temp4ActivityPrices.ToList();
                item.PintuanPriceList         = tempPintuanPrices.ToList();

                //库存
                item.AvailableStock = new AvailableStockModel();
                item.ZaituStock     = new ZaituStockModel();

                var tempStockInfos8598 = stockInfos?.FirstOrDefault(x => x.PID == item.PID && x.WAREHOUSEID == 8598);
                item.AvailableStock.SH_AvailableStockQuantity = tempStockInfos8598?.TotalAvailableStockQuantity ?? 0;
                item.ZaituStock.SH_ZaituStockQuantity         = tempStockInfos8598?.CaigouZaitu ?? 0;

                var tempStockInfos7295 = stockInfos?.FirstOrDefault(x => x.PID == item.PID && x.WAREHOUSEID == 7295);
                item.AvailableStock.WH_AvailableStockQuantity = tempStockInfos7295?.TotalAvailableStockQuantity ?? 0;
                item.ZaituStock.WH_ZaituStockQuantity         = tempStockInfos7295?.CaigouZaitu ?? 0;

                var tempStockInfos11410 = stockInfos?.FirstOrDefault(x => x.PID == item.PID && x.WAREHOUSEID == 11410);
                item.AvailableStock.GZ_AvailableStockQuantity = tempStockInfos11410?.TotalAvailableStockQuantity ?? 0;
                item.ZaituStock.GZ_ZaituStockQuantity         = tempStockInfos11410?.CaigouZaitu ?? 0;

                var tempStockInfos111 = stockInfos?.FirstOrDefault(x => x.PID == item.PID && x.WAREHOUSEID == 111);
                item.AvailableStock.YW_AvailableStockQuantity = tempStockInfos111?.TotalAvailableStockQuantity ?? 0;
                item.ZaituStock.YW_ZaituStockQuantity         = tempStockInfos111?.CaigouZaitu ?? 0;

                item.TotalAvailableStockQuantity = stockInfos?.Where(x => x.PID == item.PID).Sum(x => x.TotalAvailableStockQuantity) ?? 0;
                item.TotalZaituStockQuantity     = stockInfos?.Where(x => x.PID == item.PID).Sum(x => x.CaigouZaitu) ?? 0;

                #endregion
            }

            return(list);
            //}
            //catch (Exception ex)
            //{
            //    logger.Info($"{nameof(CarProductPriceManager)}.{nameof(FullPriceData)} 调用接口 异常:{ex.Message}", ex);
            //    return null;
            //}
        }