fixed 开始写购物车接口,添加优惠券介绍字段
This commit is contained in:
parent
0ef353e337
commit
6136cacff5
@ -14,21 +14,8 @@ namespace ARW.Model.Dto.Api.Carts
|
||||
/// </summary>
|
||||
public class CartQueryDtoApi : PagerInfo
|
||||
{
|
||||
public long? CustomerGuid { get; set; }
|
||||
public long? ShopGuid { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 购物车记录详情输入对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-07-20
|
||||
/// </summary>
|
||||
public class CartDtoApi
|
||||
{
|
||||
[Required(ErrorMessage = "CartGuid不能为空")]
|
||||
public long CartGuid { get; set; }
|
||||
[Required(ErrorMessage = "客户Guid不能为空")]
|
||||
public long CustomerGuid { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -43,6 +43,14 @@ namespace ARW.Model.Models.Business.Marketing.CouponManage.Coupons
|
||||
[SugarColumn(ColumnName = "coupon_name")]
|
||||
public string CouponName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :优惠劵介绍
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "优惠劵介绍")]
|
||||
[SugarColumn(ColumnName = "coupon_desc")]
|
||||
public string CouponDesc { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :优惠劵类型
|
||||
|
@ -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
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public int StoreId { get; set; }
|
||||
public long StoreId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 描述 : 店铺名称
|
||||
/// </summary>
|
||||
public long StoreName { get; set; }
|
||||
|
||||
|
||||
public int PromotionGoodsList { get; set; }
|
||||
public string StoreName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :客户Guid
|
||||
/// 优惠券的商品列表
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
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; }
|
||||
public List<PromotionGoods> PromotionGoodsList { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@ -67,19 +39,110 @@ namespace ARW.Model.Vo.Api.Carts
|
||||
/// <summary>
|
||||
/// 购物车记录详情展示对象Api
|
||||
/// </summary>
|
||||
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; }
|
||||
/// <summary>
|
||||
/// 优惠券Id
|
||||
/// </summary>
|
||||
public int PromotionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 优惠券名称
|
||||
/// </summary>
|
||||
public string Title { 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 = "优惠劵名称")]
|
||||
public string CouponName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :优惠劵介绍
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "优惠劵介绍")]
|
||||
public string CouponDesc { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :优惠劵类型
|
||||
|
@ -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<Cart>, 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
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <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);
|
||||
predicate = predicate.AndIF(parm.ShopGuid != null, s => s.ShopGuid == parm.ShopGuid);
|
||||
var query = _CartRepository
|
||||
.Queryable()
|
||||
.LeftJoin<Shop>((s, c) => s.ShopGuid == c.ShopGuid)
|
||||
.LeftJoin<Goods>((s, c, d) => s.GoodsGuid == d.GoodsGuid)
|
||||
.LeftJoin<Customer>((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<CartVoApi>();
|
||||
// 循环每个店铺中的购物车记录
|
||||
foreach (var item in sameShopGuids)
|
||||
{
|
||||
//CartId = s.CartId,
|
||||
//CartGuid = s.CartGuid,
|
||||
CustomerGuid = s.CustomerGuid,
|
||||
ShopGuid = s.ShopGuid,
|
||||
GoodsGuid = s.GoodsGuid,
|
||||
GoodsSkuId = s.GoodsSkuId,
|
||||
CartGoodsNum = s.CartGoodsNum,
|
||||
});
|
||||
var shop = await _ShopRepository.GetFirstAsync(s => s.ShopGuid == item);
|
||||
var shopCart = new CartVoApi();
|
||||
shopCart.StoreId = shop.ShopGuid;
|
||||
shopCart.StoreName = shop.ShopName;
|
||||
|
||||
// 查找当前用户的优惠券
|
||||
//var coupon =
|
||||
|
||||
return await query.ToPageAsync(parm);
|
||||
foreach (var _item in customerCartList)
|
||||
{
|
||||
if (_item.ShopGuid == shop.ShopGuid)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询购物车记录详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> GetCartDetails(CartDtoApi parm)
|
||||
{
|
||||
return res;
|
||||
|
||||
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>
|
||||
/// <param name="parm"></param>
|
||||
/// <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
|
||||
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.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,
|
||||
|
@ -83,30 +83,6 @@ namespace ARW.WebApi.Controllers.Api.Carts
|
||||
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