public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var v = (long)value; if (v == 0) { return(""); } return(VendorService.FormatVendorName(ServiceContainer.GetService <VendorService>().GetVendorName(v))); }
private void UpdateGoodsInfo() { StringBuilder sb = new StringBuilder(); if (this.Source.OrderGoodss != null && this.Source.OrderGoodss.Count > 0 && this.Source.Type != OrderType.SHUA) { foreach (var goods in this.Source.OrderGoodss.Where(obj => obj.State != OrderState.CLOSED && obj.State != OrderState.CANCLED && obj.State != OrderState.SPILTED)) { sb.Append(VendorService.FormatVendorName(goods.Vendor) + " " + goods.Number + " " + goods.Edtion + " " + goods.Color + " " + goods.Size + " " + goods.Count + ", "); } } this.Goods = sb.ToString(); }
private void btnPrint_Click(object sender, RoutedEventArgs e) { if (this.OrderReturns.Count < 1) { MessageBox.Show("没有需要打印的数据"); return; } try { string printer = LocalConfigService.GetValue(SystemNames.CONFIG_PRINTER_A4, ""); if (string.IsNullOrWhiteSpace(printer)) { throw new Exception("请在系统配置里面,配置要使用的打印机"); } if (MessageBox.Show("是否使用打印机:" + printer + Environment.NewLine + "打印?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) { return; } var pd = PrintUtil.GetPrinter(printer); VendorService vs = ServiceContainer.GetService <VendorService>(); var goodsCountDoc = new OrderReturnOutPrintDocument(); List <GoodsCount> counts = new List <GoodsCount>(); foreach (var item in this.OrderReturns) { string[] infos = item.Source.GoodsInfo.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries); if (infos.Length < 4) { MessageBox.Show("退货信息不正确,请检查:" + item.Source.Id); continue; } var vendor = vs.GetByAll(infos[0], "", "", "", 0, 0).First; if (vendor == null) { vendor = vs.GetByAll(infos[0] + infos[1], "", "", "", 0, 0).First; } if (vendor == null) { MessageBox.Show("退货信息厂家找不到,请检查:" + item.Source.Id); continue; } GoodsCount count = null; if (infos.Length >= 5) { count = counts.FirstOrDefault( obj => obj.Vendor == VendorService.FormatVendorName(infos[0]) && obj.Number == infos[1] && obj.Edtion == infos[2] && obj.Color == infos[3] && obj.Size == infos[4]); } else { count = counts.FirstOrDefault( obj => obj.Vendor == VendorService.FormatVendorName(infos[0]) && obj.Number == infos[1] && obj.Color == infos[2] && obj.Size == infos[3]); } if (count == null) { count = new GoodsCount { Vendor = infos[0].Trim(), Number = infos[1].Trim(), Money = (int)(item.Source.GoodsMoney / item.Source.Count), Count = 0, FirstPayTime = item.Source.ProcessTime, }; if (infos.Length >= 5) { count.Edtion = infos[2].Trim(); count.Color = infos[3].Trim(); count.Size = infos[4].Trim(); } else { count.Edtion = ""; count.Color = infos[2].Trim(); count.Size = infos[3].Trim(); } count.Address = vendor.MarketAddressShort; count.Vendor = VendorService.FormatVendorName(count.Vendor); counts.Add(count); } foreach (var c in counts.Where(obj => obj.Vendor == count.Vendor && obj.Number == count.Number && obj.Edtion == count.Edtion)) { //取消最大金额值 if (c.Money < count.Money) { c.Money = count.Money; } else { count.Money = c.Money; } } if (count.FirstPayTime >= item.Source.ProcessTime) { count.FirstPayTime = item.Source.ProcessTime; } count.Count += item.Source.Count; } IComparer <GoodsCount> comparer = new OrderGoodsCountSortByDoor(); counts.Sort(comparer); //拿货地址 counts.Sort(comparer); //货号 counts.Sort(comparer); //版本 counts.Sort(comparer); //颜色 counts.Sort(comparer); //尺码 goodsCountDoc.PageSize = new Size(793, 1122.24); goodsCountDoc.SetGoodsCount(counts.ToArray()); pd.PrintDocument(goodsCountDoc, "退货统计"); foreach (var item in this.OrderReturns) { this.OrderReturnService.Update(item.Source); } MessageBox.Show("打印完成"); } catch (Exception ex) { MessageBox.Show(ex.Message, "打印出错"); } }
private void btnQuery_Click(object sender, RoutedEventArgs e) { try { long shopId = this.cbbShops.SelectedItem == null ? 0 : (this.cbbShops.SelectedItem as Shop).Id; var scs = ServiceContainer.GetService <OrderGoodsService>().GetSaleCount(shopId, this.cbbOrderTypes.GetSelectedEnum <OrderType>(), this.cbbTimeType.SelectedIndex, this.dpStart.Value.Value, this.dpEnd.Value.Value, 0, 0).Datas.ToArray(); //订单信息金额汇总 List <SaleInfo> sis = new List <SaleInfo>(); //根据一个订单包含多个子订单重新计算每一双鞋子应该的价格,根据比例 var ordersGroupById = scs.GroupBy(obj => obj.OrderId).Where(obj => obj.Count() > 1).ToArray(); foreach (var or in ordersGroupById) { float total = or.Select(obj => obj.Count * obj.PopPrice).Sum(); foreach (var o in or) { o.PopSellerGetMoney = o.PopSellerGetMoney * o.Count * o.PopPrice / total; } } SaleCount[] targetScs = null; //左下分析,有货号,则分析商品SKU卖出情况 string vendor = this.tbVendorName.Text.Trim(); string goodsId = this.tbGoodsId.Text.Trim(); //根据商品编号查询 if (string.IsNullOrWhiteSpace(goodsId) == false) { targetScs = scs.Where(obj => obj.GoodsId.ToString() == goodsId).ToArray(); float total = targetScs.Select(obj => obj.PopSellerGetMoney).Sum(); int count = targetScs.Length; this.FillSaleMoneyInfo(targetScs); //左下统计SKU详情 var skuGroup = targetScs.GroupBy(obj => obj.Color + ":" + obj.Size + "," + obj.Edtion); this.dgvCountInfo2.ItemsSource = skuGroup .Select(obj => new SaleCountInfo { VendorName = obj.Key, Count = obj.Count(), SaleMoney = obj.Select(o => o.PopSellerGetMoney).Sum(), PerSaleMoney = obj.Select(o => o.PopSellerGetMoney).Sum() * 100F / total }).OrderByDescending(obj => obj.PerSaleMoney).ToArray(); //右下统计每日销售占比 List <SaleCountInfo> scis = new List <SaleCountInfo>(); var dateGroup = targetScs .GroupBy(obj => this.cbbTimeType.SelectedIndex == 0 ? obj.PopPayTime.Date : obj.DeliveryTime.Date).ToArray(); foreach (var dg in dateGroup) { SaleCountInfo sc = new SaleCountInfo { VendorName = dg.Key.ToString("yyyy-MM-dd"), Number = string.Join(",", dg.Select(obj => obj.Number).Distinct()), Count = dg.Count(), SaleMoney = dg.Select(obj => obj.PopSellerGetMoney).Sum() }; var matchScs = scs.Where(obj => (this.cbbTimeType.SelectedIndex == 0 ? obj.PopPayTime.Date : obj.DeliveryTime.Date) == dg.Key); sc.PerCount = sc.Count * 100F / matchScs.Count(); sc.PerSaleMoney = sc.SaleMoney * 100F / matchScs.Select(obj => obj.PopSellerGetMoney).Sum(); scis.Add(sc); } this.dgvGoodsInfo.ItemsSource = scis.OrderByDescending(obj => obj.VendorName).ToArray(); } else if (string.IsNullOrWhiteSpace(vendor) == false) { targetScs = scs.Where(obj => VendorService.FormatVendorName(obj.Vendor) == VendorService.FormatVendorName(vendor)).ToArray(); float total = targetScs.Select(obj => obj.PopSellerGetMoney).Sum(); int count = targetScs.Length; //厂家查询 this.FillSaleMoneyInfo(targetScs); //左下统计货号卖出详情 var numberGroup = targetScs.GroupBy(obj => obj.Number).ToArray(); this.dgvCountInfo2.ItemsSource = numberGroup .Select(obj => new SaleCountInfo { VendorName = obj.Key, Number = obj.Key, Count = obj.Count(), SaleMoney = obj.Select(o => o.PopSellerGetMoney).Sum(), PerCount = obj.Count() * 100F / count, PerSaleMoney = obj.Select(o => o.PopSellerGetMoney).Sum() * 100F / total }).OrderByDescending(obj => obj.PerSaleMoney).ToArray(); //右下统计每日销售占比 List <SaleCountInfo> scis = new List <SaleCountInfo>(); var dateGroup = targetScs .GroupBy(obj => this.cbbTimeType.SelectedIndex == 0 ? obj.PopPayTime.Date : obj.DeliveryTime.Date).ToArray(); foreach (var dg in dateGroup) { SaleCountInfo sc = new SaleCountInfo { VendorName = dg.Key.ToString("yyyy-MM-dd"), Number = string.Join(",", dg.Select(obj => obj.Number).Distinct()), Count = dg.Count(), SaleMoney = dg.Select(obj => obj.PopSellerGetMoney).Sum() }; var matchScs = scs.Where(obj => (this.cbbTimeType.SelectedIndex == 0 ? obj.PopPayTime.Date : obj.DeliveryTime.Date) == dg.Key); sc.PerCount = sc.Count * 100F / matchScs.Count(); sc.PerSaleMoney = sc.SaleMoney * 100F / matchScs.Select(obj => obj.PopSellerGetMoney).Sum(); scis.Add(sc); } this.dgvGoodsInfo.ItemsSource = scis.OrderByDescending(obj => obj.VendorName).ToArray(); } else { targetScs = scs; //所有 this.FillSaleMoneyInfo(targetScs.ToArray()); float total = targetScs.Select(obj => obj.PopSellerGetMoney).Sum(); int count = targetScs.Length; //左下统计厂家占比 var vGroup = targetScs.GroupBy(obj => VendorService.FormatVendorName(obj.Vendor)).ToArray(); this.dgvCountInfo2.ItemsSource = vGroup .Select(obj => new SaleCountInfo { VendorName = obj.Key, SaleMoney = obj.Select(o => o.PopSellerGetMoney).Sum(), Count = obj.Count(), Number = "", PerCount = obj.Count() * 100.0F / count, PerSaleMoney = (100.0F * obj.Select(o => o.PopSellerGetMoney).Sum() / total) }).OrderByDescending(obj => obj.PerSaleMoney).ToArray(); //右下统计商品销售占比 var gGroup = targetScs.GroupBy(obj => obj.GoodsId).ToArray(); this.dgvGoodsInfo.ItemsSource = gGroup .Select(obj => new SaleCountInfo { VendorName = obj.First().Vendor, Number = string.Join(",", obj.Select(o => o.Number).Distinct()), Count = obj.Count(), SaleMoney = obj.Select(o => o.PopSellerGetMoney).Sum(), PerCount = obj.Count() * 100F / count, PerSaleMoney = obj.Select(o => o.PopSellerGetMoney).Sum() * 100F / total }).OrderByDescending(obj => obj.PerSaleMoney).ToArray(); } var ordersGroupByState = targetScs.GroupBy(obj => obj.State).OrderBy(obj => obj.Key).ToArray(); foreach (var ogroup in ordersGroupByState) { sis.Add(new SaleInfo { State = EnumUtil.GetEnumValueDescription(ogroup.Key), Count = ogroup.Select(obj => obj.OrderId).Distinct().Count(), SaleMoney = ogroup.Select(obj => obj.PopSellerGetMoney).Sum(), CostMoney = ogroup.Select(obj => obj.ERPOrderGoodsMoney * obj.Count + obj.ERPOrderDeliveryMoney + obj.PopSellerGetMoney * GetCommissionPer(obj.ShopId)).Sum() }); } this.dgvCountInfo.ItemsSource = sis; } catch (Exception ex) { MessageBox.Show(ex.Message); } }