From a1763d5980575e3051bd6c1abd90b97fdd2200ba Mon Sep 17 00:00:00 2001 From: lwh <2679599887@qq.com> Date: Tue, 6 Jun 2023 22:50:32 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E6=94=B9=E7=94=9F=E6=88=90?= =?UTF-8?q?=E9=83=A8=E5=88=86=E5=86=85=E5=AE=B9=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E6=94=B6=E8=B4=A7=E5=9C=B0=E5=9D=80=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=A2=E6=88=B7=E7=99=BB=E5=BD=95=E9=80=BB?= =?UTF-8?q?=E8=BE=911.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomerAddresses/CustomerAddressDto.cs | 68 +++++++++ .../Dto/Business/Customers/CustomerDto.cs | 53 ++++++- .../CustomerAddresses/CustomerAddress.cs | 107 ++++++++++++++ ARW.Model/System/LoginUser.cs | 1 + .../CustomerAddresses/CustomerAddressVo.cs | 95 +++++++++++++ .../CustomerAddressRepository.cs | 20 +++ .../CustomerAddressService.cs | 116 +++++++++++++++ .../Customers/CustomerService.cs | 50 +++---- .../ICustomerAddressService.cs | 45 ++++++ .../Api/Wechat/WeChatLoginController.cs | 84 ++++++----- .../Api/Wechat/WxPay/WxPayController.cs | 2 + .../CustomerAddressController.cs | 132 ++++++++++++++++++ ARW.WebApi/Program.cs | 4 +- ARW.WebApi/appsettings.json | 14 +- .../wwwroot/CodeGenTemplate/TplVueIndex.txt | 2 +- 15 files changed, 723 insertions(+), 70 deletions(-) create mode 100644 ARW.Model/Dto/Business/Custom/CustomerAddresses/CustomerAddressDto.cs create mode 100644 ARW.Model/Models/Business/Custom/CustomerAddresses/CustomerAddress.cs create mode 100644 ARW.Model/Vo/Business/Custom/CustomerAddresses/CustomerAddressVo.cs create mode 100644 ARW.Repository/Business/Custom/CustomerAddresses/CustomerAddressRepository.cs create mode 100644 ARW.Service/Business/BusinessService/Custom/CustomerAddresses/CustomerAddressService.cs create mode 100644 ARW.Service/Business/IBusinessService/Custom/CustomerAddresses/ICustomerAddressService.cs create mode 100644 ARW.WebApi/Controllers/Business/Custom/CustomerAddresses/CustomerAddressController.cs diff --git a/ARW.Model/Dto/Business/Custom/CustomerAddresses/CustomerAddressDto.cs b/ARW.Model/Dto/Business/Custom/CustomerAddresses/CustomerAddressDto.cs new file mode 100644 index 0000000..c201fd9 --- /dev/null +++ b/ARW.Model/Dto/Business/Custom/CustomerAddresses/CustomerAddressDto.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using ARW.Model.Models.Business.Custom.CustomerAddresses; + +namespace ARW.Model.Dto.Business.Custom.CustomerAddresses +{ + /// + /// 客户收货地址输入对象 + /// + /// @author admin + /// @date 2023-06-05 + /// + public class CustomerAddressDto + { + + public int CustomerAddressId { get; set; } + + public long CustomerAddressGuid { get; set; } + + [Required(ErrorMessage = "客户guid不能为空")] + public long CustomerAddressCustomerGuid { get; set; } + + [Required(ErrorMessage = "省id不能为空")] + public int CustomerAddressProvinceId { get; set; } + + [Required(ErrorMessage = "市id不能为空")] + public int CustomerAddressCityId { get; set; } + + [Required(ErrorMessage = "区id不能为空")] + public int CustomerAddressAreaId { get; set; } + + [Required(ErrorMessage = "收货人名称不能为空")] + public string CustomerAddressName { get; set; } + + [Required(ErrorMessage = "收货电话不能为空")] + public string CustomerAddressPhone { get; set; } + + [Required(ErrorMessage = "详细地址不能为空")] + public string CustomerAddressDetailed { get; set; } + + + + + + } + + + /// + /// 客户收货地址查询对象 + /// + /// @author admin + /// @date 2023-06-05 + /// + public class CustomerAddressQueryDto : PagerInfo + { + + public string CustomerAddressName { get; set; } + + public string CustomerAddressPhone { get; set; } + + public string ids { get; set; } + } + + + + +} diff --git a/ARW.Model/Dto/Business/Customers/CustomerDto.cs b/ARW.Model/Dto/Business/Customers/CustomerDto.cs index f9c74db..ef2c75c 100644 --- a/ARW.Model/Dto/Business/Customers/CustomerDto.cs +++ b/ARW.Model/Dto/Business/Customers/CustomerDto.cs @@ -71,7 +71,7 @@ namespace ARW.Model.Dto.Business.Customers /// @author 黎文豪 /// @date 2023-06-05 /// - public class CustomerQueryDto : PagerInfo + public class CustomerQueryDto : PagerInfo { public string CustomerXcxOpenid { get; set; } @@ -83,11 +83,60 @@ namespace ARW.Model.Dto.Business.Customers public DateTime? BeginTime { get; set; } public DateTime? EndTime { get; set; } - + public string ids { get; set; } } + /// + /// 客户微信手机号登录 输入对象 + /// + /// @author 黎文豪 + /// @date 2023-06-06 + /// + public class CustomerLoginDto + { + /// + /// 手机号Code + /// + [Required(ErrorMessage = "Code不能为空")] + public string Code { get; set; } + /// + /// OpenId + /// + public string CustomerXcxOpenid { get; set; } + + } + + + /// + /// 客户手机号登录 输入对象 + /// + /// @author 黎文豪 + /// @date 2023-06-06 + /// + public class CustomerPhoneLoginDto + { + /// + /// OpenId + /// + public string CustomerXcxOpenid { get; set; } + + + /// + /// 手机号 + /// + [Required(ErrorMessage = "手机号不能为空")] + public string PhoneNumber { get; set; } + + + /// + /// 验证码 + /// + [Required(ErrorMessage = "验证码不能为空")] + public string VerifyCode { get; set; } + + } } diff --git a/ARW.Model/Models/Business/Custom/CustomerAddresses/CustomerAddress.cs b/ARW.Model/Models/Business/Custom/CustomerAddresses/CustomerAddress.cs new file mode 100644 index 0000000..66bdb2b --- /dev/null +++ b/ARW.Model/Models/Business/Custom/CustomerAddresses/CustomerAddress.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using SqlSugar; +using OfficeOpenXml.Attributes; +using Newtonsoft.Json; + +namespace ARW.Model.Models.Business.Custom.CustomerAddresses +{ + /// + /// 客户收货地址,数据实体对象 + /// + /// @author admin + /// @date 2023-06-05 + /// + [SugarTable("tb_customer_address")] + public class CustomerAddress : BusinessBase + { + + /// + /// 描述 : + /// 空值 : false + /// + [EpplusTableColumn(Header = "CustomerAddressId")] + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "customer_address_id")] + public int CustomerAddressId { get; set; } + + + /// + /// 描述 : + /// 空值 : false + /// + [EpplusTableColumn(Header = "CustomerAddressGuid")] + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "customer_address_guid")] + public long CustomerAddressGuid { get; set; } + + + /// + /// 描述 :客户guid + /// 空值 : false + /// + [EpplusTableColumn(Header = "客户guid")] + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(ColumnName = "customer_address_customer_guid")] + public long CustomerAddressCustomerGuid { get; set; } + + + /// + /// 描述 :省id + /// 空值 : false + /// + [EpplusTableColumn(Header = "省id")] + [SugarColumn(ColumnName = "customer_address_province_id")] + public int CustomerAddressProvinceId { get; set; } + + + /// + /// 描述 :市id + /// 空值 : false + /// + [EpplusTableColumn(Header = "市id")] + [SugarColumn(ColumnName = "customer_address_city_id")] + public int CustomerAddressCityId { get; set; } + + + /// + /// 描述 :区id + /// 空值 : false + /// + [EpplusTableColumn(Header = "区id")] + [SugarColumn(ColumnName = "customer_address_area_id")] + public int CustomerAddressAreaId { get; set; } + + + /// + /// 描述 :收货人名称 + /// 空值 : false + /// + [EpplusTableColumn(Header = "收货人名称")] + [SugarColumn(ColumnName = "customer_address_name")] + public string CustomerAddressName { get; set; } + + + /// + /// 描述 :收货电话 + /// 空值 : false + /// + [EpplusTableColumn(Header = "收货电话")] + [SugarColumn(ColumnName = "customer_address_phone")] + public string CustomerAddressPhone { get; set; } + + + /// + /// 描述 :详细地址 + /// 空值 : false + /// + [EpplusTableColumn(Header = "详细地址")] + [SugarColumn(ColumnName = "customer_address_detailed")] + public string CustomerAddressDetailed { get; set; } + + + + + + + } +} \ No newline at end of file diff --git a/ARW.Model/System/LoginUser.cs b/ARW.Model/System/LoginUser.cs index 75b8f4d..bd76b48 100644 --- a/ARW.Model/System/LoginUser.cs +++ b/ARW.Model/System/LoginUser.cs @@ -13,6 +13,7 @@ namespace ARW.Model.System public long UserId { get; set; } public long DeptId { get; set; } public string UserName { get; set; } + public string UserPhone { get; set; } public bool IsApi { get; set; } diff --git a/ARW.Model/Vo/Business/Custom/CustomerAddresses/CustomerAddressVo.cs b/ARW.Model/Vo/Business/Custom/CustomerAddresses/CustomerAddressVo.cs new file mode 100644 index 0000000..0705d40 --- /dev/null +++ b/ARW.Model/Vo/Business/Custom/CustomerAddresses/CustomerAddressVo.cs @@ -0,0 +1,95 @@ +using Newtonsoft.Json; +using OfficeOpenXml.Attributes; +using SqlSugar; +using System; + +namespace ARW.Model.Vo.Business.Custom.CustomerAddresses +{ + /// + /// 客户收货地址展示对象 + /// + /// @author admin + /// @date 2023-06-05 + /// + public class CustomerAddressVo + { + + + /// + /// 描述 : + /// + [EpplusIgnore] + public int CustomerAddressId { get; set; } + + + /// + /// 描述 : + /// + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusIgnore] + public long CustomerAddressGuid { get; set; } + + + /// + /// 描述 :客户guid + /// + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusIgnore] + public long CustomerAddressCustomerGuid { get; set; } + + /// + /// 客户名称 + /// + [EpplusTableColumn(Header = "客户")] + public string CustomerName { get; set; } + + + /// + /// 描述 :省id + /// + [EpplusIgnore] + public int CustomerAddressProvinceId { get; set; } + + + /// + /// 描述 :市id + /// + [EpplusIgnore] + public int CustomerAddressCityId { get; set; } + + + /// + /// 描述 :区id + /// + [EpplusIgnore] + public int CustomerAddressAreaId { get; set; } + + /// + /// 所在地区 + /// + [EpplusTableColumn(Header = "所在地区")] + public string CustomerAddress { get; set; } + + + /// + /// 描述 :收货人名称 + /// + [EpplusTableColumn(Header = "收货人名称")] + public string CustomerAddressName { get; set; } + + + /// + /// 描述 :收货电话 + /// + [EpplusTableColumn(Header = "收货电话")] + public string CustomerAddressPhone { get; set; } + + + /// + /// 描述 :详细地址 + /// + [EpplusTableColumn(Header = "详细地址")] + public string CustomerAddressDetailed { get; set; } + + } +} diff --git a/ARW.Repository/Business/Custom/CustomerAddresses/CustomerAddressRepository.cs b/ARW.Repository/Business/Custom/CustomerAddresses/CustomerAddressRepository.cs new file mode 100644 index 0000000..0afabf5 --- /dev/null +++ b/ARW.Repository/Business/Custom/CustomerAddresses/CustomerAddressRepository.cs @@ -0,0 +1,20 @@ +using System; +using Infrastructure.Attribute; +using ARW.Repository.System; +using ARW.Model.Models.Business.Custom.CustomerAddresses; + +namespace ARW.Repository.Business.Custom.CustomerAddresses +{ + /// + /// 客户收货地址仓储 + /// + /// @author admin + /// @date 2023-06-05 + /// + [AppService(ServiceLifetime = LifeTime.Transient)] + public class CustomerAddressRepository : BaseRepository + { + #region 业务逻辑代码 + #endregion + } +} \ No newline at end of file diff --git a/ARW.Service/Business/BusinessService/Custom/CustomerAddresses/CustomerAddressService.cs b/ARW.Service/Business/BusinessService/Custom/CustomerAddresses/CustomerAddressService.cs new file mode 100644 index 0000000..ab2b324 --- /dev/null +++ b/ARW.Service/Business/BusinessService/Custom/CustomerAddresses/CustomerAddressService.cs @@ -0,0 +1,116 @@ +using Infrastructure.Attribute; +using Microsoft.AspNetCore.Http; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Infrastructure; +using ARW.Model; +using ARW.Repository; +using ARW.Repository.Business.Custom.CustomerAddresses; +using ARW.Service.Business.IBusinessService.Custom.CustomerAddresses; +using ARW.Model.Dto.Business.Custom.CustomerAddresses; +using ARW.Model.Models.Business.Custom.CustomerAddresses; +using ARW.Model.Vo.Business.Custom.CustomerAddresses; +using ARW.Repository.Business.Customers; +using ARW.Model.Models.Business.Customers; +using ARW.Model.Models.Business.Regions; + +namespace ARW.Service.Business.BusinessService.Custom.CustomerAddresses +{ + /// + /// 客户收货地址接口实现类 + /// + /// @author admin + /// @date 2023-06-05 + /// + [AppService(ServiceType = typeof(ICustomerAddressService), ServiceLifetime = LifeTime.Transient)] + public class CustomerAddressServiceImpl : BaseService, ICustomerAddressService + { + private readonly CustomerAddressRepository _CustomerAddressRepository; + private readonly CustomerRepository _CustomerRepository; + + public CustomerAddressServiceImpl(CustomerAddressRepository CustomerAddressRepository, CustomerRepository customerRepository) + { + this._CustomerAddressRepository = CustomerAddressRepository; + _CustomerRepository = customerRepository; + } + + #region 业务逻辑代码 + + + /// + /// 查询客户收货地址分页列表 + /// + public Task> GetCustomerAddressList(CustomerAddressQueryDto parm) + { + //开始拼装查询条件d + var predicate = Expressionable.Create(); + + predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CustomerAddressName), it => it.CustomerAddressName.Contains(parm.CustomerAddressName)); + predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CustomerAddressPhone), it => it.CustomerAddressPhone.Contains(parm.CustomerAddressPhone)); + var query = _CustomerAddressRepository + .Queryable() + .LeftJoin((s, c) => s.CustomerAddressCustomerGuid == c.CustomerGuid) + .LeftJoin((s, c, d) => s.CustomerAddressProvinceId == d.RegionId) + .LeftJoin((s, c, d, f) => s.CustomerAddressCityId == f.RegionId) + .LeftJoin((s, c, d, f, g) => s.CustomerAddressAreaId == g.RegionId) + .Where(predicate.ToExpression()) + .OrderBy(s => s.Create_time, OrderByType.Desc) + .Select((s, c, d, f, g) => new CustomerAddressVo + { + CustomerName = c.CustomerNickname, + CustomerAddress = d.RegionName + "/" + f.RegionName + "/" + g.RegionName, + CustomerAddressId = s.CustomerAddressId, + CustomerAddressGuid = s.CustomerAddressGuid, + CustomerAddressCustomerGuid = s.CustomerAddressCustomerGuid, + CustomerAddressProvinceId = s.CustomerAddressProvinceId, + CustomerAddressCityId = s.CustomerAddressCityId, + CustomerAddressAreaId = s.CustomerAddressAreaId, + CustomerAddressName = s.CustomerAddressName, + CustomerAddressPhone = s.CustomerAddressPhone, + CustomerAddressDetailed = s.CustomerAddressDetailed, + }); + + + return query.ToPageAsync(parm); + } + + /// + /// 添加或修改客户收货地址 + /// + public async Task AddOrUpdateCustomerAddress(CustomerAddress model) + { + if (model.CustomerAddressId != 0) + { + var response = await _CustomerAddressRepository.UpdateAsync(model); + return "修改成功!"; + } + else + { + var response = await _CustomerAddressRepository.InsertReturnSnowflakeIdAsync(model); + return "添加成功!"; + } + } + + #region Excel处理 + + + /// + /// Excel数据导出处理 + /// + public async Task> HandleExportData(List data) + { + return data; + } + + #endregion + + + + #endregion + + } +} diff --git a/ARW.Service/Business/BusinessService/Customers/CustomerService.cs b/ARW.Service/Business/BusinessService/Customers/CustomerService.cs index 7f0f3f1..bac0eab 100644 --- a/ARW.Service/Business/BusinessService/Customers/CustomerService.cs +++ b/ARW.Service/Business/BusinessService/Customers/CustomerService.cs @@ -33,13 +33,13 @@ namespace ARW.Service.Business.BusinessService.Customers this._CustomerRepository = CustomerRepository; } - #region 业务逻辑代码 - - - /// + #region 业务逻辑代码 + + + /// /// 查询小程序客户分页列表 /// - public Task> GetCustomerList(CustomerQueryDto parm) + public Task> GetCustomerList(CustomerQueryDto parm) { //开始拼装查询条件d var predicate = Expressionable.Create(); @@ -51,28 +51,28 @@ namespace ARW.Service.Business.BusinessService.Customers var query = _CustomerRepository .Queryable() .Where(predicate.ToExpression()) - .OrderBy(s => s.Create_time,OrderByType.Desc) + .OrderBy(s => s.Create_time, OrderByType.Desc) .Select(s => new CustomerVo { - CustomerId = s.CustomerId, - CustomerGuid = s.CustomerGuid, - CustomerXcxOpenid = s.CustomerXcxOpenid, - CustomerNickname = s.CustomerNickname, - CustomerMobilePhoneNumber = s.CustomerMobilePhoneNumber, - CustomerAvatar = s.CustomerAvatar, - CustomerGender = s.CustomerGender, - CustomerAvailableBalance = s.CustomerAvailableBalance, - CustomerAvailablePoints = s.CustomerAvailablePoints, - CustomerTotalPaymentAmount = s.CustomerTotalPaymentAmount, - CustomerActualConsumptionAmount = s.CustomerActualConsumptionAmount, - CustomerLastLoginTime = s.CustomerLastLoginTime, - }); - + CustomerId = s.CustomerId, + CustomerGuid = s.CustomerGuid, + CustomerXcxOpenid = s.CustomerXcxOpenid, + CustomerNickname = s.CustomerNickname, + CustomerMobilePhoneNumber = s.CustomerMobilePhoneNumber, + CustomerAvatar = s.CustomerAvatar, + CustomerGender = s.CustomerGender, + CustomerAvailableBalance = s.CustomerAvailableBalance, + CustomerAvailablePoints = s.CustomerAvailablePoints, + CustomerTotalPaymentAmount = s.CustomerTotalPaymentAmount, + CustomerActualConsumptionAmount = s.CustomerActualConsumptionAmount, + CustomerLastLoginTime = s.CustomerLastLoginTime, + }); - return query.ToPageAsync(parm); + + return query.ToPageAsync(parm); } - /// + /// /// 添加或修改小程序客户 /// public async Task AddOrUpdateCustomer(Customer model) @@ -92,7 +92,7 @@ namespace ARW.Service.Business.BusinessService.Customers #region Excel处理 - + /// /// Excel数据导出处理 /// @@ -102,10 +102,10 @@ namespace ARW.Service.Business.BusinessService.Customers } #endregion - -#endregion + + #endregion } } diff --git a/ARW.Service/Business/IBusinessService/Custom/CustomerAddresses/ICustomerAddressService.cs b/ARW.Service/Business/IBusinessService/Custom/CustomerAddresses/ICustomerAddressService.cs new file mode 100644 index 0000000..4678c59 --- /dev/null +++ b/ARW.Service/Business/IBusinessService/Custom/CustomerAddresses/ICustomerAddressService.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ARW.Model; +using ARW.Model.Dto.Business.Custom.CustomerAddresses; +using ARW.Model.Models.Business.Custom.CustomerAddresses; +using ARW.Model.Vo.Business.Custom.CustomerAddresses; + +namespace ARW.Service.Business.IBusinessService.Custom.CustomerAddresses +{ + /// + /// 客户收货地址接口类 + /// + /// @author admin + /// @date 2023-06-05 + /// + public interface ICustomerAddressService : IBaseService + { + /// + /// 获取客户收货地址分页列表 + /// + /// + /// + Task> GetCustomerAddressList(CustomerAddressQueryDto parm); + + + /// + /// 添加或修改客户收货地址 + /// + /// + /// + Task AddOrUpdateCustomerAddress(CustomerAddress parm); + + + + /// + /// Excel导出 + /// + Task> HandleExportData(List data); + + + } +} diff --git a/ARW.WebApi/Controllers/Api/Wechat/WeChatLoginController.cs b/ARW.WebApi/Controllers/Api/Wechat/WeChatLoginController.cs index b0b2684..762e4ee 100644 --- a/ARW.WebApi/Controllers/Api/Wechat/WeChatLoginController.cs +++ b/ARW.WebApi/Controllers/Api/Wechat/WeChatLoginController.cs @@ -15,6 +15,8 @@ using Senparc.Weixin.WxOpen.AdvancedAPIs.WxApp.Business.JsonResult; using Senparc.Weixin.WxOpen; using Senparc.Weixin; using Senparc.Weixin.CommonAPIs; +using Senparc.Weixin.Open.WxOpenAPIs; +using Senparc.Weixin.WxOpen.AdvancedAPIs.WxApp; namespace ARW.WebApi.Controllers.Api.Wechat { @@ -31,8 +33,6 @@ namespace ARW.WebApi.Controllers.Api.Wechat private readonly OptionsSetting _jwtSettings; - static string session_key = ""; - static string openId = ""; public WeChatLoginController(WeChatLogin weChat, ICustomerService customerService, IOptions jwtSettings) { _weChat = weChat; @@ -41,54 +41,72 @@ namespace ARW.WebApi.Controllers.Api.Wechat } /// - /// 注册小程序客户 + /// 登录/注册小程序客户 /// /// /// [HttpPost("Login")] - public IActionResult AddCustomer([FromBody] CustomerDto parm) + public async Task Login([FromBody] CustomerLoginDto parm) { - - if (parm == null) { throw new CustomException("请求参数错误"); } + if (parm == null) + { + throw new CustomException("请求参数错误"); + } var addModal = parm.Adapt().ToCreate(HttpContext); - - var user = _customerService.GetFirst(s => s.CustomerXcxOpenid == parm.CustomerXcxOpenid); + var user = await _customerService.GetFirstAsync(s => s.CustomerXcxOpenid == parm.CustomerXcxOpenid); if (user == null) { - - var response = _customerService.InsertReturnSnowflakeId(addModal); + addModal.CustomerMobilePhoneNumber = await GetUserPhoneNumber(parm.Code); + var response = await _customerService.InsertReturnSnowflakeIdAsync(addModal); if (response == 0) - throw new CustomException("添加失败!"); - - var newUser = _customerService.GetFirst(s => s.CustomerGuid == response); - if (newUser != null) { - LoginUser loginUser = new LoginUser - { - UserId = newUser.CustomerGuid, - UserName = newUser.CustomerNickname, - IsApi = true, - }; - var jwt = JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser), _jwtSettings.JwtSettings); - return SUCCESS(jwt); + throw new CustomException("添加失败!"); + } + + user = await _customerService.GetFirstAsync(s => s.CustomerGuid == response); + } + + LoginUser loginUser = new LoginUser + { + UserId = user.CustomerGuid, + UserName = user.CustomerNickname, + UserPhone = user.CustomerMobilePhoneNumber, + IsApi = true, + }; + var jwt = JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser), _jwtSettings.JwtSettings); + return SUCCESS(jwt); + } + + + + /// + /// 获取用户手机号 + /// + /// + /// + public async Task GetUserPhoneNumber(string code) + { + try + { + var Appid = AppSettings.GetConfig("SenparcWeixinSetting:TenPayV3_AppId"); + var result = await BusinessApi.GetUserPhoneNumberAsync(Appid, code); + if (result.phone_info != null) + { + return result.phone_info.phoneNumber; + } + else + { + throw new Exception("获取手机号报错:"+ result); } } - else + catch (Exception ex) { - LoginUser loginUser = new LoginUser - { - UserId = user.CustomerGuid, - UserName = user.CustomerNickname, - IsApi = true, - }; - var jwt = JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser), _jwtSettings.JwtSettings); - return SUCCESS(jwt); + throw new Exception("获取手机号报错:" + ex); } - - return SUCCESS("666"); } + } } diff --git a/ARW.WebApi/Controllers/Api/Wechat/WxPay/WxPayController.cs b/ARW.WebApi/Controllers/Api/Wechat/WxPay/WxPayController.cs index b42b6df..da821e2 100644 --- a/ARW.WebApi/Controllers/Api/Wechat/WxPay/WxPayController.cs +++ b/ARW.WebApi/Controllers/Api/Wechat/WxPay/WxPayController.cs @@ -9,6 +9,8 @@ using Senparc.CO2NET.HttpUtility; using Senparc.Weixin.TenPayV3.Apis; using static Infrastructure.WeChat.TenPay.Pay; using ARW.Admin.WebApi.Framework; +using Senparc.Weixin.Open.WxOpenAPIs; +using Senparc.Weixin.WxOpen.AdvancedAPIs.WxApp; namespace ARW.WebApi.Controllers.Api.Wechat.WxPay { diff --git a/ARW.WebApi/Controllers/Business/Custom/CustomerAddresses/CustomerAddressController.cs b/ARW.WebApi/Controllers/Business/Custom/CustomerAddresses/CustomerAddressController.cs new file mode 100644 index 0000000..e1591ea --- /dev/null +++ b/ARW.WebApi/Controllers/Business/Custom/CustomerAddresses/CustomerAddressController.cs @@ -0,0 +1,132 @@ +using Infrastructure; +using Infrastructure.Attribute; +using Infrastructure.Enums; +using Infrastructure.Model; +using Mapster; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using ARW.Admin.WebApi.Extensions; +using ARW.Admin.WebApi.Filters; +using ARW.Common; +using ARW.Model.Dto.Business.Custom.CustomerAddresses; +using ARW.Service.Business.IBusinessService.Custom.CustomerAddresses; +using ARW.Admin.WebApi.Controllers; +using ARW.Model.Models.Business.Custom.CustomerAddresses; +using ARW.Model.Vo.Business.Custom.CustomerAddresses; +using Microsoft.AspNetCore.Authorization; +using ARW.Admin.WebApi.Framework; + + +namespace ARW.WebApi.Controllers.Business.Custom.CustomerAddresses +{ + /// + /// 客户收货地址控制器 + /// + /// @author admin + /// @date 2023-06-05 + /// + [Verify] + [Route("business/[controller]")] + public class CustomerAddressController : BaseController + { + private readonly ICustomerAddressService _CustomerAddressService; + + /// + /// 依赖注入 + /// + /// 客户收货地址服务 + public CustomerAddressController(ICustomerAddressService CustomerAddressService) + { + _CustomerAddressService = CustomerAddressService; + } + + + /// + /// 获取客户收货地址列表 + /// + /// 查询参数 + /// + [HttpGet("getCustomerAddressList")] + [ActionPermissionFilter(Permission = "business:customeraddress:list")] + public async Task GetCustomerAddressList([FromQuery] CustomerAddressQueryDto parm) + { + var res = await _CustomerAddressService.GetCustomerAddressList(parm); + return SUCCESS(res); + } + + /// + /// 添加或修改客户收货地址 + /// + /// + /// + [HttpPost("addOrUpdateCustomerAddress")] + [ActionPermissionFilter(Permission = "business:customeraddress:addOrUpdate")] + [Log(Title = "添加或修改客户收货地址", BusinessType = BusinessType.ADDORUPDATE)] + public async Task AddOrUpdateCustomerAddress([FromBody] CustomerAddressDto parm) + { + if (parm == null) { throw new CustomException("请求参数错误"); } + + var modal = new CustomerAddress(); + if (parm.CustomerAddressId != 0) modal = parm.Adapt().ToUpdate(HttpContext); + else modal = parm.Adapt().ToCreate(HttpContext); + + var res = await _CustomerAddressService.AddOrUpdateCustomerAddress(modal); + return SUCCESS(res); + } + + /// + /// 删除客户收货地址 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "business:customeraddress:delete")] + [Log(Title = "客户收货地址删除", BusinessType = BusinessType.DELETE)] + public IActionResult Delete(string ids) + { + long[] idsArr = Tools.SpitLongArrary(ids); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + var response = _CustomerAddressService.Delete(idsArr); + return SUCCESS("删除成功!"); + } + + + /// + /// 导出客户收货地址 + /// + /// + [Log(Title = "客户收货地址导出", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)] + [HttpGet("exportCustomerAddress")] + [ActionPermissionFilter(Permission = "business:customeraddress:export")] + public async Task ExportExcel([FromQuery] CustomerAddressQueryDto parm) + { + parm.PageSize = 10000; + var list = await _CustomerAddressService.GetCustomerAddressList(parm); + var data = list.Result; + + // 选中数据 + if (!string.IsNullOrEmpty(parm.ids)) + { + int[] idsArr = Tools.SpitIntArrary(parm.ids); + var selectDataList = new List(); + foreach (var item in idsArr) + { + var select_data = data.Where(s => s.CustomerAddressId == item).First(); + selectDataList.Add(select_data); + } + data = selectDataList; + } + + + + // 导出数据处理 + var handleData = await _CustomerAddressService.HandleExportData(data); + + string sFileName = ExportExcel(handleData, "CustomerAddress", "客户收货地址列表"); + return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName }); + } + + + + + } +} diff --git a/ARW.WebApi/Program.cs b/ARW.WebApi/Program.cs index f12bafc..3427d7c 100644 --- a/ARW.WebApi/Program.cs +++ b/ARW.WebApi/Program.cs @@ -48,9 +48,9 @@ var senparcWeixinSetting = builder.Services.BuildServiceProvider().GetRequiredSe register.UseSenparcWeixin(senparcWeixinSetting.Value, senparcSetting.Value);//微信全局注册,必须! // 小程序 -await AccessTokenContainer.RegisterAsync("wx34436769371ceb7c", "8ded49f94c8e607de7cc4244639d4666"); +await AccessTokenContainer.RegisterAsync("wx8b03fffabbbfe804", "ef5845d854c1111cd842bb54481be0c1"); // 公众号 -await AccessTokenContainer.RegisterAsync("wx99caf571c9fb1cc5", "61100d9c4fff5acf97517f0c8799e2e2"); +await AccessTokenContainer.RegisterAsync("wxa515d1bd73d06294", "c97d2e3ded5f6a7c86a4bbee3f1ab3ab"); // 添加WeChat单例服务 builder.Services.AddSingleton(new WeChatLogin("wxf3f7f286bfbb7dfa", "c2a02e478d9f0683d8dafec646c3d2ca")); diff --git a/ARW.WebApi/appsettings.json b/ARW.WebApi/appsettings.json index 2b2fbac..9186c44 100644 --- a/ARW.WebApi/appsettings.json +++ b/ARW.WebApi/appsettings.json @@ -27,11 +27,11 @@ }, //阿里云存储配置 "AARWYUN_OSS": { - "REGIONID": "oss-cn-shenzhen.aliyuncs.com", + "REGIONID": "oss-cn-hongkong.aliyuncs.com", "KEY": "LTAI5tLGSBenBxmdvZB4TpVg", "SECRET": "OR1kPyaOAP7q4zEtsmEqepZcyWG1yh", - "bucketName": "aerwen", - "domainUrl": "http://119.23.54.43/oss" //访问资源域名 + "bucketName": "arw", + "domainUrl": "arw.oss-cn-hongkong.aliyuncs.com" //访问资源域名 }, //阿里云短信配置 "AARWYUN_MSG": { @@ -134,12 +134,12 @@ //公众号 "Token": "63_I_BSEoa_qwlHgGSVxLmyNylHJ11ejzc9_WiWPRt64sDetCJe9CLU9YwVbL-VoAjqCH0Pg5QElGL4p_B2z63SKG9jj-dRPp-BD1gpiaAe6uxrwocfFeX4JXepvgcRAGhACAHQW", "EncodingAESKey": "", //公众号解密秘钥 - "WeixinAppId": "wx99caf571c9fb1cc5", //公众号AppId - "WeixinAppSecret": "61100d9c4fff5acf97517f0c8799e2e2", //公众号秘钥 + "WeixinAppId": "wxa515d1bd73d06294", //公众号AppId + "WeixinAppSecret": "c97d2e3ded5f6a7c86a4bbee3f1ab3ab", //公众号秘钥 //微信支付V3 - "TenPayV3_AppId": "wx34436769371ceb7c", // 小程序AppId - "TenPayV3_AppSecret": "8ded49f94c8e607de7cc4244639d4666", // 小程序AppSecret + "TenPayV3_AppId": "wx8b03fffabbbfe804", // 小程序AppId + "TenPayV3_AppSecret": "ef5845d854c1111cd842bb54481be0c1", // 小程序AppSecret "TenPayV3_SubAppId": "", //子小程序AppId,没有可留空 "TenPayV3_SubAppSecret": "", //子小程序AppSecret,没有可留空 "TenPayV3_MchId": "1626418383", //商户号 diff --git a/ARW.WebApi/wwwroot/CodeGenTemplate/TplVueIndex.txt b/ARW.WebApi/wwwroot/CodeGenTemplate/TplVueIndex.txt index 369068f..dff3701 100644 --- a/ARW.WebApi/wwwroot/CodeGenTemplate/TplVueIndex.txt +++ b/ARW.WebApi/wwwroot/CodeGenTemplate/TplVueIndex.txt @@ -10,7 +10,7 @@
- $foreach(column in genTable.Columns) $set(labelName = "")