diff --git a/BWP.B3_YunKen.Web/PluginClass.cs b/BWP.B3_YunKen.Web/PluginClass.cs
index 429ea7d..4fe9528 100644
--- a/BWP.B3_YunKen.Web/PluginClass.cs
+++ b/BWP.B3_YunKen.Web/PluginClass.cs
@@ -8,6 +8,8 @@ namespace BWP.B3_YunKen.Web
public void OnInit() {
GlobalFlags.On(B3SaleConsts.Flags.EnableStandardGoods);
+ GlobalFlags.On(B3SaleConsts.Flags.RecordLastSaleOutStoreDate);
+
}
public void OnUnitInit()
diff --git a/BWP.B3_YunKen/BWP.B3_YunKen.csproj b/BWP.B3_YunKen/BWP.B3_YunKen.csproj
index 8857c5e..fa78861 100644
--- a/BWP.B3_YunKen/BWP.B3_YunKen.csproj
+++ b/BWP.B3_YunKen/BWP.B3_YunKen.csproj
@@ -10,7 +10,7 @@
Properties
BWP.B3_YunKen
B3_YunKen
- v4.0
+ v4.0
512
BwpApp
@@ -22,7 +22,7 @@
TRACE;DEBUG
prompt
4
- false
+ false
pdbonly
@@ -34,6 +34,9 @@
AllRules.ruleset
+
+
+
False
@@ -47,9 +50,11 @@
False
..\..\..\TsingSoft2\TSREF\TSingSoft.WebControls2.dll
+
+
diff --git a/BWP.B3_YunKen/TimerTask/NullifyCustomerTask.cs b/BWP.B3_YunKen/TimerTask/NullifyCustomerTask.cs
new file mode 100644
index 0000000..afbeb39
--- /dev/null
+++ b/BWP.B3_YunKen/TimerTask/NullifyCustomerTask.cs
@@ -0,0 +1,89 @@
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using BWP.B3Frameworks;
+using BWP.B3Frameworks.BL;
+using BWP.B3Frameworks.BO;
+using BWP.B3Frameworks.Utils;
+using BWP.B3Sale.BL;
+using BWP.B3Sale.BO;
+using Forks.EnterpriseServices.BusinessInterfaces;
+using Forks.EnterpriseServices.DomainObjects2;
+using Forks.EnterpriseServices.DomainObjects2.DQuery;
+using TSingSoft.WebPluginFramework;
+using TSingSoft.WebPluginFramework.TimerTasks;
+
+namespace BWP.B3_YunKen.TimerTask {
+
+ public class StoppedCustomerTask : ITimerTask {
+
+ public string Name { get { return "耘垦停用客户定时任务"; } }
+
+ public long? Days { get; set; }//天数
+
+ volatile static object _lockObj = new object();
+
+ public void Execute() {
+ if (!Monitor.TryEnter(_lockObj)) {
+ throw new SameTaskNotFinishException(this);
+ }
+
+ try {
+ DoExecute();
+ } finally {
+ Monitor.Exit(_lockObj);
+ }
+
+ }
+
+ //A:查找启用状态的客户
+ //B:根据客户查找客户的【销售出库单】
+ //C:确定客户最晚【销售出库单】的日期
+ //D:若当前日期-最晚【销售出库单】的日期=60 则停用客户
+ //E:查找客户档案上的销售人员,根据销售人员查找关联的用户
+ //F:将停用客户的名单推送给销售人员关联的用户
+
+ private void DoExecute() {
+
+ var mDmoTypeID = DmoTypeIDAttribute.GetID(typeof(Customer));
+ var dom = new DQueryDom(new JoinAlias(typeof(Customer)));
+ dom.Columns.Add(DQSelectColumn.Field("ID"));
+ dom.Columns.Add(DQSelectColumn.Field("LastGoodsOutStoreDate"));
+
+ dom.Where.Conditions.Add(DQCondition.EQ("Stopped", false));
+ dom.Where.Conditions.Add(DQCondition.IsNotNull(DQExpression.Field("LastGoodsOutStoreDate")));
+ var list = dom.EExecuteList();
+ var userMesageBL = BIFactory.Create();
+ var cusBL = BIFactory.Create();
+ foreach (var tuple in list) {
+ var span = DateTime.Today - tuple.Item2;
+ if (span.Days >= (Days ?? 60)) {
+ var cus = cusBL.Load(tuple.Item1);
+ 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}因60天内未发货,被系统自动停用。", cus.Name, tuple.Item1);
+ userMesageBL.Insert(BLContext.User.ID, new long[] { userID.Value }, message);
+ }
+ }
+ }
+
+
+ }
+
+ private static long? GetBindingEmployeeID(long employeeID) {
+
+ var query = new DQueryDom(new JoinAlias(typeof(User_Employee)));
+ query.Where.Conditions.Add(DQCondition.EQ("Employee_ID", employeeID));
+ query.Columns.Add(DQSelectColumn.Field("User_ID"));
+
+ var result = (long?)query.EExecuteScalar();
+ return result;
+ }
+ }
+}
diff --git a/WebFolder/Config/Plugins/B3_YunKen.Plugin b/WebFolder/Config/Plugins/B3_YunKen.Plugin
index 36875ba..83427ab 100644
--- a/WebFolder/Config/Plugins/B3_YunKen.Plugin
+++ b/WebFolder/Config/Plugins/B3_YunKen.Plugin
@@ -1,6 +1,7 @@
+
@@ -8,11 +9,14 @@
-
+
+
+
-
+
+