任务描述

需求描述

需求内容

需求链接:https://e0dl9r.axshare.com/#id=yx38vc&p=%E4%B8%93%E4%BA%AB%E6%8A%98%E6%89%A3%E5%88%97%E8%A1%A8&g=1

密码:Admin500366

1、智能运营:新增专享折扣模块,下拉展示【策略配置、专享折扣记录】。

注意:需要设置模块权限控制

2、策略配置页面如下:

3、添加/编辑策略页面如下:

4、策略日志展示如下:


5、专享折扣记录页面如下:

验收标准
正常创建策略,开启后正常执行
历史记录  
  1. 2023-08-29 09:30:55, 由 罗友军 创建。
  2. 2023-08-29 18:16:58, 由 钟喜旺 启动。
    修改了 实际开始,旧值为 "0000-00-00 00:00:00",新值为 "2023-08-29 18:16:54"。
    修改了 总计消耗,旧值为 "0",新值为 "4"。
    修改了 任务状态,旧值为 "wait",新值为 "doing"。
  3. 2023-09-10 14:54:49, 由 钟喜旺 完成。
    修改了 总计消耗,旧值为 "4",新值为 "44"。
    修改了 指派给 ,旧值为 "zhongxiwang",新值为 "luoyoujun"。
    修改了 实际完成,旧值为 "",新值为 "2023-09-10 14:52:44"。
    修改了 任务状态,旧值为 "doing",新值为 "done"。
    修改了 预计剩余,旧值为 "40",新值为 "0"。
    修改了 由谁完成,旧值为 "",新值为 "zhongxiwang"。

    用到的表

    mysql select * from exclusivediscountordersource; -- 渠道来源表  select * from exclusivediscountordersourcesku;-- 渠道来源sku  select * from exclusivediscountstrategy; -- 策略  select * from exclusivediscountstrategyordersourcesku; -- 服务转换表 -- 添加字段 alter table exclusivediscountstrategy add ExecuteInfo json null comment '策略执行详情的冗余信息'; --  Status= 正常  ListingStatus=0 listing 在线  select * from MarkListingInfo where OrderSourceSKUID=1 and Status=1 and ListingStatus=0 and IsFBA=false and IsBrotherFBA=false -- 查询来源渠道 select * from RB_OrderSource o join RB_OrderSource_EbayAmazonAPI a on o.ID=a.OrderSourceID and o.CustomerID=a.CustomerID where a.IsActive=1 and o.IsActive=1 and isnull(o.ChannelPlatformStatus,0)=0 and o.SourceStatus=0 and o.CustomerID=1 and o.OrderSourceType=1 
    // 专项折扣任务队列 db.getSiblingDB("Amazon_AdjustPrice").getCollection("ExclusiveDiscountStrategyStatus").find(); // 标签表 db.getSiblingDB("Amazon_AdjustPrice").getCollection("MarkListingInfo").find( { "OrderSourceId":5042, "Status":1, "ListingStatus":0, "IsFBA":false, "IsBrotherFBA": false }); //策略折扣信息详细表 db.getSiblingDB("Amazon_AdjustPrice").getCollection("ExclusiveDiscountDetail").find({ "OrderSourceId":5042 }); 

    1)配送延迟率超过 4.0%。(查询逻辑) AmazonPerformancePolicyType.迟发率 =10
    取值:(pv.Rate *100)%

    SELECT pv.*,pv.Rate FROM RB_Amazon_PerformanceCheckPolicyViolationV2 pv (nolock) INNER JOIN RB_Amazon_PerformanceCheckV2 pc (nolock) ON pc.ID = pv.PerformanceCheckV2ID where PolicyType =10 and pc.OrderSourceId in ('xx') 

    2)订单缺陷率超过 1.0%。 121

    3)配送前取消率超过 0.5%

    SELECT pv.*,pv.Rate FROM RB_Amazon_PerformanceCheckPolicyViolationV2 pv (nolock) INNER JOIN RB_Amazon_PerformanceCheckV2 pc (nolock) ON pc.ID = pv.PerformanceCheckV2ID where PolicyType =11 and pc.OrderSourceId in ('xx') 

    执行策略的服务

    执行策略的服务: amazonWork ExclusiveDiscountService

    如果redis队列中的缓存大于专项折扣任务队列中的总数据量则不执行:
    rediskey值:QueueData:List:ExclusiveDiscountQueue

    执行流程:

    1. 如果redis队列中的缓存大于专项折扣任务队列中的总数据量则不执行(rediskey值:QueueData:List:ExclusiveDiscountQueue)
    2. 从专项折扣任务队列中找出没有执行成功的数据(成功是2,字段Status)
    3. 推送到redis 队列
    4. 根据orderSourceId 从 RB_OrderSource 表中找出店铺信息,没有直接退出
    5. 根据OrderSourceId 从 RB_OrderSource_EbayAmazonAPI 表中找出店铺授权Api信息,没有直接退出
    6. 设置redis中策略的最后更新时间(redisKey:ExclusiveDiscountStrategy:Status:{strategyId})
    7. 从专项折扣任务队列找出任务,如果任务执行成功则退出
    8. 从 MarkListingInfo 表找出数据(OrderSourceSKUID=1 and Status=1 and ListingStatus=0 and IsFBA=false and IsBrotherFBA=false and OrderSourceSKU in (xxxx))且 PublishTime 是七天前的数据
    9. 将查询出来的数据处理并写入ExclusiveDiscountDetail表
    10. 更新任务状态

    重置任务状态流程:

    1. 找出专项折扣任务队列中执行成功的数据其是循环执行,且大于执行间隔 的并删除
    2. 找出策略列表存在策略激活时间(Detail.ActiveTime)而且(Detail.ExpireDay)过期时间大于0,且激活时间在执行间隔时间内(当前时间-策略激活时间>执行间隔天数),则关闭策略
    3. 清除已经关闭的测试的折扣任务队列中的数据
    4. 将策略写入专项折扣任务列表

    查询所有来源渠道的逻辑:

    select * from RB_OrderSource o join RB_OrderSource_EbayAmazonAPI a on o.ID=a.OrderSourceID and o.CustomerID=a.CustomerID where a.IsActive=1 and o.IsActive=1 and isnull(o.ChannelPlatformStatus,0)=0 and o.SourceStatus=0 and o.CustomerID=1 and o.OrderSourceType=1
  4. 2023-09-10 15:04:16, 由 钟喜旺 编辑。
    修改了 任务描述,区别为:
    001- <img src="/zentao/file-read-299218.png" alt="" />
    001+
    001- <p><img src="/zentao/file-read-299218.png" alt="" /></p>
    001+ <p><img src="{299218.png}" alt="" /></p>

    开发报告规范:
    1、说明修改发布项目工程和服务配置项

    发布项目: amazonWork, AutoChoose

    项目:AmazonWork

    新增服务

    服务1: 同步专享折扣执行情况

    服务名:DiscountRuleAccountJob

    频率: 一小时执行一次

    {"ServiceName":"DiscountRuleAccountJob","Params":{},"AssemblyFullName":" Erp.Amazon.Worker","TypeFullName":"Erp.Amazon.Worker.CronJob.AdjustPrice.DiscountEvent.DiscountRuleAccountJob","ExecMethod":"Execute","IsMultiThread":false,"TimeOut":0} 

    项目:AmazonWork

    新增服务

    服务1: 同步专享折扣执行结果信息同步

    服务名:DiscountRuleExecuteInfoJob

    频率: 一小时执行一次

    {"ServiceName":"DiscountRuleExecuteInfoJob","Params":{},"AssemblyFullName":" Erp.Amazon.Worker","TypeFullName":"Zhcxkj.AutoChoose.Worker.AdjustPriceQueue.DiscountRuleExecuteInfoJob","ExecMethod":"Execute","IsMultiThread":false,"TimeOut":0} 

    2、备注新增修改数据库表或字段

    智能选品 mysql(zhcxkj_autochoose)库, 添加字段

    alter table exclusivediscountstrategy add ExecuteInfo json null comment '策略执行详情的冗余信息'; 

    3、截图核心代码逻辑



    4、截图自测业务流


       [TestMethod]
        public void Test()
        {
            var monitoringService = _serviceProvider.GetService<IMonitoringPropertiesInterceptor>();
    
            var model = CreateModel();
            var modelProxy = monitoringService.CreateProxy<ExclusiveDiscountStrategy>(model);
            modelProxy.Detail.ExpireDay = 43;
            modelProxy.Name = "test2";
            var monit = (IMonitoringProperties)modelProxy;
            var result = monit.GetPropertyModify();
            Assert.IsTrue(result.Count==2);
            monit.ClearModifyLog();
            
            result = monit.GetPropertyModify();
            Assert.IsTrue(result.Count==0);
        }
    
        [TestMethod]
        public void InsertMarkListingInfo()
        {
            var json = "";
             var model = Newtonsoft.Json.JsonConvert.DeserializeObject<MarkListingInfo>(json);
             model.OrderSourceId = 55;
             model.OrderSourceSKU = "sku";
            var monitoringService = _serviceProvider.GetService<IMarkListingInfo_MgoRepository>();
            monitoringService.InsertOne(model);
        }
    
        [TestMethod]
        public void GenerateCode()
        {
            var properties = typeof(DiscountRuleResultExcelModel).GetProperties();
            string result = "";
            foreach (var item in properties)
            {
                result += $"        this.{item.Name} = model.{item.Name};\r\n";
            }
        }
    
        [TestMethod]
        public void CreateMulitCategory()
        {
            var service = _serviceProvider.GetService<IDiscountRuleConfigService>();
            CreateDiscountRuleConfigModel model = new CreateDiscountRuleConfigModel()
            {
                Detail = new DiscountEventDetail()
                {
                    DiscountRatioInterval = new IntInfoBase() { Max = 100, Min = 10 },
                    PriceInterval = new IntInfoBase() { Max = 32, Min = 10 },
                    IsLoop = false,
                    Operation = "操作方式",
                    PlanIntervalCycle = 5,
                    DiscountRatio = 3,
                    IntervalDays = 4,
                    ActiveTime = DateTime.Now.AddHours(1)
                },
                IsAllOrderSource = false,
                Name = "name",
                OrderSourceType = EnumOrderSourceType.亚马逊平台,
                IsActive = true,
                Priority = 10,
                FilterType = EnumOrderSourceFilterType.Oss| EnumOrderSourceFilterType.Os ,
                Remark = "备注",
                OrderSourceList = new List<CreateDiscountRuleConfigSourceInfoModel>()
                {
                    new CreateDiscountRuleConfigSourceInfoModel()
                    {
                        OrderSourceId = 5042,
                        OrderSourceName = "Amazon-Z01020-US"
                    }
                },
                OrderSourceSku = new System.Collections.Generic.List<string>()
                {
                    "4504218ITMK"
                }
            };
            var result = service.CreateDiscountRuleConfig(model,1,"system");
        }
    
        [TestMethod]
        public void CreateCategory()
        {
            var service = _serviceProvider.GetService<IDiscountRuleConfigService>();
            CreateDiscountRuleConfigModel model = new CreateDiscountRuleConfigModel()
            {
                Detail = new DiscountEventDetail()
                {
                    DiscountRatioInterval = new IntInfoBase() { Max = 100, Min = 10 },
                    PriceInterval = new IntInfoBase() { Max = 32, Min = 10 },
                    IsLoop = false,
                    Operation = "操作方式",
                    PlanIntervalCycle = 5,
                    DiscountRatio = 3,
                    IntervalDays = 4,
                    ActiveTime = DateTime.Now.AddHours(1)
                },
                IsAllOrderSource = true,
                Name = "name",
                OrderSourceType = EnumOrderSourceType.亚马逊平台,
                IsActive = true,
                Priority = 10,
                FilterType = EnumOrderSourceFilterType.Os,
                Remark = "备注",
                OrderSourceList = new List<CreateDiscountRuleConfigSourceInfoModel>()
                {
                    new CreateDiscountRuleConfigSourceInfoModel()
                    {
                        OrderSourceId = 5042,
                        OrderSourceName = "Amazon-Z01020-US"
                    }
                }
            };
            var result = service.CreateDiscountRuleConfig(model,1,"system");
            var repos= _serviceProvider.GetService<IExclusiveDiscountStrategy_Repository>();
            Assert.IsTrue(result>0);
        }
    
        [TestMethod]
        public async Task ModifyCategory()
        {
            var service = _serviceProvider.GetService<IDiscountRuleConfigService>();
            CreateDiscountRuleConfigModel model = new CreateDiscountRuleConfigModel()
            {
                Detail = new DiscountEventDetail()
                {
                    DiscountRatioInterval = new IntInfoBase() { Max = 100, Min = 10 },
                    PriceInterval = new IntInfoBase() { Max = 32, Min = 10 },
                    IsLoop = false,
                    ExpireDay = 2,
                    Operation = "操作方式",
                    PlanIntervalCycle = 5,
                    DiscountRatio = 3,
                    IntervalDays = 4,
                    ActiveTime = DateTime.Now.AddHours(1)
                },
                IsAllOrderSource =false ,
                Name = "name",
                OrderSourceType = EnumOrderSourceType.亚马逊平台,
                IsActive = true,
                Priority = 10,
                FilterType = EnumOrderSourceFilterType.Os,
                Remark = "备注",
                OrderSourceList = new List<CreateDiscountRuleConfigSourceInfoModel>()
                {
                    new CreateDiscountRuleConfigSourceInfoModel()
                    {
                        OrderSourceId = 2134,
                        OrderSourceName = "来源渠道名字"
                    }
                }
            };
            var configId = service.CreateDiscountRuleConfig(model,1,"system");
            var repos= _serviceProvider.GetService<IExclusiveDiscountStrategy_Repository>();
    
            var discountRule = repos.FindOneById(configId);
            Assert.IsTrue(discountRule.Priority == model.Priority);
            Assert.IsTrue(discountRule.Name == model.Name);
            Assert.IsTrue(discountRule.OrderSourceType == model.OrderSourceType);
            Assert.IsTrue(discountRule.IsActive == model.IsActive);
            Assert.IsTrue(discountRule.FilterType == model.FilterType);
            Assert.IsTrue(discountRule.Remark == model.Remark);
            Assert.IsTrue(discountRule.Detail.DiscountRatioInterval.Equals(model.Detail.DiscountRatioInterval));
            Assert.IsTrue(discountRule.Detail.PriceInterval .Equals(model.Detail.PriceInterval));
            Assert.IsTrue(discountRule.Detail.IsLoop == model.Detail.IsLoop);
            Assert.IsTrue(discountRule.Detail.Operation == model.Detail.Operation);
            Assert.IsTrue(discountRule.Detail.PlanIntervalCycle == model.Detail.PlanIntervalCycle);
            Assert.IsTrue(discountRule.Detail.DiscountRatio == model.Detail.DiscountRatio);
            Assert.IsTrue(discountRule.Detail.IntervalDays == model.Detail.IntervalDays);
            Assert.IsTrue(discountRule.Detail.ActiveTime == model.Detail.ActiveTime);
    
            ModifyDiscountRuleConfigModel modifyModel = new ModifyDiscountRuleConfigModel()
            {
                Id = configId,
                Detail = new DiscountEventDetail()
                {
                    DiscountRatioInterval = new IntInfoBase() { Max = 90, Min = 10 },
                    PriceInterval = new IntInfoBase() { Max = 42, Min = 10 },
                    IsLoop = false,
                    ExpireDay =2 ,
                    Operation = "操作方式",
                    PlanIntervalCycle = 6,
                    DiscountRatio = 1,
                    IntervalDays = 2,
                    ActiveTime = DateTime.Now.AddHours(1)
                },
                IsAllOrderSource = false,
                Name = "name 2",
                OrderSourceType = EnumOrderSourceType.亚马逊平台,
                IsActive = false,
                Priority = 9,
                FilterType = EnumOrderSourceFilterType.Os,
                Remark = "备注",
                OrderSourceList = new List<CreateDiscountRuleConfigSourceInfoModel>()
                {
                    new CreateDiscountRuleConfigSourceInfoModel()
                    {
                        OrderSourceId = 21343,
                        OrderSourceName = "来源渠道名字"
                    }
                }
            };
            await service.ModifyDiscountRuleConfig(modifyModel,1,"system");
            var logList = await service.GetOperationLogging(new QueryBaseView<OperationLoggingQueryViewModel>()
            {
                Current = 1,
                PageSize = 10,
                OrderBy = new OrderByView()
                {
                    Field = "id",
                    Order =  OrderByTypeView.Desc
                },
                Input = new OperationLoggingQueryViewModel()
                {
                    ForeignKeyId = configId.ToString()
                }
            });
            Assert.IsTrue(logList.Data.DataSource.Any());
            repos.Delete(vla => vla.Id == configId);
        }
    
        public ExclusiveDiscountStrategy CreateModel()
        {
            ExclusiveDiscountStrategy model = new ExclusiveDiscountStrategy()
            { 
                Detail = new DiscountEventDetail()
                {
                    DiscountRatioInterval=new IntInfoBase(){Max = 100,Min = 10},
                    PriceInterval = new IntInfoBase(){Max = 32,Min = 10},
                    IsLoop = false,
                    ExpireDay= 2,
                    Operation = "操作方式",
                    PlanIntervalCycle=5,
                    DiscountRatio =3,
                    IntervalDays=4,
                    ActiveTime=DateTime.Now.AddHours(1)
                },
                IsAllOrderSource = true,
                Name = "name",
                OrderSourceType = EnumOrderSourceType.亚马逊平台,
                IsActive = true,
                Priority = 10,
                FilterType = EnumOrderSourceFilterType.Os,
                Remark = "备注",
            };
            return model;
        }
    
        [TestMethod]
        public async Task TestSync()
        {
            var service = _serviceProvider.GetService<IDiscountRuleConfigResultService>();
            var scroller = string.Empty;
            var model = new DiscountRuleConfigResultQueryModel()
            {
    
            };
            var (list, src) = await service.DataExport(model, scroller);
            var (list2, src2) = await service.DataExport(model, src);
    
             await service.SyncData(new DiscountRuleExecuteResultSyncModel()
             {
                 StartTime = new DateTime(2023,9,8),
             },default);
            
            var result = await service.PageQuery(new QueryBaseView<DiscountRuleConfigResultQueryModel>()
            {
                Current = 1,
                PageSize = 10,
                OrderBy = new OrderByView()
                {
                    Field = "UpdateTime",
                    Order = OrderByTypeView.Desc
                },
                Input = null
            });
        }
    
        [TestMethod]
        public async Task TestCron()
        {
            var serivce = _serviceProvider.GetService<DiscountRuleExecuteInfoJob>();
            await serivce.Execute(new Dictionary<string, object>());
        }
    
        [TestMethod]
        public void TestExport()
        {
            var serivce = _serviceProvider.GetService<IExportQueue_Keyword_Amazon_Job_Service>();
        }


    5、补充其他注意事项

    无

  5. 2023-10-31 16:50:40, 由 周杰 关闭。
    修改了 任务状态,旧值为 "done",新值为 "closed"。
    修改了 指派给 ,旧值为 "luoyoujun",新值为 "closed"。
    修改了 由谁关闭,旧值为 "",新值为 "zhoujie"。
    修改了 关闭时间,旧值为 "0000-00-00 00:00:00",新值为 "2023-10-31 16:50:40"。
    修改了 关闭原因,旧值为 "",新值为 "done"。
所属迭代 智能中心-智能刊登迭代
所属模块 智能中心-需求池  战略独立项目   智能刊登
相关需求 新增专享折扣策略配置与队列记录页面
指派给 Closed 于 2023-10-31 16:50:40
任务类型 后端
任务标签 初始
开发组 仓储物流开发组
任务状态 已关闭
进度 100%
优先级 P0
关键词
抄送给
由谁创建 罗友军 于 2023-08-29 09:30:55
由谁完成 钟喜旺 于 2023-09-10 14:52:44
由谁取消 暂无
由谁关闭 周杰 于 2023-10-31 16:50:40
关闭原因 已完成
最后编辑 周杰 于 2023-10-31 16:50:40
团队 最初预计 总计消耗 预计剩余
工时信息
最初预计 40工时
总计消耗 44工时
预计剩余 0工时
预计开始 2023-08-29
实际开始 2023-08-29
截止日期 2023-08-31