Exemplo n.º 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));
            }
        }
Exemplo n.º 2
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));
        }