feat 添加店铺管理审核后分发账号,后台菜单权限

This commit is contained in:
lwh 2023-06-15 15:16:11 +08:00
parent b5d9841156
commit a106678947
18 changed files with 399 additions and 19 deletions

View File

@ -25,7 +25,6 @@
<ItemGroup>
<Folder Include="Dto\Api\" />
<Folder Include="Vo\Api\" />
</ItemGroup>
</Project>

View File

@ -29,6 +29,11 @@ namespace ARW.Model.Dto.Business.Custom.Customers
[Required(ErrorMessage = "小程序openid不能为空")]
public string CustomerXcxOpenid { get; set; }
public string CustomerType { get; set; }
public string CustomerEmail { get; set; }
[Required(ErrorMessage = "昵称不能为空")]
public string CustomerNickname { get; set; }

View File

@ -2,6 +2,9 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using ARW.Model.Models.Business.ShopManager.Shops;
using MimeKit;
using OfficeOpenXml.Attributes;
using SqlSugar;
namespace ARW.Model.Dto.Business.ShopManager.Shops
{
@ -37,16 +40,12 @@ namespace ARW.Model.Dto.Business.ShopManager.Shops
[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; }
@ -114,4 +113,35 @@ namespace ARW.Model.Dto.Business.ShopManager.Shops
}
/// <summary>
/// 商户店铺查询对象
///
/// @author 黎文豪
/// @date 2023-06-09
/// </summary>
public class ShopOperatorQueryDto
{
public long ShopGuid { get; set; }
}
/// <summary>
/// 商户店铺编辑对象
///
/// @author 黎文豪
/// @date 2023-06-09
/// </summary>
public class ShopOperatorEditDto
{
public long ShopGuid { get; set; }
public string ShopLogo { get; set; }
public string ShopName { get; set; }
public string ShopIntro { get; set; }
}
}

View File

@ -91,6 +91,15 @@ namespace ARW.Model.Models.Business.Custom.Customers
public string CustomerXcxOpenid { get; set; }
/// <summary>
/// 描述 : 客户类型(1: 普通用户 2: 商户 )
/// 空值 : false
/// </summary>
[EpplusTableColumn(Header = "客户类型")]
[SugarColumn(ColumnName = "customer_type")]
public int CustomerType { get; set; }
/// <summary>
/// 描述 :昵称
/// 空值 : false
@ -108,6 +117,14 @@ namespace ARW.Model.Models.Business.Custom.Customers
[SugarColumn(ColumnName = "customer_mobile_phone_number")]
public string CustomerMobilePhoneNumber { get; set; }
/// <summary>
/// 描述 :电子邮箱
/// 空值 : false
/// </summary>
[EpplusTableColumn(Header = "电子邮箱")]
[SugarColumn(ColumnName = "customer_email")]
public string CustomerEmail { get; set; }
/// <summary>
/// 描述 :头像

View File

@ -26,6 +26,8 @@ namespace ARW.Model.Vo.Api.Custom.Customers
public string CustomerAvatar { get; set; }
[EpplusTableColumn(Header = "性别")]
public int CustomerGender { get; set; }
[EpplusTableColumn(Header = "客户类型")]
public int CustomerType { get; set; }
//[EpplusTableColumn(Header = "可用积分")]

View File

@ -0,0 +1,32 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
namespace ARW.Model.Vo.Api.ShopManager.Shops
{
/// <summary>
/// 经营类目对象Api
///
/// @author 黎文豪
/// @date 2023-06-13
/// </summary>
public class GoodsCategoryVoApi
{
/// <summary>
/// 描述 :名称
/// </summary>
public string Label { get; set; }
/// <summary>
/// 描述 :值
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
public long Value { get; set; }
}
}

View File

@ -31,7 +31,11 @@ namespace ARW.Model.Vo.Business.Custom.Customers
/// <summary>
/// 描述 :客户类型
/// </summary>
[EpplusTableColumn(Header = "客户类型")]
public int CustomerType{ get; set; }
@ -56,6 +60,13 @@ namespace ARW.Model.Vo.Business.Custom.Customers
public string CustomerMobilePhoneNumber { get; set; }
/// <summary>
/// 描述 :电子邮箱
/// </summary>
[EpplusTableColumn(Header = "电子邮箱")]
public string CustomerEmail { get; set; }
/// <summary>
/// 描述 :头像
/// </summary>
@ -66,7 +77,7 @@ namespace ARW.Model.Vo.Business.Custom.Customers
/// <summary>
/// 描述 :性别(字典)
/// </summary>
[EpplusTableColumn(Header = "性别(字典)")]
[EpplusTableColumn(Header = "性别")]
public int CustomerGender { get; set; }

View File

@ -128,4 +128,75 @@ namespace ARW.Model.Vo.Business.ShopManager.Shops
public string CreateTime { get; set; }
}
/// <summary>
/// 店铺详情展示对象
///
/// @author 黎文豪
/// @date 2023-06-015
/// </summary>
public class ShopDetailVo
{
/// <summary>
/// 描述 :
/// </summary>
public int ShopId { get; set; }
/// <summary>
/// 描述 :
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
public long ShopGuid { get; set; }
/// <summary>
/// 描述 :经营类目guid
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
public long ShopBusinessCategoryGuid { get; set; }
/// <summary>
/// 经营类别名称
/// </summary>
public string ShopBusinessCategoryName { get; set; }
/// <summary>
/// 描述 :图标
/// </summary>
public string ShopLogo { get; set; }
/// <summary>
/// 描述 :营业执照
/// </summary>
public string ShopBusinessLicense { get; set; }
/// <summary>
/// 描述 :名称
/// </summary>
public string ShopName { get; set; }
/// <summary>
/// 描述 :简介
/// </summary>
public string ShopIntro { get; set; }
/// <summary>
/// 描述 :销售单量
/// </summary>
public int ShopSalesOrderCount { get; set; }
}
}

View File

@ -53,6 +53,7 @@ namespace ARW.Service.Api.BusinessService.Custom.Customers
CustomerMobilePhoneNumber = s.CustomerMobilePhoneNumber,
CustomerAvatar = s.CustomerAvatar,
CustomerGender = s.CustomerGender,
CustomerType = s.CustomerType
}).Take(1);

View File

@ -13,6 +13,10 @@ using ARW.Service.Api.IBusinessService.ShopManager.Shops;
using ARW.Model.Dto.Api.ShopManager.Shops;
using ARW.Model.Models.Business.ShopManager.Shops;
using ARW.Model.Vo.Api.ShopManager.Shops;
using ARW.Model.Vo.Business.GoodsManager.GoodsCategorys;
using ARW.Repository.Business.GoodsManager.GoodsCategorys;
using ARW.Repository.Business.Custom.Customers;
using ARW.Model.Models.Business.Custom.Customers;
namespace ARW.Service.Api.BusinessService.ShopManager.Shops
{
@ -26,15 +30,41 @@ namespace ARW.Service.Api.BusinessService.ShopManager.Shops
public class ShopServiceImplApi : BaseService<Shop>, IShopServiceApi
{
private readonly ShopRepository _ShopRepository;
private readonly GoodsCategoryRepository _GoodsCategoryRepository;
private readonly CustomerRepository _CustomerRepository;
public ShopServiceImplApi(ShopRepository ShopRepository)
public ShopServiceImplApi(ShopRepository ShopRepository, GoodsCategoryRepository goodsCategoryRepository, CustomerRepository customerRepository)
{
this._ShopRepository = ShopRepository;
_GoodsCategoryRepository = goodsCategoryRepository;
_CustomerRepository = customerRepository;
}
#region Api接口代码
/// <summary>
/// 获取经营类目列表(一级类目)
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public async Task<List<GoodsCategoryVoApi>> GetFirstGoodsCategoryList()
{
var query = _GoodsCategoryRepository
.Queryable()
.Where(s => s.GoodsCategoryParentGuid == 0)
.OrderBy(s => s.Update_time, OrderByType.Desc)
.Select((s) => new GoodsCategoryVoApi
{
Label = s.GoodsCategoryName,
Value = s.GoodsCategoryGuid,
});
return await query.ToListAsync();
}
/// <summary>
/// 查询店铺列表(Api)
/// </summary>
@ -117,8 +147,24 @@ namespace ARW.Service.Api.BusinessService.ShopManager.Shops
}
else
{
// 判断客户类型是否为商户
var customer = await _CustomerRepository.GetFirstAsync(s => s.CustomerGuid == model.ShopCustomerGuid);
if (customer == null) throw new Exception("找不到该客户");
if (customer.CustomerType == 2)
{
return "您已经是商户";
}
model.ShopAuditStatus = 1;
model.ShopSort = 100;
var response = await _ShopRepository.InsertReturnSnowflakeIdAsync(model);
// 修改客户类型为 商户(2)
await _CustomerRepository.UpdateAsync(f => new Customer
{
CustomerType = 2
}, s => s.CustomerGuid == model.ShopCustomerGuid);
return "添加成功!";
}
}

View File

@ -7,6 +7,7 @@ using ARW.Model;
using ARW.Model.Dto.Api.ShopManager.Shops;
using ARW.Model.Models.Business.ShopManager.Shops;
using ARW.Model.Vo.Api.ShopManager.Shops;
using ARW.Model.Vo.Business.GoodsManager.GoodsCategorys;
namespace ARW.Service.Api.IBusinessService.ShopManager.Shops
{
@ -18,7 +19,13 @@ namespace ARW.Service.Api.IBusinessService.ShopManager.Shops
/// </summary>
public interface IShopServiceApi : IBaseService<Shop>
{
/// <summary>
/// <summary>
/// 获取经营类目列表(一级类目)
/// </summary>
/// <returns></returns>
Task<List<GoodsCategoryVoApi>> GetFirstGoodsCategoryList();
/// <summary>
/// 获取店铺分页列表(Api)
/// </summary>
/// <param name="parm"></param>
@ -40,5 +47,6 @@ namespace ARW.Service.Api.IBusinessService.ShopManager.Shops
/// <returns></returns>
Task<string> AddOrUpdateShop(Shop parm);
}
}

View File

@ -56,6 +56,7 @@ namespace ARW.Service.Business.BusinessService.Custom.Customers
{
CustomerId = s.CustomerId,
CustomerGuid = s.CustomerGuid,
CustomerType = s.CustomerType,
CustomerXcxOpenid = s.CustomerXcxOpenid,
CustomerNickname = s.CustomerNickname,
CustomerMobilePhoneNumber = s.CustomerMobilePhoneNumber,

View File

@ -22,6 +22,11 @@ using ARW.Repository.System;
using ARW.Model.Vo.Business.GoodsManager.GoodsCategorys;
using ARW.Repository.Business.GoodsManager.GoodsCategorys;
using ARW.Model.Models.Business.GoodsManager.GoodsCategorys;
using ARW.Service.System.IService;
using ARW.Service.System;
using MimeKit.Encodings;
using ARW.Model.Dto.Api.ShopManager.Shops;
using ARW.Model.Vo.Api.ShopManager.Shops;
namespace ARW.Service.Business.BusinessService.ShopManager.Shops
{
@ -39,13 +44,18 @@ namespace ARW.Service.Business.BusinessService.ShopManager.Shops
private readonly SysUserRepository _SysUserRepository;
private readonly GoodsCategoryRepository _GoodsCategoryRepository;
private readonly ISysUserService UserService;
private readonly ISysConfigService _SysConfigService;
public ShopServiceImpl(ShopRepository ShopRepository, CustomerRepository customerRepository, SysUserRepository sysUserRepository, GoodsCategoryRepository goodsCategoryRepository)
public ShopServiceImpl(ShopRepository ShopRepository, CustomerRepository customerRepository, SysUserRepository sysUserRepository, GoodsCategoryRepository goodsCategoryRepository, ISysUserService userService, ISysConfigService sysConfigService)
{
this._ShopRepository = ShopRepository;
_CustomerRepository = customerRepository;
_SysUserRepository = sysUserRepository;
_GoodsCategoryRepository = goodsCategoryRepository;
UserService = userService;
_SysConfigService = sysConfigService;
}
#region
@ -68,7 +78,7 @@ namespace ARW.Service.Business.BusinessService.ShopManager.Shops
.LeftJoin<GoodsCategory>((s, c, d, f) => s.ShopBusinessCategoryGuid == f.GoodsCategoryGuid)
.Where(predicate.ToExpression())
.OrderBy(s => s.ShopSort, OrderByType.Asc)
.Select((s, c, d,f) => new ShopVo
.Select((s, c, d, f) => new ShopVo
{
UserName = c.UserName,
CustomerNickname = d.CustomerNickname,
@ -218,9 +228,9 @@ namespace ARW.Service.Business.BusinessService.ShopManager.Shops
{
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);
});
{
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}】<span style='color:red'>已通过审核!</span><br>";
@ -234,6 +244,37 @@ namespace ARW.Service.Business.BusinessService.ShopManager.Shops
else if (res.ShopAuditStatus == 1)
{
var addStr = $"店铺:【{res.ShopName}】<span style='color:#27af49'>审核通过!</span><br>";
// 分发后台用户账户
var customer = await _CustomerRepository.GetFirstAsync(s => s.CustomerGuid == res.ShopCustomerGuid);
long[] roleId = new long[] { 3 };
int[] postId = Array.Empty<int>();
if (UserConstants.NOT_UNIQUE.Equals(UserService.CheckUserNameUnique(customer.CustomerMobilePhoneNumber)))
{
throw new Exception($"新增用户 '{customer.CustomerMobilePhoneNumber}'失败,登录账号已存在");
}
var initPassword = _SysConfigService.Queryable().First(f => f.ConfigKey == "sys.user.initPassword");
var password = NETCore.Encrypt.EncryptProvider.Md5(initPassword.ConfigValue);
var user = new SysUser
{
UserName = customer.CustomerMobilePhoneNumber,
NickName = customer.CustomerNickname,
Password = password,
Avatar = customer.CustomerAvatar,
Phonenumber = customer.CustomerMobilePhoneNumber,
Sex = customer.CustomerGender.ToString(),
Status = "0",
RoleIds = roleId,
PostIds = postId
};
var userId = UserService.InsertUser(user);
if (userId == 0) throw new Exception($"新增用户 '{customer.CustomerMobilePhoneNumber}'失败");
await _ShopRepository.UpdateAsync(f => new Shop
{
ShopUserId = (int?)userId,
}, s => s.ShopId == id);
return addStr;
}
return "";
@ -244,6 +285,35 @@ namespace ARW.Service.Business.BusinessService.ShopManager.Shops
}
}
/// <summary>
/// 获取商户店铺详情
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public Task<string> GetShopOperatorDetail(ShopOperatorQueryDto parm)
{
var query = _ShopRepository
.Queryable()
.Where(s => s.ShopGuid == parm.ShopGuid)
.Select(s => new ShopDetailVo
{
ShopId = s.ShopId,
ShopGuid = s.ShopGuid,
ShopBusinessCategoryGuid = s.ShopBusinessCategoryGuid,
ShopLogo = s.ShopLogo,
ShopBusinessLicense = s.ShopBusinessLicense,
ShopName = s.ShopName,
ShopIntro = s.ShopIntro,
ShopSalesOrderCount = s.ShopSalesOrderCount,
}).Take(1);
return query.ToJsonAsync();
}
#endregion
}

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ARW.Model;
using ARW.Model.Dto.Api.ShopManager.Shops;
using ARW.Model.Dto.Business.ShopManager.Shops;
using ARW.Model.Models.Business.ShopManager.Shops;
using ARW.Model.Vo.Business.GoodsManager.GoodsCategorys;
@ -69,5 +70,13 @@ namespace ARW.Service.Business.IBusinessService.ShopManager.Shops
/// </summary>
Task<string> Audit(int idsArr, int status,long userGuid);
/// <summary>
/// 获取商户店铺详情
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
Task<string> GetShopOperatorDetail(ShopOperatorQueryDto parm);
}
}

View File

@ -17,6 +17,8 @@ using Microsoft.AspNetCore.Authorization;
using Geocoding;
using ARW.Model.Dto.Business.ShopManager.Shops;
using ARW.Service.Business.IBusinessService.ShopManager.Shops;
using ARW.Model.Vo.Business.GoodsManager.GoodsCategorys;
using ARW.Admin.WebApi.Framework;
namespace ARW.WebApi.Controllers.Api.ShopManager.Shops
{
@ -43,7 +45,19 @@ namespace ARW.WebApi.Controllers.Api.ShopManager.Shops
/// <summary>
/// 获取店铺列表(Api)
/// 获取经营类目列表(一级类目)
/// </summary>
/// <returns></returns>
[HttpGet("getFirstGoodsCategoryList")]
public async Task<IActionResult> GetFirstGoodsCategoryList()
{
var res = await _ShopServiceApi.GetFirstGoodsCategoryList();
return SUCCESS(res);
}
/// <summary>
/// 获取经营类目(Api)
/// </summary>
/// <param name="parm">查询参数</param>
/// <returns></returns>
@ -70,8 +84,11 @@ namespace ARW.WebApi.Controllers.Api.ShopManager.Shops
if (parm.ShopId != 0) modal = parm.Adapt<Shop>().ToUpdate(HttpContext);
else modal = parm.Adapt<Shop>().ToCreate(HttpContext);
//var res = await _ShopServiceApi.AddOrUpdateShop(modal);
//return SUCCESS(res);
var user = JwtUtil.GetLoginUser(App.HttpContext);
modal.ShopCustomerGuid = user.UserId;
var res = await _ShopServiceApi.AddOrUpdateShop(modal);
return SUCCESS(res);
}

View File

@ -61,6 +61,7 @@ namespace ARW.WebApi.Controllers.Api.Wechat
addModal.CustomerAvatar = "https://cdn-we-retail.ym.tencent.com/miniapp/usercenter/icon-user-center-avatar@2x.png";
addModal.CustomerNickname = "用户" + addModal.CustomerMobilePhoneNumber.Substring(addModal.CustomerMobilePhoneNumber.Length - 4); ;
addModal.CustomerGender = 1;
addModal.CustomerType = 1;
addModal.CustomerLastLoginTime = DateTime.Now;
var response = await _customerService.InsertReturnSnowflakeIdAsync(addModal);
if (response == 0)

View File

@ -16,6 +16,8 @@ using ARW.Model.Vo.Business.ShopManager.Shops;
using Microsoft.AspNetCore.Authorization;
using ARW.Admin.WebApi.Framework;
using ARW.Model.Vo.Business.GoodsManager.GoodsCategorys;
using ARW.Model.Vo.Api.ShopManager.Shops;
using Geocoding;
namespace ARW.WebApi.Controllers.Business.ShopManager.Shops
{
@ -200,5 +202,63 @@ namespace ARW.WebApi.Controllers.Business.ShopManager.Shops
#region
/// <summary>
/// 获取商户店铺详情
/// </summary>
/// <param name="parm">查询参数</param>
/// <returns></returns>
[HttpGet("getShopOperatorDetail")]
[ActionPermissionFilter(Permission = "business:shopOperator:detail")]
public async Task<IActionResult> GetShopOperatorDetail([FromQuery] ShopOperatorQueryDto parm)
{
var user = JwtUtil.GetLoginUser(App.HttpContext);
var shop = await _ShopService.GetFirstAsync(s => s.ShopUserId == user.UserId);
if (shop == null) throw new Exception("当前用户没有店铺!");
parm.ShopGuid = shop.ShopGuid;
var res = await _ShopService.GetShopOperatorDetail(parm);
if (res != "[]")
{
res = res.Remove(0, 1);
res = res.Substring(0, res.Length - 1);
var data = res.FromJSON<ShopDetailVo>();
return SUCCESS(data);
}
else
{
return SUCCESS(res);
}
}
/// <summary>
/// 获取商户店铺详情
/// </summary>
/// <param name="parm">查询参数</param>
/// <returns></returns>
[HttpPost("editShopOperatorDetail")]
public async Task<IActionResult> EditShopOperatorDetail([FromBody] ShopOperatorEditDto parm)
{
var user = JwtUtil.GetLoginUser(App.HttpContext);
var shop = await _ShopService.GetFirstAsync(s => s.ShopUserId == user.UserId);
var res = await _ShopService.UpdateAsync(f => new Shop
{
ShopName = parm.ShopName,
ShopIntro = parm.ShopIntro,
ShopLogo = parm.ShopLogo
},s => s.ShopGuid == shop.ShopGuid);
return SUCCESS(res);
}
#endregion
}
}

View File

@ -11,7 +11,7 @@
//"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
},
"urls": "http://192.168.1.102:8888", //urldevServer
"urls": "http://localhost:8888", //urldevServer
"corsUrls": "http://localhost:8887", //","
"JwtSettings": {
"Issuer": "ARWAdmin.NET",
@ -22,7 +22,7 @@
"InitDb": false, //db
"DemoMode": false, //
"Upload": {
"UploadUrl": "http://192.168.1.102:8888", //访
"UploadUrl": "http://localhost:8888", //访
"localSavePath": "uploads" // wwwroot/Uploads/uploads
},
//