播报+打印改为异步+日志+length=1+解决启动报错的问题+小程序订单查询和确认失败后再次确认一次+交接班+注释部分日志打印

main
subin 8 months ago
parent 8feb6d865a
commit 6b90aa5fda

Binary file not shown.

@ -268,7 +268,15 @@ namespace POSV
/// </summary>
public static string ORDER_PAYMENT_ERROR_GENERATENO = "orderpayerror:generateticketno";
/// <summary>
/// 分账上传进度
/// </summary>
public static string SPLITPAY_UPLOAD_PROGRESS = "splitpay:uploadprogress";
/// <summary>
/// 分账完成
/// </summary>
public static string SPLITPAY_UPLOAD_FINISHED = "splitpay:uploadfinish";
#endregion
/// <summary>

@ -63,7 +63,7 @@ namespace POSV.Job
}
foreach (var order in waitUpload)
{
logger.Info("订单同步到服务中心成功,isHaveCenterTicket=true");
logger.Info($"订单[{order.TradeNo}]同步到服务中心成功,isHaveCenterTicket=true");
UploadSCNewOrder.UploadNewOrder2SC4KDS(order.TradeNo);
}
}

@ -668,7 +668,7 @@ namespace POSV.ShoppingCart
/// <param name="orderObject"></param>
public void OrderObjectCheck(OrderObject orderObject)
{
logger.Info(JsonUtils.Serialize(orderObject));
//logger.Info(JsonUtils.Serialize(orderObject));
int itemGroupCount = orderObject.Items.GroupBy(x => x.Id).ToList().Count;//订单明细数量
int itemCount = orderObject.Items.Count();//订单明细数量
if (itemGroupCount != itemCount)

@ -111,7 +111,8 @@ namespace POSV.Utils
try
{
logger.Info("请求参数:{0}", JsonUtils.Serialize(parameters));
//20240203 subin 注释掉
//logger.Info("请求参数:{0}", JsonUtils.Serialize(parameters));
var stringParams = new Func<IDictionary<string, string>, string>((dic) =>
{

@ -131,7 +131,7 @@ namespace POSV.Utils
{
connected = false;
}
logger.Info("检测服务中心是否通畅耗时<{0}>", watch.ElapsedMilliseconds);
logger.Info("检测服务中心是否通畅[{0}]耗时<{1}>", connected, watch.ElapsedMilliseconds);
}
catch (Exception ex)
{

@ -42,14 +42,12 @@ namespace POSV.Utils
public bool SaveSplitPayInfo(OrderObject orderObject)
{
Stopwatch sw = new Stopwatch();
sw.Start();
logger.Info($"开始保存订单<{orderObject.TradeNo}>的分账信息");
var isExist = false;
try
{
sw.Start();
logger.Info($"开始保存订单<{orderObject.TradeNo}>的分账信息");
var _pid = IdWorkerUtils.Instance.NextId();
using (var db = Global.Instance.OpenDataBase)
{
@ -398,8 +396,8 @@ namespace POSV.Utils
#endregion
}
}
}
logger.Info($"完成保存订单<{orderObject.TradeNo}>的分账信息");
}
catch (Exception ex)
{
@ -410,7 +408,7 @@ namespace POSV.Utils
{
sw.Stop();
logger.Info($"保存订单<{orderObject.TradeNo}的分账信息时长<{sw.ElapsedMilliseconds}>");
logger.Info($"保存订单<{orderObject.TradeNo}>的分账信息时长<{sw.ElapsedMilliseconds}>");
}
@ -649,7 +647,8 @@ namespace POSV.Utils
}
trans.Complete();
logger.Info($"退款成功后更新本地分账信息成功json" + JsonUtils.Serialize(updateData));
//logger.Info($"退款成功后更新本地分账信息成功json" + JsonUtils.Serialize(updateData));
logger.Info($"退款成功后,更新本地分账信息:成功");
}
}
}
@ -675,11 +674,13 @@ namespace POSV.Utils
var result = api.UpdateSplitPay(entity);
if (result.Item1)
{
logger.Info($"退款成功后更新服务端原分账信息成功json" + JsonUtils.Serialize(entity));
//logger.Info($"退款成功后更新服务端原分账信息成功json" + JsonUtils.Serialize(entity));
logger.Info($"退款成功后,更新服务端原分账信息:成功。");
}
else
{
logger.Info($"退款成功后更新服务端原分账信息失败json" + JsonUtils.Serialize(entity));
//logger.Info($"退款成功后更新服务端原分账信息失败json" + JsonUtils.Serialize(entity));
logger.Info($"退款成功后,更新服务端原分账信息:失败。");
}
Thread.Sleep(100);
@ -706,7 +707,7 @@ namespace POSV.Utils
logger.Info($"开始日订单[{date.ToString("yyyy-MM-dd")}]的分账信息存储处理...");
var proValue = 0;
var proMaxValue = 20;
var proMaxValue = 400;
Stopwatch sw = new Stopwatch();
sw.Start();
@ -718,7 +719,10 @@ namespace POSV.Utils
var pays = new List<PayItem>();
//支付方式分摊明细
var itemPays = new List<OrderItemPay>();
var index = 0;
try
{
while (index < 2)
{
using (var db = Global.Instance.OpenDataBase)
{
@ -728,6 +732,7 @@ namespace POSV.Utils
count = db.Query<OrderObject>($"where isSplited = 0 and finishDate between '{sDate}' and '{eDate}';").Count();
//主单数据
//lists = db.Query<OrderObject>("where syncStatus = 0 and uploadErrors < 3000 order by uploadErrors limit @0;", 1).ToList();
var tmpPress = proMaxValue / 2 / count == 0 ? 1 : proMaxValue / 2 / count;
var pageCount = count % pageSize != 0 ? (count / pageSize) + 1 : count / pageSize;
@ -735,12 +740,12 @@ namespace POSV.Utils
var sqlList = new ConcurrentQueue<string>();
for (int i = 0; i < pageCount; i++)
{
logger.Info($"日订单[{date.ToString("yyyy-MM-dd")}],分账第<{i + 1}>页订单数据");
logger.Info($"日订单[{date.ToString("yyyy-MM-dd")}],分账[index:{index + 1}]第<{i + 1}>页订单数据");
lists = db.Query<OrderObject>($"where isSplited = 0 and finishDate between '{sDate}' and '{eDate}' limit ({i * pageSize}), {pageSize};").ToList();
var ids = string.Join("','", lists.ConvertAll(x => x.Id).ToArray());
var nos = string.Join("','", lists.ConvertAll(x => x.TradeNo).ToArray());
logger.Info($"日订单[{date.ToString("yyyy-MM-dd")}],分账第<{i + 1}>页订单数据:{nos}");
logger.Info($"日订单[{date.ToString("yyyy-MM-dd")}],分账[index:{index + 1}]第<{i + 1}>页订单数据:{nos}");
var condition = " where orderId in ('" + ids + "');";
//单据明细
@ -767,6 +772,7 @@ namespace POSV.Utils
if (lists.Count > 0)
{
var p = 0;
foreach (var orderObject in lists)
{
logger.Info($"日订单[{date.ToString("yyyy-MM-dd")}]<{orderObject.TradeNo}>分账信息处理...");
@ -783,25 +789,34 @@ namespace POSV.Utils
}
Thread.Sleep(100);
//if (proValue < proMaxValue / (2 - index))
// proValue = (proMaxValue / (2 - index) * index) + tmpPress * ((p + 1) + pageSize * i);
proValue++;
MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, proValue);
p++;
}
}
else
{
logger.Info($"日订单[{date.ToString("yyyy-MM-dd")}],第<{i + 1}>页订单数据无可分账数据");
logger.Info($"日订单[{date.ToString("yyyy-MM-dd")}],[index:{index + 1}]第<{i + 1}>页订单数据无可分账数据");
//proValue = pageSize * (i + 1);
//if (proValue < proMaxValue / (2 - index))
//{
// MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, proValue);
//}
//else
//{
// MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, proMaxValue / (2 - index));
//}
proValue = count * (index + 1);
MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, proValue);
}
if (i > proMaxValue)
{
proValue = 20;
}
else
{
proValue = i;
}
MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, proValue);
}
SqliteUtils.ExecuteTransaction(sqlList);
index++;
}
}
}
catch (Exception ex)
@ -814,32 +829,37 @@ namespace POSV.Utils
sw.Stop();
logger.Info("日订单<{0}>的分账信息存储结束<{1}>", count, sw.ElapsedMilliseconds);
MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, proMaxValue);
MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, count * 2);
}
return isException;
}
}
public Tuple<bool, string> SplitData2Server(DateTime date)
public Tuple<bool, string> SplitData2Server(DateTime date, int proIndexValue = 0)
{
Tuple<bool, string> result = null;
var sDate = date.ToString("yyyy-MM-dd 00:00:00");
var eDate = date.AddDays(1).ToString("yyyy-MM-dd 00:00:00");
logger.Info($"开始日订单[{date.ToString("yyyy-MM-dd")}]的分账信息上传...");
var pageSize = 10;
var pageSize = 1500;
Stopwatch sw = new Stopwatch();
sw.Start();
int index = 0;
MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, 25);
//proIndexValue = 401;
var proValue = proIndexValue;
MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, proValue);
var proValue = 24;
var proMaxValue = 990;
var flg = false;
var tmpPress = 0;
lock (Global.Instance.SyncLock)
{
while (index < 3)
{
tmpPress = proIndexValue + (proMaxValue - proIndexValue) / (3 - index);
var icount = 0;
var count = 0;
var total = 0;
@ -853,19 +873,7 @@ namespace POSV.Utils
if (count > 0)
{
var pageCount = count % pageSize != 0 ? count / pageSize + 1 : count / pageSize;
var spp = 1;
if (pageCount > 0 && pageCount == proValue)
{
spp = 1;
}
else if (pageCount > 0 && pageCount <= 6)
{
spp = 4;
}
else if (pageCount > 7 && pageCount <= 12)
{
spp = 2;
}
//tmpPress = tmpPress / count == 0 ? 1 : tmpPress / count;
for (int i = 0; i < pageCount; i++)
{
@ -874,14 +882,13 @@ namespace POSV.Utils
var pSplitLst = db.Query<SplitStorePay>(condition).ToList();
var list = new ConcurrentQueue<string>();
int j = 0;
foreach (var item in pSplitLst)
{
StringBuilder strBil = new StringBuilder();
strBil.Append("select ord.ticketId as ordTicketId,ord.tableNo,ord.people,ord.workerNo,oi.price as unitPrice,oi.productId as goodid,ssp.* from pos_split_store_pay ssp ");
strBil.Append("left join pos_order_item oi on oi.id=ssp.orderItemId and oi.productId=ssp.productId ");
strBil.Append("left join pos_order ord on ord.id=ssp.orderId ");
strBil.Append("where ssp.pid={0};");
strBil.Append("where ssp.pid='{0}';");
string sql = string.Format(strBil.ToString(), item.Id);
var lists = db.Query<SplitStorePayEntity>(sql);
var succLst = new List<SplitStorePayEntity>();
@ -951,13 +958,15 @@ namespace POSV.Utils
list.Enqueue(strPSql);
logger.Info($"分账信息第<{index + 1}>次上传,日订单[{date.ToString("yyyy-MM-dd")}]<{item.BusNo}>明细的分账信息上传操作失败");
}
j++;
Thread.Sleep(100);
}
}
proValue += spp;
//if (proValue < tmpPress)
// proValue++;
//MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, proValue);
proValue++;
MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, proValue);
}
SqliteUtils.ExecuteTransaction(list);
}
}
@ -972,17 +981,21 @@ namespace POSV.Utils
{
flg = false;
logger.Error(ex, $"分账信息第<{index + 1}>次上传,日订单[{date.ToString("yyyy-MM-dd")}]的分账信息上传错误");
//MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, proMaxValue / 3 * index);
}
finally
{
sw.Stop();
logger.Info($"分账信息第<{index + 1}>次上传,日订单<{count}>条,应上传明细<{total}>条,实传<{icount}>条,时长<{sw.ElapsedMilliseconds}>");
var pressValue = count == 0 ? proValue * (index + 1) : proValue;
MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, pressValue);
//var pressValue = count == 0 ? proValue * (index + 1) : proValue;
//MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, tmpPress);
proValue = proIndexValue + count * (index + 1);
MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, proValue);
index++;
}
}
MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, 100);
//MsgEvent.Send(Constant.SPLITPAY_UPLOAD_PROGRESS, 1000);
if (!flg)
{

@ -176,6 +176,8 @@ namespace POSV.Utils
}
private void ReconnectTimerCallback(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
//already open or openning
if (this._websocket.State == WebSocketState.Connecting || this._websocket.State == WebSocketState.Open)
@ -183,10 +185,18 @@ namespace POSV.Utils
return;
}
logger.Info("尝试连接服务中心……");
StartConnect();
}
catch (Exception ex)
{
logger.Error(ex, "连接服务中心错误");
}
}
}
}

@ -8856,6 +8856,10 @@ namespace POSV
if (!string.IsNullOrEmpty(outTradeNo))
{
this._orderObject.TradeNo = outTradeNo;
foreach (var item in this._orderObject.Items)
{
item.TradeNo = this._orderObject.TradeNo;
}
}
else
{
@ -8867,6 +8871,10 @@ namespace POSV
if (ticket.Item1)
{
this._orderObject.TradeNo = ticket.Item3;
foreach (var item in this._orderObject.Items)
{
item.TradeNo = this._orderObject.TradeNo;
}
}
//重新判断是否获取到单号
@ -8896,6 +8904,10 @@ namespace POSV
if (DialogResult.Yes == dialog.ShowDialog())
{
this._orderObject.TradeNo = OrderUtils.Instance.GenerateTicketNo();
foreach (var item in this._orderObject.Items)
{
item.TradeNo = this._orderObject.TradeNo;
}
}
else
{
@ -8908,6 +8920,10 @@ namespace POSV
if (isLocalTicketNo)
{
this._orderObject.TradeNo = OrderUtils.Instance.GenerateTicketNo();
foreach (var item in this._orderObject.Items)
{
item.TradeNo = this._orderObject.TradeNo;
}
}
else
{

@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using uPLibrary.Networking.M2Mqtt;
using uPLibrary.Networking.M2Mqtt.Messages;
@ -59,7 +60,8 @@ namespace POSV.Proxy.Mqtt
//2022-12-13 11:06 zhangy Edit 更换IP地址为域名
this.mqttClient = new MqttClient("mqtt.ffcygl.com", 18830, false, null, null, MqttSslProtocols.None);
//this.mqttClient = new MqttClient("mqtt.ffcygl.com", 18830, false, null, null, MqttSslProtocols.None);
this.mqttClient = new MqttClient("csmqtt.ffcygl.com", 18830, false, null, null, MqttSslProtocols.None);
//this.mqttClient = new MqttClient("127.0.0.1", 1883, false, null, null, MqttSslProtocols.None);
@ -165,8 +167,13 @@ namespace POSV.Proxy.Mqtt
logger.Info("收到巨为小程序订单");
JuWeiAppOrderProxy.sendJwWeixinMessage(message);
OnMessageReceived?.Invoke(sender, new MessageEventArgs(0, message));
//Task.Factory.StartNew(() =>
//{
// JuWeiAppOrderProxy.sendJwWeixinMessage(message);
// OnMessageReceived?.Invoke(sender, new MessageEventArgs(0, message));
//});
}
if (topic.StartsWith("waimai"))

@ -25,6 +25,10 @@ namespace POSV.Proxy.ThirdPartyOrder
public JuWeiAppOrderProxy()
{
if (LOGGET == null)
{
LOGGET = NLog.LogManager.GetLogger(GetType().FullName);
}
}
#region API
@ -213,7 +217,7 @@ namespace POSV.Proxy.ThirdPartyOrder
LOGGET.Info("小程序点餐_门店信息请求:" + JsonUtils.Serialize(parameters));
string response = HttpClientUtils.PostAsync(api, api.Url, parameters);
LOGGET.Info("小程序点餐_门店信息接收:" + response);
//LOGGET.Info("小程序点餐_门店信息接收:" + response);
//获取成功
if (Constant.IsSuccessful(response))
{
@ -268,9 +272,9 @@ namespace POSV.Proxy.ThirdPartyOrder
var ignoreParameters = new List<string>();
parameters.Add("sign", OpenApiUtils.Instance.Sign(api, parameters, ignoreParameters));
LOGGET.Info("小程序点餐_门店开停业_请求:" + _isopen + JsonUtils.Serialize(parameters));
//LOGGET.Info("小程序点餐_门店开停业_请求:" + _isopen + JsonUtils.Serialize(parameters));
string response = HttpClientUtils.PostAsync(api, api.Url, parameters);
LOGGET.Info("小程序点餐_门店开停业_接收:" + _isopen + response);
//LOGGET.Info("小程序点餐_门店开停业_接收:" + _isopen + response);
//获取成功
if (Constant.IsSuccessful(response))
{
@ -319,7 +323,7 @@ namespace POSV.Proxy.ThirdPartyOrder
parameters.Add("sign", OpenApiUtils.Instance.Sign(api, parameters, ignoreParameters));
LOGGET.Info("小程序点餐_门店开业_请求:" + JsonUtils.Serialize(parameters));
string response = HttpClientUtils.PostAsync(api, api.Url, parameters);
LOGGET.Info("小程序点餐_门店开业_接收:" + response);
//LOGGET.Info("小程序点餐_门店开业_接收:" + response);
//获取成功
if (Constant.IsSuccessful(response))
{
@ -421,7 +425,7 @@ namespace POSV.Proxy.ThirdPartyOrder
LOGGET.Info("小程序点餐_配送信息请求:" + JsonUtils.Serialize(parameters));
string response = HttpClientUtils.PostAsync(api, api.Url, parameters);
LOGGET.Info("小程序点餐_配送信息接收:" + response);
//LOGGET.Info("小程序点餐_配送信息接收:" + response);
//获取成功
if (Constant.IsSuccessful(response))
{
@ -471,7 +475,7 @@ namespace POSV.Proxy.ThirdPartyOrder
parameters.Add("sign", OpenApiUtils.Instance.Sign(api, parameters, ignoreParameters));
LOGGET.Info("小程序点餐_请求内容:" + JsonUtils.Serialize(parameters));
string response = HttpClientUtils.PostAsync(api, api.Url, parameters);
LOGGET.Info("小程序点餐_订单内容:" + response);
//LOGGET.Info("小程序点餐_订单内容:" + response);
//获取成功
if (Constant.IsSuccessful(response))
{
@ -542,7 +546,7 @@ namespace POSV.Proxy.ThirdPartyOrder
parameters.Add("sign", OpenApiUtils.Instance.Sign(api, parameters, ignoreParameters));
LOGGET.Info("小程序点餐_订单" + orderOperationType + "_请求:" + JsonUtils.Serialize(parameters));
string response = HttpClientUtils.PostAsync(api, api.Url, parameters);
LOGGET.Info("小程序点餐_订单" + orderOperationType + "_接收:" + response);
//LOGGET.Info("小程序点餐_订单" + orderOperationType + "_接收:" + response);
//获取成功
if (Constant.IsSuccessful(response))
{
@ -605,7 +609,7 @@ namespace POSV.Proxy.ThirdPartyOrder
LOGGET.Info("小程序点餐_订单列表 是否待处理" + _isHandle + "请求:" + JsonUtils.Serialize(parameters));
string response = HttpClientUtils.PostAsync(api, api.Url, parameters);
LOGGET.Info("小程序点餐_订单列表 是否待处理" + _isHandle + "接收:" + response);
//LOGGET.Info("小程序点餐_订单列表 是否待处理" + _isHandle + "接收:" + response);
//获取成功
if (Constant.IsSuccessful(response))
@ -704,6 +708,16 @@ namespace POSV.Proxy.ThirdPartyOrder
try
{
var _data = this.Program_Order_Query_Bybusno(Global.Instance.Authc.StoreId, busNo);
if (_data != null && _data.Item1 == false)
{
if (_data.Item2.Equals("小程序点餐_订单详情,请检测网络连接"))
{
LOGGET.Info($"第二次小程序订单查询<{busNo}>");
_data = this.Program_Order_Query_Bybusno(Global.Instance.Authc.StoreId, busNo);
}
}
if (_data != null && _data.Item1)
{
return new Tuple<bool, string, ProgramOrderQueryBybusnoData>(_data.Item1, _data.Item2, _data.Item3.Data);
@ -760,6 +774,15 @@ namespace POSV.Proxy.ThirdPartyOrder
var _data = this.Program_Order_Confirm(orderOperationType, Global.Instance.Authc.StoreId, busNo);
LOGGET.Info("订单状态结果:<{0},{1}>", (_data != null && _data.Item1), _data.Item3 != null && _data.Item3.Data != null);
if (_data != null && _data.Item1 == false)
{
if (_data.Item2.Equals("小程序点餐_订单接单,请检测网络连接"))
{
LOGGET.Info("第二次修改订单状态:<{0},{1}>", busNo, orderOperationType.ToString());
_data = this.Program_Order_Confirm(orderOperationType, Global.Instance.Authc.StoreId, busNo);
}
}
if (_data != null && _data.Item1)
{
return new Tuple<bool, string, ProgramOrderConfirmData>(_data.Item1, _data.Item2, _data.Item3.Data);
@ -1049,7 +1072,8 @@ namespace POSV.Proxy.ThirdPartyOrder
}
else
{
LOGGET.Error("订单保存或者补单操作失败,原因:本地单号<" + orderObject.TradeNo + ">重复!,订单内容:" + JsonUtils.Serialize(orderObject));
//LOGGET.Error("订单保存或者补单操作失败,原因:本地单号<" + orderObject.TradeNo + ">重复!,订单内容:" + JsonUtils.Serialize(orderObject));
LOGGET.Error("订单保存或者补单操作失败,原因:本地单号<" + orderObject.TradeNo + ">重复!");
return new Tuple<bool, string, string>(false, "订单保存失败", "已成功补入 0 单");
}
@ -1688,8 +1712,13 @@ namespace POSV.Proxy.ThirdPartyOrder
/// </summary>
public static void sendJwWeixinMessage(string message)
{
if (LOGGET == null)
{
LOGGET = NLog.LogManager.GetLogger("JuWeiAppOrderProxy");
}
try
{
LOGGET.Info("巨为微信小程序接单开始");
//微信小程序订单是否开启自动接单
bool openConfirm = Global.Instance.GlobalConfigBoolValue(ConfigConstant.WEIXIN_CONFIRM_PARAMETER, false);
@ -1733,9 +1762,16 @@ namespace POSV.Proxy.ThirdPartyOrder
//自动接单处理
if (orderIds.Length > 0)
{
LOGGET.Info("巨为小程序订单Length>0");
}
//20240129 subin 改为只处理服务端返回为一条订单的小程序订单
if (orderIds.Length == 1)
{
LOGGET.Info($"巨为小程序订单Length={orderIds.Length}");
var _len = orderIds.Length;
foreach (var item in orderIds)
{
LOGGET.Info($"巨为小程序订单进入自动接单<{item}>开始");
if (string.IsNullOrEmpty(item))
{
LOGGET.Info("订单编号为空,忽略");
@ -1743,11 +1779,20 @@ namespace POSV.Proxy.ThirdPartyOrder
}
// 播放声音
SoundUtils.PlaySound("weixin");
LOGGET.Info("巨为小程序订单播放声音,通知自动接单");
#region 播放声音
//SoundUtils.PlaySound("weixin");
//LOGGET.Info($"巨为小程序订单<{item}>播放声音,通知自动接单");
//20240129 subin 改为异步播放
Task.Factory.StartNew(() =>
{
SoundUtils.PlaySound("weixin");
LOGGET.Info($"巨为小程序订单<{item}>播放声音,通知自动接单");
});
#endregion
//请求接口查询订单
LOGGET.Info($"巨为小程序请求接口查询订单<{item}>");
var _order = _juWeiAppOrderProxy.GetOrder(item);
if (_order == null)
@ -1821,19 +1866,24 @@ namespace POSV.Proxy.ThirdPartyOrder
var _orderdata = getOrderLocalJuWeiOrder(_order.Item3);
if (_orderdata != null)
{
LOGGET.Info("巨为小程序自动接单,开始保存数据....");
var _intder = _juWeiAppOrderProxy.InsertOrder(_orderdata);
if (_intder.Item1)
{
LOGGET.Info("巨为小程序自动接单,数据保存成功,开始打印小票....");
#region 打印小票
LOGGET.Info($"巨为小程序自动接单<{item}>,数据保存成功,开始打印小票....");
//JuWeiAppOrderProxy.PrintOrder(_orderdata);
//20240129 subin 改为异步打印
Task.Factory.StartNew(() =>
{
JuWeiAppOrderProxy.PrintOrder(_orderdata);
});
#endregion
#region subin 20230916 订单保存成功后处理分账明细
LOGGET.Info("巨为小程序自动接单,数据保存成功,开始保存分账明细....");
//LOGGET.Info("巨为小程序自动接单,数据保存成功,开始保存分账明细....");
//JuWeiAppOrderProxy.DoSplitOrder(_orderdata);
//Task.Factory.StartNew(() =>
//{
@ -1858,6 +1908,7 @@ namespace POSV.Proxy.ThirdPartyOrder
Thread.Sleep(100);
LOGGET.Info($"巨为小程序订单进入自动接单<{item}>结束");
}
}
}
@ -1872,7 +1923,7 @@ namespace POSV.Proxy.ThirdPartyOrder
LOGGET.Error(ex, "巨为小程序自动接单发生异常");
}
LOGGET.Info("巨为微信小程序接单结束");
}
public static Tuple<bool, string> DoRefund(string tradeNo)
@ -2221,7 +2272,7 @@ namespace POSV.Proxy.ThirdPartyOrder
if (splitStorePayLst.Count() > 0)
{
db.InsertBatch<SplitStorePay>(splitStorePayLst);
LOGGET.Info($"保存订单的分账信息:{JsonUtils.Serialize(splitStorePayLst)}");
//LOGGET.Info($"保存订单的分账信息:{JsonUtils.Serialize(splitStorePayLst)}");
LOGGET.Info("有需要上传的营业分账数据,isHaveUpLoadSplitPay = true");
Global.isHaveUpLoadSplitPay = true;
}

@ -372,17 +372,29 @@ namespace POSV.Bill
if (ticket.Item1)
{
this._orderObject.TradeNo = ticket.Item3;
LOGGER.Info($"订单支付失败,重新生成订单号,原单号:[{Global.Instance.BusinessPlanLog.StoreNo}_{oldTradeNo}]==>新单号:[{Global.Instance.BusinessPlanLog.StoreNo}_{_orderObject.TradeNo}]......开始");
foreach (var item in this._orderObject.Items)
{
item.TradeNo = this._orderObject.TradeNo;
LOGGER.Info($"订单支付失败,原订单[{oldTradeNo}]商品<{item.ShortName}:{item.Id}>,重置订单号:{_orderObject.TradeNo}");
}
using (var db = Global.Instance.OpenDataBase)
{
//订单保存成功更新核销状态
LOGGER.Info($"订单支付失败,重新生成订单号,原单号:[{Global.Instance.BusinessPlanLog.StoreNo}_{oldTradeNo}]==>新单号:[{Global.Instance.BusinessPlanLog.StoreNo}_{_orderObject.TradeNo}]......开始");
string sql = "update pos_saoma_pay_ticket set orderNo ='{0}' where orderNo = '{1}'";
sql = string.Format(sql, string.Format("{0}_{1}", Global.Instance.BusinessPlanLog.StoreNo, _orderObject.TradeNo), string.Format("{0}_{1}", Global.Instance.BusinessPlanLog.StoreNo, oldTradeNo));
db.Execute(sql, null);
LOGGER.Info($"订单支付失败,重新生成订单号,原单号:[{Global.Instance.BusinessPlanLog.StoreNo}_{oldTradeNo}]==>新单号:[{Global.Instance.BusinessPlanLog.StoreNo}_{_orderObject.TradeNo}]......更新成功");
LOGGER.Info($"订单支付失败,重新生成订单号,原单号:[{Global.Instance.BusinessPlanLog.StoreNo}_{oldTradeNo}]==>新单号:[{Global.Instance.BusinessPlanLog.StoreNo}_{_orderObject.TradeNo}]......pos_saoma_pay_ticket更新成功");
//发送支付失败,重新生成订单号事件
MsgEvent.Send(Constant.ORDER_PAYMENT_ERROR_GENERATENO, _orderObject.TradeNo);
}
LOGGER.Info($"订单支付失败,重新生成订单号,原单号:[{Global.Instance.BusinessPlanLog.StoreNo}_{oldTradeNo}]==>新单号:[{Global.Instance.BusinessPlanLog.StoreNo}_{_orderObject.TradeNo}]......更新成功");
}
else
{

@ -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.00M;
@ -1260,11 +1262,56 @@ namespace POSV.Shift
#region subin 20231025 分账由实时改为交班时分账
splitFrm = new SplitPayUploadForm(0, 100);
splitFrm = new SplitPayUploadForm(0, 1000);
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
}

@ -38,6 +38,7 @@ namespace POSV.Shift
this.ProgressBar1.Dock = System.Windows.Forms.DockStyle.Top;
this.ProgressBar1.Location = new System.Drawing.Point(0, 0);
this.ProgressBar1.Margin = new System.Windows.Forms.Padding(6);
this.ProgressBar1.Maximum = 1000;
this.ProgressBar1.Name = "ProgressBar1";
this.ProgressBar1.Size = new System.Drawing.Size(534, 42);
this.ProgressBar1.TabIndex = 1;
@ -60,7 +61,7 @@ namespace POSV.Shift
//
// SplitPayUploadForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleDimensions = new System.Drawing.SizeF(14F, 31F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(534, 69);
this.Controls.Add(this.labelX1);

Loading…
Cancel
Save