@ -25,6 +25,7 @@ namespace POSV.Shift
public partial class ShiftForm : BusinessForm
{
HandOverTicket handOverTicket = null ;
bool splitPayFinished = false ;
public ShiftForm ( )
{
InitializeComponent ( ) ;
@ -41,6 +42,9 @@ namespace POSV.Shift
#region subin 20231025 分账由实时改为交班时分账
MsgEvent . RemoveListener ( Constant . SPLITPAY_UPLOAD_PROGRESS , MessageEventNotify ) ;
MsgEvent . Receive ( Constant . SPLITPAY_UPLOAD_PROGRESS , MessageEventNotify ) ;
MsgEvent . RemoveListener ( Constant . SPLITPAY_UPLOAD_FINISHED , SplitPayFinishEventNotify ) ;
MsgEvent . Receive ( Constant . SPLITPAY_UPLOAD_FINISHED , SplitPayFinishEventNotify ) ;
# endregion
if ( this . DesignMode ) return ;
@ -1155,16 +1159,12 @@ namespace POSV.Shift
private void ButtonOk_Click ( object sender , EventArgs e )
{
#region 原始代码
var button = sender as ButtonX ;
try
{
button . Enabled = false ;
//#region subin 20231025 分账由实时改为交班时分账
//splitFrm = new SplitPayUploadForm(0, 100);
//this.Invoke(new EventJisuan(SplitHandle), sender, e);
//#endregion
if ( Global . Instance . GlobalConfigBoolValue ( ConfigConstant . CONFIG_CASHIER_ISVERIFICATIONORDER ) )
{
int _count = 0 ;
@ -1189,6 +1189,8 @@ namespace POSV.Shift
}
}
var shiftDateTime = DateTime . Now ;
if ( handOverTicket ! = null )
{
decimal handsMoney = 0.00 M ;
@ -1260,11 +1262,56 @@ namespace POSV.Shift
#region subin 20231025 分账由实时改为交班时分账
splitFrm = new SplitPayUploadForm ( 0 , 100 ) ;
splitFrm = new SplitPayUploadForm ( 0 , 100 0 ) ;
this . Invoke ( new EventJisuan ( SplitHandle ) , sender , e ) ;
# endregion
////刷新界面???
////交班打印
//this.ShowToastNotify(this, "开始打印");
////构建收银小票模版参数
//handOverTicket.PrintType = "";
//handOverTicket.handMoney = handsMoney;//手工金额
//handOverTicket.diffMoney = difMoney;//差异金额
//bool ShiftPrint = Global.Instance.GlobalConfigBoolValue(ConfigConstant.CONFIG_CASHIER_SHIFPRINT, false);
//LOGGER.Info("-------------------构建小票参数------------------------------");
//LOGGER.Info(JsonUtils.Serialize(this.handOverTicket));
//var vars = ShiftHelper.BuilderTicketVariable(handOverTicket, ShiftPrint, false);
//LOGGER.Info("-------------------------------------------------");
////交班开钱箱
//bool openCashbox = false;
//if (Global.Instance.GlobalConfigBoolValue(ConfigConstant.CONFIG_CASHIER_ISSHIFTOPENCASH))
//{
// openCashbox = Global.Instance.GlobalConfigBoolValue(ConfigConstant.CONFIG_CASHIER_ISSHIFTOPENCASH);
//}
//Tuple<bool, string> result = ShiftHelper.PrinterTicket("交班汇总", vars, true, openCashbox);
//this.ShowToastNotify(this, string.Format("{0}", result.Item2));
////是否交班
//Global.isHandOver = false;
//StoreBusinessUtils.SaveOperationLog("103", "班次:" + handOverTicket.ShiftNo);
////关闭当前秤
//MsgEvent.Send(Constant.CURRENTSTEELYARD_STATUS_CHANGE, "close");
////两秒退出系统
//System.Threading.Thread.Sleep(2000);
//OnCloseTouchClick(sender, e);
////交班后重启收银程序
//Global.Instance.Restart = true;
//Application.ExitThread();
while ( splitPayFinished | | DateTime . Now . Minute > shiftDateTime . AddMinutes ( 20 ) . Minute )
{
if ( splitPayFinished )
{
LOGGER . Info ( "交接班分账,splitPayFinished=true" ) ;
}
else if ( DateTime . Now . Minute > shiftDateTime . AddMinutes ( 20 ) . Minute )
{
LOGGER . Info ( "交接班分账,超出规定分账时长<20>分钟" ) ;
}
splitPayFinished = false ;
shiftDateTime = shiftDateTime . AddMinutes ( 100 ) ;
//刷新界面???
//交班打印
@ -1298,7 +1345,7 @@ namespace POSV.Shift
//交班后重启收银程序
Global . Instance . Restart = true ;
Application . ExitThread ( ) ;
}
}
}
catch ( Exception ex )
@ -1309,7 +1356,7 @@ namespace POSV.Shift
{
button . Enabled = true ;
}
# endregion
}
private void OnControlBoxKeyboardClick ( object sender , EventArgs e )
@ -1350,6 +1397,15 @@ namespace POSV.Shift
private void SplitHandle ( object sender , EventArgs e )
{
var sDate = DateTime . Now . ToString ( "yyyy-MM-dd 00:00:00" ) ;
var eDate = DateTime . Now . AddDays ( 1 ) . ToString ( "yyyy-MM-dd 00:00:00" ) ;
var count = 0 ;
using ( var db = Global . Instance . OpenDataBase )
{
count = db . Query < OrderObject > ( $"where isSplited = 0 and finishDate between '{sDate}' and '{eDate}';" ) . Count ( ) ;
}
splitFrm . ProgressBar1 . Maximum = count * 2 * 3 ;
splitFrm . Show ( this ) ;
splitFrm . setPos ( 0 ) ; //设置进度条位置0%
@ -1358,13 +1414,14 @@ namespace POSV.Shift
if ( isException )
{
LOGGER . Info ( $"↓↓↓日订单[{DateTime.Now.ToString(" yyyy - MM - dd ")}]转分账数据失败↓↓↓" ) ;
DialogForm dialog = new DialogForm ( "提示信息" , $"日订单[{DateTime.Now.ToString(" yyyy - MM - dd ")}]数据处理失败" ) ;
dialog . Show ( ) ;
//DialogForm dialog = new DialogForm("提示信息", $"日订单[{DateTime.Now.ToString("yyyy-MM-dd")}]数据处理失败") ;
//dialog.Show() ;
}
splitFrm . setPos ( 20 ) ; //设置进度条位置0%
//splitFrm.setPos(200);//设置进度条位置0%
splitFrm . setPos ( count * 2 ) ; //设置进度条位置0%
#region 上传分账记录
var result1 = SplitPayUtils . Instance . SplitData2Server ( DateTime . Now );
var result1 = SplitPayUtils . Instance . SplitData2Server ( DateTime . Now , count * 2 );
if ( result1 . Item1 )
{
LOGGER . Info ( $"↓↓↓日订单[{DateTime.Now.ToString(" yyyy - MM - dd ")}]分账数据上传完成完成↓↓↓" ) ;
@ -1372,144 +1429,22 @@ namespace POSV.Shift
else
{
LOGGER . Info ( $"↓↓↓日订单[{DateTime.Now.ToString(" yyyy - MM - dd ")}]分账数据上传完成失败↓↓↓" ) ;
DialogForm dialog = new DialogForm ( "提示信息" , $"日订单[{DateTime.Now.ToString(" yyyy - MM - dd ")}]数据上传失败" ) ;
dialog . Show ( ) ;
//DialogForm dialog = new DialogForm("提示信息", $"日订单[{DateTime.Now.ToString("yyyy-MM-dd")}]数据上传失败") ;
//dialog.Show() ;
}
splitFrm . setPos ( 100 ) ; //设置进度条位置0%
//splitFrm.setPos(1000);//设置进度条位置0%
splitFrm . setPos ( count * 2 + count * 3 ) ; //设置进度条位置0%
Thread . Sleep ( 100 ) ;
splitFrm . Close ( ) ;
# endregion
//#region 交接班
//if (Global.Instance.GlobalConfigBoolValue(ConfigConstant.CONFIG_CASHIER_ISVERIFICATIONORDER))
//{
// int _count = 0;
// //核销提示
// using (var db = Global.Instance.OpenDataBase)
// {
// using (var transaction = db.GetTransaction())
// {
// string querySql = "select * from pos_saoma_pay_ticket where payStatus ='{0}'";
// querySql = string.Format(querySql, 0);
// _count = db.Query<SaomaPayTicket>(querySql).Count();
// }
// }
// if (_count > 0)
// {
// DialogForm dialog = new DialogForm("操作提醒", "您有未核销订单,是否继续交班?", MessageBoxIcon.Warning, MessageBoxButtons.OKCancel);
// if (DialogResult.OK != dialog.ShowDialog())
// {
// return;
// }
// }
//}
//if (handOverTicket != null)
//{
// decimal handsMoney = 0.00M;
// decimal difMoney = 0.00M;
// string shiftNo = OrderUtils.Instance.GenerateShiftNo();
// handOverTicket.Id = IdWorkerUtils.Instance.NextId();
// handOverTicket.No = shiftNo;
// handOverTicket.Memo = memoTextBox.Text;
// handOverTicket.ShiftNo = Global.Instance.BusinessPlanLog.No;
// if (handOverTicket.Detail != null)
// {
// foreach (HandOverDetail handOverDetail in handOverTicket.Detail)
// {
// handOverDetail.Id = IdWorkerUtils.Instance.NextId();
// handOverDetail.TenantId = handOverTicket.TenantId;
// handOverDetail.BusNo = handOverTicket.No;
// handOverDetail.PosNo = Global.Instance.Authc.PosNo;
// handOverDetail.DeviceIp = DeviceUtils.Instance.IPAddress;
// handOverDetail.DeviceMac = DeviceUtils.Instance.MacAddress;
// handOverDetail.DeviceName = DeviceUtils.Instance.ComputerName;
// handOverDetail.HandsMoney = handOverDetail.SumMoney;
// if ("01".Equals(handOverDetail.PayModeNo))
// {
// handsMoney = handOverDetail.SumMoney + handOverTicket.Inmoney - handOverTicket.Outmoney;
// //人民币金额计算方式
// handOverDetail.HandsMoney = handsMoney;
// difMoney = 0.00M;
// }
// handOverDetail.StoreId = handOverTicket.StoreId;
// handOverDetail.TicketId = handOverTicket.Id;
// }
// }
// if (handOverTicket.Pay != null)
// {
// foreach (HandOverPay handOverPay in handOverTicket.Pay)
// {
// handOverPay.Id = IdWorkerUtils.Instance.NextId();
// handOverPay.TenantId = handOverTicket.TenantId;
// handOverPay.BusNo = handOverTicket.No;
// handOverPay.PosNo = Global.Instance.Authc.PosNo;
// handOverPay.DeviceIp = DeviceUtils.Instance.IPAddress;
// handOverPay.DeviceMac = DeviceUtils.Instance.MacAddress;
// handOverPay.DeviceName = DeviceUtils.Instance.ComputerName;
// handOverPay.StoreId = handOverTicket.StoreId;
// handOverPay.TicketId = handOverTicket.Id;
// }
// }
// saveHandOver(handOverTicket);
// var uploadObject = new UploadHandoverObject();
// uploadObject.Id = IdWorkerUtils.Instance.NextId();
// uploadObject.TenantId = this.handOverTicket.TenantId;
// uploadObject.TradeNo = this.handOverTicket.No;
// uploadObject.SyncStatus = 0;
// uploadObject.HandOverTicket = this.handOverTicket;
// uploadObject.PrintStatus = HandOverPrintStatus.WAIT;
// uploadObject.UploadErrors = 0;
// uploadObject.PrintTimes = 0;
// saveHandOverObject(uploadObject);
// //有要上传的数据
// LOGGER.Info("有需要上传的交班数据,isHaveUpLoadShift=true");
// Global.isHaveUpLoadShift = true;
// //刷新界面???
// //交班打印
// this.ShowToastNotify(this, "开始打印");
// //构建收银小票模版参数
// handOverTicket.PrintType = "";
// handOverTicket.handMoney = handsMoney;//手工金额
// handOverTicket.diffMoney = difMoney;//差异金额
// bool ShiftPrint = Global.Instance.GlobalConfigBoolValue(ConfigConstant.CONFIG_CASHIER_SHIFPRINT, false);
// LOGGER.Info("-------------------构建小票参数------------------------------");
// LOGGER.Info(JsonUtils.Serialize(this.handOverTicket));
// var vars = ShiftHelper.BuilderTicketVariable(handOverTicket, ShiftPrint, false);
// LOGGER.Info("-------------------------------------------------");
// //交班开钱箱
// bool openCashbox = false;
// if (Global.Instance.GlobalConfigBoolValue(ConfigConstant.CONFIG_CASHIER_ISSHIFTOPENCASH))
// {
// openCashbox = Global.Instance.GlobalConfigBoolValue(ConfigConstant.CONFIG_CASHIER_ISSHIFTOPENCASH);
// }
// Tuple<bool, string> result = ShiftHelper.PrinterTicket("交班汇总", vars, true, openCashbox);
// this.ShowToastNotify(this, string.Format("{0}", result.Item2));
// //是否交班
// Global.isHandOver = false;
// StoreBusinessUtils.SaveOperationLog("103", "班次:" + handOverTicket.ShiftNo);
// //关闭当前秤
// MsgEvent.Send(Constant.CURRENTSTEELYARD_STATUS_CHANGE, "close");
// //两秒退出系统
// System.Threading.Thread.Sleep(2000);
// OnCloseTouchClick(sender, e);
// //交班后重启收银程序
// Global.Instance.Restart = true;
// Application.ExitThread();
MsgEvent . Send ( Constant . SPLITPAY_UPLOAD_FINISHED , true ) ;
# endregion
}
//}
//#endregion
protected virtual void SplitPayFinishEventNotify ( object sender , MsgEventArgs args )
{
splitPayFinished = true ;
LOGGER . Info ( "交接班分账完成" ) ;
}
# endregion
}