init 初始化配送模板
This commit is contained in:
parent
fcd62fa197
commit
28b1014676
@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Models.Business.LogisticsManage.Deliverys;
|
||||
|
||||
namespace ARW.Model.Dto.Business.LogisticsManage.Deliverys
|
||||
{
|
||||
/// <summary>
|
||||
/// 配送模板输入对象
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-16
|
||||
/// </summary>
|
||||
public class DeliveryDto
|
||||
{
|
||||
|
||||
public int DeliveryId { get; set; }
|
||||
|
||||
public long DeliveryGuid { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "店铺guid不能为空")]
|
||||
public long ShopGuid { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "模板名称不能为空")]
|
||||
public string DeliveryName { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "计费方式不能为空")]
|
||||
public int DeliveryBillingMethod { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "排序不能为空")]
|
||||
public int DeliverySort { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 配送模板查询对象
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-16
|
||||
/// </summary>
|
||||
public class DeliveryQueryDto : PagerInfo
|
||||
{
|
||||
|
||||
public long? ShopGuid { get; set; }
|
||||
|
||||
public string DeliveryName { get; set; }
|
||||
|
||||
public int? DeliveryBillingMethod { get; set; }
|
||||
|
||||
public string ids { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SqlSugar;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ARW.Model.Models.Business.LogisticsManage.Deliverys
|
||||
{
|
||||
/// <summary>
|
||||
/// 配送模板,数据实体对象
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-16
|
||||
/// </summary>
|
||||
[SugarTable("tb_delivery")]
|
||||
public class Delivery : BusinessBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "DeliveryId")]
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "delivery_id")]
|
||||
public int DeliveryId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "DeliveryGuid")]
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "delivery_guid")]
|
||||
public long DeliveryGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :店铺guid
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "店铺guid")]
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(ColumnName = "shop_guid")]
|
||||
public long ShopGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :模板名称
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "模板名称")]
|
||||
[SugarColumn(ColumnName = "delivery_name")]
|
||||
public string DeliveryName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :计费方式
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "计费方式")]
|
||||
[SugarColumn(ColumnName = "delivery_billing_method")]
|
||||
public int DeliveryBillingMethod { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :排序
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "排序")]
|
||||
[SugarColumn(ColumnName = "delivery_sort")]
|
||||
public int DeliverySort { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ARW.Model.Vo.Business.LogisticsManage.Deliverys
|
||||
{
|
||||
/// <summary>
|
||||
/// 配送模板展示对象
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-16
|
||||
/// </summary>
|
||||
public class DeliveryVo
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public int DeliveryId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusIgnore]
|
||||
public long DeliveryGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :店铺guid
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusTableColumn(Header = "店铺guid")]
|
||||
public long ShopGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :模板名称
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "模板名称")]
|
||||
public string DeliveryName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :计费方式
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "计费方式")]
|
||||
public int DeliveryBillingMethod { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :排序
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "排序")]
|
||||
public int DeliverySort { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using Infrastructure.Attribute;
|
||||
using ARW.Repository.System;
|
||||
using ARW.Model.Models.Business.LogisticsManage.Deliverys;
|
||||
|
||||
namespace ARW.Repository.Business.LogisticsManage.Deliverys
|
||||
{
|
||||
/// <summary>
|
||||
/// 配送模板仓储
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-16
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class DeliveryRepository : BaseRepository<Delivery>
|
||||
{
|
||||
#region 业务逻辑代码
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -196,16 +196,16 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.ShopGoodsCategorys
|
||||
{
|
||||
try
|
||||
{
|
||||
var category = await HandleImportData(ShopGoodsCategoryVo, user.UserId,index);
|
||||
var category = await HandleImportData(ShopGoodsCategoryVo, user.UserId, index);
|
||||
var ShopGoodsCategory = new ShopGoodsCategory
|
||||
{
|
||||
ShopGoodsCategoryId= category.ShopGoodsCategoryId,
|
||||
ShopGoodsCategoryGuid= category.ShopGoodsCategoryGuid,
|
||||
ShopGoodsCategoryId = category.ShopGoodsCategoryId,
|
||||
ShopGoodsCategoryGuid = category.ShopGoodsCategoryGuid,
|
||||
ShopGuid = category.ShopGuid,
|
||||
ShopGoodsCategoryParentGuid = category.ShopGoodsCategoryParentGuid,
|
||||
ShopGoodsCategoryName = category.ShopGoodsCategoryName,
|
||||
ShopGoodsCategoryDisplayStatus = category.ShopGoodsCategoryDisplayStatus,
|
||||
ShopGoodsCategorySort = category.ShopGoodsCategorySort
|
||||
ShopGoodsCategorySort = category.ShopGoodsCategorySort
|
||||
};
|
||||
|
||||
if (isUpdateSupport)
|
||||
|
@ -0,0 +1,104 @@
|
||||
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.LogisticsManage.Deliverys;
|
||||
using ARW.Service.Business.IBusinessService.LogisticsManage.Deliverys;
|
||||
using ARW.Model.Dto.Business.LogisticsManage.Deliverys;
|
||||
using ARW.Model.Models.Business.LogisticsManage.Deliverys;
|
||||
using ARW.Model.Vo.Business.LogisticsManage.Deliverys;
|
||||
|
||||
namespace ARW.Service.Business.BusinessService.LogisticsManage.Deliverys
|
||||
{
|
||||
/// <summary>
|
||||
/// 配送模板接口实现类
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-16
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IDeliveryService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class DeliveryServiceImpl : BaseService<Delivery>, IDeliveryService
|
||||
{
|
||||
private readonly DeliveryRepository _DeliveryRepository;
|
||||
|
||||
public DeliveryServiceImpl(DeliveryRepository DeliveryRepository)
|
||||
{
|
||||
this._DeliveryRepository = DeliveryRepository;
|
||||
}
|
||||
|
||||
#region 业务逻辑代码
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询配送模板分页列表
|
||||
/// </summary>
|
||||
public async Task<PagedInfo<DeliveryVo>> GetDeliveryList(DeliveryQueryDto parm)
|
||||
{
|
||||
//开始拼装查询条件d
|
||||
var predicate = Expressionable.Create<Delivery>();
|
||||
|
||||
//predicate = predicate.AndIF(parm.ShopGuid != null, s => s.ShopGuid.Contains(parm.ShopGuid));
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.DeliveryName), s => s.DeliveryName.Contains(parm.DeliveryName));
|
||||
predicate = predicate.AndIF(parm.DeliveryBillingMethod != null, s => s.DeliveryBillingMethod == parm.DeliveryBillingMethod);
|
||||
var query = _DeliveryRepository
|
||||
.Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy(s => s.DeliverySort, OrderByType.Asc)
|
||||
.Select(s => new DeliveryVo
|
||||
{
|
||||
DeliveryId = s.DeliveryId,
|
||||
DeliveryGuid = s.DeliveryGuid,
|
||||
ShopGuid = s.ShopGuid,
|
||||
DeliveryName = s.DeliveryName,
|
||||
DeliveryBillingMethod = s.DeliveryBillingMethod,
|
||||
DeliverySort = s.DeliverySort,
|
||||
});
|
||||
|
||||
|
||||
return await query.ToPageAsync(parm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改配送模板
|
||||
/// </summary>
|
||||
public async Task<string> AddOrUpdateDelivery(Delivery model)
|
||||
{
|
||||
if (model.DeliveryId != 0)
|
||||
{
|
||||
var response = await _DeliveryRepository.UpdateAsync(model);
|
||||
return "修改成功!";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var response = await _DeliveryRepository.InsertReturnSnowflakeIdAsync(model);
|
||||
return "添加成功!";
|
||||
}
|
||||
}
|
||||
|
||||
#region Excel处理
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Excel数据导出处理
|
||||
/// </summary>
|
||||
public async Task<List<DeliveryVo>> HandleExportData(List<DeliveryVo> data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -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.LogisticsManage.Deliverys;
|
||||
using ARW.Model.Models.Business.LogisticsManage.Deliverys;
|
||||
using ARW.Model.Vo.Business.LogisticsManage.Deliverys;
|
||||
|
||||
namespace ARW.Service.Business.IBusinessService.LogisticsManage.Deliverys
|
||||
{
|
||||
/// <summary>
|
||||
/// 配送模板接口类
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-16
|
||||
/// </summary>
|
||||
public interface IDeliveryService : IBaseService<Delivery>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取配送模板分页列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedInfo<DeliveryVo>> GetDeliveryList(DeliveryQueryDto parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改配送模板
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> AddOrUpdateDelivery(Delivery parm);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Excel导出
|
||||
/// </summary>
|
||||
Task<List<DeliveryVo>> HandleExportData(List<DeliveryVo> data);
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -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.LogisticsManage.Deliverys;
|
||||
using ARW.Service.Business.IBusinessService.LogisticsManage.Deliverys;
|
||||
using ARW.Admin.WebApi.Controllers;
|
||||
using ARW.Model.Models.Business.LogisticsManage.Deliverys;
|
||||
using ARW.Model.Vo.Business.LogisticsManage.Deliverys;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using ARW.Admin.WebApi.Framework;
|
||||
|
||||
|
||||
namespace ARW.WebApi.Controllers.Business.LogisticsManage.Deliverys
|
||||
{
|
||||
/// <summary>
|
||||
/// 配送模板控制器
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-16
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("business/[controller]")]
|
||||
public class DeliveryController : BaseController
|
||||
{
|
||||
private readonly IDeliveryService _DeliveryService;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖注入
|
||||
/// </summary>
|
||||
/// <param name="DeliveryService">配送模板服务</param>
|
||||
public DeliveryController(IDeliveryService DeliveryService)
|
||||
{
|
||||
_DeliveryService = DeliveryService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取配送模板列表
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getDeliveryList")]
|
||||
[ActionPermissionFilter(Permission = "business:delivery:list")]
|
||||
public async Task<IActionResult> GetDeliveryList([FromQuery] DeliveryQueryDto parm)
|
||||
{
|
||||
var res = await _DeliveryService.GetDeliveryList(parm);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改配送模板
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("addOrUpdateDelivery")]
|
||||
[ActionPermissionFilter(Permission = "business:delivery:addOrUpdate")]
|
||||
[Log(Title = "添加或修改配送模板", BusinessType = BusinessType.ADDORUPDATE)]
|
||||
public async Task<IActionResult> AddOrUpdateDelivery([FromBody] DeliveryDto parm)
|
||||
{
|
||||
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||
|
||||
var modal = new Delivery();
|
||||
if (parm.DeliveryId != 0) modal = parm.Adapt<Delivery>().ToUpdate(HttpContext);
|
||||
else modal = parm.Adapt<Delivery>().ToCreate(HttpContext);
|
||||
|
||||
var res = await _DeliveryService.AddOrUpdateDelivery(modal);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除配送模板
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpDelete("{ids}")]
|
||||
[ActionPermissionFilter(Permission = "business:delivery: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 = _DeliveryService.Delete(idsArr);
|
||||
return SUCCESS("删除成功!");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 导出配送模板
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Log(Title = "配送模板导出", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
|
||||
[HttpGet("exportDelivery")]
|
||||
[ActionPermissionFilter(Permission = "business:delivery:export")]
|
||||
public async Task<IActionResult> ExportExcel([FromQuery] DeliveryQueryDto parm)
|
||||
{
|
||||
parm.PageSize = 10000;
|
||||
var list = await _DeliveryService.GetDeliveryList(parm);
|
||||
var data = list.Result;
|
||||
|
||||
// 选中数据
|
||||
if (!string.IsNullOrEmpty(parm.ids))
|
||||
{
|
||||
int[] idsArr = Tools.SpitIntArrary(parm.ids);
|
||||
var selectDataList = new List<DeliveryVo>();
|
||||
foreach (var item in idsArr)
|
||||
{
|
||||
var select_data = data.Where(s => s.DeliveryId == item).First();
|
||||
selectDataList.Add(select_data);
|
||||
}
|
||||
data = selectDataList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 导出数据处理
|
||||
var handleData = await _DeliveryService.HandleExportData(data);
|
||||
|
||||
string sFileName = ExportExcel(handleData, "Delivery", "配送模板列表");
|
||||
return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user