fixed 完善后台优惠券接口 50%
This commit is contained in:
parent
d8188a9ce1
commit
c975350899
@ -54,6 +54,8 @@ namespace ARW.Model.Dto.Business.Marketing.CouponManage.Coupons
|
|||||||
[Required(ErrorMessage = "排序不能为空")]
|
[Required(ErrorMessage = "排序不能为空")]
|
||||||
public int CouponSort { get; set; }
|
public int CouponSort { get; set; }
|
||||||
|
|
||||||
|
public string CouponApplicableScopeConfig { get; set; }
|
||||||
|
public string CouponGoodsIds { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,6 +134,15 @@ namespace ARW.Model.Models.Business.Marketing.CouponManage.Coupons
|
|||||||
public string CouponApplicableScopeConfig { get; set; }
|
public string CouponApplicableScopeConfig { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :适用范围(指定商品的Id集)
|
||||||
|
/// 空值 : true
|
||||||
|
/// </summary>
|
||||||
|
[EpplusTableColumn(Header = "适用范围(指定商品的Id集)")]
|
||||||
|
[SugarColumn(ColumnName = "coupon_goods_ids")]
|
||||||
|
public string CouponGoodsIds { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 描述 :发送数量(-1不限制)
|
/// 描述 :发送数量(-1不限制)
|
||||||
/// 空值 : false
|
/// 空值 : false
|
||||||
|
@ -58,11 +58,16 @@ namespace ARW.Model.Vo.Business.GoodsManager.Goodss
|
|||||||
[EpplusTableColumn(Header = "划线价格")]
|
[EpplusTableColumn(Header = "划线价格")]
|
||||||
public decimal GoodsDashedPriceLowest { get; set; }
|
public decimal GoodsDashedPriceLowest { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 库存总量
|
||||||
|
/// </summary>
|
||||||
|
public int GoodsTotalInventory { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 描述 :上下架状态(1上架 2下架)
|
/// 描述 :上下架状态(1上架 2下架)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EpplusIgnore]
|
[EpplusIgnore]
|
||||||
public int GoodsShelfStatus { get; set; }
|
public int GoodsShelfStatus { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,5 +122,12 @@ namespace ARW.Model.Vo.Business.Marketing.CouponManage.Coupons
|
|||||||
[EpplusTableColumn(Header = "排序")]
|
[EpplusTableColumn(Header = "排序")]
|
||||||
public int CouponSort { get; set; }
|
public int CouponSort { get; set; }
|
||||||
|
|
||||||
|
[EpplusIgnore]
|
||||||
|
public string CouponApplicableScopeConfig { get; set; }
|
||||||
|
|
||||||
|
[EpplusIgnore]
|
||||||
|
public string CouponGoodsIdsArr { get; set; }
|
||||||
|
[EpplusIgnore]
|
||||||
|
public string[] CouponGoodsIds { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,6 +217,7 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.Goodss
|
|||||||
GoodsDashedPriceLowest = s.GoodsDashedPriceLowest,
|
GoodsDashedPriceLowest = s.GoodsDashedPriceLowest,
|
||||||
GoodsShelfStatus = s.GoodsShelfStatus,
|
GoodsShelfStatus = s.GoodsShelfStatus,
|
||||||
GoodsSort = s.GoodsSort,
|
GoodsSort = s.GoodsSort,
|
||||||
|
GoodsTotalInventory = s.GoodsTotalInventory,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,13 +33,13 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
|||||||
this._CouponRepository = CouponRepository;
|
this._CouponRepository = CouponRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 业务逻辑代码
|
#region 业务逻辑代码
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询优惠券分页列表
|
/// 查询优惠券分页列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<PagedInfo<CouponVo>> GetCouponList(CouponQueryDto parm)
|
public async Task<PagedInfo<CouponVo>> GetCouponList(CouponQueryDto parm)
|
||||||
{
|
{
|
||||||
//开始拼装查询条件d
|
//开始拼装查询条件d
|
||||||
var predicate = Expressionable.Create<Coupon>();
|
var predicate = Expressionable.Create<Coupon>();
|
||||||
@ -52,31 +52,40 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
|||||||
var query = _CouponRepository
|
var query = _CouponRepository
|
||||||
.Queryable()
|
.Queryable()
|
||||||
.Where(predicate.ToExpression())
|
.Where(predicate.ToExpression())
|
||||||
.OrderBy(s => s.CouponSort,OrderByType.Asc)
|
.OrderBy(s => s.CouponSort, OrderByType.Asc)
|
||||||
.Select(s => new CouponVo
|
.Select(s => new CouponVo
|
||||||
{
|
{
|
||||||
CouponId = s.CouponId,
|
CouponId = s.CouponId,
|
||||||
CouponGuid = s.CouponGuid,
|
CouponGuid = s.CouponGuid,
|
||||||
CouponName = s.CouponName,
|
CouponName = s.CouponName,
|
||||||
CouponType = s.CouponType,
|
CouponType = s.CouponType,
|
||||||
CouponDeductionMoney = s.CouponDeductionMoney,
|
CouponDeductionMoney = s.CouponDeductionMoney,
|
||||||
CouponDiscountRate = s.CouponDiscountRate,
|
CouponDiscountRate = s.CouponDiscountRate,
|
||||||
CouponMinConsumeMoney = s.CouponMinConsumeMoney,
|
CouponMinConsumeMoney = s.CouponMinConsumeMoney,
|
||||||
CouponExpireType = s.CouponExpireType,
|
CouponExpireType = s.CouponExpireType,
|
||||||
CouponEffectiveDays = s.CouponEffectiveDays,
|
CouponEffectiveDays = s.CouponEffectiveDays,
|
||||||
CouponFixedStartTime = s.CouponFixedStartTime,
|
CouponFixedStartTime = s.CouponFixedStartTime,
|
||||||
CouponFixedEndTime = s.CouponFixedEndTime,
|
CouponFixedEndTime = s.CouponFixedEndTime,
|
||||||
CouponApplicableScope = s.CouponApplicableScope,
|
CouponApplicableScope = s.CouponApplicableScope,
|
||||||
CouponSendNumber = s.CouponSendNumber,
|
CouponSendNumber = s.CouponSendNumber,
|
||||||
CouponDisplayStatus = s.CouponDisplayStatus,
|
CouponDisplayStatus = s.CouponDisplayStatus,
|
||||||
CouponSort = s.CouponSort,
|
CouponSort = s.CouponSort,
|
||||||
});
|
CouponApplicableScopeConfig = s.CouponApplicableScopeConfig,
|
||||||
|
CouponGoodsIdsArr = s.CouponGoodsIds
|
||||||
|
});
|
||||||
|
|
||||||
return await query.ToPageAsync(parm);
|
|
||||||
|
var list = await query.ToPageAsync(parm);
|
||||||
|
|
||||||
|
//foreach (var item in list.Result)
|
||||||
|
//{
|
||||||
|
// item.CouponGoodsIds = item.CouponGoodsIdsArr.Split(',');
|
||||||
|
//}
|
||||||
|
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加或修改优惠券
|
/// 添加或修改优惠券
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<string> AddOrUpdateCoupon(Coupon model)
|
public async Task<string> AddOrUpdateCoupon(Coupon model)
|
||||||
@ -95,7 +104,7 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region Excel处理
|
#region Excel处理
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数据导入处理
|
/// 数据导入处理
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<CouponVo> HandleImportData(CouponVo Coupon)
|
public async Task<CouponVo> HandleImportData(CouponVo Coupon)
|
||||||
@ -107,7 +116,7 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Excel导入
|
/// Excel导入
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<string> ImportExcel(Coupon Coupon,int index,bool isUpdateSupport,string user)
|
public async Task<string> ImportExcel(Coupon Coupon, int index, bool isUpdateSupport, string user)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -118,7 +127,7 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
|||||||
{
|
{
|
||||||
// 判断唯一值
|
// 判断唯一值
|
||||||
var model = await GetFirstAsync(s => s.CouponId == Coupon.CouponId);
|
var model = await GetFirstAsync(s => s.CouponId == Coupon.CouponId);
|
||||||
|
|
||||||
// 如果为空就新增数据
|
// 如果为空就新增数据
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -146,8 +155,9 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
|||||||
return editStr;
|
return editStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
// 开启事务
|
{
|
||||||
|
// 开启事务
|
||||||
var res = await UseTranAsync(async () =>
|
var res = await UseTranAsync(async () =>
|
||||||
{
|
{
|
||||||
var addRes = await AddOrUpdateCoupon(Coupon);
|
var addRes = await AddOrUpdateCoupon(Coupon);
|
||||||
@ -166,7 +176,7 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Excel数据导出处理
|
/// Excel数据导出处理
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -176,10 +186,10 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,14 +97,6 @@ namespace ARW.WebApi.Controllers.Business.GoodsManager.Goodss
|
|||||||
[HttpGet("getAllGoodsList")]
|
[HttpGet("getAllGoodsList")]
|
||||||
public async Task<IActionResult> GetAllGoodsList([FromQuery] GoodsQueryDto parm)
|
public async Task<IActionResult> GetAllGoodsList([FromQuery] GoodsQueryDto parm)
|
||||||
{
|
{
|
||||||
var user = JwtUtil.GetLoginUser(App.HttpContext);
|
|
||||||
if (user.UserId != 1)
|
|
||||||
{
|
|
||||||
var shop = await _ShopService.GetFirstAsync(s => s.ShopUserId == user.UserId);
|
|
||||||
if (shop == null) throw new Exception("当前用户没有店铺");
|
|
||||||
parm.ShopGuid = shop.ShopGuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
var res = await _GoodsService.GetAllGoodsList(parm);
|
var res = await _GoodsService.GetAllGoodsList(parm);
|
||||||
return SUCCESS(res);
|
return SUCCESS(res);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ namespace ARW.WebApi.Controllers.Business.Marketing.CouponManage.Coupons
|
|||||||
{
|
{
|
||||||
if (parm == null) { throw new CustomException("请求参数错误"); }
|
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||||
|
|
||||||
var modal = new Coupon();
|
var modal = new Coupon();
|
||||||
if (parm.CouponId != 0) modal = parm.Adapt<Coupon>().ToUpdate(HttpContext);
|
if (parm.CouponId != 0) modal = parm.Adapt<Coupon>().ToUpdate(HttpContext);
|
||||||
else modal = parm.Adapt<Coupon>().ToCreate(HttpContext);
|
else modal = parm.Adapt<Coupon>().ToCreate(HttpContext);
|
||||||
|
|
||||||
@ -88,8 +88,8 @@ namespace ARW.WebApi.Controllers.Business.Marketing.CouponManage.Coupons
|
|||||||
var response = _CouponService.Delete(idsArr);
|
var response = _CouponService.Delete(idsArr);
|
||||||
return SUCCESS("删除成功!");
|
return SUCCESS("删除成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 导入优惠券
|
/// 导入优惠券
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
|
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
|
||||||
@ -98,7 +98,7 @@ namespace ARW.WebApi.Controllers.Business.Marketing.CouponManage.Coupons
|
|||||||
[HttpPost("importData")]
|
[HttpPost("importData")]
|
||||||
[Log(Title = "优惠券导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = false)]
|
[Log(Title = "优惠券导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = false)]
|
||||||
[ActionPermissionFilter(Permission = "business:coupon:import")]
|
[ActionPermissionFilter(Permission = "business:coupon:import")]
|
||||||
public async Task<IActionResult> ImportExcel([FromForm(Name = "file")] IFormFile formFile,bool updateSupport)
|
public async Task<IActionResult> ImportExcel([FromForm(Name = "file")] IFormFile formFile, bool updateSupport)
|
||||||
{
|
{
|
||||||
var isUpdateSupport = updateSupport;
|
var isUpdateSupport = updateSupport;
|
||||||
IEnumerable<CouponVo> parm = ExcelHelper<CouponVo>.ImportData(formFile.OpenReadStream());
|
IEnumerable<CouponVo> parm = ExcelHelper<CouponVo>.ImportData(formFile.OpenReadStream());
|
||||||
@ -111,7 +111,7 @@ namespace ARW.WebApi.Controllers.Business.Marketing.CouponManage.Coupons
|
|||||||
var Coupon = await _CouponService.HandleImportData(item);
|
var Coupon = await _CouponService.HandleImportData(item);
|
||||||
var modal = Coupon.Adapt<Coupon>().ToCreate(HttpContext);
|
var modal = Coupon.Adapt<Coupon>().ToCreate(HttpContext);
|
||||||
var user = JwtUtil.GetLoginUser(App.HttpContext).UserName;
|
var user = JwtUtil.GetLoginUser(App.HttpContext).UserName;
|
||||||
var msg = await _CouponService.ImportExcel(modal,i,isUpdateSupport,user);
|
var msg = await _CouponService.ImportExcel(modal, i, isUpdateSupport, user);
|
||||||
msgList.Add(msg);
|
msgList.Add(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,15 +137,15 @@ namespace ARW.WebApi.Controllers.Business.Marketing.CouponManage.Coupons
|
|||||||
|
|
||||||
return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"{sFileName}");
|
return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"{sFileName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 导出优惠券
|
/// 导出优惠券
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Log(Title = "优惠券导出", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
|
[Log(Title = "优惠券导出", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
|
||||||
[HttpGet("exportCoupon")]
|
[HttpGet("exportCoupon")]
|
||||||
[ActionPermissionFilter(Permission = "business:coupon:export")]
|
[ActionPermissionFilter(Permission = "business:coupon:export")]
|
||||||
public async Task<IActionResult> ExportExcel([FromQuery] CouponQueryDto parm)
|
public async Task<IActionResult> ExportExcel([FromQuery] CouponQueryDto parm)
|
||||||
{
|
{
|
||||||
parm.PageSize = 10000;
|
parm.PageSize = 10000;
|
||||||
var list = await _CouponService.GetCouponList(parm);
|
var list = await _CouponService.GetCouponList(parm);
|
||||||
@ -164,7 +164,7 @@ namespace ARW.WebApi.Controllers.Business.Marketing.CouponManage.Coupons
|
|||||||
data = selectDataList;
|
data = selectDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 导出数据处理
|
// 导出数据处理
|
||||||
var handleData = await _CouponService.HandleExportData(data);
|
var handleData = await _CouponService.HandleExportData(data);
|
||||||
|
Loading…
Reference in New Issue
Block a user