Beispiel #1
0
        public async Task <ActionResult> GetCarProductMutliPriceByCatalog(string catalogId, string merchandiseBrand, string couponsString, int onSale,
                                                                          int isDaifa, int isOutOfStock, int isHavePintuanPrice, string keyWord, int keyWordSearchType, int curPage, int pageSize)
        {
            try
            {
                int totalRecord = await CarProductPriceManager.GetCarProductMutliPriceByCatalog_Count(catalogId, onSale, isDaifa, isOutOfStock, isHavePintuanPrice, keyWord, keyWordSearchType, merchandiseBrand);

                List <CarProductPriceModel> res = await CarProductPriceManager.GetCarProductMutliPriceByCatalog(catalogId, onSale, isDaifa, isOutOfStock, isHavePintuanPrice, keyWord, keyWordSearchType, curPage, pageSize, merchandiseBrand);

                List <GetCouponRules> coupons = JsonConvert.DeserializeObject <List <GetCouponRules> >(couponsString);
                if (coupons != null && coupons.Count > 0)
                {
                    foreach (var item in res)
                    {
                        List <GetCouponRules> rules = await GetCarProductUsedCouponPriceList(item, coupons);

                        if (rules != null && rules.Count > 0)
                        {
                            item.UsedCouponPrice  = (rules.Where(p => p.UsedCouponPrice > 0).FirstOrDefault() ?? new GetCouponRules()).UsedCouponPrice;
                            item.UsedCouponProfit = (rules.Where(p => p.UsedCouponPrice > 0).FirstOrDefault() ?? new GetCouponRules()).UsedCouponProfit;
                        }
                        item.Coupons = rules;
                    }
                }
                return(Json(Tuple.Create(res, totalRecord), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #2
0
        /// <summary>
        ///计算 车品使用 优惠券的详情
        /// </summary>
        /// <param name="couponRulePKID"></param>
        /// <returns></returns>
        public async Task <JsonResult> CalulateCarProductUsedCouponPriceList(string carProductPKID, string couponsString)
        {
            try
            {
                List <GetCouponRules> coupons = JsonConvert.DeserializeObject <List <GetCouponRules> >(couponsString);
                CarProductPriceModel  _CarProductPriceModel = await CarProductPriceManager.GetShopProductsByPidsAsync(carProductPKID);

                List <GetCouponRules> rules = await GetCarProductUsedCouponPriceList(_CarProductPriceModel, coupons);

                return(Json(new { Result = 1, Data = rules }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = 0, Message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #3
0
        public async Task <FileResult> ExportExcel_ForCarProductMutliPriceByCatalog(string catalogId, int onSale,
                                                                                    int isDaifa, int isOutOfStock, int isHavePintuanPrice, string keyWord, int keyWordSearchType)
        {
            var book = new HSSFWorkbook();

            NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1");
            NPOI.SS.UserModel.IRow   row    = sheet1.CreateRow(0);
            sheet1.SetColumnWidth(0, 300 * 20);
            sheet1.SetColumnWidth(1, 300 * 80);

            var fileName = $"车品相关商品价格信息{ThreadIdentity.Operator.Name.Split('@')[0]}.xls";

            //标头
            var columns = new List <string> {
                "PID", "商品名称", "天天秒杀价", "拼团价", "限时抢购价", "官网原价", "采购价格", "是否代发", "上下架", "是否缺货", "义乌仓可用库存", "义乌仓在途库存", "上海仓可用库存", "上海仓在途库存 武汉仓可用库存", "武汉仓在途库存", "北京仓可用库存", "北京仓在途库存", "广州仓可用库存", "广州仓在途库存", "全部可用库存", "全部在途库存"
            };

            for (int i = 0; i < columns.Count; i++)
            {
                row.CreateCell(i).SetCellValue(columns[i]);
            }

            //获取相关数据
            int totalRecord = await CarProductPriceManager.GetCarProductMutliPriceByCatalog_Count(catalogId, onSale, isDaifa, isOutOfStock, isHavePintuanPrice, keyWord, keyWordSearchType);

            var res = await CarProductPriceManager.GetCarProductMutliPriceByCatalog(catalogId, onSale, isDaifa, isOutOfStock, isHavePintuanPrice, keyWord, keyWordSearchType, 1, totalRecord);

            //给每一行赋值
            int ind = 1;

            NPOI.SS.UserModel.IRow rowtemp;
            foreach (var item in res)
            {
                rowtemp = sheet1.CreateRow(ind++);

                #region SetCellValue
                rowtemp.CreateCell(0).SetCellValue(item.PID);
                rowtemp.CreateCell(1).SetCellValue(item.ProductName);
                rowtemp.CreateCell(2).SetCellValue((double)item.DaydaySeckillPrice);
                rowtemp.CreateCell(3).SetCellValue((double)item.PintuanPrice);
                rowtemp.CreateCell(4).SetCellValue((double)item.FlashSalePrice);
                rowtemp.CreateCell(5).SetCellValue((double)item.OriginalPrice);
                rowtemp.CreateCell(6).SetCellValue(0);
                rowtemp.CreateCell(7).SetCellValue(item.IsDaifa ? "是" : "否");
                rowtemp.CreateCell(8).SetCellValue(item.OnSale ? "是" : "否");
                rowtemp.CreateCell(9).SetCellValue(item.StockOut ? "是" : "否");
                rowtemp.CreateCell(10).SetCellValue(item.YW_AvailableStockQuantity);
                rowtemp.CreateCell(11).SetCellValue(item.YW_ZaituStockQuantity);
                rowtemp.CreateCell(12).SetCellValue(item.SH_AvailableStockQuantity);
                rowtemp.CreateCell(13).SetCellValue(item.SH_ZaituStockQuantity);
                rowtemp.CreateCell(14).SetCellValue(item.WH_AvailableStockQuantity);
                rowtemp.CreateCell(15).SetCellValue(item.WH_ZaituStockQuantity);
                rowtemp.CreateCell(16).SetCellValue(item.BJ_AvailableStockQuantity);
                rowtemp.CreateCell(17).SetCellValue(item.BJ_ZaituStockQuantity);
                rowtemp.CreateCell(18).SetCellValue(item.GZ_AvailableStockQuantity);
                rowtemp.CreateCell(19).SetCellValue(item.GZ_ZaituStockQuantity);
                rowtemp.CreateCell(20).SetCellValue(item.TotalAvailableStockQuantity);
                rowtemp.CreateCell(21).SetCellValue(item.TotalZaituStockQuantity);
                #endregion
            }


            var ms = new MemoryStream();
            book.Write(ms);
            ms.Seek(0, SeekOrigin.Begin);
            return(File(ms, "application/vnd.ms-excel", fileName));
        }
        public async Task <FileResult> ExportExcel4CarProductMutliPrice(int categoryId, string merchandiseBrand, int onSale,
                                                                        int isDaifa, int isOutOfStock, int isHavePintuanPrice, string keyWord, int keyWordSearchType, string couponsString)
        {
            var book = new HSSFWorkbook();

            NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1");
            NPOI.SS.UserModel.IRow   row    = sheet1.CreateRow(0);

            //标头
            var columns = new List <string> {
                "PID", "商品名称", "天天秒杀价", "拼团价", "全网活动价", "券后价格", "券后毛利", "限时抢购价", "官网原价", "采购价格", "代发价格", "是否代发", "上下架", "是否缺货", "义乌仓可用库存", "义乌仓在途库存", "上海仓可用库存", "上海仓在途库存", "武汉仓可用库存", "武汉仓在途库存", "北京仓可用库存", "北京仓在途库存", "广州仓可用库存", "广州仓在途库存", "全部可用库存", "全部在途库存"
            };

            for (int i = 0; i < columns.Count; i++)
            {
                if (i == 0)
                {
                    sheet1.SetColumnWidth(i, 300 * 20);
                }
                else if (i == 1)
                {
                    sheet1.SetColumnWidth(i, 300 * 70);
                }
                else
                {
                    sheet1.SetColumnWidth(i, 300 * 10);
                }

                row.CreateCell(i).SetCellValue(columns[i]);
            }

            //获取相关数据
            int totalRecord = await CarProductPriceManager.GetCarProductMutliPriceCountByCategory(categoryId, onSale, isDaifa, isOutOfStock, isHavePintuanPrice, keyWord, keyWordSearchType, merchandiseBrand);

            var res = await CarProductPriceManager.GetCarProductMutliPriceByCategory(categoryId, onSale, isDaifa, isOutOfStock, isHavePintuanPrice, keyWord, keyWordSearchType, 1, totalRecord, merchandiseBrand);

            List <GetCouponRules> coupons = JsonConvert.DeserializeObject <List <GetCouponRules> >(couponsString);

            if (coupons != null && coupons.Count > 0)
            {
                foreach (var item in res)
                {
                    List <GetCouponRules> rules = await GetCarProductUsedCouponPriceList(item, coupons);

                    if (rules != null && rules.Count > 0)
                    {
                        item.UsedCouponPrice  = (rules.Where(p => p.UsedCouponPrice > 0).FirstOrDefault() ?? new GetCouponRules()).UsedCouponPrice;
                        item.UsedCouponProfit = (rules.Where(p => p.UsedCouponPrice > 0).FirstOrDefault() ?? new GetCouponRules()).UsedCouponProfit;
                    }
                }
            }
            //给每一行赋值
            int ind = 1;

            NPOI.SS.UserModel.IRow rowtemp;
            foreach (var item in res)
            {
                rowtemp = sheet1.CreateRow(ind++);

                #region SetCellValue
                rowtemp.CreateCell(0).SetCellValue(item.PID);
                rowtemp.CreateCell(1).SetCellValue(item.ProductName);
                rowtemp.CreateCell(2).SetCellValue((double)item.DaydaySeckillPrice);
                rowtemp.CreateCell(3).SetCellValue((double)item.PintuanPrice);
                rowtemp.CreateCell(4).SetCellValue((double)item.FullNetActivityPrice);
                rowtemp.CreateCell(5).SetCellValue((double)item.UsedCouponPrice);
                rowtemp.CreateCell(6).SetCellValue((double)item.UsedCouponProfit);
                rowtemp.CreateCell(7).SetCellValue((double)item.FlashSalePrice);
                rowtemp.CreateCell(8).SetCellValue((double)item.OriginalPrice);
                rowtemp.CreateCell(9).SetCellValue((double)item.PurchasePrice);
                rowtemp.CreateCell(10).SetCellValue((double)item.ContractPrice);
                rowtemp.CreateCell(11).SetCellValue(item.IsDaifa ? "是" : "否");
                rowtemp.CreateCell(12).SetCellValue(item.OnSale ? "是" : "否");
                rowtemp.CreateCell(13).SetCellValue(item.StockOut ? "是" : "否");
                rowtemp.CreateCell(14).SetCellValue(item.AvailableStock.YW_AvailableStockQuantity);
                rowtemp.CreateCell(15).SetCellValue(item.ZaituStock.YW_ZaituStockQuantity);
                rowtemp.CreateCell(16).SetCellValue(item.AvailableStock.SH_AvailableStockQuantity);
                rowtemp.CreateCell(17).SetCellValue(item.ZaituStock.SH_ZaituStockQuantity);
                rowtemp.CreateCell(18).SetCellValue(item.AvailableStock.WH_AvailableStockQuantity);
                rowtemp.CreateCell(19).SetCellValue(item.ZaituStock.WH_ZaituStockQuantity);
                rowtemp.CreateCell(20).SetCellValue(item.AvailableStock.BJ_AvailableStockQuantity);
                rowtemp.CreateCell(21).SetCellValue(item.ZaituStock.BJ_ZaituStockQuantity);
                rowtemp.CreateCell(22).SetCellValue(item.AvailableStock.GZ_AvailableStockQuantity);
                rowtemp.CreateCell(23).SetCellValue(item.ZaituStock.GZ_ZaituStockQuantity);
                rowtemp.CreateCell(24).SetCellValue(item.TotalAvailableStockQuantity);
                rowtemp.CreateCell(25).SetCellValue(item.TotalZaituStockQuantity);
                #endregion
            }

            var ms = new MemoryStream();
            book.Write(ms);
            ms.Seek(0, SeekOrigin.Begin);
            var fileName = $"车品相关商品价格信息{ThreadIdentity.Operator.Name.Split('@')[0]}.xls";
            return(File(ms, "application/vnd.ms-excel", fileName));
        }