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