From d8188a9ce154eb09bcef51c566dc5ab1527fb0d6 Mon Sep 17 00:00:00 2001
From: lwh <2679599887@qq.com>
Date: Mon, 24 Jul 2023 23:11:04 +0800
Subject: [PATCH] =?UTF-8?q?feat=20=E5=88=9D=E5=A7=8B=E5=8C=96=E4=BC=98?=
=?UTF-8?q?=E6=83=A0=E5=88=B8=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=A4=9A=E9=80=89?=
=?UTF-8?q?=E5=95=86=E5=93=81=E7=9A=84=E5=BC=B9=E7=AA=97=E5=92=8C=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../CouponManage/Coupons/CouponDto.cs | 89 +++++++++
.../Marketing/CouponManage/Coupons/Coupon.cs | 178 +++++++++++++++++
.../GoodsManager/Goodss/AllGoodsVo.cs | 80 ++++++++
.../CouponManage/Coupons/CouponVo.cs | 126 ++++++++++++
.../CouponManage/Coupons/CouponRepository.cs | 20 ++
.../GoodsManager/Goodss/GoodsService.cs | 33 ++++
.../CouponManage/Coupons/CouponService.cs | 185 ++++++++++++++++++
.../GoodsManager/Goodss/IGoodsService.cs | 8 +
.../CouponManage/Coupons/ICouponService.cs | 59 ++++++
.../GoodsManager/Goodss/GoodsController.cs | 21 ++
.../CouponManage/Coupons/CouponController.cs | 180 +++++++++++++++++
11 files changed, 979 insertions(+)
create mode 100644 ARW.Model/Dto/Business/Marketing/CouponManage/Coupons/CouponDto.cs
create mode 100644 ARW.Model/Models/Business/Marketing/CouponManage/Coupons/Coupon.cs
create mode 100644 ARW.Model/Vo/Business/GoodsManager/Goodss/AllGoodsVo.cs
create mode 100644 ARW.Model/Vo/Business/Marketing/CouponManage/Coupons/CouponVo.cs
create mode 100644 ARW.Repository/Business/Marketing/CouponManage/Coupons/CouponRepository.cs
create mode 100644 ARW.Service/Business/BusinessService/Marketing/CouponManage/Coupons/CouponService.cs
create mode 100644 ARW.Service/Business/IBusinessService/Marketing/CouponManage/Coupons/ICouponService.cs
create mode 100644 ARW.WebApi/Controllers/Business/Marketing/CouponManage/Coupons/CouponController.cs
diff --git a/ARW.Model/Dto/Business/Marketing/CouponManage/Coupons/CouponDto.cs b/ARW.Model/Dto/Business/Marketing/CouponManage/Coupons/CouponDto.cs
new file mode 100644
index 0000000..8def907
--- /dev/null
+++ b/ARW.Model/Dto/Business/Marketing/CouponManage/Coupons/CouponDto.cs
@@ -0,0 +1,89 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using ARW.Model.Models.Business.Marketing.CouponManage.Coupons;
+
+namespace ARW.Model.Dto.Business.Marketing.CouponManage.Coupons
+{
+ ///
+ /// 优惠券输入对象
+ ///
+ /// @author lwh
+ /// @date 2023-07-24
+ ///
+ public class CouponDto
+ {
+
+ public int CouponId { get; set; }
+
+ public long CouponGuid { get; set; }
+
+ [Required(ErrorMessage = "优惠劵名称不能为空")]
+ public string CouponName { get; set; }
+
+ [Required(ErrorMessage = "优惠劵类型不能为空")]
+ public int CouponType { get; set; }
+
+ public decimal CouponDeductionMoney { get; set; }
+
+ public byte CouponDiscountRate { get; set; }
+
+ [Required(ErrorMessage = "最低消费金额不能为空")]
+ public decimal CouponMinConsumeMoney { get; set; }
+
+ [Required(ErrorMessage = "到期类型不能为空")]
+ public int CouponExpireType { get; set; }
+
+ public int? CouponEffectiveDays { get; set; }
+
+ public DateTime? CouponFixedStartTime { get; set; }
+
+ public DateTime? CouponFixedEndTime { get; set; }
+
+ public int? CouponApplicableScope { get; set; }
+
+
+ [Required(ErrorMessage = "发送数量(-1不限制)不能为空")]
+ public int CouponSendNumber { get; set; }
+
+ public int? CouponGetNumber { get; set; }
+
+ [Required(ErrorMessage = "显示状态不能为空")]
+ public int CouponDisplayStatus { get; set; }
+
+ [Required(ErrorMessage = "排序不能为空")]
+ public int CouponSort { get; set; }
+
+
+
+
+
+ }
+
+
+ ///
+ /// 优惠券查询对象
+ ///
+ /// @author lwh
+ /// @date 2023-07-24
+ ///
+ public class CouponQueryDto : PagerInfo
+ {
+
+ public string CouponName { get; set; }
+
+ public int? CouponType { get; set; }
+
+ public int? CouponExpireType { get; set; }
+
+ public int? CouponApplicableScope { get; set; }
+
+ public int? CouponDisplayStatus { get; set; }
+
+ public string ids { get; set; }
+ }
+
+
+
+
+}
diff --git a/ARW.Model/Models/Business/Marketing/CouponManage/Coupons/Coupon.cs b/ARW.Model/Models/Business/Marketing/CouponManage/Coupons/Coupon.cs
new file mode 100644
index 0000000..046d8b1
--- /dev/null
+++ b/ARW.Model/Models/Business/Marketing/CouponManage/Coupons/Coupon.cs
@@ -0,0 +1,178 @@
+using System;
+using System.Collections.Generic;
+using SqlSugar;
+using OfficeOpenXml.Attributes;
+using Newtonsoft.Json;
+
+namespace ARW.Model.Models.Business.Marketing.CouponManage.Coupons
+{
+ ///
+ /// 优惠券,数据实体对象
+ ///
+ /// @author lwh
+ /// @date 2023-07-24
+ ///
+ [SugarTable("tb_coupon")]
+ public class Coupon : BusinessBase
+ {
+
+ ///
+ /// 描述 :
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "CouponId")]
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "coupon_id")]
+ public int CouponId { get; set; }
+
+
+ ///
+ /// 描述 :
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "CouponGuid")]
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "coupon_guid")]
+ public long CouponGuid { get; set; }
+
+
+ ///
+ /// 描述 :优惠劵名称
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "优惠劵名称")]
+ [SugarColumn(ColumnName = "coupon_name")]
+ public string CouponName { get; set; }
+
+
+ ///
+ /// 描述 :优惠劵类型
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "优惠劵类型")]
+ [SugarColumn(ColumnName = "coupon_type")]
+ public int CouponType { get; set; }
+
+
+ ///
+ /// 描述 :减免金额
+ /// 空值 : true
+ ///
+ [EpplusTableColumn(Header = "减免金额")]
+ [SugarColumn(ColumnName = "coupon_deduction_money")]
+ public decimal CouponDeductionMoney { get; set; }
+
+
+ ///
+ /// 描述 :折扣率
+ /// 空值 : true
+ ///
+ [EpplusTableColumn(Header = "折扣率")]
+ [SugarColumn(ColumnName = "coupon_discount_rate")]
+ public byte CouponDiscountRate { get; set; }
+
+
+ ///
+ /// 描述 :最低消费金额
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "最低消费金额")]
+ [SugarColumn(ColumnName = "coupon_min_consume_money")]
+ public decimal CouponMinConsumeMoney { get; set; }
+
+
+ ///
+ /// 描述 :到期类型
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "到期类型")]
+ [SugarColumn(ColumnName = "coupon_expire_type")]
+ public int CouponExpireType { get; set; }
+
+
+ ///
+ /// 描述 :有效天数
+ /// 空值 : true
+ ///
+ [EpplusTableColumn(Header = "有效天数")]
+ [SugarColumn(ColumnName = "coupon_effective_days")]
+ public int? CouponEffectiveDays { get; set; }
+
+
+ ///
+ /// 描述 :固定时间-开始时间
+ /// 空值 : true
+ ///
+ [EpplusTableColumn(Header = "固定时间-开始时间", NumberFormat = "yyyy-MM-dd HH:mm:ss")]
+ [SugarColumn(ColumnName = "coupon_fixed_start_time")]
+ public DateTime? CouponFixedStartTime { get; set; }
+
+
+ ///
+ /// 描述 :固定时间-结束时间
+ /// 空值 : true
+ ///
+ [EpplusTableColumn(Header = "固定时间-结束时间", NumberFormat = "yyyy-MM-dd HH:mm:ss")]
+ [SugarColumn(ColumnName = "coupon_fixed_end_time")]
+ public DateTime? CouponFixedEndTime { get; set; }
+
+
+ ///
+ /// 描述 :适用范围
+ /// 空值 : true
+ ///
+ [EpplusTableColumn(Header = "适用范围")]
+ [SugarColumn(ColumnName = "coupon_applicable_scope")]
+ public int? CouponApplicableScope { get; set; }
+
+
+ ///
+ /// 描述 :适用范围配置(json)
+ /// 空值 : true
+ ///
+ [EpplusTableColumn(Header = "适用范围配置(json)")]
+ [SugarColumn(ColumnName = "coupon_applicable_scope_config")]
+ public string CouponApplicableScopeConfig { get; set; }
+
+
+ ///
+ /// 描述 :发送数量(-1不限制)
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "发送数量(-1不限制)")]
+ [SugarColumn(ColumnName = "coupon_send_number")]
+ public int CouponSendNumber { get; set; }
+
+
+ ///
+ /// 描述 :已领取数量
+ /// 空值 : true
+ ///
+ [EpplusTableColumn(Header = "已领取数量")]
+ [SugarColumn(ColumnName = "coupon_get_number")]
+ public int? CouponGetNumber { get; set; }
+
+
+ ///
+ /// 描述 :显示状态
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "显示状态")]
+ [SugarColumn(ColumnName = "coupon_display_status")]
+ public int CouponDisplayStatus { get; set; }
+
+
+ ///
+ /// 描述 :排序
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "排序")]
+ [SugarColumn(ColumnName = "coupon_sort")]
+ public int CouponSort { get; set; }
+
+
+
+
+
+
+ }
+}
\ No newline at end of file
diff --git a/ARW.Model/Vo/Business/GoodsManager/Goodss/AllGoodsVo.cs b/ARW.Model/Vo/Business/GoodsManager/Goodss/AllGoodsVo.cs
new file mode 100644
index 0000000..32eebc3
--- /dev/null
+++ b/ARW.Model/Vo/Business/GoodsManager/Goodss/AllGoodsVo.cs
@@ -0,0 +1,80 @@
+using Newtonsoft.Json;
+using OfficeOpenXml.Attributes;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+
+namespace ARW.Model.Vo.Business.GoodsManager.Goodss
+{
+ ///
+ /// 全部商品展示对象
+ ///
+ /// @author lwh
+ /// @date 2023-07-24
+ ///
+ public class AllGoodsVo
+ {
+
+
+ ///
+ /// 描述 :
+ ///
+ [EpplusIgnore]
+ public int GoodsId { get; set; }
+
+
+ ///
+ /// 描述 :
+ ///
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [EpplusIgnore]
+ public long GoodsGuid { get; set; }
+
+
+ ///
+ /// 描述 :名称
+ ///
+ [EpplusTableColumn(Header = "商品名称")]
+ public string GoodsName { get; set; }
+
+
+ ///
+ /// 描述 :图片
+ ///
+ [EpplusTableColumn(Header = "商品图片")]
+ public string GoodsPicture { get; set; }
+
+
+ ///
+ /// 描述 :价格(最低)
+ ///
+ [EpplusTableColumn(Header = "商品价格")]
+ public decimal GoodsPriceLowest { get; set; }
+
+
+ ///
+ /// 描述 :划线价格(最低)
+ ///
+ [EpplusTableColumn(Header = "划线价格")]
+ public decimal GoodsDashedPriceLowest { get; set; }
+
+
+ ///
+ /// 描述 :上下架状态(1上架 2下架)
+ ///
+ [EpplusIgnore]
+ public int GoodsShelfStatus { get; set; }
+
+
+ [EpplusTableColumn(Header = "状态")]
+ public string GoodsShelfStatusName { get; set; }
+
+
+ ///
+ /// 描述 :排序
+ ///
+ [EpplusTableColumn(Header = "排序")]
+ public int GoodsSort { get; set; }
+
+ }
+}
diff --git a/ARW.Model/Vo/Business/Marketing/CouponManage/Coupons/CouponVo.cs b/ARW.Model/Vo/Business/Marketing/CouponManage/Coupons/CouponVo.cs
new file mode 100644
index 0000000..5e9ad04
--- /dev/null
+++ b/ARW.Model/Vo/Business/Marketing/CouponManage/Coupons/CouponVo.cs
@@ -0,0 +1,126 @@
+using Newtonsoft.Json;
+using OfficeOpenXml.Attributes;
+using SqlSugar;
+using System;
+
+namespace ARW.Model.Vo.Business.Marketing.CouponManage.Coupons
+{
+ ///
+ /// 优惠券展示对象
+ ///
+ /// @author lwh
+ /// @date 2023-07-24
+ ///
+ public class CouponVo
+ {
+
+
+ ///
+ /// 描述 :
+ ///
+ [EpplusIgnore]
+ public int CouponId { get; set; }
+
+
+ ///
+ /// 描述 :
+ ///
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [EpplusIgnore]
+ public long CouponGuid { get; set; }
+
+
+ ///
+ /// 描述 :优惠劵名称
+ ///
+ [EpplusTableColumn(Header = "优惠劵名称")]
+ public string CouponName { get; set; }
+
+
+ ///
+ /// 描述 :优惠劵类型
+ ///
+ [EpplusTableColumn(Header = "优惠劵类型")]
+ public int CouponType { get; set; }
+
+
+ ///
+ /// 描述 :减免金额
+ ///
+ [EpplusIgnore]
+ public decimal CouponDeductionMoney { get; set; }
+
+
+ ///
+ /// 描述 :折扣率
+ ///
+ [EpplusIgnore]
+ public byte CouponDiscountRate { get; set; }
+
+
+ ///
+ /// 描述 :最低消费金额
+ ///
+ [EpplusTableColumn(Header = "最低消费金额")]
+ public decimal CouponMinConsumeMoney { get; set; }
+
+
+ ///
+ /// 描述 :到期类型
+ ///
+ [EpplusTableColumn(Header = "到期类型")]
+ public int CouponExpireType { get; set; }
+
+
+ ///
+ /// 描述 :有效天数
+ ///
+ [EpplusIgnore]
+ public int? CouponEffectiveDays { get; set; }
+
+
+ ///
+ /// 描述 :固定时间-开始时间
+ ///
+ [EpplusIgnore]
+ public DateTime? CouponFixedStartTime { get; set; }
+
+
+ ///
+ /// 描述 :固定时间-结束时间
+ ///
+ [EpplusIgnore]
+ public DateTime? CouponFixedEndTime { get; set; }
+
+
+ ///
+ /// 描述 :适用范围
+ ///
+ [EpplusIgnore]
+ public int? CouponApplicableScope { get; set; }
+
+
+
+ ///
+ /// 描述 :发送数量(-1不限制)
+ ///
+ [EpplusTableColumn(Header = "发送数量(-1不限制)")]
+ public int CouponSendNumber { get; set; }
+
+
+
+ ///
+ /// 描述 :显示状态
+ ///
+ [EpplusTableColumn(Header = "显示状态")]
+ public int CouponDisplayStatus { get; set; }
+
+
+ ///
+ /// 描述 :排序
+ ///
+ [EpplusTableColumn(Header = "排序")]
+ public int CouponSort { get; set; }
+
+ }
+}
diff --git a/ARW.Repository/Business/Marketing/CouponManage/Coupons/CouponRepository.cs b/ARW.Repository/Business/Marketing/CouponManage/Coupons/CouponRepository.cs
new file mode 100644
index 0000000..283b6c8
--- /dev/null
+++ b/ARW.Repository/Business/Marketing/CouponManage/Coupons/CouponRepository.cs
@@ -0,0 +1,20 @@
+using System;
+using Infrastructure.Attribute;
+using ARW.Repository.System;
+using ARW.Model.Models.Business.Marketing.CouponManage.Coupons;
+
+namespace ARW.Repository.Business.Marketing.CouponManage.Coupons
+{
+ ///
+ /// 优惠券仓储
+ ///
+ /// @author lwh
+ /// @date 2023-07-24
+ ///
+ [AppService(ServiceLifetime = LifeTime.Transient)]
+ public class CouponRepository : BaseRepository
+ {
+ #region 业务逻辑代码
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/ARW.Service/Business/BusinessService/GoodsManager/Goodss/GoodsService.cs b/ARW.Service/Business/BusinessService/GoodsManager/Goodss/GoodsService.cs
index 3d7f92a..bda764c 100644
--- a/ARW.Service/Business/BusinessService/GoodsManager/Goodss/GoodsService.cs
+++ b/ARW.Service/Business/BusinessService/GoodsManager/Goodss/GoodsService.cs
@@ -191,6 +191,39 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.Goodss
}
+ ///
+ /// 查询全部商品列表
+ ///
+ public async Task> GetAllGoodsList(GoodsQueryDto parm)
+ {
+
+ //开始拼装查询条件d
+ var predicate = Expressionable.Create();
+
+ predicate = predicate.AndIF(parm.ShopGuid != 0, s => s.ShopGuid == parm.ShopGuid);
+ predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.GoodsName), s => s.GoodsName.Contains(parm.GoodsName));
+ predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.GoodsCoding), s => s.GoodsCoding.Contains(parm.GoodsCoding));
+ var query = _GoodsRepository
+ .Queryable()
+ .Where(predicate.ToExpression())
+ .OrderBy(s => s.GoodsSort, OrderByType.Asc)
+ .Select(s => new AllGoodsVo
+ {
+ GoodsId = s.GoodsId,
+ GoodsGuid = s.GoodsGuid,
+ GoodsName = s.GoodsName,
+ GoodsPicture = s.GoodsPicture,
+ GoodsPriceLowest = s.GoodsPriceLowest,
+ GoodsDashedPriceLowest = s.GoodsDashedPriceLowest,
+ GoodsShelfStatus = s.GoodsShelfStatus,
+ GoodsSort = s.GoodsSort,
+ });
+
+
+ return await query.ToListAsync();
+
+ }
+
///
/// 添加或修改商品
diff --git a/ARW.Service/Business/BusinessService/Marketing/CouponManage/Coupons/CouponService.cs b/ARW.Service/Business/BusinessService/Marketing/CouponManage/Coupons/CouponService.cs
new file mode 100644
index 0000000..3cadd00
--- /dev/null
+++ b/ARW.Service/Business/BusinessService/Marketing/CouponManage/Coupons/CouponService.cs
@@ -0,0 +1,185 @@
+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.Marketing.CouponManage.Coupons;
+using ARW.Service.Business.IBusinessService.Marketing.CouponManage.Coupons;
+using ARW.Model.Dto.Business.Marketing.CouponManage.Coupons;
+using ARW.Model.Models.Business.Marketing.CouponManage.Coupons;
+using ARW.Model.Vo.Business.Marketing.CouponManage.Coupons;
+
+namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
+{
+ ///
+ /// 优惠券接口实现类
+ ///
+ /// @author lwh
+ /// @date 2023-07-24
+ ///
+ [AppService(ServiceType = typeof(ICouponService), ServiceLifetime = LifeTime.Transient)]
+ public class CouponServiceImpl : BaseService, ICouponService
+ {
+ private readonly CouponRepository _CouponRepository;
+
+ public CouponServiceImpl(CouponRepository CouponRepository)
+ {
+ this._CouponRepository = CouponRepository;
+ }
+
+ #region 业务逻辑代码
+
+
+ ///
+ /// 查询优惠券分页列表
+ ///
+ public async Task> GetCouponList(CouponQueryDto parm)
+ {
+ //开始拼装查询条件d
+ var predicate = Expressionable.Create();
+
+ predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CouponName), s => s.CouponName == parm.CouponName);
+ predicate = predicate.AndIF(parm.CouponType != null, s => s.CouponType == parm.CouponType);
+ predicate = predicate.AndIF(parm.CouponExpireType != null, s => s.CouponExpireType == parm.CouponExpireType);
+ predicate = predicate.AndIF(parm.CouponApplicableScope != null, s => s.CouponApplicableScope == parm.CouponApplicableScope);
+ predicate = predicate.AndIF(parm.CouponDisplayStatus != null, s => s.CouponDisplayStatus == parm.CouponDisplayStatus);
+ var query = _CouponRepository
+ .Queryable()
+ .Where(predicate.ToExpression())
+ .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,
+ });
+
+
+ return await query.ToPageAsync(parm);
+ }
+
+ ///
+ /// 添加或修改优惠券
+ ///
+ public async Task AddOrUpdateCoupon(Coupon model)
+ {
+ if (model.CouponId != 0)
+ {
+ var response = await _CouponRepository.UpdateAsync(model);
+ return "修改成功!";
+ }
+ else
+ {
+
+ var response = await _CouponRepository.InsertReturnSnowflakeIdAsync(model);
+ return "添加成功!";
+ }
+ }
+
+ #region Excel处理
+ ///
+ /// 数据导入处理
+ ///
+ public async Task HandleImportData(CouponVo Coupon)
+ {
+ return Coupon;
+ }
+
+
+ ///
+ /// Excel导入
+ ///
+ public async Task ImportExcel(Coupon Coupon,int index,bool isUpdateSupport,string user)
+ {
+ try
+ {
+ // 空值判断
+ // if (Coupon.CouponId == null) throw new CustomException("优惠券不能为空");
+
+ if (isUpdateSupport)
+ {
+ // 判断唯一值
+ var model = await GetFirstAsync(s => s.CouponId == Coupon.CouponId);
+
+ // 如果为空就新增数据
+ if (model == null)
+ {
+ // 开启事务
+ var res = await UseTranAsync(async () =>
+ {
+ var addRes = await AddOrUpdateCoupon(Coupon);
+ });
+ var addStr = $"第 {index} 行 => 优惠券:【{Coupon.CouponId}】新增成功!
";
+ return addStr;
+ }
+ else
+ {
+ // 如果有数据就进行修改
+ // 开启事务
+ await UseTranAsync(async () =>
+ {
+ Coupon.CouponId = model.CouponId;
+ Coupon.CouponGuid = model.CouponGuid;
+ Coupon.Update_by = user;
+ Coupon.Update_time = DateTime.Now;
+ var editRes = await AddOrUpdateCoupon(Coupon);
+ });
+ var editStr = $"第 {index} 行 => 优惠券:【{Coupon.CouponId}】更新成功!
";
+ return editStr;
+ }
+ }
+ else{
+ // 开启事务
+ var res = await UseTranAsync(async () =>
+ {
+ var addRes = await AddOrUpdateCoupon(Coupon);
+ });
+ //Console.WriteLine(res.IsSuccess);
+ var addStr = $"第 {index} 行 => 优惠券:【{Coupon.CouponId}】新增成功!
";
+ return addStr;
+ }
+ }
+ catch (Exception ex)
+ {
+ var errorRes = $"第 {index} 行 => 优惠券:【{Coupon.CouponId}】导入失败!{ex.Message}
";
+ return errorRes;
+ throw;
+ }
+ }
+
+
+
+ ///
+ /// Excel数据导出处理
+ ///
+ public async Task> HandleExportData(List data)
+ {
+ return data;
+ }
+
+ #endregion
+
+
+
+#endregion
+
+ }
+}
diff --git a/ARW.Service/Business/IBusinessService/GoodsManager/Goodss/IGoodsService.cs b/ARW.Service/Business/IBusinessService/GoodsManager/Goodss/IGoodsService.cs
index 8e89668..721a917 100644
--- a/ARW.Service/Business/IBusinessService/GoodsManager/Goodss/IGoodsService.cs
+++ b/ARW.Service/Business/IBusinessService/GoodsManager/Goodss/IGoodsService.cs
@@ -27,6 +27,14 @@ namespace ARW.Service.Business.IBusinessService.GoodsManager.Goodss
Task> GetGoodsList(GoodsQueryDto parm);
+ ///
+ /// 获取全部商品列表
+ ///
+ ///
+ ///
+ Task> GetAllGoodsList(GoodsQueryDto parm);
+
+
///
/// 添加或修改商品
///
diff --git a/ARW.Service/Business/IBusinessService/Marketing/CouponManage/Coupons/ICouponService.cs b/ARW.Service/Business/IBusinessService/Marketing/CouponManage/Coupons/ICouponService.cs
new file mode 100644
index 0000000..ff625f3
--- /dev/null
+++ b/ARW.Service/Business/IBusinessService/Marketing/CouponManage/Coupons/ICouponService.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ARW.Model;
+using ARW.Model.Dto.Business.Marketing.CouponManage.Coupons;
+using ARW.Model.Models.Business.Marketing.CouponManage.Coupons;
+using ARW.Model.Vo.Business.Marketing.CouponManage.Coupons;
+
+namespace ARW.Service.Business.IBusinessService.Marketing.CouponManage.Coupons
+{
+ ///
+ /// 优惠券接口类
+ ///
+ /// @author lwh
+ /// @date 2023-07-24
+ ///
+ public interface ICouponService : IBaseService
+ {
+ ///
+ /// 获取优惠券分页列表
+ ///
+ ///
+ ///
+ Task> GetCouponList(CouponQueryDto parm);
+
+
+ ///
+ /// 添加或修改优惠券
+ ///
+ ///
+ ///
+ Task AddOrUpdateCoupon(Coupon parm);
+
+
+ ///
+ /// 数据导入处理
+ ///
+ ///
+ ///
+ Task HandleImportData(CouponVo CouponVo);
+
+
+ ///
+ /// Excel导入
+ ///
+ ///
+ ///
+ Task ImportExcel(Coupon Coupon,int index,bool isUpdateSupport,string user);
+
+ ///
+ /// Excel导出
+ ///
+ Task> HandleExportData(List data);
+
+
+ }
+}
diff --git a/ARW.WebApi/Controllers/Business/GoodsManager/Goodss/GoodsController.cs b/ARW.WebApi/Controllers/Business/GoodsManager/Goodss/GoodsController.cs
index a5c48a3..cc64522 100644
--- a/ARW.WebApi/Controllers/Business/GoodsManager/Goodss/GoodsController.cs
+++ b/ARW.WebApi/Controllers/Business/GoodsManager/Goodss/GoodsController.cs
@@ -89,6 +89,27 @@ namespace ARW.WebApi.Controllers.Business.GoodsManager.Goodss
}
+ ///
+ /// 获取全部商品列表
+ ///
+ /// 查询参数
+ ///
+ [HttpGet("getAllGoodsList")]
+ public async Task 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);
+ }
+
+
///
/// 获取商品Sku
///
diff --git a/ARW.WebApi/Controllers/Business/Marketing/CouponManage/Coupons/CouponController.cs b/ARW.WebApi/Controllers/Business/Marketing/CouponManage/Coupons/CouponController.cs
new file mode 100644
index 0000000..19df621
--- /dev/null
+++ b/ARW.WebApi/Controllers/Business/Marketing/CouponManage/Coupons/CouponController.cs
@@ -0,0 +1,180 @@
+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.Marketing.CouponManage.Coupons;
+using ARW.Service.Business.IBusinessService.Marketing.CouponManage.Coupons;
+using ARW.Admin.WebApi.Controllers;
+using ARW.Model.Models.Business.Marketing.CouponManage.Coupons;
+using ARW.Model.Vo.Business.Marketing.CouponManage.Coupons;
+using Microsoft.AspNetCore.Authorization;
+using ARW.Admin.WebApi.Framework;
+
+
+namespace ARW.WebApi.Controllers.Business.Marketing.CouponManage.Coupons
+{
+ ///
+ /// 优惠券控制器
+ ///
+ /// @author lwh
+ /// @date 2023-07-24
+ ///
+ [Verify]
+ [Route("business/[controller]")]
+ public class CouponController : BaseController
+ {
+ private readonly ICouponService _CouponService;
+
+ ///
+ /// 依赖注入
+ ///
+ /// 优惠券服务
+ public CouponController(ICouponService CouponService)
+ {
+ _CouponService = CouponService;
+ }
+
+
+ ///
+ /// 获取优惠券列表
+ ///
+ /// 查询参数
+ ///
+ [HttpGet("getCouponList")]
+ [ActionPermissionFilter(Permission = "business:coupon:list")]
+ public async Task GetCouponList([FromQuery] CouponQueryDto parm)
+ {
+ var res = await _CouponService.GetCouponList(parm);
+ return SUCCESS(res);
+ }
+
+ ///
+ /// 添加或修改优惠券
+ ///
+ ///
+ ///
+ [HttpPost("addOrUpdateCoupon")]
+ [ActionPermissionFilter(Permission = "business:coupon:addOrUpdate")]
+ [Log(Title = "添加或修改优惠券", BusinessType = BusinessType.ADDORUPDATE)]
+ public async Task AddOrUpdateCoupon([FromBody] CouponDto parm)
+ {
+ if (parm == null) { throw new CustomException("请求参数错误"); }
+
+ var modal = new Coupon();
+ if (parm.CouponId != 0) modal = parm.Adapt().ToUpdate(HttpContext);
+ else modal = parm.Adapt().ToCreate(HttpContext);
+
+ var res = await _CouponService.AddOrUpdateCoupon(modal);
+ return SUCCESS(res);
+ }
+
+ ///
+ /// 删除优惠券
+ ///
+ ///
+ [HttpDelete("{ids}")]
+ [ActionPermissionFilter(Permission = "business:coupon: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 = _CouponService.Delete(idsArr);
+ return SUCCESS("删除成功!");
+ }
+
+ ///
+ /// 导入优惠券
+ ///
+ /// 使用IFromFile必须使用name属性否则获取不到文件
+ /// 是否需要更新
+ ///
+ [HttpPost("importData")]
+ [Log(Title = "优惠券导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = false)]
+ [ActionPermissionFilter(Permission = "business:coupon:import")]
+ public async Task ImportExcel([FromForm(Name = "file")] IFormFile formFile,bool updateSupport)
+ {
+ var isUpdateSupport = updateSupport;
+ IEnumerable parm = ExcelHelper.ImportData(formFile.OpenReadStream());
+
+ var i = 0;
+ var msgList = new List();
+ foreach (CouponVo item in parm)
+ {
+ i++;
+ var Coupon = await _CouponService.HandleImportData(item);
+ var modal = Coupon.Adapt().ToCreate(HttpContext);
+ var user = JwtUtil.GetLoginUser(App.HttpContext).UserName;
+ var msg = await _CouponService.ImportExcel(modal,i,isUpdateSupport,user);
+ msgList.Add(msg);
+ }
+
+ return SUCCESS(msgList.ToArray());
+ }
+
+
+ ///
+ /// 优惠券导入模板下载
+ ///
+ ///
+ [HttpGet("importTemplate")]
+ [Log(Title = "优惠券模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = false, IsSaveResponseData = false)]
+ [AllowAnonymous]
+ public IActionResult ImportTemplateExcel()
+ {
+ List Coupon = new List();
+ MemoryStream stream = new MemoryStream();
+
+ // 示例数据
+ var values = new List() { "111", "222", "333" };
+ string sFileName = DownloadImportTemplate(Coupon, stream, "优惠券导入模板", values);
+
+ return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"{sFileName}");
+ }
+
+ ///
+ /// 导出优惠券
+ ///
+ ///
+ [Log(Title = "优惠券导出", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
+ [HttpGet("exportCoupon")]
+ [ActionPermissionFilter(Permission = "business:coupon:export")]
+ public async Task ExportExcel([FromQuery] CouponQueryDto parm)
+ {
+ parm.PageSize = 10000;
+ var list = await _CouponService.GetCouponList(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.CouponId == item).First();
+ selectDataList.Add(select_data);
+ }
+ data = selectDataList;
+ }
+
+
+
+ // 导出数据处理
+ var handleData = await _CouponService.HandleExportData(data);
+
+ string sFileName = ExportExcel(handleData, "Coupon", "优惠券列表");
+ return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
+ }
+
+
+
+
+ }
+}