From 8d8b6d3478f2ce37c0f1cfbe738c7d5661b3bdf4 Mon Sep 17 00:00:00 2001
From: "AERWEN\\26795" <123456789a>
Date: Mon, 23 Oct 2023 16:13:08 +0800
Subject: [PATCH] =?UTF-8?q?feat=20=E6=B7=BB=E5=8A=A0=E4=B8=AA=E4=BA=BA?=
=?UTF-8?q?=E4=B8=AD=E5=BF=83=E6=94=B6=E8=97=8F=EF=BC=8C=E6=B5=8F=E8=A7=88?=
=?UTF-8?q?=E8=AE=B0=E5=BD=95=EF=BC=8C=E8=AE=A2=E5=8D=95=E6=95=B0=E9=87=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Vo/Api/Custom/Customers/CustomerApiVo.cs | 39 +++++++++++++-
.../Custom/Customers/CustomerServiceApi.cs | 52 +++++++++++++++++--
.../GoodsBrowsingHistoryServiceApi.cs | 5 ++
.../Custom/Customers/CustomerApiController.cs | 2 -
4 files changed, 92 insertions(+), 6 deletions(-)
diff --git a/ARW.Model/Vo/Api/Custom/Customers/CustomerApiVo.cs b/ARW.Model/Vo/Api/Custom/Customers/CustomerApiVo.cs
index 63b19e4..8db9972 100644
--- a/ARW.Model/Vo/Api/Custom/Customers/CustomerApiVo.cs
+++ b/ARW.Model/Vo/Api/Custom/Customers/CustomerApiVo.cs
@@ -29,7 +29,44 @@ namespace ARW.Model.Vo.Api.Custom.Customers
[EpplusTableColumn(Header = "客户类型")]
public int CustomerType { get; set; }
- //[EpplusTableColumn(Header = "可用积分")]
+
+ ///
+ /// 收藏数量
+ ///
+ public int CollectCount { get; set; }
+
+ ///
+ /// 历史浏览数量
+ ///
+ public int HistoryCount { get; set; }
+
+ ///
+ /// 待付款数量
+ ///
+ public int WaitPayCount { get; set; }
+
+
+ ///
+ /// 待发货数量
+ ///
+ public int DeliverCount { get; set; }
+
+
+ ///
+ /// 待收货数量
+ ///
+ public int PackageCount { get; set; }
+
+ ///
+ /// 待评价数量
+ ///
+ public int CommentCount { get; set; }
+
+
+ ///
+ /// 退款/售后数量
+ ///
+ public int ExchangCount { get; set; }
}
}
diff --git a/ARW.Service/Api/BusinessService/Custom/Customers/CustomerServiceApi.cs b/ARW.Service/Api/BusinessService/Custom/Customers/CustomerServiceApi.cs
index 67afbe5..196a625 100644
--- a/ARW.Service/Api/BusinessService/Custom/Customers/CustomerServiceApi.cs
+++ b/ARW.Service/Api/BusinessService/Custom/Customers/CustomerServiceApi.cs
@@ -11,6 +11,13 @@ using ARW.Model.Dto.Api.Custom.Customers;
using ARW.Model.Vo.Api.Custom.Customers;
using ARW.Model.Models.Business.Custom.Customers;
using ARW.Repository.Business.Custom.Customers;
+using ARW.Repository.Business.Custom.GoodsCollections;
+using ARW.Repository.Business.Custom.GoodsBrowsingHistorys;
+using ARW.Repository.Business.OrderManage.Orders;
+using ARW.Model.Vo.Api.GoodsManager.Goodss;
+using Newtonsoft.Json;
+using Senparc.CO2NET.Extensions;
+using ARW.Repository.Business.OrderManage.OrderRefunds;
namespace ARW.Service.Api.BusinessService.Custom.Customers
{
@@ -24,10 +31,18 @@ namespace ARW.Service.Api.BusinessService.Custom.Customers
public class CustomerServiceImplApi : BaseService, ICustomerServiceApi
{
private readonly CustomerRepository _CustomerRepository;
+ private readonly GoodsCollectionRepository _GoodsCollectionRepository;
+ private readonly GoodsBrowsingHistoryRepository _GoodsBrowsingHistoryRepository;
+ private readonly OrderRepository _OrderRepository;
+ private readonly OrderRefundRepository _OrderRefundRepository;
- public CustomerServiceImplApi(CustomerRepository CustomerRepository)
+ public CustomerServiceImplApi(CustomerRepository CustomerRepository, GoodsCollectionRepository goodsCollectionRepository, GoodsBrowsingHistoryRepository goodsBrowsingHistoryRepository, OrderRepository orderRepository, OrderRefundRepository orderRefundRepository)
{
this._CustomerRepository = CustomerRepository;
+ _GoodsCollectionRepository = goodsCollectionRepository;
+ _GoodsBrowsingHistoryRepository = goodsBrowsingHistoryRepository;
+ _OrderRepository = orderRepository;
+ _OrderRefundRepository = orderRefundRepository;
}
#region Api接口代码
@@ -38,7 +53,7 @@ namespace ARW.Service.Api.BusinessService.Custom.Customers
///
///
///
- public Task GetCustomerDetails(CustomerQueryDtoApi parm)
+ public async Task GetCustomerDetails(CustomerQueryDtoApi parm)
{
var query = _CustomerRepository
@@ -57,7 +72,38 @@ namespace ARW.Service.Api.BusinessService.Custom.Customers
}).Take(1);
- return query.ToJsonAsync();
+ var json = await query.ToJsonAsync();
+
+ if (json != "[]")
+ {
+ json = json.Remove(0, 1);
+ json = json.Substring(0, json.Length - 1);
+ var data = JsonConvert.DeserializeObject(json);
+
+ // 获取收藏数量
+ data.CollectCount = await _GoodsCollectionRepository.CountAsync(s => s.CustomerGuid == data.CustomerGuid);
+ // 获取历史搜索数量
+ data.HistoryCount = await _GoodsBrowsingHistoryRepository.CountAsync(s => s.CustomerGuid == data.CustomerGuid);
+ // 获取待付款数量
+ data.WaitPayCount = await _OrderRepository.CountAsync(s => s.CustomerGuid == data.CustomerGuid
+ && s.PayStatus == 1 && s.OrderStatus == 1);
+ // 获取待发货数量
+ data.DeliverCount = await _OrderRepository.CountAsync(s => s.CustomerGuid == data.CustomerGuid
+ && s.DeliveryStatus == 1 && s.PayStatus == 2 && s.OrderStatus == 1);
+ // 获取待收货数量
+ data.PackageCount = await _OrderRepository.CountAsync(s => s.CustomerGuid == data.CustomerGuid
+ && s.ReceiptStatus == 1 && s.DeliveryStatus == 2
+ && s.PayStatus == 2 && s.OrderStatus == 1);
+ // 获取待评价数量
+ data.CommentCount = await _OrderRepository.CountAsync(s => s.CustomerGuid == data.CustomerGuid
+ && s.IsComment == 1 && s.PayStatus == 2 && s.OrderStatus == 4);
+ // 获取退款/售后数量
+ data.ExchangCount = await _OrderRefundRepository.CountAsync(s => s.CustomerGuid == data.CustomerGuid && s.OrderRefundStatus == 1);
+
+ json = data.ToJson();
+ }
+
+ return json;
}
diff --git a/ARW.Service/Api/BusinessService/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryServiceApi.cs b/ARW.Service/Api/BusinessService/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryServiceApi.cs
index eb9ed0e..626b121 100644
--- a/ARW.Service/Api/BusinessService/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryServiceApi.cs
+++ b/ARW.Service/Api/BusinessService/Custom/GoodsBrowsingHistorys/GoodsBrowsingHistoryServiceApi.cs
@@ -68,6 +68,11 @@ namespace ARW.Service.Api.BusinessService.Custom.GoodsBrowsingHistorys
var list = await query.ToPageAsync(parm);
+ foreach (var item in list.Result)
+ {
+ item.Thumb = item.Thumb.Split(",").First();
+ }
+
return list;
}
diff --git a/ARW.WebApi/Controllers/Api/Custom/Customers/CustomerApiController.cs b/ARW.WebApi/Controllers/Api/Custom/Customers/CustomerApiController.cs
index b83664f..2c9f7d3 100644
--- a/ARW.WebApi/Controllers/Api/Custom/Customers/CustomerApiController.cs
+++ b/ARW.WebApi/Controllers/Api/Custom/Customers/CustomerApiController.cs
@@ -51,8 +51,6 @@ namespace ARW.WebApi.Controllers.Api.Custom.Customers
if (res != "[]")
{
- res = res.Remove(0, 1);
- res = res.Substring(0, res.Length - 1);
var data = res.FromJSON();
return SUCCESS(data);
}