From 6136cacff529bbf1baf404f19b4926ace33eba73 Mon Sep 17 00:00:00 2001 From: lwh <2679599887@qq.com> Date: Mon, 31 Jul 2023 16:12:21 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E5=BC=80=E5=A7=8B=E5=86=99=E8=B4=AD?= =?UTF-8?q?=E7=89=A9=E8=BD=A6=E6=8E=A5=E5=8F=A3=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E4=BB=8B=E7=BB=8D=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ARW.Model/Dto/Api/Carts/CartApiDto.cs | 19 +-- .../CouponManage/Coupons/CouponDto.cs | 10 +- .../Marketing/CouponManage/Coupons/Coupon.cs | 8 + ARW.Model/Vo/Api/Carts/CartApiVo.cs | 153 ++++++++++++------ .../CouponManage/Coupons/CouponVo.cs | 6 + .../BusinessService/Carts/CartServiceApi.cs | 78 ++++----- .../IBusinessService/Carts/ICartServiceApi.cs | 8 +- .../CouponManage/Coupons/CouponService.cs | 3 +- .../Api/Carts/CartApiController.cs | 24 --- 9 files changed, 166 insertions(+), 143 deletions(-) diff --git a/ARW.Model/Dto/Api/Carts/CartApiDto.cs b/ARW.Model/Dto/Api/Carts/CartApiDto.cs index 579631f..0ae0620 100644 --- a/ARW.Model/Dto/Api/Carts/CartApiDto.cs +++ b/ARW.Model/Dto/Api/Carts/CartApiDto.cs @@ -14,21 +14,8 @@ namespace ARW.Model.Dto.Api.Carts /// public class CartQueryDtoApi : PagerInfo { - public long? CustomerGuid { get; set; } - public long? ShopGuid { get; set; } + [Required(ErrorMessage = "客户Guid不能为空")] + public long CustomerGuid { get; set; } } - - - /// - /// 购物车记录详情输入对象Api - /// - /// @author lwh - /// @date 2023-07-20 - /// - public class CartDtoApi - { - [Required(ErrorMessage = "CartGuid不能为空")] - public long CartGuid { get; set; } - } - + } diff --git a/ARW.Model/Dto/Business/Marketing/CouponManage/Coupons/CouponDto.cs b/ARW.Model/Dto/Business/Marketing/CouponManage/Coupons/CouponDto.cs index 67e6e08..20c1324 100644 --- a/ARW.Model/Dto/Business/Marketing/CouponManage/Coupons/CouponDto.cs +++ b/ARW.Model/Dto/Business/Marketing/CouponManage/Coupons/CouponDto.cs @@ -2,6 +2,9 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using ARW.Model.Models.Business.Marketing.CouponManage.Coupons; +using MimeKit; +using OfficeOpenXml.Attributes; +using SqlSugar; namespace ARW.Model.Dto.Business.Marketing.CouponManage.Coupons { @@ -21,6 +24,9 @@ namespace ARW.Model.Dto.Business.Marketing.CouponManage.Coupons [Required(ErrorMessage = "优惠劵名称不能为空")] public string CouponName { get; set; } + [Required(ErrorMessage = "优惠劵介绍不能为空")] + public string CouponDesc { get; set; } + [Required(ErrorMessage = "优惠劵类型不能为空")] public int CouponType { get; set; } @@ -69,7 +75,7 @@ namespace ARW.Model.Dto.Business.Marketing.CouponManage.Coupons /// @author lwh /// @date 2023-07-24 /// - public class CouponQueryDto : PagerInfo + public class CouponQueryDto : PagerInfo { public string CouponName { get; set; } @@ -81,7 +87,7 @@ namespace ARW.Model.Dto.Business.Marketing.CouponManage.Coupons public int? CouponApplicableScope { get; set; } public int? CouponDisplayStatus { get; set; } - + public string ids { get; set; } } diff --git a/ARW.Model/Models/Business/Marketing/CouponManage/Coupons/Coupon.cs b/ARW.Model/Models/Business/Marketing/CouponManage/Coupons/Coupon.cs index c9f4d52..e3b104f 100644 --- a/ARW.Model/Models/Business/Marketing/CouponManage/Coupons/Coupon.cs +++ b/ARW.Model/Models/Business/Marketing/CouponManage/Coupons/Coupon.cs @@ -43,6 +43,14 @@ namespace ARW.Model.Models.Business.Marketing.CouponManage.Coupons [SugarColumn(ColumnName = "coupon_name")] public string CouponName { get; set; } + /// + /// 描述 :优惠劵介绍 + /// 空值 : false + /// + [EpplusTableColumn(Header = "优惠劵介绍")] + [SugarColumn(ColumnName = "coupon_desc")] + public string CouponDesc { get; set; } + /// /// 描述 :优惠劵类型 diff --git a/ARW.Model/Vo/Api/Carts/CartApiVo.cs b/ARW.Model/Vo/Api/Carts/CartApiVo.cs index 553e667..b7e2d55 100644 --- a/ARW.Model/Vo/Api/Carts/CartApiVo.cs +++ b/ARW.Model/Vo/Api/Carts/CartApiVo.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json; using OfficeOpenXml.Attributes; using SqlSugar; using System; +using System.Collections.Generic; namespace ARW.Model.Vo.Api.Carts { @@ -19,47 +20,18 @@ namespace ARW.Model.Vo.Api.Carts /// 描述 : 店铺Id /// [JsonConverter(typeof(ValueToStringConverter))] - public int StoreId { get; set; } + public long StoreId { get; set; } /// - /// 描述 : + /// 描述 : 店铺名称 /// - public long StoreName { get; set; } - - - public int PromotionGoodsList { get; set; } + public string StoreName { get; set; } /// - /// 描述 :客户Guid + /// 优惠券的商品列表 /// - [JsonConverter(typeof(ValueToStringConverter))] - public long CustomerGuid { get; set; } - - - /// - /// 描述 :店铺Guid - /// - [JsonConverter(typeof(ValueToStringConverter))] - public long ShopGuid { get; set; } - - - /// - /// 描述 :商品Guid - /// - public long GoodsGuid { get; set; } - - - /// - /// 描述 :商品sku唯一标识 - /// - public int GoodsSkuId { get; set; } - - - /// - /// 描述 :商品数量 - /// - public int CartGoodsNum { get; set; } + public List PromotionGoodsList { get; set; } } @@ -67,19 +39,110 @@ namespace ARW.Model.Vo.Api.Carts /// /// 购物车记录详情展示对象Api /// - public class CartApiDetailsVo + public class PromotionGoods { - public int CartId { get; set; } - [JsonConverter(typeof(ValueToStringConverter))] - public long CartGuid { get; set; } - [JsonConverter(typeof(ValueToStringConverter))] - public long CustomerGuid { get; set; } - [JsonConverter(typeof(ValueToStringConverter))] - public long ShopGuid { get; set; } - public long GoodsGuid { get; set; } - public int GoodsSkuId { get; set; } - public int CartGoodsNum { get; set; } + /// + /// 优惠券Id + /// + public int PromotionId { get; set; } + + /// + /// 优惠券名称 + /// + public string Title { get; set; } + + /// + /// 优惠券编码 + /// + public string PromotionCode { get; set; } = "EMPTY_PROMOTION"; + + /// + /// 优惠价类型 + /// + public string Tag { get; set; } + + /// + /// 优惠券介绍 + /// + public string Description { get; set; } + + public List GoodsPromotionList { get; set; } } + + public class GoodsPromotion + { + /// + /// 店铺Id + /// + [JsonConverter(typeof(ValueToStringConverter))] + public long StoreId { get; set; } + + /// + /// 商品Id + /// + + [JsonConverter(typeof(ValueToStringConverter))] + public long SpuId { get; set; } + + /// + /// 商品SkuId + /// + public int SkuId { get; set; } + + /// + /// 商品封面 + /// + public string Thumb { get; set; } + + + /// + /// 商品名称 + /// + public string Title { get; set; } + + /// + /// 购物车商品数量 + /// + public int Quantity { get; set; } + + /// + /// 库存状态 + /// + public bool StockStatus { get; set; } + + /// + /// 库存总数 + /// + public int StockQuantity { get; set; } + + /// + /// 价格 + /// + public decimal Price { get; set; } + + /// + /// 划线价格 + /// + public decimal OriginPrice { get; set;} + + /// + /// 商品规格详情 + /// + public SpecInfo SpecInfo { get; set; } + + /// + /// 购物车加入时间 + /// + public DateTime JoinCartTime { get; set; } + } + + + public class SpecInfo + { + public string SpecTitle { get; set; } + public string SpecValue { get; set; } + } + } diff --git a/ARW.Model/Vo/Business/Marketing/CouponManage/Coupons/CouponVo.cs b/ARW.Model/Vo/Business/Marketing/CouponManage/Coupons/CouponVo.cs index 9ac6b6c..97832b1 100644 --- a/ARW.Model/Vo/Business/Marketing/CouponManage/Coupons/CouponVo.cs +++ b/ARW.Model/Vo/Business/Marketing/CouponManage/Coupons/CouponVo.cs @@ -36,6 +36,12 @@ namespace ARW.Model.Vo.Business.Marketing.CouponManage.Coupons [EpplusTableColumn(Header = "优惠劵名称")] public string CouponName { get; set; } + /// + /// 描述 :优惠劵介绍 + /// + [EpplusTableColumn(Header = "优惠劵介绍")] + public string CouponDesc { get; set; } + /// /// 描述 :优惠劵类型 diff --git a/ARW.Service/Api/BusinessService/Carts/CartServiceApi.cs b/ARW.Service/Api/BusinessService/Carts/CartServiceApi.cs index 26962ef..980e431 100644 --- a/ARW.Service/Api/BusinessService/Carts/CartServiceApi.cs +++ b/ARW.Service/Api/BusinessService/Carts/CartServiceApi.cs @@ -16,6 +16,8 @@ using ARW.Model.Vo.Api.Carts; using ARW.Model.Models.Business.Custom.Customers; using ARW.Model.Models.Business.GoodsManager.Goodss; using ARW.Model.Models.Business.ShopManager.Shops; +using Org.BouncyCastle.Crypto.Prng; +using ARW.Repository.Business.ShopManager.Shops; namespace ARW.Service.Api.BusinessService.Carts { @@ -29,10 +31,12 @@ namespace ARW.Service.Api.BusinessService.Carts public class CartServiceImplApi : BaseService, ICartServiceApi { private readonly CartRepository _CartRepository; + private readonly ShopRepository _ShopRepository; - public CartServiceImplApi(CartRepository CartRepository) + public CartServiceImplApi(CartRepository CartRepository, ShopRepository shopRepository) { this._CartRepository = CartRepository; + _ShopRepository = shopRepository; } #region Api接口代码 @@ -43,59 +47,37 @@ namespace ARW.Service.Api.BusinessService.Carts /// /// /// - public async Task> GetCartListApi(CartQueryDtoApi parm) + public async Task> GetCartListApi(CartQueryDtoApi parm) { - //开始拼装查询条件d - var predicate = Expressionable.Create(); + // 找到当前客户的所有购物车列表 + var customerCartList = await _CartRepository.GetListAsync(s => s.CustomerGuid == parm.CustomerGuid); - predicate = predicate.AndIF(parm.CustomerGuid != null, s => s.CustomerGuid == parm.CustomerGuid); - predicate = predicate.AndIF(parm.ShopGuid != null, s => s.ShopGuid == parm.ShopGuid); - var query = _CartRepository - .Queryable() - .LeftJoin((s, c) => s.ShopGuid == c.ShopGuid) - .LeftJoin((s, c, d) => s.GoodsGuid == d.GoodsGuid) - .LeftJoin((s, c, d, f) => s.CustomerGuid == f.CustomerGuid) - .Where(predicate.ToExpression()) - .OrderBy(s => s.Create_time, OrderByType.Desc) - .Select(s => new CartVoApi + // 找到店铺的Guids + var sameShopGuids = customerCartList.Select(item => item.ShopGuid).Distinct().ToList(); + + var res = new List(); + // 循环每个店铺中的购物车记录 + foreach (var item in sameShopGuids) + { + var shop = await _ShopRepository.GetFirstAsync(s => s.ShopGuid == item); + var shopCart = new CartVoApi(); + shopCart.StoreId = shop.ShopGuid; + shopCart.StoreName = shop.ShopName; + + // 查找当前用户的优惠券 + //var coupon = + + foreach (var _item in customerCartList) { - //CartId = s.CartId, - //CartGuid = s.CartGuid, - CustomerGuid = s.CustomerGuid, - ShopGuid = s.ShopGuid, - GoodsGuid = s.GoodsGuid, - GoodsSkuId = s.GoodsSkuId, - CartGoodsNum = s.CartGoodsNum, - }); + if (_item.ShopGuid == shop.ShopGuid) + { + } + } + } - return await query.ToPageAsync(parm); - } + return res; - /// - /// 查询购物车记录详情(Api) - /// - /// - /// - public async Task GetCartDetails(CartDtoApi parm) - { - - var query = _CartRepository - .Queryable() - .Where(s => s.CartGuid == parm.CartGuid) - .Select(s => new CartApiDetailsVo - { - CartId = s.CartId, - CartGuid = s.CartGuid, - CustomerGuid = s.CustomerGuid, - ShopGuid = s.ShopGuid, - GoodsGuid = s.GoodsGuid, - GoodsSkuId = s.GoodsSkuId, - CartGoodsNum = s.CartGoodsNum, - }).Take(1); - - - return await query.ToJsonAsync(); } diff --git a/ARW.Service/Api/IBusinessService/Carts/ICartServiceApi.cs b/ARW.Service/Api/IBusinessService/Carts/ICartServiceApi.cs index 895cfb2..836cf85 100644 --- a/ARW.Service/Api/IBusinessService/Carts/ICartServiceApi.cs +++ b/ARW.Service/Api/IBusinessService/Carts/ICartServiceApi.cs @@ -23,14 +23,8 @@ namespace ARW.Service.Api.IBusinessService.Carts /// /// /// - Task> GetCartListApi(CartQueryDtoApi parm); + Task> GetCartListApi(CartQueryDtoApi parm); - /// - /// 获取购物车记录详情(Api) - /// - /// - /// - Task GetCartDetails(CartDtoApi parm); } } diff --git a/ARW.Service/Business/BusinessService/Marketing/CouponManage/Coupons/CouponService.cs b/ARW.Service/Business/BusinessService/Marketing/CouponManage/Coupons/CouponService.cs index 0296928..5dd958f 100644 --- a/ARW.Service/Business/BusinessService/Marketing/CouponManage/Coupons/CouponService.cs +++ b/ARW.Service/Business/BusinessService/Marketing/CouponManage/Coupons/CouponService.cs @@ -44,7 +44,7 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons //开始拼装查询条件d var predicate = Expressionable.Create(); - predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CouponName), s => s.CouponName == parm.CouponName); + predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CouponName), s => s.CouponName.Contains(parm.CouponName)); predicate = predicate.AndIF(parm.CouponType != null, s => s.CouponType == parm.CouponType); predicate = predicate.AndIF(parm.CouponExpireType != null, s => s.CouponExpireType == parm.CouponExpireType); predicate = predicate.AndIF(parm.CouponApplicableScope != null, s => s.CouponApplicableScope == parm.CouponApplicableScope); @@ -58,6 +58,7 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons CouponId = s.CouponId, CouponGuid = s.CouponGuid, CouponName = s.CouponName, + CouponDesc = s.CouponDesc, CouponType = s.CouponType, CouponDeductionMoney = s.CouponDeductionMoney, CouponDiscountRate = s.CouponDiscountRate, diff --git a/ARW.WebApi/Controllers/Api/Carts/CartApiController.cs b/ARW.WebApi/Controllers/Api/Carts/CartApiController.cs index 82afc60..cbdb09a 100644 --- a/ARW.WebApi/Controllers/Api/Carts/CartApiController.cs +++ b/ARW.WebApi/Controllers/Api/Carts/CartApiController.cs @@ -83,30 +83,6 @@ namespace ARW.WebApi.Controllers.Api.Carts return SUCCESS(res); } - /// - /// 获取Cart详情(Api) - /// - /// 查询参数 - /// - [HttpGet("getCartDetails")] - public async Task GetCartDetails([FromQuery] CartDtoApi parm) - { - //if (parm == null) throw new CustomException("参数错误!"); - - var res = await _CartServiceApi.GetCartDetails(parm); - - if (res != "[]") - { - res = res.Remove(0, 1); - res = res.Substring(0, res.Length - 1); - var data = res.FromJSON(); - return SUCCESS(data); - } - else - { - return SUCCESS(res); - } - } } }