fixed 开始写购物车接口,添加优惠券介绍字段
This commit is contained in:
parent
0ef353e337
commit
6136cacff5
@ -14,21 +14,8 @@ namespace ARW.Model.Dto.Api.Carts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class CartQueryDtoApi : PagerInfo
|
public class CartQueryDtoApi : PagerInfo
|
||||||
{
|
{
|
||||||
public long? CustomerGuid { get; set; }
|
[Required(ErrorMessage = "客户Guid不能为空")]
|
||||||
public long? ShopGuid { get; set; }
|
public long CustomerGuid { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 购物车记录详情输入对象Api
|
|
||||||
///
|
|
||||||
/// @author lwh
|
|
||||||
/// @date 2023-07-20
|
|
||||||
/// </summary>
|
|
||||||
public class CartDtoApi
|
|
||||||
{
|
|
||||||
[Required(ErrorMessage = "CartGuid不能为空")]
|
|
||||||
public long CartGuid { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,9 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using ARW.Model.Models.Business.Marketing.CouponManage.Coupons;
|
using ARW.Model.Models.Business.Marketing.CouponManage.Coupons;
|
||||||
|
using MimeKit;
|
||||||
|
using OfficeOpenXml.Attributes;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
namespace ARW.Model.Dto.Business.Marketing.CouponManage.Coupons
|
namespace ARW.Model.Dto.Business.Marketing.CouponManage.Coupons
|
||||||
{
|
{
|
||||||
@ -21,6 +24,9 @@ namespace ARW.Model.Dto.Business.Marketing.CouponManage.Coupons
|
|||||||
[Required(ErrorMessage = "优惠劵名称不能为空")]
|
[Required(ErrorMessage = "优惠劵名称不能为空")]
|
||||||
public string CouponName { get; set; }
|
public string CouponName { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "优惠劵介绍不能为空")]
|
||||||
|
public string CouponDesc { get; set; }
|
||||||
|
|
||||||
[Required(ErrorMessage = "优惠劵类型不能为空")]
|
[Required(ErrorMessage = "优惠劵类型不能为空")]
|
||||||
public int CouponType { get; set; }
|
public int CouponType { get; set; }
|
||||||
|
|
||||||
@ -69,7 +75,7 @@ namespace ARW.Model.Dto.Business.Marketing.CouponManage.Coupons
|
|||||||
/// @author lwh
|
/// @author lwh
|
||||||
/// @date 2023-07-24
|
/// @date 2023-07-24
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CouponQueryDto : PagerInfo
|
public class CouponQueryDto : PagerInfo
|
||||||
{
|
{
|
||||||
|
|
||||||
public string CouponName { get; set; }
|
public string CouponName { get; set; }
|
||||||
@ -81,7 +87,7 @@ namespace ARW.Model.Dto.Business.Marketing.CouponManage.Coupons
|
|||||||
public int? CouponApplicableScope { get; set; }
|
public int? CouponApplicableScope { get; set; }
|
||||||
|
|
||||||
public int? CouponDisplayStatus { get; set; }
|
public int? CouponDisplayStatus { get; set; }
|
||||||
|
|
||||||
public string ids { get; set; }
|
public string ids { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +43,14 @@ namespace ARW.Model.Models.Business.Marketing.CouponManage.Coupons
|
|||||||
[SugarColumn(ColumnName = "coupon_name")]
|
[SugarColumn(ColumnName = "coupon_name")]
|
||||||
public string CouponName { get; set; }
|
public string CouponName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :优惠劵介绍
|
||||||
|
/// 空值 : false
|
||||||
|
/// </summary>
|
||||||
|
[EpplusTableColumn(Header = "优惠劵介绍")]
|
||||||
|
[SugarColumn(ColumnName = "coupon_desc")]
|
||||||
|
public string CouponDesc { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 描述 :优惠劵类型
|
/// 描述 :优惠劵类型
|
||||||
|
@ -2,6 +2,7 @@ using Newtonsoft.Json;
|
|||||||
using OfficeOpenXml.Attributes;
|
using OfficeOpenXml.Attributes;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace ARW.Model.Vo.Api.Carts
|
namespace ARW.Model.Vo.Api.Carts
|
||||||
{
|
{
|
||||||
@ -19,47 +20,18 @@ namespace ARW.Model.Vo.Api.Carts
|
|||||||
/// 描述 : 店铺Id
|
/// 描述 : 店铺Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonConverter(typeof(ValueToStringConverter))]
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
public int StoreId { get; set; }
|
public long StoreId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 描述 :
|
/// 描述 : 店铺名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long StoreName { get; set; }
|
public string StoreName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public int PromotionGoodsList { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 描述 :客户Guid
|
/// 优惠券的商品列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonConverter(typeof(ValueToStringConverter))]
|
public List<PromotionGoods> PromotionGoodsList { get; set; }
|
||||||
public long CustomerGuid { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 :店铺Guid
|
|
||||||
/// </summary>
|
|
||||||
[JsonConverter(typeof(ValueToStringConverter))]
|
|
||||||
public long ShopGuid { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 :商品Guid
|
|
||||||
/// </summary>
|
|
||||||
public long GoodsGuid { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 :商品sku唯一标识
|
|
||||||
/// </summary>
|
|
||||||
public int GoodsSkuId { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 描述 :商品数量
|
|
||||||
/// </summary>
|
|
||||||
public int CartGoodsNum { get; set; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,19 +39,110 @@ namespace ARW.Model.Vo.Api.Carts
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 购物车记录详情展示对象Api
|
/// 购物车记录详情展示对象Api
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CartApiDetailsVo
|
public class PromotionGoods
|
||||||
{
|
{
|
||||||
public int CartId { get; set; }
|
/// <summary>
|
||||||
[JsonConverter(typeof(ValueToStringConverter))]
|
/// 优惠券Id
|
||||||
public long CartGuid { get; set; }
|
/// </summary>
|
||||||
[JsonConverter(typeof(ValueToStringConverter))]
|
public int PromotionId { get; set; }
|
||||||
public long CustomerGuid { get; set; }
|
|
||||||
[JsonConverter(typeof(ValueToStringConverter))]
|
/// <summary>
|
||||||
public long ShopGuid { get; set; }
|
/// 优惠券名称
|
||||||
public long GoodsGuid { get; set; }
|
/// </summary>
|
||||||
public int GoodsSkuId { get; set; }
|
public string Title { get; set; }
|
||||||
public int CartGoodsNum { get; set; }
|
|
||||||
|
/// <summary>
|
||||||
|
/// 优惠券编码
|
||||||
|
/// </summary>
|
||||||
|
public string PromotionCode { get; set; } = "EMPTY_PROMOTION";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 优惠价类型
|
||||||
|
/// </summary>
|
||||||
|
public string Tag { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 优惠券介绍
|
||||||
|
/// </summary>
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
public List<GoodsPromotion> GoodsPromotionList { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class GoodsPromotion
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 店铺Id
|
||||||
|
/// </summary>
|
||||||
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
|
public long StoreId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品Id
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
|
public long SpuId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品SkuId
|
||||||
|
/// </summary>
|
||||||
|
public int SkuId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品封面
|
||||||
|
/// </summary>
|
||||||
|
public string Thumb { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品名称
|
||||||
|
/// </summary>
|
||||||
|
public string Title { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 购物车商品数量
|
||||||
|
/// </summary>
|
||||||
|
public int Quantity { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 库存状态
|
||||||
|
/// </summary>
|
||||||
|
public bool StockStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 库存总数
|
||||||
|
/// </summary>
|
||||||
|
public int StockQuantity { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 价格
|
||||||
|
/// </summary>
|
||||||
|
public decimal Price { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 划线价格
|
||||||
|
/// </summary>
|
||||||
|
public decimal OriginPrice { get; set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 商品规格详情
|
||||||
|
/// </summary>
|
||||||
|
public SpecInfo SpecInfo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 购物车加入时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime JoinCartTime { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class SpecInfo
|
||||||
|
{
|
||||||
|
public string SpecTitle { get; set; }
|
||||||
|
public string SpecValue { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,12 @@ namespace ARW.Model.Vo.Business.Marketing.CouponManage.Coupons
|
|||||||
[EpplusTableColumn(Header = "优惠劵名称")]
|
[EpplusTableColumn(Header = "优惠劵名称")]
|
||||||
public string CouponName { get; set; }
|
public string CouponName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :优惠劵介绍
|
||||||
|
/// </summary>
|
||||||
|
[EpplusTableColumn(Header = "优惠劵介绍")]
|
||||||
|
public string CouponDesc { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 描述 :优惠劵类型
|
/// 描述 :优惠劵类型
|
||||||
|
@ -16,6 +16,8 @@ using ARW.Model.Vo.Api.Carts;
|
|||||||
using ARW.Model.Models.Business.Custom.Customers;
|
using ARW.Model.Models.Business.Custom.Customers;
|
||||||
using ARW.Model.Models.Business.GoodsManager.Goodss;
|
using ARW.Model.Models.Business.GoodsManager.Goodss;
|
||||||
using ARW.Model.Models.Business.ShopManager.Shops;
|
using ARW.Model.Models.Business.ShopManager.Shops;
|
||||||
|
using Org.BouncyCastle.Crypto.Prng;
|
||||||
|
using ARW.Repository.Business.ShopManager.Shops;
|
||||||
|
|
||||||
namespace ARW.Service.Api.BusinessService.Carts
|
namespace ARW.Service.Api.BusinessService.Carts
|
||||||
{
|
{
|
||||||
@ -29,10 +31,12 @@ namespace ARW.Service.Api.BusinessService.Carts
|
|||||||
public class CartServiceImplApi : BaseService<Cart>, ICartServiceApi
|
public class CartServiceImplApi : BaseService<Cart>, ICartServiceApi
|
||||||
{
|
{
|
||||||
private readonly CartRepository _CartRepository;
|
private readonly CartRepository _CartRepository;
|
||||||
|
private readonly ShopRepository _ShopRepository;
|
||||||
|
|
||||||
public CartServiceImplApi(CartRepository CartRepository)
|
public CartServiceImplApi(CartRepository CartRepository, ShopRepository shopRepository)
|
||||||
{
|
{
|
||||||
this._CartRepository = CartRepository;
|
this._CartRepository = CartRepository;
|
||||||
|
_ShopRepository = shopRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Api接口代码
|
#region Api接口代码
|
||||||
@ -43,59 +47,37 @@ namespace ARW.Service.Api.BusinessService.Carts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm"></param>
|
/// <param name="parm"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<PagedInfo<CartVoApi>> GetCartListApi(CartQueryDtoApi parm)
|
public async Task<List<CartVoApi>> GetCartListApi(CartQueryDtoApi parm)
|
||||||
{
|
{
|
||||||
//开始拼装查询条件d
|
// 找到当前客户的所有购物车列表
|
||||||
var predicate = Expressionable.Create<Cart>();
|
var customerCartList = await _CartRepository.GetListAsync(s => s.CustomerGuid == parm.CustomerGuid);
|
||||||
|
|
||||||
predicate = predicate.AndIF(parm.CustomerGuid != null, s => s.CustomerGuid == parm.CustomerGuid);
|
// 找到店铺的Guids
|
||||||
predicate = predicate.AndIF(parm.ShopGuid != null, s => s.ShopGuid == parm.ShopGuid);
|
var sameShopGuids = customerCartList.Select(item => item.ShopGuid).Distinct().ToList();
|
||||||
var query = _CartRepository
|
|
||||||
.Queryable()
|
var res = new List<CartVoApi>();
|
||||||
.LeftJoin<Shop>((s, c) => s.ShopGuid == c.ShopGuid)
|
// 循环每个店铺中的购物车记录
|
||||||
.LeftJoin<Goods>((s, c, d) => s.GoodsGuid == d.GoodsGuid)
|
foreach (var item in sameShopGuids)
|
||||||
.LeftJoin<Customer>((s, c, d, f) => s.CustomerGuid == f.CustomerGuid)
|
{
|
||||||
.Where(predicate.ToExpression())
|
var shop = await _ShopRepository.GetFirstAsync(s => s.ShopGuid == item);
|
||||||
.OrderBy(s => s.Create_time, OrderByType.Desc)
|
var shopCart = new CartVoApi();
|
||||||
.Select(s => new CartVoApi
|
shopCart.StoreId = shop.ShopGuid;
|
||||||
|
shopCart.StoreName = shop.ShopName;
|
||||||
|
|
||||||
|
// 查找当前用户的优惠券
|
||||||
|
//var coupon =
|
||||||
|
|
||||||
|
foreach (var _item in customerCartList)
|
||||||
{
|
{
|
||||||
//CartId = s.CartId,
|
if (_item.ShopGuid == shop.ShopGuid)
|
||||||
//CartGuid = s.CartGuid,
|
{
|
||||||
CustomerGuid = s.CustomerGuid,
|
|
||||||
ShopGuid = s.ShopGuid,
|
|
||||||
GoodsGuid = s.GoodsGuid,
|
|
||||||
GoodsSkuId = s.GoodsSkuId,
|
|
||||||
CartGoodsNum = s.CartGoodsNum,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return await query.ToPageAsync(parm);
|
return res;
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 查询购物车记录详情(Api)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parm"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public async Task<string> 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,14 +23,8 @@ namespace ARW.Service.Api.IBusinessService.Carts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm"></param>
|
/// <param name="parm"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<PagedInfo<CartVoApi>> GetCartListApi(CartQueryDtoApi parm);
|
Task<List<CartVoApi>> GetCartListApi(CartQueryDtoApi parm);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取购物车记录详情(Api)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parm"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<string> GetCartDetails(CartDtoApi parm);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
|||||||
//开始拼装查询条件d
|
//开始拼装查询条件d
|
||||||
var predicate = Expressionable.Create<Coupon>();
|
var predicate = Expressionable.Create<Coupon>();
|
||||||
|
|
||||||
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.CouponType != null, s => s.CouponType == parm.CouponType);
|
||||||
predicate = predicate.AndIF(parm.CouponExpireType != null, s => s.CouponExpireType == parm.CouponExpireType);
|
predicate = predicate.AndIF(parm.CouponExpireType != null, s => s.CouponExpireType == parm.CouponExpireType);
|
||||||
predicate = predicate.AndIF(parm.CouponApplicableScope != null, s => s.CouponApplicableScope == parm.CouponApplicableScope);
|
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,
|
CouponId = s.CouponId,
|
||||||
CouponGuid = s.CouponGuid,
|
CouponGuid = s.CouponGuid,
|
||||||
CouponName = s.CouponName,
|
CouponName = s.CouponName,
|
||||||
|
CouponDesc = s.CouponDesc,
|
||||||
CouponType = s.CouponType,
|
CouponType = s.CouponType,
|
||||||
CouponDeductionMoney = s.CouponDeductionMoney,
|
CouponDeductionMoney = s.CouponDeductionMoney,
|
||||||
CouponDiscountRate = s.CouponDiscountRate,
|
CouponDiscountRate = s.CouponDiscountRate,
|
||||||
|
@ -83,30 +83,6 @@ namespace ARW.WebApi.Controllers.Api.Carts
|
|||||||
return SUCCESS(res);
|
return SUCCESS(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取Cart详情(Api)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="parm">查询参数</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpGet("getCartDetails")]
|
|
||||||
public async Task<IActionResult> 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<CartApiDetailsVo>();
|
|
||||||
return SUCCESS(data);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return SUCCESS(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user