/// <summary> /// 根据原优惠券,创建新优惠券,并且插入日志 /// </summary> /// <param name="promotionId"></param> /// <param name="operation"></param> /// <returns></returns> private string CreateNewPromotionByOldPromotion(int promotionId, string operation = "部分取消") { if (promotionId > 0) { var oldPromotionCode = dbManager.Execute(connection => DalPromotionJob.FetchPromotionCodeByPromotionCode(connection, promotionId)); oldPromotionCode.RuleName = oldPromotionCode.PromtionName; if (oldPromotionCode != null) { oldPromotionCode.Status = 0; oldPromotionCode.CodeChannel = oldPromotionCode.CodeChannel + "(取消订单)"; CreatePromotionModel createPromotionModel = new CreatePromotionModel() { Author = ThreadIdentity.Operator.Name, Channel = "取消订单", Operation = "原优惠券生成新优惠券", PromotionPKID = oldPromotionCode.PkId }; using (var client = new PromotionClient()) { var result = client.CopyPromotionCode(createPromotionModel); if (result.Success) { new OprLogManager().AddOprLog <BizPromotionCode>("Order", oldPromotionCode.OrderId, operation + "原优惠券不释放,生成一张一样的优惠券,优惠券PKID:" + result.Result, null, null); } else { throw new Exception("根据原优惠券生成新优惠券失败,订单号:" + oldPromotionCode.OrderId); } } //var newPromotionCode = dbManager.Execute(connection => DalPromotionJob.CreatePromotionCode(connection, oldPromotionCode)); //new OprLogManager().AddOprLog<BizPromotionCode>("Order", oldPromotionCode.OrderId, operation + "原优惠券不释放,生成一张一样的优惠券,优惠券PKID:" + newPromotionCode, null, null); } } return(string.Empty); }
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); }
static void SyncOrderData(SearchPromotionByCondition oneTask) { //判断是否已经同步过,同步过就不再执行 var waitUsers = DalPromotionJob.ExistsPromotionTaskUsers(oneTask.PromotionTaskId); var historyUsers = DalPromotionJob.ExistsPromotionTaskHistoryUsers(oneTask.PromotionTaskId); if (waitUsers || historyUsers) { return; } DalPromotionJob.MoveFilterOrderData(oneTask.PromotionTaskId); }
static void SyncBiActivityData(SearchPromotionByCondition oneTask) { //判断是否已经同步过,同步过就不再执行 var waitUsers = DalPromotionJob.ExistsPromotionTaskUsers(oneTask.PromotionTaskId); var historyUsers = DalPromotionJob.ExistsPromotionTaskHistoryUsers(oneTask.PromotionTaskId); if (waitUsers || historyUsers) { return; } //把BI表里的数据同步到待发送表里去 DalPromotionJob.MovePromotionTaskActivityUsers(oneTask.PromotionTaskActivityId, oneTask.PromotionTaskId); }
/// <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(" 优惠券任务对象出错"); } }
public object SelectCodeChannelByAddGift(int id) { return(DalPromotionJob.SelectCodeChannelByAddGift(id)); }
/// <summary> /// 根据优惠券ID查询优惠券名称 /// </summary> /// <param name="promotionRuleId"></param> /// <returns></returns> public string GetPromotionRuleNameById(int promotionRuleId) { return(DalPromotionJob.GetPromotionRuleNameById(promotionRuleId)); }
public string GenerateCoupon(int Number, int DetailsID) { return(DalPromotionJob.GenerateCoupon(Number, DetailsID)); }
public DataTable SelectGiftByDonwLoad(int pkid) { return(DalPromotionJob.SelectGiftByDonwLoad(pkid)); }
public DataTable SelectGiftBag(int PageNumber, int PageSize, out int TotalCount) { return(DalPromotionJob.SelectGiftBag(PageNumber, PageSize, out TotalCount)); }
/// <summary> /// 获得一个订单使用的优惠券数量 /// </summary> /// <param name="orderId"></param> /// <returns></returns> public int GetOrderUsedPromtionCodeNumByOrderId(int orderId) { ParameterChecker.CheckNull(orderId, "OrderId"); return(dbManager.Execute(connection => DalPromotionJob.GetOrderUsedPromtionCodeNumByOrderId(connection, orderId))); }
/// <summary> /// 查询优惠券下拉列表 /// </summary> /// <returns></returns> public DataTable SelectDropDownList() { return(DalPromotionJob.SelectDropDownList()); }
public DataSet SelectByPhoneNum(string PhoneNum) { return(DalPromotionJob.SelectByPhoneNum(PhoneNum)); }
public int DeleteGift(int pkid) { return(DalPromotionJob.DeleteGift(pkid)); }
public int SelectPromoCodeCount(int pkid) { return(DalPromotionJob.SelectPromoCodeCount(pkid)); }
public int DeletePromoCode(int pkid) { return(DalPromotionJob.DeletePromoCode(pkid)); }
public DataTable CreateExcel(int pkid) { return(DalPromotionJob.CreateExcel(pkid)); }
public List <BizPromotionCode> SelectPromotionCodesByUserId(string userId) { ParameterChecker.CheckNull(userId, "UserId"); return(dbManager.Execute(connection => DalPromotionJob.SelectPromotionCodesByUserId(userId))); }
/// <summary> /// 根据订单号查询优惠券 /// </summary> /// <param name="OrderId"></param> /// <returns></returns> public List <BizPromotionCode> SelectPromotionByOrderId(int OrderId) { ParameterChecker.CheckNull(OrderId, "OrderId"); return(dbManager.Execute(connection => DalPromotionJob.SelectPromotionByOrderId(OrderId))); }
/// <summary> /// 创建优惠券 /// </summary> /// <param name="ecd"></param> /// <returns></returns> public int CreeatePromotion(ExchangeCodeDetail ecd) { return(DalPromotionJob.CreeatePromotion(ecd)); }
public DataTable SelectExchangeCodeDetailByPage(int PageNumber, int PageSize, out int TotalCount) { return(DalPromotionJob.SelectExchangeCodeDetailByPage(PageNumber, PageSize, out TotalCount)); }
/// <summary> /// 优惠券列表详情 /// </summary> /// <param name="pkid"></param> /// <returns></returns> public DataTable SelectPromotionDetails(int pkid) { return(DalPromotionJob.SelectPromotionDetails(pkid)); }
public DataTable SelectGiftBagByPKID(int pkid) { return(DalPromotionJob.SelectGiftBagByPKID(pkid)); }
/// <summary> /// 查询优惠券详情-->修改 /// </summary> /// <param name="id"></param> /// <returns></returns> public DataTable SelectPromotionDetailsByEdit(int id) { return(DalPromotionJob.SelectPromotionDetailsByEdit(id)); }
public int SelectDownloadByPKID(int pkid) { return(DalPromotionJob.SelectDownloadByPKID(pkid)); }
public int DoUpdateOEM(ExchangeCodeDetail ecd) { return(DalPromotionJob.DoUpdateOEM(ecd)); }
/// <summary> /// 修改优惠券 /// </summary> /// <param name="ecd"></param> /// <returns></returns> public int UpdatePromotionDetailsByOK(ExchangeCodeDetail ecd) { return(DalPromotionJob.UpdatePromotionDetailsByOK(ecd)); }
public int AddOEM(ExchangeCodeDetail ecd) { return(DalPromotionJob.AddOEM(ecd)); }
/// <summary> /// 创建优惠券执行任务 /// </summary> /// <param name="promotionTask">优惠券任务对象</param> /// <param name="operateBy">操作者</param> /// <param name="cellPhones">需要发券的用户列表</param> /// <returns></returns> public int CreatePromotionTask(PromotionTask promotionTask, string operateBy, List <string> TaskPromotionListIds = null, List <string> cellPhones = null) { return(DalPromotionJob.CreateOrUpdatePromotionTask(promotionTask, operateBy, TaskPromotionListIds, cellPhones)); }
public int UpdateGift(ExchangeCodeDetail ecd) { return(DalPromotionJob.UpdateGift(ecd)); }