/// <summary> /// 延期优惠券 /// </summary> /// <param name="request"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async ValueTask <OperationResult <bool> > DelayCouponEndTimeAsync(DelayCouponEndTimeRequest request, CancellationToken cancellationToken) { var coupon = await _PromotionCodeRepository.GetCouponByIDAsync(request.PromotionPKID, cancellationToken).ConfigureAwait(false); if (coupon == null) { return(OperationResult.FromError <bool>("-1", "优惠券不存在")); } if (coupon.UserId != request.UserID) { return(OperationResult.FromError <bool>("-2", "优惠券所属人不匹配 请检查入参userid")); } if (coupon.Status != 0) { return(OperationResult.FromError <bool>("-2", "优惠券已使用或者已作废")); } var result = await _PromotionCodeRepository.DelayCouponEndTimeAsync(request, cancellationToken).ConfigureAwait(false); if (result) { PromotionOprLogEntity entity = ObjectMapper.ConvertTo <DelayCouponEndTimeRequest, PromotionOprLogEntity> (request); entity.Referer = request.Message; entity.UserID = coupon.UserId; entity.Operation = CouponOperateEnum.延期.ToString(); entity.OperationDetail = string.Format("OldEndTime={0};NewEndTime={1}", coupon.EndTime, request.EndTime); await _IPromotionOprLogRepository.CreateAsync(entity, cancellationToken).ConfigureAwait(false); } return(OperationResult.FromResult(result)); }
/// <summary> /// 延期优惠券 /// </summary> /// <param name="request"></param> /// <returns></returns> public async override ValueTask <OperationResult <bool> > DelayCouponEndTimeAsync([FromBody] DelayCouponEndTimeRequest request) { if (!request.IsPassed) { return(OperationResult.FromError <bool>("-1", request.ErrorMsg)); } return(await _CouponManager.DelayCouponEndTimeAsync(request, HttpContext.RequestAborted).ConfigureAwait(false)); }