fixed 优化细节
This commit is contained in:
parent
e1a6a8434a
commit
6a749274b9
@ -14,6 +14,7 @@ namespace ARW.Model.Dto.Api.Marketing.CouponManage.Coupons
|
||||
/// </summary>
|
||||
public class CouponQueryDtoApi : PagerInfo
|
||||
{
|
||||
public long ShopGuid { get; set; }
|
||||
public string CouponName { get; set; }
|
||||
public int? CouponType { get; set; }
|
||||
public int? CouponExpireType { get; set; }
|
||||
|
@ -17,6 +17,8 @@ namespace ARW.Model.Dto.Api.Marketing.CouponManage.CustomerCoupons
|
||||
[Required(ErrorMessage = "CustomerGuid不能为空")]
|
||||
public long CustomerGuid{ get; set; }
|
||||
|
||||
public long ShopGuid { get; set; }
|
||||
|
||||
public int Status { get; set; }
|
||||
}
|
||||
|
||||
|
@ -7,34 +7,16 @@ namespace ARW.Model.Dto.Api.OrderManage.Orders
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 订单查询对象Api
|
||||
/// 订单优惠券对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-09-01
|
||||
/// </summary>
|
||||
public class OrderQueryDtoApi : PagerInfo
|
||||
public class OrderCoupon
|
||||
{
|
||||
public string OrderNumber { get; set; }
|
||||
public int? PayType { get; set; }
|
||||
public int? PayStatus { get; set; }
|
||||
public int? DeliveryType { get; set; }
|
||||
public string LogisticsTrackingNumber { get; set; }
|
||||
public int? DeliveryStatus { get; set; }
|
||||
public int? ReceiptStatus { get; set; }
|
||||
public int OrderStatus { get; set; }
|
||||
public long ShopGuid { get; set; }
|
||||
public int Key { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 订单详情输入对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-09-01
|
||||
/// </summary>
|
||||
public class OrderDtoApi
|
||||
{
|
||||
[Required(ErrorMessage = "OrderGuid不能为空")]
|
||||
public long OrderGuid { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
40
ARW.Model/Dto/Api/OrderManage/Orders/OrderCoupon.cs
Normal file
40
ARW.Model/Dto/Api/OrderManage/Orders/OrderCoupon.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Models.Business.OrderManage.Orders;
|
||||
|
||||
namespace ARW.Model.Dto.Api.OrderManage.Orders
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 订单查询对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-09-01
|
||||
/// </summary>
|
||||
public class OrderQueryDtoApi : PagerInfo
|
||||
{
|
||||
public string OrderNumber { get; set; }
|
||||
public int? PayType { get; set; }
|
||||
public int? PayStatus { get; set; }
|
||||
public int? DeliveryType { get; set; }
|
||||
public string LogisticsTrackingNumber { get; set; }
|
||||
public int? DeliveryStatus { get; set; }
|
||||
public int? ReceiptStatus { get; set; }
|
||||
public int OrderStatus { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 订单详情输入对象Api
|
||||
///
|
||||
/// @author lwh
|
||||
/// @date 2023-09-01
|
||||
/// </summary>
|
||||
public class OrderDtoApi
|
||||
{
|
||||
[Required(ErrorMessage = "OrderGuid不能为空")]
|
||||
public long OrderGuid { get; set; }
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Dto.Api.OrderManage.Orders;
|
||||
using ARW.Model.Models.Business.Carts;
|
||||
|
||||
namespace ARW.Model.Dto.Api.Pay
|
||||
@ -54,5 +55,9 @@ namespace ARW.Model.Dto.Api.Pay
|
||||
/// </summary>
|
||||
public long CustomerAddressGuid { get; set; }
|
||||
|
||||
|
||||
|
||||
public List<OrderCoupon> CouponList;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -203,8 +203,13 @@ namespace ARW.Model.Models.Business.Marketing.CouponManage.Coupons
|
||||
public int CouponSort { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :优惠券状态(1: 正常 2: 失效)
|
||||
/// 空值 : false
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "优惠券状态")]
|
||||
[SugarColumn(ColumnName = "coupon_status")]
|
||||
public int CouponStatus { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,13 @@ namespace ARW.Model.Vo.Api.Marketing.CouponManage.CustomerCoupons
|
||||
public long CouponGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 : CouponGuid
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long ShopGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 : Key
|
||||
/// </summary>
|
||||
|
@ -159,5 +159,9 @@ namespace ARW.Model.Vo.Business.Marketing.CouponManage.Coupons
|
||||
public string CouponGoodsIdsArr { get; set; }
|
||||
[EpplusIgnore]
|
||||
public string[] CouponGoodsIds { get; set; }
|
||||
|
||||
public int CouponStatus { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ using ARW.Model.Dto.Api.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Models.Business.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Vo.Api.Marketing.CouponManage.Coupons;
|
||||
using Senparc.Weixin.WxOpen.AdvancedAPIs.Tcb;
|
||||
using ARW.Model.Vo.Api.Marketing.CouponManage.CustomerCoupons;
|
||||
using ARW.Repository.Business.Marketing.CouponManage.CustomerCoupons;
|
||||
|
||||
namespace ARW.Service.Api.BusinessService.Marketing.CouponManage.Coupons
|
||||
{
|
||||
@ -41,41 +43,52 @@ namespace ARW.Service.Api.BusinessService.Marketing.CouponManage.Coupons
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<PagedInfo<CouponVoApi>> GetCouponListApi(CouponQueryDtoApi parm)
|
||||
public async Task<List<CustomerCouponVoApi>> GetCouponListApi(CouponQueryDtoApi parm)
|
||||
{
|
||||
//开始拼装查询条件d
|
||||
var predicate = Expressionable.Create<Coupon>();
|
||||
|
||||
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);
|
||||
predicate = predicate.AndIF(parm.ShopGuid != 0, s => s.ShopGuid == parm.ShopGuid);
|
||||
var query = _CouponRepository
|
||||
.Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy(s => s.CouponSort, OrderByType.Desc)
|
||||
.Select(s => new CouponVoApi
|
||||
.Select(s => new CustomerCouponVoApi
|
||||
{
|
||||
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,
|
||||
ShopGuid = s.ShopGuid,
|
||||
Type = s.CouponType,
|
||||
Value = s.CouponDeductionMoney != 0 ? s.CouponDeductionMoney.ToString() : s.CouponDiscountRate.ToString(),
|
||||
Desc = s.CouponDesc,
|
||||
Title = s.CouponName,
|
||||
Base = s.CouponMinConsumeMoney,
|
||||
CreateTime = s.Create_time
|
||||
});
|
||||
|
||||
var list = await query.ToListAsync();
|
||||
|
||||
return await query.ToPageAsync(parm);
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
// 处理有效日期
|
||||
var coupon = await _CouponRepository.GetFirstAsync(s => s.CouponGuid == item.CouponGuid);
|
||||
if (coupon.CouponExpireType == 1)
|
||||
{
|
||||
var firstTime = item.CreateTime.ToString("yyyy.MM.dd");
|
||||
var lastTime = item.CreateTime.AddDays(coupon.CouponEffectiveDays).ToString("yyyy.MM.dd");
|
||||
item.TimeLimit = firstTime + "-" + lastTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
var firstTime = coupon.CouponFixedStartTime.ToString("yyyy.MM.dd");
|
||||
var lastTime = coupon.CouponFixedEndTime.ToString("yyyy.MM.dd");
|
||||
item.TimeLimit = firstTime + "-" + lastTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -58,6 +58,7 @@ namespace ARW.Service.Api.BusinessService.Marketing.CouponManage.CustomerCoupons
|
||||
.Queryable()
|
||||
.LeftJoin<Coupon>((s, c) => s.CouponGuid == c.CouponGuid)
|
||||
.Where(s => s.CustomerGuid == parm.CustomerGuid)
|
||||
.WhereIF(parm.ShopGuid != 0, (s, c) => c.ShopGuid == parm.ShopGuid)
|
||||
.WhereIF(parm.Status == 1, s => s.CustomerCouponIsUsed == 1 && s.CustomerCouponIsExpired == 1)
|
||||
.WhereIF(parm.Status == 2, s => s.CustomerCouponIsUsed == 2)
|
||||
.WhereIF(parm.Status == 3, s => s.CustomerCouponIsExpired == 2)
|
||||
@ -65,6 +66,7 @@ namespace ARW.Service.Api.BusinessService.Marketing.CouponManage.CustomerCoupons
|
||||
.Select((s, c) => new CustomerCouponVoApi
|
||||
{
|
||||
CouponGuid = c.CouponGuid,
|
||||
ShopGuid = c.ShopGuid,
|
||||
Key = s.CustomerCouponId,
|
||||
Type = c.CouponType,
|
||||
Value = c.CouponDeductionMoney != 0 ? c.CouponDeductionMoney.ToString() : c.CouponDiscountRate.ToString(),
|
||||
@ -151,7 +153,7 @@ namespace ARW.Service.Api.BusinessService.Marketing.CouponManage.CustomerCoupons
|
||||
var coupon = await _CouponRepository.GetFirstAsync(s => s.CouponGuid == data.CouponGuid);
|
||||
|
||||
// 使用范围
|
||||
if(coupon.CouponApplicableScope == 1)
|
||||
if (coupon.CouponApplicableScope == 1)
|
||||
data.StoreAdapt = "全部商品";
|
||||
if (coupon.CouponApplicableScope == 2)
|
||||
data.StoreAdapt = "指定商品";
|
||||
|
@ -152,7 +152,7 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
|
||||
jsApiUiPackage = payEntity,
|
||||
outTradeNo = orderNo,
|
||||
CreateTime = res.Create_time,
|
||||
OverTime = res.Create_time.AddMinutes(1)
|
||||
OverTime = res.Create_time.AddMinutes(30)
|
||||
};
|
||||
return payRes;
|
||||
|
||||
@ -256,9 +256,14 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
|
||||
var res = new DiscountRes();
|
||||
res.DiscountPrice = parm.TotalAmount;
|
||||
// 优惠券减免价格
|
||||
if (parm.CouponId != 0)
|
||||
if (parm.CouponList.Count > 0)
|
||||
{
|
||||
var coupon = await _CouponRepository.GetFirstAsync(s => s.CouponId == parm.CouponId);
|
||||
foreach (var item in parm.CouponList)
|
||||
{
|
||||
if(item.Key != 0)
|
||||
{
|
||||
var customerCoupon = await _CustomerCouponRepository.GetFirstAsync(s => s.CustomerCouponId == item.Key);
|
||||
var coupon = await _CouponRepository.GetFirstAsync(s => s.CouponGuid == customerCoupon.CouponGuid);
|
||||
if (coupon != null)
|
||||
{
|
||||
res.CouponGuid = coupon.CouponGuid;
|
||||
@ -270,7 +275,8 @@ namespace ARW.Service.Api.BusinessService.PaymentManage
|
||||
throw new CustomException($"优惠券Id为 {parm.CouponId} 找不到");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ using ARW.Model;
|
||||
using ARW.Model.Dto.Api.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Models.Business.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Vo.Api.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Vo.Api.Marketing.CouponManage.CustomerCoupons;
|
||||
|
||||
namespace ARW.Service.Api.IBusinessService.Marketing.CouponManage.Coupons
|
||||
{
|
||||
@ -23,7 +24,7 @@ namespace ARW.Service.Api.IBusinessService.Marketing.CouponManage.Coupons
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedInfo<CouponVoApi>> GetCouponListApi(CouponQueryDtoApi parm);
|
||||
Task<List<CustomerCouponVoApi>> GetCouponListApi(CouponQueryDtoApi parm);
|
||||
|
||||
/// <summary>
|
||||
/// 获取优惠券详情(Api)
|
||||
|
@ -15,6 +15,8 @@ using ARW.Model.Dto.Business.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Models.Business.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Vo.Business.Marketing.CouponManage.Coupons;
|
||||
using ARW.Model.Models.Business.ShopManager.Shops;
|
||||
using ARW.Common;
|
||||
using MySqlX.XDevAPI.Relational;
|
||||
|
||||
namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
||||
{
|
||||
@ -79,17 +81,13 @@ namespace ARW.Service.Business.BusinessService.Marketing.CouponManage.Coupons
|
||||
CouponDisplayStatus = s.CouponDisplayStatus,
|
||||
CouponSort = s.CouponSort,
|
||||
CouponApplicableScopeConfig = s.CouponApplicableScopeConfig,
|
||||
CouponGoodsIdsArr = s.CouponGoodsIds
|
||||
CouponGoodsIdsArr = s.CouponGoodsIds,
|
||||
CouponStatus = s.CouponStatus,
|
||||
});
|
||||
|
||||
|
||||
var list = await query.ToPageAsync(parm);
|
||||
|
||||
//foreach (var item in list.Result)
|
||||
//{
|
||||
// item.CouponGoodsIds = item.CouponGoodsIdsArr.Split(',');
|
||||
//}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user