diff --git a/ARW.Model/Dto/Business/ShopManager/Shops/ShopDto.cs b/ARW.Model/Dto/Business/ShopManager/Shops/ShopDto.cs new file mode 100644 index 0000000..cc1c5e4 --- /dev/null +++ b/ARW.Model/Dto/Business/ShopManager/Shops/ShopDto.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using ARW.Model.Models.Business.ShopManager.Shops; + +namespace ARW.Model.Dto.Business.ShopManager.Shops +{ + /// + /// 店铺输入对象 + /// + /// @author 黎文豪 + /// @date 2023-06-09 + /// + public class ShopDto + { + + public int ShopId { get; set; } + + public long ShopGuid { get; set; } + + public int? ShopUserId { get; set; } + + public long? ShopCustomerGuid { get; set; } + + [Required(ErrorMessage = "经营类目guid不能为空")] + public long ShopBusinessCategoryGuid { get; set; } + + [Required(ErrorMessage = "图标不能为空")] + public string ShopLogo { get; set; } + + [Required(ErrorMessage = "营业执照不能为空")] + public string ShopBusinessLicense { get; set; } + + [Required(ErrorMessage = "名称不能为空")] + public string ShopName { get; set; } + + [Required(ErrorMessage = "简介不能为空")] + public string ShopIntro { get; set; } + + [Required(ErrorMessage = "排序不能为空")] + public int ShopSort { get; set; } + + [Required(ErrorMessage = "销售单量不能为空")] + public int ShopSalesOrderCount { get; set; } + + [Required(ErrorMessage = "审核状态不能为空")] + public int ShopAuditStatus { get; set; } + + [Required(ErrorMessage = "审核人不能为空")] + public long ShopAuditUserGuid { get; set; } + + + + + + } + + + /// + /// 店铺查询对象 + /// + /// @author 黎文豪 + /// @date 2023-06-09 + /// + public class ShopQueryDto : PagerInfo + { + + public string ShopName { get; set; } + + public int? ShopAuditStatus { get; set; } + + public string ids { get; set; } + } + + + /// + /// + /// @author 黎文豪 + /// @date 2023-06-09 + /// 审核对象 + /// + public class ShopAuditDto + { + public int ShopAuditStatus { get; set; } + public string ids { get; set; } + } + + +} diff --git a/ARW.Model/Models/Business/ShopManager/Shops/Shop.cs b/ARW.Model/Models/Business/ShopManager/Shops/Shop.cs new file mode 100644 index 0000000..52e0367 --- /dev/null +++ b/ARW.Model/Models/Business/ShopManager/Shops/Shop.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using SqlSugar; +using OfficeOpenXml.Attributes; +using Newtonsoft.Json; + +namespace ARW.Model.Models.Business.ShopManager.Shops +{ + /// + /// 店铺,数据实体对象 + /// + /// @author 黎文豪 + /// @date 2023-06-09 + /// + [SugarTable("tb_shop")] + public class Shop : BusinessBase + { + + /// + /// 描述 : + /// 空值 : false + /// + [EpplusTableColumn(Header = "ShopId")] + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "shop_id")] + public int ShopId { get; set; } + + + /// + /// 描述 : + /// 空值 : false + /// + [EpplusTableColumn(Header = "ShopGuid")] + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "shop_guid")] + public long ShopGuid { get; set; } + + + /// + /// 描述 :用户id + /// 空值 : true + /// + [EpplusTableColumn(Header = "用户id")] + [SugarColumn(ColumnName = "shop_user_id")] + public int? ShopUserId { get; set; } + + + /// + /// 描述 :客户guid + /// 空值 : true + /// + [EpplusTableColumn(Header = "客户guid")] + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(ColumnName = "shop_customer_guid")] + public long? ShopCustomerGuid { get; set; } + + + /// + /// 描述 :经营类目guid + /// 空值 : false + /// + [EpplusTableColumn(Header = "经营类目guid")] + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(ColumnName = "shop_business_category_guid")] + public long ShopBusinessCategoryGuid { get; set; } + + + /// + /// 描述 :图标 + /// 空值 : false + /// + [EpplusTableColumn(Header = "图标")] + [SugarColumn(ColumnName = "shop_logo")] + public string ShopLogo { get; set; } + + + /// + /// 描述 :营业执照 + /// 空值 : false + /// + [EpplusTableColumn(Header = "营业执照")] + [SugarColumn(ColumnName = "shop_business_license")] + public string ShopBusinessLicense { get; set; } + + + /// + /// 描述 :名称 + /// 空值 : false + /// + [EpplusTableColumn(Header = "名称")] + [SugarColumn(ColumnName = "shop_name")] + public string ShopName { get; set; } + + + /// + /// 描述 :简介 + /// 空值 : false + /// + [EpplusTableColumn(Header = "简介")] + [SugarColumn(ColumnName = "shop_intro")] + public string ShopIntro { get; set; } + + + /// + /// 描述 :排序 + /// 空值 : false + /// + [EpplusTableColumn(Header = "排序")] + [SugarColumn(ColumnName = "shop_sort")] + public int ShopSort { get; set; } + + + /// + /// 描述 :销售单量 + /// 空值 : false + /// + [EpplusTableColumn(Header = "销售单量")] + [SugarColumn(ColumnName = "shop_sales_order_count")] + public int ShopSalesOrderCount { get; set; } + + + /// + /// 描述 :审核状态 + /// 空值 : false + /// + [EpplusTableColumn(Header = "审核状态")] + [SugarColumn(ColumnName = "shop_audit_status")] + public int ShopAuditStatus { get; set; } + + + /// + /// 描述 :审核人 + /// 空值 : false + /// + [EpplusTableColumn(Header = "审核人")] + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(ColumnName = "shop_audit_user_guid")] + public long ShopAuditUserGuid { get; set; } + + + + + + + } +} \ No newline at end of file diff --git a/ARW.Model/Vo/Business/ShopManager/Shops/ShopVo.cs b/ARW.Model/Vo/Business/ShopManager/Shops/ShopVo.cs new file mode 100644 index 0000000..0320f7b --- /dev/null +++ b/ARW.Model/Vo/Business/ShopManager/Shops/ShopVo.cs @@ -0,0 +1,113 @@ +using Newtonsoft.Json; +using OfficeOpenXml.Attributes; +using SqlSugar; +using System; + +namespace ARW.Model.Vo.Business.ShopManager.Shops +{ + /// + /// 店铺展示对象 + /// + /// @author 黎文豪 + /// @date 2023-06-09 + /// + public class ShopVo + { + + + /// + /// 描述 : + /// + [EpplusIgnore] + public int ShopId { get; set; } + + + /// + /// 描述 : + /// + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusIgnore] + public long ShopGuid { get; set; } + + + /// + /// 描述 :用户id + /// + [EpplusIgnore] + public int? ShopUserId { get; set; } + + + /// + /// 描述 :客户guid + /// + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusIgnore] + public long? ShopCustomerGuid { get; set; } + + + /// + /// 描述 :经营类目guid + /// + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusTableColumn(Header = "经营类目guid")] + public long ShopBusinessCategoryGuid { get; set; } + + + /// + /// 描述 :图标 + /// + [EpplusTableColumn(Header = "图标")] + public string ShopLogo { get; set; } + + + /// + /// 描述 :营业执照 + /// + [EpplusTableColumn(Header = "营业执照")] + public string ShopBusinessLicense { get; set; } + + + /// + /// 描述 :名称 + /// + [EpplusTableColumn(Header = "名称")] + public string ShopName { get; set; } + + + /// + /// 描述 :简介 + /// + [EpplusTableColumn(Header = "简介")] + public string ShopIntro { get; set; } + + + /// + /// 描述 :排序 + /// + [EpplusTableColumn(Header = "排序")] + public int ShopSort { get; set; } + + + /// + /// 描述 :销售单量 + /// + [EpplusTableColumn(Header = "销售单量")] + public int ShopSalesOrderCount { get; set; } + + + /// + /// 描述 :审核状态 + /// + [EpplusTableColumn(Header = "审核状态")] + public int ShopAuditStatus { get; set; } + + + /// + /// 描述 :审核人 + /// + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusTableColumn(Header = "审核人")] + public long ShopAuditUserGuid { get; set; } + + } +} diff --git a/ARW.Repository/Business/ShopManager/Shops/ShopRepository.cs b/ARW.Repository/Business/ShopManager/Shops/ShopRepository.cs new file mode 100644 index 0000000..a2a37f8 --- /dev/null +++ b/ARW.Repository/Business/ShopManager/Shops/ShopRepository.cs @@ -0,0 +1,20 @@ +using System; +using Infrastructure.Attribute; +using ARW.Repository.System; +using ARW.Model.Models.Business.ShopManager.Shops; + +namespace ARW.Repository.Business.ShopManager.Shops +{ + /// + /// 店铺仓储 + /// + /// @author 黎文豪 + /// @date 2023-06-09 + /// + [AppService(ServiceLifetime = LifeTime.Transient)] + public class ShopRepository : BaseRepository + { + #region 业务逻辑代码 + #endregion + } +} \ No newline at end of file diff --git a/ARW.Service/Business/BusinessService/ShopManager/Shops/ShopService.cs b/ARW.Service/Business/BusinessService/ShopManager/Shops/ShopService.cs new file mode 100644 index 0000000..df6f047 --- /dev/null +++ b/ARW.Service/Business/BusinessService/ShopManager/Shops/ShopService.cs @@ -0,0 +1,144 @@ +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.ShopManager.Shops; +using ARW.Service.Business.IBusinessService.ShopManager.Shops; +using ARW.Model.Dto.Business.ShopManager.Shops; +using ARW.Model.Models.Business.ShopManager.Shops; +using ARW.Model.Vo.Business.ShopManager.Shops; + +namespace ARW.Service.Business.BusinessService.ShopManager.Shops +{ + /// + /// 店铺接口实现类 + /// + /// @author 黎文豪 + /// @date 2023-06-09 + /// + [AppService(ServiceType = typeof(IShopService), ServiceLifetime = LifeTime.Transient)] + public class ShopServiceImpl : BaseService, IShopService + { + private readonly ShopRepository _ShopRepository; + + public ShopServiceImpl(ShopRepository ShopRepository) + { + this._ShopRepository = ShopRepository; + } + + #region 业务逻辑代码 + + + /// + /// 查询店铺分页列表 + /// + public Task> GetShopList(ShopQueryDto parm) + { + //开始拼装查询条件d + var predicate = Expressionable.Create(); + + predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.ShopName), it => it.ShopName.Contains(parm.ShopName)); + predicate = predicate.AndIF(parm.ShopAuditStatus != null, it => it.ShopAuditStatus == parm.ShopAuditStatus); + var query = _ShopRepository + .Queryable() + .Where(predicate.ToExpression()) + .OrderBy(s => s.ShopSort,OrderByType.Asc) + .Select(s => new ShopVo + { + ShopId = s.ShopId, + ShopGuid = s.ShopGuid, + ShopUserId = s.ShopUserId, + ShopCustomerGuid = s.ShopCustomerGuid, + ShopBusinessCategoryGuid = s.ShopBusinessCategoryGuid, + ShopLogo = s.ShopLogo, + ShopBusinessLicense = s.ShopBusinessLicense, + ShopName = s.ShopName, + ShopIntro = s.ShopIntro, + ShopSort = s.ShopSort, + ShopSalesOrderCount = s.ShopSalesOrderCount, + ShopAuditStatus = s.ShopAuditStatus, + ShopAuditUserGuid = s.ShopAuditUserGuid, + }); + + + return query.ToPageAsync(parm); + } + + /// + /// 添加或修改店铺 + /// + public async Task AddOrUpdateShop(Shop model) + { + if (model.ShopId != 0) + { + var response = await _ShopRepository.UpdateAsync(model); + return "修改成功!"; + } + else + { + + var response = await _ShopRepository.InsertReturnSnowflakeIdAsync(model); + return "添加成功!"; + } + } + + #region Excel处理 + + + /// + /// Excel数据导出处理 + /// + public async Task> HandleExportData(List data) + { + return data; + } + + #endregion + + + /// + /// 审核 + /// + public async Task Audit(int id, int status, long userGuid) + { + try + { + var res = await _ShopRepository.GetFirstAsync(s => s.ShopId == id); + await UseTranAsync(async () => + { + await _ShopRepository.UpdateAsync(f => new Shop { ShopAuditStatus = status, ShopAuditUserGuid = userGuid, Update_time = DateTime.Now, Update_by = userGuid.ToString() }, s => s.ShopId == id); + }); + if (res.ShopAuditStatus == 2) + { + var errorRes = $"店铺:【{res.ShopName}】已通过审核!
"; + return errorRes; + } + if (res.ShopAuditStatus == 3) + { + var errorRes = $"店铺:【{res.ShopName}】已被驳回!
"; + return errorRes; + } + else if (res.ShopAuditStatus == 1) + { + var addStr = $"店铺:【{res.ShopName}】审核通过!
"; + return addStr; + } + return ""; + } + catch (Exception) + { + throw; + } + } + +#endregion + + } +} diff --git a/ARW.Service/Business/IBusinessService/ShopManager/Shops/IShopService.cs b/ARW.Service/Business/IBusinessService/ShopManager/Shops/IShopService.cs new file mode 100644 index 0000000..dea0e5f --- /dev/null +++ b/ARW.Service/Business/IBusinessService/ShopManager/Shops/IShopService.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ARW.Model; +using ARW.Model.Dto.Business.ShopManager.Shops; +using ARW.Model.Models.Business.ShopManager.Shops; +using ARW.Model.Vo.Business.ShopManager.Shops; + +namespace ARW.Service.Business.IBusinessService.ShopManager.Shops +{ + /// + /// 店铺接口类 + /// + /// @author 黎文豪 + /// @date 2023-06-09 + /// + public interface IShopService : IBaseService + { + /// + /// 获取店铺分页列表 + /// + /// + /// + Task> GetShopList(ShopQueryDto parm); + + + /// + /// 添加或修改店铺 + /// + /// + /// + Task AddOrUpdateShop(Shop parm); + + + + /// + /// Excel导出 + /// + Task> HandleExportData(List data); + + /// + /// 审核 + /// + Task Audit(int idsArr, int status,long userGuid); + + } +} diff --git a/ARW.WebApi/Controllers/Business/ShopManager/Shops/ShopController.cs b/ARW.WebApi/Controllers/Business/ShopManager/Shops/ShopController.cs new file mode 100644 index 0000000..c489375 --- /dev/null +++ b/ARW.WebApi/Controllers/Business/ShopManager/Shops/ShopController.cs @@ -0,0 +1,154 @@ +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.ShopManager.Shops; +using ARW.Service.Business.IBusinessService.ShopManager.Shops; +using ARW.Admin.WebApi.Controllers; +using ARW.Model.Models.Business.ShopManager.Shops; +using ARW.Model.Vo.Business.ShopManager.Shops; +using Microsoft.AspNetCore.Authorization; +using ARW.Admin.WebApi.Framework; + + +namespace ARW.WebApi.Controllers.Business.ShopManager.Shops +{ + /// + /// 店铺控制器 + /// + /// @author 黎文豪 + /// @date 2023-06-09 + /// + [Verify] + [Route("business/[controller]")] + public class ShopController : BaseController + { + private readonly IShopService _ShopService; + + /// + /// 依赖注入 + /// + /// 店铺服务 + public ShopController(IShopService ShopService) + { + _ShopService = ShopService; + } + + + /// + /// 获取店铺列表 + /// + /// 查询参数 + /// + [HttpGet("getShopList")] + [ActionPermissionFilter(Permission = "business:shop:list")] + public async Task GetShopList([FromQuery] ShopQueryDto parm) + { + var res = await _ShopService.GetShopList(parm); + return SUCCESS(res); + } + + /// + /// 添加或修改店铺 + /// + /// + /// + [HttpPost("addOrUpdateShop")] + [ActionPermissionFilter(Permission = "business:shop:addOrUpdate")] + [Log(Title = "添加或修改店铺", BusinessType = BusinessType.ADDORUPDATE)] + public async Task AddOrUpdateShop([FromBody] ShopDto parm) + { + if (parm == null) { throw new CustomException("请求参数错误"); } + + var modal = new Shop(); + if (parm.ShopId != 0) modal = parm.Adapt().ToUpdate(HttpContext); + else modal = parm.Adapt().ToCreate(HttpContext); + + var res = await _ShopService.AddOrUpdateShop(modal); + return SUCCESS(res); + } + + /// + /// 删除店铺 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "business:shop: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 = _ShopService.Delete(idsArr); + return SUCCESS("删除成功!"); + } + + + /// + /// 导出店铺 + /// + /// + [Log(Title = "店铺导出", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)] + [HttpGet("exportShop")] + [ActionPermissionFilter(Permission = "business:shop:export")] + public async Task ExportExcel([FromQuery] ShopQueryDto parm) + { + parm.PageSize = 10000; + var list = await _ShopService.GetShopList(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.ShopId == item).First(); + selectDataList.Add(select_data); + } + data = selectDataList; + } + + + + // 导出数据处理 + var handleData = await _ShopService.HandleExportData(data); + + string sFileName = ExportExcel(handleData, "Shop", "店铺列表"); + return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName }); + } + + /// + /// 审核店铺 + /// + /// + [HttpPut("audit")] + [ActionPermissionFilter(Permission = "business:shop:audit")] + [Log(Title = "审核店铺", BusinessType = BusinessType.AUDIT)] + public async Task AuditShop([FromBody] ShopAuditDto param) + { + var user = JwtUtil.GetLoginUser(App.HttpContext); + int[] idsArr = Tools.SpitIntArrary(param.ids); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"审核失败 Id 不能为空")); } + + var msgList = new List(); + foreach (var item in idsArr) + { + var msg = await _ShopService.Audit(item, param.ShopAuditStatus, user.UserId); + msgList.Add(msg); + } + + return SUCCESS(msgList.ToArray()); + } + + + + } +} diff --git a/ARW.WebApi/appsettings.json b/ARW.WebApi/appsettings.json index 9340c03..7c81618 100644 --- a/ARW.WebApi/appsettings.json +++ b/ARW.WebApi/appsettings.json @@ -7,7 +7,7 @@ } }, "ConnectionStrings": { - "conn_db": "server=47.242.159.172;Database=shop_template;Uid=shop_template;Pwd=TWYrxjCiEnmP6aBi;SslMode=none;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=true;", + "conn_db": "server=47.242.159.172;Database=shop_template;Uid=shop_template;Pwd=tKFJjWwL2kxMYtJK;SslMode=none;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=true;", //"conn_db": "server=127.0.0.1;Database= shop_template;Uid=root;Pwd=root;SslMode=none;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=true;", "conn_db_type": "8" //数据库类型 MySql = 0, SqlServer = 1 }, @@ -41,7 +41,7 @@ "templateCode": "SMS_154950909" }, "gen": { - "conn": "server=47.242.159.172;Database=shop_template;Uid=shop_template;Pwd=TWYrxjCiEnmP6aBi;SslMode=none;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=true;", + "conn": "server=47.242.159.172;Database=shop_template;Uid=shop_template;Pwd=tKFJjWwL2kxMYtJK;SslMode=none;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=true;", //"conn": "server=127.0.0.1;Database= shop_template;Uid=root;Pwd=root;SslMode=none;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=true;", "dbType": 8, //MySql = 0, SqlServer = 1 "autoPre": true, //自动去除表前缀