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