fixed 修改订单列表查询
This commit is contained in:
parent
f68693a0de
commit
a1728bf765
@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Models.Business.OrderManage.OrderGoodss;
|
||||
|
||||
namespace ARW.Model.Dto.Business.OrderManage.OrderGoodss
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单商品记录输入对象
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-09-01
|
||||
/// </summary>
|
||||
public class OrderGoodsDto
|
||||
{
|
||||
|
||||
public int OrderGoodsId { get; set; }
|
||||
|
||||
public long OrderGoodsGuid { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "订单guid不能为空")]
|
||||
public long OrderGuid { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "商品guid不能为空")]
|
||||
public long GoodsGuid { get; set; }
|
||||
|
||||
public int? GoodsSkuId { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "商品单价不能为空")]
|
||||
public decimal GoodsPrice { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "商品购买数量不能为空")]
|
||||
public int GoodsTotalNum { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "商品总额(单价 × 数量)不能为空")]
|
||||
public decimal GoodsTotalAmoun { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 订单商品记录查询对象
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-09-01
|
||||
/// </summary>
|
||||
public class OrderGoodsQueryDto : PagerInfo
|
||||
{
|
||||
|
||||
public string ids { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SqlSugar;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ARW.Model.Models.Business.OrderManage.OrderGoodss
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单商品记录,数据实体对象
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-09-01
|
||||
/// </summary>
|
||||
[SugarTable("tb_order_goods")]
|
||||
public class OrderGoods : BusinessBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "order_goods_id")]
|
||||
public int OrderGoodsId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "order_goods_guid")]
|
||||
public long OrderGoodsGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :订单guid
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(ColumnName = "order_guid")]
|
||||
public long OrderGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品guid
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(ColumnName = "goods_guid")]
|
||||
public long GoodsGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品sku唯一标识
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "goods_sku_id")]
|
||||
public int? GoodsSkuId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品单价
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "goods_price")]
|
||||
public decimal GoodsPrice { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品购买数量
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "goods_total_num")]
|
||||
public int GoodsTotalNum { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品总额(单价 × 数量)
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "goods_total_amoun")]
|
||||
public decimal GoodsTotalAmoun { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -55,16 +55,6 @@ namespace ARW.Model.Models.Business.OrderManage.Orders
|
||||
public long CustomerGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :店铺guid
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "店铺guid")]
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(ColumnName = "shop_guid")]
|
||||
public long? ShopGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :订单号
|
||||
/// 空值 : false
|
||||
|
@ -0,0 +1,69 @@
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ARW.Model.Vo.Business.OrderManage.OrderGoodss
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单商品记录展示对象
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-09-01
|
||||
/// </summary>
|
||||
public class OrderGoodsVo
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
public int OrderGoodsId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long OrderGoodsGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :订单guid
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long OrderGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品guid
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long GoodsGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品sku唯一标识
|
||||
/// </summary>
|
||||
public int? GoodsSkuId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品单价
|
||||
/// </summary>
|
||||
public decimal GoodsPrice { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品购买数量
|
||||
/// </summary>
|
||||
public int GoodsTotalNum { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :商品总额(单价 × 数量)
|
||||
/// </summary>
|
||||
public decimal GoodsTotalAmoun { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -37,5 +37,11 @@ namespace ARW.Model.Vo.Business.OrderManage.Orders
|
||||
/// </summary>
|
||||
public decimal GoodsPrice { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 购买数量
|
||||
/// </summary>
|
||||
public int GoodsTotalNum { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ARW.Model.Vo.Business.OrderManage.Orders
|
||||
{
|
||||
@ -32,7 +33,7 @@ namespace ARW.Model.Vo.Business.OrderManage.Orders
|
||||
/// <summary>
|
||||
/// 商品信息
|
||||
/// </summary>
|
||||
public OrderGoodsVo GoodsInfo { get; set; }
|
||||
public List<OrderGoodsVo> GoodsInfoList { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using Infrastructure.Attribute;
|
||||
using ARW.Repository.System;
|
||||
using ARW.Model.Models.Business.OrderManage.OrderGoodss;
|
||||
|
||||
namespace ARW.Repository.Business.OrderManage.OrderGoodss
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单商品记录仓储
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-09-01
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class OrderGoodsRepository : BaseRepository<OrderGoods>
|
||||
{
|
||||
#region 业务逻辑代码
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -153,7 +153,7 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.GoodsSpecs.GoodsSkus
|
||||
/// </summary>
|
||||
/// <param name="skuId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> GetSpecValueFullName(int skuId)
|
||||
public async Task<string> GetSpecValueFullName(int? skuId)
|
||||
{
|
||||
var str = "";
|
||||
// 从数据库中查询规格值名称
|
||||
|
@ -0,0 +1,95 @@
|
||||
using Infrastructure.Attribute;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using ARW.Model;
|
||||
using ARW.Repository;
|
||||
using ARW.Repository.Business.OrderManage.OrderGoodss;
|
||||
using ARW.Service.Business.IBusinessService.OrderManage.OrderGoodss;
|
||||
using ARW.Model.Dto.Business.OrderManage.OrderGoodss;
|
||||
using ARW.Model.Models.Business.OrderManage.OrderGoodss;
|
||||
using ARW.Model.Vo.Business.OrderManage.OrderGoodss;
|
||||
|
||||
namespace ARW.Service.Business.BusinessService.OrderManage.OrderGoodss
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单商品记录接口实现类
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-09-01
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IOrderGoodsService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class OrderGoodsServiceImpl : BaseService<OrderGoods>, IOrderGoodsService
|
||||
{
|
||||
private readonly OrderGoodsRepository _OrderGoodsRepository;
|
||||
|
||||
public OrderGoodsServiceImpl(OrderGoodsRepository OrderGoodsRepository)
|
||||
{
|
||||
this._OrderGoodsRepository = OrderGoodsRepository;
|
||||
}
|
||||
|
||||
#region 业务逻辑代码
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询订单商品记录分页列表
|
||||
/// </summary>
|
||||
public async Task<PagedInfo<OrderGoodsVo>> GetOrderGoodsList(OrderGoodsQueryDto parm)
|
||||
{
|
||||
//开始拼装查询条件d
|
||||
var predicate = Expressionable.Create<OrderGoods>();
|
||||
|
||||
var query = _OrderGoodsRepository
|
||||
.Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy(s => s.Update_time,OrderByType.Desc)
|
||||
.Select(s => new OrderGoodsVo
|
||||
{
|
||||
OrderGoodsId = s.OrderGoodsId,
|
||||
OrderGoodsGuid = s.OrderGoodsGuid,
|
||||
OrderGuid = s.OrderGuid,
|
||||
GoodsGuid = s.GoodsGuid,
|
||||
GoodsSkuId = s.GoodsSkuId,
|
||||
GoodsPrice = s.GoodsPrice,
|
||||
GoodsTotalNum = s.GoodsTotalNum,
|
||||
GoodsTotalAmoun = s.GoodsTotalAmoun,
|
||||
});
|
||||
|
||||
|
||||
return await query.ToPageAsync(parm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改订单商品记录
|
||||
/// </summary>
|
||||
public async Task<string> AddOrUpdateOrderGoods(OrderGoods model)
|
||||
{
|
||||
if (model.OrderGoodsId != 0)
|
||||
{
|
||||
var response = await _OrderGoodsRepository.UpdateAsync(model);
|
||||
return "修改成功!";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var response = await _OrderGoodsRepository.InsertReturnSnowflakeIdAsync(model);
|
||||
return "添加成功!";
|
||||
}
|
||||
}
|
||||
|
||||
#region Excel处理
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -18,6 +18,8 @@ using ARW.Repository.Business.GoodsManager.Goodss;
|
||||
using ARW.Repository.Business.GoodsManager.GoodsSpecs.GoodsSkus;
|
||||
using ARW.Service.Business.IBusinessService.GoodsManager.GoodsSpecs.GoodsSkus;
|
||||
using ARW.Model.Models.Business.Custom.Customers;
|
||||
using ARW.Repository.Business.OrderManage.OrderGoodss;
|
||||
using ARW.Model.Models.Business.GoodsManager.Goodss;
|
||||
|
||||
namespace ARW.Service.Business.BusinessService.OrderManage.Orders
|
||||
{
|
||||
@ -31,14 +33,16 @@ namespace ARW.Service.Business.BusinessService.OrderManage.Orders
|
||||
public class OrderServiceImpl : BaseService<Order>, IOrderService
|
||||
{
|
||||
private readonly OrderRepository _OrderRepository;
|
||||
private readonly OrderGoodsRepository _OrderGoodsRepository;
|
||||
private readonly GoodsRepository _GoodsRepository;
|
||||
private readonly IGoodsSkuService _GoodsSkuService;
|
||||
|
||||
public OrderServiceImpl(OrderRepository OrderRepository, GoodsRepository goodsRepository, IGoodsSkuService goodsSkuService)
|
||||
public OrderServiceImpl(OrderRepository OrderRepository, GoodsRepository goodsRepository, IGoodsSkuService goodsSkuService, OrderGoodsRepository orderGoodsRepository)
|
||||
{
|
||||
this._OrderRepository = OrderRepository;
|
||||
_GoodsRepository = goodsRepository;
|
||||
_GoodsSkuService = goodsSkuService;
|
||||
_OrderGoodsRepository = orderGoodsRepository;
|
||||
}
|
||||
|
||||
#region 业务逻辑代码
|
||||
@ -90,23 +94,33 @@ namespace ARW.Service.Business.BusinessService.OrderManage.Orders
|
||||
|
||||
foreach (var item in list.Result)
|
||||
{
|
||||
|
||||
// 获取商品信息
|
||||
//var goods = await _GoodsRepository.GetFirstAsync(s => s.GoodsGuid == item.GoodsGuid) ?? throw new CustomException("商品不存在");
|
||||
//item.GoodsInfo = new OrderGoodsVo();
|
||||
//item.GoodsInfo.GoodsName = goods.GoodsName;
|
||||
//item.GoodsInfo.GoodsPicture = goods.GoodsPicture;
|
||||
//if (item.GoodsSkuId != 0)
|
||||
//{
|
||||
// var specName = await _GoodsSkuService.GetSpecValueFullName(item.GoodsSkuId);
|
||||
// var sku = await _GoodsSkuService.GetByIdAsync(item.GoodsSkuId);
|
||||
// item.GoodsInfo.GoodsSpecName = specName;
|
||||
// item.GoodsInfo.GoodsPrice = sku.GoodsSkuPrice;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// item.GoodsInfo.GoodsPrice = goods.GoodsPriceHighest;
|
||||
//}
|
||||
item.GoodsInfoList = new List<OrderGoodsVo>();
|
||||
var orderGoodsList = await _OrderGoodsRepository.GetListAsync(s => s.OrderGuid == item.OrderGuid);
|
||||
if (orderGoodsList.Count <= 0) throw new CustomException("订单商品不存在");
|
||||
foreach (var orderGoods in orderGoodsList)
|
||||
{
|
||||
var goods = await _GoodsRepository.GetFirstAsync(s => s.GoodsGuid == orderGoods.GoodsGuid) ?? throw new CustomException("商品不存在");
|
||||
var orderGoodsInfo = new OrderGoodsVo();
|
||||
orderGoodsInfo.GoodsName = goods.GoodsName;
|
||||
orderGoodsInfo.GoodsPicture = goods.GoodsPicture;
|
||||
orderGoodsInfo.GoodsTotalNum = orderGoods.GoodsTotalNum;
|
||||
if (orderGoods.GoodsSkuId != null)
|
||||
{
|
||||
var specName = await _GoodsSkuService.GetSpecValueFullName(orderGoods.GoodsSkuId);
|
||||
var sku = await _GoodsSkuService.GetByIdAsync(orderGoods.GoodsSkuId);
|
||||
orderGoodsInfo.GoodsSpecName = specName;
|
||||
orderGoodsInfo.GoodsPrice = sku.GoodsSkuPrice;
|
||||
}
|
||||
else
|
||||
{
|
||||
orderGoodsInfo.GoodsPrice = goods.GoodsPriceHighest;
|
||||
}
|
||||
item.GoodsInfoList.Add(orderGoodsInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@ -34,7 +34,7 @@ namespace ARW.Service.Business.IBusinessService.GoodsManager.GoodsSpecs.GoodsSku
|
||||
/// </summary>
|
||||
/// <param name="skuId"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> GetSpecValueFullName(int skuId);
|
||||
Task<string> GetSpecValueFullName(int? skuId);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ARW.Model;
|
||||
using ARW.Model.Dto.Business.OrderManage.OrderGoodss;
|
||||
using ARW.Model.Models.Business.OrderManage.OrderGoodss;
|
||||
using ARW.Model.Vo.Business.OrderManage.OrderGoodss;
|
||||
|
||||
namespace ARW.Service.Business.IBusinessService.OrderManage.OrderGoodss
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单商品记录接口类
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-09-01
|
||||
/// </summary>
|
||||
public interface IOrderGoodsService : IBaseService<OrderGoods>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取订单商品记录分页列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedInfo<OrderGoodsVo>> GetOrderGoodsList(OrderGoodsQueryDto parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改订单商品记录
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> AddOrUpdateOrderGoods(OrderGoods parm);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user