shanji 3 years ago
parent
commit
f6eb88ea6b
  1. 23
      BBWY.Client/Models/Shop/Department.cs
  2. 58
      BBWY.Client/ViewModels/FinancialTerminal/ProcurementAuditViewModel.cs
  3. 27
      BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml
  4. 29
      BBWY.Server.Business/Sync/JD/JDPopularizeReportFormAdLevelSyncBusiness.cs

23
BBWY.Client/Models/Shop/Department.cs

@ -1,18 +1,37 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
namespace BBWY.Client.Models namespace BBWY.Client.Models
{ {
public class Department public class Department : NotifyObject
{ {
private bool isSelected;
public string Id { get; set; } public string Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public IList<Shop> ShopList { get; set; } public IList<Shop> ShopList { get; set; }
public bool IsSelected
{
get => isSelected;
set
{
if (Set(ref isSelected, value))
OnIsSelectedChanged?.Invoke();
}
}
public Department() public Department()
{ {
ShopList = new List<Shop>(); ShopList = new List<Shop>();
} }
public Action OnIsSelectedChanged { get; set; }
public override string ToString()
{
return this.Name;
}
} }
} }

58
BBWY.Client/ViewModels/FinancialTerminal/ProcurementAuditViewModel.cs

@ -17,6 +17,7 @@ using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using BBWY.Common.Extensions; using BBWY.Common.Extensions;
using BBWY.Client.Views.FinancialTerminal; using BBWY.Client.Views.FinancialTerminal;
using Newtonsoft.Json;
namespace BBWY.Client.ViewModels namespace BBWY.Client.ViewModels
{ {
@ -30,7 +31,6 @@ namespace BBWY.Client.ViewModels
private bool onlyException; private bool onlyException;
private PurchaseOrderService purchaseOrderService; private PurchaseOrderService purchaseOrderService;
private FinancialTerminalService financialTerminalService; private FinancialTerminalService financialTerminalService;
private Department selectedDepartment;
private DateTime startDate; private DateTime startDate;
private DateTime endDate; private DateTime endDate;
private Shop selectResultShop; private Shop selectResultShop;
@ -38,17 +38,6 @@ namespace BBWY.Client.ViewModels
private bool noChooseFundType; private bool noChooseFundType;
private string searchResultPurchaseOrder; private string searchResultPurchaseOrder;
private Platform? selectPurchasePlatform; private Platform? selectPurchasePlatform;
public Department SelectedDepartment
{
get => selectedDepartment; set
{
if (Set(ref selectedDepartment, value))
{
foreach (var s in value.ShopList)
s.IsSelected = false;
}
}
}
public DateTime StartDate { get => startDate; set { Set(ref startDate, value); } } public DateTime StartDate { get => startDate; set { Set(ref startDate, value); } }
public DateTime EndDate { get => endDate; set { Set(ref endDate, value); } } public DateTime EndDate { get => endDate; set { Set(ref endDate, value); } }
@ -59,6 +48,8 @@ namespace BBWY.Client.ViewModels
public IList<Department> DepartmentList { get; set; } public IList<Department> DepartmentList { get; set; }
public IList<Shop> ShopList { get; set; }
public IList<AuditPayBill> ShowAuditPayBillList { get; set; } public IList<AuditPayBill> ShowAuditPayBillList { get; set; }
public AuditFile SelectAuditFile public AuditFile SelectAuditFile
@ -136,6 +127,7 @@ namespace BBWY.Client.ViewModels
this.financialTerminalService = financialTerminalService; this.financialTerminalService = financialTerminalService;
DepartmentList = new ObservableCollection<Department>(); DepartmentList = new ObservableCollection<Department>();
ShopList = new ObservableCollection<Shop>();
AuditFileList = new ObservableCollection<AuditFile>(); AuditFileList = new ObservableCollection<AuditFile>();
AuditPayBillList = new List<AuditPayBill>(); AuditPayBillList = new List<AuditPayBill>();
ShowAuditPayBillList = new ObservableCollection<AuditPayBill>(); ShowAuditPayBillList = new ObservableCollection<AuditPayBill>();
@ -144,11 +136,31 @@ namespace BBWY.Client.ViewModels
EndDate = DateTime.Now.Date; EndDate = DateTime.Now.Date;
} }
private void OnDeparmentSelectionChanged()
{
ShopList.Clear();
foreach (var d in DepartmentList)
{
if (!d.IsSelected)
continue;
foreach (var s in d.ShopList)
{
s.IsSelected = false;
ShopList.Add(s);
}
}
}
private void LoadDepartment() private void LoadDepartment()
{ {
foreach (var d in globalContext.User.DepartmentList) var dlist = JsonConvert.DeserializeObject<IList<Department>>(JsonConvert.SerializeObject(globalContext.User.DepartmentList));
foreach (var d in dlist)
{
d.IsSelected = false;
DepartmentList.Add(d); DepartmentList.Add(d);
SelectedDepartment = DepartmentList[0]; d.OnIsSelectedChanged = OnDeparmentSelectionChanged;
}
ShopList.Clear();
} }
private void SearchHistory() private void SearchHistory()
@ -157,7 +169,7 @@ namespace BBWY.Client.ViewModels
return; return;
ClearAudit(); ClearAudit();
IsLoading = true; IsLoading = true;
var importShopIds = string.Join(',', SelectedDepartment.ShopList.Where(s => s.IsSelected).Select(s => s.ShopId)); var importShopIds = string.Join(',', ShopList.Where(s => s.IsSelected).Select(s => s.ShopId));
Task.Factory.StartNew(() => financialTerminalService.GetAuditPayBillList(importShopIds, StartDate, EndDate)).ContinueWith(t => Task.Factory.StartNew(() => financialTerminalService.GetAuditPayBillList(importShopIds, StartDate, EndDate)).ContinueWith(t =>
{ {
IsLoading = false; IsLoading = false;
@ -173,7 +185,7 @@ namespace BBWY.Client.ViewModels
{ {
foreach (var b in list) foreach (var b in list)
{ {
b.Init(SelectedDepartment.ShopList); b.Init(ShopList);
AuditPayBillList.Add(b); AuditPayBillList.Add(b);
} }
SearchLocal(); SearchLocal();
@ -186,7 +198,7 @@ namespace BBWY.Client.ViewModels
{ {
if (IsLoading) if (IsLoading)
return; return;
if (AuditPayBillList.Count() == 0 || !SelectedDepartment.ShopList.Any(s => s.IsSelected)) if (AuditPayBillList.Count() == 0 || !ShopList.Any(s => s.IsSelected))
{ {
MessageBox.Show("审核数据不全", "提示"); MessageBox.Show("审核数据不全", "提示");
return; return;
@ -197,7 +209,7 @@ namespace BBWY.Client.ViewModels
new ManualResetEvent(false) new ManualResetEvent(false)
}; };
IsLoading = true; IsLoading = true;
var shopList = SelectedDepartment.ShopList.Where(s => s.IsSelected).ToList(); var shopList = ShopList.Where(s => s.IsSelected).ToList();
var sDate = StartDate.AddDays(-5); var sDate = StartDate.AddDays(-5);
var eDate = EndDate; var eDate = EndDate;
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
@ -529,7 +541,7 @@ namespace BBWY.Client.ViewModels
return; return;
} }
var importShopIds = string.Join(',', SelectedDepartment.ShopList.Where(s => s.IsSelected).Select(s => s.ShopId)); var importShopIds = string.Join(',', ShopList.Where(s => s.IsSelected).Select(s => s.ShopId));
var replaceResponse = financialTerminalService.IsExistAuditPayBill(importShopIds, StartDate, EndDate); var replaceResponse = financialTerminalService.IsExistAuditPayBill(importShopIds, StartDate, EndDate);
if (!replaceResponse.Success) if (!replaceResponse.Success)
@ -570,7 +582,7 @@ namespace BBWY.Client.ViewModels
{ {
if (ShowAuditPayBillList.Count == 0) if (ShowAuditPayBillList.Count == 0)
return; return;
var shopNames = string.Join(',', SelectedDepartment.ShopList.Where(s => s.IsSelected).Select(s => s.ShopName)); var shopNames = string.Join(',', ShopList.Where(s => s.IsSelected).Select(s => s.ShopName));
var ew = new ProcurementAuditExcelExport(); var ew = new ProcurementAuditExcelExport();
if (ew.ShowDialog() != true) if (ew.ShowDialog() != true)
@ -587,7 +599,7 @@ namespace BBWY.Client.ViewModels
else else
{ {
fileName = $"{StartDate:yyyy-MM-dd}_{EndDate:yyyy-MM-dd}_{shopNames}_资金类型汇总.csv"; fileName = $"{StartDate:yyyy-MM-dd}_{EndDate:yyyy-MM-dd}_{shopNames}_资金类型汇总.csv";
saveList.Add($"序号,资金类型,{string.Join(',', SelectedDepartment.ShopList)},汇总"); saveList.Add($"序号,资金类型,{string.Join(',', ShopList)},汇总");
var capitalGroups = ShowAuditPayBillList.Where(p => p.AuditCapitalType != null).GroupBy(p => p.AuditCapitalType); var capitalGroups = ShowAuditPayBillList.Where(p => p.AuditCapitalType != null).GroupBy(p => p.AuditCapitalType);
var index = 1; var index = 1;
var rowBuilder = new StringBuilder(); var rowBuilder = new StringBuilder();
@ -595,7 +607,7 @@ namespace BBWY.Client.ViewModels
{ {
var sum = 0M; var sum = 0M;
rowBuilder.Append($"{index},{capitalGroup.Key},"); rowBuilder.Append($"{index},{capitalGroup.Key},");
foreach (var shop in SelectedDepartment.ShopList) foreach (var shop in ShopList)
{ {
var currentShopCapitalGroup = capitalGroup.Where(p => p.BelongShopId == shop.ShopId); var currentShopCapitalGroup = capitalGroup.Where(p => p.BelongShopId == shop.ShopId);
var amount = 0M; var amount = 0M;
@ -641,5 +653,7 @@ namespace BBWY.Client.ViewModels
{ {
auditPayBill.AuditCapitalTypeInputMode = 0; auditPayBill.AuditCapitalTypeInputMode = 0;
} }
} }
} }

27
BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml

@ -48,11 +48,24 @@
</ResourceDictionary> </ResourceDictionary>
</Border.Resources> </Border.Resources>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<ComboBox Width="Auto" ItemsSource="{Binding DepartmentList}" <hc:CheckComboBox IsTextSearchEnabled="True" ItemsSource="{Binding DepartmentList}"
DisplayMemberPath="Name" ShowClearButton="True"
SelectedItem="{Binding SelectedDepartment,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/> MinWidth="150">
<!--<ComboBox Width="100" Margin="5,0,0,0"/>--> <hc:CheckComboBox.ItemTemplate>
<hc:CheckComboBox IsTextSearchEnabled="True" ItemsSource="{Binding SelectedDepartment.ShopList}" <DataTemplate>
<StackPanel Orientation="Horizontal" Margin="5,2.5">
<CheckBox Content="{Binding Name}" IsChecked="{Binding IsSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
</StackPanel>
</DataTemplate>
</hc:CheckComboBox.ItemTemplate>
<hc:CheckComboBox.ItemContainerStyle>
<Style TargetType="{x:Type hc:CheckComboBoxItem}" BasedOn="{StaticResource NoBgListBoxItemStyle}">
<Setter Property="IsSelected" Value="{Binding IsSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
</Style>
</hc:CheckComboBox.ItemContainerStyle>
</hc:CheckComboBox>
<hc:CheckComboBox IsTextSearchEnabled="True" ItemsSource="{Binding ShopList}"
ShowClearButton="True" ShowClearButton="True"
MinWidth="150"> MinWidth="150">
<hc:CheckComboBox.ItemTemplate> <hc:CheckComboBox.ItemTemplate>
@ -70,7 +83,7 @@
</hc:CheckComboBox> </hc:CheckComboBox>
<DatePicker Height="30" Margin="5,0,0,0" SelectedDate="{Binding StartDate,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/> <DatePicker Height="30" Margin="5,0,0,0" SelectedDate="{Binding StartDate,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<DatePicker Height="30" Margin="5,0,0,0" SelectedDate="{Binding EndDate,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/> <DatePicker Height="30" Margin="5,0,0,0" SelectedDate="{Binding EndDate,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<c:BButton Content="查询" Margin="5,0,0,0" Padding="10,0" Command="{Binding SearchHistoryCommand}"/> <c:BButton Content="查询历史" Margin="5,0,0,0" Padding="10,0" Command="{Binding SearchHistoryCommand}"/>
<c:BButton Content="审计" Padding="10,0" Command="{Binding AuditCommand}" Background="#02A7F0"/> <c:BButton Content="审计" Padding="10,0" Command="{Binding AuditCommand}" Background="#02A7F0"/>
<c:BButton Content="清空" Padding="10,0" Command="{Binding ClearAuditCommand}" Background="{StaticResource Text.Pink}"/> <c:BButton Content="清空" Padding="10,0" Command="{Binding ClearAuditCommand}" Background="{StaticResource Text.Pink}"/>
</StackPanel> </StackPanel>
@ -163,7 +176,7 @@
<Grid Grid.Row="6" Background="{StaticResource Border.Background}"> <Grid Grid.Row="6" Background="{StaticResource Border.Background}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="店铺名称" VerticalAlignment="Center" Margin="5,0,0,0"/> <TextBlock Text="店铺名称" VerticalAlignment="Center" Margin="5,0,0,0"/>
<ComboBox Margin="5,0,0,0" ItemsSource="{Binding SelectedDepartment.ShopList}" <ComboBox Margin="5,0,0,0" ItemsSource="{Binding ShopList}"
SelectedItem="{Binding SelectResultShop,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" SelectedItem="{Binding SelectResultShop,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
VerticalContentAlignment="Center" VerticalContentAlignment="Center"
VerticalAlignment="Center" Height="25"/> VerticalAlignment="Center" Height="25"/>

29
BBWY.Server.Business/Sync/JD/JDPopularizeReportFormAdLevelSyncBusiness.cs

@ -20,6 +20,8 @@ namespace BBWY.Server.Business.Sync
{ {
public class JDPopularizeReportFormAdLevelSyncBusiness : BaseSyncBusiness, IDenpendency public class JDPopularizeReportFormAdLevelSyncBusiness : BaseSyncBusiness, IDenpendency
{ {
private char[] separator_dx = new char[] { '-' };
public JDPopularizeReportFormAdLevelSyncBusiness(RestApiService restApiService, public JDPopularizeReportFormAdLevelSyncBusiness(RestApiService restApiService,
IOptions<GlobalConfig> options, IOptions<GlobalConfig> options,
NLogManager nLogManager, NLogManager nLogManager,
@ -115,7 +117,7 @@ namespace BBWY.Server.Business.Sync
if (!presponse.Success) if (!presponse.Success)
throw new Exception($"获取JD推广报表-创意维度失败 {presponse.Msg}"); throw new Exception($"获取JD推广报表-创意维度失败 {presponse.Msg}");
SyncShopPopularizeReportFormAdLevel(long.Parse(shop.ShopId), presponse.Data); SyncShopPopularizeReportFormAdLevel(shop.ShopName, long.Parse(shop.ShopId), presponse.Data);
currentCount = presponse.Data?.Count() ?? 0; currentCount = presponse.Data?.Count() ?? 0;
} }
catch (Exception ex) catch (Exception ex)
@ -125,7 +127,7 @@ namespace BBWY.Server.Business.Sync
} }
} }
private void SyncShopPopularizeReportFormAdLevel(long shopId, JArray jArray) private void SyncShopPopularizeReportFormAdLevel(string shopName, long shopId, JArray jArray)
{ {
if (jArray == null || !jArray.HasValues) if (jArray == null || !jArray.HasValues)
return; return;
@ -133,10 +135,29 @@ namespace BBWY.Server.Business.Sync
foreach (var j in jArray) foreach (var j in jArray)
{ {
var adName = j.Value<string>("adName"); var adName = j.Value<string>("adName");
var adId = j.Value<string>("adId");
var skuMatch = Regex.Match(adName, @"^(.*-)?(\d+)-(.*)$"); var skuMatch = Regex.Match(adName, @"^(.*-)?(\d+)-(.*)$");
string sku;
if (skuMatch.Success)
sku = skuMatch.Groups[2].Value;
else
{
skuMatch = Regex.Match(adName, @"^(.*)-(\d+)$");
if (!skuMatch.Success) if (!skuMatch.Success)
{
nLogManager.GetLogger($"创意维度-{shopName}").Info($"创意名称识别失败 adId {adId} adName {adName} 名称格式错误");
continue; continue;
var sku = skuMatch.Groups[2].Value; }
sku = skuMatch.Groups[2].Value;
}
if (sku == adId)
{
nLogManager.GetLogger($"创意维度-{shopName}").Info($"创意名称识别失败 adId {adId} adName {adName} 提取的[sku]与创意Id相同");
continue;
}
insertList.Add(new JDPopularizeAdSku() insertList.Add(new JDPopularizeAdSku()
{ {
Id = idGenerator.NewLong(), Id = idGenerator.NewLong(),
@ -145,7 +166,7 @@ namespace BBWY.Server.Business.Sync
CreateTime = DateTime.Now, CreateTime = DateTime.Now,
CampaignId = j.Value<long>("campaignId"), CampaignId = j.Value<long>("campaignId"),
AdGroupId = j.Value<long>("adGroupId"), AdGroupId = j.Value<long>("adGroupId"),
AdId = j.Value<long>("adId"), AdId = long.Parse(adId),
AdName = adName, AdName = adName,
Date = DateTime.ParseExact(j.Value<string>("date"), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture), Date = DateTime.ParseExact(j.Value<string>("date"), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture),
Cost = j["retrievalType0"].Value<decimal>("cost"), Cost = j["retrievalType0"].Value<decimal>("cost"),

Loading…
Cancel
Save