示例#1
0
        public static int UpdatePromotionTaskStatus(int id, PromotionConsts.PromotionTaskStatusEnum taskStatus,
                                                    string operateBy)
        {
            int result = DalPromotionJob.UpdatePromotionTaskStatus(id, taskStatus, operateBy);

            if (result > 0)
            {
                var promotionTask = DalPromotionJob.GetPromotionTaskById(id);
                if (promotionTask == null)
                {
                    return(0);
                }
                if (promotionTask.IsImmediately == 1) //需要立即执行
                {
                    if (taskStatus == PromotionConsts.PromotionTaskStatusEnum.Executed)
                    {
                        TuhuNotification.SendNotification("ExecutePromotionTask.setting", new
                        {
                            PromotionTaskId = id
                        }, 10000);
                    }
                }
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// 创建优惠券任务
        /// </summary>
        /// <param name="promotionTask">优惠券任务对象</param>
        /// <param name="cellPhones">需要发送优惠券的用户列表</param>
        /// <returns></returns>
        public int CreatePromotionTask(PromotionTask promotionTask, List <string> TaskPromotionListIds = null, List <string> cellPhones = null)
        {
            try
            {
                var oper = ThreadIdentity.Operator.Name;
                var task = DalPromotionJob.GetPromotionTaskById(promotionTask.PromotionTaskId ?? 0);
                if (task != null && task.TaskStatus > 0)             //已经审核或者关闭的任务不能修改
                {
                    return(0);
                }
                if (promotionTask.PromotionTaskId != null && promotionTask.PromotionTaskId > 0)
                {
                    //如果是修改了数据源,则要释放原来的数据源
                    if (promotionTask.SelectUserType == 3 && task.PromotionTaskActivityId !=
                        promotionTask.PromotionTaskActivityId)
                    {
                        DalPromotionJob.ResetPromotionTaskActivity(task.PromotionTaskActivityId,
                                                                   task.PromotionTaskId);
                    }
                }

                var resultId = handler.CreatePromotionTask(promotionTask, oper, TaskPromotionListIds, cellPhones);
                if (promotionTask.SelectUserType == 3)
                {
                    //如果是从BI库里获取数据,则要同步taskid
                    DalPromotionJob.SetPromotionTaskActivity(promotionTask.PromotionTaskActivityId.Value, resultId);
                }

                using (var log = new ConfigLogClient())
                {
                    log.InsertDefaultLogQueue("PromotionConfigLog", JsonConvert.SerializeObject(new
                    {
                        ObjectId    = resultId,
                        ObjectType  = "PromTask",
                        BeforeValue = "",
                        AfterValue  = JsonConvert.SerializeObject(promotionTask),
                        Operate     = promotionTask?.PromotionTaskId == null ? "新增优惠券任务" : "修改优惠券任务",
                        Author      = oper
                    }));
                }
                return(resultId);
            }
            catch (Exception ex)
            {
                throw new Exception(" 优惠券任务对象出错");
            }
        }
示例#3
0
        /// <summary>
        /// 创建优惠券任务
        /// </summary>
        /// <param name="promotionTask">优惠券任务对象</param>
        /// <param name="cellPhones">需要发送优惠券的用户列表</param>
        /// <returns></returns>
        public int CreatePromotionTask(PromotionTask promotionTask, List <string> TaskPromotionListIds = null, List <string> cellPhones = null)
        {
            try
            {
                var oper = ThreadIdentity.Operator.Name;
                var task = DalPromotionJob.GetPromotionTaskById(promotionTask.PromotionTaskId ?? 0);
                if (task != null && task.TaskStatus > 0)             //已经审核或者关闭的任务不能修改
                {
                    return(0);
                }
                if (promotionTask.PromotionTaskId != null && promotionTask.PromotionTaskId > 0)
                {
                    //如果是修改了数据源,则要释放原来的数据源
                    if (promotionTask.SelectUserType == 3 && task.PromotionTaskActivityId !=
                        promotionTask.PromotionTaskActivityId)
                    {
                        DalPromotionJob.ResetPromotionTaskActivity(task.PromotionTaskActivityId,
                                                                   task.PromotionTaskId);
                    }
                }
                //新增或者修改优惠券任务 resultId 会会员任务Id
                var resultId = handler.CreatePromotionTask(promotionTask, oper, TaskPromotionListIds, cellPhones);
                if (promotionTask.TaskType.HasValue && promotionTask.TaskType.Value == (int)PromotionTaskType.Repeat)
                {
                    //先删除该Id下所选品类
                    DalPromotionTaskProductCategory.DeletePromotionTaskProductCategory(resultId);
                    //将优惠券任务产品类型保存到关系表
                    if (!string.IsNullOrWhiteSpace(promotionTask.ProductCategoryIds) && promotionTask.ProductCategoryIds.Trim().Length > 0)
                    {
                        var categoryIdList    = promotionTask.ProductCategoryIds.Split(',');
                        var parentCategoryIds = promotionTask.ParentCategoryIds.Split(',');
                        var categoryNames     = promotionTask.CategoryNames.Split(',');
                        var nodeNos           = promotionTask.NodeNos.Split(',');
                        for (int i = 0; i < categoryIdList.Length; i++)
                        {
                            var model = new PromotionTaskProductCategory()
                            {
                                PromotionTaskId   = resultId,
                                ProductCategoryId = Convert.ToInt32(categoryIdList[i]),
                                ParentCategoryId  = Convert.ToInt32(parentCategoryIds[i]),
                                NodeNo            = nodeNos[i],
                                CategoryName      = categoryNames[i],
                                CreateBy          = oper,
                                LastUpdateBy      = oper
                            };
                            DalPromotionTaskProductCategory.Insert(model);
                        }
                    }
                }

                if (promotionTask.SelectUserType == 3)
                {
                    //如果是从BI库里获取数据,则要同步taskid
                    DalPromotionJob.SetPromotionTaskActivity(promotionTask.PromotionTaskActivityId.Value, resultId);
                }

                using (var log = new ConfigLogClient())
                {
                    log.InsertDefaultLogQueue("PromotionConfigLog", JsonConvert.SerializeObject(new
                    {
                        ObjectId    = resultId,
                        ObjectType  = "PromTask",
                        BeforeValue = "",
                        AfterValue  = JsonConvert.SerializeObject(promotionTask),
                        Operate     = promotionTask?.PromotionTaskId == null ? "新增优惠券任务" : "修改优惠券任务",
                        Author      = oper
                    }));
                }
                return(resultId);
            }
            catch (Exception ex)
            {
                throw new Exception(" 优惠券任务对象出错");
            }
        }