faet 添加优惠券取消 自动任务
This commit is contained in:
parent
db01c5a87b
commit
3ea32705ae
24
ARW.Model/Dto/Api/OrderManage/Orders/StoreInfo.cs
Normal file
24
ARW.Model/Dto/Api/OrderManage/Orders/StoreInfo.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using ARW.Model.Models.Business.OrderManage.Orders;
|
||||||
|
|
||||||
|
namespace ARW.Model.Dto.Api.OrderManage.Orders
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单店铺对象Api
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-09-01
|
||||||
|
/// </summary>
|
||||||
|
public class StoreInfo
|
||||||
|
{
|
||||||
|
|
||||||
|
public long StoreId { get; set; }
|
||||||
|
public string StoreName { get; set; }
|
||||||
|
public string Remark { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -56,8 +56,17 @@ namespace ARW.Model.Dto.Api.Pay
|
|||||||
public long CustomerAddressGuid { get; set; }
|
public long CustomerAddressGuid { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 优惠券列表
|
||||||
|
/// </summary>
|
||||||
public List<OrderCoupon> CouponList;
|
public List<OrderCoupon> CouponList;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 店铺信息
|
||||||
|
/// </summary>
|
||||||
|
public List<StoreInfo> StoreInfoList;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
ARW.Model/Vo/Api/Custom/HistorySearchs/SearchRecVoApi.cs
Normal file
20
ARW.Model/Vo/Api/Custom/HistorySearchs/SearchRecVoApi.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using OfficeOpenXml.Attributes;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ARW.Model.Vo.Api.Custom.HistorySearchs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 热门搜索对象Api
|
||||||
|
///
|
||||||
|
/// @author lwh
|
||||||
|
/// @date 2023-10-09
|
||||||
|
/// </summary>
|
||||||
|
public class SearchTermCount
|
||||||
|
{
|
||||||
|
public string SearchTerm { get; set; }
|
||||||
|
public int Count { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -6,15 +6,14 @@ using System;
|
|||||||
namespace ARW.Model.Vo.Api.Custom.HistorySearchs
|
namespace ARW.Model.Vo.Api.Custom.HistorySearchs
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 热门搜索对象Api
|
/// 搜索推荐对象Api
|
||||||
///
|
///
|
||||||
/// @author lwh
|
/// @author lwh
|
||||||
/// @date 2023-10-09
|
/// @date 2023-10-09
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SearchTermCount
|
public class SearchRecVoApi
|
||||||
{
|
{
|
||||||
public string SearchTerm { get; set; }
|
public string Title { get; set; }
|
||||||
public int Count { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,13 @@ namespace ARW.Model.Vo.Api.OrderManage.Orders
|
|||||||
/// 订单号
|
/// 订单号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string OrderNo { get; set; }
|
public string OrderNo { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 备注
|
||||||
|
/// </summary>
|
||||||
|
public string ReMark { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 该店铺待结算列表
|
/// 该店铺待结算列表
|
||||||
|
@ -13,6 +13,7 @@ using ARW.Service.Api.IBusinessService.Custom.HistorySearchs;
|
|||||||
using ARW.Model.Dto.Api.Custom.HistorySearchs;
|
using ARW.Model.Dto.Api.Custom.HistorySearchs;
|
||||||
using ARW.Model.Models.Business.Custom.HistorySearchs;
|
using ARW.Model.Models.Business.Custom.HistorySearchs;
|
||||||
using ARW.Model.Vo.Api.Custom.HistorySearchs;
|
using ARW.Model.Vo.Api.Custom.HistorySearchs;
|
||||||
|
using ARW.Repository.Business.GoodsManager.Goodss;
|
||||||
|
|
||||||
namespace ARW.Service.Api.BusinessService.Custom.HistorySearchs
|
namespace ARW.Service.Api.BusinessService.Custom.HistorySearchs
|
||||||
{
|
{
|
||||||
@ -26,10 +27,12 @@ namespace ARW.Service.Api.BusinessService.Custom.HistorySearchs
|
|||||||
public class HistorySearchServiceImplApi : BaseService<HistorySearch>, IHistorySearchServiceApi
|
public class HistorySearchServiceImplApi : BaseService<HistorySearch>, IHistorySearchServiceApi
|
||||||
{
|
{
|
||||||
private readonly HistorySearchRepository _HistorySearchRepository;
|
private readonly HistorySearchRepository _HistorySearchRepository;
|
||||||
|
private readonly GoodsRepository _GoodsRepository;
|
||||||
|
|
||||||
public HistorySearchServiceImplApi(HistorySearchRepository HistorySearchRepository)
|
public HistorySearchServiceImplApi(HistorySearchRepository HistorySearchRepository, GoodsRepository goodsRepository)
|
||||||
{
|
{
|
||||||
this._HistorySearchRepository = HistorySearchRepository;
|
this._HistorySearchRepository = HistorySearchRepository;
|
||||||
|
_GoodsRepository = goodsRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Api接口代码
|
#region Api接口代码
|
||||||
@ -63,6 +66,27 @@ namespace ARW.Service.Api.BusinessService.Custom.HistorySearchs
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取搜索推荐列表(Api)
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<List<SearchRecVoApi>> GetSearchRecList()
|
||||||
|
{
|
||||||
|
|
||||||
|
var query = _GoodsRepository
|
||||||
|
.Queryable()
|
||||||
|
.OrderBy(g => Guid.NewGuid())
|
||||||
|
.Select(s => new SearchRecVoApi
|
||||||
|
{
|
||||||
|
Title = s.GoodsName,
|
||||||
|
}).Take(10);
|
||||||
|
|
||||||
|
return await query.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取热门搜索列表(Api)
|
/// 获取热门搜索列表(Api)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -256,7 +256,7 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm"></param>
|
/// <param name="parm"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<DiscountRes> CalculateAfterPrice(CommitPayDtoApi parm,decimal totalPrice)
|
public async Task<DiscountRes> CalculateAfterPrice(CommitPayDtoApi parm, decimal totalPrice)
|
||||||
{
|
{
|
||||||
var res = new DiscountRes();
|
var res = new DiscountRes();
|
||||||
res.DiscountPrice = totalPrice;
|
res.DiscountPrice = totalPrice;
|
||||||
@ -265,7 +265,7 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
|
|||||||
{
|
{
|
||||||
foreach (var item in parm.CouponList)
|
foreach (var item in parm.CouponList)
|
||||||
{
|
{
|
||||||
if(item.Key != 0)
|
if (item.Key != 0)
|
||||||
{
|
{
|
||||||
var customerCoupon = await _CustomerCouponRepository.GetFirstAsync(s => s.CustomerCouponId == item.Key);
|
var customerCoupon = await _CustomerCouponRepository.GetFirstAsync(s => s.CustomerCouponId == item.Key);
|
||||||
var coupon = await _CouponRepository.GetFirstAsync(s => s.CouponGuid == customerCoupon.CouponGuid);
|
var coupon = await _CouponRepository.GetFirstAsync(s => s.CouponGuid == customerCoupon.CouponGuid);
|
||||||
@ -354,6 +354,18 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
|
|||||||
{
|
{
|
||||||
if (item.StoreId == shopGuid)
|
if (item.StoreId == shopGuid)
|
||||||
{
|
{
|
||||||
|
// 获取当前店铺的订单备注
|
||||||
|
if (parm.StoreInfoList.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var item1 in parm.StoreInfoList)
|
||||||
|
{
|
||||||
|
if (item1.StoreId == shopGuid)
|
||||||
|
{
|
||||||
|
orderShop.ReMark = item1.Remark;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
orderShopGoodsRequestList.Add(item);
|
orderShopGoodsRequestList.Add(item);
|
||||||
// 关联购物车ids
|
// 关联购物车ids
|
||||||
CartIdsList.Add(item.CartId);
|
CartIdsList.Add(item.CartId);
|
||||||
@ -392,12 +404,12 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
|
|||||||
PaymentGuid = paymentGuid,
|
PaymentGuid = paymentGuid,
|
||||||
CustomerGuid = parm.UserId,
|
CustomerGuid = parm.UserId,
|
||||||
OrderNumber = item.OrderNo,
|
OrderNumber = item.OrderNo,
|
||||||
|
OrderRemark = item.ReMark,
|
||||||
ShopGuid = item.ShopGuid,
|
ShopGuid = item.ShopGuid,
|
||||||
CouponGuid = discountRes?.CouponGuid,
|
CouponGuid = discountRes?.CouponGuid,
|
||||||
CouponMoney = discountRes.CouponMoney,
|
CouponMoney = discountRes.CouponMoney,
|
||||||
GoodsTotalAmoun = goodsTotalMoney,
|
GoodsTotalAmoun = goodsTotalMoney,
|
||||||
OrderAmount = discountRes.DiscountPrice,
|
OrderAmount = discountRes.DiscountPrice,
|
||||||
OrderRemark = parm?.Remark,
|
|
||||||
PayType = parm.PayType,
|
PayType = parm.PayType,
|
||||||
PayStatus = 1,
|
PayStatus = 1,
|
||||||
DeliveryStatus = 1,
|
DeliveryStatus = 1,
|
||||||
@ -408,7 +420,7 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
|
|||||||
OrderStatus = 1,
|
OrderStatus = 1,
|
||||||
DeliveryType = 1,
|
DeliveryType = 1,
|
||||||
ExpressPrice = freight,
|
ExpressPrice = freight,
|
||||||
CartIds = string.Join(",",item.CartIdsList)
|
CartIds = string.Join(",", item.CartIdsList)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,6 +26,13 @@ namespace ARW.Service.Api.IBusinessService.Custom.HistorySearchs
|
|||||||
Task<List<HistorySearchVoApi>> GetHistorySearchListApi(HistorySearchQueryDtoApi parm);
|
Task<List<HistorySearchVoApi>> GetHistorySearchListApi(HistorySearchQueryDtoApi parm);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取搜索推荐列表(Api)
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<SearchRecVoApi>> GetSearchRecList();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取热门搜索列表(Api)
|
/// 获取热门搜索列表(Api)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
150
ARW.Tasks/TaskScheduler/Business/CouponTask_Job.cs
Normal file
150
ARW.Tasks/TaskScheduler/Business/CouponTask_Job.cs
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
using ARW.Common;
|
||||||
|
using ARW.Model.Models.Business.SubscribeTasks;
|
||||||
|
using ARW.Model.System;
|
||||||
|
using ARW.Service.Business.IBusinessService.Marketing.CouponManage.Coupons;
|
||||||
|
using ARW.Service.Business.IBusinessService.Marketing.CouponManage.CustomerCoupons;
|
||||||
|
using ARW.Service.Business.IBusinessService.SubscribeTasks;
|
||||||
|
using ARW.Service.System.IService;
|
||||||
|
using Infrastructure;
|
||||||
|
using Infrastructure.Attribute;
|
||||||
|
using Infrastructure.WeChat.SubScribe;
|
||||||
|
using Quartz;
|
||||||
|
using Senparc.CO2NET.Extensions;
|
||||||
|
using Senparc.Weixin.Entities.TemplateMessage;
|
||||||
|
using Senparc.Weixin.WxOpen.AdvancedAPIs.WxApp.WxAppJson;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SystemTime = System.SystemTime;
|
||||||
|
|
||||||
|
namespace ARW.Tasks.TaskScheduler.Business
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 优惠券过期任务
|
||||||
|
/// </summary>
|
||||||
|
[AppService(ServiceType = typeof(CouponTask_Job), ServiceLifetime = LifeTime.Scoped)]
|
||||||
|
public class CouponTask_Job : JobBase, IJob
|
||||||
|
{
|
||||||
|
private readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||||
|
private readonly ISysTasksLogService SysTasksLogService;
|
||||||
|
private readonly ISysTasksQzService SysTasksQzService;
|
||||||
|
|
||||||
|
private readonly ISubscribeTaskService _SubscribeTaskService;
|
||||||
|
private readonly ICouponService _CouponService;
|
||||||
|
private readonly ICustomerCouponService _CustomerCouponService;
|
||||||
|
|
||||||
|
|
||||||
|
public CouponTask_Job(ISysTasksLogService sysTasksLogService, ISysTasksQzService sysTasksQzService, ISubscribeTaskService subscribeTaskService, ICouponService couponService, ICustomerCouponService customerCouponService)
|
||||||
|
{
|
||||||
|
SysTasksLogService = sysTasksLogService;
|
||||||
|
SysTasksQzService = sysTasksQzService;
|
||||||
|
_SubscribeTaskService = subscribeTaskService;
|
||||||
|
_CouponService = couponService;
|
||||||
|
_CustomerCouponService = customerCouponService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Execute(IJobExecutionContext context)
|
||||||
|
{
|
||||||
|
var message = await Run();
|
||||||
|
var logModel = await ExecuteJob(context, async () => await Run(), message);
|
||||||
|
await RecordTaskLog(context, logModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<string> Run()
|
||||||
|
{
|
||||||
|
await Task.Delay(1);
|
||||||
|
//TODO 业务逻辑
|
||||||
|
|
||||||
|
var waiCancelList = await _CustomerCouponService.GetListAsync(s => s.CustomerCouponIsExpired == 1 && s.CustomerCouponIsUsed == 1 && s.IsDelete == false);
|
||||||
|
if (waiCancelList.Count > 0)
|
||||||
|
{
|
||||||
|
var taskList = new List<string>();
|
||||||
|
foreach (var item in waiCancelList)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 判断类型
|
||||||
|
var coupon = await _CouponService.GetFirstAsync(s => s.CouponGuid == item.CouponGuid);
|
||||||
|
if(coupon != null)
|
||||||
|
{
|
||||||
|
// 领券后生效
|
||||||
|
if (coupon.CouponExpireType == 1)
|
||||||
|
{
|
||||||
|
var endTime = item.Create_time.AddDays(coupon.CouponEffectiveDays);
|
||||||
|
if (endTime < DateTime.Now)
|
||||||
|
{
|
||||||
|
item.CustomerCouponIsExpired = 2;
|
||||||
|
await _CustomerCouponService.UpdateAsync(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 固定时间
|
||||||
|
if (coupon.CouponExpireType == 2)
|
||||||
|
{
|
||||||
|
var endTime = coupon.CouponFixedEndTime;
|
||||||
|
if (endTime < DateTime.Now)
|
||||||
|
{
|
||||||
|
item.CustomerCouponIsExpired = 2;
|
||||||
|
await _CustomerCouponService.UpdateAsync(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return ex.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return taskList.ToJson().ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "没有需要执行的任务";
|
||||||
|
}
|
||||||
|
//return "执行成功!";
|
||||||
|
|
||||||
|
#region 公众号模板消息信息 -- DPBMARK MP
|
||||||
|
|
||||||
|
//可选参数(需要和公众号模板消息匹配):
|
||||||
|
//var templateData = new
|
||||||
|
//{
|
||||||
|
// first = new Senparc.Weixin.MP.AdvancedAPIs.TemplateMessage.TemplateDataItem("预约健身开始提醒"),
|
||||||
|
// keyword1 = new Senparc.Weixin.MP.AdvancedAPIs.TemplateMessage.TemplateDataItem("测试门店"),
|
||||||
|
// keyword2 = new Senparc.Weixin.MP.AdvancedAPIs.TemplateMessage.TemplateDataItem("佛山市顺德区xxx健身"),
|
||||||
|
// keyword3 = new Senparc.Weixin.MP.AdvancedAPIs.TemplateMessage.TemplateDataItem(SystemTime.Now.ToString("yyyy年MM月dd日 HH:mm")),
|
||||||
|
// keyword4 = new Senparc.Weixin.MP.AdvancedAPIs.TemplateMessage.TemplateDataItem("1小时"),
|
||||||
|
// keyword5 = new Senparc.Weixin.MP.AdvancedAPIs.TemplateMessage.TemplateDataItem("还有1个小时开始健身,请熟知!"),
|
||||||
|
// remark = new Senparc.Weixin.MP.AdvancedAPIs.TemplateMessage.TemplateDataItem("您的 OpenId:" + openId),
|
||||||
|
//};
|
||||||
|
#endregion DPBMARK_END
|
||||||
|
//System.Console.WriteLine("job test");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 记录到日志
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <param name="logModel"></param>
|
||||||
|
public async Task RecordTaskLog(IJobExecutionContext context, SysTasksLog logModel)
|
||||||
|
{
|
||||||
|
|
||||||
|
//可以直接获取 JobDetail 的值
|
||||||
|
IJobDetail job = context.JobDetail;
|
||||||
|
|
||||||
|
logModel.InvokeTarget = job.JobType.FullName;
|
||||||
|
logModel = await SysTasksLogService.AddTaskLog(job.Key.Name, logModel);
|
||||||
|
//成功后执行次数+1
|
||||||
|
if (logModel.Status == "0")
|
||||||
|
{
|
||||||
|
await SysTasksQzService.UpdateAsync(f => new SysTasksQz()
|
||||||
|
{
|
||||||
|
RunTimes = f.RunTimes + 1,
|
||||||
|
LastRunTime = DateTime.Now
|
||||||
|
}, f => f.ID.ToString() == job.Key.Name);
|
||||||
|
}
|
||||||
|
logger.Info($"执行任务【{job.Key.Name}|{logModel.JobName}】结果={logModel.JobMessage}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -59,6 +59,18 @@ namespace ARW.WebApi.Controllers.Api.Custom.HistorySearchs
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取搜索推荐列表(Api)
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("getSearchRecList")]
|
||||||
|
public async Task<IActionResult> GetSearchRecList()
|
||||||
|
{
|
||||||
|
var res = await _HistorySearchServiceApi.GetSearchRecList();
|
||||||
|
return SUCCESS(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取热门搜索列表(Api)
|
/// 获取热门搜索列表(Api)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user