|
|
|
@ -58,33 +58,40 @@ namespace BWP.B3_YunKen.TimerTask { |
|
|
|
var cusBL = BIFactory.Create<ICustomerBL>(); |
|
|
|
foreach (var tuple in list) { |
|
|
|
var loadTime = GetMaxLoadTime(tuple.Item1); |
|
|
|
int? diffDays2 = null; |
|
|
|
if (tuple.Item2 != null) { |
|
|
|
diffDays2 = (DateTime.Now - tuple.Item2.Value).Days; |
|
|
|
} |
|
|
|
if (loadTime != null) { |
|
|
|
var diffDays = (DateTime.Now - loadTime.Value).Days; |
|
|
|
int? diffDays2 = null; |
|
|
|
if (tuple.Item2 != null) { |
|
|
|
diffDays2 = (DateTime.Now - tuple.Item2.Value).Days; |
|
|
|
} |
|
|
|
if (diffDays >= Days && diffDays2 >= Days) { |
|
|
|
var cus = cusBL.Load(tuple.Item1); |
|
|
|
cus.StopedByCustomerTask = true; |
|
|
|
cus.StopReason = Days + "天内未发货"; |
|
|
|
cusBL.Update(cus); |
|
|
|
cusBL.Stop(cus); |
|
|
|
if (cus.Employee_ID.HasValue) { |
|
|
|
var userID = GetBindingEmployeeID(cus.Employee_ID.Value); |
|
|
|
if (userID == null) |
|
|
|
continue; |
|
|
|
var message = new CommonUserMessage(); |
|
|
|
message.TargetDmoTypeID = mDmoTypeID; |
|
|
|
message.TargetDmoID = tuple.Item1; |
|
|
|
message.Text = string.Format("客户{0}NO.{1}因{2}天内未发货,被系统自动停用。", cus.Name, tuple.Item1, Days); |
|
|
|
userMesageBL.Insert(BLContext.User.ID, new long[] { userID.Value }, message); |
|
|
|
} |
|
|
|
StopCustomer(userMesageBL, cusBL, tuple.Item1, mDmoTypeID); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (diffDays2 >= Days) { |
|
|
|
StopCustomer(userMesageBL, cusBL, tuple.Item1, mDmoTypeID); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void StopCustomer(IUserMessageBL userMesageBL, ICustomerBL cusBL,long cusId,short dmoTypeID) |
|
|
|
{ |
|
|
|
var cus = cusBL.Load(cusId); |
|
|
|
cus.StopedByCustomerTask = true; |
|
|
|
cus.StopReason = Days + "天内未发货"; |
|
|
|
cusBL.Update(cus); |
|
|
|
cusBL.Stop(cus); |
|
|
|
if (cus.Employee_ID.HasValue) { |
|
|
|
var userID = GetBindingEmployeeID(cus.Employee_ID.Value); |
|
|
|
if (userID != null) { |
|
|
|
var message = new CommonUserMessage(); |
|
|
|
message.TargetDmoTypeID = dmoTypeID; |
|
|
|
message.TargetDmoID = cusId; |
|
|
|
message.Text = string.Format("客户{0}NO.{1}因{2}天内未发货,被系统自动停用。", cus.Name, cusId, Days); |
|
|
|
userMesageBL.Insert(BLContext.User.ID, new long[] { userID.Value }, message); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private static DateTime? GetMaxLoadTime(long cusID) |
|
|
|
|