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 = "排序不能为空")]
|
||||
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; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :适用范围(指定商品的Id集)
|
||||
/// 空值 : true
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "适用范围(指定商品的Id集)")]
|
||||
[SugarColumn(ColumnName = "coupon_goods_ids")]
|
||||
public string CouponGoodsIds { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :发送数量(-1不限制)
|
||||
/// 空值 : false
|
||||
|
@ -58,11 +58,16 @@ namespace ARW.Model.Vo.Business.GoodsManager.Goodss
|
||||
[EpplusTableColumn(Header = "划线价格")]
|
||||
public decimal GoodsDashedPriceLowest { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库存总量
|
||||
/// </summary>
|
||||
public int GoodsTotalInventory { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :上下架状态(1上架 2下架)
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
[EpplusIgnore]
|
||||
public int GoodsShelfStatus { get; set; }
|
||||
|
||||
|
||||
|
@ -122,5 +122,12 @@ namespace ARW.Model.Vo.Business.Marketing.CouponManage.Coupons
|
||||
[EpplusTableColumn(Header = "排序")]
|
||||
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,
|
||||
GoodsShelfStatus = s.GoodsShelfStatus,
|
||||
GoodsSort = s.GoodsSort,
|
||||
GoodsTotalInventory = s.GoodsTotalInventory,
|
||||
});
|
||||
|
||||
|
||||
|
@ -33,13 +33,13 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
||||
this._CouponRepository = CouponRepository;
|
||||
}
|
||||
|
||||
#region 业务逻辑代码
|
||||
#region 业务逻辑代码
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// 查询优惠券分页列表
|
||||
/// </summary>
|
||||
public async Task<PagedInfo<CouponVo>> GetCouponList(CouponQueryDto parm)
|
||||
public async Task<PagedInfo<CouponVo>> GetCouponList(CouponQueryDto parm)
|
||||
{
|
||||
//开始拼装查询条件d
|
||||
var predicate = Expressionable.Create<Coupon>();
|
||||
@ -52,31 +52,40 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
||||
var query = _CouponRepository
|
||||
.Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy(s => s.CouponSort,OrderByType.Asc)
|
||||
.OrderBy(s => s.CouponSort, OrderByType.Asc)
|
||||
.Select(s => new CouponVo
|
||||
{
|
||||
CouponId = s.CouponId,
|
||||
CouponGuid = s.CouponGuid,
|
||||
CouponName = s.CouponName,
|
||||
CouponType = s.CouponType,
|
||||
CouponDeductionMoney = s.CouponDeductionMoney,
|
||||
CouponDiscountRate = s.CouponDiscountRate,
|
||||
CouponMinConsumeMoney = s.CouponMinConsumeMoney,
|
||||
CouponExpireType = s.CouponExpireType,
|
||||
CouponEffectiveDays = s.CouponEffectiveDays,
|
||||
CouponFixedStartTime = s.CouponFixedStartTime,
|
||||
CouponFixedEndTime = s.CouponFixedEndTime,
|
||||
CouponApplicableScope = s.CouponApplicableScope,
|
||||
CouponSendNumber = s.CouponSendNumber,
|
||||
CouponDisplayStatus = s.CouponDisplayStatus,
|
||||
CouponSort = s.CouponSort,
|
||||
});
|
||||
CouponId = s.CouponId,
|
||||
CouponGuid = s.CouponGuid,
|
||||
CouponName = s.CouponName,
|
||||
CouponType = s.CouponType,
|
||||
CouponDeductionMoney = s.CouponDeductionMoney,
|
||||
CouponDiscountRate = s.CouponDiscountRate,
|
||||
CouponMinConsumeMoney = s.CouponMinConsumeMoney,
|
||||
CouponExpireType = s.CouponExpireType,
|
||||
CouponEffectiveDays = s.CouponEffectiveDays,
|
||||
CouponFixedStartTime = s.CouponFixedStartTime,
|
||||
CouponFixedEndTime = s.CouponFixedEndTime,
|
||||
CouponApplicableScope = s.CouponApplicableScope,
|
||||
CouponSendNumber = s.CouponSendNumber,
|
||||
CouponDisplayStatus = s.CouponDisplayStatus,
|
||||
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>
|
||||
public async Task<string> AddOrUpdateCoupon(Coupon model)
|
||||
@ -95,7 +104,7 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
||||
}
|
||||
|
||||
#region Excel处理
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// 数据导入处理
|
||||
/// </summary>
|
||||
public async Task<CouponVo> HandleImportData(CouponVo Coupon)
|
||||
@ -107,7 +116,7 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
||||
/// <summary>
|
||||
/// Excel导入
|
||||
/// </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
|
||||
{
|
||||
@ -146,8 +155,9 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
||||
return editStr;
|
||||
}
|
||||
}
|
||||
else{
|
||||
// 开启事务
|
||||
else
|
||||
{
|
||||
// 开启事务
|
||||
var res = await UseTranAsync(async () =>
|
||||
{
|
||||
var addRes = await AddOrUpdateCoupon(Coupon);
|
||||
@ -179,7 +189,7 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -97,14 +97,6 @@ namespace ARW.WebApi.Controllers.Business.GoodsManager.Goodss
|
||||
[HttpGet("getAllGoodsList")]
|
||||
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);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ namespace ARW.WebApi.Controllers.Business.Marketing.CouponManage.Coupons
|
||||
{
|
||||
if (parm == null) { throw new CustomException("请求参数错误"); }
|
||||
|
||||
var modal = new Coupon();
|
||||
var modal = new Coupon();
|
||||
if (parm.CouponId != 0) modal = parm.Adapt<Coupon>().ToUpdate(HttpContext);
|
||||
else modal = parm.Adapt<Coupon>().ToCreate(HttpContext);
|
||||
|
||||
@ -89,7 +89,7 @@ namespace ARW.WebApi.Controllers.Business.Marketing.CouponManage.Coupons
|
||||
return SUCCESS("删除成功!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// 导入优惠券
|
||||
/// </summary>
|
||||
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
|
||||
@ -98,7 +98,7 @@ namespace ARW.WebApi.Controllers.Business.Marketing.CouponManage.Coupons
|
||||
[HttpPost("importData")]
|
||||
[Log(Title = "优惠券导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = false)]
|
||||
[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;
|
||||
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 modal = Coupon.Adapt<Coupon>().ToCreate(HttpContext);
|
||||
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);
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ namespace ARW.WebApi.Controllers.Business.Marketing.CouponManage.Coupons
|
||||
return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"{sFileName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// 导出优惠券
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
Loading…
Reference in New Issue
Block a user