shanji 2 years ago
parent
commit
2d555215c6
  1. 10
      BBWY.Server.API/Controllers/EvaluationAssistantController.cs
  2. 66
      BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs
  3. 8
      BBWY.Server.Business/Vender/VenderBusiness.cs
  4. 12
      BBWY.Server.Model/Db/Mds/Shops.cs
  5. 20
      BBWY.Server.Model/Dto/Request/PromotionTask/PJZSShopSettingRequest.cs
  6. 10
      BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs
  7. 2
      PJZS/MainWindow.xaml
  8. 2
      PJZS/MainWindow.xaml.cs
  9. 10
      PJZS/Models/APIModel/Shop/ShopResponse.cs
  10. 10
      PJZS/Models/Shop/Shop.cs

10
BBWY.Server.API/Controllers/EvaluationAssistantController.cs

@ -139,6 +139,16 @@ namespace BBWY.Server.API.Controllers
evaluationAssistantBusiness.StopPromotionTask(request);
}
/// <summary>
/// 修改评价助手店铺设置
/// </summary>
/// <param name="request"></param>
[HttpPost]
public void EditPJZSSettings([FromBody] PJZSShopSettingRequest request)
{
evaluationAssistantBusiness.EditPJZSSettings(request);
}
/// <summary>
/// 开始监控
/// </summary>

66
BBWY.Server.Business/EvaluationAssistant/EvaluationAssistantBusiness.cs

@ -28,10 +28,13 @@ namespace BBWY.Server.Business
private List<Enums.OrderState> validOrderStateList;
private List<Enums.PromitionTaskStatus> preTaskStateList;
private ProductBusiness productBusiness;
private FreeSqlMultiDBManager freeSqlMultiDBManager;
private char[] spliter;
public EvaluationAssistantBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, YunDingBusiness yunDingBusiness, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, DingDingBusiness dingDingBusiness, NLogManager nLogManager, ProductBusiness productBusiness) : base(restApiService, options, yunDingBusiness)
public EvaluationAssistantBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, YunDingBusiness yunDingBusiness, IFreeSql fsql, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager, VenderBusiness venderBusiness, DingDingBusiness dingDingBusiness, NLogManager nLogManager, ProductBusiness productBusiness, FreeSqlMultiDBManager freeSqlMultiDBManager) : base(restApiService, options, yunDingBusiness)
{
this.fsql = fsql;
this.idGenerator = idGenerator;
this.taskSchedulerManager = taskSchedulerManager;
@ -39,6 +42,7 @@ namespace BBWY.Server.Business
this.dingDingBusiness = dingDingBusiness;
this.nLogManager = nLogManager;
this.productBusiness = productBusiness;
this.freeSqlMultiDBManager = freeSqlMultiDBManager;
validOrderStateList = new List<Enums.OrderState>()
{
Enums.OrderState.,
@ -303,6 +307,9 @@ namespace BBWY.Server.Business
if (pt == null)
throw new BusinessException($"{request.TaskId}任务不存在");
if (pt.Status != Enums.PromitionTaskStatus.)
throw new BusinessException("任务状态必须为等待");
if (request.PreTaskId != -1)
{
var prpt = fsql.Select<PromotionTask>(request.PreTaskId).ToOne();
@ -312,9 +319,6 @@ namespace BBWY.Server.Business
if (pt.Id == prpt.Id)
throw new BusinessException("前置任务不能设置为自己");
if (pt.Status != Enums.PromitionTaskStatus.)
throw new BusinessException("任务状态必须为等待");
if (prpt.Status != Enums.PromitionTaskStatus. && prpt.Status != Enums.PromitionTaskStatus.)
throw new BusinessException("前置任务状态必须为等待或进行中");
@ -563,7 +567,7 @@ namespace BBWY.Server.Business
fsql.Update<PromotionTask>(id).Set(pt => pt.Status, Enums.PromitionTaskStatus.)
.Set(pt => pt.ErrorMsg, errorMsg)
.ExecuteAffrows();
Error(shop, $"评价助手-{shop.ShopName}", $"开始任务延迟任务-任务Id {request.Id}", new Exception(errorMsg));
Error(shop, $"评价助手-{shop.ShopName}", $"开始任务-延迟任务-任务Id {request.Id}", new Exception(errorMsg));
});
if (httpApiResult.StatusCode != System.Net.HttpStatusCode.OK)
{
@ -691,6 +695,15 @@ namespace BBWY.Server.Business
throw new BusinessException(response.Msg);
fsql.Update<PromotionTask>(request.Id).Set(pt => pt.Status, Enums.PromitionTaskStatus.).ExecuteAffrows();
}
public void EditPJZSSettings(PJZSShopSettingRequest request)
{
var shopId = request.ShopId.ToString();
freeSqlMultiDBManager.MDSfsql.Update<Model.Db.Mds.Shops>().Set(s => s.PJZSDingDingKey, request.PJZSDingDingKey)
.Set(s => s.PJZSDingDingWebHook, request.PJZSDingDingWebHook)
.Where(s => s.ShopId == shopId)
.ExecuteAffrows();
}
#endregion
#region 自动任务
@ -700,6 +713,22 @@ namespace BBWY.Server.Business
//查询店铺
var shopList = venderBusiness.GetShopList(shopId, Enums.Platform.);
//开始下一轮开始任务
var nextPromotionTaskList = fsql.Select<PromotionTask>().WhereIf(shopId != null, pt => pt.ShopId == shopId)
.Where(pt => pt.Status == Enums.PromitionTaskStatus. && pt.PreTaskId == -1)
.ToList(pt => new { Id = pt.Id, ShopId = pt.ShopId });
if (nextPromotionTaskList.Count() > 0)
{
foreach (var nextTask in nextPromotionTaskList)
{
var shop = shopList.FirstOrDefault(s => s.ShopId == nextTask.ShopId.ToString());
if (shop != null)
{
Task.Factory.StartNew(() => AutoStart(nextTask.Id, shop), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.JDPromotionAutoStartTaskScheduler);
}
}
}
//查询正在进行的任务
var runningTaskList = fsql.Select<PromotionTask>()
.WhereIf(shopId != null, pt => pt.ShopId == shopId)
@ -898,30 +927,19 @@ namespace BBWY.Server.Business
#region 开始后续任务
//下一轮开始任务
var nextPromotionTaskList = new List<long>();
var noPrePromotionTaskList = fsql.Select<PromotionTask>().Where(pt => pt.ShopId == shopId &&
pt.Status == Enums.PromitionTaskStatus. &&
pt.PreTaskId == -1).ToList(pt => pt.Id);
if (noPrePromotionTaskList.Count() > 0)
nextPromotionTaskList.AddRange(noPrePromotionTaskList);
if (jobDoneTaskIdList.Count() > 0)
{
var childTaskList = fsql.Select<PromotionTask>().Where(pt => pt.ShopId == shopId &&
pt.Status == Enums.PromitionTaskStatus. &&
jobDoneTaskIdList.Contains(pt.PreTaskId.Value)).ToList(pt => pt.Id);
pt.Status == Enums.PromitionTaskStatus. &&
jobDoneTaskIdList.Contains(pt.PreTaskId.Value)).ToList(pt => pt.Id);
if (childTaskList.Count() > 0)
nextPromotionTaskList.AddRange(childTaskList);
}
if (nextPromotionTaskList.Count() > 0)
{
foreach (var taskId in nextPromotionTaskList)
{
Task.Factory.StartNew(() => AutoStart(taskId, shop), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.JDPromotionAutoStartTaskScheduler);
foreach (var taskId in childTaskList)
{
Task.Factory.StartNew(() => AutoStart(taskId, shop), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.JDPromotionAutoStartTaskScheduler);
}
}
}
#endregion
}
@ -945,13 +963,13 @@ namespace BBWY.Server.Business
}
}
private void Error(ShopResponse shop, string loggerName, string message, Exception ex)
{
nLogManager.GetLogger(loggerName).Error(ex, message);
//send dingding
if (!string.IsNullOrEmpty(shop.PJZSDingDingKey) && !string.IsNullOrEmpty(shop.PJZSDingDingWebHook))
dingDingBusiness.SendDingDingBotMessage(shop.PJZSDingDingKey, shop.PJZSDingDingWebHook, $"评价助手\n{shop.ShopName}\n{message}\n{ex.Message}");
}
#endregion
}

8
BBWY.Server.Business/Vender/VenderBusiness.cs

@ -226,7 +226,9 @@ namespace BBWY.Server.Business
s.SkuSafeTurnoverDays,
s.SiNanDingDingKey,
s.SiNanDingDingWebHook,
s.SiNanPolicyLevel
s.SiNanPolicyLevel,
s.PJZSDingDingWebHook,
s.PJZSDingDingKey
}).GroupBy(x => x.DepartmentId);
if (relationGroups.Count() == 0)
return null;
@ -259,7 +261,9 @@ namespace BBWY.Server.Business
SkuSafeTurnoverDays = x.SkuSafeTurnoverDays,
SiNanDingDingKey = x.SiNanDingDingKey,
SiNanDingDingWebHook = x.SiNanDingDingWebHook,
SiNanPolicyLevel = x.SiNanPolicyLevel
SiNanPolicyLevel = x.SiNanPolicyLevel,
PJZSDingDingKey = x.PJZSDingDingKey,
PJZSDingDingWebHook = x.PJZSDingDingWebHook
}).ToList()
};
departmentList.Add(department);

12
BBWY.Server.Model/Db/Mds/Shops.cs

@ -158,6 +158,18 @@ namespace BBWY.Server.Model.Db.Mds
/// </summary>
[Column(StringLength = 100)]
public string SiNanDingDingKey { get; set; }
/// <summary>
/// PJZS钉钉WebHook地址
/// </summary>
[Column(StringLength = 255)]
public string PJZSDingDingWebHook { get; set; }
/// <summary>
/// PJZS钉钉密钥
/// </summary>
[Column(StringLength = 100)]
public string PJZSDingDingKey { get; set; }
}
}

20
BBWY.Server.Model/Dto/Request/PromotionTask/PJZSShopSettingRequest.cs

@ -0,0 +1,20 @@
namespace BBWY.Server.Model.Dto
{
public class PJZSShopSettingRequest
{
/// <summary>
/// 店铺Id,Shop对象的ShopId (注意不是Shop对象的主键)
/// </summary>
public long ShopId { get; set; }
/// <summary>
/// 评价助手的钉钉地址
/// </summary>
public string PJZSDingDingWebHook { get; set; }
/// <summary>
/// 评价助手的钉钉密钥
/// </summary>
public string PJZSDingDingKey { get; set; }
}
}

10
BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs

@ -71,6 +71,16 @@ namespace BBWY.Server.Model.Dto
/// 司南钉钉密钥
/// </summary>
public string SiNanDingDingKey { get; set; }
/// <summary>
/// PJZS钉钉WebHook地址
/// </summary>
public string PJZSDingDingWebHook { get; set; }
/// <summary>
/// PJZS钉钉密钥
/// </summary>
public string PJZSDingDingKey { get; set; }
}
public class PurchaseAccountResponse

2
PJZS/MainWindow.xaml

@ -27,7 +27,7 @@
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0"
TextBlock.Foreground="White">
<TextBlock Text="评价助手"/>
<TextBlock Text="v10002" Margin="5,0,0,0"/>
<TextBlock Text="v10003" Margin="5,0,0,0"/>
<TextBlock x:Name="txtUserName" Margin="5,0,0,0"/>
</StackPanel>
</Border>

2
PJZS/MainWindow.xaml.cs

@ -176,6 +176,8 @@ namespace PJZS
shop.AppKey2 = s2.AppKey2;
shop.AppSecret2 = s2.AppSecret2;
shop.AppToken2 = s2.AppToken2;
shop.PJZSDingDingKey = s2.PJZSDingDingKey;
shop.PJZSDingDingWebHook = s2.PJZSDingDingWebHook;
}
}
}

10
PJZS/Models/APIModel/Shop/ShopResponse.cs

@ -56,6 +56,16 @@ namespace PJZS.Models
/// 司南钉钉密钥
/// </summary>
public string SiNanDingDingKey { get; set; }
/// <summary>
/// PJZS钉钉WebHook地址
/// </summary>
public string PJZSDingDingWebHook { get; set; }
/// <summary>
/// PJZS钉钉密钥
/// </summary>
public string PJZSDingDingKey { get; set; }
}
public class DepartmentResponse

10
PJZS/Models/Shop/Shop.cs

@ -71,6 +71,16 @@ namespace PJZS
/// </summary>
public string SiNanDingDingKey { get; set; }
/// <summary>
/// PJZS钉钉WebHook地址
/// </summary>
public string PJZSDingDingWebHook { get; set; }
/// <summary>
/// PJZS钉钉密钥
/// </summary>
public string PJZSDingDingKey { get; set; }
public override string ToString()
{
return ShopName;

Loading…
Cancel
Save