You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
249 lines
10 KiB
C#
249 lines
10 KiB
C#
using DevComponents.DotNetBar;
|
|
using DevComponents.DotNetBar.SuperGrid;
|
|
using POS.Language.Language;
|
|
using POSV.Card;
|
|
using POSV.Component;
|
|
using POSV.Entity.ReportPrint;
|
|
using POSV.Helper;
|
|
using POSV.OtherWaiMai;
|
|
using POSV.Utils;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace POSV.Report
|
|
{
|
|
public partial class OtherWaiMaiSummaryForm : BusinessForm
|
|
{
|
|
private bool querying = false;//待处理订单查询锁
|
|
private List<WaimaiOrderStatisticsResponse> statisticsResponse = new List<WaimaiOrderStatisticsResponse>();
|
|
public OtherWaiMaiSummaryForm()
|
|
{
|
|
InitializeComponent();
|
|
this.controlBox1.Text = LangProxy.ToLang("第三方外卖汇总");
|
|
this.controlBox1.ShowApplicationVersion = false;
|
|
}
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
base.OnLoad(e);
|
|
|
|
if (this.DesignMode) return;
|
|
|
|
DefaultGridStyle.setDefaultGridStyle(this.payListTable);
|
|
|
|
this.startPicker.Value = DateTime.Parse(Global.Instance.BusinessPlan.StartTimeSimple);
|
|
this.endPicker.Value = DateTime.Parse(Global.Instance.BusinessPlan.EndTimeSimple);
|
|
//打开界面默认加载第一个TAB
|
|
QueryTicket();
|
|
}
|
|
|
|
private void btn_query_Click(object sender, EventArgs e)
|
|
{
|
|
QueryTicket();
|
|
}
|
|
|
|
private void btn_time_Click(object sender, EventArgs e)
|
|
{
|
|
var obj = sender as ButtonX;
|
|
var typeStr = obj.Tag as string;
|
|
var type = (ReportQuickDate)Enum.Parse(typeof(ReportQuickDate), typeStr);
|
|
|
|
var res = DateTimeUtils.CalculateBusinessPlanDate(type, this.startPicker.Value, this.endPicker.Value);
|
|
|
|
this.startPicker.Value = res.Item1;
|
|
this.endPicker.Value = res.Item2;
|
|
QueryTicket();
|
|
}
|
|
|
|
private void btn_print_Click(object sender, EventArgs e)
|
|
{
|
|
PrintOtherWaiMaiSummary printOtherWaiMaiSummary = new PrintOtherWaiMaiSummary();
|
|
printOtherWaiMaiSummary.StoreNo = Global.Instance.Worker.StoreInfo.No;
|
|
printOtherWaiMaiSummary.StoreName = Global.Instance.Worker.StoreInfo.PrintName;
|
|
printOtherWaiMaiSummary.WorkerNo = Global.Instance.Worker.No;
|
|
printOtherWaiMaiSummary.WorkerName = Global.Instance.Worker.Name;
|
|
printOtherWaiMaiSummary.PrintTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
printOtherWaiMaiSummary.StartTime = this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
|
printOtherWaiMaiSummary.EndTime = this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
|
int Total = 0;
|
|
int Success = 0;
|
|
int Failed = 0;
|
|
int Other = 0;
|
|
decimal OriginalAmount = 0.00M;
|
|
decimal ShippingFee = 0.00M;
|
|
decimal ReceiveAmount = 0.00M;
|
|
decimal TotalAmount = 0.00M;
|
|
foreach (var item in statisticsResponse)
|
|
{
|
|
if ("合计".Equals(item.SignName))
|
|
{
|
|
break;
|
|
}
|
|
Total += item.Total;
|
|
Success += item.Success;
|
|
Failed += item.Failed;
|
|
Other += item.Other;
|
|
OriginalAmount += item.OriginalAmount;
|
|
ShippingFee += item.ShippingFee;
|
|
ReceiveAmount += item.ReceiveAmount;
|
|
TotalAmount += item.TotalAmount;
|
|
}
|
|
printOtherWaiMaiSummary.Total = string.Format("{0}", Total);
|
|
printOtherWaiMaiSummary.Success = string.Format("{0}", Success);
|
|
printOtherWaiMaiSummary.Failed = string.Format("{0}", Failed);
|
|
printOtherWaiMaiSummary.Other = string.Format("{0}", Other);
|
|
printOtherWaiMaiSummary.OriginalAmount = string.Format("{0}", OriginalAmount);
|
|
printOtherWaiMaiSummary.ShippingFee = string.Format("{0}", ShippingFee);
|
|
printOtherWaiMaiSummary.ReceiveAmount = string.Format("{0}", ReceiveAmount);
|
|
printOtherWaiMaiSummary.TotalAmount = string.Format("{0}", TotalAmount);
|
|
this.ShowToastNotify(this, "开始打印");
|
|
//构建打印模版参数
|
|
var vars = ReportHelper.BuilderOtherWaiMaiSummaryVariable(printOtherWaiMaiSummary, statisticsResponse);
|
|
Tuple<bool, string> result = ReportHelper.PrinterTicket("外卖汇总", vars, true, false);
|
|
this.ShowToastNotify(this, string.Format("{0}", result.Item2));
|
|
}
|
|
|
|
private void btn_exit_Click(object sender, EventArgs e)
|
|
{
|
|
OnCloseTouchClick(sender, e);
|
|
}
|
|
|
|
private void OnControlBoxCloseClick(object sender, EventArgs e)
|
|
{
|
|
OnCloseTouchClick(sender, e);
|
|
}
|
|
|
|
private void OnCloseTouchClick(object sender, EventArgs e)
|
|
{
|
|
//先关闭父窗体
|
|
if (this.Owner != null)
|
|
{
|
|
this.Owner.Close();
|
|
}
|
|
//再关闭当前窗体
|
|
this.Close();
|
|
}
|
|
|
|
private void OnControlBoxMinClick(object sender, EventArgs e)
|
|
{
|
|
this.WindowState = FormWindowState.Minimized;
|
|
}
|
|
public void QueryTicket()
|
|
{
|
|
if (querying)
|
|
{
|
|
this.ShowToastNotify(this, "查询中.....");
|
|
return;
|
|
}
|
|
querying = true;
|
|
|
|
Task.Factory.StartNew(() =>
|
|
{
|
|
WaimaiOrderStatisticsRequest request = new WaimaiOrderStatisticsRequest();
|
|
request.StoreId = Global.Instance.BusinessPlanLog.StoreId;
|
|
request.StartTime = this.startPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
|
request.EndTime = this.endPicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
|
var response = OtherWaiMaiUtils.WaimaiOrderStatistics(request);
|
|
if (response != null && response.Item1)
|
|
{
|
|
if (this.IsDisposed || !this.IsHandleCreated) return;
|
|
this.Invoke(new Action(() =>
|
|
{
|
|
statisticsResponse = response.Item3.List;
|
|
int Total = 0;
|
|
int Success = 0;
|
|
int Failed = 0;
|
|
int Other = 0;
|
|
decimal OriginalAmount = 0.00M;
|
|
decimal ShippingFee = 0.00M;
|
|
decimal ReceiveAmount = 0.00M;
|
|
decimal TotalAmount = 0.00M;
|
|
|
|
foreach (WaimaiOrderStatisticsResponse waimaiOrderStatisticsResponse in statisticsResponse)
|
|
{
|
|
Total += waimaiOrderStatisticsResponse.Total;
|
|
Success += waimaiOrderStatisticsResponse.Success;
|
|
Failed += waimaiOrderStatisticsResponse.Failed;
|
|
Other += waimaiOrderStatisticsResponse.Other;
|
|
OriginalAmount += waimaiOrderStatisticsResponse.OriginalAmount;
|
|
ShippingFee += waimaiOrderStatisticsResponse.ShippingFee;
|
|
ReceiveAmount += waimaiOrderStatisticsResponse.ReceiveAmount;
|
|
TotalAmount += waimaiOrderStatisticsResponse.TotalAmount;
|
|
switch (waimaiOrderStatisticsResponse.Sign)
|
|
{
|
|
case "meituan":
|
|
waimaiOrderStatisticsResponse.SignName = "美团外卖";
|
|
break;
|
|
case "eleme":
|
|
waimaiOrderStatisticsResponse.SignName = "饿了么";
|
|
break;
|
|
case "baidu":
|
|
waimaiOrderStatisticsResponse.SignName = "百度外卖";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
WaimaiOrderStatisticsResponse summary = new WaimaiOrderStatisticsResponse();
|
|
summary.SignName = "合计";
|
|
summary.Total = Total;
|
|
summary.Success = Success;
|
|
summary.Failed = Failed;
|
|
summary.Other = Other;
|
|
summary.OriginalAmount = OriginalAmount;
|
|
summary.ShippingFee = ShippingFee;
|
|
summary.ReceiveAmount = ReceiveAmount;
|
|
summary.TotalAmount = TotalAmount;
|
|
statisticsResponse.Add(summary);
|
|
payListTable.PrimaryGrid.DataSource = statisticsResponse;
|
|
}));
|
|
}
|
|
querying = false;
|
|
});
|
|
}
|
|
|
|
private void OnBind(object sender, DevComponents.DotNetBar.SuperGrid.GridDataBindingCompleteEventArgs e)
|
|
{
|
|
var panel = e.GridPanel;
|
|
|
|
foreach (var r in panel.Rows)
|
|
{
|
|
var row = r as GridRow;
|
|
|
|
var payTypeNo = row.Cells["signName"].Value.ToString();
|
|
if ("合计".Equals(payTypeNo))
|
|
{
|
|
row.CellStyles.Default.Background.Color1 = Color.AliceBlue;
|
|
|
|
row.CellStyles.Default.Font = new Font("宋体", 14.00f, FontStyle.Bold, GraphicsUnit.Pixel);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void OnGridPostRenderRow(object sender, DevComponents.DotNetBar.SuperGrid.GridPostRenderRowEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void tab_onclick(object sender, EventArgs e)
|
|
{
|
|
var obj = sender as SuperTabItem;
|
|
var name = obj.Tag as string;
|
|
switch (name)
|
|
{
|
|
case "superTabItem1"://第三方外卖汇总
|
|
QueryTicket();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|