From 841b996bc200fd1b0b8a0e2a2975c896b0427baf Mon Sep 17 00:00:00 2001 From: HBL Date: Wed, 20 Apr 2022 10:35:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 25 +++ DataV.sln | 25 +++ DataV/App/DataVApplication.cs | 52 +++++ DataV/DataV.csproj | 19 ++ DataV/DataV.xml | 314 +++++++++++++++++++++++++++ DataV/Enums/AfterEnum.cs | 27 +++ DataV/Enums/CookEnum.cs | 33 +++ DataV/Enums/OrderTypeEnum.cs | 27 +++ DataV/Enums/PayEnum.cs | 27 +++ DataV/Enums/PayModelEnum.cs | 31 +++ DataV/Model/BPA_Order.cs | 75 +++++++ DataV/Model/BPA_StoreInfo.cs | 29 +++ DataV/Model/BPA_SubOrder.cs | 48 ++++ DataV/Model/BasicEntity.cs | 15 ++ DataV/Model/BasicEntityRead.cs | 22 ++ DataV/Program.cs | 27 +++ DataV/Properties/launchSettings.json | 28 +++ DataV/Result.cs | 14 ++ DataV/Service/DataVService.cs | 259 ++++++++++++++++++++++ DataV/Service/Dto/DataVDto.cs | 13 ++ DataV/Service/Dto/LocDto.cs | 8 + DataV/Service/IDataVService.cs | 22 ++ DataV/SqlDbContext.cs | 27 +++ DataV/Startup.cs | 48 ++++ DataV/appsettings.json | 17 ++ Dockerfile | 32 +++ NuGet.config | 7 + 27 files changed, 1271 insertions(+) create mode 100644 .dockerignore create mode 100644 DataV.sln create mode 100644 DataV/App/DataVApplication.cs create mode 100644 DataV/DataV.csproj create mode 100644 DataV/DataV.xml create mode 100644 DataV/Enums/AfterEnum.cs create mode 100644 DataV/Enums/CookEnum.cs create mode 100644 DataV/Enums/OrderTypeEnum.cs create mode 100644 DataV/Enums/PayEnum.cs create mode 100644 DataV/Enums/PayModelEnum.cs create mode 100644 DataV/Model/BPA_Order.cs create mode 100644 DataV/Model/BPA_StoreInfo.cs create mode 100644 DataV/Model/BPA_SubOrder.cs create mode 100644 DataV/Model/BasicEntity.cs create mode 100644 DataV/Model/BasicEntityRead.cs create mode 100644 DataV/Program.cs create mode 100644 DataV/Properties/launchSettings.json create mode 100644 DataV/Result.cs create mode 100644 DataV/Service/DataVService.cs create mode 100644 DataV/Service/Dto/DataVDto.cs create mode 100644 DataV/Service/Dto/LocDto.cs create mode 100644 DataV/Service/IDataVService.cs create mode 100644 DataV/SqlDbContext.cs create mode 100644 DataV/Startup.cs create mode 100644 DataV/appsettings.json create mode 100644 Dockerfile create mode 100644 NuGet.config diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3729ff0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md \ No newline at end of file diff --git a/DataV.sln b/DataV.sln new file mode 100644 index 0000000..ece661f --- /dev/null +++ b/DataV.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.32126.315 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataV", "DataV\DataV.csproj", "{DF0C496F-1683-4B82-A6B9-63B961A17067}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DF0C496F-1683-4B82-A6B9-63B961A17067}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DF0C496F-1683-4B82-A6B9-63B961A17067}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DF0C496F-1683-4B82-A6B9-63B961A17067}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DF0C496F-1683-4B82-A6B9-63B961A17067}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DBDD0A53-9FC4-486D-890D-0BDA45DE92B8} + EndGlobalSection +EndGlobal diff --git a/DataV/App/DataVApplication.cs b/DataV/App/DataVApplication.cs new file mode 100644 index 0000000..0004362 --- /dev/null +++ b/DataV/App/DataVApplication.cs @@ -0,0 +1,52 @@ +using DataV.Service; +using DataV.Service.Dto; +using Furion.DynamicApiController; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DataV.App +{ + [ApiDescriptionSettings("DataV", Tag = "大屏服务", SplitCamelCase = false), Route("/screen"), NonUnify] + public class DataVApplication : IDynamicApiController + { + private IDataVService DataV; + public DataVApplication(IDataVService DataV) + { + this.DataV = DataV; + } + /// + /// 统计订单 + /// + /// + [HttpPost] + public Result GetAllOrderDataState(DataVDto input) => DataV.GetAllOrderDataState(input.AutoKey); + + /// + /// 订单日活 + /// + /// + [HttpPost] + public Result OrderLine(DataVDto input) => DataV.OrderLine(input.AutoKey); + /// + /// 顶数量 + /// + /// + [HttpPost] + public Result OrderNumber(DataVDto input) => DataV.OrderNumber(input.AutoKey); + /// + /// 获取加盟商设备列表 + /// + /// + [HttpGet] + public Result>> OnlineDevice() => DataV.OnlineDevice(); + /// + /// 区域饼状图统计 + /// + /// + [HttpGet] + public Result GetLocSale() => DataV.GetLocSale(); + } +} diff --git a/DataV/DataV.csproj b/DataV/DataV.csproj new file mode 100644 index 0000000..1524392 --- /dev/null +++ b/DataV/DataV.csproj @@ -0,0 +1,19 @@ + + + + net6.0 + + + + D:\Codes\DataV\DataV\DataV.xml + + + + + + + + + + + diff --git a/DataV/DataV.xml b/DataV/DataV.xml new file mode 100644 index 0000000..bee77e0 --- /dev/null +++ b/DataV/DataV.xml @@ -0,0 +1,314 @@ + + + + DataV + + + + + 统计订单 + + + + + + 订单日活 + + + + + + 顶数量 + + + + + + 获取加盟商设备列表 + + + + + + 区域饼状图统计 + + + + + + 取消售后 + + + + + 申请售后 + + + + + 等待处理 + + + + + 处理完成 + + + + + 等待制作 + + + + + 制作中 + + + + + 等待取餐 + + + + 取餐完成 + + + + 正常订单 + + + + + 异常订单数据不会放入redis + + + + + 正常 + + + + + 立即吃面2 + + + + + 盲盒 + + + + + 其他 + + + + + 未支付 + + + + + 已支付 + + + + + 支付取消 + + + + + 已退单 + + + + + 微信 + + + + + 支付宝 + + + + + 钱包 + + + + + 银联 + + + + + 其他 + + + + + 排序号 + + + + + 用户Id + + + + + 支付状态 + + + + + 售后状态 + + + + + 数量 + + + + + 商品总价 + + + + + 折扣价格 + + + + + 实际支付价格 + + + + + 支付方式 + + + + + 订单号 + + + + + 订单号(第三方) + + + + + 流水号 + + + + + 订单类型 + + + + + OpenId + + + + + 订单 + + + + + 与上位机映射ID + + + + + 校验库存 + + + + + 店铺名称 + + + + + 店铺类型 + + + + + 原价 + + + + + 实际金额 + + + + + 备注 + + + + + 订单状态 + + + + + 废弃状态 0 正常 1 废弃 + + + + + 废弃时间 + + + + + 订单序号 + + + + + 大屏数据 + + + + + + + 设备 + + + + + + 折线图 + + + + + + + 下单数量 + + + + + + + 区域销售 + + + + + diff --git a/DataV/Enums/AfterEnum.cs b/DataV/Enums/AfterEnum.cs new file mode 100644 index 0000000..72ec676 --- /dev/null +++ b/DataV/Enums/AfterEnum.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DataV.Enums +{ + public enum AfterEnum + { + /// + /// 取消售后 + /// + Cancel, + /// + /// 申请售后 + /// + Apply, + /// + /// 等待处理 + /// + Wait, + /// + /// 处理完成 + /// + Ok + } +} diff --git a/DataV/Enums/CookEnum.cs b/DataV/Enums/CookEnum.cs new file mode 100644 index 0000000..a529a8c --- /dev/null +++ b/DataV/Enums/CookEnum.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DataV.Enums +{ + public enum CookEnum + { + /// + /// 等待制作 + /// + WaitMake, + /// + /// 制作中 + /// + Making, + /// + /// 等待取餐 + /// + WaitTake, + ///取餐完成 + TakeCompleted, + /// + /// 正常订单 + /// + Normal = 99998, + /// + /// 异常订单数据不会放入redis + /// + Error = 99999 + } +} diff --git a/DataV/Enums/OrderTypeEnum.cs b/DataV/Enums/OrderTypeEnum.cs new file mode 100644 index 0000000..1241499 --- /dev/null +++ b/DataV/Enums/OrderTypeEnum.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DataV.Enums +{ + public enum OrderTypeEnum + { + /// + /// 正常 + /// + Normal, + /// + /// 立即吃面2 + /// + RightNow, + /// + /// 盲盒 + /// + Box, + /// + /// 其他 + /// + Other + } +} diff --git a/DataV/Enums/PayEnum.cs b/DataV/Enums/PayEnum.cs new file mode 100644 index 0000000..cb01ba5 --- /dev/null +++ b/DataV/Enums/PayEnum.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DataV.Enums +{ + public enum PayEnum + { + /// + /// 未支付 + /// + NoPay, + /// + /// 已支付 + /// + PayOk, + /// + /// 支付取消 + /// + PayCancel, + /// + /// 已退单 + /// + Refund + } +} diff --git a/DataV/Enums/PayModelEnum.cs b/DataV/Enums/PayModelEnum.cs new file mode 100644 index 0000000..f4e7754 --- /dev/null +++ b/DataV/Enums/PayModelEnum.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DataV.Enums +{ + public enum PayModelEnum + { + /// + /// 微信 + /// + WeiXin, + /// + /// 支付宝 + /// + AliPay, + /// + /// 钱包 + /// + Wallet, + /// + /// 银联 + /// + UnionPay, + /// + /// 其他 + /// + Other, + } +} diff --git a/DataV/Model/BPA_Order.cs b/DataV/Model/BPA_Order.cs new file mode 100644 index 0000000..f1cb1d3 --- /dev/null +++ b/DataV/Model/BPA_Order.cs @@ -0,0 +1,75 @@ +using DataV.Enums; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DataV.Model +{ + [SugarTable("BPA_Order")] + public class BPA_Order : BasicEntity + { + /// + /// 排序号 + /// + public string SortId { get; set; } + /// + /// 用户Id + /// + public string CustomerId { get; set; } + /// + /// 支付状态 + /// + public PayEnum OrderStatus { get; set; } + /// + /// 售后状态 + /// + public AfterEnum AfterStatus { get; set; } + /// + /// 数量 + /// + public int OrderCount { get; set; } + /// + /// 商品总价 + /// + public decimal OrderOriginalMoney { get; set; } + /// + /// 折扣价格 + /// + public decimal DiscountMoney { get; set; } + /// + /// 实际支付价格 + /// + public decimal OrderRealMoney { get; set; } + /// + /// 支付方式 + /// + public PayModelEnum PayMode { get; set; } + /// + /// 订单号 + /// + public string OrderNumber { get; set; } + /// + /// 订单号(第三方) + /// + public string TradeNo { get; set; } + /// + /// 流水号 + /// + public string TransactionId { get; set; } + /// + /// 订单类型 + /// + public OrderTypeEnum OrderType { get; set; } + /// + /// OpenId + /// + public string TroikaId { get; set; } + /// + /// 订单 + /// + public int OrderSourceFrom { get; set; } + public string Remark { get; set; } + } +} diff --git a/DataV/Model/BPA_StoreInfo.cs b/DataV/Model/BPA_StoreInfo.cs new file mode 100644 index 0000000..e59a2cd --- /dev/null +++ b/DataV/Model/BPA_StoreInfo.cs @@ -0,0 +1,29 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DataV.Model +{ + [SugarTable("BPA_StoreInfo")] + public class BPA_StoreInfo : BasicEntityRead + { + /// + /// 与上位机映射ID + /// + public int AutoKey { get; set; } + /// + /// 校验库存 + /// + public bool CheckStock { get; set; } + /// + /// 店铺名称 + /// + public string Store_Name { get; set; } + /// + /// 店铺类型 + /// + public string Store_TypeId { get; set; } + } +} diff --git a/DataV/Model/BPA_SubOrder.cs b/DataV/Model/BPA_SubOrder.cs new file mode 100644 index 0000000..efcd8ff --- /dev/null +++ b/DataV/Model/BPA_SubOrder.cs @@ -0,0 +1,48 @@ +using DataV.Enums; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DataV.Model +{ + [SugarTable("BPA_SubOrder")] + public class BPA_SubOrder : BasicEntity + { + public string OrderId { get; set; } + public string GoodId { get; set; } + public string StoreId { get; set; } + /// + /// 原价 + /// + public decimal GooodOriginPrice { get; set; } + /// + /// 实际金额 + /// + public decimal GoodsRealPrice { get; set; } + /// + /// 备注 + /// + public string Remark { get; set; } + /// + /// 订单状态 + /// + public CookEnum CookingStatus { get; set; } + /// + /// 废弃状态 0 正常 1 废弃 + /// + public int IsVaild { get; set; } + /// + /// 废弃时间 + /// + public DateTime? VaildTime { get; set; } + public DateTime? StartCookingTime { get; set; } + public DateTime? EndCookingTime { get; set; } + public DateTime? CompleteTakeTime { get; set; } + /// + /// 订单序号 + /// + public string SortNumber { get; set; } + } +} diff --git a/DataV/Model/BasicEntity.cs b/DataV/Model/BasicEntity.cs new file mode 100644 index 0000000..d30577e --- /dev/null +++ b/DataV/Model/BasicEntity.cs @@ -0,0 +1,15 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DataV.Model +{ + public class BasicEntity + { + [SugarColumn(IsPrimaryKey = true)] + public string Id { get; set; } + public DateTime? CreatedAt { get; set; } + } +} diff --git a/DataV/Model/BasicEntityRead.cs b/DataV/Model/BasicEntityRead.cs new file mode 100644 index 0000000..b5841ac --- /dev/null +++ b/DataV/Model/BasicEntityRead.cs @@ -0,0 +1,22 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DataV.Model +{ + public class BasicEntityRead + { + [SugarColumn(IsPrimaryKey = true)] + public string Id { get; set; } + public string GroupId { get; set; } + public DateTime? UpdateAt { get; set; } + public string UpdateBy { get; set; } + public string DeleteBy { get; set; } + public DateTime? DeleteAt { get; set; } + public int IsDeleted { get; set; } + public DateTime? CreateAt { get; set; } + public string CreateBy { get; set; } + } +} diff --git a/DataV/Program.cs b/DataV/Program.cs new file mode 100644 index 0000000..02f391f --- /dev/null +++ b/DataV/Program.cs @@ -0,0 +1,27 @@ +using BPA.ApolloClient; +using BPA.ApolloClient.Options; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; + +namespace DataV +{ + public class Program + { + public static void Main(string[] args) + { + WebApplicationBuilder builder = WebApplication.CreateBuilder(args); + builder.Inject().WebHost.ConfigureAppConfiguration((context, build) => + { + builder.Configuration.AddApolloConfiguration(opt => + { + builder.Configuration.GetSection(nameof(ApolloOptions)).Bind(opt); + }); + + }); + var app = builder.Build(); + app.Run(); + } + } +} diff --git a/DataV/Properties/launchSettings.json b/DataV/Properties/launchSettings.json new file mode 100644 index 0000000..916e6f2 --- /dev/null +++ b/DataV/Properties/launchSettings.json @@ -0,0 +1,28 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:49839", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "DataV": { + "commandName": "Project", + "dotnetRunMessages": "true", + "launchBrowser": true, + "applicationUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/DataV/Result.cs b/DataV/Result.cs new file mode 100644 index 0000000..0ec5ff3 --- /dev/null +++ b/DataV/Result.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DataV +{ + public class Result + { + public bool IsSuccess { get; set; } + public T Data { get; set; } + public string Msg { get; set; } + } +} diff --git a/DataV/Service/DataVService.cs b/DataV/Service/DataVService.cs new file mode 100644 index 0000000..e20de3d --- /dev/null +++ b/DataV/Service/DataVService.cs @@ -0,0 +1,259 @@ +using DataV.Enums; +using DataV.Model; +using DataV.Service.Dto; +using Furion.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Xml; +using XExten.Advance.HttpFramework.MultiFactory; + +namespace DataV.Service +{ + public class DataVService : IDataVService, ITransient + { + private SqlDbContext Db; + + public DataVService() + { + Db = new SqlDbContext(); + } + /// + /// 大屏数据 + /// + /// + /// + public Result GetAllOrderDataState(int? autokey) + { + var db = Db.DbContext(); + + List OrderIds = new List(); + + + if (autokey != null) + { + OrderIds = db.Queryable().LeftJoin((t, x) => t.Id == x.StoreId) + .Where(t => t.AutoKey == autokey.Value).Select((t, x) => x.OrderId).ToList(); + } + + var data = db.Queryable().Where(t => t.AfterStatus == 0) + .Where(t => t.OrderStatus == PayEnum.PayOk || t.PayMode == PayModelEnum.Other) + .Where(t => !string.IsNullOrEmpty(t.TransactionId)) + .Where(t => !string.IsNullOrEmpty(t.TradeNo)) + .WhereIF(OrderIds.Count > 0, t => OrderIds.Contains(t.Id)) + .Select(t => new { t.OrderRealMoney, t.CreatedAt }).ToList(); + + return new Result + { + Data = new + { + Total = data.Sum(t => t.OrderRealMoney).ToString(), + OrderCount = data.Count().ToString(), + MoneyM = data.Where(t => t.CreatedAt.Value.Month == DateTime.Now.Month).Sum(t => t.OrderRealMoney).ToString(), + MoneyD = data.Where(t => t.CreatedAt.Value >= DateTime.Parse(DateTime.Now.ToShortDateString()) && t.CreatedAt < DateTime.Parse(DateTime.Now.ToShortDateString()).AddDays(1)).Sum(t => t.OrderRealMoney).ToString(), + }, + IsSuccess = true, + Msg = String.Empty + }; + } + + /// + /// 设备 + /// + /// + public Result>> OnlineDevice() + { + string sql = $@"SELECT + a.AutoKey, + b.Name +FROM + BPA_StoreInfo AS a + LEFT JOIN BPA_Company AS b ON a.GroupId= b.Id +"; + + var data = Db.DbContext().SqlQueryable(sql).ToList().GroupBy(t => t.Name).Select(t => new + { + Key = t.Key, + Value = t.Select(x => x.AutoKey).ToList() + }).ToDictionary(t => t.Key, t => t.Value); + + + return new Result>> + { + Data = data, + IsSuccess = true, + Msg = String.Empty + }; + } + + /// + /// 折线图 + /// + /// + /// + public Result OrderLine(int? autokey) + { + var db = Db.DbContext(); + + List OrderIds = new List(); + + + if (autokey != null) + { + OrderIds = db.Queryable().LeftJoin((t, x) => t.Id == x.StoreId) + .Where(t => t.AutoKey == autokey.Value).Select((t, x) => x.OrderId).ToList(); + } + + var data = db.Queryable() + .Where(t => !string.IsNullOrEmpty(t.TransactionId)) + .WhereIF(OrderIds.Count > 0, t => OrderIds.Contains(t.Id)) + .Where(t => !string.IsNullOrEmpty(t.TradeNo)).Select(t => new + { + t.OrderStatus, + t.AfterStatus, + t.CreatedAt, + t.PayMode + }).ToList(); + + List res = new List(); + + + for (int index = 0; index < 10; index++) + { + var temp = DateTime.Now.AddDays(-index); + var end = DateTime.Parse(temp.ToString("yyyy-MM-dd 23:59:59")); + var start = DateTime.Parse(temp.ToString("yyyy-MM-dd 00:00:00")); + var NO = data.Where(t => t.CreatedAt.Value < end && t.CreatedAt.Value >= start).Where(t => t.AfterStatus != 0 && (t.OrderStatus == PayEnum.PayOk || t.PayMode == PayModelEnum.Other)).Count(); + var OK = data.Where(t => t.CreatedAt.Value < end && t.CreatedAt.Value >= start).Where(t => t.AfterStatus == 0 && (t.OrderStatus == PayEnum.PayOk || t.PayMode == PayModelEnum.Other)).Count(); + var Date = temp.ToString("MM/dd"); + res.Add(new + { + NO, + OK, + Date + }); + } + + return new Result + { + Data = res, + IsSuccess = true, + Msg = String.Empty, + }; + } + + /// + /// 下单数量 + /// + /// + /// + public Result OrderNumber(int? autokey) + { + var db = Db.DbContext(); + + List OrderIds = new List(); + + + if (autokey != null) + { + OrderIds = db.Queryable().LeftJoin((t, x) => t.Id == x.StoreId) + .Where(t => t.AutoKey == autokey.Value).Select((t, x) => x.OrderId).ToList(); + } + + + var data = db.Queryable().Where(t => t.AfterStatus == 0) + .Where(t => t.OrderStatus == PayEnum.PayOk || t.PayMode == PayModelEnum.Other) + .Where(t => !string.IsNullOrEmpty(t.TransactionId)) + .Where(t => !string.IsNullOrEmpty(t.TradeNo)) + .WhereIF(OrderIds.Count > 0, t => OrderIds.Contains(t.Id)) + .Select(t => t.CreatedAt).ToList(); + + return new Result + { + IsSuccess = true, + Msg = String.Empty, + Data = new + { + Year = data.Where(t => t.Value.Year == DateTime.Now.Year).Count(), + Month = data.Where(t => t.Value.Month == DateTime.Now.Month).Count(), + Day = data.Where(t => t.Value.Day == DateTime.Now.Day).Count(), + } + }; + } + + /// + /// 区域销售 + /// + /// + public Result GetLocSale() + { + var db = Db.DbContext(); + + var baiduMap = "http://api.map.baidu.com/geocoder/v2/?ak=3ce7ddfda60046708248ea55e10b1435&callback=renderReverse&location={0}&output=xml"; + List loc = new List(); + var data = db.SqlQueryable(@"SELECT + a.Store_Loc AS Loc, + ( + SELECT COUNT + ( b.Id ) + FROM + BPA_Order AS b + JOIN BPA_SubOrder AS c ON b.Id= c.OrderId + WHERE + c.StoreId= a.Id + AND ( b.OrderStatus= 1 OR b.OrderStatus = 4 ) + AND b.TradeNo IS NOT NULL + AND b.TransactionId IS NOT NULL + ) AS Counts +FROM + BPA_StoreInfo AS a +WHERE + a.Store_Status = 0 + AND a.IsDeleted = 0 + AND a.Store_Loc LIKE '%,%'").ToList(); + IHttpMultiClient http = null; + + data.ForEach(item => + { + if (http == null) + http = IHttpMultiClient.HttpMulti.AddNode(opt => + { + opt.NodePath = String.Format(baiduMap, item.Loc); + }); + else + http = http.AddNode(opt => + { + opt.NodePath = String.Format(baiduMap, item.Loc); + }); + }); + XmlDocument doc = new XmlDocument(); + + var Temps = http.Build().RunString(); + + for (int i = 0; i < Temps.Count; i++) + { + doc.LoadXml(Temps[i]); + loc.Add(new LocDto + { + Count = data[i].Counts, + City = doc.SelectSingleNode("//province")?.InnerText + doc.SelectSingleNode("//city")?.InnerText + }); + } + + return new Result + { + Data = new + { + Data = loc.GroupBy(t => t.City).Select(t => new LocDto + { + City = t.Key, + Count = t.Sum(t => t.Count) + }) + }, + IsSuccess = true, + Msg = "" + }; + } + } +} diff --git a/DataV/Service/Dto/DataVDto.cs b/DataV/Service/Dto/DataVDto.cs new file mode 100644 index 0000000..82a4a82 --- /dev/null +++ b/DataV/Service/Dto/DataVDto.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DataV.Service.Dto +{ + public class DataVDto + { + public int AutoKey { get; set; } + public string Name { get; set; } + } +} diff --git a/DataV/Service/Dto/LocDto.cs b/DataV/Service/Dto/LocDto.cs new file mode 100644 index 0000000..2e7e461 --- /dev/null +++ b/DataV/Service/Dto/LocDto.cs @@ -0,0 +1,8 @@ +namespace DataV.Service.Dto +{ + public class LocDto + { + public string City { get; set; } + public int Count { get; set; } + } +} diff --git a/DataV/Service/IDataVService.cs b/DataV/Service/IDataVService.cs new file mode 100644 index 0000000..a8a5ccd --- /dev/null +++ b/DataV/Service/IDataVService.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DataV.Service +{ + public interface IDataVService + { + + Result GetAllOrderDataState(int? autokey); + + Result OrderLine(int? autokey); + + Result OrderNumber(int? autokey); + + Result>> OnlineDevice(); + + Result GetLocSale(); + + } +} diff --git a/DataV/SqlDbContext.cs b/DataV/SqlDbContext.cs new file mode 100644 index 0000000..f28d5f6 --- /dev/null +++ b/DataV/SqlDbContext.cs @@ -0,0 +1,27 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DataV +{ + public class SqlDbContext + { + public SqlSugarScope DbContext() + { + SqlSugarScope client = new SqlSugarScope(new ConnectionConfig + { + ConnectionString = Furion.App.Configuration["DbConnectionstring"], + DbType = DbType.SqlServer, + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true + }); + client.Aop.OnLogExecuting = (sql, pars) => + { + Console.WriteLine($"当前SQL语句:【{sql}】,参数:【{string.Join(",", pars.Select(t => t.Value))}】"); + }; + return client; + } + } +} diff --git a/DataV/Startup.cs b/DataV/Startup.cs new file mode 100644 index 0000000..1320d96 --- /dev/null +++ b/DataV/Startup.cs @@ -0,0 +1,48 @@ +using Furion; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace DataV +{ + public class Startup: AppStartup + { + + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddControllers().AddInjectWithUnifyResult(); + + services.AddCorsAccessor(); + + services.AddRemoteRequest(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + app.UseStaticFiles(); + + app.UseRouting(); + + app.UseCorsAccessor(); + + app.UseAuthentication(); + app.UseAuthorization(); + + app.UseInject(string.Empty); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} diff --git a/DataV/appsettings.json b/DataV/appsettings.json new file mode 100644 index 0000000..730cdcf --- /dev/null +++ b/DataV/appsettings.json @@ -0,0 +1,17 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*", + "ApolloOptions": { + "MetaServer": "http://10.2.1.21:28080", //Meta serverַ޸ + "Namespaces": [ + "data_v" + ], + "AppId": "dev1_data_v" //ԼӦ޸ + } +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..de6826b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base +RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf +RUN sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1/g' /etc/ssl/openssl.cnf +RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /usr/lib/ssl/openssl.cnf +RUN sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1/g' /usr/lib/ssl/openssl.cnf +RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +RUN echo Asia/Shanghai > /etc/timezone +RUN cat /etc/localtime +ENV TZ=Asia/Shanghai +WORKDIR /app +EXPOSE 9000 + +FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build +WORKDIR /src + +COPY . . + +WORKDIR "/src/DataV" +RUN dotnet build "DataV.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "DataV.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . + +ENV ASPNETCORE_URLS http://+:9000 + +ENTRYPOINT ["dotnet", "DataV.dll"] \ No newline at end of file diff --git a/NuGet.config b/NuGet.config new file mode 100644 index 0000000..d7f23e6 --- /dev/null +++ b/NuGet.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file