@ -2247,134 +2247,177 @@ namespace djy.Paas.Service
foreach ( var ord in orderList )
{
var customerComp = DbBus . Get ( DbList . djyolddb )
_LogsAdd ( $"{ord.Gid} {ord.ShipOrderNo}" , "胜云航通自动扣费" , null ) ;
CustFee ( ord ) ;
}
}
}
}
/// <summary>
/// 报关扣费
/// </summary>
/// <param name="ord"></param>
/// <returns></returns>
public ReturnResult < string > CustFee ( tb_BaoGuanOrderList ord )
{
var rs = new ReturnResult < string > ( ) ;
rs . OK ( ) ;
var cfgDingtalk = DjyTools . GetConfigKey ( "baoguanDingtalkNotify" ) ;
var customerComp = DbBus . Get ( DbList . djyolddb )
. Select < CompanyNew > ( )
. Where ( x = > x . CompName = = ord . ClientName )
. ToOne ( ) ;
if ( customerComp = = null )
{
//推送钉钉消息给客服
var content = $"公司{ord.ClientName}提单号{ord.ShipOrderNo}未找到" ;
_LogsAdd ( content , "胜云航通自动扣费" , null ) ;
var gethtml = DjyTools . PostOnLogs ( new { text = new { content = $"【未扣费提醒】\r\n{content}\r\n----报关消息通知" } , msgtype = "text" } , cfgDingtalk , "胜云航通自动扣费" , YsPsotType . Json ) . Result ;
//设置状态
DbBus . Get ( DbList . djypublicedb ) . Update < tb_BaoGuanOrderList > ( )
. Where ( x = > x . Gid = = ord . Gid )
. Set ( x = > x . StaCustFee , "FAIL" )
. Set ( x = > x . TimeCustFee , DateTime . Now )
. ExecuteAffrows ( ) ;
continue ;
}
if ( customerComp = = null )
{
//推送钉钉消息给客服
var content = $"公司{ord.ClientName}提单号{ord.ShipOrderNo}未找到" ;
_LogsAdd ( content , "胜云航通扣费" , null ) ;
var gethtml = DjyTools . PostOnLogs ( new { text = new { content = $"【未扣费提醒】\r\n{content}\r\n----报关消息通知" } , msgtype = "text" } , cfgDingtalk , "胜云航通扣费" , YsPsotType . Json ) . Result ;
//设置状态
DbBus . Get ( DbList . djypublicedb ) . Update < tb_BaoGuanOrderList > ( )
. Where ( x = > x . Gid = = ord . Gid )
. Set ( x = > x . StaCustFee , "FAIL" )
. Set ( x = > x . TimeCustFee , DateTime . Now )
. ExecuteAffrows ( ) ;
rs . Not ( content ) ;
return rs ;
}
var balance = DbBus . Get ( DbList . djyolddb )
. Select < CustBalance > ( )
. Where ( x = > x . COMNAME = = customerComp . CompName )
. ToOne ( ) ;
var balance = DbBus . Get ( DbList . djyolddb )
. Select < CustBalance > ( )
. Where ( x = > x . COMNAME = = customerComp . CompName )
. ToOne ( ) ;
//没有钱包
if ( balance = = null )
{
//推送钉钉消息给客服
var content = $"公司{ord.ClientName}提单号{ord.ShipOrderNo}没有钱包" ;
_LogsAdd ( content , "胜云航通 自动 扣费", null ) ;
var gethtml = DjyTools . PostOnLogs ( new { text = new { content = $"【未扣费提醒】\r\n{content}\r\n----报关消息通知" } , msgtype = "text" } , cfgDingtalk , "胜云航通 自动 扣费", YsPsotType . Json ) . Result ;
//没有钱包
if ( balance = = null )
{
//推送钉钉消息给客服
var content = $"公司{ord.ClientName}提单号{ord.ShipOrderNo}没有钱包" ;
_LogsAdd ( content , "胜云航通 扣费", null ) ;
var gethtml = DjyTools . PostOnLogs ( new { text = new { content = $"【未扣费提醒】\r\n{content}\r\n----报关消息通知" } , msgtype = "text" } , cfgDingtalk , "胜云航通 扣费", YsPsotType . Json ) . Result ;
//设置状态
DbBus . Get ( DbList . djypublicedb ) . Update < tb_BaoGuanOrderList > ( )
. Where ( x = > x . Gid = = ord . Gid )
. Set ( x = > x . StaCustFee , "FAIL" )
. Set ( x = > x . TimeCustFee , DateTime . Now )
. ExecuteAffrows ( ) ;
//设置状态
DbBus . Get ( DbList . djypublicedb ) . Update < tb_BaoGuanOrderList > ( )
. Where ( x = > x . Gid = = ord . Gid )
. Set ( x = > x . StaCustFee , "FAIL" )
. Set ( x = > x . TimeCustFee , DateTime . Now )
. ExecuteAffrows ( ) ;
continue ;
}
rs . Not ( content ) ;
return rs ;
}
var price = DbBus . Get ( DbList . djyolddb )
. Select < CustPrice > ( )
. Where ( x = > x . COMNAME = = customerComp . CompName & & x . SENDTYPE = = 0 & & x . BSTYPE = = 13 )
. ToOne ( ) ;
var price = DbBus . Get ( DbList . djyolddb )
. Select < CustPrice > ( )
. Where ( x = > x . COMNAME = = customerComp . CompName & & x . SENDTYPE = = 0 & & x . BSTYPE = = 13 )
. ToOne ( ) ;
//未设置单价
if ( price = = null )
{
//推送钉钉消息给客服
var content = $"公司{ord.ClientName}提单号{ord.ShipOrderNo}的报关单价未设置" ;
var gethtml = DjyTools . PostOnLogs ( new { text = new { content = $"【未扣费提醒】\r\n{content}\r\n----报关消息通知" } , msgtype = "text" } , cfgDingtalk , "胜云航通 自动 扣费", YsPsotType . Json ) . Result ;
//未设置单价
if ( price = = null )
{
//推送钉钉消息给客服
var content = $"公司{ord.ClientName}提单号{ord.ShipOrderNo}的报关单价未设置" ;
var gethtml = DjyTools . PostOnLogs ( new { text = new { content = $"【未扣费提醒】\r\n{content}\r\n----报关消息通知" } , msgtype = "text" } , cfgDingtalk , "胜云航通 扣费", YsPsotType . Json ) . Result ;
//设置状态
DbBus . Get ( DbList . djypublicedb ) . Update < tb_BaoGuanOrderList > ( )
. Where ( x = > x . Gid = = ord . Gid )
. Set ( x = > x . StaCustFee , "FAIL" )
. Set ( x = > x . TimeCustFee , DateTime . Now )
. ExecuteAffrows ( ) ;
//设置状态
DbBus . Get ( DbList . djypublicedb ) . Update < tb_BaoGuanOrderList > ( )
. Where ( x = > x . Gid = = ord . Gid )
. Set ( x = > x . StaCustFee , "FAIL" )
. Set ( x = > x . TimeCustFee , DateTime . Now )
. ExecuteAffrows ( ) ;
continue ;
}
rs . Not ( content ) ;
return rs ;
}
//余额不足
if ( price . PRICE > balance . Balance )
{
//推送钉钉消息给客服
var content = $"公司{ord.ClientName}提单号{ord.ShipOrderNo}的余额不足" ;
var gethtml = DjyTools . PostOnLogs ( new { text = new { content = $"【未扣费提醒】\r\n{content}\r\n----报关消息通知" } , msgtype = "text" } , cfgDingtalk , "胜云航通 自动 扣费", YsPsotType . Json ) . Result ;
//余额不足
if ( price . PRICE > balance . Balance )
{
//推送钉钉消息给客服
var content = $"公司{ord.ClientName}提单号{ord.ShipOrderNo}的余额不足" ;
var gethtml = DjyTools . PostOnLogs ( new { text = new { content = $"【未扣费提醒】\r\n{content}\r\n----报关消息通知" } , msgtype = "text" } , cfgDingtalk , "胜云航通 扣费", YsPsotType . Json ) . Result ;
//设置状态
DbBus . Get ( DbList . djypublicedb ) . Update < tb_BaoGuanOrderList > ( )
. Where ( x = > x . Gid = = ord . Gid )
. Set ( x = > x . StaCustFee , "FAIL" )
. Set ( x = > x . TimeCustFee , DateTime . Now )
. ExecuteAffrows ( ) ;
//设置状态
DbBus . Get ( DbList . djypublicedb ) . Update < tb_BaoGuanOrderList > ( )
. Where ( x = > x . Gid = = ord . Gid )
. Set ( x = > x . StaCustFee , "FAIL" )
. Set ( x = > x . TimeCustFee , DateTime . Now )
. ExecuteAffrows ( ) ;
continue ;
}
rs . Not ( content ) ;
return rs ;
}
//执行扣费
var fin = new FinanceService ( ) ;
var getfinrs = fin . Expend ( new djy . Model . CustFee
{
SENDUSERID = customerComp . AdminUser ,
LURURENID = customerComp . AdminUser ,
CtnrCount = 1 ,
CtnrInfo = string . Empty ,
BSTYPE = 13 ,
SENDTYPE = 0 ,
BSNO = ord . Gid . ToString ( ) ,
MBLNO = ord . ShipOrderNo
} , 1 ) ;
if ( getfinrs . Status )
{
//设置状态
DbBus . Get ( DbList . djypublicedb ) . Update < tb_BaoGuanOrderList > ( )
. Where ( x = > x . Gid = = ord . Gid )
. Set ( x = > x . StaCustFee , "OK" )
. Set ( x = > x . TimeCustFee , DateTime . Now )
. ExecuteAffrows ( ) ;
}
else
{
//设置状态
DbBus . Get ( DbList . djypublicedb ) . Update < tb_BaoGuanOrderList > ( )
. Where ( x = > x . Gid = = ord . Gid )
. Set ( x = > x . StaCustFee , "FAIL" )
. Set ( x = > x . TimeCustFee , DateTime . Now )
. ExecuteAffrows ( ) ;
//执行扣费
var fin = new FinanceService ( ) ;
var getfinrs = fin . Expend ( new djy . Model . CustFee
{
SENDUSERID = customerComp . AdminUser ,
LURURENID = customerComp . AdminUser ,
CtnrCount = 1 ,
CtnrInfo = string . Empty ,
BSTYPE = 13 ,
SENDTYPE = 0 ,
BSNO = ord . Gid . ToString ( ) ,
MBLNO = ord . ShipOrderNo
} , 1 ) ;
if ( getfinrs . Status )
{
//设置状态
DbBus . Get ( DbList . djypublicedb ) . Update < tb_BaoGuanOrderList > ( )
. Where ( x = > x . Gid = = ord . Gid )
. Set ( x = > x . StaCustFee , "OK" )
. Set ( x = > x . TimeCustFee , DateTime . Now )
. ExecuteAffrows ( ) ;
}
else
{
//设置状态
DbBus . Get ( DbList . djypublicedb ) . Update < tb_BaoGuanOrderList > ( )
. Where ( x = > x . Gid = = ord . Gid )
. Set ( x = > x . StaCustFee , "FAIL" )
. Set ( x = > x . TimeCustFee , DateTime . Now )
. ExecuteAffrows ( ) ;
//推送钉钉消息给客服
var content = $"公司{ord.ClientName}提单号{ord.ShipOrderNo}报关扣费失败:{getfinrs.Message}" ;
var gethtml = DjyTools . PostOnLogs ( new { text = new { content = $"【未扣费提醒】\r\n{content}\r\n----报关消息通知" } , msgtype = "text" } , cfgDingtalk , "胜云航通 自动 扣费", YsPsotType . Json ) . Result ;
//推送钉钉消息给客服
var content = $"公司{ord.ClientName}提单号{ord.ShipOrderNo}报关扣费失败:{getfinrs.Message}" ;
var gethtml = DjyTools . PostOnLogs ( new { text = new { content = $"【未扣费提醒】\r\n{content}\r\n----报关消息通知" } , msgtype = "text" } , cfgDingtalk , "胜云航通 扣费", YsPsotType . Json ) . Result ;
}
}
}
}
return rs ;
}
/// <summary>
/// 报关扣费
/// </summary>
/// <param name="gid"></param>
/// <returns></returns>
public async Task < ReturnResult < string > > CustFee ( Guid gid )
{
var ord = await DbBus . Get ( DbList . djypublicedb )
. Select < tb_BaoGuanOrderList > ( )
. Where ( x = > x . Gid = = gid )
. ToOneAsync ( ) ;
if ( ord . StaCustFee = = "OK" )
{
var rtn = new ReturnResult < string > ( ) ;
rtn . Not ( "当前业务已成功扣费,无需再次扣费" ) ;
return rtn ;
}
return CustFee ( ord ) ;
}
# endregion
}