优惠券
This commit is contained in:
@@ -247,11 +247,16 @@ FROM product_order where {where} GROUP BY Channel,ProductName order by Channel,
|
||||
}
|
||||
|
||||
|
||||
//是否已经设置会员价
|
||||
var is_user_price = true;
|
||||
|
||||
var price = packageEntity.Price;
|
||||
var userPrice = await this.m_ProductUserPriceService.Query(true).FirstOrDefaultAsync(m => m.UserId == userId && m.PackageId == packageEntity.Id && m.Status == 1);
|
||||
if (userPrice != null && userPrice.UserPrice > 0)
|
||||
{
|
||||
price = userPrice.UserPrice;
|
||||
is_user_price = false;
|
||||
}
|
||||
|
||||
if (ProductAccountCount == 0 && request.OrderType != OrderType.News && packageEntity.DayCount == 1 && request.ConnectCount == 1 && request.OrderType!=OrderType.AgainBuy&& request.OrderType!=OrderType.AgainBuys){
|
||||
price = 0.1M;
|
||||
@@ -329,7 +334,7 @@ FROM product_order where {where} GROUP BY Channel,ProductName order by Channel,
|
||||
|
||||
await CheckRequest(order);
|
||||
|
||||
var ret = await CaclePaymentAmount(order, request.UseAccountAmount);
|
||||
var ret = await CaclePaymentAmount(order, request.UseAccountAmount, is_user_price);
|
||||
|
||||
if (ret.Code != ResultCode.C_SUCCESS) return ret;
|
||||
|
||||
@@ -353,7 +358,7 @@ FROM product_order where {where} GROUP BY Channel,ProductName order by Channel,
|
||||
return new ApiResult<ProductOrderEntity>(order);
|
||||
}
|
||||
|
||||
public async Task<ApiResult<ProductOrderEntity>> CaclePaymentAmount(ProductOrderEntity order, int useAccountAmount)
|
||||
public async Task<ApiResult<ProductOrderEntity>> CaclePaymentAmount(ProductOrderEntity order, int useAccountAmount, bool is_user_price = true)
|
||||
{
|
||||
using (await _mutex1.LockAsync())
|
||||
{
|
||||
@@ -363,16 +368,33 @@ FROM product_order where {where} GROUP BY Channel,ProductName order by Channel,
|
||||
if (order.CouponId > 0)
|
||||
{
|
||||
var currentCoupon = await m_CouponService.GetOneUserAvailableCoupon(userEntity.Id, order.CouponId.Value);
|
||||
if (currentCoupon == null)
|
||||
return new ApiResult<ProductOrderEntity>(ResultCode.C_INVALID_ERROR, "没有可用的优惠券");
|
||||
if (currentCoupon.Coupon.AllowMinAmount > 0 && order.OrderAmount < currentCoupon.Coupon.AllowMinAmount)
|
||||
{
|
||||
return new ApiResult<ProductOrderEntity>(ResultCode.C_INVALID_ERROR, $"满{currentCoupon.Coupon.AllowMinAmount}元才能使用");
|
||||
if(currentCoupon.Coupon.Id<16 ){
|
||||
if(is_user_price){
|
||||
if (currentCoupon == null)
|
||||
return new ApiResult<ProductOrderEntity>(ResultCode.C_INVALID_ERROR, "没有可用的优惠券");
|
||||
if (currentCoupon.Coupon.AllowMinAmount > 0 && order.OrderAmount < currentCoupon.Coupon.AllowMinAmount)
|
||||
{
|
||||
return new ApiResult<ProductOrderEntity>(ResultCode.C_INVALID_ERROR, $"满{currentCoupon.Coupon.AllowMinAmount}元才能使用");
|
||||
}
|
||||
if (currentCoupon.Coupon.CouponType == Sells.Model.ECouponType.Minus)
|
||||
couponAmount = currentCoupon.Coupon.CouponValue;
|
||||
else
|
||||
couponAmount = order.OrderAmount * (currentCoupon.Coupon.CouponValue * 0.1m);
|
||||
} else {
|
||||
return new ApiResult<ProductOrderEntity>(ResultCode.C_INVALID_ERROR, "您已经享有会员优惠价,无法与优惠券共享!如有需求,请联系客服!");
|
||||
}
|
||||
} else {
|
||||
if (currentCoupon == null)
|
||||
return new ApiResult<ProductOrderEntity>(ResultCode.C_INVALID_ERROR, "没有可用的优惠券");
|
||||
if (currentCoupon.Coupon.AllowMinAmount > 0 && order.OrderAmount < currentCoupon.Coupon.AllowMinAmount)
|
||||
{
|
||||
return new ApiResult<ProductOrderEntity>(ResultCode.C_INVALID_ERROR, $"满{currentCoupon.Coupon.AllowMinAmount}元才能使用");
|
||||
}
|
||||
if (currentCoupon.Coupon.CouponType == Sells.Model.ECouponType.Minus)
|
||||
couponAmount = currentCoupon.Coupon.CouponValue;
|
||||
else
|
||||
couponAmount = order.OrderAmount * (currentCoupon.Coupon.CouponValue * 0.1m);
|
||||
}
|
||||
if (currentCoupon.Coupon.CouponType == Sells.Model.ECouponType.Minus)
|
||||
couponAmount = currentCoupon.Coupon.CouponValue;
|
||||
else
|
||||
couponAmount = order.OrderAmount * (currentCoupon.Coupon.CouponValue * 0.1m);
|
||||
}
|
||||
|
||||
order.CouponAmount = couponAmount;
|
||||
|
||||
Reference in New Issue
Block a user