From fc669a9e87ef979bb4f642708455f0e43dce6801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?old=E6=98=93?= <156663459@qq.com> Date: Mon, 22 Jan 2024 14:24:36 +0800 Subject: [PATCH] order bug fixed --- .../Controllers/Back/OrderInfoController.cs | 7 ++ New_College.Api/New_College.Model.xml | 35 ++++++ New_College.IServices/IV_OrderInfoServices.cs | 7 +- .../ViewModels/Query/OrderInfoQuery.cs | 39 +++++++ New_College.Services/V_OrderInfoServices.cs | 100 ++++++++++++++++-- 5 files changed, 181 insertions(+), 7 deletions(-) diff --git a/New_College.Api/Controllers/Back/OrderInfoController.cs b/New_College.Api/Controllers/Back/OrderInfoController.cs index 85d553a..64c717e 100644 --- a/New_College.Api/Controllers/Back/OrderInfoController.cs +++ b/New_College.Api/Controllers/Back/OrderInfoController.cs @@ -39,5 +39,12 @@ namespace New_College.Api.Controllers.Back { return await v_OrderInfoServices.GetOrderInfoByPage(query); } + + [HttpGet] + public async Task>> GetFrontOrderInfoList([FromQuery] FrontOrderQuery query) + { + return await v_OrderInfoServices.GetFrontOrderInfoPage(query); + } + } } diff --git a/New_College.Api/New_College.Model.xml b/New_College.Api/New_College.Model.xml index 84d09fe..ea60195 100644 --- a/New_College.Api/New_College.Model.xml +++ b/New_College.Api/New_College.Model.xml @@ -4740,6 +4740,41 @@ 根据out_trade_no号查询 + + + + + + + + 根据卡号查询 + + + + + 根据VIP类别查询 + + + + + 根据支付方式查询 + + + + + 根据支付状态查询 + + + + + 根据CustomerId + + + + + 根据out_trade_no号查询 + + 微信浏览器(标价金额) diff --git a/New_College.IServices/IV_OrderInfoServices.cs b/New_College.IServices/IV_OrderInfoServices.cs index 4421291..3552368 100644 --- a/New_College.IServices/IV_OrderInfoServices.cs +++ b/New_College.IServices/IV_OrderInfoServices.cs @@ -23,7 +23,12 @@ namespace New_College.IServices Task UpdateOrderStatus(string orderNo, EnumPayType payType, string trade_no); - + /// + /// + /// + /// + /// + Task>> GetFrontOrderInfoPage(FrontOrderQuery query); /// diff --git a/New_College.Model/ViewModels/Query/OrderInfoQuery.cs b/New_College.Model/ViewModels/Query/OrderInfoQuery.cs index 4b2930b..7eabaa9 100644 --- a/New_College.Model/ViewModels/Query/OrderInfoQuery.cs +++ b/New_College.Model/ViewModels/Query/OrderInfoQuery.cs @@ -130,4 +130,43 @@ namespace New_College.Model.ViewModels } + + /// + /// + /// + public class FrontOrderQuery : BasePageRequest + { + /// + /// 根据卡号查询 + /// + public string CardNo { get; set; } + + /// + /// 根据VIP类别查询 + /// + public int? CardTypeId { get; set; } + + /// + /// 根据支付方式查询 + /// + public int? PayType { get; set; } + + /// + /// 根据支付状态查询 + /// + public int? Status { get; set; } + + /// + /// 根据CustomerId + /// + public int CustomerId { get; set; } + + /// + /// 根据out_trade_no号查询 + /// + public string out_trade_no { get; set; } + + + } + } diff --git a/New_College.Services/V_OrderInfoServices.cs b/New_College.Services/V_OrderInfoServices.cs index acfb31a..c388015 100644 --- a/New_College.Services/V_OrderInfoServices.cs +++ b/New_College.Services/V_OrderInfoServices.cs @@ -18,6 +18,8 @@ using System.Collections.Generic; using LinqKit; using System.IO; using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using System.Linq.Expressions; namespace New_College.Services { @@ -32,7 +34,7 @@ namespace New_College.Services private readonly ILogger logger; public int Nums = 10; - public V_OrderInfoServices( IBaseRepository dal + public V_OrderInfoServices(IBaseRepository dal , IUnitOfWork IUnitOfWork , IV_CustomerInfoRepository IV_CustomerInfoRepository , IV_VipCardInfoRepository IV_VipCardInfoRepository @@ -58,11 +60,11 @@ namespace New_College.Services { viewModel.OutTradeNo = OrderGenerateHelper.GenerateOrderNo("ZY"); viewModel.Total = 99 * 100; - - - return await WeChatPayV3.QrCodePay(viewModel.Total.Value,"demo"); - + + return await WeChatPayV3.QrCodePay(viewModel.Total.Value, "demo"); + + } /// @@ -213,6 +215,85 @@ namespace New_College.Services }; } + + + public async Task>> GetFrontOrderInfoPage(FrontOrderQuery query) + { + + if (query.CustomerId <= 0) + { + return new MessageModel>() + { + msg = "customerId is null", + + }; + } + var payType = query.PayType.HasValue ? (EnumPayType)query.PayType.Value : 0; + var payStatus = query.Status.HasValue ? (EnumOrderType)query.Status.Value : 0; + Expression> wheres = Expressionable.Create() + .And(x => x.IsDelete == false) + .And(x => x.CustomerId == query.CustomerId) + .AndIF(!string.IsNullOrWhiteSpace(query.CardNo), x => x.CardNo.Contains(query.CardNo))//根据卡号查询 + .And(x => x.Status == payStatus) //根据支付状态查询 + .And(x => x.PayType == payType) + .AndIF(!string.IsNullOrWhiteSpace(query.out_trade_no), x => x.out_trade_no.Contains(query.out_trade_no)) + .AndIF(query.CardTypeId > 0, x => x.CardTypeId == query.CardTypeId) //根据卡片类别查询 + .ToExpression(); + var info = await _dal.QueryPage(wheres, query.PageIndex, query.PageSize); + if (info.data.Count <= 0) + return new MessageModel>() + { + success = false, + msg = "获取失败" + }; + var idsCard = info.data.Select(x => x.CardTypeId).ToList(); + var idsCoustomer = info.data.Select(x => x.CustomerId).ToList(); + var listCard = await v_VipCardTypeRepository.Query(x => idsCard.Contains(x.Id) && x.IsDelete == false); + var listCoustomer = await v_CustomerInfoRepository.Query(x => idsCoustomer.Contains(x.Id) && x.IsDelete == false); + PageModel pageModel = new PageModel() { }; + List list = new List() { }; + foreach (var item in info.data) + { + var CardOne = listCard.Where(x => x.Id == item.CardTypeId).FirstOrDefault(); + if (CardOne == null) + continue; + var CoustomerOne = listCoustomer.Where(x => x.Id == item.CustomerId).FirstOrDefault(); + if (CoustomerOne == null) + continue; + + list.Add(new OrderInfoQuery() + { + CardId = item.Id, + PayPrice = item.PayPrice, + Price = item.Price, + CardNo = item.CardNo, + CardTypeName = CardOne.Name, + OrderId = item.OrderId, + CustomerName = CoustomerOne.NickName, + Name = item.Name, + //支付状态 + StatusName = item.Status.GetDescription(), + out_trade_no = item.out_trade_no, + //支付方式 + PayTypeName = item.PayType.GetDescription(), + + Phone = CoustomerOne.Phone, + }); + } + pageModel.data = list; + pageModel.dataCount = info.dataCount; + pageModel.page = info.page; + pageModel.pageCount = info.pageCount; + pageModel.PageSize = info.PageSize; + return new MessageModel>() + { + success = true, + msg = "获取成功", + response = pageModel + }; + } + + //public async Task> /// @@ -254,6 +335,13 @@ namespace New_College.Services var cc = await _dal.Update(model); if (cc) { + var oldorderlist = await _dal.Query(c => c.Id != model.Id && c.CustomerId == model.CustomerId); + oldorderlist.ForEach(c => + { + c.Status = EnumOrderType.Cancel; + }); + await _dal.Update(oldorderlist); + _unitOfWork.CommitTran(); status = true; } @@ -383,7 +471,7 @@ namespace New_College.Services return code; } - + }