diff --git a/ARW.Model/Dto/Api/OrderManage/Orders/StoreInfo.cs b/ARW.Model/Dto/Api/OrderManage/Orders/StoreInfo.cs new file mode 100644 index 0000000..0d0146e --- /dev/null +++ b/ARW.Model/Dto/Api/OrderManage/Orders/StoreInfo.cs @@ -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 +{ + + /// + /// 订单店铺对象Api + /// + /// @author lwh + /// @date 2023-09-01 + /// + public class StoreInfo + { + + public long StoreId { get; set; } + public string StoreName { get; set; } + public string Remark { get; set; } + } + + +} diff --git a/ARW.Model/Dto/Api/Pay/CommitPayDtoApi.cs b/ARW.Model/Dto/Api/Pay/CommitPayDtoApi.cs index a731e7f..de77089 100644 --- a/ARW.Model/Dto/Api/Pay/CommitPayDtoApi.cs +++ b/ARW.Model/Dto/Api/Pay/CommitPayDtoApi.cs @@ -56,8 +56,17 @@ namespace ARW.Model.Dto.Api.Pay public long CustomerAddressGuid { get; set; } - + /// + /// 优惠券列表 + /// public List CouponList; + + /// + /// 店铺信息 + /// + public List StoreInfoList; + + } } diff --git a/ARW.Model/Vo/Api/Custom/HistorySearchs/SearchRecVoApi.cs b/ARW.Model/Vo/Api/Custom/HistorySearchs/SearchRecVoApi.cs new file mode 100644 index 0000000..ad530c0 --- /dev/null +++ b/ARW.Model/Vo/Api/Custom/HistorySearchs/SearchRecVoApi.cs @@ -0,0 +1,20 @@ +using Newtonsoft.Json; +using OfficeOpenXml.Attributes; +using SqlSugar; +using System; + +namespace ARW.Model.Vo.Api.Custom.HistorySearchs +{ + /// + /// 热门搜索对象Api + /// + /// @author lwh + /// @date 2023-10-09 + /// + public class SearchTermCount + { + public string SearchTerm { get; set; } + public int Count { get; set; } + } + +} diff --git a/ARW.Model/Vo/Api/Custom/HistorySearchs/SearchTermCount.cs b/ARW.Model/Vo/Api/Custom/HistorySearchs/SearchTermCount.cs index ad530c0..e004104 100644 --- a/ARW.Model/Vo/Api/Custom/HistorySearchs/SearchTermCount.cs +++ b/ARW.Model/Vo/Api/Custom/HistorySearchs/SearchTermCount.cs @@ -6,15 +6,14 @@ using System; namespace ARW.Model.Vo.Api.Custom.HistorySearchs { /// - /// 热门搜索对象Api + /// 搜索推荐对象Api /// /// @author lwh /// @date 2023-10-09 /// - public class SearchTermCount + public class SearchRecVoApi { - public string SearchTerm { get; set; } - public int Count { get; set; } + public string Title { get; set; } } } diff --git a/ARW.Model/Vo/Api/OrderManage/Orders/OrderShopApiVo.cs b/ARW.Model/Vo/Api/OrderManage/Orders/OrderShopApiVo.cs index b195743..1577554 100644 --- a/ARW.Model/Vo/Api/OrderManage/Orders/OrderShopApiVo.cs +++ b/ARW.Model/Vo/Api/OrderManage/Orders/OrderShopApiVo.cs @@ -28,7 +28,13 @@ namespace ARW.Model.Vo.Api.OrderManage.Orders /// 订单号 /// public string OrderNo { get; set; } - + + + /// + /// 备注 + /// + public string ReMark { get; set; } + /// /// 该店铺待结算列表 diff --git a/ARW.Service/Api/BusinessService/Custom/HistorySearchs/HistorySearchServiceApi.cs b/ARW.Service/Api/BusinessService/Custom/HistorySearchs/HistorySearchServiceApi.cs index ef9a3f4..71d0e1c 100644 --- a/ARW.Service/Api/BusinessService/Custom/HistorySearchs/HistorySearchServiceApi.cs +++ b/ARW.Service/Api/BusinessService/Custom/HistorySearchs/HistorySearchServiceApi.cs @@ -13,6 +13,7 @@ using ARW.Service.Api.IBusinessService.Custom.HistorySearchs; using ARW.Model.Dto.Api.Custom.HistorySearchs; using ARW.Model.Models.Business.Custom.HistorySearchs; using ARW.Model.Vo.Api.Custom.HistorySearchs; +using ARW.Repository.Business.GoodsManager.Goodss; namespace ARW.Service.Api.BusinessService.Custom.HistorySearchs { @@ -26,10 +27,12 @@ namespace ARW.Service.Api.BusinessService.Custom.HistorySearchs public class HistorySearchServiceImplApi : BaseService, IHistorySearchServiceApi { private readonly HistorySearchRepository _HistorySearchRepository; + private readonly GoodsRepository _GoodsRepository; - public HistorySearchServiceImplApi(HistorySearchRepository HistorySearchRepository) + public HistorySearchServiceImplApi(HistorySearchRepository HistorySearchRepository, GoodsRepository goodsRepository) { this._HistorySearchRepository = HistorySearchRepository; + _GoodsRepository = goodsRepository; } #region Api接口代码 @@ -63,6 +66,27 @@ namespace ARW.Service.Api.BusinessService.Custom.HistorySearchs } + + /// + /// 获取搜索推荐列表(Api) + /// + /// + public async Task> GetSearchRecList() + { + + var query = _GoodsRepository + .Queryable() + .OrderBy(g => Guid.NewGuid()) + .Select(s => new SearchRecVoApi + { + Title = s.GoodsName, + }).Take(10); + + return await query.ToListAsync(); + } + + + /// /// 获取热门搜索列表(Api) /// diff --git a/ARW.Service/Api/BusinessService/PayManage/PayServiceApi.cs b/ARW.Service/Api/BusinessService/PayManage/PayServiceApi.cs index 59ed665..a9f5d9a 100644 --- a/ARW.Service/Api/BusinessService/PayManage/PayServiceApi.cs +++ b/ARW.Service/Api/BusinessService/PayManage/PayServiceApi.cs @@ -256,7 +256,7 @@ namespace ARW.Service.Api.BusinessService.PaymentManage /// /// /// - public async Task CalculateAfterPrice(CommitPayDtoApi parm,decimal totalPrice) + public async Task CalculateAfterPrice(CommitPayDtoApi parm, decimal totalPrice) { var res = new DiscountRes(); res.DiscountPrice = totalPrice; @@ -265,7 +265,7 @@ namespace ARW.Service.Api.BusinessService.PaymentManage { 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 coupon = await _CouponRepository.GetFirstAsync(s => s.CouponGuid == customerCoupon.CouponGuid); @@ -354,6 +354,18 @@ namespace ARW.Service.Api.BusinessService.PaymentManage { 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); // 关联购物车ids CartIdsList.Add(item.CartId); @@ -392,12 +404,12 @@ namespace ARW.Service.Api.BusinessService.PaymentManage PaymentGuid = paymentGuid, CustomerGuid = parm.UserId, OrderNumber = item.OrderNo, + OrderRemark = item.ReMark, ShopGuid = item.ShopGuid, CouponGuid = discountRes?.CouponGuid, CouponMoney = discountRes.CouponMoney, GoodsTotalAmoun = goodsTotalMoney, OrderAmount = discountRes.DiscountPrice, - OrderRemark = parm?.Remark, PayType = parm.PayType, PayStatus = 1, DeliveryStatus = 1, @@ -408,7 +420,7 @@ namespace ARW.Service.Api.BusinessService.PaymentManage OrderStatus = 1, DeliveryType = 1, ExpressPrice = freight, - CartIds = string.Join(",",item.CartIdsList) + CartIds = string.Join(",", item.CartIdsList) }; diff --git a/ARW.Service/Api/IBusinessService/Custom/HistorySearchs/IHistorySearchServiceApi.cs b/ARW.Service/Api/IBusinessService/Custom/HistorySearchs/IHistorySearchServiceApi.cs index a61951f..a7a1d38 100644 --- a/ARW.Service/Api/IBusinessService/Custom/HistorySearchs/IHistorySearchServiceApi.cs +++ b/ARW.Service/Api/IBusinessService/Custom/HistorySearchs/IHistorySearchServiceApi.cs @@ -26,6 +26,13 @@ namespace ARW.Service.Api.IBusinessService.Custom.HistorySearchs Task> GetHistorySearchListApi(HistorySearchQueryDtoApi parm); + /// + /// 获取搜索推荐列表(Api) + /// + /// + Task> GetSearchRecList(); + + /// /// 获取热门搜索列表(Api) /// diff --git a/ARW.Tasks/TaskScheduler/Business/CouponTask_Job.cs b/ARW.Tasks/TaskScheduler/Business/CouponTask_Job.cs new file mode 100644 index 0000000..a7e4ecc --- /dev/null +++ b/ARW.Tasks/TaskScheduler/Business/CouponTask_Job.cs @@ -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 +{ + /// + /// 优惠券过期任务 + /// + [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 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(); + 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"); + } + + + /// + /// 记录到日志 + /// + /// + /// + 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}"); + } + } +} diff --git a/ARW.WebApi/Controllers/Api/Custom/HistorySearchs/HistorySearchApiController.cs b/ARW.WebApi/Controllers/Api/Custom/HistorySearchs/HistorySearchApiController.cs index bc57064..ea11aa3 100644 --- a/ARW.WebApi/Controllers/Api/Custom/HistorySearchs/HistorySearchApiController.cs +++ b/ARW.WebApi/Controllers/Api/Custom/HistorySearchs/HistorySearchApiController.cs @@ -59,6 +59,18 @@ namespace ARW.WebApi.Controllers.Api.Custom.HistorySearchs } + /// + /// 获取搜索推荐列表(Api) + /// + /// + [HttpGet("getSearchRecList")] + public async Task GetSearchRecList() + { + var res = await _HistorySearchServiceApi.GetSearchRecList(); + return SUCCESS(res); + } + + /// /// 获取热门搜索列表(Api) ///