Browse Source

授权调整

Your Name 4 months ago
parent
commit
89f41d9416
50 changed files with 1560 additions and 277 deletions
  1. 10 2
      FuelCloud/Fuel.Application/Authorization/Authorization.cs
  2. 40 16
      FuelCloud/Fuel.Application/Authorization/PermissionHandler.cs
  3. 1 0
      FuelCloud/Fuel.Application/Fuel.Application.csproj
  4. 0 12
      FuelCloud/Fuel.Application/Repositories/NozzleRepository.cs
  5. 22 0
      FuelCloud/Fuel.Application/Service/ApplyService.cs
  6. 14 0
      FuelCloud/Fuel.Application/Service/IApplyService.cs
  7. 11 2
      FuelCloud/Fuel.Application/Service/INozzleService.cs
  8. 1 0
      FuelCloud/Fuel.Application/Service/IUserService.cs
  9. 237 43
      FuelCloud/Fuel.Application/Service/NozzleService.cs
  10. 26 0
      FuelCloud/Fuel.Application/Service/UserService.cs
  11. 55 0
      FuelCloud/Fuel.Infrastructure/Payment/Enum/PaymentID.cs
  12. 24 0
      FuelCloud/Fuel.Infrastructure/Payment/Enum/ReturnCode.cs
  13. 22 0
      FuelCloud/Fuel.Infrastructure/Payment/GenericProcessResponse.cs
  14. 14 0
      FuelCloud/Fuel.Infrastructure/Payment/IPaymentNotifier.cs
  15. 22 0
      FuelCloud/Fuel.Infrastructure/Payment/IPaymentProcessor.cs
  16. 45 0
      FuelCloud/Fuel.Infrastructure/Payment/Models/AllInPay/TongLianResponseV2.cs
  17. 111 0
      FuelCloud/Fuel.Infrastructure/Payment/Models/ElectronicOrderModel.cs
  18. 27 0
      FuelCloud/Fuel.Infrastructure/Payment/Models/ElectronicOrderProcessResultModel.cs
  19. 31 0
      FuelCloud/Fuel.Infrastructure/Payment/Models/FuelOrderDetailModel.cs
  20. 61 0
      FuelCloud/Fuel.Infrastructure/Payment/Models/ServiceResponse.cs
  21. 16 0
      FuelCloud/Fuel.Infrastructure/Payment/Models/TradeStatus.cs
  22. 41 0
      FuelCloud/Fuel.Infrastructure/Payment/Models/UnionPay/UnionPayConfig.cs
  23. 55 0
      FuelCloud/Fuel.Infrastructure/Payment/SequenceNumber.cs
  24. 12 0
      FuelCloud/Fuel.Infrastructure/Payment/Services/IOrderServer.cs
  25. 12 0
      FuelCloud/Fuel.Infrastructure/Payment/Services/IPaymentServer.cs
  26. 2 16
      FuelCloud/FuelCloud.sln
  27. 5 4
      FuelCloud/src/Fuel.Payment.Server/Controllers/AuthController.cs
  28. 118 3
      FuelCloud/src/Fuel.Payment.Server/Controllers/NozzleController.cs
  29. 1 0
      FuelCloud/src/Fuel.Payment.Server/Controllers/TransactionsController.cs
  30. 1 1
      FuelCloud/src/Fuel.Payment.Server/Fuel.PaymentServer.csproj
  31. 68 0
      FuelCloud/src/Fuel.Payment.Server/MicServer/Middlewares/JwtValidator.cs
  32. 100 0
      FuelCloud/src/Fuel.Payment.Server/MicServer/Middlewares/SignatureValidationMiddleware.cs
  33. 91 0
      FuelCloud/src/Fuel.Payment.Server/MicServer/Middlewares/SignatureValidator.cs
  34. 31 6
      FuelCloud/src/Fuel.Payment.Server/Program.cs
  35. 3 1
      FuelCloud/src/FuelServer.Core/Entity/AdApply.cs
  36. 78 0
      FuelCloud/src/FuelServer.Core/Entity/AdRoleApply.cs
  37. 3 3
      FuelCloud/src/FuelServer.Core/Entity/configuration.cs
  38. 1 1
      FuelCloud/src/FuelServer.Core/Entity/miniprogramusers.cs
  39. 13 7
      FuelCloud/src/FuelServer.Core/Entity/nozzle.cs
  40. 1 1
      FuelCloud/src/FuelServer.Core/Entity/paytype.cs
  41. 9 2
      FuelCloud/src/FuelServer.Core/Entity/product.cs
  42. 10 5
      FuelCloud/src/FuelServer.Core/Entity/tanks.cs
  43. 5 5
      FuelCloud/src/FuelServer.Core/Entity/transactions.cs
  44. 1 1
      FuelCloud/src/FuelServer.Core/Entity/users.cs
  45. 0 1
      FuelCloud/src/FuelServer.Core/Fuel.Core.csproj
  46. 61 0
      FuelCloud/src/FuelServer.Core/HttpRequestReader.cs
  47. 3 3
      FuelCloud/src/FuelServer.Core/Nozzle/Dto/NozzleInfo.cs
  48. 45 9
      FuelCloud/src/FuelServer.Core/Nozzle/Dto/UploadNozzle.cs
  49. 0 47
      FuelCloud/src/FuelServer.Core/SignatureValidationMiddleware.cs
  50. 0 86
      FuelCloud/src/FuelServer.Core/SignatureValidator.cs

+ 10 - 2
FuelCloud/Fuel.Application/Authorization/Authorization.cs

@@ -13,8 +13,9 @@ namespace Fuel.Core
     public  class Authorization
     {
         private   IUserService _userService;
+        private IApplyService _applyService;
 
-        //public  Authorization(IUserService userService)
+        //public Authorization(IUserService userService)
         //{
         //    _userService = ServiceLocator.GetRequiredService<IUserService>();
         //}
@@ -23,9 +24,10 @@ namespace Fuel.Core
         //    var permissions =   _userService.GetUserPermissions();
         //    return permissions;
         //}
-        public Authorization(IUserService userService)
+        public Authorization(IUserService userService,IApplyService applyService)
         {
             _userService = userService;
+            _applyService = applyService;
         }
 
         public List<string> GetPermissions()
@@ -33,6 +35,12 @@ namespace Fuel.Core
             var permissions = _userService.GetUserPermissions();
             return permissions;
         }
+        public AdApply GetApply(string appid)
+        {
+            var apply = _applyService.GetApply(appid);
+            return apply;
+        }
+
     }
     public static class ServiceLocator
     {

+ 40 - 16
FuelCloud/Fuel.Application/Authorization/PermissionHandler.cs

@@ -6,6 +6,7 @@ using System.Security.Claims;
 using System.Text;
 using System.Threading.Tasks;
 using Fuel.Application.Service;
+using Microsoft.AspNetCore.Http;
 
 namespace Fuel.Application.Authorization
 {
@@ -20,30 +21,53 @@ namespace Fuel.Application.Authorization
 
         protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, PermissionRequirement requirement)
         {
-            var user = context.User;
-
-            if (user == null || !user.Identity.IsAuthenticated)
+            bool IsSite = false;//判断是否是子站请求
+            bool Isbackstage = false;//判断是否是后台请求
+            string secret_id = string.Empty;
+            var httpContext = (context.Resource as HttpContext);
+            if (httpContext != null)
             {
-                return;
+                if (httpContext.Request.Headers.TryGetValue("secret_id", out var userIdHeader))
+                {
+                    IsSite = true;
+                     secret_id = userIdHeader.ToString();
+                }
             }
 
-            // 从用户声明中获取用户 ID
-            var userIdClaim = user.FindFirst(ClaimTypes.NameIdentifier);
-            if (userIdClaim == null)
+            var user = context.User;
+            int userId = 0;
+            if (user != null && user.Identity.IsAuthenticated)
             {
-                return;
+                // 从用户声明中获取用户 ID
+                var userIdClaim = user.FindFirst(ClaimTypes.NameIdentifier);
+                if (userIdClaim != null)
+                {
+                    userId = int.TryParse(userIdClaim.Value, out int number) ? number : 0;
+                    Isbackstage = true;
+                }
             }
 
-           // var userId = userIdClaim.Value;
-            int userId = int.TryParse(userIdClaim.Value, out int number) ? number : 0;
-            // 查询用户的权限列表
-            var permissions =   _userService.GetUserPermissions(userId);
-
-            // 检查用户是否有足够的权限
-            if (permissions.Contains(requirement.Permission))
+            if (IsSite || Isbackstage)
             {
-                context.Succeed(requirement);
+                List<string>? permissions = null;
+                if (IsSite)
+                {
+                    // 查询用户权限
+                    permissions = _userService.GetUserPermissions(userId);
+                }
+                if (Isbackstage)
+                {
+
+                    permissions = _userService.GetSitePermissions(secret_id);
+                }
+
+                // 检查用户是否有权限
+                if (permissions.Contains(requirement.Permission))
+                {
+                    context.Succeed(requirement);
+                }
             }
+          
         }
     }
 }

+ 1 - 0
FuelCloud/Fuel.Application/Fuel.Application.csproj

@@ -7,6 +7,7 @@
   </PropertyGroup>
 
   <ItemGroup>
+    <PackageReference Include="Microsoft.AspNetCore.Authorization" Version="8.0.6" />
     <PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
   </ItemGroup>
 

+ 0 - 12
FuelCloud/Fuel.Application/Repositories/NozzleRepository.cs

@@ -18,18 +18,6 @@ namespace Fuel.Application.Repositories
         public async Task<bool> uploadNozzle(UploadNozzle uploadNozzle)
         {
             bool result = false;
-            if (uploadNozzle.type == 1)
-            {
-
-            }
-            else if (uploadNozzle.type == 2)
-            {
-
-            }
-            else if (uploadNozzle.type == 3)
-            {
-
-            }
             var sds = _fsql.Select<nozzle>().ToList();
             return result;
         }

+ 22 - 0
FuelCloud/Fuel.Application/Service/ApplyService.cs

@@ -0,0 +1,22 @@
+using FuelServer.Core.Entity;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Application.Service
+{
+    public class ApplyService: IApplyService
+    {
+        public readonly IFreeSql _fsql;
+        public ApplyService(IFreeSql fsql)
+        {
+            _fsql = fsql;
+        }
+        public  AdApply GetApply(string appId)
+        {
+            return  _fsql.Select<AdApply>().Where(_ => _.Appid == appId).First();
+        }
+    }
+}

+ 14 - 0
FuelCloud/Fuel.Application/Service/IApplyService.cs

@@ -0,0 +1,14 @@
+using FuelServer.Core.Entity;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Application.Service
+{
+    public interface IApplyService
+    {
+        AdApply GetApply(string appId);
+    }
+}

+ 11 - 2
FuelCloud/Fuel.Application/Service/INozzleService.cs

@@ -1,4 +1,5 @@
-using Fuel.Core.Nozzle.Dto;
+using Fuel.Core.Models;
+using Fuel.Core.Nozzle.Dto;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -9,7 +10,15 @@ namespace Fuel.Application.Service
 {
     public interface INozzleService
     {
-        Task<bool> uploadNozzle(UploadNozzle uploadNozzle);
+        Task<ServiceResponse> uploadNozzle(UploadNozzle uploadNozzle);
+        Task<ServiceResponse> UpdateNozzle(UploadNozzle uploadNozzle);
+        Task<ServiceResponse> DeleteNozzle(UploadNozzle uploadNozzle);
         Task<List<NozzleInfo>> GetNozzleInfo(int Nozzleid);
+        Task<ServiceResponse> UploadProduct(UploadProduct uploadProduct);
+        Task<ServiceResponse> UpdateProduct(UploadProduct uploadProduct);
+        Task<ServiceResponse> DeleteProduct(UploadProduct uploadProduct);
+        Task<ServiceResponse> UploadTanks(UploadTanks uploadTanks);
+        Task<ServiceResponse> UpdateTanks(UploadTanks uploadTanks);
+        Task<ServiceResponse> DeleteTanks(UploadTanks uploadTanks);
     }
 }

+ 1 - 0
FuelCloud/Fuel.Application/Service/IUserService.cs

@@ -10,6 +10,7 @@ namespace Fuel.Application.Service
     public interface  IUserService
     {
         List<string> GetUserPermissions(int userId = 1);
+        List<string> GetSitePermissions(string Appid);
         users ValidateCredentials(string username, string password);
     }
 }

+ 237 - 43
FuelCloud/Fuel.Application/Service/NozzleService.cs

@@ -1,5 +1,8 @@
-using Fuel.Core.Nozzle.Dto;
+using Fuel.Core;
+using Fuel.Core.Models;
+using Fuel.Core.Nozzle.Dto;
 using FuelServer.Core.Entity;
+using Org.BouncyCastle.Ocsp;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -13,69 +16,259 @@ namespace Fuel.Application.Service
     public class NozzleService : INozzleService
     {
         private readonly EntityHelper _entityHelper;
-        public NozzleService(EntityHelper entityHelper)
+        public readonly IFreeSql _fsql;
+        public NozzleService(EntityHelper entityHelper, IFreeSql fsql)
         {
             _entityHelper = entityHelper;
+            _fsql = fsql;
         }
+        #region 油品
         /// <summary>
-        /// 上传油枪
+        /// 上传油品
+        /// </summary>
+        /// <param name="uploadProduct"></param>
+        /// <returns></returns>
+        public async Task<ServiceResponse> UploadProduct(UploadProduct uploadProduct)
+        {
+            Guid guid = HttpRequestReader.GetCurrentBuId(); //站点id
+            var _product = _fsql.Select<product>().Where(_ => _.Buid == guid && _.ProductId == uploadProduct.ProductId).First();
+            if (_product != null)
+            {
+                return ServiceResponse.Error("油品已存在,请勿重复上传");
+            }
+            product product = new product();
+            product.Buid = guid;
+            product.ProductId = uploadProduct.ProductId;
+            product.ProductCode = uploadProduct.ProductCode;
+            product.ProductName = uploadProduct.ProductName;
+            product.ProductPrice = uploadProduct.ProductPrice;
+
+            int affectedRows = _fsql.Insert<product>().AppendData(product).ExecuteAffrows();
+            if (affectedRows <= 0)
+            {
+                return ServiceResponse.Error("油品信息插入失败");
+            }
+            return ServiceResponse.Ok(product);
+        }
+
+        /// <summary>
+        /// 更新油品信息
         /// </summary>
         /// <param name="uploadNozzle"></param>
         /// <returns></returns>
-        public async Task<bool> uploadNozzle(UploadNozzle uploadNozzle)
+        public async Task<ServiceResponse> UpdateProduct(UploadProduct uploadProduct)
         {
-            //RedisHelper.HSetAsync("Transaction", "11:22:33:44", "3232");
-            //RedisHelper.SetAsync("33:22:33:44", "qweqweqwe", 3600);
-           // var fsdds = RedisHelper.GetAsync("33:22:33:44");
-            //var das = RedisHelper.ExpireAsync("33:22:33:44", 10);
-            Guid guid = Guid.Parse("12345678-9abc-def0-1234-56789abcdef0");//站点id,先默认填这个
-            if (uploadNozzle.type == 1)
-            {
-                var isproduct = await _entityHelper.GetEntitiesAsync<product>(_ => _.Buid == guid && _.ProductName == uploadNozzle.ProductName);
-                var istanks = await _entityHelper.GetEntitiesAsync<tanks>(_ => _.Buid == guid && _.TankNumber == uploadNozzle.TankNumber);
-                var isnozzle = await _entityHelper.GetEntitiesAsync<nozzle>(_ => _.Buid == guid && _.ExternalGunNumber == uploadNozzle.ExternalGunNumber);
-                if (isproduct.Count > 0 || istanks.Count > 0 || isnozzle.Count > 0)
-                {
-                    return false;
-                }
-                product product = new product();
-                product.ProductPrice = uploadNozzle.ProductPrice;
-                product.ProductName = uploadNozzle.ProductName;
-                product.ProductCode = uploadNozzle.ProductCode;
-                product.Buid = guid;
+            Guid guid = HttpRequestReader.GetCurrentBuId(); //站点id
+            var _product = _fsql.Select<product>().Where(_ => _.Buid == guid && _.ProductId == uploadProduct.ProductId).First();
+            if (_product == null)
+            {
+                return ServiceResponse.Error("未找到油枪");
+            }
+            _product.ProductCode = uploadProduct.ProductCode;
+            _product.ProductName = uploadProduct.ProductName;
+            _product.ProductPrice = uploadProduct.ProductPrice;
+            int affectedRows = _fsql.Update<product>().SetSource(_product).ExecuteAffrows();
+            if (affectedRows <= 0)
+            {
+                return ServiceResponse.Error("油品信息更新失败");
+            }
+            return ServiceResponse.Ok(_product);
+        }
+
+        /// <summary>
+        /// 删除油品信息
+        /// </summary>
+        /// <param name="uploadNozzle"></param>
+        /// <returns></returns>
+        public async Task<ServiceResponse> DeleteProduct(UploadProduct uploadProduct)
+        {
+            Guid guid = HttpRequestReader.GetCurrentBuId(); //站点id
+            var _product = _fsql.Select<product>().Where(_ => _.Buid == guid && _.ProductId == uploadProduct.ProductId).First();
+            if (_product == null)
+            {
+                return ServiceResponse.Error("未找到油品");
+            }
+            int affectedRows = _fsql.Delete<product>()
+     .Where(p => p.ProductId == uploadProduct.ProductId)
+     .ExecuteAffrows();
+            if (affectedRows <= 0)
+            {
+                return ServiceResponse.Error("油品信息删除失败");
+            }
+            return ServiceResponse.Ok();
+        }
+
+        #endregion
+
 
-                var productid = await _entityHelper.InsertEntityAsync(product);
+        #region 油罐
+
+        /// <summary>
+        /// 上传油罐
+        /// </summary>
+        /// <param name="uploadProduct"></param>
+        /// <returns></returns>
+        public async Task<ServiceResponse> UploadTanks(UploadTanks uploadTanks)
+        {
+            Guid guid = HttpRequestReader.GetCurrentBuId(); //站点id
+            var _tanks = _fsql.Select<tanks>().Where(_ => _.Buid == guid && _.TankID == uploadTanks.TankID).First();
+            if (_tanks != null)
+            {
+                return ServiceResponse.Error("油灌已存在,请勿重复上传");
+            }
+            tanks tanks = new tanks();
+            tanks.Buid = guid;
+            tanks.ProductId = uploadTanks.ProductId;
+            tanks.TankCapacity = uploadTanks.TankCapacity;
+            tanks.ProductName = uploadTanks.ProductName;
+            tanks.TankNumber = uploadTanks.TankNumber;
 
-                tanks tanks = new tanks();
-                tanks.Buid = guid;
-                tanks.TankNumber = uploadNozzle.TankNumber;
-                tanks.TankCapacity = uploadNozzle.TankCapacity;
-                tanks.ProductId = productid.Id;
-                tanks.ProductName = uploadNozzle.ProductName;
+            int affectedRows = _fsql.Insert<tanks>().AppendData(tanks).ExecuteAffrows();
+            if (affectedRows <= 0)
+            {
+                return ServiceResponse.Error("油灌信息插入失败");
+            }
+            return ServiceResponse.Ok(tanks);
+        }
 
-                var tanksid = await _entityHelper.InsertEntityAsync(tanks);
+        /// <summary>
+        /// 更新油罐
+        /// </summary>
+        /// <param name="uploadNozzle"></param>
+        /// <returns></returns>
+        public async Task<ServiceResponse> UpdateTanks(UploadTanks uploadTanks)
+        {
+            Guid guid = HttpRequestReader.GetCurrentBuId(); //站点id
+            var _tanks = _fsql.Select<tanks>().Where(_ => _.Buid == guid && _.TankID == uploadTanks.TankID).First();
+            if (_tanks != null)
+            {
+                return ServiceResponse.Error("油灌已存在,请勿重复上传");
+            }
+            _tanks.ProductId = uploadTanks.ProductId;
+            _tanks.TankCapacity = uploadTanks.TankCapacity;
+            _tanks.ProductName = uploadTanks.ProductName;
+            _tanks.TankNumber = uploadTanks.TankNumber;
+            int affectedRows = _fsql.Update<tanks>().SetSource(_tanks).ExecuteAffrows();
+            if (affectedRows <= 0)
+            {
+                return ServiceResponse.Error("油灌信息更新失败");
+            }
+            return ServiceResponse.Ok(_tanks);
+        }
 
-                nozzle nozzle = new nozzle();
-                nozzle.Buid = guid;
-                nozzle.PumpId = uploadNozzle.PumpID;
-                nozzle.TankId = tanksid.Id;
-                nozzle.InternalGunNumber = uploadNozzle.InternalGunNumber;
-                nozzle.ExternalGunNumber = uploadNozzle.ExternalGunNumber;
-                nozzle.ProductID = productid.Id;
-                await _entityHelper.InsertEntityAsync(nozzle);
+        /// <summary>
+        /// 删除油罐
+        /// </summary>
+        /// <param name="uploadNozzle"></param>
+        /// <returns></returns>
+        public async Task<ServiceResponse> DeleteTanks(UploadTanks uploadTanks)
+        {
+            Guid guid = HttpRequestReader.GetCurrentBuId(); //站点id
+            var _tanks = _fsql.Select<tanks>().Where(_ => _.Buid == guid && _.TankID == uploadTanks.TankID).First();
+            if (_tanks != null)
+            {
+                return ServiceResponse.Error("油灌已存在,请勿重复上传");
             }
-            else if (uploadNozzle.type == 2)
+            int affectedRows = _fsql.Delete<tanks>()
+     .Where(p => p.TankID == uploadTanks.TankID)
+     .ExecuteAffrows();
+            if (affectedRows <= 0)
             {
+                return ServiceResponse.Error("油灌信息删除失败");
+            }
+            return ServiceResponse.Ok();
+        }
+
+        #endregion
+
+        #region 油枪
 
+        /// <summary>
+        /// 上传油枪
+        /// </summary>
+        /// <param name="uploadNozzle"></param>
+        /// <returns></returns>
+        public async Task<ServiceResponse> uploadNozzle(UploadNozzle uploadNozzle)
+        {
+            //RedisHelper.HSetAsync("Transaction", "11:22:33:44", "3232");
+            //RedisHelper.SetAsync("33:22:33:44", "qweqweqwe", 3600);
+            // var fsdds = RedisHelper.GetAsync("33:22:33:44");
+            //var das = RedisHelper.ExpireAsync("33:22:33:44", 10);
+            Guid guid = HttpRequestReader.GetCurrentBuId(); //站点id
+            var _product = _fsql.Select<product>().Where(_ => _.Buid == guid && _.ProductName == uploadNozzle.ProductName).First();
+            var _tanks = _fsql.Select<tanks>().Where(_ => _.Buid == guid && _.TankNumber == uploadNozzle.TankNumber).First();
+            var isproduct = _fsql.Select<nozzle>().Where(_ => _.Buid == guid && _.NozzleId == uploadNozzle.NozzleId).First();
+            if (isproduct != null)
+            {
+                return ServiceResponse.Error("油枪已存在");
+            }
+            if (_product != null || _tanks != null)
+            {
+                return ServiceResponse.Error("油品或油罐信息为空");
+            }
+            nozzle _nozzle = new nozzle();
+            _nozzle.Buid = guid;
+            _nozzle.PumpId = uploadNozzle.PumpID;
+            _nozzle.TankId = _tanks.Id;
+            _nozzle.InternalGunNumber = uploadNozzle.InternalGunNumber;
+            _nozzle.ExternalGunNumber = uploadNozzle.ExternalGunNumber;
+            _nozzle.ProductID = _product.Id;
+            int affectedRows = _fsql.Insert<nozzle>().AppendData(_nozzle).ExecuteAffrows();
+            if (affectedRows <= 0)
+            {
+                return ServiceResponse.Error("油枪信息插入失败");
+            }
+            return ServiceResponse.Ok(_nozzle);
+        }
+        /// <summary>
+        /// 更新油枪信息
+        /// </summary>
+        /// <param name="uploadNozzle"></param>
+        /// <returns></returns>
+        public async Task<ServiceResponse> UpdateNozzle(UploadNozzle uploadNozzle)
+        {
+            Guid guid = HttpRequestReader.GetCurrentBuId(); //站点id
+            var _nozzle = _fsql.Select<nozzle>().Where(_ => _.Buid == guid && _.NozzleId == uploadNozzle.NozzleId).First();
+            if (_nozzle == null)
+            {
+                return ServiceResponse.Error("未找到油枪");
+            }
+            _nozzle.PumpId = uploadNozzle.PumpID;
+            _nozzle.InternalGunNumber = uploadNozzle.InternalGunNumber;
+            _nozzle.ExternalGunNumber = uploadNozzle.ExternalGunNumber;
+            int affectedRows = _fsql.Update<nozzle>().SetSource(_nozzle).ExecuteAffrows();
+            if (affectedRows <= 0)
+            {
+                return ServiceResponse.Error("油枪信息更新失败");
+            }
+            return ServiceResponse.Ok(_nozzle);
+        }
+        /// <summary>
+        /// 删除油枪信息
+        /// </summary>
+        /// <param name="uploadNozzle"></param>
+        /// <returns></returns>
+        public async Task<ServiceResponse> DeleteNozzle(UploadNozzle uploadNozzle)
+        {
+            Guid guid = HttpRequestReader.GetCurrentBuId(); //站点id
+            var _nozzle = _fsql.Select<nozzle>().Where(_ => _.Buid == guid && _.NozzleId == uploadNozzle.NozzleId).First();
+            if (_nozzle == null)
+            {
+                return ServiceResponse.Error("未找到油枪");
             }
-            else if (uploadNozzle.type == 3)
+            int affectedRows = _fsql.Delete<nozzle>()
+    .Where(p => p.NozzleId == uploadNozzle.NozzleId) 
+    .ExecuteAffrows();
+            if (affectedRows <= 0)
             {
+                return ServiceResponse.Error("油枪信息删除失败");
             }
-            return true;
+            return ServiceResponse.Ok();
         }
+
         public async Task<List<NozzleInfo>> GetNozzleInfo(int Nozzleid)
         {
-            Guid guid = Guid.Parse("12345678-9abc-def0-1234-56789abcdef0");
+            Guid guid = HttpRequestReader.GetCurrentBuId(); //站点id
             return _entityHelper._fsql.Select<nozzle, tanks, product>()
                     .LeftJoin((a, b, c) => a.TankId == b.Id)
                     .LeftJoin((a, b, c) => a.ProductID == c.Id)
@@ -89,5 +282,6 @@ namespace Fuel.Application.Service
                         TankNumber = b.TankNumber
                     });
         }
+        #endregion
     }
 }

+ 26 - 0
FuelCloud/Fuel.Application/Service/UserService.cs

@@ -35,10 +35,36 @@ namespace Fuel.Application.Service
             var permissionList = new List<string>();
             foreach (var permission in Permission)
             {
+                if(permission.d != null)
                 permissionList.Add(permission.d.Code);
             }
+            permissionList.Add("Nozzle:uploadNozzle:POST");
+            permissionList.Add("Nozzle:DeleteNozzle:Delete");
             return permissionList;
 
         }
+        public List<string> GetSitePermissions(string Appid)
+        {
+            var Permission = _fsql.Select<AdApply, AdRoleApply, AdRole,AdRolePermission, AdPermission>()
+ .LeftJoin((a, b, c, d,e) => a.Id == b.OauthApplyID)
+ .LeftJoin((a, b, c, d, e) => b.OauthRoleID == c.Id)
+ .LeftJoin((a, b, c, d, e) => c.Id == d.RoleId)
+  .LeftJoin((a, b, c, d, e) => d.PermissionId == e.Id)
+ .Where((a, b, c, d, e) => a.Appid == Appid)
+ .ToList((a, b, c, d, e) => new { e });
+            var permissionList = new List<string>();
+            foreach (var permission in Permission)
+            {
+                if (permission.e != null)
+                    permissionList.Add(permission.e.Code);
+            }
+            permissionList.Add("Nozzle:uploadNozzle:POST");
+            permissionList.Add("Nozzle:DeleteNozzle:Delete");
+            return permissionList;
+        }
+        public Task<users> GetUsers()
+        {
+            return null;
+        }
     }
 }

+ 55 - 0
FuelCloud/Fuel.Infrastructure/Payment/Enum/PaymentID.cs

@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Infrastructure.Payment.Enum
+{
+    public enum PaymentID
+    {
+        Cash = 1, //室内现金
+        AliPay = 2,
+        WechatPay = 3,
+        IC = 4,
+        MiniProgram = 5,
+        ThirdPartyPay = 6,
+        AutoCleared = 7, //油机大屏上的自动清除
+        BankCard = 8,
+        OutdoorCash = 9, //油机大屏的室外现金
+        IndoorPay = 10, //油机大屏上的室内支付
+        AllInPay = 11, //通联支付,
+        PumpTest = 12, //打油测试, 现改为回罐
+        AllInPayV2 = 13, //通联分账支付,
+        IcbcPay = 16, //工商银行支付
+        IcbcPayQrScan = 18, //统一下单,用户扫商户, 微信支付宝工商银行扫码支付,
+        WechatQrScan = 20, //微信扫码,统一下单,用户扫商户,
+        AliPayQrScan = 21, //支付宝扫码,统一下单,用户扫商户,
+        PointPay = 26, //积分支付
+        MiniUnionPay = 56, //小程序银联云闪付
+        UnionPay = 58, //银联云闪付
+        GrgbankingPay = 60, //广电运通支付
+        SelfUse = 30, //自用,
+        CarPlate = 100,
+        /// <summary>
+        /// outdoor driver drive off without real payment
+        /// </summary>
+        DriveOff = 400,
+        /// <summary>
+        /// indoor customer leave off without real payment
+        /// </summary>
+        LeaveOff = 401,
+        /// <summary>
+        /// membership depoist balance payment initiated by mini program 
+        /// </summary>
+        MembershipPay = 500,
+        /// <summary>
+        /// membership mobile payment initiated by mini program 
+        /// </summary>
+        MembershipMobilePay = 501,
+
+        PetroChinaIC = 600,
+        AliSmilePay = 700, //支付宝刷脸付
+        WechatSmilePay = 701 //微信刷脸付
+    }
+}

+ 24 - 0
FuelCloud/Fuel.Infrastructure/Payment/Enum/ReturnCode.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Infrastructure.Payment.Enum
+{
+    public enum ReturnCode
+    {
+        OK = 0,
+        SITE_ID_NOT_AUTHORIZED = 1,
+        PAY_FACTOR_NOT_SET = 2,
+        CHANNEL_INVALID = 3,
+        MISS_PARAM = 4,
+        PARAM_INVALID = 5,
+        CERT_FILE_ERROR = 6,
+        CHANNEL_ERROR = 7,
+        TRADE_CLOSED = 8,
+        PAY_ERROR = 9,
+        RUN_TIME_ERROR = 14,
+        CODE_NOT_FOUND = 15,
+    }
+}

+ 22 - 0
FuelCloud/Fuel.Infrastructure/Payment/GenericProcessResponse.cs

@@ -0,0 +1,22 @@
+using Aop.Api;
+using Fuel.Payment.Core.Models;
+using Fuel.Payment.Core.Models.AllInPay;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Wechat.PayAPI;
+
+namespace Fuel.Infrastructure.Payment
+{
+    public class GenericProcessResponse
+    {
+        public AopResponse AopResponse { get; set; }
+        public WxPayData WeChatResponse { get; set; }
+        public Dictionary<string, string> AllInPayResponse { get; set; }
+        public TongLianResponseV2 AllInPayResponseV2 { get; set; }
+        public ElectronicOrderModel electronicOrderModel { get; set; }
+        public  List<ElectronicOrderProcessResultModel> ProcessResults { get; set; }
+    }
+}

+ 14 - 0
FuelCloud/Fuel.Infrastructure/Payment/IPaymentNotifier.cs

@@ -0,0 +1,14 @@
+using Fuel.Payment.Core.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Infrastructure.Payment
+{
+    public interface IPaymentNotifier
+    {
+        Task<ElectronicOrderModel> PaymentResult(GenericProcessResponse paymentResult, ElectronicOrderModel electronicOrderModel);
+    }
+}

+ 22 - 0
FuelCloud/Fuel.Infrastructure/Payment/IPaymentProcessor.cs

@@ -0,0 +1,22 @@
+using Fuel.Payment.Core.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Infrastructure.Payment
+{
+    public interface IPaymentProcessor<in TOrder, out TProcessResult>
+    {
+        TProcessResult Process(TOrder order);
+        TProcessResult Cancel(TOrder order);
+        TProcessResult Query(TOrder order);
+        TProcessResult Query(TOrder order, int count = 1, int interval = 2000);
+        TProcessResult Return(TOrder order);
+        TProcessResult UnifiedOrder(TOrder order);
+        //TProcessResult Initialize(TOrder order);
+        //Task<ElectronicOrderModel> PaymentResult(GenericProcessResponse paymentResult, TOrder order);
+
+    }
+}

+ 45 - 0
FuelCloud/Fuel.Infrastructure/Payment/Models/AllInPay/TongLianResponseV2.cs

@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Infrastructure.Payment.Models.AllInPay
+{
+    public class TongLianResponseV2
+    {
+        public string amount { get; set; }
+        public string bizCode { get; set; }
+        public string bizMsg { get; set; }
+        public string bizOrderNo { get; set; }
+        public string createTime { get; set; }
+        public string code { get; set; }
+        public string finishTime { get; set; }
+        public string msg { get; set; }
+        public string oldBizOrderNo { get; set; }
+        public string orderNo { get; set; }
+        public string payInfo { get; set; }
+        public string payStatus { get; set; }
+        public string payStatusMsg { get; set; }
+        public string payType { get; set; }
+        public string remark { get; set; }
+        public string shiftsMask { get; set; }
+        public string shiftsTime { get; set; }
+        public string sign { get; set; }
+        public string sysId { get; set; }
+        public string tradeDirection { get; set; }
+        public string consumeTypes { get; set; }
+
+        public override string ToString()
+        {
+            var sb = new StringBuilder();
+            PropertyInfo[] properties = typeof(TongLianResponseV2).GetProperties();
+            foreach (PropertyInfo property in properties)
+            {
+                sb.Append($"{property.Name}: {property.GetValue(this)}\n");
+            }
+            return sb.ToString();
+        }
+    }
+}

+ 111 - 0
FuelCloud/Fuel.Infrastructure/Payment/Models/ElectronicOrderModel.cs

@@ -0,0 +1,111 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Infrastructure.Payment.Models
+{
+    public class ElectronicOrderModel
+    {
+        [Key]
+        public int Id { get; set; }
+        [Required]
+        [MaxLength(192)]
+        public string SiteId { get; set; }
+
+        //public string CurrentBuId { get; set; }
+        //public string ConfigurationServiceUrl { get; set; }
+        public Object Config { get; set; }
+        public Object Certification { get; set; }
+        /// <summary>
+        /// Gets or sets the time that client side create this order
+        /// </summary>
+        public DateTime? CreationTime { get; set; }
+
+        /// <summary>
+        /// 根据不同场景选择不同的支付方式, accepted values: WX_SCAN、ALI_SCAN、ALL_IN_SCAN
+        /// </summary>
+        [Required]
+        public string Channel { get; set; }
+
+        [Required]
+        public bool IsRefund { get; set; }
+
+        /// <summary>
+        ///  trade status, expected values: USERPAYING, SUCCESS, SUCCESS_CANCELLING, PAYERROR, PAYERROR_CANCELLING, CLOSED
+        /// </summary>
+        public TradeStatus TradeStatus { get; set; }
+
+        /// <summary>
+        /// Gets or sets the netamount for this transaction, this amount deducted all the discount, and should be the final amount would be charged from 
+        /// customer account.
+        /// </summary>
+        [Required]
+        public decimal NetAmount { get; set; }
+
+        /// <summary>
+        /// Gets or sets the grossamount for this transaction, this is not the final amount to be charged from 
+        /// customer account, need substract the discount.
+        /// </summary>
+        public decimal GrossAmount { get; set; }
+
+        public decimal TotalAmount { get; set; }
+        /// <summary>
+        /// Gets or sets the 商户订单号, 确保唯一
+        /// </summary>
+        [Required]
+        [MaxLength(128)]
+        public string BillNumber { get; set; }
+
+        /// <summary>
+        /// Gets or sets the 订单标题   UTF8编码格式,32个字节内,最长支持16个汉字
+        /// </summary>
+        [MaxLength(32)]
+        public string Title { get; set; }
+
+        /// <summary>
+        /// Gets or sets 用户授权码, 当商户用扫码枪扫用户的条形码时得到的字符串
+        /// </summary>
+        [Required]
+        public string AuthCode { get; set; }
+
+        /// <summary>
+        /// Gets or sets the operator id for who submit this order from site.
+        /// </summary>
+        [MaxLength(128)]
+        public string OperatorId { get; set; }
+
+        /// <summary>
+        /// Gets or sets the terminal id for submit this order
+        /// </summary>
+        [MaxLength(128)]
+        public string TerminalId { get; set; }
+
+        /// <summary>
+        /// Gets or sets the time that server received this order for processing.
+        /// </summary>
+        public DateTime? ReceivedTime { get; set; }
+
+        /// <summary>
+        /// Gets or set the Optional data.
+        /// sample:  {"key1":"value1","key2":"value2",...}
+        /// 用户自定义的参数,将会在webhook通知中原样返回,该字段主要用于商户携带订单的自定义数据
+        /// </summary>
+        public Dictionary<string, object> Optional { get; set; } = new Dictionary<string, object>();
+
+        [Required(ErrorMessage = "Need provide at least one FuelOrderDetail")]
+        public List<FuelOrderDetailModel> FuelOrderDetails { get; set; }
+
+        /// <summary>
+        /// Gets or sets the process result which from the communication result with the 3rd party payment server
+        /// </summary>
+        public List<ElectronicOrderProcessResultModel> ProcessResults { get; set; }
+
+        public string ToSimpleLogString()
+        {
+            return "SiteId: " + this.SiteId + ", BillNumber: " + this.BillNumber;
+        }
+    }
+}

+ 27 - 0
FuelCloud/Fuel.Infrastructure/Payment/Models/ElectronicOrderProcessResultModel.cs

@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Infrastructure.Payment.Models
+{
+    public class ElectronicOrderProcessResultModel
+    {
+        public int Id { get; set; }
+
+        [MaxLength(128)]
+        public string BillNumber { get; set; }
+
+        [Required]
+        public string ResultCode { get; set; }
+        public string ResultMessage { get; set; }
+        public string ErrorDetail { get; set; }
+
+        /// <summary>
+        /// Gets or sets the raw result (a string) from 3rd party payment server.
+        /// </summary>
+        public string RawResult { get; set; }
+    }
+}

+ 31 - 0
FuelCloud/Fuel.Infrastructure/Payment/Models/FuelOrderDetailModel.cs

@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Infrastructure.Payment.Models
+{
+    public class FuelOrderDetailModel
+    {
+        public int Id { get; set; }
+        public int PumpNumber { get; set; }
+        public int NozzleNumber { get; set; }
+
+        /// <summary>
+        /// Gets or sets the fule product name this transaction consumed, like #93, #95, #DIESEL and etc.
+        /// </summary>
+        public string FuelProductName { get; set; }
+
+        public string FuelProductId { get; set; }
+
+        public decimal Qualtity { get; set; }
+
+        public decimal Price { get; set; }
+
+        public decimal Amount { get; set; }
+
+        public string Category { get; set; }
+    }
+
+}

+ 61 - 0
FuelCloud/Fuel.Infrastructure/Payment/Models/ServiceResponse.cs

@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Infrastructure.Payment.Models
+{
+    public class ServiceResponse
+    {
+        public HttpStatusCode StatusCode { get; set; }
+        public string Message { get; set; }
+        public object Data { get; set; }
+        public object Result { get; set; }
+        private bool Success { get; set; }
+        public bool IsSuccessful()
+        {
+            return StatusCode == HttpStatusCode.OK;
+        }
+        public ServiceResponse() { }
+        public ServiceResponse(HttpStatusCode statusCode, object data, string errorMsg = "")
+        {
+            StatusCode = statusCode;
+            Data = data;
+            Message = errorMsg;
+        }
+        public static ServiceResponse Ok(object data = null)
+        {
+            return new ServiceResponse(HttpStatusCode.OK, data);
+        }
+        public static ServiceResponse NotFound(string errorMsg = "")
+        {
+            return new ServiceResponse(HttpStatusCode.NotFound, null, errorMsg);
+        }
+        public static ServiceResponse Unauthorized(string errorMsg = "")
+        {
+            return new ServiceResponse(HttpStatusCode.Unauthorized, null, errorMsg);
+        }
+        public static ServiceResponse Forbidden(string errorMsg = "")
+        {
+            return new ServiceResponse(HttpStatusCode.Forbidden, null, errorMsg);
+        }
+        public static ServiceResponse BadRequest(string errorMsg = "")
+        {
+            return new ServiceResponse(HttpStatusCode.BadRequest, null, errorMsg);
+        }
+        public static ServiceResponse Error(string errorMsg = "")
+        {
+            return new ServiceResponse(HttpStatusCode.InternalServerError, null, errorMsg);
+        }
+        public static ServiceResponse Error(HttpStatusCode code, string errorMsg = "")
+        {
+            return new ServiceResponse(code, null, errorMsg);
+        }
+        public static ServiceResponse ValidateFailed(string errorMsg = "")
+        {
+            return new ServiceResponse(HttpStatusCode.NotAcceptable, null, errorMsg);
+        }
+    }
+}

+ 16 - 0
FuelCloud/Fuel.Infrastructure/Payment/Models/TradeStatus.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Infrastructure.Payment.Models
+{
+    public enum TradeStatus
+    {
+        SUCCESS,
+        PAYERROR,
+        CANCELLING,
+        CLOSED,
+    }
+}

+ 41 - 0
FuelCloud/Fuel.Infrastructure/Payment/Models/UnionPay/UnionPayConfig.cs

@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Infrastructure.Payment.Models.UnionPay
+{
+    public class UnionPayConfig
+    {
+        public static string DEFAULT_CHARSET = "GBK";
+        public string scanUrl { get; set; }
+        public string clientId { get; set; }
+        public string merchantCode { get; set; }
+        public string cloudIp { get; set; }
+        public string charset { get; set; }
+        public string miniUrl { get; set; }
+        public string appId { get; set; }
+        public string mid { get; set; }
+        public string terminalCode { get; set; }
+    }
+
+    public class UnionPayConfigInfo
+    {
+        public UnionPayConfig Config { get; set; }
+        public string HashValue { get; set; }
+    }
+
+    public class UnionPayCertificaitonInfo
+    {
+        public string unionpay_public_key_HashValue { get; set; }
+        public string merchant_private_key_HashValue { get; set; }
+        public string merchant_public_key_HashValue { get; set; }
+    }
+
+    public class UnionPayConfigAndCertification
+    {
+        public UnionPayConfigInfo ConfigInfo { get; set; }
+        public UnionPayCertificaitonInfo CertificaitonInfo { get; set; }
+    }
+}

+ 55 - 0
FuelCloud/Fuel.Infrastructure/Payment/SequenceNumber.cs

@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Infrastructure.Payment
+{
+    public class SequenceNumber
+    {
+        private const int INIT_VALUE = 1;
+
+        private static readonly object obj = new object();
+        private static int counter = INIT_VALUE;
+        public static string Next()
+        {
+            lock (obj)
+            {
+                var now = DateTime.Now.ToString("yyyyMMddHHmmssfff");
+                var cnt = counter.ToString().PadLeft(11, '0');
+
+                if (counter >= int.MaxValue)
+                    counter = INIT_VALUE;
+                else
+                    counter++;
+
+                return now + cnt; // length of 28
+            }
+        }
+    }
+
+    public class SequenceNumber20
+    {
+        private const int INIT_VALUE = 1;
+        private const int MAX_VALUE = 999;
+
+        private static readonly object obj = new object();
+        private static int counter = INIT_VALUE;
+        public static string Next()
+        {
+            lock (obj)
+            {
+                var now = DateTime.Now.ToString("yyyyMMddHHmmssfff"); // length of 17
+                var cnt = counter.ToString().PadLeft(3, '0');
+
+                if (counter > MAX_VALUE)
+                    counter = INIT_VALUE;
+                else
+                    counter++;
+
+                return now + cnt; // length of 20
+            }
+        }
+    }
+}

+ 12 - 0
FuelCloud/Fuel.Infrastructure/Payment/Services/IOrderServer.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Infrastructure.Payment.Services
+{
+    public interface IOrderServer
+    {
+    }
+}

+ 12 - 0
FuelCloud/Fuel.Infrastructure/Payment/Services/IPaymentServer.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Infrastructure.Payment.Services
+{
+    public interface IPaymentServer
+    {
+    }
+}

+ 2 - 16
FuelCloud/FuelCloud.sln

@@ -7,14 +7,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PaymentServer", "PaymentSer
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fuel.PaymentServer", "src\Fuel.Payment.Server\Fuel.PaymentServer.csproj", "{C6136845-5F8D-4021-9C6B-028CB386647A}"
 EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fuel.Payment.Core", "src\Fuel.Payment.Core\Fuel.Payment.Core.csproj", "{82ADD4DA-C4A6-49EA-8297-D2477CA6EAF3}"
-EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fuel.Payment.Service", "src\Fuel.Payment.Service\Fuel.Payment.Service.csproj", "{92947E0E-4C48-4D94-A243-F097081B3694}"
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fuel.Payment.Repositories", "Fuel.Payment.Repositories\Fuel.Payment.Repositories.csproj", "{8D22ECD9-B1F9-46AD-84B5-CB737B318DDE}"
 EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fuel.Payment.ExtServer", "src\Fuel.Payment.ExtServer\Fuel.Payment.ExtServer.csproj", "{ADB9278E-D932-422B-8585-DFA0F0333D3B}"
-EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ElectronicPayment", "ElectronicPayment", "{FF8B0E2F-823B-4ACF-ADAC-282CD8F2B3CF}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AopSdk", "ElectronicPayment\alipay-sdk-NET20161213174056\AopSdk.csproj", "{E02188DB-6DFB-4341-8E85-F78C33E90617}"
@@ -27,9 +23,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Models", "ElectronicPayment
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fuel.Core", "src\FuelServer.Core\Fuel.Core.csproj", "{AEDE8AC1-17AB-47A3-8CBA-36D32484B6ED}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fuel.Infrastructure", "Fuel.Infrastructure\Fuel.Infrastructure.csproj", "{FB53499B-CA9D-4E75-9EDC-2A04DCD4C5D1}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fuel.Infrastructure", "Fuel.Infrastructure\Fuel.Infrastructure.csproj", "{FB53499B-CA9D-4E75-9EDC-2A04DCD4C5D1}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fuel.Application", "Fuel.Application\Fuel.Application.csproj", "{6DBC4319-6D95-482B-9DBD-2F48BA72B0D9}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fuel.Application", "Fuel.Application\Fuel.Application.csproj", "{6DBC4319-6D95-482B-9DBD-2F48BA72B0D9}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -41,10 +37,6 @@ Global
 		{C6136845-5F8D-4021-9C6B-028CB386647A}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{C6136845-5F8D-4021-9C6B-028CB386647A}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{C6136845-5F8D-4021-9C6B-028CB386647A}.Release|Any CPU.Build.0 = Release|Any CPU
-		{82ADD4DA-C4A6-49EA-8297-D2477CA6EAF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{82ADD4DA-C4A6-49EA-8297-D2477CA6EAF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{82ADD4DA-C4A6-49EA-8297-D2477CA6EAF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{82ADD4DA-C4A6-49EA-8297-D2477CA6EAF3}.Release|Any CPU.Build.0 = Release|Any CPU
 		{92947E0E-4C48-4D94-A243-F097081B3694}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{92947E0E-4C48-4D94-A243-F097081B3694}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{92947E0E-4C48-4D94-A243-F097081B3694}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -53,10 +45,6 @@ Global
 		{8D22ECD9-B1F9-46AD-84B5-CB737B318DDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{8D22ECD9-B1F9-46AD-84B5-CB737B318DDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{8D22ECD9-B1F9-46AD-84B5-CB737B318DDE}.Release|Any CPU.Build.0 = Release|Any CPU
-		{ADB9278E-D932-422B-8585-DFA0F0333D3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{ADB9278E-D932-422B-8585-DFA0F0333D3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{ADB9278E-D932-422B-8585-DFA0F0333D3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{ADB9278E-D932-422B-8585-DFA0F0333D3B}.Release|Any CPU.Build.0 = Release|Any CPU
 		{E02188DB-6DFB-4341-8E85-F78C33E90617}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{E02188DB-6DFB-4341-8E85-F78C33E90617}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{E02188DB-6DFB-4341-8E85-F78C33E90617}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -91,10 +79,8 @@ Global
 	EndGlobalSection
 	GlobalSection(NestedProjects) = preSolution
 		{C6136845-5F8D-4021-9C6B-028CB386647A} = {A70E5B56-8E5C-4EB2-92F0-66FA7E67A2D1}
-		{82ADD4DA-C4A6-49EA-8297-D2477CA6EAF3} = {A70E5B56-8E5C-4EB2-92F0-66FA7E67A2D1}
 		{92947E0E-4C48-4D94-A243-F097081B3694} = {A70E5B56-8E5C-4EB2-92F0-66FA7E67A2D1}
 		{8D22ECD9-B1F9-46AD-84B5-CB737B318DDE} = {A70E5B56-8E5C-4EB2-92F0-66FA7E67A2D1}
-		{ADB9278E-D932-422B-8585-DFA0F0333D3B} = {A70E5B56-8E5C-4EB2-92F0-66FA7E67A2D1}
 		{FF8B0E2F-823B-4ACF-ADAC-282CD8F2B3CF} = {A70E5B56-8E5C-4EB2-92F0-66FA7E67A2D1}
 		{E02188DB-6DFB-4341-8E85-F78C33E90617} = {FF8B0E2F-823B-4ACF-ADAC-282CD8F2B3CF}
 		{EC6DA18D-0532-4E73-BA69-A575A724C8BB} = {FF8B0E2F-823B-4ACF-ADAC-282CD8F2B3CF}

+ 5 - 4
FuelCloud/src/Fuel.Payment.Server/Controllers/AuthController.cs

@@ -1,5 +1,6 @@
 using Fuel.Application.Service;
 using Fuel.Core.User;
+using FuelServer.Core;
 using FuelServer.Core.Entity;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
@@ -40,8 +41,8 @@ namespace Fuel.PaymentServer.Controllers
 
         private string GenerateJwt(users user)
         {
-            var jwtSettings = _configuration.GetSection("Jwt");
-            var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSettings["Key"]));
+            var jwtSettings = ConstKey.JwtKey;
+            var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSettings));
             var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
 
             var claims = new[]
@@ -52,8 +53,8 @@ namespace Fuel.PaymentServer.Controllers
             };
 
             var token = new JwtSecurityToken(
-                issuer: jwtSettings["Issuer"],
-                audience: jwtSettings["Audience"],
+                issuer: ConstKey.JwtIssuer,
+                audience: ConstKey.JwtAudience,
                 claims: claims,
                 expires: DateTime.Now.AddMinutes(15),
                 signingCredentials: credentials

+ 118 - 3
FuelCloud/src/Fuel.Payment.Server/Controllers/NozzleController.cs

@@ -1,6 +1,7 @@
 using Fuel.Application.Authorization;
 using Fuel.Application.Service;
 using Fuel.Core.Nozzle.Dto;
+using Fuel.Core.Transactions.Dto;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
@@ -9,7 +10,7 @@ namespace Fuel.PaymentServer.Controllers
 {
     [Route("api/[controller]")]
     [ApiController]
-    [Authorize]
+   // [Authorize]
     public class NozzleController : ControllerBase
     {
         private readonly INozzleService InozzleService;
@@ -17,14 +18,50 @@ namespace Fuel.PaymentServer.Controllers
         {
             InozzleService = nozzleService;
         }
+        /// <summary>
+        /// 上传油枪信息
+        /// </summary>
+        /// <param name="uploadNozzle"></param>
+        /// <returns></returns>
         [Permission("Nozzle:uploadNozzle:POST")]
         [Route("uploadNozzle")]
         [HttpPost]
         public async Task<IActionResult> uploadNozzle(UploadNozzle uploadNozzle)
         {
-            await InozzleService.uploadNozzle(uploadNozzle);
-            return Ok(0);
+            var serviceResult = await InozzleService.uploadNozzle(uploadNozzle);
+            return Ok(serviceResult);
         }
+        /// <summary>
+        /// 更新油枪信息
+        /// </summary>
+        /// <param name="uploadNozzle"></param>
+        /// <returns></returns>
+        [Permission("Nozzle:UpdateNozzle:PUT")]
+        [Route("UpdateNozzle")]
+        [HttpPut]
+        public async Task<IActionResult> UpdateNozzle(UploadNozzle uploadNozzle)
+        {
+            var serviceResult = await InozzleService.UpdateNozzle(uploadNozzle);
+            return Ok(serviceResult);
+        }
+        /// <summary>
+        /// 删除油枪信息
+        /// </summary>
+        /// <param name="uploadNozzle"></param>
+        /// <returns></returns>
+        [Permission("Nozzle:DeleteNozzle:Delete")]
+        [Route("DeleteNozzle")]
+        [HttpDelete]
+        public async Task<IActionResult> DeleteNozzle(UploadNozzle uploadNozzle)
+        {
+            var serviceResult = await InozzleService.DeleteNozzle(uploadNozzle);
+            return Ok(serviceResult);
+        }
+        /// <summary>
+        /// 获取油枪信息
+        /// </summary>
+        /// <param name="Nozzleid"></param>
+        /// <returns></returns>
         [Route("GetNozzleInfo")]
         [HttpPost]
         public async Task<List<NozzleInfo>> GetNozzleInfo(int Nozzleid)
@@ -32,5 +69,83 @@ namespace Fuel.PaymentServer.Controllers
             var data = await InozzleService.GetNozzleInfo(Nozzleid);
             return data;
         }
+        /// <summary>
+        /// 上传油品
+        /// </summary>
+        /// <param name="uploadNozzle"></param>
+        /// <returns></returns>
+        [Permission("Nozzle:uploadProduct:POST")]
+        [Route("uploadProduct")]
+        [HttpPost]
+        public async Task<IActionResult> uploadProduct(UploadProduct uploadProduct)
+        {
+            var serviceResult = await InozzleService.UploadProduct(uploadProduct);
+            return Ok(serviceResult);
+        }
+        /// <summary>
+        /// 更新油品信息
+        /// </summary>
+        /// <param name="uploadNozzle"></param>
+        /// <returns></returns>
+        [Permission("Nozzle:UpdateProduct:Put")]
+        [Route("UpdateProduct")]
+        [HttpPut]
+        public async Task<IActionResult> UpdateProduct(UploadProduct uploadProduct)
+        {
+            var serviceResult = await InozzleService.UpdateProduct(uploadProduct);
+            return Ok(serviceResult);
+        }
+        /// <summary>
+        /// 删除油品信息
+        /// </summary>
+        /// <param name="uploadNozzle"></param>
+        /// <returns></returns>
+        [Permission("Nozzle:DeleteProduct:Delete")]
+        [Route("DeleteProduct")]
+        [HttpDelete]
+        public async Task<IActionResult> DeleteProduct(UploadProduct uploadProduct)
+        {
+            var serviceResult = await InozzleService.DeleteProduct(uploadProduct);
+            return Ok(serviceResult);
+        }
+        /// <summary>
+        /// 上传油罐信息
+        /// </summary>
+        /// <param name="uploadNozzle"></param>
+        /// <returns></returns>
+        [Permission("Nozzle:uploadTanks:POST")]
+        [Route("uploadTanks")]
+        [HttpPost]
+        public async Task<IActionResult> uploadTanks(UploadTanks uploadTanks)
+        {
+            var serviceResult = await InozzleService.UploadTanks(uploadTanks);
+            return Ok(serviceResult);
+        }
+        /// <summary>
+        /// 更新油罐信息
+        /// </summary>
+        /// <param name="uploadNozzle"></param>
+        /// <returns></returns>
+        [Permission("Nozzle:UpdateTanks:Put")]
+        [Route("UpdateTanks")]
+        [HttpPut]
+        public async Task<IActionResult> UpdateTanks(UploadTanks uploadTanks)
+        {
+            var serviceResult = await InozzleService.UpdateTanks(uploadTanks);
+            return Ok(serviceResult);
+        }
+        /// <summary>
+        /// 删除油灌信息
+        /// </summary>
+        /// <param name="uploadNozzle"></param>
+        /// <returns></returns>
+        [Permission("Nozzle:DeleteTanks:Delete")]
+        [Route("DeleteTanks")]
+        [HttpDelete]
+        public async Task<IActionResult> DeleteTanks(UploadTanks uploadTanks)
+        {
+            var serviceResult = await InozzleService.DeleteTanks(uploadTanks);
+            return Ok(serviceResult);
+        }
     }
 }

+ 1 - 0
FuelCloud/src/Fuel.Payment.Server/Controllers/TransactionsController.cs

@@ -109,5 +109,6 @@ namespace Fuel.PaymentServer.Controllers
             var serviceResult = await _transactionsService.Redeem(trxId, OriginalQty);
             return Ok(serviceResult);
         }
+
     }
 }

+ 1 - 1
FuelCloud/src/Fuel.Payment.Server/Fuel.PaymentServer.csproj

@@ -7,10 +7,10 @@
   </PropertyGroup>
 
   <ItemGroup>
+    <PackageReference Include="DFS.Infrastructure" Version="8.0.0" />
     <PackageReference Include="DFS.Infrastructure.Redis" Version="8.0.0" />
     <PackageReference Include="JWT" Version="10.1.1" />
     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.6" />
-    <PackageReference Include="Microsoft.AspNetCore.Authorization" Version="9.0.0" />
     <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.5" />
     <PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
   </ItemGroup>

+ 68 - 0
FuelCloud/src/Fuel.Payment.Server/MicServer/Middlewares/JwtValidator.cs

@@ -0,0 +1,68 @@
+using FuelServer.Core;
+using Microsoft.IdentityModel.Tokens;
+using System;
+using System.Collections.Generic;
+using System.IdentityModel.Tokens.Jwt;
+using System.Linq;
+using System.Security.Claims;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DFS.Core.Mvc.Middlewares
+{
+    public static class JwtValidator
+    {
+        private static string _secretKey = ConstKey.JwtKey;
+        private static string _issuer = ConstKey.JwtIssuer;
+        private static string _audience = ConstKey.JwtAudience;
+
+
+        public static bool ValidateToken(string token)
+        {
+            var tokenHandler = new JwtSecurityTokenHandler();
+
+            try
+            {
+                // 将密钥转换为字节数组
+                var key = Encoding.ASCII.GetBytes(_secretKey);
+
+                // 设置 Token 验证参数
+                var validationParameters = new TokenValidationParameters
+                {
+                    ValidateIssuerSigningKey = true, // 验证签名
+                    IssuerSigningKey = new SymmetricSecurityKey(key),
+                    ValidateIssuer = true, // 验证签发者
+                    ValidIssuer = _issuer,
+                    ValidateAudience = true, // 验证受众
+                    ValidAudience = _audience,
+                    ValidateLifetime = true, // 验证过期时间
+                    ClockSkew = TimeSpan.Zero // 不允许时间偏差
+                };
+
+                // 验证 Token
+                ClaimsPrincipal principal = tokenHandler.ValidateToken(token, validationParameters, out SecurityToken validatedToken);
+
+                // 如果验证成功,返回 true
+                return true;
+            }
+            catch (SecurityTokenExpiredException)
+            {
+                // Token 已过期
+                Console.WriteLine("Token has expired.");
+                return false;
+            }
+            catch (SecurityTokenValidationException)
+            {
+                // Token 验证失败(签名无效、签发者或受众不匹配等)
+                Console.WriteLine("Token validation failed.");
+                return false;
+            }
+            catch (Exception ex)
+            {
+                // 其他异常
+                Console.WriteLine($"An error occurred: {ex.Message}");
+                return false;
+            }
+        }
+    }
+}

+ 100 - 0
FuelCloud/src/Fuel.Payment.Server/MicServer/Middlewares/SignatureValidationMiddleware.cs

@@ -0,0 +1,100 @@
+using Fuel.Core;
+using Microsoft.AspNetCore.Http;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DFS.Core.Mvc.Middlewares
+{
+    public class SignatureValidationMiddleware
+    {
+        private readonly RequestDelegate _next;
+        private readonly SignatureValidator _validator;
+
+        public SignatureValidationMiddleware(RequestDelegate next, SignatureValidator validator)
+        {
+            _next = next;
+            _validator = validator;
+        }
+
+        /// <summary>
+        /// 处理每个 HTTP 请求的异步方法。
+        /// </summary>
+        /// <param name="context">HTTP 上下文。</param>
+        /// <returns>一个任务表示的操作。</returns>
+        public async Task InvokeAsync(HttpContext context, Authorization _authorization)
+        {
+            // 跳过登录接口
+            var path = context.Request.Path.Value;
+            if (path.StartsWith("/api/Auth/login", StringComparison.OrdinalIgnoreCase))
+            {
+                await _next(context);
+                return;
+            }
+            var headers = context.Request.Headers;
+            var authorization = headers["authorization"];
+            if (string.IsNullOrEmpty(authorization))
+            {
+            }
+            var Bread = authorization.ToString().Split(' ');
+            if (Bread.Count() == 2)
+            {
+                // 验证token
+                {
+                    var token = Bread[1];
+                    bool isValid = JwtValidator.ValidateToken(token);
+                    if (!isValid)
+                    {
+                        context.Response.StatusCode = StatusCodes.Status401Unauthorized;
+                        await context.Response.WriteAsync("token验证失败");
+                        return;
+                    }
+                }
+
+                //子站接入验证签名
+                //{
+                //    if (Bread[0] == "Bread")
+                //    {
+                //        if (!_validator.ValidateSignature(context.Request))
+                //        {
+                //            context.Response.StatusCode = StatusCodes.Status401Unauthorized;
+                //            await context.Response.WriteAsync("无效的签名");
+                //            return;
+                //        }
+                //    }
+                //}
+               
+            }
+            else
+            {
+                var SecretId = headers["secret_id"];
+                if (string.IsNullOrEmpty(authorization))
+                {
+                }
+                var apply = _authorization.GetApply(SecretId);
+                if (apply == null)
+                {
+                    context.Response.StatusCode = StatusCodes.Status401Unauthorized;
+                    await context.Response.WriteAsync("无效的签名,未找到SecretId");
+                    return;
+                }
+                var ValidateSignature = await _validator.ValidateSignature(context.Request, apply.AppSecret);
+                if (ValidateSignature)
+                {
+                    await _next(context);
+                    return;
+                }
+                context.Response.StatusCode = StatusCodes.Status401Unauthorized;
+                await context.Response.WriteAsync("无效的签名");
+                return;
+            }
+          
+
+            await _next(context);
+        }
+    }
+}
+

+ 91 - 0
FuelCloud/src/Fuel.Payment.Server/MicServer/Middlewares/SignatureValidator.cs

@@ -0,0 +1,91 @@
+using DFS.Infrastructure.Extension.SM;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Threading.Tasks;
+using System.Web;
+
+namespace DFS.Core.Mvc.Middlewares
+{
+    public class SignatureValidator
+    {
+        private readonly ILogger<SignatureValidator> _logger;
+
+        public SignatureValidator( ILogger<SignatureValidator> logger)
+        {
+            _logger = logger;
+        }
+
+        /// <summary>
+        /// 验证传入请求的签名是否有效。
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        public async Task<bool> ValidateSignature(HttpRequest request,string Secret)
+        {
+            try
+            {
+                var signMethod = request.Headers["sign_method"].ToString();
+                var secretId = request.Headers["secret_id"].ToString();
+                var nonce = request.Headers["nonce"].ToString();
+                var timestamp = request.Headers["timestamp"].ToString();
+                var signature = request.Headers["signature"].ToString();//签名串
+                string bodyContent = string.Empty;
+                if (request.Body != null)
+                {
+                    // 将 Body 流读取为字符串
+                    request.EnableBuffering(); // 允许多次读取 Body
+                    using (var reader = new StreamReader(request.Body, Encoding.UTF8, true, 1024, true))
+                    {
+                        bodyContent = await reader.ReadToEndAsync();
+                    }
+                    request.Body.Position = 0; // 重置流的位置以便后续读取
+                }
+                if (string.IsNullOrEmpty(signMethod) || string.IsNullOrEmpty(secretId) ||
+                    string.IsNullOrEmpty(nonce) || string.IsNullOrEmpty(timestamp) ||
+                    string.IsNullOrEmpty(signature))
+                {
+                    _logger.LogError("缺少签名信息");
+                    return false;
+                }
+
+                // 查询字符串
+                //var queryString = HttpUtility.ParseQueryString(request.QueryString.ToString());
+                //var queryParameters = queryString.AllKeys
+                //    .OrderBy(k => k)
+                //    .Select(k => $"{k}={queryString[k]}")
+                //    .Aggregate((current, next) => current + "&" + next);
+
+                // 待签字符串
+                var stringToSign = $"sign_method={signMethod}&secret_id={secretId}&nonce={nonce}&timestamp={timestamp}&{bodyContent}";
+                stringToSign = stringToSign.SM4Encrypt_ECB(Secret);
+                // 根据 RFC3986 对字符串进行 URL 编码
+                var encodedString = Uri.EscapeDataString(stringToSign);
+
+                string base64 = StringToBase64(encodedString);
+                return base64.Equals(signature, StringComparison.Ordinal);
+            }
+            catch (Exception ex)
+            {
+                _logger.LogError(ex, "签名验证过程中发生错误。");
+                return false;
+            }
+        }
+
+        public static string StringToBase64(string input)
+        {
+            if (string.IsNullOrEmpty(input))
+                return string.Empty;
+
+            // 将字符串转换为字节数组
+            byte[] bytes = Encoding.UTF8.GetBytes(input);
+
+            // 将字节数组转换为 Base64 字符串
+            return Convert.ToBase64String(bytes);
+        }
+    }
+}

+ 31 - 6
FuelCloud/src/Fuel.Payment.Server/Program.cs

@@ -20,6 +20,10 @@ using Fuel.Core;
 using Microsoft.AspNetCore.Authorization;
 using Fuel.Application.Authorization;
 using Microsoft.Extensions.DependencyInjection;
+using Microsoft.AspNetCore.Authentication.JwtBearer;
+using Microsoft.IdentityModel.Tokens;
+using System.Text;
+using DFS.Core.Mvc.Middlewares;
 
 var builder = WebApplication.CreateBuilder(args);
 builder.Services.AddScoped<IPayService, PayService>();
@@ -41,15 +45,32 @@ builder.Services.AddFreeSql(builder.Configuration);
 
 //³õʼ»¯DFS Server
 builder.Services.AddMicService(builder.Environment);
+//builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
+//    .AddJwtBearer(options =>
+//    {
+//        options.TokenValidationParameters = new TokenValidationParameters
+//        {
+//            ValidateIssuer = true,
+//            ValidateAudience = true,
+//            ValidateLifetime = true,
+//            ValidateIssuerSigningKey = true,
+//            ValidIssuer = ConstKey.JwtIssuer,
+//            ValidAudience = ConstKey.JwtAudience,
+//            IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(ConstKey.JwtKey))
+//        };
+//    });
 
 builder.Services.AddHttpContextAccessor();
 builder.Services.AddScoped<INozzleRepository, NozzleRepository>();
 builder.Services.AddScoped<INozzleService, NozzleService>();
 builder.Services.AddScoped<ITransactionsService, TransactionsService>();
-
+builder.Services.AddScoped<IUserService, UserService>();
+builder.Services.AddScoped<IApplyService, ApplyService>();
+builder.Services.AddScoped<Authorization>();
 // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
 builder.Services.AddEndpointsApiExplorer();
 builder.Services.AddSwaggerGen();
+builder.Services.AddTransient<IAuthorizationHandler, PermissionHandler>();
 
 Fuel.Infrastructure.Extension.RedisOptions redisOptions = builder.Configuration.GetSection("Redis").Get<Fuel.Infrastructure.Extension.RedisOptions>();
 builder.Services.UseRedisClient(redisOptions);
@@ -66,7 +87,8 @@ void AddPermissionPolicies(AuthorizationOptions options)
     using (var scope = builder.Services.BuildServiceProvider().CreateScope())
     {
         var userService = scope.ServiceProvider.GetRequiredService<IUserService>();
-        var authorization = new Authorization(userService);
+        var applyService = scope.ServiceProvider.GetRequiredService<IApplyService>();
+        var authorization = new Authorization(userService, applyService);
         var permissions = authorization.GetPermissions();
 
         foreach (var permission in permissions)
@@ -90,11 +112,14 @@ var loggerFactory = LoggerFactory.Create(builder =>
 {
     builder.AddConsole();
 });
-var accessKeySecret = "sfsdfasfsdafasdfdsa";//ÃÜÔ¿
-var logger = loggerFactory.CreateLogger<SignatureValidator>();
-var signatureValidator = new SignatureValidator(accessKeySecret, logger);
+var logger = loggerFactory.CreateLogger<DFS.Core.Mvc.Middlewares.SignatureValidator>();
+var signatureValidator = new DFS.Core.Mvc.Middlewares.SignatureValidator(logger);
 app.UseMiddleware<SignatureValidationMiddleware>(signatureValidator);//Ç©ÃûÑéÖ¤
 
+// ÅäÖÃHttpRequestReader¾²Ì¬Àà
+var httpContextAccessor = app.Services.GetRequiredService<IHttpContextAccessor>();
+HttpRequestReader.Configure(httpContextAccessor);
+
 // Configure the HTTP request pipeline.
 if (app.Environment.IsDevelopment())
 {
@@ -111,5 +136,5 @@ app.UseAuthentication();
 app.UseAuthorization();
 
 app.MapControllers();
-
+app.Urls.Add("http://192.168.0.202:5006");
 app.Run();

+ 3 - 1
FuelCloud/src/FuelServer.Core/Entity/AdApply.cs

@@ -99,7 +99,9 @@ namespace FuelServer.Core.Entity
 		/// </summary>
 		[JsonProperty]
 		public long Version { get; set; }
+        [JsonProperty]
+        public Guid? Buid { get; set; }
 
-	}
+    }
 
 }

+ 78 - 0
FuelCloud/src/FuelServer.Core/Entity/AdRoleApply.cs

@@ -0,0 +1,78 @@
+using FreeSql.DatabaseModel;using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+using FreeSql.DataAnnotations;
+
+namespace FuelServer.Core.Entity
+{
+
+	[JsonObject(MemberSerialization.OptIn), Table(Name = "ad_role_apply", DisableSyncStructure = true)]
+	public partial class AdRoleApply {
+
+		/// <summary>
+		/// 主键Id
+		/// </summary>
+		[JsonProperty, Column(IsPrimary = true)]
+		public long Id { get; set; }
+
+		/// <summary>
+		/// 创建时间
+		/// </summary>
+		[JsonProperty, Column(DbType = "datetime")]
+		public DateTime? CreatedTime { get; set; }
+
+		/// <summary>
+		/// 创建者Id
+		/// </summary>
+		[JsonProperty]
+		public long? CreatedUserId { get; set; }
+
+		/// <summary>
+		/// 创建者
+		/// </summary>
+		[JsonProperty, Column(StringLength = 50)]
+		public string CreatedUserName { get; set; }
+
+		/// <summary>
+		/// 是否删除
+		/// </summary>
+		[JsonProperty]
+		public bool IsDeleted { get; set; }
+
+		/// <summary>
+		/// 修改时间
+		/// </summary>
+		[JsonProperty, Column(DbType = "datetime")]
+		public DateTime? ModifiedTime { get; set; }
+
+		/// <summary>
+		/// 修改者Id
+		/// </summary>
+		[JsonProperty]
+		public long? ModifiedUserId { get; set; }
+
+		/// <summary>
+		/// 修改者
+		/// </summary>
+		[JsonProperty, Column(StringLength = 50)]
+		public string ModifiedUserName { get; set; }
+
+		[JsonProperty]
+		public long OauthApplyID { get; set; }
+
+		[JsonProperty]
+		public long OauthRoleID { get; set; }
+
+		/// <summary>
+		/// 版本
+		/// </summary>
+		[JsonProperty]
+		public long Version { get; set; }
+
+	}
+
+}

+ 3 - 3
FuelCloud/src/FuelServer.Core/Entity/configuration.cs

@@ -17,7 +17,7 @@ namespace FuelServer.Core.Entity
 	public partial class configuration {
 
 		[JsonProperty, Column(IsPrimary = true, IsIdentity = true)]
-		public int Id { get; set; }
+		public long Id { get; set; }
 
 		/// <summary>
 		/// buid
@@ -29,7 +29,7 @@ namespace FuelServer.Core.Entity
 		/// 支付方式类型
 		/// </summary>
 		[JsonProperty]
-		public int? payType { get; set; }
+		public long payType { get; set; }
 
 		[JsonProperty, Column(StringLength = 100)]
 		public string CreateBy { get; set; }
@@ -59,7 +59,7 @@ namespace FuelServer.Core.Entity
 		/// 模板类型
 		/// </summary>
 		[JsonProperty]
-		public int? Type { get; set; }
+		public long Type { get; set; }
 
 		/// <summary>
 		/// 配置内容

+ 1 - 1
FuelCloud/src/FuelServer.Core/Entity/miniprogramusers.cs

@@ -20,7 +20,7 @@ namespace FuelServer.Core.Entity
 		/// 用户唯一标识符
 		/// </summary>
 		[JsonProperty, Column(IsPrimary = true, IsIdentity = true)]
-		public int Id { get; set; }
+		public long Id { get; set; }
 
 		[JsonProperty]
 		public Guid Buid { get; set; }

+ 13 - 7
FuelCloud/src/FuelServer.Core/Entity/nozzle.cs

@@ -17,7 +17,7 @@ namespace FuelServer.Core.Entity
 	public partial class nozzle {
 
 		[JsonProperty, Column(IsPrimary = true, IsIdentity = true)]
-		public int Id { get; set; }
+		public long Id { get; set; }
 
 		[JsonProperty]
 		public Guid? Buid { get; set; }
@@ -26,38 +26,44 @@ namespace FuelServer.Core.Entity
 		/// 油品id
 		/// </summary>
 		[JsonProperty]
-		public int? ProductID { get; set; }
+		public long ProductID { get; set; }
 
 		/// <summary>
 		/// 油罐ID
 		/// </summary>
 		[JsonProperty]
-		public int? TankId { get; set; }
+		public long TankId { get; set; }
 
 		/// <summary>
 		/// 外部枪号
 		/// </summary>
 		[JsonProperty, Column(StringLength = 50, IsNullable = false)]
-		public int? ExternalGunNumber { get; set; }
+		public long ExternalGunNumber { get; set; }
 
 		/// <summary>
 		/// 内部枪号
 		/// </summary>
 		[JsonProperty, Column(StringLength = 50, IsNullable = false)]
-		public int? InternalGunNumber { get; set; }
+		public long InternalGunNumber { get; set; }
 
 
 		/// <summary>
 		/// 加油点
 		/// </summary>
 		[JsonProperty, Column(StringLength = 100, IsNullable = false)]
-		public int? PumpId { get; set; }
+		public long PumpId { get; set; }
 
 		/// <summary>
 		/// 1:在线、2:离线、3:正在加油
 		/// </summary>
 		[JsonProperty]
-		public int? Status { get; set; }
+		public long Status { get; set; }
+
+        [JsonProperty]
+        /// <summary>
+        /// fcc的油枪ID
+        /// </summary>
+        public long NozzleId { get; set; }
 
 	}
 

+ 1 - 1
FuelCloud/src/FuelServer.Core/Entity/paytype.cs

@@ -17,7 +17,7 @@ namespace FuelServer.Core.Entity
 	public partial class paytype {
 
 		[JsonProperty, Column(IsPrimary = true, IsIdentity = true)]
-		public int Id { get; set; }
+		public long Id { get; set; }
 
 		/// <summary>
 		/// 支付方式名称

+ 9 - 2
FuelCloud/src/FuelServer.Core/Entity/product.cs

@@ -17,7 +17,7 @@ namespace FuelServer.Core.Entity
 	public partial class product {
 
 		[JsonProperty, Column(IsPrimary = true, IsIdentity = true)]
-		public int Id { get; set; }
+		public long Id { get; set; }
 
 		[JsonProperty]
 		public Guid Buid { get; set; }
@@ -40,6 +40,13 @@ namespace FuelServer.Core.Entity
 		[JsonProperty]
 		public decimal? ProductPrice { get; set; }
 
-	}
+        [JsonProperty]
+        /// <summary>
+        /// fcc油品ID
+        /// </summary>
+        public long ProductId { get; set; }
+
+
+    }
 
 }

+ 10 - 5
FuelCloud/src/FuelServer.Core/Entity/tanks.cs

@@ -20,7 +20,7 @@ namespace FuelServer.Core.Entity
 		/// 油罐唯一标识符
 		/// </summary>
 		[JsonProperty, Column(IsPrimary = true, IsIdentity = true)]
-		public int Id { get; set; }
+		public long Id { get; set; }
 
 		[JsonProperty]
 		public Guid? Buid { get; set; }
@@ -29,7 +29,7 @@ namespace FuelServer.Core.Entity
 		/// 油品ID
 		/// </summary>
 		[JsonProperty, Column(StringLength = 50, IsNullable = false)]
-		public int? ProductId { get; set; }
+		public long ProductId { get; set; }
 
 		/// <summary>
 		/// 油品名称
@@ -47,8 +47,13 @@ namespace FuelServer.Core.Entity
 		/// 油罐号
 		/// </summary>
 		[JsonProperty, Column(StringLength = 50, IsNullable = false)]
-		public int? TankNumber { get; set; }
-
-	}
+		public long TankNumber { get; set; }
+
+        /// <summary>
+        /// fcc油罐ID
+        /// </summary>
+        [JsonProperty]
+        public long TankID { get; set; }
+    }
 
 }

+ 5 - 5
FuelCloud/src/FuelServer.Core/Entity/transactions.cs

@@ -20,7 +20,7 @@ namespace FuelServer.Core.Entity
 		/// 订单唯一标识符
 		/// </summary>
 		[JsonProperty, Column(IsPrimary = true, IsIdentity = true)]
-		public int Id { get; set; }
+		public long Id { get; set; }
 
 		/// <summary>
 		/// 油站唯一标识符
@@ -32,19 +32,19 @@ namespace FuelServer.Core.Entity
 		/// 用户ID
 		/// </summary>
 		[JsonProperty]
-		public int MiniProgramID { get; set; }
+		public long MiniProgramID { get; set; }
 
 		/// <summary>
 		/// 枪号
 		/// </summary>
 		[JsonProperty]
-		public int NozzleId { get; set; }
+		public long NozzleId { get; set; }
 
 		/// <summary>
 		/// 油品ID
 		/// </summary>
 		[JsonProperty]
-		public int ProductId { get; set; }
+		public long ProductId { get; set; }
 
 		/// <summary>
 		/// 实际支付金额
@@ -98,7 +98,7 @@ namespace FuelServer.Core.Entity
 		/// 支付方式
 		/// </summary>
 		[JsonProperty]
-		public int PaymentMethod { get; set; }
+		public long PaymentMethod { get; set; }
 
 		/// <summary>
 		/// 油品名称

+ 1 - 1
FuelCloud/src/FuelServer.Core/Entity/users.cs

@@ -20,7 +20,7 @@ namespace FuelServer.Core.Entity
 		/// 用户唯一标识符
 		/// </summary>
 		[JsonProperty, Column(IsPrimary = true, IsIdentity = true)]
-		public int Id { get; set; }
+		public long Id { get; set; }
 
 		[JsonProperty]
 		public Guid? Buid { get; set; }

+ 0 - 1
FuelCloud/src/FuelServer.Core/Fuel.Core.csproj

@@ -9,7 +9,6 @@
   <ItemGroup>
     <PackageReference Include="DFS.Infrastructure.Redis" Version="8.0.0" />
     <PackageReference Include="FreeSql" Version="3.2.833" />
-    <PackageReference Include="Microsoft.AspNetCore.Authorization" Version="9.0.0" />
     <PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
     <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
   </ItemGroup>

+ 61 - 0
FuelCloud/src/FuelServer.Core/HttpRequestReader.cs

@@ -0,0 +1,61 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Fuel.Core
+{
+    public static class HttpRequestReader
+    {
+        private static IHttpContextAccessor? _httpContextAccessor;
+
+        // 使用依赖注入配置静态属性
+        public static void Configure(IHttpContextAccessor httpContextAccessor)
+        {
+            _httpContextAccessor = httpContextAccessor;
+        }
+        public static Guid GetCurrentBuId()
+        {
+            if (_httpContextAccessor == null || _httpContextAccessor.HttpContext == null)
+            {
+                return Guid.Empty;
+            }
+            var httpContext = _httpContextAccessor.HttpContext;
+            var headerValue = httpContext.Request.Headers["CurrentBuId"].ToString();
+
+            if (Guid.TryParse(headerValue, out Guid buId))
+            {
+                return buId;
+            }
+            return Guid.Empty;
+        }
+        /// <summary>
+        /// 获取请求头值
+        /// </summary>
+        /// <param name="headerName"></param>
+        /// <returns></returns>
+        public static string? GetHeaderValue(string headerName)
+        {
+            if (_httpContextAccessor == null || _httpContextAccessor.HttpContext == null)
+            {
+                throw new InvalidOperationException("HttpContext is not available.");
+            }
+
+            if (string.IsNullOrWhiteSpace(headerName))
+            {
+                throw new ArgumentException("Header name cannot be null or empty.", nameof(headerName));
+            }
+
+            var httpContext = _httpContextAccessor.HttpContext;
+            if (httpContext.Request.Headers.TryGetValue(headerName, out var headerValue))
+            {
+                return headerValue.ToString();
+            }
+
+            return null;
+        }
+    }
+}

+ 3 - 3
FuelCloud/src/FuelServer.Core/Nozzle/Dto/NozzleInfo.cs

@@ -8,9 +8,9 @@ namespace Fuel.Core.Nozzle.Dto
 {
     public class NozzleInfo
     {
-        public int? Nozzleid { get; set; }
-        public int? TankNumber { get; set; }
-        public int? Status { get; set; }
+        public long Nozzleid { get; set; }
+        public long TankNumber { get; set; }
+        public long Status { get; set; }
         public string ProductName { get; set; }
         public decimal? ProductPrice { get; set; }
     }

+ 45 - 9
FuelCloud/src/FuelServer.Core/Nozzle/Dto/UploadNozzle.cs

@@ -6,24 +6,64 @@ using System.Threading.Tasks;
 
 namespace Fuel.Core.Nozzle.Dto
 {
+    public class UploadProduct
+    {
+        /// <summary>
+        /// 油品名称
+        /// </summary>
+        public string ProductName { get; set; }
+        /// <summary>
+        /// 油品码
+        /// </summary>
+        public string ProductCode { get; set; }
+        /// <summary>
+        /// 油品单价
+        /// </summary>
+        public decimal? ProductPrice { get; set; }
+        /// <summary>
+        /// FCC油品id
+        /// </summary>
+        public long  ProductId { get; set; }
+    }
+    public class UploadTanks
+    {
+        /// <summary>
+        /// 油罐号
+        /// </summary>
+        public long TankNumber { get; set; }
+        /// <summary>
+        /// 油罐容量
+        /// </summary>
+        public decimal? TankCapacity { get; set; }
+        /// <summary>
+        /// 油品名称
+        /// </summary>
+        public string ProductName { get; set; }
+        /// <summary>
+        /// FCC油品id
+        /// </summary>
+        public long ProductId { get; set; }
+        public long TankID { get; set; }
+    }
     public class UploadNozzle
     {
         /// <summary>
         /// 加油点
         /// </summary>
-        public int? PumpID { get; set; }
+        public long PumpID { get; set; }
         /// <summary>
         /// 内部枪号
         /// </summary>
-        public int? InternalGunNumber { get; set; }
+        public long InternalGunNumber { get; set; }
         /// <summary>
         /// 外部枪号
         /// </summary>
-        public int? ExternalGunNumber { get; set; }
+        public long ExternalGunNumber { get; set; }
+        public long NozzleId { get; set; }
         /// <summary>
         /// 油罐号
         /// </summary>
-        public int? TankNumber { get; set; }
+        public long TankNumber { get; set; }
         /// <summary>
         /// 油罐容量
         /// </summary>
@@ -40,10 +80,6 @@ namespace Fuel.Core.Nozzle.Dto
         /// 油品单价
         /// </summary>
         public decimal? ProductPrice { get; set; }
-        /// <summary>
-        /// 1:上传      2:更新      3:上传
-        /// </summary>
-        public int type { get; set; }
-
     }
+
 }

+ 0 - 47
FuelCloud/src/FuelServer.Core/SignatureValidationMiddleware.cs

@@ -1,47 +0,0 @@
-using Microsoft.AspNetCore.Http;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Fuel.Core
-{
-    public class SignatureValidationMiddleware
-    {
-        private readonly RequestDelegate _next;
-        private readonly SignatureValidator _validator;
-
-        public SignatureValidationMiddleware(RequestDelegate next, SignatureValidator validator)
-        {
-            _next = next;
-            _validator = validator;
-        }
-
-        /// <summary>
-        /// 处理每个 HTTP 请求的异步方法。
-        /// </summary>
-        /// <param name="context">HTTP 上下文。</param>
-        /// <returns>一个任务表示的操作。</returns>
-        public async Task InvokeAsync(HttpContext context)
-        {
-            // 跳过登录接口
-            var path = context.Request.Path.Value;
-            if (path.StartsWith("/api/login", StringComparison.OrdinalIgnoreCase))
-            {
-                await _next(context);
-                return;
-            }
-
-            if (!_validator.ValidateSignature(context.Request))
-            {
-                context.Response.StatusCode = StatusCodes.Status401Unauthorized;
-                await context.Response.WriteAsync("无效的签名");
-                return;
-            }
-
-            await _next(context);
-        }
-    }
-}
-

+ 0 - 86
FuelCloud/src/FuelServer.Core/SignatureValidator.cs

@@ -1,86 +0,0 @@
-using Microsoft.AspNetCore.Http;
-using Microsoft.Extensions.Logging;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Security.Cryptography;
-using System.Text;
-using System.Threading.Tasks;
-using System.Web;
-
-namespace Fuel.Core
-{
-    public class SignatureValidator
-    {
-        private readonly string _accessKeySecret;
-        private readonly ILogger<SignatureValidator> _logger;
-
-        public SignatureValidator(string accessKeySecret, ILogger<SignatureValidator> logger)
-        {
-            _accessKeySecret = accessKeySecret;
-            _logger = logger;
-        }
-
-        /// <summary>
-        /// 验证传入请求的签名是否有效。
-        /// </summary>
-        /// <param name="request"></param>
-        /// <returns></returns>
-        public bool ValidateSignature(HttpRequest request)
-        {
-            try
-            {
-                var signMethod = request.Headers["sign_method"].ToString();
-                var secretId = request.Headers["secret_id"].ToString();
-                var nonce = request.Headers["nonce"].ToString();
-                var timestamp = request.Headers["timestamp"].ToString();
-                var signature = request.Headers["signature"].ToString();
-
-                if (string.IsNullOrEmpty(signMethod) || string.IsNullOrEmpty(secretId) ||
-                    string.IsNullOrEmpty(nonce) || string.IsNullOrEmpty(timestamp) ||
-                    string.IsNullOrEmpty(signature))
-                {
-                    _logger.LogError("缺少签名信息");
-                    return false;
-                }
-
-                // 查询字符串
-                var queryString = HttpUtility.ParseQueryString(request.QueryString.ToString());
-                var queryParameters = queryString.AllKeys
-                    .OrderBy(k => k)
-                    .Select(k => $"{k}={queryString[k]}")
-                    .Aggregate((current, next) => current + "&" + next);
-
-                // 待签字符串
-                var stringToSign = $"sign_method={signMethod}&secret_id={secretId}&nonce={nonce}&timestamp={timestamp}&{queryParameters}";
-
-                // 根据 RFC3986 对字符串进行 URL 编码
-                var encodedString = Uri.EscapeDataString(stringToSign);
-
-                // 计算 HMAC-SM3 哈希(此处用 HMACSHA256 作为占位符)
-                var calculatedSignature = HmacSm3(_accessKeySecret, encodedString);
-                var base64Signature = Convert.ToBase64String(calculatedSignature);
-                return base64Signature.Equals(signature, StringComparison.Ordinal);
-            }
-            catch (Exception ex)
-            {
-                _logger.LogError(ex, "签名验证过程中发生错误。");
-                return false;
-            }
-        }
-
-        /// <summary>
-        /// 使用 HMAC-SM3 算法计算哈希值(此处用 HMACSHA256 作为占位符)
-        /// </summary>
-        /// <param name="key"></param>
-        /// <param name="message"></param>
-        /// <returns></returns>
-        private byte[] HmacSm3(string key, string message)
-        {
-            using (var hmacsha = new HMACSHA256(Encoding.UTF8.GetBytes(key)))
-            {
-                return hmacsha.ComputeHash(Encoding.UTF8.GetBytes(message));
-            }
-        }
-    }
-}