自动扣费修改

master
wanghaomei 2 years ago
parent dda7659f67
commit 2b4f449f32

3
.gitignore vendored

@ -24,3 +24,6 @@ bin-release/
/djy.Paas.IService/.vs
/djyweb_djyPaasApi/publish
/djyweb_djyPaasApi/userdata
/djyweb_djyPaasApi/Properties/PublishProfiles/FolderProfile1.pubxml.user
/djyweb_djyPaasApi/Properties/PublishProfiles/FolderProfile.pubxml.user
/djyweb_djyPaasApi/DJY_SYHT.csproj.user

@ -2223,123 +2223,157 @@ namespace djy.Paas.Service
var cfgAutoCompId = DjyTools.GetConfigKey("baoguanAutoBindCompanyFeeCompId");
var cfgDingtalk = DjyTools.GetConfigKey("baoguanDingtalkNotify");
_LogsAdd($"报关自动扣费,公司参数:{cfgAutoCompId}", "胜云航通客服消息", null);
_LogsAdd($"报关自动扣费,钉钉:{cfgDingtalk}", "胜云航通客服消息", null);
_LogsAdd($"报关自动扣费,公司参数:{cfgAutoCompId}", "胜云航通自动扣费", null);
_LogsAdd($"报关自动扣费,钉钉:{cfgDingtalk}", "胜云航通自动扣费", null);
if (!string.IsNullOrEmpty(cfgAutoCompId))
{
try
var arr = cfgAutoCompId.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
_LogsAdd($"报关自动扣费,待处理公司:{arr.Length}", "胜云航通自动扣费", null);
foreach (var compid in arr)
{
var arr = cfgAutoCompId.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
_LogsAdd($"报关自动扣费,待处理公司:{arr.Length}", "胜云航通客服消息", null);
foreach (var compid in arr)
var guidComp = Guid.Parse(compid);
var orderList = DbBus.Get(DbList.djypublicedb)
.Select<tb_BaoGuanOrderList>()
.Where(x => x.CompId == guidComp
&& (x.StaCustFee == null || x.StaCustFee == "") //未扣费
&& x.ClientName != null && x.ClientName != "" //已绑定客户
&& (x.stateCode == "14" || x.stateCode == "15" || x.stateCode == "18"))//14海关放行15已结关18准予入港
.ToList();
_LogsAdd($"处理{guidComp}的报关自动扣费,共发现{orderList.Count}票", "胜云航通自动扣费", null);
foreach (var ord in orderList)
{
var guidComp = Guid.Parse(compid);
var orderList = DbBus.Get(DbList.djypublicedb)
.Select<tb_BaoGuanOrderList>()
.Where(x => x.CompId == guidComp
&& (x.StaCustFee == null || x.StaCustFee == "") //未扣费
&& x.ClientName != null && x.ClientName != "" //已绑定客户
&& (x.stateCode == "14" || x.stateCode == "15" || x.stateCode == "18"))//14海关放行15已结关18准予入港
.ToList();
_LogsAdd($"处理{compid}的报关自动扣费,共发现{orderList.Count}票", "胜云航通客服消息", null);
foreach (var ord in orderList)
var customerComp = DbBus.Get(DbList.djyolddb)
.Select<CompanyNew>()
.Where(x => x.CompName == ord.ClientName)
.ToOne();
if (customerComp == null)
{
var customerComp = DbBus.Get(DbList.djyolddb)
.Select<CompanyNew>()
.Where(x => x.CompName == ord.ClientName)
.ToOne();
//推送钉钉消息给客服
var content = $"公司{ord.ClientName}未找到";
_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}未找到";
_LogsAdd(content, "胜云航通客服消息", null);
var gethtml = DjyTools.PostOnLogs(new { text = new { content = $"【未扣费提醒】\r\n{content}\r\n----报关消息通知" }, msgtype = "text" }, cfgDingtalk, "胜云航通客服消息", YsPsotType.Json).Result;
continue;
}
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}没有钱包";
_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}没有钱包";
_LogsAdd(content, "胜云航通客服消息", null);
var gethtml = DjyTools.PostOnLogs(new { text = new { content = $"【未扣费提醒】\r\n{content}\r\n----报关消息通知" }, msgtype = "text" }, cfgDingtalk, "胜云航通客服消息", YsPsotType.Json).Result;
continue;
}
//设置状态
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 price = DbBus.Get(DbList.djyolddb)
.Select<CustPrice>()
.Where(x => x.COMNAME == customerComp.CompName && x.SENDTYPE == 0 && x.BSTYPE == 13)
.ToOne();
continue;
}
//未设置单价
if (price == null)
{
//推送钉钉消息给客服
var content = $"公司{ord.ClientName}的报关单价未设置";
var gethtml = DjyTools.PostOnLogs(new { text = new { content = $"【未扣费提醒】\r\n{content}\r\n----报关消息通知" }, msgtype = "text" }, cfgDingtalk, "胜云航通客服消息", YsPsotType.Json).Result;
var price = DbBus.Get(DbList.djyolddb)
.Select<CustPrice>()
.Where(x => x.COMNAME == customerComp.CompName && x.SENDTYPE == 0 && x.BSTYPE == 13)
.ToOne();
continue;
}
//未设置单价
if (price == null)
{
//推送钉钉消息给客服
var content = $"公司{ord.ClientName}的报关单价未设置";
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}的余额不足";
var gethtml = DjyTools.PostOnLogs(new { text = new { content = $"【未扣费提醒】\r\n{content}\r\n----报关消息通知" }, msgtype = "text" }, cfgDingtalk, "胜云航通客服消息", YsPsotType.Json).Result;
continue;
}
//设置状态
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
{
//推送钉钉消息给客服
var content = $"公司{ord.ClientName}报关扣费失败:{getfinrs.Message}";
var gethtml = DjyTools.PostOnLogs(new { text = new { content = $"【未扣费提醒】\r\n{content}\r\n----报关消息通知" }, msgtype = "text" }, cfgDingtalk, "胜云航通客服消息", YsPsotType.Json).Result;
continue;
}
}
//余额不足
if (price.PRICE > balance.Balance)
{
//推送钉钉消息给客服
var content = $"公司{ord.ClientName}的余额不足";
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;
}
//执行扣费
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}报关扣费失败:{getfinrs.Message}";
var gethtml = DjyTools.PostOnLogs(new { text = new { content = $"【未扣费提醒】\r\n{content}\r\n----报关消息通知" }, msgtype = "text" }, cfgDingtalk, "胜云航通自动扣费", YsPsotType.Json).Result;
}
}
}
catch (Exception ex)
{
_LogsAdd(ex.Message, "胜云航通自动扣费", new { ex.StackTrace });
}
}
}
#endregion

@ -116,7 +116,7 @@ namespace djy.Paas.Service
var count = 0;
try
{
LogsList.ForEach(x=> { x.Init();x.SysCode = "djypaas"; });
LogsList.ForEach(x=> { x.Init();x.SysCode = "djy_syht"; });
count = DbBus.Get(DbList.Logsdb).Insert(LogsList).ExecuteAffrows();
}
catch { }

Loading…
Cancel
Save