/// <summary>
        /// 适配优惠券
        /// </summary>
        /// <returns></returns>
        public async Task <string> SelectCouponAsync()
        {
            var workRules = new RulesEngine.Models.WorkflowRules();

            workRules.WorkflowName = "优惠券";
            var rules = new List <Rule>();

            foreach (var coupon in _userCoupons.Where(s => s.BeginTime <DateTime.Now && s.EndTime> DateTime.Now))
            {
                var rule = new Rule
                {
                    RuleName     = coupon.Name,
                    SuccessEvent = coupon.Code,
                    //ErrorMessage = "规则应用失败",
                    ErrorType          = ErrorType.Error,
                    RuleExpressionType = RuleExpressionType.LambdaExpression,
                    Expression         = coupon.Expression
                };
                rules.Add(rule);
            }
            workRules.Rules = rules;
            var rulesEngine = new RulesEngine.RulesEngine(new WorkflowRules[] { workRules }, _logger, new ReSettings());
            var ruleResults = await rulesEngine.ExecuteAllRulesAsync("优惠券", _order, _user, _goodses);

            // var valueCoupons = new List<string>();
            //处理结果
            var discountCoupons = new StringBuilder();

            foreach (var ruleResult in ruleResults)
            {
                if (ruleResult.IsSuccess)
                {
                    discountCoupons.AppendLine($"可以使用的优惠券 “{_userCoupons.SingleOrDefault(s => s.Code == ruleResult.Rule.SuccessEvent)?.Name}”, Code是:{ruleResult.Rule.SuccessEvent}");
                    //valueCoupons.Add(ruleResult.Rule.SuccessEvent);
                }
                else
                {
                    Console.WriteLine(ruleResult.ExceptionMessage);
                }
            }
            //resultList.OnSuccess((eventName) =>
            //{
            //    discountOffered += $"可以使用的优惠券“{userCoupons.SingleOrDefault(s => s.Code == eventName)?.Name}”,Code是:{eventName} ";
            //});
            ruleResults.OnFail(() =>
            {
                discountCoupons.AppendLine("您没有适合的优惠券!");
            });
            return(discountCoupons.ToString());
        }
        public async Task <string> Get()
        {
            var workRules = new RulesEngine.Models.WorkflowRules();

            workRules.WorkflowName = "折扣";
            workRules.Rules        = new List <Rule>
            {
                new Rule
                {
                    RuleName           = "活动一",
                    SuccessEvent       = "10",
                    ErrorMessage       = "One or more adjust rules failed.",
                    ErrorType          = ErrorType.Error,
                    RuleExpressionType = RuleExpressionType.LambdaExpression,
                    Expression         = "input1.country == \"india\" AND input1.loyalityFactor <= 2 AND input1.totalPurchasesToDate >= 5000"
                },
                new Rule
                {
                    RuleName           = "活动二",
                    SuccessEvent       = "20",
                    ErrorMessage       = "One or more adjust rules failed.",
                    ErrorType          = ErrorType.Error,
                    RuleExpressionType = RuleExpressionType.LambdaExpression,
                    Expression         = "input1.country == \"india\" AND input1.loyalityFactor >= 3 AND input1.totalPurchasesToDate >= 10000"
                },
            };
            var rulesEngine = new RulesEngine.RulesEngine(new WorkflowRules[] { workRules }, _logger, new ReSettings());
            var resultList  = await rulesEngine.ExecuteAllRulesAsync("折扣", new Country
            {
                loyalityFactor       = 5,
                totalPurchasesToDate = 20000
            });

            var discountOffered = "";

            resultList.OnSuccess((eventName) =>
            {
                discountOffered = $"Discount offered is {eventName} % over MRP.";
            });
            resultList.OnFail(() =>
            {
                discountOffered = "The user is not eligible for any discount.";
            });
            return(discountOffered);
        }